@toolproof-npm/schema 0.1.78 → 0.1.80

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.
@@ -448,9 +448,7 @@ export interface Named {
448
448
  * This interface was referenced by `GenesisJson`'s JSON-Schema
449
449
  * via the `definition` "ExecutionSocket".
450
450
  */
451
- export interface ExecutionSocket {
452
- [k: string]: ResourceMissing | ResourcePotentialInput | ResourcePotentialOutput | Resource;
453
- }
451
+ export type ExecutionSocket = Record<ResourceRoleIdentity, ResourceMissing | ResourcePotentialInput | ResourcePotentialOutput | Resource>;
454
452
  /**
455
453
  * This interface was referenced by `GenesisJson`'s JSON-Schema
456
454
  * via the `definition` "ResourceBase".
@@ -484,9 +482,7 @@ export interface Path {
484
482
  * This interface was referenced by `GenesisJson`'s JSON-Schema
485
483
  * via the `definition` "ExecutionSocketMaterialized".
486
484
  */
487
- export interface ExecutionSocketMaterialized {
488
- [k: string]: Resource;
489
- }
485
+ export type ExecutionSocketMaterialized = Record<ResourceRoleIdentity, Resource>;
490
486
  /**
491
487
  * This interface was referenced by `GenesisJson`'s JSON-Schema
492
488
  * via the `definition` "ExtractionSchemaWrapper".
@@ -591,9 +587,7 @@ export interface StrategyStateWrapper {
591
587
  * This interface was referenced by `GenesisJson`'s JSON-Schema
592
588
  * via the `definition` "StrategyState".
593
589
  */
594
- export interface StrategyState {
595
- [k: string]: ExecutionSocket;
596
- }
590
+ export type StrategyState = Record<ExecutionIdentity, ExecutionSocket>;
597
591
  /**
598
592
  * This interface was referenced by `GenesisJson`'s JSON-Schema
599
593
  * via the `definition` "StrategyRunContext".
@@ -610,9 +604,7 @@ export interface StrategyThreadMapWrapper {
610
604
  * This interface was referenced by `GenesisJson`'s JSON-Schema
611
605
  * via the `definition` "StrategyThreadMap".
612
606
  */
613
- export interface StrategyThreadMap {
614
- [k: string]: Step[];
615
- }
607
+ export type StrategyThreadMap = Record<StrategyThreadIdentity, Step[]>;
616
608
  export interface StrategyStateWrapper1 {
617
609
  strategyState: StrategyState;
618
610
  }
@@ -623,12 +615,8 @@ export interface StrategyStateWrapper1 {
623
615
  export interface StrategyRunUpdate {
624
616
  strategyRun?: StrategyRun1;
625
617
  strategyRunRef: StrategyRunIdentity;
626
- strategyStateUpdate: {
627
- [k: string]: ExecutionSocketMaterialized;
628
- };
629
- strategyStateUpdateWide?: {
630
- [k: string]: ExecutionSocket;
631
- };
618
+ strategyStateUpdate: Record<ExecutionIdentity, ExecutionSocketMaterialized>;
619
+ strategyStateUpdateWide?: Record<ExecutionIdentity, ExecutionSocket>;
632
620
  }
633
621
  /**
634
622
  * This interface was referenced by `GenesisJson`'s JSON-Schema
@@ -860,12 +848,8 @@ export interface Conditional {
860
848
  export interface StrategyStateWrapper {
861
849
  strategyState: StrategyState;
862
850
  }
863
- export interface StrategyState {
864
- [k: string]: ExecutionSocket;
865
- }
866
- export interface ExecutionSocket {
867
- [k: string]: ResourceMissing | ResourcePotentialInput | ResourcePotentialOutput | Resource;
868
- }
851
+ export type StrategyState = Record<ExecutionIdentity, ExecutionSocket>;
852
+ export type ExecutionSocket = Record<ResourceRoleIdentity, ResourceMissing | ResourcePotentialInput | ResourcePotentialOutput | Resource>;
869
853
  export interface ResourceBase {
870
854
  identity: ResourceIdentity;
871
855
  resourceTypeRef: ResourceTypeIdentity;
@@ -1163,9 +1147,7 @@ export interface Timestamp {
1163
1147
  export interface StrategyThreadMapWrapper {
1164
1148
  strategyThreadMap: StrategyThreadMap;
1165
1149
  }
1166
- export interface StrategyThreadMap {
1167
- [k: string]: Step[];
1168
- }
1150
+ export type StrategyThreadMap = Record<StrategyThreadIdentity, Step[]>;
1169
1151
  export interface RoleBindingsWrapper {
1170
1152
  roleBindings: RoleBindings;
1171
1153
  }
@@ -1184,12 +1166,8 @@ export interface Conditional {
1184
1166
  export interface StrategyStateWrapper {
1185
1167
  strategyState: StrategyState;
1186
1168
  }
1187
- export interface StrategyState {
1188
- [k: string]: ExecutionSocket;
1189
- }
1190
- export interface ExecutionSocket {
1191
- [k: string]: ResourceMissing | ResourcePotentialInput | ResourcePotentialOutput | Resource;
1192
- }
1169
+ export type StrategyState = Record<ExecutionIdentity, ExecutionSocket>;
1170
+ export type ExecutionSocket = Record<ResourceRoleIdentity, ResourceMissing | ResourcePotentialInput | ResourcePotentialOutput | Resource>;
1193
1171
  export interface ResourceBase {
1194
1172
  identity: ResourceIdentity;
1195
1173
  resourceTypeRef: ResourceTypeIdentity;
@@ -0,0 +1,3 @@
1
+ import type { ResourceRoleIdentity, StrategyThreadIdentity } from './genesis/generated/types/types.js';
2
+ export declare function isResourceRoleIdentityJson(value: string): value is ResourceRoleIdentity;
3
+ export declare function isStrategyThreadIdentityJson(value: string): value is StrategyThreadIdentity;
@@ -0,0 +1,6 @@
1
+ export function isResourceRoleIdentityJson(value) {
2
+ return value.startsWith('ROLE-');
3
+ }
4
+ export function isStrategyThreadIdentityJson(value) {
5
+ return value.startsWith('STRATEGY_THREAD-');
6
+ }
package/dist/index.d.ts CHANGED
@@ -14,3 +14,4 @@ export type { Resource_StrategyRun as Resource_StrategyRunJson } from './genesis
14
14
  export type StepIdentityJson = WorkStepIdentity | BranchStepIdentity | WhileStepIdentity | ForStepIdentity;
15
15
  export type { Documented as DocumentedJson, ResourceFormatIdentity as ResourceFormatIdentityJson, ResourceFormat as ResourceFormatJson, ExtractionSchema as ExtractionSchemaJson, IdentityProp as IdentityPropJson, MeritProp as MeritPropJson, ResourceTypeIdentity as ResourceTypeIdentityJson, ResourceType as ResourceTypeJson, ResourceRoleIdentity as ResourceRoleIdentityJson, ResourceRoleValue as ResourceRoleValueJson, ExecutionIdentity as ExecutionIdentityJson, Execution as ExecutionJson, Conditional as ConditionalJson, RoleMap as RoleMapJson, Roles as RolesJson, RoleBindingMap as RoleBindingMapJson, RoleBindings as RoleBindingsJson, ResourceIdentity as ResourceIdentityJson, WorkStepIdentity as WorkStepIdentityJson, BranchStepIdentity as BranchStepIdentityJson, WhileStepIdentity as WhileStepIdentityJson, ForStepIdentity as ForStepIdentityJson, WorkStep as WorkStepJson, BranchStep as BranchStepJson, WhileStep as WhileStepJson, ForStep as ForStepJson, StepKind as StepKindJson, Step as StepJson, CreationContext as CreationContextJson, ResourceMissing as ResourceMissingJson, ResourcePotentialInput as ResourcePotentialInputJson, ResourcePotentialOutput as ResourcePotentialOutputJson, ResourceMetaBase as ResourceMetaJson, // ATTENTION: type not generated for ResourceMeta
16
16
  Resource as ResourceJson, StrategyState as StrategyStateJson, StatelessStrategyIdentity as StatelessStrategyIdentityJson, StatelessStrategy as StatelessStrategyJson, StatefulStrategyIdentity as StatefulStrategyIdentityJson, StatefulStrategy as StatefulStrategyJson, StrategyRunIdentity as StrategyRunIdentityJson, StrategyRunStatus as StrategyRunStatusJson, StrategyRun as StrategyRunJson, StrategyRunUpdate as StrategyRunUpdateJson, JobIdentity as JobIdentityJson, Job as JobJson, JsonData as JsonDataJson, StrategyThreadIdentity as StrategyThreadIdentityJson, StrategyThreadMap as StrategyThreadMapJson, ExecutionSocket as ExecutionSocketJson, ExecutionSocketMaterialized as ExecutionSocketMaterializedJson, Timestamp as TimestampJson, } from './genesis/generated/types/types.js';
17
+ export { isResourceRoleIdentityJson, isStrategyThreadIdentityJson } from './identityGuards.js';
package/dist/index.js CHANGED
@@ -4,3 +4,4 @@ export { default as SchemaJob } from './genesis/generated/schemas/Job.js';
4
4
  export { default as ResourceTypeGenesis } from './genesis/generated/resource-type-envelopes/Genesis.js';
5
5
  export { default as dependencies } from './genesis/generated/dependencies_ordered.json';
6
6
  export { default as terminals } from './genesis/generated/terminals.json';
7
+ export { isResourceRoleIdentityJson, isStrategyThreadIdentityJson } from './identityGuards.js';
@@ -469,9 +469,20 @@ async function main() {
469
469
  const resourceRoleKeyType = 'ResourceRoleIdentity';
470
470
  const resourceKeyType = 'ResourceIdentity';
471
471
  const executionKeyType = 'ExecutionIdentity';
472
+ const strategyThreadKeyType = 'StrategyThreadIdentity';
472
473
  ts = ts.replace(/export interface RoleMap\s*{[^}]*}/g, `export type RoleMap = Record<${resourceRoleKeyType}, ResourceRoleValue>;`);
473
474
  ts = ts.replace(/export interface RoleBindingMap\s*{[^}]*}/g, `export type RoleBindingMap = Record<${resourceRoleKeyType}, ${resourceKeyType}>;`);
474
- ts = ts.replace(/export interface StrategyState\s*\{[^}]*\{[^}]*\}[^}]*\}/gs, `export type StrategyState = Record<${executionKeyType}, Record<${resourceRoleKeyType}, ResourceMissing | ResourcePotentialInput | ResourcePotentialOutput | Resource>>;`);
475
+ // Normalize StrategyState & related socket maps to identity-keyed Records.
476
+ // These are emitted as `[k: string]` by json-schema-to-typescript but are identity-keyed in practice.
477
+ const executionSocketValueType = 'ResourceMissing | ResourcePotentialInput | ResourcePotentialOutput | Resource';
478
+ ts = ts.replace(/export interface ExecutionSocket\s*\{\s*\[k:\s*string\]:\s*[^;]+;\s*\}/g, `export type ExecutionSocket = Record<${resourceRoleKeyType}, ${executionSocketValueType}>;`);
479
+ ts = ts.replace(/export interface ExecutionSocketMaterialized\s*\{\s*\[k:\s*string\]:\s*Resource;\s*\}/g, `export type ExecutionSocketMaterialized = Record<${resourceRoleKeyType}, Resource>;`);
480
+ ts = ts.replace(/export interface StrategyState\s*\{\s*\[k:\s*string\]:\s*ExecutionSocket;\s*\}/g, `export type StrategyState = Record<${executionKeyType}, ExecutionSocket>;`);
481
+ ts = ts.replace(/(strategyStateUpdate:\s*)\{\s*\[k:\s*string\]:\s*ExecutionSocketMaterialized;\s*\};/g, `$1Record<${executionKeyType}, ExecutionSocketMaterialized>;`);
482
+ ts = ts.replace(/(strategyStateUpdateWide\??:\s*)\{\s*\[k:\s*string\]:\s*ExecutionSocket;\s*\};/g, `$1Record<${executionKeyType}, ExecutionSocket>;`);
483
+ // Ensure key constraints for strategyThreadMap are preserved as template-literal identity keys.
484
+ // json-schema-to-typescript emits `[k: string]: Step[];`, but we want keys to be `StrategyThreadIdentity`.
485
+ ts = ts.replace(/export interface StrategyThreadMap\s*\{\s*\[k:\s*string\]:\s*Step\[\];\s*\}/g, `export type StrategyThreadMap = Record<${strategyThreadKeyType}, Step[]>;`);
475
486
  parts.push(ts);
476
487
  let output = parts.join('\n');
477
488
  // Final guard: strip any lingering `[k: string]: unknown;` that might have been
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolproof-npm/schema",
3
- "version": "0.1.78",
3
+ "version": "0.1.80",
4
4
  "description": "JSON schemas and TypeScript types for ToolProof",
5
5
  "keywords": [
6
6
  "toolproof",
@@ -26,6 +26,10 @@
26
26
  ".": {
27
27
  "import": "./dist/index.js",
28
28
  "types": "./dist/index.d.ts"
29
+ },
30
+ "./identityGuards": {
31
+ "import": "./dist/identityGuards.js",
32
+ "types": "./dist/identityGuards.d.ts"
29
33
  }
30
34
  },
31
35
  "files": [