@toolproof-npm/schema 0.1.65 → 0.1.67
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/README.md +59 -59
- package/dist/genesis/generated/dependencies_ordered.json +197 -0
- package/dist/genesis/generated/resourceTypes/Genesis.json +0 -19
- package/dist/genesis/generated/resources/Genesis.json +0 -29
- package/dist/genesis/generated/schemas/Genesis.json +0 -13
- package/dist/genesis/generated/terminals.json +8 -0
- package/dist/genesis/generated/types/ResourceTypeGenesis.d.ts +0 -1
- package/dist/genesis/generated/types/types.d.ts +0 -7
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/scripts/generateDependencies.d.ts +1 -0
- package/dist/scripts/generateDependencies.js +86 -0
- package/dist/scripts/generateDependenciesOrdered.d.ts +1 -0
- package/dist/scripts/generateDependenciesOrdered.js +131 -0
- package/dist/scripts/generateTerminals.d.ts +1 -0
- package/dist/scripts/generateTerminals.js +36 -0
- package/package.json +59 -56
package/README.md
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
# @toolproof-npm/schema
|
|
2
|
-
|
|
3
|
-
JSON schemas and TypeScript types for ToolProof...
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pnpm add @toolproof-npm/schema
|
|
9
|
-
# or
|
|
10
|
-
npm install @toolproof-npm/schema
|
|
11
|
-
# or
|
|
12
|
-
yarn add @toolproof-npm/schema
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
### Import Schemas and Types
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
import { /* schemas and types */ } from '@toolproof-npm/schema';
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Features
|
|
24
|
-
|
|
25
|
-
- JSON Schema definitions with $defs subschemas
|
|
26
|
-
- Generated TypeScript types from JSON schemas
|
|
27
|
-
- Runtime schema validation support
|
|
28
|
-
- Extractors for non-JSON resource types
|
|
29
|
-
- Schema bundling utilities
|
|
30
|
-
|
|
31
|
-
## Development
|
|
32
|
-
|
|
33
|
-
### Generate Types
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
pnpm run generateTypes
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Build
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
pnpm run build
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Update (Clean build + generate types)
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
pnpm run update
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Requirements
|
|
52
|
-
|
|
53
|
-
- Node.js 16+
|
|
54
|
-
- TypeScript 4.5+ (for TypeScript projects)
|
|
55
|
-
|
|
56
|
-
## License
|
|
57
|
-
|
|
58
|
-
MIT
|
|
59
|
-
|
|
1
|
+
# @toolproof-npm/schema
|
|
2
|
+
|
|
3
|
+
JSON schemas and TypeScript types for ToolProof...
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @toolproof-npm/schema
|
|
9
|
+
# or
|
|
10
|
+
npm install @toolproof-npm/schema
|
|
11
|
+
# or
|
|
12
|
+
yarn add @toolproof-npm/schema
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Import Schemas and Types
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { /* schemas and types */ } from '@toolproof-npm/schema';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- JSON Schema definitions with $defs subschemas
|
|
26
|
+
- Generated TypeScript types from JSON schemas
|
|
27
|
+
- Runtime schema validation support
|
|
28
|
+
- Extractors for non-JSON resource types
|
|
29
|
+
- Schema bundling utilities
|
|
30
|
+
|
|
31
|
+
## Development
|
|
32
|
+
|
|
33
|
+
### Generate Types
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pnpm run generateTypes
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Build
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pnpm run build
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Update (Clean build + generate types)
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pnpm run update
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Requirements
|
|
52
|
+
|
|
53
|
+
- Node.js 16+
|
|
54
|
+
- TypeScript 4.5+ (for TypeScript projects)
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT
|
|
59
|
+
|
|
@@ -0,0 +1,197 @@
|
|
|
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
|
+
"ForStepIdentity": [],
|
|
66
|
+
"JobIdentity": [],
|
|
67
|
+
"ResourceFormat": [
|
|
68
|
+
"Documented",
|
|
69
|
+
"ResourceFormatIdentity"
|
|
70
|
+
],
|
|
71
|
+
"ResourceMeta": [
|
|
72
|
+
"ResourceMetaBase"
|
|
73
|
+
],
|
|
74
|
+
"ResourceMissing": [
|
|
75
|
+
"ResourceBase",
|
|
76
|
+
"ResourceKind"
|
|
77
|
+
],
|
|
78
|
+
"ResourcePotentialInput": [
|
|
79
|
+
"ResourceBase",
|
|
80
|
+
"CreationContextWrapper",
|
|
81
|
+
"ResourceKind"
|
|
82
|
+
],
|
|
83
|
+
"ResourcePotentialOutput": [
|
|
84
|
+
"ResourceBase",
|
|
85
|
+
"CreationContextWrapper",
|
|
86
|
+
"ResourceKind"
|
|
87
|
+
],
|
|
88
|
+
"ResourceRoleValue": [
|
|
89
|
+
"ResourceTypeIdentity",
|
|
90
|
+
"Documented"
|
|
91
|
+
],
|
|
92
|
+
"RoleBindingMap": [
|
|
93
|
+
"ResourceIdentity",
|
|
94
|
+
"ResourceRoleIdentity"
|
|
95
|
+
],
|
|
96
|
+
"RoleBindings": [
|
|
97
|
+
"RoleBindingMap"
|
|
98
|
+
],
|
|
99
|
+
"RoleBindingsWrapper": [
|
|
100
|
+
"RoleBindings"
|
|
101
|
+
],
|
|
102
|
+
"Execution": [
|
|
103
|
+
"RoleBindingsWrapper",
|
|
104
|
+
"ExecutionIdentity",
|
|
105
|
+
"JobIdentity"
|
|
106
|
+
],
|
|
107
|
+
"RoleMap": [
|
|
108
|
+
"ResourceRoleValue",
|
|
109
|
+
"ResourceRoleIdentity"
|
|
110
|
+
],
|
|
111
|
+
"Roles": [
|
|
112
|
+
"RoleMap"
|
|
113
|
+
],
|
|
114
|
+
"RolesWrapper": [
|
|
115
|
+
"Roles"
|
|
116
|
+
],
|
|
117
|
+
"Job": [
|
|
118
|
+
"Documented",
|
|
119
|
+
"RolesWrapper",
|
|
120
|
+
"JobIdentity"
|
|
121
|
+
],
|
|
122
|
+
"StatefulStrategyIdentity": [],
|
|
123
|
+
"StatelessStrategyIdentity": [],
|
|
124
|
+
"StepKind": [],
|
|
125
|
+
"StrategyRunIdentity": [],
|
|
126
|
+
"StrategyRunStatus": [],
|
|
127
|
+
"StrategyRunContext": [
|
|
128
|
+
"Timestamp",
|
|
129
|
+
"StrategyRunStatus"
|
|
130
|
+
],
|
|
131
|
+
"StrategyState": [
|
|
132
|
+
"ResourceMissing",
|
|
133
|
+
"ResourcePotentialInput",
|
|
134
|
+
"ResourcePotentialOutput",
|
|
135
|
+
"Resource",
|
|
136
|
+
"ResourceRoleIdentity",
|
|
137
|
+
"ExecutionIdentity"
|
|
138
|
+
],
|
|
139
|
+
"StrategyStateWrapper": [
|
|
140
|
+
"StrategyState"
|
|
141
|
+
],
|
|
142
|
+
"StrategyThreadIdentity": [],
|
|
143
|
+
"WhileStepIdentity": [],
|
|
144
|
+
"WorkStepIdentity": [],
|
|
145
|
+
"WorkStep": [
|
|
146
|
+
"StepKind",
|
|
147
|
+
"Execution",
|
|
148
|
+
"WorkStepIdentity"
|
|
149
|
+
],
|
|
150
|
+
"Conditional": [
|
|
151
|
+
"WorkStep"
|
|
152
|
+
],
|
|
153
|
+
"BranchStep": [
|
|
154
|
+
"StepKind",
|
|
155
|
+
"Conditional",
|
|
156
|
+
"BranchStepIdentity"
|
|
157
|
+
],
|
|
158
|
+
"ForStep": [
|
|
159
|
+
"StepKind",
|
|
160
|
+
"Conditional",
|
|
161
|
+
"ForStepIdentity"
|
|
162
|
+
],
|
|
163
|
+
"WhileStep": [
|
|
164
|
+
"StepKind",
|
|
165
|
+
"Conditional",
|
|
166
|
+
"WhileStepIdentity"
|
|
167
|
+
],
|
|
168
|
+
"Step": [
|
|
169
|
+
"WorkStep",
|
|
170
|
+
"BranchStep",
|
|
171
|
+
"WhileStep",
|
|
172
|
+
"ForStep"
|
|
173
|
+
],
|
|
174
|
+
"StatelessStrategy": [
|
|
175
|
+
"StatelessStrategyIdentity",
|
|
176
|
+
"Step"
|
|
177
|
+
],
|
|
178
|
+
"StatelessStrategyWrapper": [
|
|
179
|
+
"StatelessStrategy"
|
|
180
|
+
],
|
|
181
|
+
"StatefulStrategy": [
|
|
182
|
+
"StatelessStrategyWrapper",
|
|
183
|
+
"StrategyStateWrapper",
|
|
184
|
+
"StatefulStrategyIdentity"
|
|
185
|
+
],
|
|
186
|
+
"StrategyThreadMap": [
|
|
187
|
+
"Step",
|
|
188
|
+
"StrategyThreadIdentity"
|
|
189
|
+
],
|
|
190
|
+
"StrategyRun": [
|
|
191
|
+
"StrategyThreadMap",
|
|
192
|
+
"StrategyStateWrapper",
|
|
193
|
+
"StrategyRunIdentity",
|
|
194
|
+
"StatefulStrategyIdentity",
|
|
195
|
+
"StrategyRunContext"
|
|
196
|
+
]
|
|
197
|
+
}
|
|
@@ -1776,25 +1776,6 @@
|
|
|
1776
1776
|
"unevaluatedProperties": false
|
|
1777
1777
|
}
|
|
1778
1778
|
},
|
|
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
1779
|
"StrategyRunIdentity": {
|
|
1799
1780
|
"identity": "TYPE-StrategyRunIdentity",
|
|
1800
1781
|
"name": "StrategyRunIdentity",
|
|
@@ -2368,35 +2368,6 @@
|
|
|
2368
2368
|
}
|
|
2369
2369
|
}
|
|
2370
2370
|
},
|
|
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
2371
|
"StrategyRunIdentity": {
|
|
2401
2372
|
"identity": "RESOURCE-StrategyRunIdentity",
|
|
2402
2373
|
"resourceTypeRef": "TYPE-ResourceType",
|
|
@@ -1215,19 +1215,6 @@
|
|
|
1215
1215
|
"$anchor": "StatefulStrategyIdentity",
|
|
1216
1216
|
"pattern": "^STATEFUL_STRATEGY-.+$"
|
|
1217
1217
|
},
|
|
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
1218
|
"StatelessStrategy": {
|
|
1232
1219
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
1233
1220
|
"type": "object",
|
|
@@ -49,7 +49,6 @@ export type ResourceTypeGenesis = {
|
|
|
49
49
|
"RolesWrapper": ResourceType;
|
|
50
50
|
"StatefulStrategy": ResourceType;
|
|
51
51
|
"StatefulStrategyIdentity": ResourceType;
|
|
52
|
-
"StatefulStrategyWrapper": ResourceType;
|
|
53
52
|
"StatelessStrategy": ResourceType;
|
|
54
53
|
"StatelessStrategyIdentity": ResourceType;
|
|
55
54
|
"StatelessStrategyWrapper": ResourceType;
|
|
@@ -555,13 +555,6 @@ export interface StrategyStateWrapper {
|
|
|
555
555
|
* via the `definition` "StrategyState".
|
|
556
556
|
*/
|
|
557
557
|
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
558
|
/**
|
|
566
559
|
* This interface was referenced by `GenesisJson`'s JSON-Schema
|
|
567
560
|
* via the `definition` "StrategyRunContext".
|
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,58 +1,61 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
2
|
+
"name": "@toolproof-npm/schema",
|
|
3
|
+
"version": "0.1.67",
|
|
4
|
+
"description": "JSON schemas and TypeScript types for ToolProof",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"toolproof",
|
|
7
|
+
"schemas",
|
|
8
|
+
"json-schema",
|
|
9
|
+
"typescript"
|
|
10
|
+
],
|
|
11
|
+
"author": "ToolProof Team",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/ToolProof/core.git",
|
|
16
|
+
"directory": "packages/_schemas"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/ToolProof/core#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/ToolProof/core/issues"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "dist/index.js",
|
|
24
|
+
"types": "dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc -b",
|
|
33
|
+
"build:scripts": "tsc -p tsconfig.scripts.json",
|
|
34
|
+
"rewriteAnchors": "node ./dist/scripts/rewriteAnchors.js",
|
|
35
|
+
"extractSchemas": "node ./dist/scripts/extractSchemas.js",
|
|
36
|
+
"extractSubschema": "node ./dist/scripts/extractSubschemaWithDefs.js",
|
|
37
|
+
"resolveRefsInGenesisStory": "pnpm run build:scripts && node ./dist/scripts/resolveRefsInGenesisStory.js",
|
|
38
|
+
"generateTypes": "node ./dist/scripts/generateTypes.js",
|
|
39
|
+
"generateResourceTypeGenesisType": "node ./dist/scripts/generateResourceTypeGenesisType.js",
|
|
40
|
+
"generateResourceTypeType": "node ./dist/scripts/generateResourceTypeType.js",
|
|
41
|
+
"generateResourceEnvelopes": "node ./dist/scripts/generateResourceEnvelopes.js",
|
|
42
|
+
"generateSchemaShims": "node ./dist/scripts/generateSchemaShims.js",
|
|
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"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"README.md"
|
|
51
|
+
],
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@apidevtools/json-schema-ref-parser": "^14.2.1",
|
|
54
|
+
"@types/node": "^20.8.1",
|
|
55
|
+
"ajv-cli": "^5.0.0",
|
|
56
|
+
"ajv-formats": "^3.0.1",
|
|
57
|
+
"json-schema-to-typescript": "^15.0.4",
|
|
58
|
+
"rimraf": "^5.0.0",
|
|
59
|
+
"typescript": "^5.0.0"
|
|
29
60
|
}
|
|
30
|
-
|
|
31
|
-
"files": [
|
|
32
|
-
"dist",
|
|
33
|
-
"README.md"
|
|
34
|
-
],
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@apidevtools/json-schema-ref-parser": "^14.2.1",
|
|
37
|
-
"@types/node": "^20.8.1",
|
|
38
|
-
"ajv-cli": "^5.0.0",
|
|
39
|
-
"ajv-formats": "^3.0.1",
|
|
40
|
-
"json-schema-to-typescript": "^15.0.4",
|
|
41
|
-
"rimraf": "^5.0.0",
|
|
42
|
-
"typescript": "^5.0.0"
|
|
43
|
-
},
|
|
44
|
-
"scripts": {
|
|
45
|
-
"build": "tsc -b",
|
|
46
|
-
"build:scripts": "tsc -p tsconfig.scripts.json",
|
|
47
|
-
"rewriteAnchors": "node ./dist/scripts/rewriteAnchors.js",
|
|
48
|
-
"extractSchemas": "node ./dist/scripts/extractSchemas.js",
|
|
49
|
-
"extractSubschema": "node ./dist/scripts/extractSubschemaWithDefs.js",
|
|
50
|
-
"resolveRefsInGenesisStory": "pnpm run build:scripts && node ./dist/scripts/resolveRefsInGenesisStory.js",
|
|
51
|
-
"generateTypes": "node ./dist/scripts/generateTypes.js",
|
|
52
|
-
"generateResourceTypeGenesisType": "node ./dist/scripts/generateResourceTypeGenesisType.js",
|
|
53
|
-
"generateResourceTypeType": "node ./dist/scripts/generateResourceTypeType.js",
|
|
54
|
-
"generateResourceEnvelopes": "node ./dist/scripts/generateResourceEnvelopes.js",
|
|
55
|
-
"generateSchemaShims": "node ./dist/scripts/generateSchemaShims.js",
|
|
56
|
-
"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"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
61
|
+
}
|