@agntn/registries 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +26 -3
  2. package/dist/THIRD-PARTY-LICENSES.md +36 -0
  3. package/dist/_chunks/cache.mjs +15 -0
  4. package/dist/{cache/index.mjs.map → _chunks/cache.mjs.map} +1 -1
  5. package/dist/{commands/cache.mjs → _chunks/cache2.mjs} +6 -8
  6. package/dist/_chunks/cache2.mjs.map +1 -0
  7. package/dist/{cache → _chunks}/cached-registry.mjs +12 -8
  8. package/dist/_chunks/cached-registry.mjs.map +1 -0
  9. package/dist/{commands → _chunks}/deps.mjs +19 -13
  10. package/dist/_chunks/deps.mjs.map +1 -0
  11. package/dist/_chunks/helpers.mjs +53 -19
  12. package/dist/_chunks/helpers.mjs.map +1 -1
  13. package/dist/_chunks/index.d.mts +9 -23
  14. package/dist/_chunks/index.d.mts.map +1 -1
  15. package/dist/_chunks/index2.d.mts +181 -0
  16. package/dist/_chunks/index2.d.mts.map +1 -0
  17. package/dist/_chunks/index3.d.mts +188 -0
  18. package/dist/_chunks/index3.d.mts.map +1 -0
  19. package/dist/_chunks/info.mjs +105 -0
  20. package/dist/_chunks/info.mjs.map +1 -0
  21. package/dist/_chunks/libs/typebox.mjs +278 -0
  22. package/dist/_chunks/libs/typebox.mjs.map +1 -0
  23. package/dist/_chunks/lockfile.mjs +183 -0
  24. package/dist/_chunks/lockfile.mjs.map +1 -0
  25. package/dist/_chunks/maintainers.mjs +53 -0
  26. package/dist/_chunks/maintainers.mjs.map +1 -0
  27. package/dist/_chunks/mcp.mjs +15 -0
  28. package/dist/_chunks/mcp.mjs.map +1 -0
  29. package/dist/_chunks/registries.mjs +514 -245
  30. package/dist/_chunks/registries.mjs.map +1 -1
  31. package/dist/_chunks/registry.d.mts +121 -10
  32. package/dist/_chunks/registry.d.mts.map +1 -1
  33. package/dist/_chunks/registry.mjs +121 -31
  34. package/dist/_chunks/registry.mjs.map +1 -1
  35. package/dist/{commands → _chunks}/shared.mjs +15 -8
  36. package/dist/_chunks/shared.mjs.map +1 -0
  37. package/dist/_chunks/tool-operations.mjs +63 -0
  38. package/dist/_chunks/tool-operations.mjs.map +1 -0
  39. package/dist/_chunks/version.mjs +4 -0
  40. package/dist/_chunks/version.mjs.map +1 -0
  41. package/dist/{commands → _chunks}/versions.mjs +10 -9
  42. package/dist/_chunks/versions.mjs.map +1 -0
  43. package/dist/ai.d.mts +4 -4
  44. package/dist/ai.mjs +0 -1
  45. package/dist/ai.mjs.map +1 -1
  46. package/dist/cache/index.d.mts +3 -23
  47. package/dist/cache/index.mjs +4 -11
  48. package/dist/cli.mjs +9 -7
  49. package/dist/cli.mjs.map +1 -1
  50. package/dist/index.d.mts +4 -56
  51. package/dist/index.mjs +4 -7
  52. package/dist/mcp.d.mts +7 -0
  53. package/dist/mcp.d.mts.map +1 -0
  54. package/dist/mcp.mjs +155 -0
  55. package/dist/mcp.mjs.map +1 -0
  56. package/dist/registries/index.d.mts +0 -1
  57. package/dist/registries/index.mjs +0 -1
  58. package/dist/tool-operations.d.mts +36 -0
  59. package/dist/tool-operations.d.mts.map +1 -0
  60. package/dist/tool-operations.mjs +5 -0
  61. package/package.json +55 -9
  62. package/packages/omp/extensions/registries.ts +112 -0
  63. package/packages/pi/extensions/registries.ts +125 -0
  64. package/dist/_chunks/errors.d.mts +0 -90
  65. package/dist/_chunks/errors.d.mts.map +0 -1
  66. package/dist/_chunks/purl.mjs +0 -200
  67. package/dist/_chunks/purl.mjs.map +0 -1
  68. package/dist/_chunks/types.d.mts +0 -73
  69. package/dist/_chunks/types.d.mts.map +0 -1
  70. package/dist/cache/cached-registry.d.mts +0 -35
  71. package/dist/cache/cached-registry.d.mts.map +0 -1
  72. package/dist/cache/cached-registry.mjs.map +0 -1
  73. package/dist/cache/index.d.mts.map +0 -1
  74. package/dist/cache/lockfile.d.mts +0 -50
  75. package/dist/cache/lockfile.d.mts.map +0 -1
  76. package/dist/cache/lockfile.mjs +0 -68
  77. package/dist/cache/lockfile.mjs.map +0 -1
  78. package/dist/cache/paths.d.mts +0 -11
  79. package/dist/cache/paths.d.mts.map +0 -1
  80. package/dist/cache/paths.mjs +0 -26
  81. package/dist/cache/paths.mjs.map +0 -1
  82. package/dist/cache/storage.d.mts +0 -22
  83. package/dist/cache/storage.d.mts.map +0 -1
  84. package/dist/cache/storage.mjs +0 -40
  85. package/dist/cache/storage.mjs.map +0 -1
  86. package/dist/commands/cache.d.mts +0 -7
  87. package/dist/commands/cache.d.mts.map +0 -1
  88. package/dist/commands/cache.mjs.map +0 -1
  89. package/dist/commands/deps.d.mts +0 -23
  90. package/dist/commands/deps.d.mts.map +0 -1
  91. package/dist/commands/deps.mjs.map +0 -1
  92. package/dist/commands/info.d.mts +0 -26
  93. package/dist/commands/info.d.mts.map +0 -1
  94. package/dist/commands/info.mjs +0 -54
  95. package/dist/commands/info.mjs.map +0 -1
  96. package/dist/commands/maintainers.d.mts +0 -23
  97. package/dist/commands/maintainers.d.mts.map +0 -1
  98. package/dist/commands/maintainers.mjs +0 -46
  99. package/dist/commands/maintainers.mjs.map +0 -1
  100. package/dist/commands/shared.d.mts +0 -27
  101. package/dist/commands/shared.d.mts.map +0 -1
  102. package/dist/commands/shared.mjs.map +0 -1
  103. package/dist/commands/versions.d.mts +0 -31
  104. package/dist/commands/versions.d.mts.map +0 -1
  105. package/dist/commands/versions.mjs.map +0 -1
  106. package/dist/core/index.d.mts +0 -4
  107. package/dist/core/index.mjs +0 -3
  108. package/dist/index.d.mts.map +0 -1
  109. package/dist/types.d.mts +0 -3
  110. package/dist/types.mjs +0 -1
@@ -0,0 +1,181 @@
1
+ import { d as Package, f as ParsedPURL, g as Version, h as URLBuilder, l as Dependency, o as Client, t as Registry, u as Maintainer } from "./registry.mjs";
2
+
3
+ //#region src/core/purl.d.ts
4
+ /**
5
+ * Parse a package URL into normalized components.
6
+ *
7
+ * @param purlStr - Package URL to parse.
8
+ * @returns {ParsedPURL} The normalized components.
9
+ * @see https://github.com/package-url/purl-spec (ECMA-427)
10
+ */
11
+ declare function parsePURL(purlStr: string): ParsedPURL;
12
+ /**
13
+ * Build a registry package name from PURL components.
14
+ *
15
+ * @param parsed - Parsed package URL components.
16
+ * @returns {string} The namespace-qualified package name.
17
+ */
18
+ declare function fullName(parsed: ParsedPURL): string;
19
+ /**
20
+ * Create a registry from a package URL.
21
+ *
22
+ * @param purlStr - Package URL to resolve.
23
+ * @param client - Optional HTTP client.
24
+ * @returns {[Registry, string, string]} The registry, package name, and version.
25
+ */
26
+ declare function createFromPURL(purlStr: string, client?: Client): [Registry, string, string];
27
+ /**
28
+ * Build a package URL from normalized components.
29
+ *
30
+ * @param parts - Package URL components.
31
+ * @returns {string} The canonical package URL.
32
+ */
33
+ declare function buildPURL(parts: Readonly<{
34
+ type: string;
35
+ name: string;
36
+ version?: string;
37
+ namespace?: string;
38
+ qualifiers?: Readonly<Record<string, string>>;
39
+ subpath?: string;
40
+ }>): string;
41
+ //#endregion
42
+ //#region src/core/license.d.ts
43
+ /**
44
+ * Normalize common license names to SPDX expressions.
45
+ *
46
+ * @param raw - License name or SPDX expression.
47
+ * @returns {string} The normalized SPDX expression, or an empty string.
48
+ */
49
+ declare function normalizeLicense(raw: string | null | undefined): string;
50
+ /**
51
+ * Combine license strings into one SPDX expression.
52
+ *
53
+ * @param licenses - License names or expressions to normalize.
54
+ * @param operator - SPDX operator joining multiple licenses.
55
+ * @returns {string} The combined SPDX expression, or an empty string.
56
+ */
57
+ declare function combineLicenses(licenses: readonly (string | null | undefined)[], operator?: "OR" | "AND"): string;
58
+ //#endregion
59
+ //#region src/core/repository.d.ts
60
+ /**
61
+ * Normalize repository shorthands and Git transports to HTTPS.
62
+ *
63
+ * @param raw - Repository URL string or object with a URL field.
64
+ * @returns {string} The normalized URL, or an empty string.
65
+ */
66
+ declare function normalizeRepositoryURL(raw: unknown): string;
67
+ //#endregion
68
+ //#region src/core/errors.d.ts
69
+ /** Custom error types for registry operations. */
70
+ declare class PkioError extends Error {
71
+ constructor(message: string, options?: ErrorOptions);
72
+ }
73
+ declare class HTTPError extends PkioError {
74
+ readonly statusCode: number;
75
+ readonly url: string;
76
+ readonly body: string;
77
+ constructor(statusCode: number, url: string, body: string);
78
+ isNotFound(): boolean;
79
+ isRateLimit(): boolean;
80
+ isServerError(): boolean;
81
+ }
82
+ declare class NotFoundError extends PkioError {
83
+ readonly ecosystem: string;
84
+ readonly packageName: string;
85
+ readonly version: string;
86
+ constructor(ecosystem: string, packageName: string, version?: string);
87
+ }
88
+ declare class RateLimitError extends PkioError {
89
+ readonly retryAfter: number;
90
+ constructor(retryAfter: number);
91
+ }
92
+ declare class UnknownEcosystemError extends PkioError {
93
+ readonly ecosystem: string;
94
+ constructor(ecosystem: string);
95
+ }
96
+ declare class InvalidPURLError extends PkioError {
97
+ readonly purl: string;
98
+ constructor(purl: string, reason: string);
99
+ }
100
+ //#endregion
101
+ //#region src/helpers.d.ts
102
+ /**
103
+ * Fetch normalized package metadata from a package URL.
104
+ *
105
+ * @param purl - Package URL.
106
+ * @param signal - Optional cancellation signal.
107
+ * @param client - Optional HTTP client.
108
+ * @returns {Promise<Package>} Normalized package metadata.
109
+ */
110
+ declare function fetchPackageFromPURL(purl: string, signal?: AbortSignal, client?: Client): Promise<Package>;
111
+ /**
112
+ * Fetch all versions from a package URL.
113
+ *
114
+ * @param purl - Package URL.
115
+ * @param signal - Optional cancellation signal.
116
+ * @param client - Optional HTTP client.
117
+ * @returns {Promise<Version[]>} Normalized versions.
118
+ */
119
+ declare function fetchVersionsFromPURL(purl: string, signal?: AbortSignal, client?: Client): Promise<Version[]>;
120
+ /**
121
+ * Fetch dependencies for a versioned package URL.
122
+ *
123
+ * @param purl - Versioned package URL.
124
+ * @param signal - Optional cancellation signal.
125
+ * @param client - Optional HTTP client.
126
+ * @returns {Promise<Dependency[]>} Normalized dependencies.
127
+ */
128
+ declare function fetchDependenciesFromPURL(purl: string, signal?: AbortSignal, client?: Client): Promise<Dependency[]>;
129
+ /**
130
+ * Fetch maintainers from a package URL.
131
+ *
132
+ * @param purl - Package URL.
133
+ * @param signal - Optional cancellation signal.
134
+ * @param client - Optional HTTP client.
135
+ * @returns {Promise<Maintainer[]>} Normalized maintainers.
136
+ */
137
+ declare function fetchMaintainersFromPURL(purl: string, signal?: AbortSignal, client?: Client): Promise<Maintainer[]>;
138
+ /**
139
+ * Fetch packages concurrently, skipping failed lookups.
140
+ *
141
+ * @param purls - Package URLs to fetch.
142
+ * @param options - Optional concurrency, cancellation, and client settings.
143
+ * @returns {Promise<Map<string, Package>>} Results keyed by package URL.
144
+ */
145
+ declare function bulkFetchPackages(purls: readonly string[], options?: Readonly<{
146
+ concurrency?: number;
147
+ signal?: AbortSignal;
148
+ client?: Client;
149
+ }>): Promise<Map<string, Package>>;
150
+ /**
151
+ * Select an exact requested or latest version, then the newest usable one.
152
+ *
153
+ * @param versions - Candidate versions.
154
+ * @param options - Optional requested and latest version numbers.
155
+ * @returns {Version | null} The selected version, or null.
156
+ */
157
+ declare function selectVersion(versions: readonly Version[], options?: Readonly<{
158
+ requested?: string;
159
+ latest?: string;
160
+ }>): Version | null;
161
+ /**
162
+ * Resolve the best documentation URL for a package.
163
+ *
164
+ * @param pkg - Package metadata.
165
+ * @param urls - Ecosystem URL builder.
166
+ * @param version - Optional package version.
167
+ * @returns {string} The explicit, homepage, or ecosystem documentation URL.
168
+ */
169
+ declare function resolveDocsUrl(pkg: Package, urls: URLBuilder, version?: string): string;
170
+ /**
171
+ * Resolve the ecosystem README URL for a package.
172
+ *
173
+ * @param pkg - Package metadata.
174
+ * @param urls - Ecosystem URL builder.
175
+ * @param version - Optional package version.
176
+ * @returns {string} The README URL.
177
+ */
178
+ declare function resolveReadmeUrl(pkg: Package, urls: URLBuilder, version?: string): string;
179
+ //#endregion
180
+ export { normalizeLicense as _, fetchVersionsFromPURL as a, fullName as b, selectVersion as c, NotFoundError as d, PkioError as f, combineLicenses as g, normalizeRepositoryURL as h, fetchPackageFromPURL as i, HTTPError as l, UnknownEcosystemError as m, fetchDependenciesFromPURL as n, resolveDocsUrl as o, RateLimitError as p, fetchMaintainersFromPURL as r, resolveReadmeUrl as s, bulkFetchPackages as t, InvalidPURLError as u, buildPURL as v, parsePURL as x, createFromPURL as y };
181
+ //# sourceMappingURL=index2.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.d.mts","names":[],"sources":["../../src/core/purl.ts","../../src/core/license.ts","../../src/core/repository.ts","../../src/core/errors.ts","../../src/helpers.ts"],"mappings":";;;AAiEA;;;;;AAmEA;;AAnEA,iBAAgB,SAAA,CAAU,OAAA,WAAkB,UAAA;;;AAiF5C;;;;iBAdgB,QAAA,CAAS,MAAA,EAAQ,UAAA;;;;;;AA2BjC;;iBAbgB,cAAA,CAAe,OAAA,UAAiB,MAAA,GAAS,MAAA,IAAU,QAAA;;;;;;;iBAanD,SAAA,CACd,KAAA,EAAO,QAAA;EACL,IAAA;EACA,IAAA;EACA,OAAA;EACA,SAAA;EACA,UAAA,GAAa,QAAA,CAAS,MAAA;EACtB,OAAA;AAAA;;;;;;AArGJ;;;iBC3DgB,gBAAA,CAAiB,GAAA;;AD8HjC;;;;;AAcA;iBClFgB,eAAA,CACd,QAAA,0CACA,QAAA;;;;;;ADDF;;;iBE/BgB,sBAAA,CAAuB,GAAA;;;;cChC1B,SAAA,SAAkB,KAAA;cACjB,OAAA,UAAiB,OAAA,GAAU,YAAA;AAAA;AAAA,cAM5B,SAAA,SAAkB,SAAA;EAAA,SACpB,UAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA;cAEG,UAAA,UAAoB,GAAA,UAAa,IAAA;EAQ7C,UAAA,CAAA;EAIA,WAAA,CAAA;EAIA,aAAA,CAAA;AAAA;AAAA,cAKW,aAAA,SAAsB,SAAA;EAAA,SACxB,SAAA;EAAA,SACA,WAAA;EAAA,SACA,OAAA;cAEG,SAAA,UAAmB,WAAA,UAAqB,OAAA;AAAA;AAAA,cAUzC,cAAA,SAAuB,SAAA;EAAA,SACzB,UAAA;cAEG,UAAA;AAAA;AAAA,cAOD,qBAAA,SAA8B,SAAA;EAAA,SAChC,SAAA;cAEG,SAAA;AAAA;AAAA,cAOD,gBAAA,SAAyB,SAAA;EAAA,SAC3B,IAAA;cAEG,IAAA,UAAc,MAAA;AAAA;;;;AHR5B;;;;;AAmEA;;iBIvHsB,oBAAA,CACpB,IAAA,UACA,MAAA,GAAS,WAAA,EACT,MAAA,GAAS,MAAA,GACR,OAAA,CAAQ,OAAA;;;AJiIX;;;;;;iBIpHsB,qBAAA,CACpB,IAAA,UACA,MAAA,GAAS,WAAA,EACT,MAAA,GAAS,MAAA,GACR,OAAA,CAAQ,OAAA;;;;AJ6HX;;;;;iBIhHsB,yBAAA,CACpB,IAAA,UACA,MAAA,GAAS,WAAA,EACT,MAAA,GAAS,MAAA,GACR,OAAA,CAAQ,UAAA;;;;;;;;;iBAgBW,wBAAA,CACpB,IAAA,UACA,MAAA,GAAS,WAAA,EACT,MAAA,GAAS,MAAA,GACR,OAAA,CAAQ,UAAA;;;;;;;;iBAcW,iBAAA,CACpB,KAAA,qBACA,OAAA,GAAU,QAAA;EAAW,WAAA;EAAsB,MAAA,GAAS,WAAA;EAAa,MAAA,GAAS,MAAA;AAAA,KACzE,OAAA,CAAQ,GAAA,SAAY,OAAA;;AHxBvB;;;;;;iBGyDgB,aAAA,CACd,QAAA,WAAmB,OAAA,IACnB,OAAA,GAAU,QAAA;EACR,SAAA;EACA,MAAA;AAAA,KAED,OAAA;;;;;;;AD7HH;;iBC8JgB,cAAA,CAAe,GAAA,EAAK,OAAA,EAAS,IAAA,EAAM,UAAA,EAAY,OAAA;;;;;;;;;iBAY/C,gBAAA,CAAiB,GAAA,EAAK,OAAA,EAAS,IAAA,EAAM,UAAA,EAAY,OAAA"}
@@ -0,0 +1,188 @@
1
+ import { d as Package, g as Version, h as URLBuilder, l as Dependency, o as Client, t as Registry, u as Maintainer } from "./registry.mjs";
2
+ import { Storage } from "unstorage";
3
+
4
+ //#region src/cache/paths.d.ts
5
+ /**
6
+ * Resolve the cache directory using the current platform convention.
7
+ *
8
+ * @returns {string} The absolute cache directory path.
9
+ */
10
+ declare function getCacheDir(): string;
11
+ //#endregion
12
+ //#region src/cache/storage.d.ts
13
+ /**
14
+ * Configure the storage backend before the first cache operation.
15
+ *
16
+ * @param storage - Storage backend to use.
17
+ */
18
+ declare function configureStorage(storage: Storage): void;
19
+ /**
20
+ * Get or create the shared storage backend.
21
+ *
22
+ * @returns {Storage} The configured or filesystem-backed storage.
23
+ */
24
+ declare function getStorage(): Storage;
25
+ /**
26
+ * Get storage scoped to one registry ecosystem.
27
+ *
28
+ * @param ecosystem - Registry ecosystem key.
29
+ * @returns {Storage} Namespaced storage for the ecosystem.
30
+ */
31
+ declare function getEcosystemStorage(ecosystem: string): Storage;
32
+ /**
33
+ * Compute a SHA-256 integrity value for JSON-serializable data.
34
+ *
35
+ * @param value - Value to hash.
36
+ * @returns {string} The prefixed hexadecimal digest.
37
+ */
38
+ declare function computeIntegrity(value: unknown): string;
39
+ /** Dispose the storage instance. Call on process exit. */
40
+ declare function disposeStorage(): Promise<void>;
41
+ /** Clear all cached data. */
42
+ declare function clearStorage(): Promise<void>;
43
+ //#endregion
44
+ //#region src/cache/cached-registry.d.ts
45
+ /**
46
+ * CachedRegistry wraps any Registry and adds caching backed by unstorage
47
+ * with a lockfile for freshness tracking.
48
+ *
49
+ * Pass a custom `storage` to use a non-default driver (e.g. Cloudflare KV).
50
+ * If omitted, uses the globally configured storage (see `configureStorage()`).
51
+ */
52
+ declare class CachedRegistry extends Registry {
53
+ readonly inner: Registry;
54
+ readonly storage: Storage;
55
+ private readonly lockfileStorage;
56
+ private readonly inflight;
57
+ constructor(inner: Registry, storage?: Storage);
58
+ ecosystem(): string;
59
+ urls(): URLBuilder;
60
+ fetchPackage(name: string, signal?: AbortSignal): Promise<Package>;
61
+ fetchVersions(name: string, signal?: AbortSignal): Promise<Version[]>;
62
+ fetchDependencies(name: string, version: string, signal?: AbortSignal): Promise<Dependency[]>;
63
+ fetchMaintainers(name: string, signal?: AbortSignal): Promise<Maintainer[]>;
64
+ /**
65
+ * Read a fresh cached value or fetch and persist its replacement.
66
+ *
67
+ * @param name - Package name.
68
+ * @param type - Cached data type.
69
+ * @param version - Package version when the cache entry is versioned.
70
+ * @param fetcher - Upstream operation used after a cache miss.
71
+ * @param signal - Optional cancellation signal.
72
+ * @param extraMeta - Optional lockfile metadata derived from the fetched value.
73
+ * @returns {Promise<T>} The cached or freshly fetched value.
74
+ */
75
+ private cached;
76
+ }
77
+ //#endregion
78
+ //#region src/cache/lockfile.d.ts
79
+ /** Default TTL per data type (seconds). */
80
+ declare const DEFAULT_TTL: {
81
+ readonly package: 3600;
82
+ readonly versions: 1800;
83
+ readonly dependencies: 86400;
84
+ readonly maintainers: 86400;
85
+ };
86
+ type EntryType = keyof typeof DEFAULT_TTL;
87
+ /** A single cached entry tracked in the lockfile. */
88
+ interface LockfileEntry {
89
+ /** PURL-style key: 'npm:lodash', 'cargo:serde' */
90
+ key: string;
91
+ /** What kind of data: package, versions, dependencies, maintainers */
92
+ type: EntryType;
93
+ /** Unix timestamp (ms) when fetched */
94
+ fetchedAt: number;
95
+ /** TTL in seconds */
96
+ ttl: number;
97
+ /** Latest version at time of caching (for package entries) */
98
+ latestVersion?: string;
99
+ /** Content hash (sha256 of JSON-serialized value) for integrity */
100
+ integrity: string;
101
+ }
102
+ /** The full lockfile structure. */
103
+ interface Lockfile {
104
+ version: number;
105
+ entries: Record<string, LockfileEntry>;
106
+ }
107
+ /**
108
+ * Read the lockfile, falling back to an empty valid structure.
109
+ *
110
+ * @param storage - Optional storage backend.
111
+ * @returns {Promise<Lockfile>} The stored or empty lockfile.
112
+ */
113
+ declare function readLockfile(storage?: Storage): Promise<Lockfile>;
114
+ /**
115
+ * Persist the lockfile.
116
+ *
117
+ * @param lockfile - Lockfile to persist.
118
+ * @param storage - Optional storage backend.
119
+ */
120
+ declare function writeLockfile(lockfile: Lockfile, storage?: Storage): Promise<void>;
121
+ /**
122
+ * Build a stable cache key.
123
+ *
124
+ * @param ecosystem - Registry ecosystem.
125
+ * @param name - Package name.
126
+ * @param type - Cached data type.
127
+ * @param version - Optional package version.
128
+ * @returns {string} The cache key.
129
+ */
130
+ declare function cacheKey(ecosystem: string, name: string, type: EntryType, version?: string): string;
131
+ /**
132
+ * Check whether a lockfile entry is fresh.
133
+ *
134
+ * @param entry - Entry to inspect.
135
+ * @returns {boolean} Whether the entry is still valid.
136
+ */
137
+ declare function isFresh(entry: LockfileEntry): boolean;
138
+ /**
139
+ * Read a fresh lockfile entry.
140
+ *
141
+ * @param lockfile - Lockfile to inspect.
142
+ * @param key - Cache key.
143
+ * @returns {LockfileEntry | null} The fresh entry, or null.
144
+ */
145
+ declare function getFreshEntry(lockfile: Lockfile, key: string): LockfileEntry | null;
146
+ /**
147
+ * Upsert an in-memory lockfile entry without persisting it.
148
+ *
149
+ * @param lockfile - Lockfile to mutate.
150
+ * @param entry - Entry to store.
151
+ */
152
+ declare function setEntry(lockfile: Lockfile, entry: LockfileEntry): void;
153
+ /**
154
+ * Remove an in-memory lockfile entry.
155
+ *
156
+ * @param lockfile - Lockfile to mutate.
157
+ * @param key - Cache key to remove.
158
+ */
159
+ declare function removeEntry(lockfile: Lockfile, key: string): void;
160
+ /**
161
+ * Remove every stale in-memory entry.
162
+ *
163
+ * @param lockfile - Lockfile to prune.
164
+ * @returns {number} The number of removed entries.
165
+ */
166
+ declare function pruneStale(lockfile: Lockfile): number;
167
+ //#endregion
168
+ //#region src/cache/index.d.ts
169
+ /** Options for creating a cached registry. */
170
+ interface CreateCachedOptions {
171
+ /** Custom base URL for the registry API. */
172
+ baseURL?: string;
173
+ /** Custom HTTP client. */
174
+ client?: Client;
175
+ /** Custom unstorage instance. Overrides the globally configured storage. */
176
+ storage?: Storage;
177
+ }
178
+ /**
179
+ * Create a registry with cache and lockfile tracking.
180
+ *
181
+ * @param ecosystem - Registry ecosystem key.
182
+ * @param options - Optional registry, client, and storage overrides.
183
+ * @returns {Registry} A cached registry instance.
184
+ */
185
+ declare function createCached(ecosystem: string, options?: CreateCachedOptions): Registry;
186
+ //#endregion
187
+ export { getCacheDir as S, computeIntegrity as _, Lockfile as a, getEcosystemStorage as b, getFreshEntry as c, readLockfile as d, removeEntry as f, clearStorage as g, CachedRegistry as h, EntryType as i, isFresh as l, writeLockfile as m, createCached as n, LockfileEntry as o, setEntry as p, DEFAULT_TTL as r, cacheKey as s, CreateCachedOptions as t, pruneStale as u, configureStorage as v, getStorage as x, disposeStorage as y };
188
+ //# sourceMappingURL=index3.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index3.d.mts","names":[],"sources":["../../src/cache/paths.ts","../../src/cache/storage.ts","../../src/cache/cached-registry.ts","../../src/cache/lockfile.ts","../../src/cache/index.ts"],"mappings":";;;;;;;;AAUA;iBAAgB,WAAA,CAAA;;;;;;AAAhB;;iBCGgB,gBAAA,CAAiB,OAAA,EAAS,OAAA;;;;;;iBAS1B,UAAA,CAAA,GAAc,OAAA;;;;;AAA9B;;iBAagB,mBAAA,CAAoB,SAAA,WAAoB,OAAA;;;AAAxD;;;;iBAUgB,gBAAA,CAAiB,KAAA;AAAjC;AAAA,iBAKsB,cAAA,CAAA,GAAkB,OAAA;;iBAQlB,YAAA,CAAA,GAAgB,OAAA;;;;ADhDtC;;;;;;cEWa,cAAA,SAAuB,QAAA;EAAA,SACzB,KAAA,EAAO,QAAA;EAAA,SACP,OAAA,EAAS,OAAA;EAAA,iBACD,eAAA;EAAA,iBACA,QAAA;cAEL,KAAA,EAAO,QAAA,EAAU,OAAA,GAAU,OAAA;EAOvC,SAAA,CAAA;EAIA,IAAA,CAAA,GAAQ,UAAA;EAIF,YAAA,CAAa,IAAA,UAAc,MAAA,GAAS,WAAA,GAAc,OAAA,CAAQ,OAAA;EAW1D,aAAA,CAAc,IAAA,UAAc,MAAA,GAAS,WAAA,GAAc,OAAA,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+1,105 @@
1
+ import "./registry.mjs";
2
+ import "./registries.mjs";
3
+ import { o as resolveDocsUrl } from "./helpers.mjs";
4
+ import "./lockfile.mjs";
5
+ import "./cached-registry.mjs";
6
+ import { n as sharedArgs, r as withErrorHandling, t as resolvePURL } from "./shared.mjs";
7
+ import { defineCommand } from "citty";
8
+ import consola from "consola";
9
+ function outputPackageInfo(pkg, name, reg) {
10
+ const urls = reg.urls();
11
+ const registryUrl = urls.registry(name);
12
+ const docsUrl = resolveDocsUrl(pkg, urls, pkg.latestVersion || void 0);
13
+ const showDocs = shouldShowDocs(docsUrl, pkg, registryUrl);
14
+ consola.log("");
15
+ consola.log(` \x1B[1m\x1B[36m${pkg.name}\x1B[0m${pkg.latestVersion ? `\x1B[90m@${pkg.latestVersion}\x1B[0m` : ""}`);
16
+ if (pkg.description) consola.log(` ${pkg.description}`);
17
+ consola.log("");
18
+ const rows = [
19
+ [
20
+ "License:",
21
+ " ",
22
+ pkg.licenses,
23
+ Boolean(pkg.licenses)
24
+ ],
25
+ [
26
+ "Repository:",
27
+ " ",
28
+ pkg.repository,
29
+ Boolean(pkg.repository)
30
+ ],
31
+ [
32
+ "Homepage:",
33
+ " ",
34
+ pkg.homepage,
35
+ Boolean(pkg.homepage)
36
+ ],
37
+ [
38
+ "Docs:",
39
+ " ",
40
+ docsUrl,
41
+ showDocs
42
+ ],
43
+ [
44
+ "Registry:",
45
+ " ",
46
+ registryUrl,
47
+ true
48
+ ],
49
+ [
50
+ "Keywords:",
51
+ " ",
52
+ pkg.keywords.join(", "),
53
+ pkg.keywords.length > 0
54
+ ],
55
+ [
56
+ "Namespace:",
57
+ " ",
58
+ pkg.namespace,
59
+ Boolean(pkg.namespace)
60
+ ],
61
+ [
62
+ "Ecosystem:",
63
+ " ",
64
+ reg.ecosystem(),
65
+ true
66
+ ]
67
+ ];
68
+ for (const [label, spacing, value, visible] of rows) if (visible) consola.log(` \x1B[90m${label}\x1B[0m${spacing}${value}`);
69
+ consola.log("");
70
+ }
71
+ function shouldShowDocs(docsUrl, pkg, registryUrl) {
72
+ return Boolean(docsUrl) && ![
73
+ pkg.homepage,
74
+ pkg.repository,
75
+ registryUrl
76
+ ].includes(docsUrl);
77
+ }
78
+ var info_default = defineCommand({
79
+ meta: {
80
+ name: "info",
81
+ description: "Show package metadata"
82
+ },
83
+ args: {
84
+ ...sharedArgs,
85
+ purl: {
86
+ type: "positional",
87
+ description: "Package PURL (e.g. pkg:npm/lodash, cargo/serde@1.0)",
88
+ required: true
89
+ }
90
+ },
91
+ async run({ args }) {
92
+ await withErrorHandling(async () => {
93
+ const [reg, name] = resolvePURL(args.purl, !args["no-cache"]);
94
+ const pkg = await reg.fetchPackage(name);
95
+ if (args.json) {
96
+ console.log(JSON.stringify(pkg, null, 2));
97
+ return;
98
+ }
99
+ outputPackageInfo(pkg, name, reg);
100
+ });
101
+ }
102
+ });
103
+ export { info_default as default };
104
+
105
+ //# sourceMappingURL=info.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"info.mjs","names":[],"sources":["../../src/commands/info.ts"],"sourcesContent":["import type { Package } from \"../core/types.ts\";\nimport type { Registry } from \"../core/registry.ts\";\nimport { defineCommand } from \"citty\";\nimport consola from \"consola\";\nimport { resolveDocsUrl } from \"../helpers.ts\";\nimport { sharedArgs, resolvePURL, withErrorHandling } from \"./shared.ts\";\n\nexport function outputPackageInfo(pkg: Package, name: string, reg: Registry): void {\n const urls = reg.urls();\n const registryUrl = urls.registry(name);\n const docsUrl = resolveDocsUrl(pkg, urls, pkg.latestVersion || undefined);\n const showDocs = shouldShowDocs(docsUrl, pkg, registryUrl);\n\n consola.log(\"\");\n consola.log(\n ` \\x1B[1m\\x1B[36m${pkg.name}\\x1B[0m${pkg.latestVersion ? `\\x1B[90m@${pkg.latestVersion}\\x1B[0m` : \"\"}`,\n );\n if (pkg.description) {\n consola.log(` ${pkg.description}`);\n }\n consola.log(\"\");\n\n const rows = [\n [\"License:\", \" \", pkg.licenses, Boolean(pkg.licenses)],\n [\"Repository:\", \" \", pkg.repository, Boolean(pkg.repository)],\n [\"Homepage:\", \" \", pkg.homepage, Boolean(pkg.homepage)],\n [\"Docs:\", \" \", docsUrl, showDocs],\n [\"Registry:\", \" \", registryUrl, true],\n [\"Keywords:\", \" \", pkg.keywords.join(\", \"), pkg.keywords.length > 0],\n [\"Namespace:\", \" \", pkg.namespace, Boolean(pkg.namespace)],\n [\"Ecosystem:\", \" \", reg.ecosystem(), true],\n ] as const;\n\n for (const [label, spacing, value, visible] of rows) {\n if (visible) consola.log(` \\x1B[90m${label}\\x1B[0m${spacing}${value}`);\n }\n consola.log(\"\");\n}\n\nfunction shouldShowDocs(\n docsUrl: string,\n pkg: Readonly<Pick<Package, \"homepage\" | \"repository\">>,\n registryUrl: string,\n): boolean {\n return Boolean(docsUrl) && ![pkg.homepage, pkg.repository, registryUrl].includes(docsUrl);\n}\n\nexport default defineCommand({\n meta: {\n name: \"info\",\n description: \"Show package metadata\",\n },\n args: {\n ...sharedArgs,\n purl: {\n type: \"positional\",\n description: \"Package PURL (e.g. pkg:npm/lodash, cargo/serde@1.0)\",\n required: true,\n },\n },\n async run({ args }) {\n await withErrorHandling(async () => {\n const [reg, name] = resolvePURL(args.purl, !args[\"no-cache\"]);\n const pkg = await reg.fetchPackage(name);\n\n if (args.json) {\n console.log(JSON.stringify(pkg, null, 2));\n return;\n }\n\n outputPackageInfo(pkg, name, reg);\n });\n },\n});\n"],"mappings":";;;;;;;;AAOA,SAAgB,kBAAkB,KAAc,MAAc,KAAqB;CACjF,MAAM,OAAO,IAAI,MAAM;CACvB,MAAM,cAAc,KAAK,SAAS,KAAK;CACvC,MAAM,UAAU,eAAe,KAAK,MAAM,IAAI,iBAAiB,KAAA,EAAU;CACzE,MAAM,WAAW,eAAe,SAAS,KAAK,YAAY;AAE1D,SAAQ,IAAI,GAAG;AACf,SAAQ,IACN,oBAAoB,IAAI,KAAK,SAAS,IAAI,gBAAgB,YAAY,IAAI,cAAc,WAAW,KACpG;AACD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