@toolproof-npm/schema 0.1.30 → 0.1.31
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
CHANGED
|
@@ -5,14 +5,14 @@ const Job = {
|
|
|
5
5
|
uri: 'uri',
|
|
6
6
|
roles: {
|
|
7
7
|
inputMap: {
|
|
8
|
-
'
|
|
8
|
+
'RR-1234': {
|
|
9
9
|
resourceTypeId: 'RT-1234',
|
|
10
10
|
name: 'name',
|
|
11
11
|
description: 'description'
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
outputMap: {
|
|
15
|
-
'
|
|
15
|
+
'RR-5678': {
|
|
16
16
|
resourceTypeId: 'RT-5678',
|
|
17
17
|
name: 'name',
|
|
18
18
|
description: 'description'
|
|
@@ -69,7 +69,7 @@ const resourceDataJobAlpha = {
|
|
|
69
69
|
id: 'RESOURCE-1',
|
|
70
70
|
resourceTypeId: 'RT-ID',
|
|
71
71
|
creationContext: {
|
|
72
|
-
resourceRoleId: '
|
|
72
|
+
resourceRoleId: 'RR-ID',
|
|
73
73
|
executionId: 'EXECUTION-ID',
|
|
74
74
|
},
|
|
75
75
|
kind: 'realized',
|
|
@@ -83,7 +83,7 @@ const resourceDataJobAlpha2 = {
|
|
|
83
83
|
id: 'RESOURCE-3',
|
|
84
84
|
resourceTypeId: 'RT-ID',
|
|
85
85
|
creationContext: {
|
|
86
|
-
resourceRoleId: '
|
|
86
|
+
resourceRoleId: 'RR-ID',
|
|
87
87
|
executionId: 'EXECUTION-ID',
|
|
88
88
|
},
|
|
89
89
|
kind: 'realized',
|
|
@@ -97,7 +97,7 @@ const resourceDataJobAlpha3 = {
|
|
|
97
97
|
id: 'RESOURCE-2',
|
|
98
98
|
resourceTypeId: 'RT-ID',
|
|
99
99
|
creationContext: {
|
|
100
|
-
resourceRoleId: '
|
|
100
|
+
resourceRoleId: 'RR-ID',
|
|
101
101
|
executionId: 'EXECUTION-ID',
|
|
102
102
|
},
|
|
103
103
|
kind: 'realized',
|
|
@@ -110,7 +110,7 @@ const resourceDataJobBeta = {
|
|
|
110
110
|
id: 'RESOURCE-4',
|
|
111
111
|
resourceTypeId: 'RT-ID',
|
|
112
112
|
creationContext: {
|
|
113
|
-
resourceRoleId: '
|
|
113
|
+
resourceRoleId: 'RR-ID',
|
|
114
114
|
executionId: 'EXECUTION-ID',
|
|
115
115
|
},
|
|
116
116
|
kind: 'realized',
|
|
@@ -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, RoleLiteral>;
|
|
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';
|
|
@@ -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[];
|
|
@@ -22,10 +22,10 @@ export function unsafeBrand(s) {
|
|
|
22
22
|
const RE_RT_ID = /^RT-.+$/;
|
|
23
23
|
const RE_SIGNATURE_ID = /^SIGNATURE-.+$/;
|
|
24
24
|
const RE_JOB_ID = /^JOB-.+$/;
|
|
25
|
-
const
|
|
25
|
+
const RE_RR_ID = /^RR-.+$/;
|
|
26
26
|
// Factories for each Id-like type
|
|
27
27
|
export const asResourceTypeId = makeFactory("ResourceTypeId", RE_RT_ID);
|
|
28
|
-
export const
|
|
28
|
+
export const asResourceRoleId = makeFactory("ResourceRoleId", RE_RR_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);
|
|
@@ -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, RoleLiteral>;');
|
|
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
|