@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
|
@@ -1,141 +1,141 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { getConfig } from './_lib/config.js';
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Rewrite anchor-style references to JSON Pointer references in Genesis.json.
|
|
7
|
-
* We also strip all $anchor fields from the output since they are no longer needed after rewriting refs.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
// PURE: Remove all `$anchor` keys from a schema tree without rewriting refs.
|
|
11
|
-
export function stripAnchors<T>(schema: T): T {
|
|
12
|
-
const seen = new WeakMap<object, unknown>();
|
|
13
|
-
|
|
14
|
-
function walk(node: unknown): unknown {
|
|
15
|
-
if (!node || typeof node !== 'object') return node;
|
|
16
|
-
|
|
17
|
-
const existing = seen.get(node as object);
|
|
18
|
-
if (existing) return existing;
|
|
19
|
-
|
|
20
|
-
if (Array.isArray(node)) {
|
|
21
|
-
const out: unknown[] = [];
|
|
22
|
-
seen.set(node, out);
|
|
23
|
-
for (const item of node) out.push(walk(item));
|
|
24
|
-
return out;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const out: Record<string, unknown> = {};
|
|
28
|
-
seen.set(node as object, out);
|
|
29
|
-
|
|
30
|
-
for (const [key, value] of Object.entries(node as Record<string, unknown>)) {
|
|
31
|
-
if (key === '$anchor') continue;
|
|
32
|
-
out[key] = walk(value);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return out;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return walk(schema) as T;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// PURE: Rewrite anchor-style `$ref` strings (`#Anchor`) into JSON Pointer refs (`#/$defs/DefName`).
|
|
42
|
-
function normalizeAnchorsToPointers(input: any): any {
|
|
43
|
-
if (!input || typeof input !== "object") return input;
|
|
44
|
-
|
|
45
|
-
// Deep clone the input to ensure the function is pure (no side effects on input)
|
|
46
|
-
const root = JSON.parse(JSON.stringify(input));
|
|
47
|
-
|
|
48
|
-
// Build a map of anchors to their definition names
|
|
49
|
-
const defs: Record<string, any> = root.$defs && typeof root.$defs === "object" ? root.$defs : {};
|
|
50
|
-
const anchorToDef: Record<string, string> = {};
|
|
51
|
-
|
|
52
|
-
// For Genesis structure: each def is a Type envelope with nucleusSchema.$anchor
|
|
53
|
-
for (const [defName, defValue] of Object.entries(defs)) {
|
|
54
|
-
if (!defValue || typeof defValue !== "object") continue;
|
|
55
|
-
|
|
56
|
-
// Check if this is a Type envelope (has nucleusSchema property)
|
|
57
|
-
const nucleusSchema = (defValue as any).nucleusSchema;
|
|
58
|
-
if (nucleusSchema && typeof nucleusSchema === "object") {
|
|
59
|
-
// Look for $anchor inside the nucleusSchema
|
|
60
|
-
const anchor = nucleusSchema.$anchor;
|
|
61
|
-
if (typeof anchor === "string" && !anchorToDef[anchor]) {
|
|
62
|
-
anchorToDef[anchor] = defName;
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
// Fallback: check for $anchor at the def level (non-envelope case)
|
|
66
|
-
const anchor = (defValue as any).$anchor;
|
|
67
|
-
if (typeof anchor === "string" && !anchorToDef[anchor]) {
|
|
68
|
-
anchorToDef[anchor] = defName;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Walk the entire tree and rewrite anchor refs to pointer refs
|
|
74
|
-
function walk(node: any): void {
|
|
75
|
-
if (Array.isArray(node)) {
|
|
76
|
-
for (const item of node) walk(item);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (!node || typeof node !== "object") return;
|
|
80
|
-
|
|
81
|
-
// Rewrite $ref if it's an anchor-style reference
|
|
82
|
-
if (typeof node.$ref === "string") {
|
|
83
|
-
const ref: string = node.$ref;
|
|
84
|
-
// Match anchor refs: starts with # but not #/ (JSON Pointer syntax)
|
|
85
|
-
if (ref.startsWith("#") && !ref.startsWith("#/")) {
|
|
86
|
-
const anchor = ref.slice(1);
|
|
87
|
-
const defName = anchorToDef[anchor];
|
|
88
|
-
if (defName) {
|
|
89
|
-
node.$ref = `#/$defs/${defName}`;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Recursively walk all properties
|
|
95
|
-
for (const val of Object.values(node)) {
|
|
96
|
-
walk(val);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
walk(root);
|
|
101
|
-
return root;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// IMPURE: Script entrypoint (config + filesystem I/O + console + process exit code).
|
|
105
|
-
function main() {
|
|
106
|
-
try {
|
|
107
|
-
const config = getConfig();
|
|
108
|
-
const genesisSourcePath = config.getSourcePath();
|
|
109
|
-
|
|
110
|
-
// Create a generated/normalized version (anchor refs rewritten to pointers)
|
|
111
|
-
const normalizedPath = config.getNormalizedSourcePath();
|
|
112
|
-
|
|
113
|
-
if (!fs.existsSync(genesisSourcePath)) {
|
|
114
|
-
throw new Error(`Genesis source file not found at ${genesisSourcePath}`);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const raw = fs.readFileSync(genesisSourcePath, 'utf-8');
|
|
118
|
-
const genesis = JSON.parse(raw);
|
|
119
|
-
|
|
120
|
-
// Validate structure
|
|
121
|
-
if (!genesis.nucleusSchema || !genesis.nucleusSchema.$defs) {
|
|
122
|
-
throw new Error('Genesis.json must have nucleusSchema.$defs');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Rewrite anchors in the nucleusSchema (pure function call)
|
|
126
|
-
genesis.nucleusSchema = normalizeAnchorsToPointers(genesis.nucleusSchema);
|
|
127
|
-
|
|
128
|
-
// Strip $anchor fields from the schemas (pure function call)
|
|
129
|
-
genesis.nucleusSchema = stripAnchors(genesis.nucleusSchema);
|
|
130
|
-
|
|
131
|
-
// Write normalized version
|
|
132
|
-
fs.mkdirSync(path.dirname(normalizedPath), { recursive: true });
|
|
133
|
-
fs.writeFileSync(normalizedPath, JSON.stringify(genesis, null, 4), 'utf-8');
|
|
134
|
-
console.log(`Wrote normalized Genesis with pointer refs to ${normalizedPath}`);
|
|
135
|
-
} catch (e) {
|
|
136
|
-
console.error(e);
|
|
137
|
-
process.exitCode = 1;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
main();
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Rewrite anchor-style references to JSON Pointer references in Genesis.json.
|
|
7
|
+
* We also strip all $anchor fields from the output since they are no longer needed after rewriting refs.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// PURE: Remove all `$anchor` keys from a schema tree without rewriting refs.
|
|
11
|
+
export function stripAnchors<T>(schema: T): T {
|
|
12
|
+
const seen = new WeakMap<object, unknown>();
|
|
13
|
+
|
|
14
|
+
function walk(node: unknown): unknown {
|
|
15
|
+
if (!node || typeof node !== 'object') return node;
|
|
16
|
+
|
|
17
|
+
const existing = seen.get(node as object);
|
|
18
|
+
if (existing) return existing;
|
|
19
|
+
|
|
20
|
+
if (Array.isArray(node)) {
|
|
21
|
+
const out: unknown[] = [];
|
|
22
|
+
seen.set(node, out);
|
|
23
|
+
for (const item of node) out.push(walk(item));
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const out: Record<string, unknown> = {};
|
|
28
|
+
seen.set(node as object, out);
|
|
29
|
+
|
|
30
|
+
for (const [key, value] of Object.entries(node as Record<string, unknown>)) {
|
|
31
|
+
if (key === '$anchor') continue;
|
|
32
|
+
out[key] = walk(value);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return walk(schema) as T;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// PURE: Rewrite anchor-style `$ref` strings (`#Anchor`) into JSON Pointer refs (`#/$defs/DefName`).
|
|
42
|
+
function normalizeAnchorsToPointers(input: any): any {
|
|
43
|
+
if (!input || typeof input !== "object") return input;
|
|
44
|
+
|
|
45
|
+
// Deep clone the input to ensure the function is pure (no side effects on input)
|
|
46
|
+
const root = JSON.parse(JSON.stringify(input));
|
|
47
|
+
|
|
48
|
+
// Build a map of anchors to their definition names
|
|
49
|
+
const defs: Record<string, any> = root.$defs && typeof root.$defs === "object" ? root.$defs : {};
|
|
50
|
+
const anchorToDef: Record<string, string> = {};
|
|
51
|
+
|
|
52
|
+
// For Genesis structure: each def is a Type envelope with nucleusSchema.$anchor
|
|
53
|
+
for (const [defName, defValue] of Object.entries(defs)) {
|
|
54
|
+
if (!defValue || typeof defValue !== "object") continue;
|
|
55
|
+
|
|
56
|
+
// Check if this is a Type envelope (has nucleusSchema property)
|
|
57
|
+
const nucleusSchema = (defValue as any).nucleusSchema;
|
|
58
|
+
if (nucleusSchema && typeof nucleusSchema === "object") {
|
|
59
|
+
// Look for $anchor inside the nucleusSchema
|
|
60
|
+
const anchor = nucleusSchema.$anchor;
|
|
61
|
+
if (typeof anchor === "string" && !anchorToDef[anchor]) {
|
|
62
|
+
anchorToDef[anchor] = defName;
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
// Fallback: check for $anchor at the def level (non-envelope case)
|
|
66
|
+
const anchor = (defValue as any).$anchor;
|
|
67
|
+
if (typeof anchor === "string" && !anchorToDef[anchor]) {
|
|
68
|
+
anchorToDef[anchor] = defName;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Walk the entire tree and rewrite anchor refs to pointer refs
|
|
74
|
+
function walk(node: any): void {
|
|
75
|
+
if (Array.isArray(node)) {
|
|
76
|
+
for (const item of node) walk(item);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (!node || typeof node !== "object") return;
|
|
80
|
+
|
|
81
|
+
// Rewrite $ref if it's an anchor-style reference
|
|
82
|
+
if (typeof node.$ref === "string") {
|
|
83
|
+
const ref: string = node.$ref;
|
|
84
|
+
// Match anchor refs: starts with # but not #/ (JSON Pointer syntax)
|
|
85
|
+
if (ref.startsWith("#") && !ref.startsWith("#/")) {
|
|
86
|
+
const anchor = ref.slice(1);
|
|
87
|
+
const defName = anchorToDef[anchor];
|
|
88
|
+
if (defName) {
|
|
89
|
+
node.$ref = `#/$defs/${defName}`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Recursively walk all properties
|
|
95
|
+
for (const val of Object.values(node)) {
|
|
96
|
+
walk(val);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
walk(root);
|
|
101
|
+
return root;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// IMPURE: Script entrypoint (config + filesystem I/O + console + process exit code).
|
|
105
|
+
function main() {
|
|
106
|
+
try {
|
|
107
|
+
const config = getConfig();
|
|
108
|
+
const genesisSourcePath = config.getSourcePath();
|
|
109
|
+
|
|
110
|
+
// Create a generated/normalized version (anchor refs rewritten to pointers)
|
|
111
|
+
const normalizedPath = config.getNormalizedSourcePath();
|
|
112
|
+
|
|
113
|
+
if (!fs.existsSync(genesisSourcePath)) {
|
|
114
|
+
throw new Error(`Genesis source file not found at ${genesisSourcePath}`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const raw = fs.readFileSync(genesisSourcePath, 'utf-8');
|
|
118
|
+
const genesis = JSON.parse(raw);
|
|
119
|
+
|
|
120
|
+
// Validate structure
|
|
121
|
+
if (!genesis.nucleusSchema || !genesis.nucleusSchema.$defs) {
|
|
122
|
+
throw new Error('Genesis.json must have nucleusSchema.$defs');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Rewrite anchors in the nucleusSchema (pure function call)
|
|
126
|
+
genesis.nucleusSchema = normalizeAnchorsToPointers(genesis.nucleusSchema);
|
|
127
|
+
|
|
128
|
+
// Strip $anchor fields from the schemas (pure function call)
|
|
129
|
+
genesis.nucleusSchema = stripAnchors(genesis.nucleusSchema);
|
|
130
|
+
|
|
131
|
+
// Write normalized version
|
|
132
|
+
fs.mkdirSync(path.dirname(normalizedPath), { recursive: true });
|
|
133
|
+
fs.writeFileSync(normalizedPath, JSON.stringify(genesis, null, 4), 'utf-8');
|
|
134
|
+
console.log(`Wrote normalized Genesis with pointer refs to ${normalizedPath}`);
|
|
135
|
+
} catch (e) {
|
|
136
|
+
console.error(e);
|
|
137
|
+
process.exitCode = 1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
main();
|
|
@@ -1,82 +1,86 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { getConfig } from './_lib/config.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Wrap each ResourceType definition (from Genesis.nucleusSchema.$defs) with a Resource shell
|
|
7
|
-
* that conforms to the Resource.nucleusSchema pattern defined in Genesis.json.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
// PURE: Build Resource shell envelopes for each $defs entry (no I/O, no mutation of inputs).
|
|
11
|
-
function generateResourceShellLogic(genesis: any): Record<string, any> {
|
|
12
|
-
if (!genesis.nucleusSchema || !genesis.nucleusSchema.$defs) {
|
|
13
|
-
throw new Error('Genesis.json must have nucleusSchema.$defs');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const defs = genesis.nucleusSchema.$defs;
|
|
17
|
-
const defKeys = Object.keys(defs);
|
|
18
|
-
|
|
19
|
-
const resources: Record<string, any> = {};
|
|
20
|
-
|
|
21
|
-
// Genesis timestamp: 2025-11-30T00:00:00.000Z marks the genesis of ToolProof
|
|
22
|
-
const genesisTimestamp = '2025-11-30T00:00:00.000Z';
|
|
23
|
-
|
|
24
|
-
resources['Genesis'] = {
|
|
25
|
-
identity: 'RESOURCE-Genesis',
|
|
26
|
-
resourceTypeHandle: 'TYPE-ResourceType',
|
|
27
|
-
creationContext: {
|
|
28
|
-
resourceRoleHandle: 'ROLE-Genesis',
|
|
29
|
-
jobStepHandle: 'JOB_STEP-Genesis'
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Wrap each ResourceType definition (from Genesis.nucleusSchema.$defs) with a Resource shell
|
|
7
|
+
* that conforms to the Resource.nucleusSchema pattern defined in Genesis.json.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// PURE: Build Resource shell envelopes for each $defs entry (no I/O, no mutation of inputs).
|
|
11
|
+
function generateResourceShellLogic(genesis: any): Record<string, any> {
|
|
12
|
+
if (!genesis.nucleusSchema || !genesis.nucleusSchema.$defs) {
|
|
13
|
+
throw new Error('Genesis.json must have nucleusSchema.$defs');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const defs = genesis.nucleusSchema.$defs;
|
|
17
|
+
const defKeys = Object.keys(defs);
|
|
18
|
+
|
|
19
|
+
const resources: Record<string, any> = {};
|
|
20
|
+
|
|
21
|
+
// Genesis timestamp: 2025-11-30T00:00:00.000Z marks the genesis of ToolProof
|
|
22
|
+
const genesisTimestamp = '2025-11-30T00:00:00.000Z';
|
|
23
|
+
|
|
24
|
+
resources['Genesis'] = {
|
|
25
|
+
identity: 'RESOURCE-Genesis',
|
|
26
|
+
resourceTypeHandle: 'TYPE-ResourceType',
|
|
27
|
+
creationContext: {
|
|
28
|
+
resourceRoleHandle: 'ROLE-Genesis',
|
|
29
|
+
jobStepHandle: 'JOB_STEP-Genesis'
|
|
30
|
+
},
|
|
31
|
+
resourceShellKind: 'materialized',
|
|
32
|
+
version: 1,
|
|
33
|
+
timestamp: genesisTimestamp,
|
|
34
|
+
path: 'https://schemas.toolproof.com/v1/Genesis.json',
|
|
35
|
+
nucleus: {}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
defKeys.forEach((defName) => {
|
|
39
|
+
const defValue = defs[defName];
|
|
40
|
+
|
|
41
|
+
resources[defName] = {
|
|
42
|
+
identity: `RESOURCE-${defName}`,
|
|
43
|
+
resourceTypeHandle: 'TYPE-ResourceType',
|
|
44
|
+
creationContext: {
|
|
45
|
+
resourceRoleHandle: 'ROLE-Genesis',
|
|
46
|
+
jobStepHandle: 'JOB_STEP-Genesis'
|
|
47
|
+
},
|
|
48
|
+
resourceShellKind: 'materialized',
|
|
49
|
+
version: 1,
|
|
50
|
+
timestamp: genesisTimestamp,
|
|
51
|
+
path: `https://schemas.toolproof.com/v1/Genesis.json#/$defs/${defName}`,
|
|
52
|
+
nucleus: defValue
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return resources;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// IMPURE: Script entrypoint (config + filesystem I/O + console + process exit code).
|
|
60
|
+
function main() {
|
|
61
|
+
try {
|
|
62
|
+
const config = getConfig();
|
|
63
|
+
const genesisSourcePath = config.getNormalizedSourcePath();
|
|
64
|
+
const outputPath = path.join(config.getResourcesDir(), 'Genesis.json');
|
|
65
|
+
|
|
66
|
+
if (!fs.existsSync(genesisSourcePath)) {
|
|
67
|
+
throw new Error(`Genesis source file not found at ${genesisSourcePath}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const raw = fs.readFileSync(genesisSourcePath, 'utf-8');
|
|
71
|
+
const genesis = JSON.parse(raw);
|
|
72
|
+
|
|
73
|
+
const resources = generateResourceShellLogic(genesis);
|
|
74
|
+
|
|
75
|
+
const outputDir = path.dirname(outputPath);
|
|
76
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
77
|
+
|
|
78
|
+
fs.writeFileSync(outputPath, JSON.stringify(resources, null, 4) + '\n', 'utf-8');
|
|
79
|
+
console.log(`Generated ${Object.keys(resources).length} Resource envelopes -> ${outputPath}`);
|
|
80
|
+
} catch (error: any) {
|
|
81
|
+
console.error(error?.message ?? error);
|
|
82
|
+
process.exitCode = 1;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
main();
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
declare const CONSTANTS: {
|
|
2
|
-
readonly IDENTIFIABLES: {
|
|
3
|
-
readonly PREFIXES: {
|
|
4
|
-
readonly BranchStepIdentity: "BRANCH_STEP-";
|
|
5
|
-
readonly ForStepIdentity: "FOR_STEP-";
|
|
6
|
-
readonly GoalIdentity: "GOAL-";
|
|
7
|
-
readonly JobIdentity: "JOB-";
|
|
8
|
-
readonly JobStepIdentity: "JOB_STEP-";
|
|
9
|
-
readonly ResourceIdentity: "RESOURCE-";
|
|
10
|
-
readonly ResourceRoleIdentity: "ROLE-";
|
|
11
|
-
readonly ResourceTypeIdentity: "TYPE-";
|
|
12
|
-
readonly RunnableStrategyIdentity: "RUNNABLE_STRATEGY-";
|
|
13
|
-
readonly StrategyRunIdentity: "STRATEGY_RUN-";
|
|
14
|
-
readonly StrategyThreadIdentity: "STRATEGY_THREAD-";
|
|
15
|
-
readonly WhileStepIdentity: "WHILE_STEP-";
|
|
16
|
-
};
|
|
17
|
-
readonly NAMES: {
|
|
18
|
-
readonly BranchStep: "BranchStep";
|
|
19
|
-
readonly ForStep: "ForStep";
|
|
20
|
-
readonly Goal: "Goal";
|
|
21
|
-
readonly Job: "Job";
|
|
22
|
-
readonly JobStep: "JobStep";
|
|
23
|
-
readonly Resource: "Resource";
|
|
24
|
-
readonly ResourceRole: "ResourceRole";
|
|
25
|
-
readonly ResourceType: "ResourceType";
|
|
26
|
-
readonly RunnableStrategy: "RunnableStrategy";
|
|
27
|
-
readonly StrategyRun: "StrategyRun";
|
|
28
|
-
readonly StrategyThread: "StrategyThread";
|
|
29
|
-
readonly WhileStep: "WhileStep";
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
readonly ENUMS: {
|
|
33
|
-
readonly ResourceKind: {
|
|
34
|
-
readonly missing: "missing";
|
|
35
|
-
readonly inputPotential: "inputPotential";
|
|
36
|
-
readonly outputPotential: "outputPotential";
|
|
37
|
-
readonly materialized: "materialized";
|
|
38
|
-
};
|
|
39
|
-
readonly RunEventKind: {
|
|
40
|
-
readonly graph_start: "graph_start";
|
|
41
|
-
readonly tick: "tick";
|
|
42
|
-
readonly interrupt: "interrupt";
|
|
43
|
-
readonly graph_end: "graph_end";
|
|
44
|
-
};
|
|
45
|
-
readonly RunnableStrategyStatus: {
|
|
46
|
-
readonly pending: "pending";
|
|
47
|
-
readonly running: "running";
|
|
48
|
-
readonly completed: "completed";
|
|
49
|
-
readonly failed: "failed";
|
|
50
|
-
readonly cancelled: "cancelled";
|
|
51
|
-
};
|
|
52
|
-
readonly StepKind: {
|
|
53
|
-
readonly job: "job";
|
|
54
|
-
readonly branch: "branch";
|
|
55
|
-
readonly while: "while";
|
|
56
|
-
readonly for: "for";
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
export default CONSTANTS;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const CONSTANTS = {
|
|
2
|
-
IDENTIFIABLES: {
|
|
3
|
-
PREFIXES: {
|
|
4
|
-
BranchStepIdentity: 'BRANCH_STEP-',
|
|
5
|
-
ForStepIdentity: 'FOR_STEP-',
|
|
6
|
-
GoalIdentity: 'GOAL-',
|
|
7
|
-
JobIdentity: 'JOB-',
|
|
8
|
-
JobStepIdentity: 'JOB_STEP-',
|
|
9
|
-
ResourceIdentity: 'RESOURCE-',
|
|
10
|
-
ResourceRoleIdentity: 'ROLE-',
|
|
11
|
-
ResourceTypeIdentity: 'TYPE-',
|
|
12
|
-
RunnableStrategyIdentity: 'RUNNABLE_STRATEGY-',
|
|
13
|
-
StrategyRunIdentity: 'STRATEGY_RUN-',
|
|
14
|
-
StrategyThreadIdentity: 'STRATEGY_THREAD-',
|
|
15
|
-
WhileStepIdentity: 'WHILE_STEP-',
|
|
16
|
-
},
|
|
17
|
-
NAMES: {
|
|
18
|
-
BranchStep: 'BranchStep',
|
|
19
|
-
ForStep: 'ForStep',
|
|
20
|
-
Goal: 'Goal',
|
|
21
|
-
Job: 'Job',
|
|
22
|
-
JobStep: 'JobStep',
|
|
23
|
-
Resource: 'Resource',
|
|
24
|
-
ResourceRole: 'ResourceRole',
|
|
25
|
-
ResourceType: 'ResourceType',
|
|
26
|
-
RunnableStrategy: 'RunnableStrategy',
|
|
27
|
-
StrategyRun: 'StrategyRun',
|
|
28
|
-
StrategyThread: 'StrategyThread',
|
|
29
|
-
WhileStep: 'WhileStep',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
ENUMS: {
|
|
33
|
-
ResourceKind: {
|
|
34
|
-
missing: 'missing',
|
|
35
|
-
inputPotential: 'inputPotential',
|
|
36
|
-
outputPotential: 'outputPotential',
|
|
37
|
-
materialized: 'materialized',
|
|
38
|
-
},
|
|
39
|
-
RunEventKind: {
|
|
40
|
-
graph_start: 'graph_start',
|
|
41
|
-
tick: 'tick',
|
|
42
|
-
interrupt: 'interrupt',
|
|
43
|
-
graph_end: 'graph_end',
|
|
44
|
-
},
|
|
45
|
-
RunnableStrategyStatus: {
|
|
46
|
-
pending: 'pending',
|
|
47
|
-
running: 'running',
|
|
48
|
-
completed: 'completed',
|
|
49
|
-
failed: 'failed',
|
|
50
|
-
cancelled: 'cancelled',
|
|
51
|
-
},
|
|
52
|
-
StepKind: {
|
|
53
|
-
job: 'job',
|
|
54
|
-
branch: 'branch',
|
|
55
|
-
while: 'while',
|
|
56
|
-
for: 'for',
|
|
57
|
-
},
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
export default CONSTANTS;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type GeneratedConstants = {
|
|
2
|
-
IDENTIFIABLES: {
|
|
3
|
-
PREFIXES: Record<string, string>;
|
|
4
|
-
NAMES: Record<string, string>;
|
|
5
|
-
};
|
|
6
|
-
ENUMS: Record<string, Record<string, string>>;
|
|
7
|
-
};
|
|
8
|
-
export declare function extractIdentityPrefixes(schema: unknown): Record<string, string>;
|
|
9
|
-
export declare function deriveIdentifiablesFromIdentityPrefixes(identityPrefixes: Record<string, string>): Record<string, string>;
|
|
10
|
-
export declare function extractEnums(schema: unknown): Record<string, Record<string, string>>;
|
|
11
|
-
export declare function extractConstants(schema: unknown): GeneratedConstants;
|
|
12
|
-
export declare function renderConstantsTs(constants: GeneratedConstants): string;
|