@toolproof-core/schema 1.0.7 → 1.0.9

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.
Files changed (33) hide show
  1. package/dist/generated/constants/constants.d.ts +2 -2
  2. package/dist/generated/constants/constants.js +2 -2
  3. package/dist/generated/normalized/Genesis.json +5 -5
  4. package/dist/generated/resources/Genesis.json +5 -5
  5. package/dist/generated/schemas/Genesis.json +5 -5
  6. package/dist/generated/schemas/standalone/RawStrategy.json +4 -4
  7. package/dist/generated/schemas/standalone/RunnableStrategy.json +5 -5
  8. package/dist/generated/schemas/standalone/StrategyRun.json +5 -5
  9. package/dist/generated/types/types.d.ts +5 -5
  10. package/dist/index.d.ts +1 -1
  11. package/dist/scripts/generateConstants.js +1 -1
  12. package/package.json +8 -7
  13. package/src/Genesis.json +1833 -1833
  14. package/src/generated/constants/constants.ts +2 -2
  15. package/src/generated/normalized/Genesis.json +5 -5
  16. package/src/generated/resources/Genesis.json +5 -5
  17. package/src/generated/schemas/Genesis.json +5 -5
  18. package/src/generated/schemas/standalone/RawStrategy.json +4 -4
  19. package/src/generated/schemas/standalone/RunnableStrategy.json +5 -5
  20. package/src/generated/schemas/standalone/StrategyRun.json +5 -5
  21. package/src/generated/types/types.d.ts +5 -5
  22. package/src/index.ts +70 -69
  23. package/src/scripts/_lib/config.ts +215 -215
  24. package/src/scripts/extractSchemasFromResourceTypeShells.ts +261 -261
  25. package/src/scripts/generateConstants.ts +217 -217
  26. package/src/scripts/generateDependencies.ts +121 -121
  27. package/src/scripts/generateSchemaShims.ts +127 -127
  28. package/src/scripts/generateStandaloneSchema.ts +185 -185
  29. package/src/scripts/generateStandaloneType.ts +127 -127
  30. package/src/scripts/generateTerminals.ts +73 -73
  31. package/src/scripts/generateTypes.ts +531 -531
  32. package/src/scripts/normalizeAnchorsToPointers.ts +141 -141
  33. package/src/scripts/wrapResourceTypesWithResourceShells.ts +82 -82
@@ -1,73 +1,73 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { getConfig } from "./_lib/config.js";
4
-
5
- type DependencyMap = Record<string, string[]>;
6
-
7
- // PURE: Validate + normalize a dependency map loaded from JSON.
8
- function normalizeDependencyMap(value: unknown): DependencyMap {
9
- if (!value || typeof value !== "object" || Array.isArray(value)) {
10
- throw new Error("Invalid dependencyMap.json: expected an object");
11
- }
12
-
13
- const input = value as Record<string, unknown>;
14
- const out: DependencyMap = {};
15
-
16
- // Preserve insertion order from the parsed JSON object.
17
- for (const [key, rawDeps] of Object.entries(input)) {
18
- if (rawDeps == null) {
19
- out[key] = [];
20
- continue;
21
- }
22
- if (!Array.isArray(rawDeps)) {
23
- throw new Error(`Invalid dependencyMap.json: value for ${key} must be an array`);
24
- }
25
- out[key] = rawDeps.filter((d): d is string => typeof d === "string");
26
- }
27
-
28
- return out;
29
- }
30
-
31
- // PURE: Compute terminals (defs that are not depended-upon by any other def).
32
- function computeTerminalsInKeyOrder(dependencyMap: DependencyMap): string[] {
33
- const keys = Object.keys(dependencyMap);
34
- const dependedUpon = new Set<string>();
35
-
36
- for (const key of keys) {
37
- for (const dep of dependencyMap[key] ?? []) {
38
- dependedUpon.add(dep);
39
- }
40
- }
41
-
42
- // Preserve key order from dependencyMap.json.
43
- return keys.filter((k) => !dependedUpon.has(k));
44
- }
45
-
46
- // IMPURE: Script entrypoint (config + filesystem I/O + console + process exit code).
47
- function main() {
48
- try {
49
- const config = getConfig();
50
-
51
- const inPath = config.getDependencyMapPath();
52
- const outPath = path.join(path.dirname(inPath), "terminals.json");
53
-
54
- if (!fs.existsSync(inPath)) {
55
- throw new Error(`Dependency map not found at ${inPath}. Run generateDependencies first.`);
56
- }
57
-
58
- const raw = fs.readFileSync(inPath, "utf8");
59
- const parsed = JSON.parse(raw) as unknown;
60
-
61
- const dependencyMap = normalizeDependencyMap(parsed);
62
- const terminals = computeTerminalsInKeyOrder(dependencyMap);
63
-
64
- fs.mkdirSync(path.dirname(outPath), { recursive: true });
65
- fs.writeFileSync(outPath, JSON.stringify(terminals, null, 4), "utf8");
66
- console.log(`Wrote terminals to ${outPath}`);
67
- } catch (error: any) {
68
- console.error(`Error generating terminals: ${error?.message ?? error}`);
69
- process.exitCode = 1;
70
- }
71
- }
72
-
73
- main();
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { getConfig } from "./_lib/config.js";
4
+
5
+ type DependencyMap = Record<string, string[]>;
6
+
7
+ // PURE: Validate + normalize a dependency map loaded from JSON.
8
+ function normalizeDependencyMap(value: unknown): DependencyMap {
9
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
10
+ throw new Error("Invalid dependencyMap.json: expected an object");
11
+ }
12
+
13
+ const input = value as Record<string, unknown>;
14
+ const out: DependencyMap = {};
15
+
16
+ // Preserve insertion order from the parsed JSON object.
17
+ for (const [key, rawDeps] of Object.entries(input)) {
18
+ if (rawDeps == null) {
19
+ out[key] = [];
20
+ continue;
21
+ }
22
+ if (!Array.isArray(rawDeps)) {
23
+ throw new Error(`Invalid dependencyMap.json: value for ${key} must be an array`);
24
+ }
25
+ out[key] = rawDeps.filter((d): d is string => typeof d === "string");
26
+ }
27
+
28
+ return out;
29
+ }
30
+
31
+ // PURE: Compute terminals (defs that are not depended-upon by any other def).
32
+ function computeTerminalsInKeyOrder(dependencyMap: DependencyMap): string[] {
33
+ const keys = Object.keys(dependencyMap);
34
+ const dependedUpon = new Set<string>();
35
+
36
+ for (const key of keys) {
37
+ for (const dep of dependencyMap[key] ?? []) {
38
+ dependedUpon.add(dep);
39
+ }
40
+ }
41
+
42
+ // Preserve key order from dependencyMap.json.
43
+ return keys.filter((k) => !dependedUpon.has(k));
44
+ }
45
+
46
+ // IMPURE: Script entrypoint (config + filesystem I/O + console + process exit code).
47
+ function main() {
48
+ try {
49
+ const config = getConfig();
50
+
51
+ const inPath = config.getDependencyMapPath();
52
+ const outPath = path.join(path.dirname(inPath), "terminals.json");
53
+
54
+ if (!fs.existsSync(inPath)) {
55
+ throw new Error(`Dependency map not found at ${inPath}. Run generateDependencies first.`);
56
+ }
57
+
58
+ const raw = fs.readFileSync(inPath, "utf8");
59
+ const parsed = JSON.parse(raw) as unknown;
60
+
61
+ const dependencyMap = normalizeDependencyMap(parsed);
62
+ const terminals = computeTerminalsInKeyOrder(dependencyMap);
63
+
64
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
65
+ fs.writeFileSync(outPath, JSON.stringify(terminals, null, 4), "utf8");
66
+ console.log(`Wrote terminals to ${outPath}`);
67
+ } catch (error: any) {
68
+ console.error(`Error generating terminals: ${error?.message ?? error}`);
69
+ process.exitCode = 1;
70
+ }
71
+ }
72
+
73
+ main();