@toolproof-npm/schema 0.1.30 → 0.1.32
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/_lib/test.js +6 -6
- package/dist/_lib/types/types.d.ts +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/schemas/Genesis.json +5 -5
- package/dist/schemas/Job.json +2 -2
- package/dist/scripts/brandFactories.d.ts +2 -2
- package/dist/scripts/brandFactories.js +4 -4
- package/dist/scripts/generateTypes.js +4 -4
- package/package.json +1 -1
package/dist/_lib/test.js
CHANGED
|
@@ -6,14 +6,14 @@ const Job = {
|
|
|
6
6
|
roles: {
|
|
7
7
|
inputMap: {
|
|
8
8
|
'ROLE-1234': {
|
|
9
|
-
resourceTypeId: '
|
|
9
|
+
resourceTypeId: 'TYPE-1234',
|
|
10
10
|
name: 'name',
|
|
11
11
|
description: 'description'
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
outputMap: {
|
|
15
15
|
'ROLE-5678': {
|
|
16
|
-
resourceTypeId: '
|
|
16
|
+
resourceTypeId: 'TYPE-5678',
|
|
17
17
|
name: 'name',
|
|
18
18
|
description: 'description'
|
|
19
19
|
}
|
|
@@ -67,7 +67,7 @@ const jobBeta = {
|
|
|
67
67
|
// This checks (no error expected); we're providing all required fields
|
|
68
68
|
const resourceDataJobAlpha = {
|
|
69
69
|
id: 'RESOURCE-1',
|
|
70
|
-
resourceTypeId: '
|
|
70
|
+
resourceTypeId: 'TYPE-ID',
|
|
71
71
|
creationContext: {
|
|
72
72
|
resourceRoleId: 'ROLE-ID',
|
|
73
73
|
executionId: 'EXECUTION-ID',
|
|
@@ -81,7 +81,7 @@ const resourceDataJobAlpha = {
|
|
|
81
81
|
// This SHOULD fail (missing path) once ResourceData_Job enforces Path strictly.
|
|
82
82
|
const resourceDataJobAlpha2 = {
|
|
83
83
|
id: 'RESOURCE-3',
|
|
84
|
-
resourceTypeId: '
|
|
84
|
+
resourceTypeId: 'TYPE-ID',
|
|
85
85
|
creationContext: {
|
|
86
86
|
resourceRoleId: 'ROLE-ID',
|
|
87
87
|
executionId: 'EXECUTION-ID',
|
|
@@ -95,7 +95,7 @@ const resourceDataJobAlpha2 = {
|
|
|
95
95
|
// This should fail; we're missing extractedData
|
|
96
96
|
const resourceDataJobAlpha3 = {
|
|
97
97
|
id: 'RESOURCE-2',
|
|
98
|
-
resourceTypeId: '
|
|
98
|
+
resourceTypeId: 'TYPE-ID',
|
|
99
99
|
creationContext: {
|
|
100
100
|
resourceRoleId: 'ROLE-ID',
|
|
101
101
|
executionId: 'EXECUTION-ID',
|
|
@@ -108,7 +108,7 @@ const resourceDataJobAlpha3 = {
|
|
|
108
108
|
// This SHOULD fail (missing roles.outputMap) once Job's roles is strictly enforced.
|
|
109
109
|
const resourceDataJobBeta = {
|
|
110
110
|
id: 'RESOURCE-4',
|
|
111
|
-
resourceTypeId: '
|
|
111
|
+
resourceTypeId: 'TYPE-ID',
|
|
112
112
|
creationContext: {
|
|
113
113
|
resourceRoleId: 'ROLE-ID',
|
|
114
114
|
executionId: 'EXECUTION-ID',
|
|
@@ -478,7 +478,7 @@ export interface RoleBindingsInner {
|
|
|
478
478
|
* This interface was referenced by `GenesisJson`'s JSON-Schema
|
|
479
479
|
* via the `definition` "RoleBindingMap".
|
|
480
480
|
*/
|
|
481
|
-
export type RoleBindingMap = Record<
|
|
481
|
+
export type RoleBindingMap = Record<ResourceRoleId, ResourceId>;
|
|
482
482
|
/**
|
|
483
483
|
* This interface was referenced by `GenesisJson`'s JSON-Schema
|
|
484
484
|
* via the `definition` "CanonicalRef".
|
|
@@ -620,7 +620,7 @@ export interface Timestamp {
|
|
|
620
620
|
* This interface was referenced by `GenesisJson`'s JSON-Schema
|
|
621
621
|
* via the `definition` "ResourceMap".
|
|
622
622
|
*/
|
|
623
|
-
export type ResourceMap = Record<ExecutionId, Record<
|
|
623
|
+
export type ResourceMap = Record<ExecutionId, Record<ResourceRoleId, ResourcePotentialInput | ResourcePotentialOutput | ResourceData>>;
|
|
624
624
|
/**
|
|
625
625
|
* This interface was referenced by `GenesisJson`'s JSON-Schema
|
|
626
626
|
* via the `definition` "RoleBindingsOuter".
|
|
@@ -632,7 +632,7 @@ export interface RoleBindingsOuter1 {
|
|
|
632
632
|
* This interface was referenced by `GenesisJson`'s JSON-Schema
|
|
633
633
|
* via the `definition` "RoleMap".
|
|
634
634
|
*/
|
|
635
|
-
export type RoleMap = Record<
|
|
635
|
+
export type RoleMap = Record<ResourceRoleId, ResourceRoleValue>;
|
|
636
636
|
/**
|
|
637
637
|
* This interface was referenced by `GenesisJson`'s JSON-Schema
|
|
638
638
|
* via the `definition` "RolesInner".
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { default as GenesisSchema } from './schemas/Genesis.js';
|
|
|
2
2
|
export { default as JobSchema } from './schemas/Job.js';
|
|
3
3
|
export type { ResourceData_Job as ResourceData_JobJson } from './_lib/types/ResourceData_Job.js';
|
|
4
4
|
export type { Identifiable as IdentifiableJson, Documented as DocumentedJson, IdentifiableDocumented as IdentifiableDocumentedJson, ResourceFormatId as ResourceFormatIdJson, ResourceFormatMeta as ResourceFormatMetaJson, ResourceFormatData as ResourceFormatDataJson, ExtractionSchema as ExtractionSchemaJson, ExtractionSchemaValue as ExtractionSchemaValueJson, IdentityProp as IdentityPropJson, MeritProp as MeritPropJson, ResourceTypeId as ResourceTypeIdJson, ResourceTypeMeta as ResourceTypeMetaJson, ResourceTypeData as ResourceTypeDataJson, ResourceRoleId as ResourceRoleIdJson, ResourceRoleValue as ResourceRoleValueJson, ExecutionId as ExecutionIdJson, Execution as ExecutionJson, ConditionalWrapper as ConditionalWrapperJson, RoleMap as RoleMapJson, RolesOuter as RolesOuterJson, RoleBindingMap as RoleBindingMapJson, RoleBindingsOuter as RoleBindingsOuterJson, ResourceId as ResourceIdJson, WorkStepId as WorkStepIdJson, BranchStepId as BranchStepIdJson, WhileStepId as WhileStepIdJson, ForStepId as ForStepIdJson, WorkStep as WorkStepJson, BranchStep as BranchStepJson, WhileStep as WhileStepJson, ForStep as ForStepJson, StepId as StepIdJson, Step as StepJson, ResourceSocket as ResourceSocketJson, ResourcePotentialInput as ResourcePotentialInputJson, ResourcePotentialOutput as ResourcePotentialOutputJson, ResourceMeta as ResourceMetaJson, ResourceData as ResourceDataJson, ResourceMap as ResourceMapJson, WorkflowId as WorkflowIdJson, Workflow as WorkflowJson, WorkflowSpecId as WorkflowSpecIdJson, WorkflowSpec as WorkflowSpecJson, Job as JobJson, JsonValue as JsonValueJson, } from './_lib/types/types.js';
|
|
5
|
-
export { unsafeBrand, asResourceTypeId,
|
|
5
|
+
export { unsafeBrand, asResourceTypeId, asResourceRoleId, asExecutionId, asResourceId, asWorkStepId, asBranchStepId, asForStepId, asResourceFormatId, asWhileStepId, asWorkflowId, asWorkflowSpecId, asResourceTypeIds, asResourceRoleIds, asExecutionIds, asResourceIds, asWorkStepIds, asBranchStepIds, asForStepIds, asResourceFormatIds, asWhileStepIds, asWorkflowIds, asWorkflowSpecIds, } from './scripts/brandFactories.js';
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
export { default as GenesisSchema } from './schemas/Genesis.js';
|
|
3
3
|
export { default as JobSchema } from './schemas/Job.js';
|
|
4
4
|
// Re-export brand factories so consumers can construct branded IDs at runtime.
|
|
5
|
-
export { unsafeBrand, asResourceTypeId,
|
|
5
|
+
export { unsafeBrand, asResourceTypeId, asResourceRoleId, asExecutionId, asResourceId, asWorkStepId, asBranchStepId, asForStepId, asResourceFormatId, asWhileStepId, asWorkflowId, asWorkflowSpecId, asResourceTypeIds, asResourceRoleIds, asExecutionIds, asResourceIds, asWorkStepIds, asBranchStepIds, asForStepIds, asResourceFormatIds, asWhileStepIds, asWorkflowIds, asWorkflowSpecIds, } from './scripts/brandFactories.js';
|
|
@@ -663,7 +663,7 @@
|
|
|
663
663
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
664
664
|
"type": "string",
|
|
665
665
|
"$anchor": "ResourceFormatId",
|
|
666
|
-
"pattern": "^
|
|
666
|
+
"pattern": "^FORMAT-.+$"
|
|
667
667
|
},
|
|
668
668
|
"ResourceFormatMeta": {
|
|
669
669
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -802,7 +802,7 @@
|
|
|
802
802
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
803
803
|
"type": "string",
|
|
804
804
|
"$anchor": "ResourceRoleId",
|
|
805
|
-
"pattern": "^
|
|
805
|
+
"pattern": "^ROLE-.+$"
|
|
806
806
|
},
|
|
807
807
|
"ResourceRoleValue": {
|
|
808
808
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -858,7 +858,7 @@
|
|
|
858
858
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
859
859
|
"type": "string",
|
|
860
860
|
"$anchor": "ResourceTypeId",
|
|
861
|
-
"pattern": "^
|
|
861
|
+
"pattern": "^TYPE-.+$"
|
|
862
862
|
},
|
|
863
863
|
"ResourceTypeMeta": {
|
|
864
864
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -874,10 +874,10 @@
|
|
|
874
874
|
"if": {
|
|
875
875
|
"properties": {
|
|
876
876
|
"resourceFormatId": {
|
|
877
|
-
"const": "
|
|
877
|
+
"const": "FORMAT-ApplicationJson"
|
|
878
878
|
}
|
|
879
879
|
},
|
|
880
|
-
"$comment": "If resourceFormatId is
|
|
880
|
+
"$comment": "If resourceFormatId is FORMAT-ApplicationJson, then uri must not be present, but if resourceFormatId is not FORMAT-ApplicationJson, then uri must be present. This is because resources of types with format FORMAT-ApplicationJson are self-contained and do not need an extractor."
|
|
881
881
|
},
|
|
882
882
|
"then": {
|
|
883
883
|
"not": {
|
package/dist/schemas/Job.json
CHANGED
|
@@ -149,13 +149,13 @@
|
|
|
149
149
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
150
150
|
"type": "string",
|
|
151
151
|
"$anchor": "ResourceRoleId",
|
|
152
|
-
"pattern": "^
|
|
152
|
+
"pattern": "^ROLE-.+$"
|
|
153
153
|
},
|
|
154
154
|
"ResourceTypeId": {
|
|
155
155
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
156
156
|
"type": "string",
|
|
157
157
|
"$anchor": "ResourceTypeId",
|
|
158
|
-
"pattern": "^
|
|
158
|
+
"pattern": "^TYPE-.+$"
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -2,7 +2,7 @@ import type { ExecutionId, ResourceId, WorkStepId, BranchStepId, ForStepId, Reso
|
|
|
2
2
|
/** Generic unsafe brand helper when a bespoke factory is not available. */
|
|
3
3
|
export declare function unsafeBrand<T extends string>(s: string): T;
|
|
4
4
|
export declare const asResourceTypeId: (s: string) => string;
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const asResourceRoleId: (s: string) => string;
|
|
6
6
|
export declare const asExecutionId: (s: string) => string;
|
|
7
7
|
export declare const asResourceId: (s: string) => string;
|
|
8
8
|
export declare const asWorkStepId: (s: string) => string;
|
|
@@ -13,7 +13,7 @@ export declare const asWhileStepId: (s: string) => string;
|
|
|
13
13
|
export declare const asWorkflowId: (s: string) => string;
|
|
14
14
|
export declare const asWorkflowSpecId: (s: string) => string;
|
|
15
15
|
export declare const asResourceTypeIds: (xs: string[]) => ResourceTypeId[];
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const asResourceRoleIds: (xs: string[]) => ResourceRoleId[];
|
|
17
17
|
export declare const asExecutionIds: (xs: string[]) => ExecutionId[];
|
|
18
18
|
export declare const asResourceIds: (xs: string[]) => ResourceId[];
|
|
19
19
|
export declare const asWorkStepIds: (xs: string[]) => WorkStepId[];
|
|
@@ -19,13 +19,13 @@ export function unsafeBrand(s) {
|
|
|
19
19
|
return s;
|
|
20
20
|
}
|
|
21
21
|
// Known patterns from schemas (when available)
|
|
22
|
-
const
|
|
22
|
+
const RE_TYPE_ID = /^TYPE-.+$/;
|
|
23
23
|
const RE_SIGNATURE_ID = /^SIGNATURE-.+$/;
|
|
24
24
|
const RE_JOB_ID = /^JOB-.+$/;
|
|
25
25
|
const RE_ROLE_ID = /^ROLE-.+$/;
|
|
26
26
|
// Factories for each Id-like type
|
|
27
|
-
export const asResourceTypeId = makeFactory("ResourceTypeId",
|
|
28
|
-
export const
|
|
27
|
+
export const asResourceTypeId = makeFactory("ResourceTypeId", RE_TYPE_ID);
|
|
28
|
+
export const asResourceRoleId = makeFactory("ResourceRoleId", RE_ROLE_ID);
|
|
29
29
|
// IDs without strict regex patterns in the current schemas: keep unchecked casts.
|
|
30
30
|
export const asExecutionId = makeFactory("ExecutionId");
|
|
31
31
|
export const asResourceId = makeFactory("ResourceId");
|
|
@@ -38,7 +38,7 @@ export const asWorkflowId = makeFactory("WorkflowId");
|
|
|
38
38
|
export const asWorkflowSpecId = makeFactory("WorkflowSpecId");
|
|
39
39
|
// Batch helpers
|
|
40
40
|
export const asResourceTypeIds = (xs) => xs.map(asResourceTypeId);
|
|
41
|
-
export const
|
|
41
|
+
export const asResourceRoleIds = (xs) => xs.map(asResourceRoleId);
|
|
42
42
|
export const asExecutionIds = (xs) => xs.map(asExecutionId);
|
|
43
43
|
export const asResourceIds = (xs) => xs.map(asResourceId);
|
|
44
44
|
export const asWorkStepIds = (xs) => xs.map(asWorkStepId);
|
|
@@ -185,7 +185,7 @@ async function main() {
|
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
187
|
// Remove permissive index signatures that make interfaces open-ended.
|
|
188
|
-
// Keep meaningful map-like signatures (e.g., `[k: string]:
|
|
188
|
+
// Keep meaningful map-like signatures (e.g., `[k: string]: ResourceRoleValue`) intact.
|
|
189
189
|
// Robust single-pass: delete the entire line (with optional trailing newline) where the signature appears.
|
|
190
190
|
// This avoids introducing extra blank lines while handling CRLF/LF and varying indentation.
|
|
191
191
|
ts = ts.replace(/^\s*\[k:\s*string\]:\s*unknown;\s*(?:\r?\n)?/gm, '');
|
|
@@ -331,9 +331,9 @@ async function main() {
|
|
|
331
331
|
});
|
|
332
332
|
// Post-process map-like interfaces to enforce key constraints via template literal Id types.
|
|
333
333
|
// Replace index-signature interfaces with Record<IdType, ValueType> so object literal keys are checked.
|
|
334
|
-
ts = ts.replace(/export interface RoleMap\s*{[^}]*}/g, 'export type RoleMap = Record<
|
|
335
|
-
ts = ts.replace(/export interface RoleBindingMap\s*{[^}]*}/g, 'export type RoleBindingMap = Record<
|
|
336
|
-
ts = ts.replace(/export interface ResourceMap\s*\{[^}]*\{[^}]*\}[^}]*\}/gs, 'export type ResourceMap = Record<ExecutionId, Record<
|
|
334
|
+
ts = ts.replace(/export interface RoleMap\s*{[^}]*}/g, 'export type RoleMap = Record<ResourceRoleId, ResourceRoleValue>;');
|
|
335
|
+
ts = ts.replace(/export interface RoleBindingMap\s*{[^}]*}/g, 'export type RoleBindingMap = Record<ResourceRoleId, ResourceId>;');
|
|
336
|
+
ts = ts.replace(/export interface ResourceMap\s*\{[^}]*\{[^}]*\}[^}]*\}/gs, 'export type ResourceMap = Record<ExecutionId, Record<ResourceRoleId, ResourcePotentialInput | ResourcePotentialOutput | ResourceData>>;');
|
|
337
337
|
parts.push(ts);
|
|
338
338
|
let output = parts.join('\n');
|
|
339
339
|
// Final guard: strip any lingering `[k: string]: unknown;` that might have been
|