hostdb 0.30.0 → 0.31.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.
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Version resolution for the hostdb npm package.
3
+ *
4
+ * Consumers (spindb, layerbase-cloud, third parties) call these functions
5
+ * to translate user-supplied version strings (e.g., '17', '11.4', '8.0.23')
6
+ * into the full pinned version that's actually built and published on R2.
7
+ *
8
+ * Resolution algorithm:
9
+ * 1. Identity — if the input is already a known full version, return it.
10
+ * Deprecated patches still match here; only `enabled: false` excludes a
11
+ * version from resolution entirely. The deprecated-but-resolvable case
12
+ * is intentional: existing containers keep working when a version is
13
+ * deprecation-flagged but not removed.
14
+ * 2. Defaults — if the input matches a key in the engine's `defaults` block,
15
+ * return the explicit policy choice. Preserves LTS-vs-latest decisions
16
+ * that previously lived only as comments in spindb's hand-written MAPs.
17
+ * 3. Major.minor prefix — pick the highest full version (including deprecated)
18
+ * that starts with the input prefix.
19
+ * 4. Major prefix — same, but only when no `defaults['X']` is declared.
20
+ * 5. Otherwise null.
21
+ *
22
+ * "Enabled" vs "deprecated":
23
+ * - `enabled: false` → version is INVISIBLE to the resolver (skipped entirely).
24
+ * - `deprecated: true` → version is still resolvable (so containers don't break)
25
+ * but flagged for UI consumers via `isVersionDeprecated`.
26
+ * These flags are independent. UI layers like spindb's version picker use
27
+ * `getDeprecatedVersions()` to hide deprecated entries from create flows.
28
+ */
29
+ import { _resetLoaderCachesForTests, type DatabaseEntry, type CliTools, type Platform } from './databases.js';
30
+ /**
31
+ * Reset the in-process loader cache. Tests only — not part of the public API.
32
+ * Re-exported here so test files don't need to import from two places.
33
+ */
34
+ export declare const _resetCacheForTests: typeof _resetLoaderCachesForTests;
35
+ /**
36
+ * Compare two version strings. Handles:
37
+ * - standard semver (X.Y.Z)
38
+ * - 4-part ClickHouse-style (25.12.3.21)
39
+ * - PostgreSQL-DocumentDB compound format (17-0.107.0)
40
+ *
41
+ * Returns positive if a > b, negative if a < b, 0 if equal.
42
+ */
43
+ export declare function compareVersions(a: string, b: string): number;
44
+ export type ListVersionsOptions = {
45
+ format?: 'full' | 'major' | 'major-minor';
46
+ };
47
+ /**
48
+ * List every engine known to the bundled registry.
49
+ */
50
+ export declare function listEngines(): string[];
51
+ /**
52
+ * Get the raw database entry from the bundled databases.json.
53
+ */
54
+ export declare function getDatabaseEntry(engine: string): DatabaseEntry | null;
55
+ /**
56
+ * Resolve a user-supplied version string to a full pinned version.
57
+ *
58
+ * Returns null when no known version matches the input.
59
+ *
60
+ * Examples:
61
+ * resolveVersion('postgresql', '17') → '17.10.0'
62
+ * resolveVersion('mariadb', '11') → '11.8.6' (from defaults)
63
+ * resolveVersion('mongodb', '8') → '8.0.23' (LTS, from defaults)
64
+ * resolveVersion('mysql', '9') → '9.6.0' (no defaults; prefix match)
65
+ * resolveVersion('sqlite', '3.53.1') → '3.53.1' (identity)
66
+ * resolveVersion('postgresql', '99') → null
67
+ */
68
+ export declare function resolveVersion(engine: string, version: string): string | null;
69
+ /**
70
+ * Like resolveVersion, but returns the input unchanged when nothing matches.
71
+ * Mirrors spindb's per-engine `normalizeVersion` behavior so the wrapper layer
72
+ * can be a drop-in replacement.
73
+ */
74
+ export declare function normalizeVersion(engine: string, version: string): string;
75
+ /**
76
+ * List versions for an engine in the requested format.
77
+ *
78
+ * - 'full' (default): every full version, sorted descending.
79
+ * - 'major-minor': every unique X.Y prefix among full versions, sorted descending.
80
+ * - 'major': every unique X prefix, sorted descending.
81
+ */
82
+ export declare function listVersions(engine: string, opts?: ListVersionsOptions): string[];
83
+ /**
84
+ * The set of supported major versions (1-part keys) for an engine.
85
+ *
86
+ * Prefers the engine's `defaults` block (since it represents an explicit policy);
87
+ * falls back to inferring from the version list if no defaults declared.
88
+ *
89
+ * Matches spindb's existing `SUPPORTED_MAJOR_VERSIONS` shape exactly.
90
+ */
91
+ export declare function getSupportedMajorVersions(engine: string): string[];
92
+ /**
93
+ * Get the explicit major-version default for an engine, or null when none declared.
94
+ *
95
+ * Useful when callers want to know whether `'8'` resolves via policy (LTS pick)
96
+ * or via prefix-match fallback.
97
+ */
98
+ export declare function getMajorDefault(engine: string, major: string): string | null;
99
+ /**
100
+ * Convenience defaults: the engine's overall `defaultVersion` (typically the
101
+ * highest declared major's resolved value) and `latestVersion` (the highest
102
+ * enabled full version — deprecated patches are still included; only
103
+ * `enabled: false` excludes a version).
104
+ *
105
+ * For multi-track engines like MongoDB the two can differ:
106
+ * - MongoDB defaultVersion = '8.0.23' (LTS pick from defaults['8'])
107
+ * - MongoDB latestVersion = '8.2.9' (highest full version)
108
+ */
109
+ export declare function getEngineDefaults(engine: string): {
110
+ defaultVersion: string | null;
111
+ latestVersion: string | null;
112
+ };
113
+ /**
114
+ * Check whether a specific version is marked deprecated in the registry.
115
+ */
116
+ export declare function isVersionDeprecated(engine: string, version: string): boolean;
117
+ /**
118
+ * Get the cliTools metadata for a specific version (resolves engine vs. version-level overrides).
119
+ */
120
+ export declare function getCliTools(engine: string, version: string): CliTools | null;
121
+ /**
122
+ * Get the platforms supported for a specific version.
123
+ */
124
+ export declare function getAvailablePlatforms(engine: string, version: string): Platform[];
125
+ /**
126
+ * Get the download metadata for a specific published-asset version + platform.
127
+ *
128
+ * Returns null when the version isn't published (yet), the platform isn't built
129
+ * for that version, or the engine doesn't exist.
130
+ *
131
+ * Note: `sha256` here is the SHA-256 of the published artifact on R2 (computed
132
+ * by the build pipeline). The build-time *source-tarball* checksum (which is
133
+ * SHA3-256 for SQLite specifically) lives in `sources.json` and is not exposed
134
+ * by this resolver.
135
+ */
136
+ export declare function getReleaseInfo(engine: string, version: string, platform: Platform): {
137
+ url: string;
138
+ sha256: string;
139
+ size: number;
140
+ } | null;
141
+ export type { DatabaseEntry, CliTools, Platform } from './databases.js';
142
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../lib/resolver.ts"],"names":[],"m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7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B,CAeA;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAM5E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAK5E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,QAAQ,EAAE,CAKZ;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,GACjB;IACD,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,IAAI,CAYP;AAGD,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,306 @@
1
+ /**
2
+ * Version resolution for the hostdb npm package.
3
+ *
4
+ * Consumers (spindb, layerbase-cloud, third parties) call these functions
5
+ * to translate user-supplied version strings (e.g., '17', '11.4', '8.0.23')
6
+ * into the full pinned version that's actually built and published on R2.
7
+ *
8
+ * Resolution algorithm:
9
+ * 1. Identity — if the input is already a known full version, return it.
10
+ * Deprecated patches still match here; only `enabled: false` excludes a
11
+ * version from resolution entirely. The deprecated-but-resolvable case
12
+ * is intentional: existing containers keep working when a version is
13
+ * deprecation-flagged but not removed.
14
+ * 2. Defaults — if the input matches a key in the engine's `defaults` block,
15
+ * return the explicit policy choice. Preserves LTS-vs-latest decisions
16
+ * that previously lived only as comments in spindb's hand-written MAPs.
17
+ * 3. Major.minor prefix — pick the highest full version (including deprecated)
18
+ * that starts with the input prefix.
19
+ * 4. Major prefix — same, but only when no `defaults['X']` is declared.
20
+ * 5. Otherwise null.
21
+ *
22
+ * "Enabled" vs "deprecated":
23
+ * - `enabled: false` → version is INVISIBLE to the resolver (skipped entirely).
24
+ * - `deprecated: true` → version is still resolvable (so containers don't break)
25
+ * but flagged for UI consumers via `isVersionDeprecated`.
26
+ * These flags are independent. UI layers like spindb's version picker use
27
+ * `getDeprecatedVersions()` to hide deprecated entries from create flows.
28
+ */
29
+ import { loadDatabasesJson, loadReleasesJson, _resetLoaderCachesForTests, isVersionDeprecated as _isVersionDeprecated, isVersionEnabled, getVersionPlatforms, getVersionCliTools, } from './databases.js';
30
+ // The loader functions cache their parsed result, so calling them on every
31
+ // resolver invocation is O(1) after the first read. No second-layer cache needed.
32
+ const databases = loadDatabasesJson;
33
+ const releases = loadReleasesJson;
34
+ /**
35
+ * Reset the in-process loader cache. Tests only — not part of the public API.
36
+ * Re-exported here so test files don't need to import from two places.
37
+ */
38
+ export const _resetCacheForTests = _resetLoaderCachesForTests;
39
+ // ─── Version comparison ─────────────────────────────────────────────────────
40
+ /**
41
+ * Compare two version strings. Handles:
42
+ * - standard semver (X.Y.Z)
43
+ * - 4-part ClickHouse-style (25.12.3.21)
44
+ * - PostgreSQL-DocumentDB compound format (17-0.107.0)
45
+ *
46
+ * Returns positive if a > b, negative if a < b, 0 if equal.
47
+ */
48
+ export function compareVersions(a, b) {
49
+ // Compound format like '17-0.107.0' splits on '-' first.
50
+ const [aBase, aSuffix = ''] = a.split('-', 2);
51
+ const [bBase, bSuffix = ''] = b.split('-', 2);
52
+ const aParts = aBase.split('.').map((n) => parseInt(n, 10) || 0);
53
+ const bParts = bBase.split('.').map((n) => parseInt(n, 10) || 0);
54
+ const len = Math.max(aParts.length, bParts.length);
55
+ for (let i = 0; i < len; i++) {
56
+ const ai = aParts[i] ?? 0;
57
+ const bi = bParts[i] ?? 0;
58
+ if (ai !== bi)
59
+ return ai - bi;
60
+ }
61
+ // Bases equal — compare suffix recursively (treats no-suffix as smaller)
62
+ if (!aSuffix && !bSuffix)
63
+ return 0;
64
+ if (!aSuffix)
65
+ return -1;
66
+ if (!bSuffix)
67
+ return 1;
68
+ return compareVersions(aSuffix, bSuffix);
69
+ }
70
+ // ─── Helpers ────────────────────────────────────────────────────────────────
71
+ function getEntry(engine) {
72
+ return databases().databases[engine] ?? null;
73
+ }
74
+ /**
75
+ * Return the engine's full-version list, filtered by the `enabled` flag.
76
+ * Deprecated versions stay in the list — see resolver-level docstring.
77
+ */
78
+ function getAvailableFullVersions(engine) {
79
+ const entry = getEntry(engine);
80
+ if (!entry)
81
+ return [];
82
+ return Object.keys(entry.versions ?? {}).filter((v) => isVersionEnabled(entry.versions[v]));
83
+ }
84
+ /**
85
+ * List every engine known to the bundled registry.
86
+ */
87
+ export function listEngines() {
88
+ return Object.keys(databases().databases).sort();
89
+ }
90
+ /**
91
+ * Get the raw database entry from the bundled databases.json.
92
+ */
93
+ export function getDatabaseEntry(engine) {
94
+ return getEntry(engine);
95
+ }
96
+ /**
97
+ * Resolve a user-supplied version string to a full pinned version.
98
+ *
99
+ * Returns null when no known version matches the input.
100
+ *
101
+ * Examples:
102
+ * resolveVersion('postgresql', '17') → '17.10.0'
103
+ * resolveVersion('mariadb', '11') → '11.8.6' (from defaults)
104
+ * resolveVersion('mongodb', '8') → '8.0.23' (LTS, from defaults)
105
+ * resolveVersion('mysql', '9') → '9.6.0' (no defaults; prefix match)
106
+ * resolveVersion('sqlite', '3.53.1') → '3.53.1' (identity)
107
+ * resolveVersion('postgresql', '99') → null
108
+ */
109
+ export function resolveVersion(engine, version) {
110
+ const entry = getEntry(engine);
111
+ if (!entry)
112
+ return null;
113
+ const versions = getAvailableFullVersions(engine);
114
+ if (versions.length === 0)
115
+ return null;
116
+ // 1. Identity — already a known full version
117
+ if (versions.includes(version))
118
+ return version;
119
+ // 2. Defaults — explicit policy
120
+ const defaults = entry.defaults ?? {};
121
+ if (defaults[version]) {
122
+ const target = defaults[version];
123
+ // Accept only if the target is actually a known version
124
+ return versions.includes(target) ? target : null;
125
+ }
126
+ // 3. Prefix match — for any input length, pick the highest enabled full
127
+ // version that starts with `<input>.`. Deprecated versions are still
128
+ // considered enabled (`enabled: false` is the only flag that excludes a
129
+ // version from resolution) — see the file-level docstring for the
130
+ // enabled-vs-deprecated rationale.
131
+ //
132
+ // Skip the major-only case (1-part) when an explicit `defaults` entry exists
133
+ // for that major: e.g., MongoDB '8' is governed by defaults block; don't
134
+ // fall through to "highest version starting with '8.'" which would pick
135
+ // 8.2.9 instead of the intended 8.0.23 LTS.
136
+ const isOnePart = !version.includes('.');
137
+ if (isOnePart && defaults[version]) {
138
+ // already handled above; this case shouldn't fall through
139
+ return null;
140
+ }
141
+ const matches = versions
142
+ .filter((v) => v.startsWith(version + '.'))
143
+ .sort((a, b) => compareVersions(b, a));
144
+ return matches[0] ?? null;
145
+ }
146
+ /**
147
+ * Like resolveVersion, but returns the input unchanged when nothing matches.
148
+ * Mirrors spindb's per-engine `normalizeVersion` behavior so the wrapper layer
149
+ * can be a drop-in replacement.
150
+ */
151
+ export function normalizeVersion(engine, version) {
152
+ return resolveVersion(engine, version) ?? version;
153
+ }
154
+ /**
155
+ * List versions for an engine in the requested format.
156
+ *
157
+ * - 'full' (default): every full version, sorted descending.
158
+ * - 'major-minor': every unique X.Y prefix among full versions, sorted descending.
159
+ * - 'major': every unique X prefix, sorted descending.
160
+ */
161
+ export function listVersions(engine, opts = {}) {
162
+ const versions = getAvailableFullVersions(engine);
163
+ if (versions.length === 0)
164
+ return [];
165
+ const sorted = [...versions].sort((a, b) => compareVersions(b, a));
166
+ const format = opts.format ?? 'full';
167
+ if (format === 'full')
168
+ return sorted;
169
+ if (format === 'major-minor') {
170
+ const seen = new Set();
171
+ const out = [];
172
+ for (const v of sorted) {
173
+ const parts = v.split('-')[0].split('.');
174
+ const key = parts.length >= 2 ? `${parts[0]}.${parts[1]}` : parts[0];
175
+ if (!seen.has(key)) {
176
+ seen.add(key);
177
+ out.push(key);
178
+ }
179
+ }
180
+ return out;
181
+ }
182
+ // 'major'
183
+ const seen = new Set();
184
+ const out = [];
185
+ for (const v of sorted) {
186
+ const major = v.split('-')[0].split('.')[0];
187
+ if (!seen.has(major)) {
188
+ seen.add(major);
189
+ out.push(major);
190
+ }
191
+ }
192
+ return out;
193
+ }
194
+ /**
195
+ * The set of supported major versions (1-part keys) for an engine.
196
+ *
197
+ * Prefers the engine's `defaults` block (since it represents an explicit policy);
198
+ * falls back to inferring from the version list if no defaults declared.
199
+ *
200
+ * Matches spindb's existing `SUPPORTED_MAJOR_VERSIONS` shape exactly.
201
+ */
202
+ export function getSupportedMajorVersions(engine) {
203
+ const entry = getEntry(engine);
204
+ if (!entry)
205
+ return [];
206
+ const defaults = entry.defaults ?? {};
207
+ if (Object.keys(defaults).length > 0) {
208
+ return Object.keys(defaults).sort((a, b) => compareVersions(b, a));
209
+ }
210
+ return listVersions(engine, { format: 'major' });
211
+ }
212
+ /**
213
+ * Get the explicit major-version default for an engine, or null when none declared.
214
+ *
215
+ * Useful when callers want to know whether `'8'` resolves via policy (LTS pick)
216
+ * or via prefix-match fallback.
217
+ */
218
+ export function getMajorDefault(engine, major) {
219
+ const entry = getEntry(engine);
220
+ return entry?.defaults?.[major] ?? null;
221
+ }
222
+ /**
223
+ * Convenience defaults: the engine's overall `defaultVersion` (typically the
224
+ * highest declared major's resolved value) and `latestVersion` (the highest
225
+ * enabled full version — deprecated patches are still included; only
226
+ * `enabled: false` excludes a version).
227
+ *
228
+ * For multi-track engines like MongoDB the two can differ:
229
+ * - MongoDB defaultVersion = '8.0.23' (LTS pick from defaults['8'])
230
+ * - MongoDB latestVersion = '8.2.9' (highest full version)
231
+ */
232
+ export function getEngineDefaults(engine) {
233
+ const versions = getAvailableFullVersions(engine);
234
+ if (versions.length === 0)
235
+ return { defaultVersion: null, latestVersion: null };
236
+ const sortedDesc = [...versions].sort((a, b) => compareVersions(b, a));
237
+ const latestVersion = sortedDesc[0];
238
+ const majors = getSupportedMajorVersions(engine);
239
+ const highestMajor = majors[0];
240
+ const defaultVersion = highestMajor
241
+ ? (resolveVersion(engine, highestMajor) ?? latestVersion)
242
+ : latestVersion;
243
+ return { defaultVersion, latestVersion };
244
+ }
245
+ /**
246
+ * Check whether a specific version is marked deprecated in the registry.
247
+ */
248
+ export function isVersionDeprecated(engine, version) {
249
+ const entry = getEntry(engine);
250
+ if (!entry)
251
+ return false;
252
+ const ve = entry.versions[version];
253
+ if (ve === undefined)
254
+ return false;
255
+ return _isVersionDeprecated(ve);
256
+ }
257
+ /**
258
+ * Get the cliTools metadata for a specific version (resolves engine vs. version-level overrides).
259
+ */
260
+ export function getCliTools(engine, version) {
261
+ const entry = getEntry(engine);
262
+ if (!entry)
263
+ return null;
264
+ if (entry.versions[version] === undefined)
265
+ return null;
266
+ return getVersionCliTools(entry, version);
267
+ }
268
+ /**
269
+ * Get the platforms supported for a specific version.
270
+ */
271
+ export function getAvailablePlatforms(engine, version) {
272
+ const entry = getEntry(engine);
273
+ if (!entry)
274
+ return [];
275
+ if (entry.versions[version] === undefined)
276
+ return [];
277
+ return getVersionPlatforms(entry, version);
278
+ }
279
+ /**
280
+ * Get the download metadata for a specific published-asset version + platform.
281
+ *
282
+ * Returns null when the version isn't published (yet), the platform isn't built
283
+ * for that version, or the engine doesn't exist.
284
+ *
285
+ * Note: `sha256` here is the SHA-256 of the published artifact on R2 (computed
286
+ * by the build pipeline). The build-time *source-tarball* checksum (which is
287
+ * SHA3-256 for SQLite specifically) lives in `sources.json` and is not exposed
288
+ * by this resolver.
289
+ */
290
+ export function getReleaseInfo(engine, version, platform) {
291
+ const releaseDb = releases().databases[engine];
292
+ if (!releaseDb)
293
+ return null;
294
+ const versionRel = releaseDb[version];
295
+ if (!versionRel)
296
+ return null;
297
+ const asset = versionRel.platforms?.[platform];
298
+ if (!asset)
299
+ return null;
300
+ return {
301
+ url: asset.url,
302
+ sha256: asset.sha256,
303
+ size: asset.size,
304
+ };
305
+ }
306
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+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K,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,20 @@
1
1
  {
2
2
  "name": "hostdb",
3
- "version": "0.30.0",
4
- "description": "Source and download pre-built database binaries for multiple platforms, distributed via GitHub Releases",
3
+ "version": "0.31.1",
4
+ "description": "Pre-built database binaries for multiple platforms, plus a typed registry library for resolving versions and download URLs offline.",
5
5
  "private": false,
6
6
  "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./databases.json": "./databases.json",
15
+ "./releases.json": "./releases.json",
16
+ "./downloads.json": "./downloads.json"
17
+ },
7
18
  "bin": {
8
19
  "hostdb": "./bin/cli.js"
9
20
  },
@@ -20,14 +31,18 @@
20
31
  "files": [
21
32
  "bin",
22
33
  "cli",
23
- "lib",
34
+ "dist",
24
35
  "databases.json",
25
36
  "releases.json",
26
37
  "downloads.json"
27
38
  ],
28
39
  "scripts": {
29
40
  "add:engine": "tsx scripts/add-engine.ts",
41
+ "build": "tsc -p tsconfig.build.json",
42
+ "test": "node --import tsx --test tests/*.test.ts",
30
43
  "build:releases": "tsx scripts/build-releases-json.ts",
44
+ "prepare": "pnpm build",
45
+ "prepublishOnly": "pnpm build",
31
46
  "check:dylibs": "builds/common/check-macos-dylibs.sh",
32
47
  "checksums:populate": "tsx scripts/populate-checksums.ts",
33
48
  "dbs": "tsx scripts/list-databases.ts",
@@ -62,10 +77,8 @@
62
77
  "repair:checksums": "tsx scripts/repair-checksums.ts",
63
78
  "start": "tsx cli/bin.ts",
64
79
  "sync:versions": "tsx scripts/sync-versions.ts",
65
- "upload:r2": "tsx scripts/upload-to-r2.ts"
66
- },
67
- "dependencies": {
68
- "tsx": "^4.19.0"
80
+ "upload:r2": "tsx scripts/upload-to-r2.ts",
81
+ "audit:r2-orphans": "tsx scripts/audit-r2-orphans.ts"
69
82
  },
70
83
  "devDependencies": {
71
84
  "@aws-sdk/client-s3": "^3.990.0",
@@ -77,6 +90,7 @@
77
90
  "eslint": "^9.17.0",
78
91
  "ora": "^9.3.0",
79
92
  "prettier": "^3.4.0",
93
+ "tsx": "^4.19.0",
80
94
  "typescript": "^5.7.0",
81
95
  "typescript-eslint": "^8.18.0",
82
96
  "yaml": "^2.8.2"