@toolproof-core/schema 1.0.9 → 1.0.10
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/artifacts/constants.d.ts +120 -0
- package/dist/generated/artifacts/constants.js +120 -0
- package/dist/generated/artifacts/mappings.d.ts +23 -0
- package/dist/generated/artifacts/mappings.js +23 -0
- package/dist/generated/normalized/Genesis.json +67 -53
- package/dist/generated/resources/Genesis.json +424 -236
- package/dist/generated/schemas/Genesis.json +56 -42
- package/dist/generated/schemas/standalone/Job.json +2 -0
- package/dist/generated/schemas/standalone/RawStrategy.json +86 -110
- package/dist/generated/schemas/standalone/RunnableStrategy.json +108 -132
- package/dist/generated/schemas/standalone/StrategyRun.json +86 -110
- package/dist/generated/types/types.d.ts +34 -34
- package/dist/index.d.ts +6 -3
- package/dist/index.js +5 -2
- package/dist/scripts/_lib/config.d.ts +3 -5
- package/dist/scripts/_lib/config.js +8 -14
- package/dist/scripts/generateConstantsAndMappings.d.ts +31 -0
- package/dist/scripts/generateConstantsAndMappings.js +243 -0
- package/dist/scripts/generateDependencies.js +1 -1
- package/dist/scripts/generateTerminals.js +2 -2
- package/dist/scripts/generateTypes.js +47 -2
- package/dist/scripts/wrapResourceTypesWithResourceShells.js +7 -3
- package/package.json +9 -10
- package/src/Genesis.json +1847 -1833
- package/src/generated/artifacts/constants.ts +121 -0
- package/src/generated/{dependencies → artifacts}/dependencyMap.json +16 -18
- package/src/generated/artifacts/mappings.ts +24 -0
- package/src/generated/{dependencies → artifacts}/terminals.json +1 -0
- package/src/generated/normalized/Genesis.json +1760 -1746
- package/src/generated/resources/Genesis.json +2796 -2608
- package/src/generated/schemas/Genesis.json +1329 -1315
- package/src/generated/schemas/standalone/Job.json +2 -0
- package/src/generated/schemas/standalone/RawStrategy.json +580 -604
- package/src/generated/schemas/standalone/RunnableStrategy.json +645 -669
- package/src/generated/schemas/standalone/StrategyRun.json +913 -937
- package/src/generated/types/types.d.ts +709 -709
- package/src/index.ts +75 -70
- package/src/scripts/_lib/config.ts +207 -215
- package/src/scripts/extractSchemasFromResourceTypeShells.ts +261 -261
- package/src/scripts/generateConstantsAndMappings.ts +309 -0
- package/src/scripts/generateDependencies.ts +121 -121
- package/src/scripts/generateSchemaShims.ts +127 -127
- package/src/scripts/generateStandaloneSchema.ts +185 -185
- package/src/scripts/generateStandaloneType.ts +127 -127
- package/src/scripts/generateTerminals.ts +73 -73
- package/src/scripts/generateTypes.ts +587 -531
- package/src/scripts/normalizeAnchorsToPointers.ts +141 -141
- package/src/scripts/wrapResourceTypesWithResourceShells.ts +86 -82
- package/dist/generated/constants/constants.d.ts +0 -60
- package/dist/generated/constants/constants.js +0 -60
- package/dist/scripts/generateConstants.d.ts +0 -12
- package/dist/scripts/generateConstants.js +0 -179
- package/src/generated/constants/constants.ts +0 -61
- package/src/scripts/generateConstants.ts +0 -217
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
// PURE: Convert a string enum member into PascalCase.
|
|
5
|
+
// Examples: 'job' -> 'Job', 'graph_start' -> 'GraphStart'
|
|
6
|
+
function toPascalCase(value) {
|
|
7
|
+
return value
|
|
8
|
+
.split(/[^A-Za-z0-9]+/g)
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
11
|
+
.join('');
|
|
12
|
+
}
|
|
13
|
+
// PURE: Attempt to derive a canonical identity prefix from a canonical identity regex pattern.
|
|
14
|
+
function deriveIdentityPrefixFromPattern(pattern) {
|
|
15
|
+
// Canonical (currently used across schemas): ^PREFIX-.+$
|
|
16
|
+
const match = /^\^([^$]+)\.\+\$$/.exec(pattern);
|
|
17
|
+
if (!match)
|
|
18
|
+
return undefined;
|
|
19
|
+
const prefix = match[1];
|
|
20
|
+
if (!prefix || /[`\n\r]/.test(prefix))
|
|
21
|
+
return undefined;
|
|
22
|
+
return prefix;
|
|
23
|
+
}
|
|
24
|
+
// PURE: Extract all identity prefixes from `$defs/*Identity` string-pattern definitions.
|
|
25
|
+
export function extractIdentityPrefixes(schema) {
|
|
26
|
+
if (!schema || typeof schema !== 'object')
|
|
27
|
+
return {};
|
|
28
|
+
const defs = schema.$defs;
|
|
29
|
+
if (!defs || typeof defs !== 'object')
|
|
30
|
+
return {};
|
|
31
|
+
const defEntries = Object.entries(defs);
|
|
32
|
+
defEntries.sort(([a], [b]) => a.localeCompare(b));
|
|
33
|
+
const out = {};
|
|
34
|
+
for (const [defName, defVal] of defEntries) {
|
|
35
|
+
if (!/Identity$/.test(defName))
|
|
36
|
+
continue;
|
|
37
|
+
if (!defVal || typeof defVal !== 'object' || Array.isArray(defVal))
|
|
38
|
+
continue;
|
|
39
|
+
const v = defVal;
|
|
40
|
+
if (v.type !== 'string')
|
|
41
|
+
continue;
|
|
42
|
+
if (typeof v.pattern !== 'string')
|
|
43
|
+
continue;
|
|
44
|
+
const prefix = deriveIdentityPrefixFromPattern(v.pattern);
|
|
45
|
+
if (!prefix)
|
|
46
|
+
continue;
|
|
47
|
+
out[defName] = prefix;
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
// PURE: Extract all subschema names from `$defs/*`.
|
|
52
|
+
// Shape: { JobStep: 'JobStep', StepKind: 'StepKind', ... }
|
|
53
|
+
export function extractSubschemaNames(schema) {
|
|
54
|
+
if (!schema || typeof schema !== 'object')
|
|
55
|
+
return {};
|
|
56
|
+
const defs = schema.$defs;
|
|
57
|
+
if (!defs || typeof defs !== 'object')
|
|
58
|
+
return {};
|
|
59
|
+
const defEntries = Object.entries(defs);
|
|
60
|
+
defEntries.sort(([a], [b]) => a.localeCompare(b));
|
|
61
|
+
const out = {};
|
|
62
|
+
for (const [defName] of defEntries) {
|
|
63
|
+
if (!defName || /[\n\r`]/.test(defName))
|
|
64
|
+
continue;
|
|
65
|
+
out[defName] = defName;
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
// PURE: Extract all string enums from `$defs/*Kind|*Status` definitions.
|
|
70
|
+
// Shape: { StepKind: { job: 'job', ... }, ResourceShellKind: { inputPotential': 'inputPotential', ... } }
|
|
71
|
+
export function extractEnums(schema) {
|
|
72
|
+
if (!schema || typeof schema !== 'object')
|
|
73
|
+
return {};
|
|
74
|
+
const defs = schema.$defs;
|
|
75
|
+
if (!defs || typeof defs !== 'object')
|
|
76
|
+
return {};
|
|
77
|
+
const defEntries = Object.entries(defs);
|
|
78
|
+
defEntries.sort(([a], [b]) => a.localeCompare(b));
|
|
79
|
+
const out = {};
|
|
80
|
+
for (const [defName, defVal] of defEntries) {
|
|
81
|
+
if (!/(Kind|Status)$/.test(defName))
|
|
82
|
+
continue;
|
|
83
|
+
if (!defVal || typeof defVal !== 'object' || Array.isArray(defVal))
|
|
84
|
+
continue;
|
|
85
|
+
const v = defVal;
|
|
86
|
+
if (v.type !== 'string')
|
|
87
|
+
continue;
|
|
88
|
+
if (!Array.isArray(v.enum) || v.enum.length === 0)
|
|
89
|
+
continue;
|
|
90
|
+
if (v.enum.some((x) => typeof x !== 'string'))
|
|
91
|
+
continue;
|
|
92
|
+
const members = {};
|
|
93
|
+
for (const member of v.enum) {
|
|
94
|
+
members[member] = member;
|
|
95
|
+
}
|
|
96
|
+
out[defName] = members;
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
// PURE: Derive a StepKind -> StepIdentityPrefix mapping.
|
|
101
|
+
// Example: { job: 'job' } + IdentityNameToIdentityPrefix['JobStepIdentity']='JOB_STEP-' => { job: 'JOB_STEP-' }
|
|
102
|
+
export function deriveStepKindToStepIdentityPrefix(enums, identityNameToIdentityPrefix) {
|
|
103
|
+
const stepKindEnum = enums.StepKind;
|
|
104
|
+
if (!stepKindEnum || typeof stepKindEnum !== 'object')
|
|
105
|
+
return { mapping: {}, missing: [] };
|
|
106
|
+
const stepKinds = Object.keys(stepKindEnum).sort((a, b) => a.localeCompare(b));
|
|
107
|
+
const mapping = {};
|
|
108
|
+
const missing = [];
|
|
109
|
+
for (const stepKind of stepKinds) {
|
|
110
|
+
const identityName = `${toPascalCase(stepKind)}StepIdentity`;
|
|
111
|
+
const prefix = identityNameToIdentityPrefix[identityName];
|
|
112
|
+
if (!prefix) {
|
|
113
|
+
missing.push({ stepKind, identityName });
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
mapping[stepKind] = prefix;
|
|
117
|
+
}
|
|
118
|
+
return { mapping, missing };
|
|
119
|
+
}
|
|
120
|
+
// PURE: Extract generated CONSTANTS + MAPPINGS from a parsed schema.
|
|
121
|
+
export function extractGeneratedConstantsAndMappings(schema) {
|
|
122
|
+
const names = extractSubschemaNames(schema);
|
|
123
|
+
const enums = extractEnums(schema);
|
|
124
|
+
const identityPrefixes = extractIdentityPrefixes(schema);
|
|
125
|
+
const derivedStepKind = deriveStepKindToStepIdentityPrefix(enums, identityPrefixes);
|
|
126
|
+
return {
|
|
127
|
+
CONSTANTS: {
|
|
128
|
+
Names: names,
|
|
129
|
+
Enums: enums,
|
|
130
|
+
},
|
|
131
|
+
MAPPINGS: {
|
|
132
|
+
IdentityNameToIdentityPrefix: identityPrefixes,
|
|
133
|
+
StepKindToStepIdentityPrefix: derivedStepKind.mapping,
|
|
134
|
+
},
|
|
135
|
+
DIAGNOSTICS: {
|
|
136
|
+
missingStepKindIdentityPrefixes: derivedStepKind.missing,
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
// PURE: Render helpers for TS keys/strings.
|
|
141
|
+
function escapeTsString(value) {
|
|
142
|
+
return value
|
|
143
|
+
.replace(/\\/g, '\\\\')
|
|
144
|
+
.replace(/\r/g, '\\r')
|
|
145
|
+
.replace(/\n/g, '\\n')
|
|
146
|
+
.replace(/\t/g, '\\t')
|
|
147
|
+
.replace(/'/g, "\\'");
|
|
148
|
+
}
|
|
149
|
+
function renderTsStringLiteral(value) {
|
|
150
|
+
return `'${escapeTsString(value)}'`;
|
|
151
|
+
}
|
|
152
|
+
function isValidTsIdentifier(key) {
|
|
153
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key);
|
|
154
|
+
}
|
|
155
|
+
function renderTsKey(key) {
|
|
156
|
+
return isValidTsIdentifier(key) ? key : renderTsStringLiteral(key);
|
|
157
|
+
}
|
|
158
|
+
// PURE: Render constants TypeScript source.
|
|
159
|
+
export function renderConstantsTs(constants) {
|
|
160
|
+
const nameKeys = Object.keys(constants.Names).sort((a, b) => a.localeCompare(b));
|
|
161
|
+
const enumKeys = Object.keys(constants.Enums).sort((a, b) => a.localeCompare(b));
|
|
162
|
+
const lines = [];
|
|
163
|
+
lines.push('const CONSTANTS = {');
|
|
164
|
+
lines.push(' Names: {');
|
|
165
|
+
for (const key of nameKeys) {
|
|
166
|
+
const value = constants.Names[key] ?? '';
|
|
167
|
+
lines.push(` ${renderTsKey(key)}: ${renderTsStringLiteral(value)},`);
|
|
168
|
+
}
|
|
169
|
+
lines.push(' },');
|
|
170
|
+
lines.push(' Enums: {');
|
|
171
|
+
for (const key of enumKeys) {
|
|
172
|
+
const members = constants.Enums[key] ?? {};
|
|
173
|
+
lines.push(` ${renderTsKey(key)}: {`);
|
|
174
|
+
for (const memberKey of Object.keys(members)) {
|
|
175
|
+
const value = members[memberKey] ?? '';
|
|
176
|
+
lines.push(` ${renderTsKey(memberKey)}: ${renderTsStringLiteral(value)},`);
|
|
177
|
+
}
|
|
178
|
+
lines.push(' },');
|
|
179
|
+
}
|
|
180
|
+
lines.push(' }');
|
|
181
|
+
lines.push('} as const;');
|
|
182
|
+
lines.push('');
|
|
183
|
+
lines.push('export default CONSTANTS;');
|
|
184
|
+
lines.push('');
|
|
185
|
+
return lines.join('\n');
|
|
186
|
+
}
|
|
187
|
+
// PURE: Render mappings TypeScript source.
|
|
188
|
+
export function renderMappingsTs(mappings) {
|
|
189
|
+
const identityKeys = Object.keys(mappings.IdentityNameToIdentityPrefix).sort((a, b) => a.localeCompare(b));
|
|
190
|
+
const stepKindKeys = Object.keys(mappings.StepKindToStepIdentityPrefix).sort((a, b) => a.localeCompare(b));
|
|
191
|
+
const lines = [];
|
|
192
|
+
lines.push('const MAPPINGS = {');
|
|
193
|
+
lines.push(' IdentityNameToIdentityPrefix: {');
|
|
194
|
+
for (const key of identityKeys) {
|
|
195
|
+
const value = mappings.IdentityNameToIdentityPrefix[key] ?? '';
|
|
196
|
+
lines.push(` ${renderTsKey(key)}: ${renderTsStringLiteral(value)},`);
|
|
197
|
+
}
|
|
198
|
+
lines.push(' },');
|
|
199
|
+
lines.push(' StepKindToStepIdentityPrefix: {');
|
|
200
|
+
for (const key of stepKindKeys) {
|
|
201
|
+
const value = mappings.StepKindToStepIdentityPrefix[key] ?? '';
|
|
202
|
+
lines.push(` ${renderTsKey(key)}: ${renderTsStringLiteral(value)},`);
|
|
203
|
+
}
|
|
204
|
+
lines.push(' },');
|
|
205
|
+
lines.push('} as const;');
|
|
206
|
+
lines.push('');
|
|
207
|
+
lines.push('export default MAPPINGS;');
|
|
208
|
+
lines.push('');
|
|
209
|
+
return lines.join('\n');
|
|
210
|
+
}
|
|
211
|
+
// IMPURE: Script entrypoint (config + filesystem I/O + console + process exit code).
|
|
212
|
+
function main() {
|
|
213
|
+
try {
|
|
214
|
+
const config = getConfig();
|
|
215
|
+
const inPath = config.getSchemaPath('Genesis.json');
|
|
216
|
+
const outConstantsPath = config.getArtifactsPath('constants.ts');
|
|
217
|
+
const outMappingsPath = config.getArtifactsPath('mappings.ts');
|
|
218
|
+
if (!fs.existsSync(inPath)) {
|
|
219
|
+
throw new Error(`Genesis schema not found at ${inPath}. Run extractSchemasFromResourceTypeShells first.`);
|
|
220
|
+
}
|
|
221
|
+
const raw = fs.readFileSync(inPath, 'utf8');
|
|
222
|
+
const doc = JSON.parse(raw);
|
|
223
|
+
const { CONSTANTS, MAPPINGS, DIAGNOSTICS } = extractGeneratedConstantsAndMappings(doc);
|
|
224
|
+
if (DIAGNOSTICS.missingStepKindIdentityPrefixes.length) {
|
|
225
|
+
const rows = DIAGNOSTICS.missingStepKindIdentityPrefixes
|
|
226
|
+
.map(({ stepKind, identityName }) => `${stepKind} -> ${identityName}`)
|
|
227
|
+
.join(', ');
|
|
228
|
+
throw new Error(`Missing IdentityNameToIdentityPrefix entries required for StepKindToStepIdentityPrefix: ${rows}`);
|
|
229
|
+
}
|
|
230
|
+
const constantsTs = renderConstantsTs(CONSTANTS);
|
|
231
|
+
const mappingsTs = renderMappingsTs(MAPPINGS);
|
|
232
|
+
fs.mkdirSync(path.dirname(outConstantsPath), { recursive: true });
|
|
233
|
+
fs.writeFileSync(outConstantsPath, constantsTs, 'utf8');
|
|
234
|
+
fs.writeFileSync(outMappingsPath, mappingsTs, 'utf8');
|
|
235
|
+
console.log(`Wrote constants to ${outConstantsPath}`);
|
|
236
|
+
console.log(`Wrote mappings to ${outMappingsPath}`);
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
console.error(`Error generating constants/mappings: ${error?.message ?? error}`);
|
|
240
|
+
process.exitCode = 1;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
main();
|
|
@@ -88,7 +88,7 @@ function main() {
|
|
|
88
88
|
try {
|
|
89
89
|
const config = getConfig();
|
|
90
90
|
const inPath = config.getSchemaPath("Genesis.json");
|
|
91
|
-
const outPath = config.
|
|
91
|
+
const outPath = config.getArtifactsPath("dependencyMap.json");
|
|
92
92
|
if (!fs.existsSync(inPath)) {
|
|
93
93
|
throw new Error(`Genesis schema not found at ${inPath}. Run extractSchemasFromResourceTypeShells first.`);
|
|
94
94
|
}
|
|
@@ -37,8 +37,8 @@ function computeTerminalsInKeyOrder(dependencyMap) {
|
|
|
37
37
|
function main() {
|
|
38
38
|
try {
|
|
39
39
|
const config = getConfig();
|
|
40
|
-
const inPath = config.
|
|
41
|
-
const outPath =
|
|
40
|
+
const inPath = config.getArtifactsPath("dependencyMap.json");
|
|
41
|
+
const outPath = config.getArtifactsPath("terminals.json");
|
|
42
42
|
if (!fs.existsSync(inPath)) {
|
|
43
43
|
throw new Error(`Dependency map not found at ${inPath}. Run generateDependencies first.`);
|
|
44
44
|
}
|
|
@@ -227,6 +227,48 @@ function removeDuplicateUnionEntries(ts) {
|
|
|
227
227
|
function escapeRegExpLiteral(value) {
|
|
228
228
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
229
229
|
}
|
|
230
|
+
// PURE: Derive the TS value type for JobStepSocket from Genesis.json.
|
|
231
|
+
// We prefer to match the schema shape:
|
|
232
|
+
// JobStepSocket.additionalProperties.oneOf = [#ResourcePotential, #Resource]
|
|
233
|
+
// so the emitted TS becomes:
|
|
234
|
+
// Record<ResourceRoleIdentity, Resource | ResourcePotential>
|
|
235
|
+
function deriveJobStepSocketValueType(parsedSchema) {
|
|
236
|
+
// NOTE: The generator reads from `src/generated/schemas/Genesis.json`, where `$defs.*`
|
|
237
|
+
// entries are plain JSON-Schema objects.
|
|
238
|
+
// The source-of-truth `src/Genesis.json` uses a wrapper shape:
|
|
239
|
+
// $defs.X = { identity, name, description, nucleusSchema: { ...actual schema... } }
|
|
240
|
+
// Support both.
|
|
241
|
+
const defs = parsedSchema?.$defs ?? parsedSchema?.nucleusSchema?.$defs;
|
|
242
|
+
const def = defs?.JobStepSocket;
|
|
243
|
+
const schemaNode = def?.nucleusSchema ?? def;
|
|
244
|
+
const additionalProperties = schemaNode?.additionalProperties;
|
|
245
|
+
if (!additionalProperties || typeof additionalProperties !== 'object' || Array.isArray(additionalProperties)) {
|
|
246
|
+
return 'Resource';
|
|
247
|
+
}
|
|
248
|
+
const union = additionalProperties.oneOf ??
|
|
249
|
+
additionalProperties.anyOf;
|
|
250
|
+
if (!Array.isArray(union) || union.length === 0) {
|
|
251
|
+
return 'Resource';
|
|
252
|
+
}
|
|
253
|
+
const names = [];
|
|
254
|
+
for (const item of union) {
|
|
255
|
+
const ref = item && typeof item === 'object' ? item.$ref : undefined;
|
|
256
|
+
if (typeof ref !== 'string')
|
|
257
|
+
continue;
|
|
258
|
+
// Accept both internal anchor refs like "#Resource" and JSON Pointer refs like "#/$defs/Resource".
|
|
259
|
+
const m = /^#(?:\/(?:\$defs|definitions)\/)?([A-Za-z_][A-Za-z0-9_]*)$/.exec(ref);
|
|
260
|
+
if (m)
|
|
261
|
+
names.push(m[1]);
|
|
262
|
+
}
|
|
263
|
+
const unique = Array.from(new Set(names));
|
|
264
|
+
if (!unique.length)
|
|
265
|
+
return 'Resource';
|
|
266
|
+
// Preserve an intentional ordering when we recognize the canonical pair.
|
|
267
|
+
if (unique.includes('Resource') && unique.includes('ResourcePotential')) {
|
|
268
|
+
return 'Resource | ResourcePotential';
|
|
269
|
+
}
|
|
270
|
+
return unique.join(' | ');
|
|
271
|
+
}
|
|
230
272
|
// PURE: Fix a known json-schema-to-typescript edge case where a JSON-like recursive value union
|
|
231
273
|
// accidentally includes a direct self-reference (`| JsonData`) instead of the intended array case (`| JsonData[]`).
|
|
232
274
|
function fixJsonDataSelfReference(ts) {
|
|
@@ -309,10 +351,13 @@ function postProcessEmittedTypes(ts, parsedSchema) {
|
|
|
309
351
|
ts = ts.replace(/export interface RoleMap\s*{[^}]*}/g, `export type RoleMap = Record<${resourceRoleKeyType}, ResourceRoleValue>;`);
|
|
310
352
|
// Normalize StrategyState & related socket maps to identity-keyed Records.
|
|
311
353
|
// These are emitted as `[k: string]` by json-schema-to-typescript but are identity-keyed in practice.
|
|
312
|
-
// Per schema: JobStepSocket: Record<ResourceRoleIdentity, Resource>
|
|
354
|
+
// Per schema: JobStepSocket: Record<ResourceRoleIdentity, Resource | ResourcePotential>
|
|
313
355
|
// StrategyState: Record<JobStepIdentity, JobStepSocket>
|
|
314
|
-
const jobStepSocketValueType =
|
|
356
|
+
const jobStepSocketValueType = deriveJobStepSocketValueType(parsedSchema);
|
|
315
357
|
ts = ts.replace(/export interface JobStepSocket\s*\{\s*\[k:\s*string\]:\s*[^;]+;\s*\}/g, `export type JobStepSocket = Record<${resourceRoleKeyType}, ${jobStepSocketValueType}>;`);
|
|
358
|
+
// If the upstream generator (or earlier passes) already emitted a Record-based alias,
|
|
359
|
+
// force its value type to match the schema-derived union.
|
|
360
|
+
ts = ts.replace(/export\s+type\s+JobStepSocket\s*=\s*Record<\s*ResourceRoleIdentity\s*,\s*[^>]+>\s*;/g, `export type JobStepSocket = Record<${resourceRoleKeyType}, ${jobStepSocketValueType}>;`);
|
|
316
361
|
ts = ts.replace(/export interface StrategyState\s*\{\s*\[k:\s*string\]:\s*JobStepSocket;\s*\}/g, `export type StrategyState = Record<${jobStepKeyType}, JobStepSocket>;`);
|
|
317
362
|
ts = ts.replace(/(strategyStateUpdate\??:\s*)\{\s*\[k:\s*string\]:\s*JobStepSocket;\s*\};/g, `$1Record<${jobStepKeyType}, JobStepSocket>;`);
|
|
318
363
|
// Ensure key constraints for strategyThreadMap are preserved as template-literal identity keys.
|
|
@@ -22,8 +22,10 @@ function generateResourceShellLogic(genesis) {
|
|
|
22
22
|
resourceRoleHandle: 'ROLE-Genesis',
|
|
23
23
|
jobStepHandle: 'JOB_STEP-Genesis'
|
|
24
24
|
},
|
|
25
|
-
|
|
25
|
+
resourceShellKind: 'materialized',
|
|
26
|
+
version: 1,
|
|
26
27
|
timestamp: genesisTimestamp,
|
|
28
|
+
path: 'https://schemas.toolproof.com/v1/Genesis.json',
|
|
27
29
|
nucleus: {}
|
|
28
30
|
};
|
|
29
31
|
defKeys.forEach((defName) => {
|
|
@@ -33,10 +35,12 @@ function generateResourceShellLogic(genesis) {
|
|
|
33
35
|
resourceTypeHandle: 'TYPE-ResourceType',
|
|
34
36
|
creationContext: {
|
|
35
37
|
resourceRoleHandle: 'ROLE-Genesis',
|
|
36
|
-
jobStepHandle:
|
|
38
|
+
jobStepHandle: 'JOB_STEP-Genesis'
|
|
37
39
|
},
|
|
38
|
-
|
|
40
|
+
resourceShellKind: 'materialized',
|
|
41
|
+
version: 1,
|
|
39
42
|
timestamp: genesisTimestamp,
|
|
43
|
+
path: `https://schemas.toolproof.com/v1/Genesis.json#/$defs/${defName}`,
|
|
40
44
|
nucleus: defValue
|
|
41
45
|
};
|
|
42
46
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toolproof-core/schema",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "JSON schemas and TypeScript types for ToolProof",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,10 +18,15 @@
|
|
|
18
18
|
"keywords": [],
|
|
19
19
|
"author": "",
|
|
20
20
|
"license": "ISC",
|
|
21
|
-
"packageManager": "pnpm@10.15.0",
|
|
22
21
|
"publishConfig": {
|
|
23
22
|
"access": "public"
|
|
24
23
|
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^20.8.1",
|
|
26
|
+
"json-schema-to-typescript": "^15.0.4",
|
|
27
|
+
"rimraf": "^5.0.0",
|
|
28
|
+
"typescript": "^5.9.3"
|
|
29
|
+
},
|
|
25
30
|
"scripts": {
|
|
26
31
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
27
32
|
"build": "tsc -b",
|
|
@@ -34,15 +39,9 @@
|
|
|
34
39
|
"wrapResourceTypesWithResourceShells": "node ./dist/scripts/wrapResourceTypesWithResourceShells.js",
|
|
35
40
|
"generateSchemaShims": "node ./dist/scripts/generateSchemaShims.js",
|
|
36
41
|
"generateDependencies": "node ./dist/scripts/generateDependencies.js",
|
|
37
|
-
"
|
|
42
|
+
"generateConstantsAndMappings": "node ./dist/scripts/generateConstantsAndMappings.js",
|
|
38
43
|
"generateTerminals": "node ./dist/scripts/generateTerminals.js",
|
|
39
44
|
"generateResourceTypeGenesisType": "node ./dist/scripts/generateStandaloneType.js --name Genesis",
|
|
40
|
-
"update": "rimraf /s /q dist && pnpm run build:scripts && pnpm run normalizeAnchorsToPointers && pnpm run extractSchemasFromResourceTypeShells && pnpm run
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@types/node": "^20.8.1",
|
|
44
|
-
"json-schema-to-typescript": "^15.0.4",
|
|
45
|
-
"rimraf": "^5.0.0",
|
|
46
|
-
"typescript": "^5.9.3"
|
|
45
|
+
"update": "rimraf /s /q dist && pnpm run build:scripts && pnpm run normalizeAnchorsToPointers && pnpm run extractSchemasFromResourceTypeShells && pnpm run generateConstantsAndMappings && pnpm run generateStandaloneSchema -- --name Job && pnpm run generateStandaloneSchema -- --name ResourceType && pnpm run generateStandaloneSchema -- --name RawStrategy && pnpm run generateStandaloneSchema -- --name RunnableStrategy && pnpm run generateStandaloneSchema -- --name StrategyRun && pnpm run generateStandaloneSchema -- --name Goal && pnpm run wrapResourceTypesWithResourceShells && pnpm run generateSchemaShims && pnpm run generateTypes && pnpm run generateStandaloneType -- --name Job && pnpm run generateStandaloneType -- --name ResourceType && pnpm run generateStandaloneType -- --name RawStrategy && pnpm run generateStandaloneType -- --name RunnableStrategy && pnpm run generateResourceTypeGenesisType && pnpm run generateDependencies && pnpm run generateTerminals && pnpm run build"
|
|
47
46
|
}
|
|
48
47
|
}
|