/** * npm package specification utilities for Socket CLI. * Parses and handles various npm package specification formats. * * Supported Formats: * - Regular packages: lodash, lodash@4.17.21 * - Scoped packages: @types/node, @types/node@20.0.0 * - Version ranges: lodash@^4.0.0, lodash@~4.17.0 * - Git URLs: git+https://github.com/user/repo.git * - File paths: file:../local-package * - Aliases: my-alias@npm:real-package@1.0.0 * * Key Functions: * - safeNpa: Safe wrapper for npm-package-arg * - safeNpmSpecToPurl: Convert npm spec to PURL * - safeParseNpmSpec: Parse npm spec to name/version * * Error Handling: * - Returns undefined for invalid specs * - Fallback parsing for edge cases * - Safe against malformed input */ import npmPackageArg from 'npm-package-arg'; export type { AliasResult, FileResult, HostedGit, HostedGitResult, RegistryResult, Result, URLResult, } from 'npm-package-arg'; export type ParsedPackageSpec = { name: string; version: string | undefined; }; /** * Safe wrapper for npm-package-arg that doesn't throw. * Returns undefined if parsing fails. */ export declare function safeNpa(...args: Parameters): ReturnType | undefined; /** * Parse npm package specification into name and version. * Uses npm-package-arg for proper handling of various spec formats: * - Regular packages: lodash, lodash@4.17.21 * - Scoped packages: @types/node, @types/node@20.0.0 * - Version ranges: lodash@^4.0.0 * - Git URLs, file paths, etc. * * Returns undefined if parsing fails. */ export declare function safeParseNpmSpec(pkgSpec: string): ParsedPackageSpec | undefined; /** * Convert npm package spec to PURL string. * Handles various npm spec formats and converts them to standardized PURLs. * Returns undefined if conversion fails. */ export declare function safeNpmSpecToPurl(pkgSpec: string): string | undefined; /** * Convert npm package spec to PURL string. * Handles various npm spec formats and converts them to standardized PURLs. * Throws if conversion fails. */ export declare function npmSpecToPurl(pkgSpec: string): string; //# sourceMappingURL=npm-spec.d.mts.map