@onereach/json-schema-aot 0.0.0-stage → 0.2.0-framework.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/README.md +271 -2
- package/dist/index.d.mts +17 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +189 -0
- package/dist/index.mjs.map +1 -0
- package/dist/replace-directory.d.mts +20 -0
- package/dist/replace-directory.d.mts.map +1 -0
- package/dist/replace-directory.mjs +41 -0
- package/dist/replace-directory.mjs.map +1 -0
- package/dist/rolldown/authoring-inputs.d.mts +13 -0
- package/dist/rolldown/authoring-inputs.d.mts.map +1 -0
- package/dist/rolldown/authoring-inputs.mjs +86 -0
- package/dist/rolldown/authoring-inputs.mjs.map +1 -0
- package/dist/rolldown/directories.d.mts +7 -0
- package/dist/rolldown/directories.d.mts.map +1 -0
- package/dist/rolldown/directories.mjs +65 -0
- package/dist/rolldown/directories.mjs.map +1 -0
- package/dist/rolldown/generate.d.mts +7 -0
- package/dist/rolldown/generate.d.mts.map +1 -0
- package/dist/rolldown/generate.mjs +49 -0
- package/dist/rolldown/generate.mjs.map +1 -0
- package/dist/rolldown/index.d.mts +18 -0
- package/dist/rolldown/index.d.mts.map +1 -0
- package/dist/rolldown/index.mjs +185 -0
- package/dist/rolldown/index.mjs.map +1 -0
- package/dist/rolldown/inputs.d.mts +7 -0
- package/dist/rolldown/inputs.d.mts.map +1 -0
- package/dist/rolldown/inputs.mjs +65 -0
- package/dist/rolldown/inputs.mjs.map +1 -0
- package/dist/rolldown/node-options.d.mts +10 -0
- package/dist/rolldown/node-options.d.mts.map +1 -0
- package/dist/rolldown/node-options.mjs +95 -0
- package/dist/rolldown/node-options.mjs.map +1 -0
- package/dist/rolldown/publish.d.mts +10 -0
- package/dist/rolldown/publish.d.mts.map +1 -0
- package/dist/rolldown/publish.mjs +25 -0
- package/dist/rolldown/publish.mjs.map +1 -0
- package/dist/rolldown/resolution.d.mts +10 -0
- package/dist/rolldown/resolution.d.mts.map +1 -0
- package/dist/rolldown/resolution.mjs +105 -0
- package/dist/rolldown/resolution.mjs.map +1 -0
- package/dist/rolldown/schema-worker.d.mts +2 -0
- package/dist/rolldown/schema-worker.d.mts.map +1 -0
- package/dist/rolldown/schema-worker.mjs +24 -0
- package/dist/rolldown/schema-worker.mjs.map +1 -0
- package/dist/rolldown/worker-protocol.d.mts +10 -0
- package/dist/rolldown/worker-protocol.d.mts.map +1 -0
- package/dist/rolldown/worker-protocol.mjs +9 -0
- package/dist/rolldown/worker-protocol.mjs.map +1 -0
- package/dist/validator-source.d.mts +10 -0
- package/dist/validator-source.d.mts.map +1 -0
- package/dist/validator-source.mjs +62 -0
- package/dist/validator-source.mjs.map +1 -0
- package/package.json +49 -3
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
function parseArguments(arguments_) {
|
|
2
|
+
const execArgv = [];
|
|
3
|
+
const conditions = [];
|
|
4
|
+
// Inherit module-loading behavior, not arbitrary process/V8/debugging options.
|
|
5
|
+
const paired = new Set(['--conditions', '-C', '--import', '--require', '-r', '--loader', '--experimental-loader']);
|
|
6
|
+
const boolean = new Set([
|
|
7
|
+
'--enable-source-maps',
|
|
8
|
+
'--no-warnings',
|
|
9
|
+
'--trace-warnings',
|
|
10
|
+
'--trace-uncaught',
|
|
11
|
+
'--preserve-symlinks',
|
|
12
|
+
'--preserve-symlinks-main',
|
|
13
|
+
]);
|
|
14
|
+
const invocation = new Set(['--input-type', '--eval', '-e', '--print', '-p']);
|
|
15
|
+
for (let index = 0; index < arguments_.length; index++) {
|
|
16
|
+
const argument = arguments_[index];
|
|
17
|
+
const equals = argument.indexOf('=');
|
|
18
|
+
const name = equals === -1 ? argument : argument.slice(0, equals);
|
|
19
|
+
if (paired.has(name)) {
|
|
20
|
+
let value;
|
|
21
|
+
if (equals !== -1) {
|
|
22
|
+
value = argument.slice(equals + 1);
|
|
23
|
+
execArgv.push(argument);
|
|
24
|
+
}
|
|
25
|
+
else if (index + 1 < arguments_.length) {
|
|
26
|
+
value = arguments_[++index];
|
|
27
|
+
execArgv.push(argument, value);
|
|
28
|
+
}
|
|
29
|
+
else
|
|
30
|
+
continue;
|
|
31
|
+
if (name === '--conditions' || name === '-C')
|
|
32
|
+
conditions.push(value);
|
|
33
|
+
}
|
|
34
|
+
else if (boolean.has(argument)) {
|
|
35
|
+
execArgv.push(argument);
|
|
36
|
+
}
|
|
37
|
+
else if (invocation.has(argument)) {
|
|
38
|
+
// An eval expression is an argument, not a flag to forward.
|
|
39
|
+
index++;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { execArgv, conditions };
|
|
43
|
+
}
|
|
44
|
+
function environmentArguments(value) {
|
|
45
|
+
const result = [];
|
|
46
|
+
let argument = '';
|
|
47
|
+
let isQuoted = false;
|
|
48
|
+
let hasArgument = false;
|
|
49
|
+
// NODE_OPTIONS uses double quotes and backslash escapes inside quoted strings,
|
|
50
|
+
// not shell quoting (single quotes remain literal).
|
|
51
|
+
for (let index = 0; index < value.length; index++) {
|
|
52
|
+
const character = value[index];
|
|
53
|
+
if (character === '\\' && isQuoted) {
|
|
54
|
+
if (++index === value.length)
|
|
55
|
+
throw new Error('Invalid NODE_OPTIONS: trailing escape.');
|
|
56
|
+
argument += value[index];
|
|
57
|
+
}
|
|
58
|
+
else if (character === '"') {
|
|
59
|
+
isQuoted = !isQuoted;
|
|
60
|
+
hasArgument = true;
|
|
61
|
+
}
|
|
62
|
+
else if (character === ' ' && !isQuoted) {
|
|
63
|
+
if (hasArgument)
|
|
64
|
+
result.push(argument);
|
|
65
|
+
argument = '';
|
|
66
|
+
hasArgument = false;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
argument += character;
|
|
70
|
+
hasArgument = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (isQuoted)
|
|
74
|
+
throw new Error('Invalid NODE_OPTIONS: unterminated quoted string.');
|
|
75
|
+
if (hasArgument)
|
|
76
|
+
result.push(argument);
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
export function workerExecArgv(arguments_) {
|
|
80
|
+
return parseArguments(arguments_).execArgv;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Use the same custom conditions for static authoring resolution and fresh workers.
|
|
84
|
+
* NODE_OPTIONS is not included in process.execArgv; do not replay its preloads.
|
|
85
|
+
*/
|
|
86
|
+
export function authoringNodeOptions(arguments_, nodeOptions = '') {
|
|
87
|
+
const environment = parseArguments(environmentArguments(nodeOptions));
|
|
88
|
+
const invocation = parseArguments(arguments_);
|
|
89
|
+
const conditions = [...new Set([...environment.conditions, ...invocation.conditions])];
|
|
90
|
+
return {
|
|
91
|
+
conditions,
|
|
92
|
+
execArgv: [...invocation.execArgv, ...environment.conditions.map((condition) => `--conditions=${condition}`)],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=node-options.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-options.mjs","sourceRoot":"","sources":["../../src/rolldown/node-options.mts"],"names":[],"mappings":"AAAA,SAAS,cAAc,CAAC,UAA6B;IACnD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,+EAA+E;IAC/E,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,uBAAuB,CAAC,CAAC,CAAC;IACnH,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC;QACtB,sBAAsB;QACtB,eAAe;QACf,kBAAkB;QAClB,kBAAkB;QAClB,qBAAqB;QACrB,0BAA0B;KAC3B,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9E,KAAK,IAAI,KAAK,GA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A6B;IAC1D,OAAO,cAAc,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAA6B,EAAE,WAAW,GAAG,EAAE;IAClF,MAAM,WAAW,GAAG,cAAc,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC;IACtE,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,UAAU,EAAE,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACvF,OAAO;QACL,UAAU;QACV,QAAQ,EAAE,CAAC,GAAG,UAAU,CAAC,QAAQ,EAAE,GAAG,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,SAAS,EAAE,CAAC,CAAC;KAC9G,CAAC;AACJ,CAAC","sourcesContent":["function parseArguments(arguments_: readonly string[]) {\n const execArgv: string[] = [];\n const conditions: string[] = [];\n // Inherit module-loading behavior, not arbitrary process/V8/debugging options.\n const paired = new Set(['--conditions', '-C', '--import', '--require', '-r', '--loader', '--experimental-loader']);\n const boolean = new Set([\n '--enable-source-maps',\n '--no-warnings',\n '--trace-warnings',\n '--trace-uncaught',\n '--preserve-symlinks',\n '--preserve-symlinks-main',\n ]);\n const invocation = new Set(['--input-type', '--eval', '-e', '--print', '-p']);\n for (let index = 0; index < arguments_.length; index++) {\n const argument = arguments_[index]!;\n const equals = argument.indexOf('=');\n const name = equals === -1 ? argument : argument.slice(0, equals);\n if (paired.has(name)) {\n let value: string;\n if (equals !== -1) {\n value = argument.slice(equals + 1);\n execArgv.push(argument);\n } else if (index + 1 < arguments_.length) {\n value = arguments_[++index]!;\n execArgv.push(argument, value);\n } else continue;\n if (name === '--conditions' || name === '-C') conditions.push(value);\n } else if (boolean.has(argument)) {\n execArgv.push(argument);\n } else if (invocation.has(argument)) {\n // An eval expression is an argument, not a flag to forward.\n index++;\n }\n }\n return { execArgv, conditions };\n}\n\nfunction environmentArguments(value: string): string[] {\n const result: string[] = [];\n let argument = '';\n let isQuoted = false;\n let hasArgument = false;\n // NODE_OPTIONS uses double quotes and backslash escapes inside quoted strings,\n // not shell quoting (single quotes remain literal).\n for (let index = 0; index < value.length; index++) {\n const character = value[index]!;\n if (character === '\\\\' && isQuoted) {\n if (++index === value.length) throw new Error('Invalid NODE_OPTIONS: trailing escape.');\n argument += value[index]!;\n } else if (character === '\"') {\n isQuoted = !isQuoted;\n hasArgument = true;\n } else if (character === ' ' && !isQuoted) {\n if (hasArgument) result.push(argument);\n argument = '';\n hasArgument = false;\n } else {\n argument += character;\n hasArgument = true;\n }\n }\n if (isQuoted) throw new Error('Invalid NODE_OPTIONS: unterminated quoted string.');\n if (hasArgument) result.push(argument);\n return result;\n}\n\nexport function workerExecArgv(arguments_: readonly string[]): string[] {\n return parseArguments(arguments_).execArgv;\n}\n\n/**\n * Use the same custom conditions for static authoring resolution and fresh workers.\n * NODE_OPTIONS is not included in process.execArgv; do not replay its preloads.\n */\nexport function authoringNodeOptions(arguments_: readonly string[], nodeOptions = '') {\n const environment = parseArguments(environmentArguments(nodeOptions));\n const invocation = parseArguments(arguments_);\n const conditions = [...new Set([...environment.conditions, ...invocation.conditions])];\n return {\n conditions,\n execArgv: [...invocation.execArgv, ...environment.conditions.map((condition) => `--conditions=${condition}`)],\n };\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DirectoryPaths } from '../replace-directory.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Prepare the output parent without modifying live artifacts, then validate again
|
|
4
|
+
* and check input freshness and cancellation before rollback-safe installation.
|
|
5
|
+
*/
|
|
6
|
+
export declare function publishArtifacts(paths: DirectoryPaths, temporaryDirectory: string, authoredInputs: Iterable<string>, { signal, areInputsCurrent }: {
|
|
7
|
+
signal: AbortSignal;
|
|
8
|
+
areInputsCurrent: () => Promise<boolean>;
|
|
9
|
+
}): Promise<'published' | 'retry'>;
|
|
10
|
+
//# sourceMappingURL=publish.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.d.mts","sourceRoot":"","sources":["../../src/rolldown/publish.mts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI/D;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,cAAc,EACrB,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,EAChC,EAAE,MAAM,EAAE,gBAAgB,EAAE,EAAE;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,GAC9F,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,CAchC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { mkdir } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { replaceDirectory } from '../replace-directory.mjs';
|
|
4
|
+
import { assertSafeDirectories } from './directories.mjs';
|
|
5
|
+
/**
|
|
6
|
+
* Prepare the output parent without modifying live artifacts, then validate again
|
|
7
|
+
* and check input freshness and cancellation before rollback-safe installation.
|
|
8
|
+
*/
|
|
9
|
+
export async function publishArtifacts(paths, temporaryDirectory, authoredInputs, { signal, areInputsCurrent }) {
|
|
10
|
+
const inputs = [...authoredInputs];
|
|
11
|
+
signal.throwIfAborted();
|
|
12
|
+
await assertSafeDirectories(paths.output, temporaryDirectory, inputs);
|
|
13
|
+
signal.throwIfAborted();
|
|
14
|
+
await mkdir(path.dirname(paths.output), { recursive: true });
|
|
15
|
+
await assertSafeDirectories(paths.output, temporaryDirectory, inputs);
|
|
16
|
+
signal.throwIfAborted();
|
|
17
|
+
const isCurrent = await areInputsCurrent();
|
|
18
|
+
signal.throwIfAborted();
|
|
19
|
+
if (!isCurrent)
|
|
20
|
+
return 'retry';
|
|
21
|
+
// Once installation starts, let it complete or roll back rather than interrupt it.
|
|
22
|
+
await replaceDirectory(paths);
|
|
23
|
+
return 'published';
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=publish.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.mjs","sourceRoot":"","sources":["../../src/rolldown/publish.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAqB,EACrB,kBAA0B,EAC1B,cAAgC,EAChC,EAAE,MAAM,EAAE,gBAAgB,EAAqE;IAE/F,MAAM,MAAM,GAAG,CAAC,GAAG,cAAc,CAAC,CAAC;IACnC,MAAM,CAAC,cAAc,EAAE,CAAC;IACxB,MAAM,qBAAqB,CAAC,KAAK,CAAC,MAAM,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACtE,MAAM,CAAC,cAAc,EAAE,CAAC;IACxB,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,qBAAqB,CAAC,KAAK,CAAC,MAAM,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACtE,MAAM,CAAC,cAAc,EAAE,CAAC;IACxB,MAAM,SAAS,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAC3C,MAAM,CAAC,cAAc,EAAE,CAAC;IACxB,IAAI,CAAC,SAAS;QAAE,OAAO,OAAO,CAAC;IAC/B,mFAAmF;IACnF,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { replaceDirectory } from '../replace-directory.mjs';\nimport type { DirectoryPaths } from '../replace-directory.mjs';\n\nimport { assertSafeDirectories } from './directories.mjs';\n\n/**\n * Prepare the output parent without modifying live artifacts, then validate again\n * and check input freshness and cancellation before rollback-safe installation.\n */\nexport async function publishArtifacts(\n paths: DirectoryPaths,\n temporaryDirectory: string,\n authoredInputs: Iterable<string>,\n { signal, areInputsCurrent }: { signal: AbortSignal; areInputsCurrent: () => Promise<boolean> },\n): Promise<'published' | 'retry'> {\n const inputs = [...authoredInputs];\n signal.throwIfAborted();\n await assertSafeDirectories(paths.output, temporaryDirectory, inputs);\n signal.throwIfAborted();\n await mkdir(path.dirname(paths.output), { recursive: true });\n await assertSafeDirectories(paths.output, temporaryDirectory, inputs);\n signal.throwIfAborted();\n const isCurrent = await areInputsCurrent();\n signal.throwIfAborted();\n if (!isCurrent) return 'retry';\n // Once installation starts, let it complete or roll back rather than interrupt it.\n await replaceDirectory(paths);\n return 'published';\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture resolver metadata before resolution, retaining the first observed contents
|
|
3
|
+
* so changes made during a build invalidate the attempt rather than its baseline.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolutionInputs(snapshot: (file: string, contents: Uint8Array) => void, watchFile: (file: string) => void, explicitTsconfig: string | undefined): {
|
|
6
|
+
beforeResolve: (source: string, importer: string | undefined) => Promise<void>;
|
|
7
|
+
resolved: (file: string, packageJsonPath?: string) => Promise<void>;
|
|
8
|
+
files: Set<string>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=resolution.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution.d.mts","sourceRoot":"","sources":["../../src/rolldown/resolution.mts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,KAAK,IAAI,EACtD,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EACjC,gBAAgB,EAAE,MAAM,GAAG,SAAS;4BA0EC,MAAM,YAAY,MAAM,GAAG,SAAS,KAAG,OAAO,CAAC,IAAI,CAAC;qBAgB3D,MAAM,oBAAoB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;;EAO/E"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { isBuiltin } from 'node:module';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { findConfigFile, flattenDiagnosticMessageText, getParsedCommandLineOfConfigFile, sys } from 'typescript';
|
|
6
|
+
/**
|
|
7
|
+
* Capture resolver metadata before resolution, retaining the first observed contents
|
|
8
|
+
* so changes made during a build invalidate the attempt rather than its baseline.
|
|
9
|
+
*/
|
|
10
|
+
export function resolutionInputs(snapshot, watchFile, explicitTsconfig) {
|
|
11
|
+
const metadata = new Set();
|
|
12
|
+
const checked = new Set();
|
|
13
|
+
const configs = new Set();
|
|
14
|
+
const configDirectories = new Set();
|
|
15
|
+
function capture(file, contents) {
|
|
16
|
+
const absolute = path.resolve(file);
|
|
17
|
+
watchFile(absolute);
|
|
18
|
+
snapshot(absolute, contents);
|
|
19
|
+
metadata.add(absolute);
|
|
20
|
+
}
|
|
21
|
+
async function captureFile(file) {
|
|
22
|
+
if (checked.has(file))
|
|
23
|
+
return;
|
|
24
|
+
checked.add(file);
|
|
25
|
+
try {
|
|
26
|
+
capture(file, await readFile(file));
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (!(error instanceof Error && 'code' in error && ['ENOENT', 'ENOTDIR'].includes(String(error.code))))
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function captureConfig(file) {
|
|
34
|
+
if (configs.has(file))
|
|
35
|
+
return;
|
|
36
|
+
configs.add(file);
|
|
37
|
+
getParsedCommandLineOfConfigFile(file, {}, {
|
|
38
|
+
...sys,
|
|
39
|
+
readDirectory: () => [],
|
|
40
|
+
readFile(name) {
|
|
41
|
+
try {
|
|
42
|
+
const contents = readFileSync(name);
|
|
43
|
+
capture(name, contents);
|
|
44
|
+
return contents.toString('utf8');
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
|
|
48
|
+
return;
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
onUnRecoverableConfigFileDiagnostic(diagnostic) {
|
|
53
|
+
throw new Error(flattenDiagnosticMessageText(diagnostic.messageText, '\n'));
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function discoverConfig(file) {
|
|
58
|
+
if (explicitTsconfig) {
|
|
59
|
+
captureConfig(explicitTsconfig);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const directory = path.dirname(file);
|
|
63
|
+
if (configDirectories.has(directory))
|
|
64
|
+
return;
|
|
65
|
+
configDirectories.add(directory);
|
|
66
|
+
const config = findConfigFile(directory, (candidate) => sys.fileExists(candidate));
|
|
67
|
+
if (config)
|
|
68
|
+
captureConfig(config);
|
|
69
|
+
}
|
|
70
|
+
async function packageContext(directory, packageName) {
|
|
71
|
+
let current = directory;
|
|
72
|
+
while (true) {
|
|
73
|
+
await captureFile(path.join(current, 'package.json'));
|
|
74
|
+
if (packageName)
|
|
75
|
+
await captureFile(path.join(current, 'node_modules', packageName, 'package.json'));
|
|
76
|
+
const parent = path.dirname(current);
|
|
77
|
+
if (parent === current)
|
|
78
|
+
break;
|
|
79
|
+
current = parent;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function beforeResolve(source, importer) {
|
|
83
|
+
if (isBuiltin(source))
|
|
84
|
+
return;
|
|
85
|
+
const directory = importer ? path.dirname(importer) : path.dirname(path.resolve(source));
|
|
86
|
+
discoverConfig(importer ?? path.resolve(source));
|
|
87
|
+
const parts = source.split('/');
|
|
88
|
+
const packageName = !source.startsWith('.') && !source.startsWith('#') && !path.isAbsolute(source)
|
|
89
|
+
? source.startsWith('@')
|
|
90
|
+
? parts.slice(0, 2).join('/')
|
|
91
|
+
: parts[0]
|
|
92
|
+
: undefined;
|
|
93
|
+
await packageContext(directory, packageName);
|
|
94
|
+
if (source.startsWith('.') || path.isAbsolute(source))
|
|
95
|
+
await packageContext(path.resolve(importer ? directory : process.cwd(), source));
|
|
96
|
+
}
|
|
97
|
+
async function resolved(file, packageJsonPath) {
|
|
98
|
+
if (packageJsonPath)
|
|
99
|
+
await captureFile(packageJsonPath);
|
|
100
|
+
discoverConfig(file);
|
|
101
|
+
await packageContext(path.dirname(file));
|
|
102
|
+
}
|
|
103
|
+
return { beforeResolve, resolved, files: metadata };
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=resolution.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution.mjs","sourceRoot":"","sources":["../../src/rolldown/resolution.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,4BAA4B,EAAE,gCAAgC,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjH;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAsD,EACtD,SAAiC,EACjC,gBAAoC;IAEpC,MAAM,QAAQ,GAAG,IAAI,GA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,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,KAAK,UAAU,QAAQ,CAAC,IAAY,EAAE,eAAwB;QAC5D,IAAI,eAAe;YAAE,MAAM,WAAW,CAAC,eAAe,CAAC,CAAC;QACxD,cAAc,CAAC,IAAI,CAAC,CAAC;QACrB,MAAM,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACtD,CAAC","sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { isBuiltin } from 'node:module';\nimport path from 'node:path';\nimport { findConfigFile, flattenDiagnosticMessageText, getParsedCommandLineOfConfigFile, sys } from 'typescript';\n\n/**\n * Capture resolver metadata before resolution, retaining the first observed contents\n * so changes made during a build invalidate the attempt rather than its baseline.\n */\nexport function resolutionInputs(\n snapshot: (file: string, contents: Uint8Array) => void,\n watchFile: (file: string) => void,\n explicitTsconfig: string | undefined,\n) {\n const metadata = new Set<string>();\n const checked = new Set<string>();\n const configs = new Set<string>();\n const configDirectories = new Set<string>();\n\n function capture(file: string, contents: Uint8Array): void {\n const absolute = path.resolve(file);\n watchFile(absolute);\n snapshot(absolute, contents);\n metadata.add(absolute);\n }\n\n async function captureFile(file: string): Promise<void> {\n if (checked.has(file)) return;\n checked.add(file);\n try {\n capture(file, await readFile(file));\n } catch (error) {\n if (!(error instanceof Error && 'code' in error && ['ENOENT', 'ENOTDIR'].includes(String(error.code))))\n throw error;\n }\n }\n\n function captureConfig(file: string): void {\n if (configs.has(file)) return;\n configs.add(file);\n getParsedCommandLineOfConfigFile(\n file,\n {},\n {\n ...sys,\n readDirectory: () => [],\n readFile(name) {\n try {\n const contents = readFileSync(name);\n capture(name, contents);\n return contents.toString('utf8');\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return;\n throw error;\n }\n },\n onUnRecoverableConfigFileDiagnostic(diagnostic) {\n throw new Error(flattenDiagnosticMessageText(diagnostic.messageText, '\\n'));\n },\n },\n );\n }\n\n function discoverConfig(file: string): void {\n if (explicitTsconfig) {\n captureConfig(explicitTsconfig);\n return;\n }\n const directory = path.dirname(file);\n if (configDirectories.has(directory)) return;\n configDirectories.add(directory);\n const config = findConfigFile(directory, (candidate) => sys.fileExists(candidate));\n if (config) captureConfig(config);\n }\n\n async function packageContext(directory: string, packageName?: string): Promise<void> {\n let current = directory;\n while (true) {\n await captureFile(path.join(current, 'package.json'));\n if (packageName) await captureFile(path.join(current, 'node_modules', packageName, 'package.json'));\n const parent = path.dirname(current);\n if (parent === current) break;\n current = parent;\n }\n }\n\n async function beforeResolve(source: string, importer: string | undefined): Promise<void> {\n if (isBuiltin(source)) return;\n const directory = importer ? path.dirname(importer) : path.dirname(path.resolve(source));\n discoverConfig(importer ?? path.resolve(source));\n const parts = source.split('/');\n const packageName =\n !source.startsWith('.') && !source.startsWith('#') && !path.isAbsolute(source)\n ? source.startsWith('@')\n ? parts.slice(0, 2).join('/')\n : parts[0]\n : undefined;\n await packageContext(directory, packageName);\n if (source.startsWith('.') || path.isAbsolute(source))\n await packageContext(path.resolve(importer ? directory : process.cwd(), source));\n }\n\n async function resolved(file: string, packageJsonPath?: string): Promise<void> {\n if (packageJsonPath) await captureFile(packageJsonPath);\n discoverConfig(file);\n await packageContext(path.dirname(file));\n }\n\n return { beforeResolve, resolved, files: metadata };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-worker.d.mts","sourceRoot":"","sources":["../../src/rolldown/schema-worker.mts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { pathToFileURL } from 'node:url';
|
|
2
|
+
import { parentPort, workerData } from 'node:worker_threads';
|
|
3
|
+
import { generateArtifacts } from '../index.mjs';
|
|
4
|
+
if (!parentPort)
|
|
5
|
+
throw new Error('Schema generation must run in a worker.');
|
|
6
|
+
let result;
|
|
7
|
+
try {
|
|
8
|
+
const { entry, exportName, options } = workerData;
|
|
9
|
+
const namespace = (await import(pathToFileURL(entry).href));
|
|
10
|
+
const schemas = exportName === undefined ? { ...namespace } : namespace[exportName];
|
|
11
|
+
if (schemas === null || typeof schemas !== 'object' || Array.isArray(schemas))
|
|
12
|
+
throw new Error('The schema entry must export a record of named schemas.');
|
|
13
|
+
await generateArtifacts(schemas, options);
|
|
14
|
+
result = { type: 'json-schema-aot:complete', success: true };
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
result = {
|
|
18
|
+
type: 'json-schema-aot:complete',
|
|
19
|
+
success: false,
|
|
20
|
+
error: error instanceof Error ? error : new Error('Schema generation failed.', { cause: error }),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
parentPort.postMessage(result);
|
|
24
|
+
//# sourceMappingURL=schema-worker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-worker.mjs","sourceRoot":"","sources":["../../src/rolldown/schema-worker.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAKjD,IAAI,CAAC,UAAU;IAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;AAC5E,IAAI,MAAwB,CAAC;AAC7B,IAAI,CAAC;IACH,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,UAItC,CAAC;IACF,MAAM,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAA4B,CAAC;IACvF,MAAM,OAAO,GAAY,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7F,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAC3E,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,MAAM,iBAAiB,CAAC,OAA2C,EAAE,OAAO,CAAC,CAAC;IAC9E,MAAM,GAAG,EAAE,IAAI,EAAE,0BAA0B,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC/D,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,GAAG;QACP,IAAI,EAAE,0BAA0B;QAChC,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;KACjG,CAAC;AACJ,CAAC;AACD,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC","sourcesContent":["import { pathToFileURL } from 'node:url';\nimport { parentPort, workerData } from 'node:worker_threads';\n\nimport { generateArtifacts } from '../index.mjs';\nimport type { GenerateOptions } from '../index.mjs';\n\nimport type { GenerationResult } from './worker-protocol.mjs';\n\nif (!parentPort) throw new Error('Schema generation must run in a worker.');\nlet result: GenerationResult;\ntry {\n const { entry, exportName, options } = workerData as {\n entry: string;\n exportName?: string;\n options: GenerateOptions;\n };\n const namespace = (await import(pathToFileURL(entry).href)) as Record<string, unknown>;\n const schemas: unknown = exportName === undefined ? { ...namespace } : namespace[exportName];\n if (schemas === null || typeof schemas !== 'object' || Array.isArray(schemas))\n throw new Error('The schema entry must export a record of named schemas.');\n await generateArtifacts(schemas as Record<string, boolean | object>, options);\n result = { type: 'json-schema-aot:complete', success: true };\n} catch (error) {\n result = {\n type: 'json-schema-aot:complete',\n success: false,\n error: error instanceof Error ? error : new Error('Schema generation failed.', { cause: error }),\n };\n}\nparentPort.postMessage(result);\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type GenerationResult = {
|
|
2
|
+
type: 'json-schema-aot:complete';
|
|
3
|
+
success: true;
|
|
4
|
+
} | {
|
|
5
|
+
type: 'json-schema-aot:complete';
|
|
6
|
+
success: false;
|
|
7
|
+
error: Error;
|
|
8
|
+
};
|
|
9
|
+
export declare function isGenerationResult(value: unknown): value is GenerationResult;
|
|
10
|
+
//# sourceMappingURL=worker-protocol.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-protocol.d.mts","sourceRoot":"","sources":["../../src/rolldown/worker-protocol.mts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,0BAA0B,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,0BAA0B,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEvE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAS5E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function isGenerationResult(value) {
|
|
2
|
+
return (typeof value === 'object' &&
|
|
3
|
+
value !== null &&
|
|
4
|
+
'type' in value &&
|
|
5
|
+
value.type === 'json-schema-aot:complete' &&
|
|
6
|
+
'success' in value &&
|
|
7
|
+
(value.success === true || (value.success === false && 'error' in value && value.error instanceof Error)));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=worker-protocol.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-protocol.mjs","sourceRoot":"","sources":["../../src/rolldown/worker-protocol.mts"],"names":[],"mappings":"AAIA,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,KAAK,CAAC,IAAI,KAAK,0BAA0B;QACzC,SAAS,IAAI,KAAK;QAClB,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,KAAK,IAAI,OAAO,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAC1G,CAAC;AACJ,CAAC","sourcesContent":["export type GenerationResult =\n | { type: 'json-schema-aot:complete'; success: true }\n | { type: 'json-schema-aot:complete'; success: false; error: Error };\n\nexport function isGenerationResult(value: unknown): value is GenerationResult {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'type' in value &&\n value.type === 'json-schema-aot:complete' &&\n 'success' in value &&\n (value.success === true || (value.success === false && 'error' in value && value.error instanceof Error))\n );\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render the runtime adapter around AJV's standalone validator.
|
|
3
|
+
* Keep source templates separate from artifact staging and publication.
|
|
4
|
+
*/
|
|
5
|
+
export declare function validatorModuleSource(standalone: string, fields: readonly string[]): string;
|
|
6
|
+
/**
|
|
7
|
+
* Render the validator declarations alongside the independently generated data types.
|
|
8
|
+
*/
|
|
9
|
+
export declare function validatorDeclarationSource(declarations: string, name: string): string;
|
|
10
|
+
//# sourceMappingURL=validator-source.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator-source.d.mts","sourceRoot":"","sources":["../src/validator-source.mts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CA4B3F;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAwBrF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render the runtime adapter around AJV's standalone validator.
|
|
3
|
+
* Keep source templates separate from artifact staging and publication.
|
|
4
|
+
*/
|
|
5
|
+
export function validatorModuleSource(standalone, fields) {
|
|
6
|
+
return `${standalone}
|
|
7
|
+
export const fields = ${JSON.stringify(fields)};
|
|
8
|
+
export function validate(value) {
|
|
9
|
+
const valid = isValid(value);
|
|
10
|
+
return { valid, errors: valid ? [] : isValid.errors };
|
|
11
|
+
}
|
|
12
|
+
export const validator = {
|
|
13
|
+
'~standard': {
|
|
14
|
+
version: 1,
|
|
15
|
+
vendor: '@onereach/json-schema-aot',
|
|
16
|
+
validate(value) {
|
|
17
|
+
if (isValid(value)) return { value };
|
|
18
|
+
return {
|
|
19
|
+
issues: isValid.errors.map((error) => {
|
|
20
|
+
let pointer = error.instancePath;
|
|
21
|
+
if (error.keyword === 'required')
|
|
22
|
+
pointer += '/' + error.params.missingProperty.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
23
|
+
return {
|
|
24
|
+
message: error.message ?? 'Invalid value',
|
|
25
|
+
path: pointer === '' ? [] : pointer.slice(1).split('/').map((part) => part.replaceAll('~1', '/').replaceAll('~0', '~')),
|
|
26
|
+
};
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Render the validator declarations alongside the independently generated data types.
|
|
36
|
+
*/
|
|
37
|
+
export function validatorDeclarationSource(declarations, name) {
|
|
38
|
+
return `${declarations}
|
|
39
|
+
export declare const fields: readonly string[];
|
|
40
|
+
export declare const validator: {
|
|
41
|
+
readonly '~standard': {
|
|
42
|
+
readonly version: 1;
|
|
43
|
+
readonly vendor: string;
|
|
44
|
+
readonly validate: (value: unknown) =>
|
|
45
|
+
{ readonly value: ${name}; readonly issues?: undefined } |
|
|
46
|
+
{ readonly issues: readonly { readonly message: string; readonly path: readonly string[] }[] };
|
|
47
|
+
readonly types?: { readonly input: ${name}; readonly output: ${name} };
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export declare function isValid(value: unknown): value is ${name};
|
|
51
|
+
export declare function validate(value: unknown): {
|
|
52
|
+
valid: boolean;
|
|
53
|
+
errors: readonly {
|
|
54
|
+
instancePath: string;
|
|
55
|
+
message?: string;
|
|
56
|
+
keyword: string;
|
|
57
|
+
params: Record<string, unknown>;
|
|
58
|
+
}[];
|
|
59
|
+
};
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=validator-source.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator-source.mjs","sourceRoot":"","sources":["../src/validator-source.mts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAkB,EAAE,MAAyB;IACjF,OAAO,GAAG,UAAU;wBACE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyB7C,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,YAAoB,EAAE,IAAY;IAC3E,OAAO,GAAG,YAAY;;;;;;;0BAOE,IAAI;;yCAEW,IAAI,sBAAsB,IAAI;;;4DAGX,IAAI;;;;;;;;;;CAU/D,CAAC;AACF,CAAC","sourcesContent":["/**\n * Render the runtime adapter around AJV's standalone validator.\n * Keep source templates separate from artifact staging and publication.\n */\nexport function validatorModuleSource(standalone: string, fields: readonly string[]): string {\n return `${standalone}\nexport const fields = ${JSON.stringify(fields)};\nexport function validate(value) {\n const valid = isValid(value);\n return { valid, errors: valid ? [] : isValid.errors };\n}\nexport const validator = {\n '~standard': {\n version: 1,\n vendor: '@onereach/json-schema-aot',\n validate(value) {\n if (isValid(value)) return { value };\n return {\n issues: isValid.errors.map((error) => {\n let pointer = error.instancePath;\n if (error.keyword === 'required')\n pointer += '/' + error.params.missingProperty.replaceAll('~', '~0').replaceAll('/', '~1');\n return {\n message: error.message ?? 'Invalid value',\n path: pointer === '' ? [] : pointer.slice(1).split('/').map((part) => part.replaceAll('~1', '/').replaceAll('~0', '~')),\n };\n }),\n };\n },\n },\n};\n`;\n}\n\n/**\n * Render the validator declarations alongside the independently generated data types.\n */\nexport function validatorDeclarationSource(declarations: string, name: string): string {\n return `${declarations}\nexport declare const fields: readonly string[];\nexport declare const validator: {\n readonly '~standard': {\n readonly version: 1;\n readonly vendor: string;\n readonly validate: (value: unknown) =>\n { readonly value: ${name}; readonly issues?: undefined } |\n { readonly issues: readonly { readonly message: string; readonly path: readonly string[] }[] };\n readonly types?: { readonly input: ${name}; readonly output: ${name} };\n };\n};\nexport declare function isValid(value: unknown): value is ${name};\nexport declare function validate(value: unknown): {\n valid: boolean;\n errors: readonly {\n instancePath: string;\n message?: string;\n keyword: string;\n params: Record<string, unknown>;\n }[];\n};\n`;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onereach/json-schema-aot",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0-framework.2",
|
|
4
|
+
"description": "Build-time JSON Schema validators, Standard Schema objects, and independent declarations",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"./dist/rolldown/schema-worker.mjs"
|
|
8
|
+
],
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=24"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.mts",
|
|
16
|
+
"import": "./dist/index.mjs"
|
|
17
|
+
},
|
|
18
|
+
"./replace-directory": {
|
|
19
|
+
"types": "./dist/replace-directory.d.mts",
|
|
20
|
+
"import": "./dist/replace-directory.mjs"
|
|
21
|
+
},
|
|
22
|
+
"./rolldown": {
|
|
23
|
+
"types": "./dist/rolldown/index.d.mts",
|
|
24
|
+
"import": "./dist/rolldown/index.mjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"ajv": "^8.20.0",
|
|
35
|
+
"ajv-formats": "^3.0.1",
|
|
36
|
+
"json-schema-to-typescript": "^16.0.0",
|
|
37
|
+
"rolldown": "1.2.6",
|
|
38
|
+
"typescript": "^6.0.3"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@standard-schema/spec": "^1.1.0",
|
|
42
|
+
"@types/node": "^24.13.3",
|
|
43
|
+
"tsdown": "^0.22.14",
|
|
44
|
+
"vitest": "^4.1.11"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc --project tsconfig.build.json",
|
|
48
|
+
"typecheck": "tsc --noEmit --incremental --tsBuildInfoFile .cache/typecheck/source.tsbuildinfo && tsc --noEmit -p test/tsconfig.json --incremental --tsBuildInfoFile .cache/typecheck/test.tsbuildinfo",
|
|
49
|
+
"unit": "vitest run",
|
|
50
|
+
"unit:coverage": "vitest run --coverage"
|
|
51
|
+
}
|
|
6
52
|
}
|