@toolproof-npm/schema 0.1.77 → 0.1.79
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/genesis/generated/types/types.d.ts +11 -33
- package/dist/index.d.ts +1 -18
- package/dist/index.js +0 -17
- package/dist/scripts/generateResourceTypeType.js +1 -1
- package/dist/scripts/generateTypes.js +13 -6
- package/package.json +1 -1
- package/dist/scripts/brandFactories.d.ts +0 -48
- package/dist/scripts/brandFactories.js +0 -54
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
864
|
-
|
|
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
|
|
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
|
|
1188
|
-
|
|
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;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WorkStepIdentity, BranchStepIdentity,
|
|
1
|
+
import { WorkStepIdentity, BranchStepIdentity, WhileStepIdentity, ForStepIdentity } from './genesis/generated/types/types.js';
|
|
2
2
|
export { default as SchemaGenesis } from './genesis/generated/schemas/Genesis.js';
|
|
3
3
|
export { default as SchemaJob } from './genesis/generated/schemas/Job.js';
|
|
4
4
|
export { default as ResourceTypeGenesis } from './genesis/generated/resource-type-envelopes/Genesis.js';
|
|
@@ -14,20 +14,3 @@ 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 { unsafeBrand, asResourceTypeIdentity, asResourceRoleIdentity, asExecutionIdentity, asResourceIdentity, asWorkStepIdentity, asBranchStepIdentity, asForStepIdentity, asResourceFormatIdentity, asWhileStepIdentity, asStatelessStrategyIdentity, asStatefulStrategyIdentity, asJobIdentity, asStrategyRunIdentity, asStrategyThreadIdentity, asResourceTypeIdentities, asResourceRoleIdentities, asExecutionIdentities, asResourceIdentities, asWorkStepIdentities, asBranchStepIdentities, asForStepIdentities, asResourceFormatIdentities, asWhileStepIdentities, asStatelessStrategyIdentities, asStatefulStrategyIdentities, asJobIdentities, asStrategyRunIdentities, asStrategyThreadIdentities, } from './scripts/brandFactories.js';
|
|
18
|
-
export declare const identityFactoriesByPrefix: {
|
|
19
|
-
readonly format: (s: string) => import("./scripts/brandFactories.js").ResourceFormatIdentity;
|
|
20
|
-
readonly type: (s: string) => import("./scripts/brandFactories.js").ResourceTypeIdentity;
|
|
21
|
-
readonly role: (s: string) => import("./scripts/brandFactories.js").ResourceRoleIdentity;
|
|
22
|
-
readonly job: (s: string) => import("./scripts/brandFactories.js").JobIdentity;
|
|
23
|
-
readonly execution: (s: string) => import("./scripts/brandFactories.js").ExecutionIdentity;
|
|
24
|
-
readonly resource: (s: string) => import("./scripts/brandFactories.js").ResourceIdentity;
|
|
25
|
-
readonly stateless_strategy: (s: string) => import("./scripts/brandFactories.js").StatelessStrategyIdentity;
|
|
26
|
-
readonly stateful_strategy: (s: string) => import("./scripts/brandFactories.js").StatefulStrategyIdentity;
|
|
27
|
-
readonly strategy_thread: (s: string) => import("./scripts/brandFactories.js").StrategyThreadIdentity;
|
|
28
|
-
readonly strategy_run: (s: string) => import("./scripts/brandFactories.js").StrategyRunIdentity;
|
|
29
|
-
};
|
|
30
|
-
export type IdentityPrefix = keyof typeof identityFactoriesByPrefix;
|
|
31
|
-
export type IdentityByPrefix = {
|
|
32
|
-
[K in IdentityPrefix]: ReturnType<(typeof identityFactoriesByPrefix)[K]>;
|
|
33
|
-
};
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
import { asExecutionIdentity, asJobIdentity, asResourceFormatIdentity, asResourceIdentity, asResourceRoleIdentity, asResourceTypeIdentity, asStatefulStrategyIdentity, asStatelessStrategyIdentity, asStrategyRunIdentity, asStrategyThreadIdentity, } from './scripts/brandFactories.js';
|
|
2
1
|
// Re-export JSON schemas via .ts shims to avoid .json re-exports in declarations
|
|
3
2
|
export { default as SchemaGenesis } from './genesis/generated/schemas/Genesis.js';
|
|
4
3
|
export { default as SchemaJob } from './genesis/generated/schemas/Job.js';
|
|
5
4
|
export { default as ResourceTypeGenesis } from './genesis/generated/resource-type-envelopes/Genesis.js';
|
|
6
5
|
export { default as dependencies } from './genesis/generated/dependencies_ordered.json';
|
|
7
6
|
export { default as terminals } from './genesis/generated/terminals.json';
|
|
8
|
-
// Re-export brand factories so consumers can construct branded identities at runtime.
|
|
9
|
-
export { unsafeBrand, asResourceTypeIdentity, asResourceRoleIdentity, asExecutionIdentity, asResourceIdentity, asWorkStepIdentity, asBranchStepIdentity, asForStepIdentity, asResourceFormatIdentity, asWhileStepIdentity, asStatelessStrategyIdentity, asStatefulStrategyIdentity, asJobIdentity, asStrategyRunIdentity, asStrategyThreadIdentity, asResourceTypeIdentities, asResourceRoleIdentities, asExecutionIdentities, asResourceIdentities, asWorkStepIdentities, asBranchStepIdentities, asForStepIdentities, asResourceFormatIdentities, asWhileStepIdentities, asStatelessStrategyIdentities, asStatefulStrategyIdentities, asJobIdentities, asStrategyRunIdentities, asStrategyThreadIdentities, } from './scripts/brandFactories.js';
|
|
10
|
-
// Identity prefix -> factory mapping.
|
|
11
|
-
// Consumers can derive types from this (and it centralizes future additions).
|
|
12
|
-
export const identityFactoriesByPrefix = {
|
|
13
|
-
format: asResourceFormatIdentity,
|
|
14
|
-
type: asResourceTypeIdentity,
|
|
15
|
-
role: asResourceRoleIdentity,
|
|
16
|
-
job: asJobIdentity,
|
|
17
|
-
execution: asExecutionIdentity,
|
|
18
|
-
resource: asResourceIdentity,
|
|
19
|
-
stateless_strategy: asStatelessStrategyIdentity,
|
|
20
|
-
stateful_strategy: asStatefulStrategyIdentity,
|
|
21
|
-
strategy_thread: asStrategyThreadIdentity,
|
|
22
|
-
strategy_run: asStrategyRunIdentity,
|
|
23
|
-
};
|
|
@@ -45,7 +45,7 @@ async function main() {
|
|
|
45
45
|
// IMPORTANT:
|
|
46
46
|
// We intentionally do NOT re-run json-schema-to-typescript here.
|
|
47
47
|
// That path produces self-contained types that degrade schema-patterned identities/refs
|
|
48
|
-
// into plain `string`, which then becomes incompatible with our canonical
|
|
48
|
+
// into plain `string`, which then becomes incompatible with our canonical
|
|
49
49
|
// identity types in `types.d.ts` (e.g. `ResourceIdentity = `RESOURCE-${string}``).
|
|
50
50
|
//
|
|
51
51
|
// Instead, we generate a tiny module that composes the canonical types:
|
|
@@ -459,11 +459,7 @@ async function main() {
|
|
|
459
459
|
}
|
|
460
460
|
const patternTemplates = loadPatternTemplates();
|
|
461
461
|
// Replace any exported Identity/Ref aliases to use the inferred template literals where available.
|
|
462
|
-
// Handle
|
|
463
|
-
ts = ts.replace(/^(export\s+type\s+)([A-Za-z_][A-Za-z0-9_]*(?:Identity|Ref))(\s*=\s*)Branded<string,\s*'[^']+'>\s*;$/gm, (_m, p1, typeName, p3) => {
|
|
464
|
-
const tmpl = patternTemplates[typeName];
|
|
465
|
-
return `${p1}${typeName}${p3}${tmpl ?? 'string'};`;
|
|
466
|
-
});
|
|
462
|
+
// Handle the common `= string;` output from json-schema-to-typescript.
|
|
467
463
|
ts = ts.replace(/^(export\s+type\s+)([A-Za-z_][A-Za-z0-9_]*(?:Identity|Ref))(\s*=\s*)string\s*;$/gm, (_m, p1, typeName, p3) => {
|
|
468
464
|
const tmpl = patternTemplates[typeName];
|
|
469
465
|
return `${p1}${typeName}${p3}${tmpl ?? 'string'};`;
|
|
@@ -473,9 +469,20 @@ async function main() {
|
|
|
473
469
|
const resourceRoleKeyType = 'ResourceRoleIdentity';
|
|
474
470
|
const resourceKeyType = 'ResourceIdentity';
|
|
475
471
|
const executionKeyType = 'ExecutionIdentity';
|
|
472
|
+
const strategyThreadKeyType = 'StrategyThreadIdentity';
|
|
476
473
|
ts = ts.replace(/export interface RoleMap\s*{[^}]*}/g, `export type RoleMap = Record<${resourceRoleKeyType}, ResourceRoleValue>;`);
|
|
477
474
|
ts = ts.replace(/export interface RoleBindingMap\s*{[^}]*}/g, `export type RoleBindingMap = Record<${resourceRoleKeyType}, ${resourceKeyType}>;`);
|
|
478
|
-
|
|
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[]>;`);
|
|
479
486
|
parts.push(ts);
|
|
480
487
|
let output = parts.join('\n');
|
|
481
488
|
// Final guard: strip any lingering `[k: string]: unknown;` that might have been
|
package/package.json
CHANGED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
type Brand<K extends string> = string & {
|
|
2
|
-
readonly __brand: K;
|
|
3
|
-
};
|
|
4
|
-
export type ExecutionIdentity = Brand<'ExecutionIdentity'>;
|
|
5
|
-
export type ResourceIdentity = Brand<'ResourceIdentity'>;
|
|
6
|
-
export type WorkStepIdentity = Brand<'WorkStepIdentity'>;
|
|
7
|
-
export type BranchStepIdentity = Brand<'BranchStepIdentity'>;
|
|
8
|
-
export type ForStepIdentity = Brand<'ForStepIdentity'>;
|
|
9
|
-
export type WhileStepIdentity = Brand<'WhileStepIdentity'>;
|
|
10
|
-
export type ResourceFormatIdentity = Brand<'ResourceFormatIdentity'>;
|
|
11
|
-
export type ResourceTypeIdentity = Brand<'ResourceTypeIdentity'>;
|
|
12
|
-
export type ResourceRoleIdentity = Brand<'ResourceRoleIdentity'>;
|
|
13
|
-
export type StatelessStrategyIdentity = Brand<'StatelessStrategyIdentity'>;
|
|
14
|
-
export type StatefulStrategyIdentity = Brand<'StatefulStrategyIdentity'>;
|
|
15
|
-
export type JobIdentity = Brand<'JobIdentity'>;
|
|
16
|
-
export type StrategyRunIdentity = Brand<'StrategyRunIdentity'>;
|
|
17
|
-
export type StrategyThreadIdentity = Brand<'StrategyThreadIdentity'>;
|
|
18
|
-
/** Generic unsafe brand helper when a bespoke factory is not available. */
|
|
19
|
-
export declare function unsafeBrand<T extends string>(s: string): T;
|
|
20
|
-
export declare const asResourceTypeIdentity: (s: string) => ResourceTypeIdentity;
|
|
21
|
-
export declare const asResourceRoleIdentity: (s: string) => ResourceRoleIdentity;
|
|
22
|
-
export declare const asJobIdentity: (s: string) => JobIdentity;
|
|
23
|
-
export declare const asExecutionIdentity: (s: string) => ExecutionIdentity;
|
|
24
|
-
export declare const asResourceIdentity: (s: string) => ResourceIdentity;
|
|
25
|
-
export declare const asWorkStepIdentity: (s: string) => WorkStepIdentity;
|
|
26
|
-
export declare const asBranchStepIdentity: (s: string) => BranchStepIdentity;
|
|
27
|
-
export declare const asForStepIdentity: (s: string) => ForStepIdentity;
|
|
28
|
-
export declare const asResourceFormatIdentity: (s: string) => ResourceFormatIdentity;
|
|
29
|
-
export declare const asWhileStepIdentity: (s: string) => WhileStepIdentity;
|
|
30
|
-
export declare const asStatelessStrategyIdentity: (s: string) => StatelessStrategyIdentity;
|
|
31
|
-
export declare const asStatefulStrategyIdentity: (s: string) => StatefulStrategyIdentity;
|
|
32
|
-
export declare const asStrategyRunIdentity: (s: string) => StrategyRunIdentity;
|
|
33
|
-
export declare const asStrategyThreadIdentity: (s: string) => StrategyThreadIdentity;
|
|
34
|
-
export declare const asResourceTypeIdentities: (xs: string[]) => ResourceTypeIdentity[];
|
|
35
|
-
export declare const asResourceRoleIdentities: (xs: string[]) => ResourceRoleIdentity[];
|
|
36
|
-
export declare const asJobIdentities: (xs: string[]) => JobIdentity[];
|
|
37
|
-
export declare const asExecutionIdentities: (xs: string[]) => ExecutionIdentity[];
|
|
38
|
-
export declare const asResourceIdentities: (xs: string[]) => ResourceIdentity[];
|
|
39
|
-
export declare const asWorkStepIdentities: (xs: string[]) => WorkStepIdentity[];
|
|
40
|
-
export declare const asBranchStepIdentities: (xs: string[]) => BranchStepIdentity[];
|
|
41
|
-
export declare const asForStepIdentities: (xs: string[]) => ForStepIdentity[];
|
|
42
|
-
export declare const asResourceFormatIdentities: (xs: string[]) => ResourceFormatIdentity[];
|
|
43
|
-
export declare const asWhileStepIdentities: (xs: string[]) => WhileStepIdentity[];
|
|
44
|
-
export declare const asStatelessStrategyIdentities: (xs: string[]) => StatelessStrategyIdentity[];
|
|
45
|
-
export declare const asStatefulStrategyIdentities: (xs: string[]) => StatefulStrategyIdentity[];
|
|
46
|
-
export declare const asStrategyRunIdentities: (xs: string[]) => StrategyRunIdentity[];
|
|
47
|
-
export declare const asStrategyThreadIdentities: (xs: string[]) => StrategyThreadIdentity[];
|
|
48
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// Optional runtime validation toggle. Off by default.
|
|
2
|
-
// Enable by setting TP_BRAND_VALIDATE=1 (or NODE_ENV=development) when running.
|
|
3
|
-
const shouldValidate = (typeof process !== "undefined" && !!process.env &&
|
|
4
|
-
(process.env.TP_BRAND_VALIDATE === "1" || process.env.NODE_ENV === "development")) ||
|
|
5
|
-
false;
|
|
6
|
-
function makeFactory(name, pattern) {
|
|
7
|
-
return (s) => {
|
|
8
|
-
if (shouldValidate && pattern && !pattern.test(s)) {
|
|
9
|
-
throw new TypeError(`Invalid ${name}: "${s}" does not match ${String(pattern)}`);
|
|
10
|
-
}
|
|
11
|
-
return s;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
/** Generic unsafe brand helper when a bespoke factory is not available. */
|
|
15
|
-
export function unsafeBrand(s) {
|
|
16
|
-
return s;
|
|
17
|
-
}
|
|
18
|
-
// Known patterns from schemas (when available)
|
|
19
|
-
const RE_TYPE_IDENTITY = /^TYPE-.+$/;
|
|
20
|
-
const RE_JOB_IDENTITY = /^JOB-.+$/;
|
|
21
|
-
const RE_ROLE_IDENTITY = /^ROLE-.+$/;
|
|
22
|
-
const RE_STRATEGY_RUN_IDENTITY = /^STRATEGY_RUN-.+$/;
|
|
23
|
-
const RE_STRATEGY_THREAD_IDENTITY = /^STRATEGY_THREAD-.+$/;
|
|
24
|
-
// Factories for each Identity-like type
|
|
25
|
-
export const asResourceTypeIdentity = makeFactory("ResourceTypeIdentity", RE_TYPE_IDENTITY);
|
|
26
|
-
export const asResourceRoleIdentity = makeFactory("ResourceRoleIdentity", RE_ROLE_IDENTITY);
|
|
27
|
-
export const asJobIdentity = makeFactory("JobIdentity", RE_JOB_IDENTITY);
|
|
28
|
-
// IDs without strict regex patterns in the current schemas: keep unchecked casts.
|
|
29
|
-
export const asExecutionIdentity = makeFactory("ExecutionIdentity");
|
|
30
|
-
export const asResourceIdentity = makeFactory("ResourceIdentity");
|
|
31
|
-
export const asWorkStepIdentity = makeFactory("WorkStepIdentity");
|
|
32
|
-
export const asBranchStepIdentity = makeFactory("BranchStepIdentity");
|
|
33
|
-
export const asForStepIdentity = makeFactory("ForStepIdentity");
|
|
34
|
-
export const asResourceFormatIdentity = makeFactory("ResourceFormatIdentity");
|
|
35
|
-
export const asWhileStepIdentity = makeFactory("WhileStepIdentity");
|
|
36
|
-
export const asStatelessStrategyIdentity = makeFactory("StatelessStrategyIdentity");
|
|
37
|
-
export const asStatefulStrategyIdentity = makeFactory("StatefulStrategyIdentity");
|
|
38
|
-
export const asStrategyRunIdentity = makeFactory("StrategyRunIdentity", RE_STRATEGY_RUN_IDENTITY);
|
|
39
|
-
export const asStrategyThreadIdentity = makeFactory("StrategyThreadIdentity", RE_STRATEGY_THREAD_IDENTITY);
|
|
40
|
-
// Batch helpers
|
|
41
|
-
export const asResourceTypeIdentities = (xs) => xs.map(asResourceTypeIdentity);
|
|
42
|
-
export const asResourceRoleIdentities = (xs) => xs.map(asResourceRoleIdentity);
|
|
43
|
-
export const asJobIdentities = (xs) => xs.map(asJobIdentity);
|
|
44
|
-
export const asExecutionIdentities = (xs) => xs.map(asExecutionIdentity);
|
|
45
|
-
export const asResourceIdentities = (xs) => xs.map(asResourceIdentity);
|
|
46
|
-
export const asWorkStepIdentities = (xs) => xs.map(asWorkStepIdentity);
|
|
47
|
-
export const asBranchStepIdentities = (xs) => xs.map(asBranchStepIdentity);
|
|
48
|
-
export const asForStepIdentities = (xs) => xs.map(asForStepIdentity);
|
|
49
|
-
export const asResourceFormatIdentities = (xs) => xs.map(asResourceFormatIdentity);
|
|
50
|
-
export const asWhileStepIdentities = (xs) => xs.map(asWhileStepIdentity);
|
|
51
|
-
export const asStatelessStrategyIdentities = (xs) => xs.map(asStatelessStrategyIdentity);
|
|
52
|
-
export const asStatefulStrategyIdentities = (xs) => xs.map(asStatefulStrategyIdentity);
|
|
53
|
-
export const asStrategyRunIdentities = (xs) => xs.map(asStrategyRunIdentity);
|
|
54
|
-
export const asStrategyThreadIdentities = (xs) => xs.map(asStrategyThreadIdentity);
|