@toolproof-core/schema 1.0.3 → 1.0.4
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/generated/normalized/Genesis.json +17 -9
- package/dist/generated/resources/Genesis.json +19 -11
- package/dist/generated/schemas/Genesis.json +15 -7
- package/dist/generated/schemas/standalone/RawStrategy.json +15 -7
- package/dist/generated/schemas/standalone/RunnableStrategy.json +15 -7
- package/dist/generated/schemas/standalone/StrategyRun.json +15 -7
- package/dist/generated/{types → typesTS}/standalone/Resource_Genesis.d.ts +1 -1
- package/{src/generated/types → dist/generated/typesTS}/standalone/Resource_Job.d.ts +1 -1
- package/dist/generated/{types → typesTS}/standalone/Resource_RawStrategy.d.ts +1 -1
- package/{src/generated/types → dist/generated/typesTS}/standalone/Resource_ResourceType.d.ts +1 -1
- package/dist/generated/{types → typesTS}/standalone/Resource_RunnableStrategy.d.ts +1 -1
- package/dist/generated/typesTS/typesTS.d.ts +745 -0
- package/dist/index.d.ts +6 -9
- package/dist/index.js +0 -2
- package/dist/scripts/_lib/config.d.ts +10 -10
- package/dist/scripts/_lib/config.js +23 -23
- package/dist/scripts/extractSchemasFromResourceTypeShells.js +109 -103
- package/dist/scripts/generateDependencies.js +15 -14
- package/dist/scripts/generateSchemaShims.js +76 -84
- package/dist/scripts/generateStandaloneSchema.js +47 -37
- package/dist/scripts/generateStandaloneTypeTS.js +108 -0
- package/dist/scripts/generateTypesTS.js +430 -0
- package/dist/scripts/normalizeAnchorsToPointers.js +37 -30
- package/dist/scripts/wrapResourceTypesWithResourceShells.js +14 -16
- package/package.json +11 -12
- package/src/Genesis.json +2007 -1999
- package/{dist/generated → src/generated/dependencies}/dependencyMap.json +8 -7
- package/src/generated/normalized/Genesis.json +17 -9
- package/src/generated/resources/Genesis.json +19 -11
- package/src/generated/schemas/Genesis.json +15 -7
- package/src/generated/schemas/standalone/RawStrategy.json +15 -7
- package/src/generated/schemas/standalone/RunnableStrategy.json +15 -7
- package/src/generated/schemas/standalone/StrategyRun.json +15 -7
- package/src/generated/{types → typesTS}/standalone/Resource_Genesis.d.ts +1 -1
- package/{dist/generated/types → src/generated/typesTS}/standalone/Resource_Job.d.ts +1 -1
- package/src/generated/{types → typesTS}/standalone/Resource_RawStrategy.d.ts +1 -1
- package/{dist/generated/types → src/generated/typesTS}/standalone/Resource_ResourceType.d.ts +1 -1
- package/src/generated/{types → typesTS}/standalone/Resource_RunnableStrategy.d.ts +1 -1
- package/src/generated/typesTS/typesTS.d.ts +745 -0
- package/src/index.ts +67 -93
- package/src/scripts/_lib/config.ts +205 -205
- package/src/scripts/extractSchemasFromResourceTypeShells.ts +261 -218
- package/src/scripts/generateDependencies.ts +121 -120
- package/src/scripts/generateSchemaShims.ts +127 -135
- package/src/scripts/generateStandaloneSchema.ts +185 -175
- package/src/scripts/generateStandaloneTypeTS.ts +127 -0
- package/src/scripts/generateTypesTS.ts +532 -0
- package/src/scripts/normalizeAnchorsToPointers.ts +115 -123
- package/src/scripts/wrapResourceTypesWithResourceShells.ts +82 -84
- package/dist/generated/types/types.d.ts +0 -1723
- package/dist/scripts/generateStandaloneType.js +0 -102
- package/dist/scripts/generateTypes.js +0 -550
- package/src/generated/dependencyMap.json +0 -292
- package/src/generated/types/types.d.ts +0 -1723
- package/src/scripts/generateStandaloneType.ts +0 -119
- package/src/scripts/generateTypes.ts +0 -615
- /package/dist/generated/{types → typesTS}/standalone/Resource_Genesis.js +0 -0
- /package/dist/generated/{types → typesTS}/standalone/Resource_Job.js +0 -0
- /package/dist/generated/{types → typesTS}/standalone/Resource_RawStrategy.js +0 -0
- /package/dist/generated/{types → typesTS}/standalone/Resource_ResourceType.js +0 -0
- /package/dist/generated/{types → typesTS}/standalone/Resource_RunnableStrategy.js +0 -0
- /package/dist/generated/{types/types.js → typesTS/typesTS.js} +0 -0
- /package/dist/scripts/{generateStandaloneType.d.ts → generateStandaloneTypeTS.d.ts} +0 -0
- /package/dist/scripts/{generateTypes.d.ts → generateTypesTS.d.ts} +0 -0
- /package/src/generated/{types → typesTS}/standalone/Resource_Genesis.js +0 -0
- /package/src/generated/{types → typesTS}/standalone/Resource_Job.js +0 -0
- /package/src/generated/{types → typesTS}/standalone/Resource_RawStrategy.js +0 -0
- /package/src/generated/{types → typesTS}/standalone/Resource_ResourceType.js +0 -0
- /package/src/generated/{types → typesTS}/standalone/Resource_RunnableStrategy.js +0 -0
- /package/src/generated/{types/types.js → typesTS/typesTS.js} +0 -0
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { getConfig } from './_lib/config.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Generate a typed Resource variant where `nucleus` is typed to a specific schema
|
|
7
|
-
* extracted under the configured output directory.
|
|
8
|
-
*
|
|
9
|
-
* Usage: node ./dist/scripts/generateStandaloneType.js --name Job
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Pure function to generate the typed Resource D.TS content.
|
|
13
|
-
*
|
|
14
|
-
* @param name The name of the schema
|
|
15
|
-
* @returns The TypeScript D.TS file content
|
|
16
|
-
*/
|
|
17
|
-
function generateStandaloneTypeLogic(name: string): string {
|
|
18
|
-
const header = '// Auto-generated strict composite type. Do not edit.\n';
|
|
19
|
-
const ts =
|
|
20
|
-
`import type { ShellMaterializedBase, ${name} as NucleusSchema } from '../types.js';\n` +
|
|
21
|
-
`export type Resource_${name} = ShellMaterializedBase & { nucleus: NucleusSchema };\n`;
|
|
22
|
-
return header + ts;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async function main() {
|
|
26
|
-
const config = getConfig();
|
|
27
|
-
const { name } = parseArgs(process.argv.slice(2));
|
|
28
|
-
if (!name) {
|
|
29
|
-
console.error('Missing --name <SchemaBasename> argument');
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const inPath =
|
|
34
|
-
name === 'Genesis'
|
|
35
|
-
? config.getSchemaPath('Genesis.json')
|
|
36
|
-
: config.getSchemaStandalonePath(`${name}.json`);
|
|
37
|
-
|
|
38
|
-
if (!fs.existsSync(inPath)) {
|
|
39
|
-
if (name === 'Genesis') {
|
|
40
|
-
console.error(`Schema file not found: ${inPath}`);
|
|
41
|
-
console.error('Run extractSchemasFromResourceTypeShells first.');
|
|
42
|
-
} else {
|
|
43
|
-
console.error(`Standalone schema file not found: ${inPath}`);
|
|
44
|
-
console.error(`Run generateStandaloneSchema -- --name ${name} first.`);
|
|
45
|
-
}
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Basic validation against the expected shape of nucleusSchema.
|
|
50
|
-
const raw = fs.readFileSync(inPath, 'utf8');
|
|
51
|
-
let parsed: any = null;
|
|
52
|
-
try {
|
|
53
|
-
parsed = JSON.parse(raw);
|
|
54
|
-
} catch (e) {
|
|
55
|
-
console.error(`Failed to parse JSON schema ${inPath}:`, e);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Minimal checks that roughly match the nucleusSchema constraints used elsewhere.
|
|
60
|
-
if (parsed.$schema && parsed.$schema !== 'https://json-schema.org/draft/2020-12/schema') {
|
|
61
|
-
console.warn(`Warning: schema $schema is '${parsed.$schema}', expected draft 2020-12. Proceeding anyway.`);
|
|
62
|
-
}
|
|
63
|
-
if (parsed.type && parsed.type !== 'object') {
|
|
64
|
-
console.warn(`Warning: nucleusSchema usually has type: 'object' but this schema has type: '${parsed.type}'. Proceeding.`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const tsContent = generateStandaloneTypeLogic(name);
|
|
68
|
-
const jsContent = 'export {}\n';
|
|
69
|
-
|
|
70
|
-
// Output setup
|
|
71
|
-
const outName = `Resource_${name}.d.ts`;
|
|
72
|
-
const outJsName = `Resource_${name}.js`;
|
|
73
|
-
|
|
74
|
-
// Process src output
|
|
75
|
-
const outDir = config.getTypesStandaloneSrcDir();
|
|
76
|
-
fs.mkdirSync(outDir, { recursive: true });
|
|
77
|
-
|
|
78
|
-
const outPath = config.getTypesStandaloneSrcPath(outName);
|
|
79
|
-
const outJsPath = config.getTypesStandaloneSrcPath(outJsName);
|
|
80
|
-
|
|
81
|
-
fs.writeFileSync(outPath, tsContent, 'utf8');
|
|
82
|
-
console.log(`Wrote ${outPath}`);
|
|
83
|
-
|
|
84
|
-
if (!fs.existsSync(outJsPath)) {
|
|
85
|
-
fs.writeFileSync(outJsPath, jsContent, 'utf8');
|
|
86
|
-
console.log(`Wrote ${outJsPath}`);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Process dist output
|
|
90
|
-
const distLibDir = config.getTypesStandaloneDistDir();
|
|
91
|
-
fs.mkdirSync(distLibDir, { recursive: true });
|
|
92
|
-
|
|
93
|
-
const distDtsPath = config.getTypesStandaloneDistPath(outName);
|
|
94
|
-
const distJsPath = config.getTypesStandaloneDistPath(outJsName);
|
|
95
|
-
|
|
96
|
-
fs.writeFileSync(distDtsPath, tsContent, 'utf8');
|
|
97
|
-
fs.writeFileSync(distJsPath, jsContent, 'utf8');
|
|
98
|
-
console.log(`Wrote ${distDtsPath}`);
|
|
99
|
-
console.log(`Wrote ${distJsPath}`);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function parseArgs(args: string[]): { name?: string } {
|
|
103
|
-
let name: string | undefined;
|
|
104
|
-
for (let i = 0; i < args.length; i++) {
|
|
105
|
-
const a = args[i];
|
|
106
|
-
if (a === '--name') {
|
|
107
|
-
name = args[i + 1];
|
|
108
|
-
i++;
|
|
109
|
-
} else if (a.startsWith('--name=')) {
|
|
110
|
-
name = a.split('=')[1];
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return { name };
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
main().catch((e) => {
|
|
117
|
-
console.error(e);
|
|
118
|
-
process.exit(1);
|
|
119
|
-
});
|