@toolproof-npm/schema 0.1.66 → 0.1.68

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.
@@ -0,0 +1,201 @@
1
+ {
2
+ "Described": [],
3
+ "IdentitySchema": [],
4
+ "IdentitySchemaRef": [],
5
+ "IdentityProp": [
6
+ "IdentitySchema",
7
+ "IdentitySchemaRef"
8
+ ],
9
+ "MeritSchema": [],
10
+ "MeritSchemaRef": [],
11
+ "MeritProp": [
12
+ "MeritSchema",
13
+ "MeritSchemaRef"
14
+ ],
15
+ "ExtractionSchema": [
16
+ "IdentityProp",
17
+ "MeritProp"
18
+ ],
19
+ "ExtractionSchemaWrapper": [
20
+ "ExtractionSchema"
21
+ ],
22
+ "Named": [],
23
+ "Documented": [
24
+ "Named",
25
+ "Described"
26
+ ],
27
+ "ResourceFormatIdentity": [],
28
+ "ResourceTypeIdentity": [],
29
+ "ResourceType": [
30
+ "Documented",
31
+ "ExtractionSchemaWrapper",
32
+ "ResourceTypeIdentity",
33
+ "ResourceFormatIdentity"
34
+ ],
35
+ "ExecutionIdentity": [],
36
+ "JsonData": [],
37
+ "Path": [],
38
+ "ResourceIdentity": [],
39
+ "ResourceBase": [
40
+ "ResourceIdentity",
41
+ "ResourceTypeIdentity"
42
+ ],
43
+ "ResourceKind": [],
44
+ "ResourceRoleIdentity": [],
45
+ "CreationContext": [
46
+ "ExecutionIdentity",
47
+ "ResourceRoleIdentity"
48
+ ],
49
+ "CreationContextWrapper": [
50
+ "CreationContext"
51
+ ],
52
+ "Timestamp": [],
53
+ "ResourceMetaBase": [
54
+ "ResourceBase",
55
+ "CreationContextWrapper",
56
+ "ResourceKind",
57
+ "Timestamp",
58
+ "Path"
59
+ ],
60
+ "Resource": [
61
+ "ResourceMetaBase",
62
+ "JsonData"
63
+ ],
64
+ "BranchStepIdentity": [],
65
+ "Error": [
66
+ "Documented"
67
+ ],
68
+ "ForStepIdentity": [],
69
+ "JobIdentity": [],
70
+ "ResourceFormat": [
71
+ "Documented",
72
+ "ResourceFormatIdentity"
73
+ ],
74
+ "ResourceMeta": [
75
+ "ResourceMetaBase"
76
+ ],
77
+ "ResourceMissing": [
78
+ "ResourceBase",
79
+ "ResourceKind"
80
+ ],
81
+ "ResourcePotentialInput": [
82
+ "ResourceBase",
83
+ "CreationContextWrapper",
84
+ "ResourceKind"
85
+ ],
86
+ "ResourcePotentialOutput": [
87
+ "ResourceBase",
88
+ "CreationContextWrapper",
89
+ "ResourceKind"
90
+ ],
91
+ "ResourceRoleValue": [
92
+ "ResourceTypeIdentity",
93
+ "Documented"
94
+ ],
95
+ "RoleBindingMap": [
96
+ "ResourceIdentity",
97
+ "ResourceRoleIdentity"
98
+ ],
99
+ "RoleBindings": [
100
+ "RoleBindingMap"
101
+ ],
102
+ "RoleBindingsWrapper": [
103
+ "RoleBindings"
104
+ ],
105
+ "Execution": [
106
+ "RoleBindingsWrapper",
107
+ "ExecutionIdentity",
108
+ "JobIdentity"
109
+ ],
110
+ "RoleMap": [
111
+ "ResourceRoleValue",
112
+ "ResourceRoleIdentity"
113
+ ],
114
+ "Roles": [
115
+ "RoleMap",
116
+ "ResourceRoleValue"
117
+ ],
118
+ "RolesWrapper": [
119
+ "Roles"
120
+ ],
121
+ "Job": [
122
+ "Documented",
123
+ "RolesWrapper",
124
+ "JobIdentity"
125
+ ],
126
+ "StatefulStrategyIdentity": [],
127
+ "StatelessStrategyIdentity": [],
128
+ "StepKind": [],
129
+ "StrategyRunIdentity": [],
130
+ "StrategyRunStatus": [],
131
+ "StrategyRunContext": [
132
+ "Timestamp",
133
+ "StrategyRunStatus"
134
+ ],
135
+ "StrategyState": [
136
+ "ResourceMissing",
137
+ "ResourcePotentialInput",
138
+ "ResourcePotentialOutput",
139
+ "Resource",
140
+ "ResourceRoleIdentity",
141
+ "ExecutionIdentity"
142
+ ],
143
+ "StrategyStateWrapper": [
144
+ "StrategyState"
145
+ ],
146
+ "StrategyThreadIdentity": [],
147
+ "WhileStepIdentity": [],
148
+ "WorkStepIdentity": [],
149
+ "WorkStep": [
150
+ "StepKind",
151
+ "Execution",
152
+ "WorkStepIdentity"
153
+ ],
154
+ "Conditional": [
155
+ "WorkStep"
156
+ ],
157
+ "BranchStep": [
158
+ "StepKind",
159
+ "Conditional",
160
+ "BranchStepIdentity"
161
+ ],
162
+ "ForStep": [
163
+ "StepKind",
164
+ "Conditional",
165
+ "ForStepIdentity"
166
+ ],
167
+ "WhileStep": [
168
+ "StepKind",
169
+ "Conditional",
170
+ "WhileStepIdentity"
171
+ ],
172
+ "Step": [
173
+ "WorkStep",
174
+ "BranchStep",
175
+ "WhileStep",
176
+ "ForStep"
177
+ ],
178
+ "StatelessStrategy": [
179
+ "StatelessStrategyIdentity",
180
+ "Step"
181
+ ],
182
+ "StatelessStrategyWrapper": [
183
+ "StatelessStrategy"
184
+ ],
185
+ "StatefulStrategy": [
186
+ "StatelessStrategyWrapper",
187
+ "StrategyStateWrapper",
188
+ "StatefulStrategyIdentity"
189
+ ],
190
+ "StrategyThreadMap": [
191
+ "Step",
192
+ "StrategyThreadIdentity"
193
+ ],
194
+ "StrategyRun": [
195
+ "StrategyThreadMap",
196
+ "StrategyStateWrapper",
197
+ "StrategyRunIdentity",
198
+ "StatefulStrategyIdentity",
199
+ "StrategyRunContext"
200
+ ]
201
+ }
@@ -814,7 +814,8 @@
814
814
  "$ref": "#/$defs/Documented"
815
815
  }
816
816
  ]
817
- }
817
+ },
818
+ "unevaluatedProperties": false
818
819
  },
819
820
  "RoleMap": {
820
821
  "identity": "TYPE-RoleMap",
@@ -833,6 +834,30 @@
833
834
  }
834
835
  }
835
836
  },
837
+ "Error": {
838
+ "identity": "TYPE-Error",
839
+ "name": "Error",
840
+ "description": "dummy-description",
841
+ "resourceFormatRef": "FORMAT-ApplicationJson",
842
+ "extractionSchema": {
843
+ "$anchor": "Error",
844
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
845
+ "type": "object",
846
+ "allOf": [
847
+ {
848
+ "$ref": "#/$defs/Documented"
849
+ },
850
+ {
851
+ "properties": {
852
+ "details": {
853
+ "type": "object"
854
+ }
855
+ }
856
+ }
857
+ ],
858
+ "unevaluatedProperties": false
859
+ }
860
+ },
836
861
  "Roles": {
837
862
  "identity": "TYPE-Roles",
838
863
  "name": "Roles",
@@ -851,7 +876,44 @@
851
876
  "$ref": "#/$defs/RoleMap"
852
877
  },
853
878
  "outputMap": {
854
- "$ref": "#/$defs/RoleMap"
879
+ "allOf": [
880
+ {
881
+ "$ref": "#/$defs/RoleMap"
882
+ },
883
+ {
884
+ "required": [
885
+ "ROLE-ErrorOutput"
886
+ ],
887
+ "properties": {
888
+ "ROLE-ErrorOutput": {
889
+ "type": "object",
890
+ "allOf": [
891
+ {
892
+ "$ref": "#/$defs/ResourceRoleValue"
893
+ },
894
+ {
895
+ "required": [
896
+ "resourceTypeRef",
897
+ "name",
898
+ "description"
899
+ ],
900
+ "properties": {
901
+ "resourceTypeRef": {
902
+ "const": "TYPE-Error"
903
+ },
904
+ "name": {
905
+ "const": "ErrorOutput"
906
+ },
907
+ "description": {
908
+ "const": "Represents error outputs from job executions."
909
+ }
910
+ }
911
+ }
912
+ ]
913
+ }
914
+ }
915
+ }
916
+ ]
855
917
  }
856
918
  },
857
919
  "unevaluatedProperties": false
@@ -1776,25 +1838,6 @@
1776
1838
  "unevaluatedProperties": false
1777
1839
  }
1778
1840
  },
1779
- "StatefulStrategyWrapper": {
1780
- "identity": "TYPE-StatefulStrategyWrapper",
1781
- "name": "StatefulStrategyWrapper",
1782
- "description": "dummy-description",
1783
- "resourceFormatRef": "FORMAT-ApplicationJson",
1784
- "extractionSchema": {
1785
- "$anchor": "StatefulStrategyWrapper",
1786
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1787
- "type": "object",
1788
- "required": [
1789
- "statefulStrategy"
1790
- ],
1791
- "properties": {
1792
- "statefulStrategy": {
1793
- "$ref": "#/$defs/StatefulStrategy"
1794
- }
1795
- }
1796
- }
1797
- },
1798
1841
  "StrategyRunIdentity": {
1799
1842
  "identity": "TYPE-StrategyRunIdentity",
1800
1843
  "name": "StrategyRunIdentity",
@@ -995,7 +995,8 @@
995
995
  "$ref": "#/$defs/Documented"
996
996
  }
997
997
  ]
998
- }
998
+ },
999
+ "unevaluatedProperties": false
999
1000
  }
1000
1001
  },
1001
1002
  "RoleMap": {
@@ -1025,6 +1026,40 @@
1025
1026
  }
1026
1027
  }
1027
1028
  },
1029
+ "Error": {
1030
+ "identity": "RESOURCE-Error",
1031
+ "resourceTypeRef": "TYPE-ResourceType",
1032
+ "creationContext": {
1033
+ "resourceRoleRef": "ROLE-Genesis",
1034
+ "executionRef": "EXECUTION-Error"
1035
+ },
1036
+ "kind": "materialized",
1037
+ "timestamp": "2025-11-30T00:00:00.000Z",
1038
+ "extractedData": {
1039
+ "identity": "TYPE-Error",
1040
+ "name": "Error",
1041
+ "description": "dummy-description",
1042
+ "resourceFormatRef": "FORMAT-ApplicationJson",
1043
+ "extractionSchema": {
1044
+ "$anchor": "Error",
1045
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1046
+ "type": "object",
1047
+ "allOf": [
1048
+ {
1049
+ "$ref": "#/$defs/Documented"
1050
+ },
1051
+ {
1052
+ "properties": {
1053
+ "details": {
1054
+ "type": "object"
1055
+ }
1056
+ }
1057
+ }
1058
+ ],
1059
+ "unevaluatedProperties": false
1060
+ }
1061
+ }
1062
+ },
1028
1063
  "Roles": {
1029
1064
  "identity": "RESOURCE-Roles",
1030
1065
  "resourceTypeRef": "TYPE-ResourceType",
@@ -1052,7 +1087,44 @@
1052
1087
  "$ref": "#/$defs/RoleMap"
1053
1088
  },
1054
1089
  "outputMap": {
1055
- "$ref": "#/$defs/RoleMap"
1090
+ "allOf": [
1091
+ {
1092
+ "$ref": "#/$defs/RoleMap"
1093
+ },
1094
+ {
1095
+ "required": [
1096
+ "ROLE-ErrorOutput"
1097
+ ],
1098
+ "properties": {
1099
+ "ROLE-ErrorOutput": {
1100
+ "type": "object",
1101
+ "allOf": [
1102
+ {
1103
+ "$ref": "#/$defs/ResourceRoleValue"
1104
+ },
1105
+ {
1106
+ "required": [
1107
+ "resourceTypeRef",
1108
+ "name",
1109
+ "description"
1110
+ ],
1111
+ "properties": {
1112
+ "resourceTypeRef": {
1113
+ "const": "TYPE-Error"
1114
+ },
1115
+ "name": {
1116
+ "const": "ErrorOutput"
1117
+ },
1118
+ "description": {
1119
+ "const": "Represents error outputs from job executions."
1120
+ }
1121
+ }
1122
+ }
1123
+ ]
1124
+ }
1125
+ }
1126
+ }
1127
+ ]
1056
1128
  }
1057
1129
  },
1058
1130
  "unevaluatedProperties": false
@@ -2368,35 +2440,6 @@
2368
2440
  }
2369
2441
  }
2370
2442
  },
2371
- "StatefulStrategyWrapper": {
2372
- "identity": "RESOURCE-StatefulStrategyWrapper",
2373
- "resourceTypeRef": "TYPE-ResourceType",
2374
- "creationContext": {
2375
- "resourceRoleRef": "ROLE-Genesis",
2376
- "executionRef": "EXECUTION-StatefulStrategyWrapper"
2377
- },
2378
- "kind": "materialized",
2379
- "timestamp": "2025-11-30T00:00:00.000Z",
2380
- "extractedData": {
2381
- "identity": "TYPE-StatefulStrategyWrapper",
2382
- "name": "StatefulStrategyWrapper",
2383
- "description": "dummy-description",
2384
- "resourceFormatRef": "FORMAT-ApplicationJson",
2385
- "extractionSchema": {
2386
- "$anchor": "StatefulStrategyWrapper",
2387
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2388
- "type": "object",
2389
- "required": [
2390
- "statefulStrategy"
2391
- ],
2392
- "properties": {
2393
- "statefulStrategy": {
2394
- "$ref": "#/$defs/StatefulStrategy"
2395
- }
2396
- }
2397
- }
2398
- }
2399
- },
2400
2443
  "StrategyRunIdentity": {
2401
2444
  "identity": "RESOURCE-StrategyRunIdentity",
2402
2445
  "resourceTypeRef": "TYPE-ResourceType",
@@ -116,6 +116,24 @@
116
116
  ],
117
117
  "$anchor": "Documented"
118
118
  },
119
+ "Error": {
120
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
121
+ "type": "object",
122
+ "allOf": [
123
+ {
124
+ "$ref": "#/$defs/Documented"
125
+ },
126
+ {
127
+ "properties": {
128
+ "details": {
129
+ "type": "object"
130
+ }
131
+ }
132
+ }
133
+ ],
134
+ "unevaluatedProperties": false,
135
+ "$anchor": "Error"
136
+ },
119
137
  "Execution": {
120
138
  "$schema": "https://json-schema.org/draft/2020-12/schema",
121
139
  "type": "object",
@@ -1164,7 +1182,44 @@
1164
1182
  "$ref": "#/$defs/RoleMap"
1165
1183
  },
1166
1184
  "outputMap": {
1167
- "$ref": "#/$defs/RoleMap"
1185
+ "allOf": [
1186
+ {
1187
+ "$ref": "#/$defs/RoleMap"
1188
+ },
1189
+ {
1190
+ "properties": {
1191
+ "ROLE-ErrorOutput": {
1192
+ "type": "object",
1193
+ "allOf": [
1194
+ {
1195
+ "$ref": "#/$defs/ResourceRoleValue"
1196
+ },
1197
+ {
1198
+ "properties": {
1199
+ "description": {
1200
+ "const": "Represents error outputs from job executions."
1201
+ },
1202
+ "name": {
1203
+ "const": "ErrorOutput"
1204
+ },
1205
+ "resourceTypeRef": {
1206
+ "const": "TYPE-Error"
1207
+ }
1208
+ },
1209
+ "required": [
1210
+ "resourceTypeRef",
1211
+ "name",
1212
+ "description"
1213
+ ]
1214
+ }
1215
+ ]
1216
+ }
1217
+ },
1218
+ "required": [
1219
+ "ROLE-ErrorOutput"
1220
+ ]
1221
+ }
1222
+ ]
1168
1223
  }
1169
1224
  },
1170
1225
  "required": [
@@ -1215,19 +1270,6 @@
1215
1270
  "$anchor": "StatefulStrategyIdentity",
1216
1271
  "pattern": "^STATEFUL_STRATEGY-.+$"
1217
1272
  },
1218
- "StatefulStrategyWrapper": {
1219
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1220
- "type": "object",
1221
- "properties": {
1222
- "statefulStrategy": {
1223
- "$ref": "#/$defs/StatefulStrategy"
1224
- }
1225
- },
1226
- "required": [
1227
- "statefulStrategy"
1228
- ],
1229
- "$anchor": "StatefulStrategyWrapper"
1230
- },
1231
1273
  "StatelessStrategy": {
1232
1274
  "$schema": "https://json-schema.org/draft/2020-12/schema",
1233
1275
  "type": "object",
@@ -99,7 +99,44 @@
99
99
  "$ref": "#/$defs/RoleMap"
100
100
  },
101
101
  "outputMap": {
102
- "$ref": "#/$defs/RoleMap"
102
+ "allOf": [
103
+ {
104
+ "$ref": "#/$defs/RoleMap"
105
+ },
106
+ {
107
+ "properties": {
108
+ "ROLE-ErrorOutput": {
109
+ "type": "object",
110
+ "allOf": [
111
+ {
112
+ "$ref": "#/$defs/ResourceRoleValue"
113
+ },
114
+ {
115
+ "properties": {
116
+ "description": {
117
+ "const": "Represents error outputs from job executions."
118
+ },
119
+ "name": {
120
+ "const": "ErrorOutput"
121
+ },
122
+ "resourceTypeRef": {
123
+ "const": "TYPE-Error"
124
+ }
125
+ },
126
+ "required": [
127
+ "resourceTypeRef",
128
+ "name",
129
+ "description"
130
+ ]
131
+ }
132
+ ]
133
+ }
134
+ },
135
+ "required": [
136
+ "ROLE-ErrorOutput"
137
+ ]
138
+ }
139
+ ]
103
140
  }
104
141
  },
105
142
  "required": [
@@ -0,0 +1,9 @@
1
+ [
2
+ "ResourceType",
3
+ "Error",
4
+ "ResourceFormat",
5
+ "ResourceMeta",
6
+ "Job",
7
+ "StatefulStrategy",
8
+ "StrategyRun"
9
+ ]
@@ -9,6 +9,7 @@ export type ResourceTypeGenesis = {
9
9
  "CreationContextWrapper": ResourceType;
10
10
  "Described": ResourceType;
11
11
  "Documented": ResourceType;
12
+ "Error": ResourceType;
12
13
  "Execution": ResourceType;
13
14
  "ExecutionIdentity": ResourceType;
14
15
  "ExtractionSchema": ResourceType;
@@ -49,7 +50,6 @@ export type ResourceTypeGenesis = {
49
50
  "RolesWrapper": ResourceType;
50
51
  "StatefulStrategy": ResourceType;
51
52
  "StatefulStrategyIdentity": ResourceType;
52
- "StatefulStrategyWrapper": ResourceType;
53
53
  "StatelessStrategy": ResourceType;
54
54
  "StatelessStrategyIdentity": ResourceType;
55
55
  "StatelessStrategyWrapper": ResourceType;
@@ -74,6 +74,16 @@ export type ResourceRoleIdentity =
74
74
  */
75
75
  export type Documented =
76
76
  Named & Described;
77
+ /**
78
+ * This interface was referenced by `GenesisJson`'s JSON-Schema
79
+ * via the `definition` "Error".
80
+ */
81
+ export type Error =
82
+ {
83
+ } & Documented & {
84
+ details?: {
85
+ };
86
+ };
77
87
  /**
78
88
  * This interface was referenced by `GenesisJson`'s JSON-Schema
79
89
  * via the `definition` "ExtractionSchema".
@@ -466,7 +476,13 @@ export interface RolesWrapper {
466
476
  */
467
477
  export interface Roles {
468
478
  inputMap: RoleMap;
469
- outputMap: RoleMap;
479
+ outputMap: RoleMap & {
480
+ "ROLE-ErrorOutput": ResourceRoleValue & {
481
+ description: "Represents error outputs from job executions.";
482
+ name: "ErrorOutput";
483
+ resourceTypeRef: "TYPE-Error";
484
+ };
485
+ };
470
486
  }
471
487
  /**
472
488
  * This interface was referenced by `GenesisJson`'s JSON-Schema
@@ -555,13 +571,6 @@ export interface StrategyStateWrapper {
555
571
  * via the `definition` "StrategyState".
556
572
  */
557
573
  export type StrategyState = Record<ExecutionIdentity, Record<ResourceRoleIdentity, ResourceMissing | ResourcePotentialInput | ResourcePotentialOutput | Resource>>;
558
- /**
559
- * This interface was referenced by `GenesisJson`'s JSON-Schema
560
- * via the `definition` "StatefulStrategyWrapper".
561
- */
562
- export interface StatefulStrategyWrapper {
563
- statefulStrategy: StatefulStrategy;
564
- }
565
574
  /**
566
575
  * This interface was referenced by `GenesisJson`'s JSON-Schema
567
576
  * via the `definition` "StrategyRunContext".
@@ -613,7 +622,13 @@ export interface RolesWrapper {
613
622
  }
614
623
  export interface Roles {
615
624
  inputMap: RoleMap;
616
- outputMap: RoleMap;
625
+ outputMap: RoleMap & {
626
+ "ROLE-ErrorOutput": ResourceRoleValue & {
627
+ description: "Represents error outputs from job executions.";
628
+ name: "ErrorOutput";
629
+ resourceTypeRef: "TYPE-Error";
630
+ };
631
+ };
617
632
  }
618
633
  export type RoleMap = Record<ResourceRoleIdentity, ResourceRoleValue>;
619
634
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { default as SchemaGenesis } from './genesis/generated/schemas/Genesis.js';
2
- export { default as ResourceTypeGenesis } from './genesis/generated/resource-type-envelopes/Genesis.js';
3
2
  export { default as SchemaJob } from './genesis/generated/schemas/Job.js';
3
+ export { default as ResourceTypeGenesis } from './genesis/generated/resource-type-envelopes/Genesis.js';
4
+ export { default as dependencies } from './genesis/generated/dependencies_ordered.json';
5
+ export { default as terminals } from './genesis/generated/terminals.json';
4
6
  export type { ResourceTypeGenesis as ResourceTypeGenesisJson } from './genesis/generated/types/ResourceTypeGenesis.js';
5
7
  export type { Resource_ResourceFormat as Resource_ResourceFormatJson } from './genesis/generated/types/Resource_ResourceFormat.js';
6
8
  export type { Resource_ResourceType as Resource_ResourceTypeJson } from './genesis/generated/types/Resource_ResourceType.js';
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  // Re-export JSON schemas via .ts shims to avoid .json re-exports in declarations
2
2
  export { default as SchemaGenesis } from './genesis/generated/schemas/Genesis.js';
3
- export { default as ResourceTypeGenesis } from './genesis/generated/resource-type-envelopes/Genesis.js';
4
3
  export { default as SchemaJob } from './genesis/generated/schemas/Job.js';
4
+ export { default as ResourceTypeGenesis } from './genesis/generated/resource-type-envelopes/Genesis.js';
5
+ export { default as dependencies } from './genesis/generated/dependencies_ordered.json';
6
+ export { default as terminals } from './genesis/generated/terminals.json';
5
7
  // Re-export brand factories so consumers can construct branded identities at runtime.
6
8
  export { unsafeBrand, asResourceTypeIdentity, asResourceRoleIdentity, asExecutionIdentity, asResourceIdentity, asWorkStepIdentity, asBranchStepIdentity, asForStepIdentity, asResourceFormatIdentity, asWhileStepIdentity, asStatelessStrategyIdentity, asStatefulStrategyIdentity, asResourceTypeIdentities, asResourceRoleIdentities, asExecutionIdentities, asResourceIdentities, asWorkStepIdentities, asBranchStepIdentities, asForStepIdentities, asResourceFormatIdentities, asWhileStepIdentities, asStatelessStrategyIdentities, asStatefulStrategyIdentities, } from './scripts/brandFactories.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,86 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { getConfig } from "./_lib/config.js";
4
+ function decodeJsonPointerSegment(segment) {
5
+ // JSON Pointer decoding: ~1 => / and ~0 => ~
6
+ return segment.replace(/~1/g, "/").replace(/~0/g, "~");
7
+ }
8
+ function collectRefs(node, out) {
9
+ if (Array.isArray(node)) {
10
+ for (const item of node)
11
+ collectRefs(item, out);
12
+ return;
13
+ }
14
+ if (!node || typeof node !== "object")
15
+ return;
16
+ const obj = node;
17
+ const ref = obj["$ref"];
18
+ if (typeof ref === "string")
19
+ out.add(ref);
20
+ for (const value of Object.values(obj)) {
21
+ collectRefs(value, out);
22
+ }
23
+ }
24
+ function resolveInternalRefToDefKey(ref, defKeys, anchorToDef) {
25
+ if (!ref.startsWith("#"))
26
+ return null;
27
+ // JSON Pointer: #/$defs/<Name>(/...)
28
+ const defsPrefix = "#/$defs/";
29
+ if (ref.startsWith(defsPrefix)) {
30
+ const rest = ref.slice(defsPrefix.length);
31
+ const firstSegment = rest.split("/")[0] ?? "";
32
+ const defKey = decodeJsonPointerSegment(firstSegment);
33
+ return defKeys.has(defKey) ? defKey : null;
34
+ }
35
+ // Anchor ref: #AnchorName
36
+ if (!ref.startsWith("#/")) {
37
+ const anchor = ref.slice(1);
38
+ const mapped = anchorToDef[anchor];
39
+ if (mapped && defKeys.has(mapped))
40
+ return mapped;
41
+ if (defKeys.has(anchor))
42
+ return anchor;
43
+ }
44
+ return null;
45
+ }
46
+ function main() {
47
+ const config = getConfig();
48
+ const inPath = config.getOutputPath("Genesis.json");
49
+ const outPath = path.join(config.getRoot(), "src/genesis/generated/dependencies.json");
50
+ if (!fs.existsSync(inPath)) {
51
+ throw new Error(`Genesis schema not found at ${inPath}. Run extractSchemas first.`);
52
+ }
53
+ const raw = fs.readFileSync(inPath, "utf8");
54
+ const doc = JSON.parse(raw);
55
+ const defs = doc?.$defs && typeof doc.$defs === "object" ? doc.$defs : {};
56
+ const defKeys = new Set(Object.keys(defs));
57
+ // Map anchors to $defs keys (useful if any anchor-style refs remain)
58
+ const anchorToDef = {};
59
+ for (const [defKey, defSchema] of Object.entries(defs)) {
60
+ if (!defSchema || typeof defSchema !== "object" || Array.isArray(defSchema))
61
+ continue;
62
+ const anchor = defSchema.$anchor;
63
+ if (typeof anchor === "string" && !(anchor in anchorToDef)) {
64
+ anchorToDef[anchor] = defKey;
65
+ }
66
+ }
67
+ const dependencyMap = {};
68
+ for (const [defKey, defSchema] of Object.entries(defs)) {
69
+ const refs = new Set();
70
+ collectRefs(defSchema, refs);
71
+ const deps = new Set();
72
+ for (const ref of refs) {
73
+ const depKey = resolveInternalRefToDefKey(ref, defKeys, anchorToDef);
74
+ if (!depKey)
75
+ continue;
76
+ if (depKey === defKey)
77
+ continue;
78
+ deps.add(depKey);
79
+ }
80
+ dependencyMap[defKey] = Array.from(deps);
81
+ }
82
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
83
+ fs.writeFileSync(outPath, JSON.stringify(dependencyMap, null, 4), "utf8");
84
+ console.log(`Wrote dependency map to ${outPath}`);
85
+ }
86
+ main();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,131 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { getConfig } from "./_lib/config.js";
4
+ function readDependencyMap(filePath) {
5
+ const raw = fs.readFileSync(filePath, "utf8");
6
+ const parsed = JSON.parse(raw);
7
+ const out = {};
8
+ for (const [k, v] of Object.entries(parsed)) {
9
+ if (!Array.isArray(v) || v.some((x) => typeof x !== "string")) {
10
+ throw new Error(`Invalid dependency map: value for ${k} must be string[]`);
11
+ }
12
+ out[k] = v;
13
+ }
14
+ return out;
15
+ }
16
+ function buildReverseGraph(deps) {
17
+ const children = new Map();
18
+ for (const k of Object.keys(deps))
19
+ children.set(k, []);
20
+ for (const [node, nodeDeps] of Object.entries(deps)) {
21
+ for (const dep of nodeDeps) {
22
+ if (!children.has(dep))
23
+ children.set(dep, []);
24
+ children.get(dep).push(node);
25
+ }
26
+ }
27
+ return children;
28
+ }
29
+ function computeAncestors(target, deps) {
30
+ const visited = new Set();
31
+ const stack = [target];
32
+ while (stack.length) {
33
+ const cur = stack.pop();
34
+ if (visited.has(cur))
35
+ continue;
36
+ visited.add(cur);
37
+ const direct = deps[cur] ?? [];
38
+ for (const d of direct) {
39
+ if (!visited.has(d))
40
+ stack.push(d);
41
+ }
42
+ }
43
+ // If target isn't a known key, treat as empty set
44
+ if (!(target in deps))
45
+ return new Set();
46
+ return visited;
47
+ }
48
+ function pickNext(available, phase, neededForResourceType, neededForResource) {
49
+ const sorted = available.slice().sort((a, b) => a.localeCompare(b));
50
+ if (phase === "beforeResourceType") {
51
+ const candidates = sorted.filter((k) => neededForResourceType.has(k));
52
+ return (candidates[0] ?? sorted[0]);
53
+ }
54
+ if (phase === "beforeResource") {
55
+ const candidates = sorted.filter((k) => neededForResource.has(k));
56
+ return (candidates[0] ?? sorted[0]);
57
+ }
58
+ return sorted[0];
59
+ }
60
+ function topoOrderWithPrecedence(deps) {
61
+ const keys = Object.keys(deps);
62
+ const keySet = new Set(keys);
63
+ // Validate that all dependencies are known keys (otherwise ordering is ill-defined)
64
+ for (const [k, ds] of Object.entries(deps)) {
65
+ for (const d of ds) {
66
+ if (!keySet.has(d)) {
67
+ throw new Error(`Unknown dependency key in map: ${k} -> ${d}`);
68
+ }
69
+ if (d === k) {
70
+ throw new Error(`Self-dependency detected for ${k}`);
71
+ }
72
+ }
73
+ }
74
+ const children = buildReverseGraph(deps);
75
+ const inDegree = new Map();
76
+ for (const k of keys)
77
+ inDegree.set(k, 0);
78
+ for (const [node, nodeDeps] of Object.entries(deps)) {
79
+ inDegree.set(node, (inDegree.get(node) ?? 0) + nodeDeps.length);
80
+ }
81
+ const neededForResourceType = computeAncestors("ResourceType", deps);
82
+ const neededForResource = computeAncestors("Resource", deps);
83
+ const order = [];
84
+ const available = [];
85
+ for (const k of keys) {
86
+ if ((inDegree.get(k) ?? 0) === 0)
87
+ available.push(k);
88
+ }
89
+ let phase = "beforeResourceType";
90
+ while (available.length) {
91
+ const next = pickNext(available, phase, neededForResourceType, neededForResource);
92
+ const idx = available.indexOf(next);
93
+ available.splice(idx, 1);
94
+ order.push(next);
95
+ if (phase === "beforeResourceType" && next === "ResourceType") {
96
+ phase = "beforeResource";
97
+ }
98
+ else if (phase === "beforeResource" && next === "Resource") {
99
+ phase = "afterResource";
100
+ }
101
+ for (const child of children.get(next) ?? []) {
102
+ const newDeg = (inDegree.get(child) ?? 0) - 1;
103
+ inDegree.set(child, newDeg);
104
+ if (newDeg === 0)
105
+ available.push(child);
106
+ }
107
+ }
108
+ if (order.length !== keys.length) {
109
+ const remaining = keys.filter((k) => !order.includes(k));
110
+ throw new Error(`Cycle detected or unsatisfied ordering. Remaining: ${remaining.join(", ")}`);
111
+ }
112
+ return order;
113
+ }
114
+ function main() {
115
+ const config = getConfig();
116
+ const inPath = path.join(config.getRoot(), "src/genesis/generated/dependencies.json");
117
+ const outPath = path.join(config.getRoot(), "src/genesis/generated/dependencies_ordered.json");
118
+ if (!fs.existsSync(inPath)) {
119
+ throw new Error(`dependencies.json not found at ${inPath}. Run generateDependencies first.`);
120
+ }
121
+ const deps = readDependencyMap(inPath);
122
+ const order = topoOrderWithPrecedence(deps);
123
+ const ordered = {};
124
+ for (const k of order) {
125
+ ordered[k] = deps[k];
126
+ }
127
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
128
+ fs.writeFileSync(outPath, JSON.stringify(ordered, null, 4), "utf8");
129
+ console.log(`Wrote ordered dependency map to ${outPath}`);
130
+ }
131
+ main();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { getConfig } from "./_lib/config.js";
4
+ function main() {
5
+ const config = getConfig();
6
+ const orderedDepsPath = path.join(config.getRoot(), "src/genesis/generated/dependencies_ordered.json");
7
+ const fallbackDepsPath = path.join(config.getRoot(), "src/genesis/generated/dependencies.json");
8
+ const outPath = path.join(config.getRoot(), "src/genesis/generated/terminals.json");
9
+ const depsPath = fs.existsSync(orderedDepsPath) ? orderedDepsPath : fallbackDepsPath;
10
+ if (!fs.existsSync(depsPath)) {
11
+ throw new Error(`No dependency file found at ${orderedDepsPath} or ${fallbackDepsPath}.`);
12
+ }
13
+ const raw = fs.readFileSync(depsPath, "utf8");
14
+ const dependencyMap = JSON.parse(raw);
15
+ const keys = Object.keys(dependencyMap);
16
+ const dependedUpon = new Set();
17
+ for (const key of keys) {
18
+ const deps = dependencyMap[key];
19
+ if (deps == null)
20
+ continue;
21
+ if (!Array.isArray(deps)) {
22
+ throw new Error(`Invalid dependencies.json: value for ${key} must be an array`);
23
+ }
24
+ for (const dep of deps) {
25
+ if (typeof dep === "string")
26
+ dependedUpon.add(dep);
27
+ }
28
+ }
29
+ // Preserve the key order from the dependency file (dependencies_ordered.json)
30
+ // so terminals are emitted in a dependency-respecting order.
31
+ const terminals = keys.filter((k) => !dependedUpon.has(k));
32
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
33
+ fs.writeFileSync(outPath, JSON.stringify(terminals, null, 4), "utf8");
34
+ console.log(`Wrote terminals to ${outPath}`);
35
+ }
36
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolproof-npm/schema",
3
- "version": "0.1.66",
3
+ "version": "0.1.68",
4
4
  "description": "JSON schemas and TypeScript types for ToolProof",
5
5
  "keywords": [
6
6
  "toolproof",
@@ -40,7 +40,10 @@
40
40
  "generateResourceTypeType": "node ./dist/scripts/generateResourceTypeType.js",
41
41
  "generateResourceEnvelopes": "node ./dist/scripts/generateResourceEnvelopes.js",
42
42
  "generateSchemaShims": "node ./dist/scripts/generateSchemaShims.js",
43
- "update": "rimraf /s /q dist && pnpm run build:scripts && pnpm run rewriteAnchors && pnpm run generateResourceEnvelopes && pnpm run extractSchemas && pnpm run extractSubschema -- --name Job && pnpm run extractSubschema -- --name ResourceFormat && pnpm run extractSubschema -- --name ResourceType && pnpm run extractSubschema -- --name StatelessStrategy && pnpm run extractSubschema -- --name StatefulStrategy && pnpm run extractSubschema -- --name StrategyRun && pnpm run generateSchemaShims && pnpm run generateTypes && pnpm run generateResourceTypeType -- --name Job && pnpm run generateResourceTypeType -- --name ResourceFormat && pnpm run generateResourceTypeType -- --name ResourceType && pnpm run generateResourceTypeType -- --name StatelessStrategy && pnpm run generateResourceTypeType -- --name StatefulStrategy && pnpm run generateResourceTypeType -- --name StrategyRun && pnpm run generateResourceTypeGenesisType && pnpm run build"
43
+ "generateDependencies": "node ./dist/scripts/generateDependencies.js",
44
+ "generateDependenciesOrdered": "node ./dist/scripts/generateDependenciesOrdered.js",
45
+ "generateTerminals": "node ./dist/scripts/generateTerminals.js",
46
+ "update": "rimraf /s /q dist && pnpm run build:scripts && pnpm run rewriteAnchors && pnpm run generateResourceEnvelopes && pnpm run extractSchemas && pnpm run extractSubschema -- --name Job && pnpm run extractSubschema -- --name ResourceFormat && pnpm run extractSubschema -- --name ResourceType && pnpm run extractSubschema -- --name StatelessStrategy && pnpm run extractSubschema -- --name StatefulStrategy && pnpm run extractSubschema -- --name StrategyRun && pnpm run generateSchemaShims && pnpm run generateTypes && pnpm run generateResourceTypeType -- --name Job && pnpm run generateResourceTypeType -- --name ResourceFormat && pnpm run generateResourceTypeType -- --name ResourceType && pnpm run generateResourceTypeType -- --name StatelessStrategy && pnpm run generateResourceTypeType -- --name StatefulStrategy && pnpm run generateResourceTypeType -- --name StrategyRun && pnpm run generateResourceTypeGenesisType && pnpm run build && pnpm run generateDependencies && pnpm run generateDependenciesOrdered && pnpm run generateTerminals"
44
47
  },
45
48
  "files": [
46
49
  "dist",