@gobing-ai/ts-runtime 0.8.0 → 0.8.2
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.
- package/dist/schema-validation.js +30 -2
- package/package.json +4 -4
- package/src/schema-validation.ts +35 -2
|
@@ -199,13 +199,41 @@ function resolvePackageSchema(specifier, source, resolve) {
|
|
|
199
199
|
try {
|
|
200
200
|
// Resolve the package root via its always-present package.json, then join the subpath.
|
|
201
201
|
// This sidesteps `exports` gating on arbitrary JSON subpaths.
|
|
202
|
-
|
|
203
|
-
return joinPath(dirnamePath(manifest), subpath);
|
|
202
|
+
return schemaPathOf(resolveFn, pkg, subpath, from);
|
|
204
203
|
}
|
|
205
204
|
catch (error) {
|
|
205
|
+
// A project config names the schema of the tool that reads it, and that tool is not always an
|
|
206
|
+
// ancestor of the config: globally installed CLIs (bun/npm global, `bun link`) live outside the
|
|
207
|
+
// project tree, so the config-directory lookup cannot see them. Retry from this module's own
|
|
208
|
+
// directory — inside a bundled CLI that is the tool's package root, which ships the schema.
|
|
209
|
+
const host = hostModuleDir();
|
|
210
|
+
if (host !== undefined && host !== from) {
|
|
211
|
+
try {
|
|
212
|
+
return schemaPathOf(resolveFn, pkg, subpath, host);
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
// Both locations missed: report the caller's own location, which is the actionable one.
|
|
216
|
+
}
|
|
217
|
+
}
|
|
206
218
|
throw new StructuredConfigSchemaError(`Cannot resolve package schema "${specifier}" referenced by "${source}": ${errorMessage(error)}`);
|
|
207
219
|
}
|
|
208
220
|
}
|
|
221
|
+
function schemaPathOf(resolve, pkg, subpath, from) {
|
|
222
|
+
return joinPath(dirnamePath(resolve(`${pkg}/package.json`, from)), subpath);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Directory of this module: the host tool's own package root once bundled. `import.meta.dir` is Bun's
|
|
226
|
+
* form; `import.meta.url` covers other ESM hosts. `undefined` where neither exists (e.g. some workers).
|
|
227
|
+
*/
|
|
228
|
+
function hostModuleDir() {
|
|
229
|
+
const meta = import.meta;
|
|
230
|
+
if (typeof meta.dir === 'string' && meta.dir.length > 0)
|
|
231
|
+
return meta.dir;
|
|
232
|
+
if (typeof meta.url === 'string' && meta.url.startsWith('file://')) {
|
|
233
|
+
return dirnamePath(decodeURIComponent(meta.url.slice('file://'.length)));
|
|
234
|
+
}
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
209
237
|
function splitPackageSpecifier(specifier) {
|
|
210
238
|
const parts = specifier.split('/');
|
|
211
239
|
const segments = specifier.startsWith('@') ? 2 : 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gobing-ai/ts-runtime",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "@gobing-ai/ts-runtime — Runtime abstractions for Bun, Node, and Cloudflare Workers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -58,17 +58,17 @@
|
|
|
58
58
|
"release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-runtime-v<version> && git push --tags' && exit 1"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@gobing-ai/ts-utils": "^0.8.
|
|
61
|
+
"@gobing-ai/ts-utils": "^0.8.2",
|
|
62
62
|
"execa": "^9.5.0",
|
|
63
63
|
"yaml": "^2.7.0",
|
|
64
64
|
"zod": "^4.1.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@gobing-ai/ts-db": "^0.8.
|
|
67
|
+
"@gobing-ai/ts-db": "^0.8.2",
|
|
68
68
|
"@types/bun": "1.4.3"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@gobing-ai/ts-db": "^0.8.
|
|
71
|
+
"@gobing-ai/ts-db": "^0.8.2"
|
|
72
72
|
},
|
|
73
73
|
"peerDependenciesMeta": {
|
|
74
74
|
"@gobing-ai/ts-db": {
|
package/src/schema-validation.ts
CHANGED
|
@@ -336,15 +336,48 @@ function resolvePackageSchema(
|
|
|
336
336
|
try {
|
|
337
337
|
// Resolve the package root via its always-present package.json, then join the subpath.
|
|
338
338
|
// This sidesteps `exports` gating on arbitrary JSON subpaths.
|
|
339
|
-
|
|
340
|
-
return joinPath(dirnamePath(manifest), subpath);
|
|
339
|
+
return schemaPathOf(resolveFn, pkg, subpath, from);
|
|
341
340
|
} catch (error) {
|
|
341
|
+
// A project config names the schema of the tool that reads it, and that tool is not always an
|
|
342
|
+
// ancestor of the config: globally installed CLIs (bun/npm global, `bun link`) live outside the
|
|
343
|
+
// project tree, so the config-directory lookup cannot see them. Retry from this module's own
|
|
344
|
+
// directory — inside a bundled CLI that is the tool's package root, which ships the schema.
|
|
345
|
+
const host = hostModuleDir();
|
|
346
|
+
if (host !== undefined && host !== from) {
|
|
347
|
+
try {
|
|
348
|
+
return schemaPathOf(resolveFn, pkg, subpath, host);
|
|
349
|
+
} catch {
|
|
350
|
+
// Both locations missed: report the caller's own location, which is the actionable one.
|
|
351
|
+
}
|
|
352
|
+
}
|
|
342
353
|
throw new StructuredConfigSchemaError(
|
|
343
354
|
`Cannot resolve package schema "${specifier}" referenced by "${source}": ${errorMessage(error)}`,
|
|
344
355
|
);
|
|
345
356
|
}
|
|
346
357
|
}
|
|
347
358
|
|
|
359
|
+
function schemaPathOf(
|
|
360
|
+
resolve: (specifier: string, from: string) => string,
|
|
361
|
+
pkg: string,
|
|
362
|
+
subpath: string,
|
|
363
|
+
from: string,
|
|
364
|
+
): string {
|
|
365
|
+
return joinPath(dirnamePath(resolve(`${pkg}/package.json`, from)), subpath);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Directory of this module: the host tool's own package root once bundled. `import.meta.dir` is Bun's
|
|
370
|
+
* form; `import.meta.url` covers other ESM hosts. `undefined` where neither exists (e.g. some workers).
|
|
371
|
+
*/
|
|
372
|
+
function hostModuleDir(): string | undefined {
|
|
373
|
+
const meta = import.meta as { dir?: string; url?: string };
|
|
374
|
+
if (typeof meta.dir === 'string' && meta.dir.length > 0) return meta.dir;
|
|
375
|
+
if (typeof meta.url === 'string' && meta.url.startsWith('file://')) {
|
|
376
|
+
return dirnamePath(decodeURIComponent(meta.url.slice('file://'.length)));
|
|
377
|
+
}
|
|
378
|
+
return undefined;
|
|
379
|
+
}
|
|
380
|
+
|
|
348
381
|
function splitPackageSpecifier(specifier: string): { pkg: string; subpath: string } {
|
|
349
382
|
const parts = specifier.split('/');
|
|
350
383
|
const segments = specifier.startsWith('@') ? 2 : 1;
|