@toolproof-npm/schema 0.1.76 → 0.1.77
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/index.d.ts +17 -1
- package/dist/index.js +16 -1
- package/dist/scripts/brandFactories.d.ts +9 -0
- package/dist/scripts/brandFactories.js +8 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -14,4 +14,20 @@ 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, asResourceTypeIdentities, asResourceRoleIdentities, asExecutionIdentities, asResourceIdentities, asWorkStepIdentities, asBranchStepIdentities, asForStepIdentities, asResourceFormatIdentities, asWhileStepIdentities, asStatelessStrategyIdentities, asStatefulStrategyIdentities, } from './scripts/brandFactories.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,3 +1,4 @@
|
|
|
1
|
+
import { asExecutionIdentity, asJobIdentity, asResourceFormatIdentity, asResourceIdentity, asResourceRoleIdentity, asResourceTypeIdentity, asStatefulStrategyIdentity, asStatelessStrategyIdentity, asStrategyRunIdentity, asStrategyThreadIdentity, } from './scripts/brandFactories.js';
|
|
1
2
|
// Re-export JSON schemas via .ts shims to avoid .json re-exports in declarations
|
|
2
3
|
export { default as SchemaGenesis } from './genesis/generated/schemas/Genesis.js';
|
|
3
4
|
export { default as SchemaJob } from './genesis/generated/schemas/Job.js';
|
|
@@ -5,4 +6,18 @@ export { default as ResourceTypeGenesis } from './genesis/generated/resource-typ
|
|
|
5
6
|
export { default as dependencies } from './genesis/generated/dependencies_ordered.json';
|
|
6
7
|
export { default as terminals } from './genesis/generated/terminals.json';
|
|
7
8
|
// Re-export brand factories so consumers can construct branded identities at runtime.
|
|
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';
|
|
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
|
+
};
|
|
@@ -12,10 +12,14 @@ export type ResourceTypeIdentity = Brand<'ResourceTypeIdentity'>;
|
|
|
12
12
|
export type ResourceRoleIdentity = Brand<'ResourceRoleIdentity'>;
|
|
13
13
|
export type StatelessStrategyIdentity = Brand<'StatelessStrategyIdentity'>;
|
|
14
14
|
export type StatefulStrategyIdentity = Brand<'StatefulStrategyIdentity'>;
|
|
15
|
+
export type JobIdentity = Brand<'JobIdentity'>;
|
|
16
|
+
export type StrategyRunIdentity = Brand<'StrategyRunIdentity'>;
|
|
17
|
+
export type StrategyThreadIdentity = Brand<'StrategyThreadIdentity'>;
|
|
15
18
|
/** Generic unsafe brand helper when a bespoke factory is not available. */
|
|
16
19
|
export declare function unsafeBrand<T extends string>(s: string): T;
|
|
17
20
|
export declare const asResourceTypeIdentity: (s: string) => ResourceTypeIdentity;
|
|
18
21
|
export declare const asResourceRoleIdentity: (s: string) => ResourceRoleIdentity;
|
|
22
|
+
export declare const asJobIdentity: (s: string) => JobIdentity;
|
|
19
23
|
export declare const asExecutionIdentity: (s: string) => ExecutionIdentity;
|
|
20
24
|
export declare const asResourceIdentity: (s: string) => ResourceIdentity;
|
|
21
25
|
export declare const asWorkStepIdentity: (s: string) => WorkStepIdentity;
|
|
@@ -25,8 +29,11 @@ export declare const asResourceFormatIdentity: (s: string) => ResourceFormatIden
|
|
|
25
29
|
export declare const asWhileStepIdentity: (s: string) => WhileStepIdentity;
|
|
26
30
|
export declare const asStatelessStrategyIdentity: (s: string) => StatelessStrategyIdentity;
|
|
27
31
|
export declare const asStatefulStrategyIdentity: (s: string) => StatefulStrategyIdentity;
|
|
32
|
+
export declare const asStrategyRunIdentity: (s: string) => StrategyRunIdentity;
|
|
33
|
+
export declare const asStrategyThreadIdentity: (s: string) => StrategyThreadIdentity;
|
|
28
34
|
export declare const asResourceTypeIdentities: (xs: string[]) => ResourceTypeIdentity[];
|
|
29
35
|
export declare const asResourceRoleIdentities: (xs: string[]) => ResourceRoleIdentity[];
|
|
36
|
+
export declare const asJobIdentities: (xs: string[]) => JobIdentity[];
|
|
30
37
|
export declare const asExecutionIdentities: (xs: string[]) => ExecutionIdentity[];
|
|
31
38
|
export declare const asResourceIdentities: (xs: string[]) => ResourceIdentity[];
|
|
32
39
|
export declare const asWorkStepIdentities: (xs: string[]) => WorkStepIdentity[];
|
|
@@ -36,4 +43,6 @@ export declare const asResourceFormatIdentities: (xs: string[]) => ResourceForma
|
|
|
36
43
|
export declare const asWhileStepIdentities: (xs: string[]) => WhileStepIdentity[];
|
|
37
44
|
export declare const asStatelessStrategyIdentities: (xs: string[]) => StatelessStrategyIdentity[];
|
|
38
45
|
export declare const asStatefulStrategyIdentities: (xs: string[]) => StatefulStrategyIdentity[];
|
|
46
|
+
export declare const asStrategyRunIdentities: (xs: string[]) => StrategyRunIdentity[];
|
|
47
|
+
export declare const asStrategyThreadIdentities: (xs: string[]) => StrategyThreadIdentity[];
|
|
39
48
|
export {};
|
|
@@ -19,9 +19,12 @@ export function unsafeBrand(s) {
|
|
|
19
19
|
const RE_TYPE_IDENTITY = /^TYPE-.+$/;
|
|
20
20
|
const RE_JOB_IDENTITY = /^JOB-.+$/;
|
|
21
21
|
const RE_ROLE_IDENTITY = /^ROLE-.+$/;
|
|
22
|
+
const RE_STRATEGY_RUN_IDENTITY = /^STRATEGY_RUN-.+$/;
|
|
23
|
+
const RE_STRATEGY_THREAD_IDENTITY = /^STRATEGY_THREAD-.+$/;
|
|
22
24
|
// Factories for each Identity-like type
|
|
23
25
|
export const asResourceTypeIdentity = makeFactory("ResourceTypeIdentity", RE_TYPE_IDENTITY);
|
|
24
26
|
export const asResourceRoleIdentity = makeFactory("ResourceRoleIdentity", RE_ROLE_IDENTITY);
|
|
27
|
+
export const asJobIdentity = makeFactory("JobIdentity", RE_JOB_IDENTITY);
|
|
25
28
|
// IDs without strict regex patterns in the current schemas: keep unchecked casts.
|
|
26
29
|
export const asExecutionIdentity = makeFactory("ExecutionIdentity");
|
|
27
30
|
export const asResourceIdentity = makeFactory("ResourceIdentity");
|
|
@@ -32,9 +35,12 @@ export const asResourceFormatIdentity = makeFactory("ResourceFormatIdentity");
|
|
|
32
35
|
export const asWhileStepIdentity = makeFactory("WhileStepIdentity");
|
|
33
36
|
export const asStatelessStrategyIdentity = makeFactory("StatelessStrategyIdentity");
|
|
34
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);
|
|
35
40
|
// Batch helpers
|
|
36
41
|
export const asResourceTypeIdentities = (xs) => xs.map(asResourceTypeIdentity);
|
|
37
42
|
export const asResourceRoleIdentities = (xs) => xs.map(asResourceRoleIdentity);
|
|
43
|
+
export const asJobIdentities = (xs) => xs.map(asJobIdentity);
|
|
38
44
|
export const asExecutionIdentities = (xs) => xs.map(asExecutionIdentity);
|
|
39
45
|
export const asResourceIdentities = (xs) => xs.map(asResourceIdentity);
|
|
40
46
|
export const asWorkStepIdentities = (xs) => xs.map(asWorkStepIdentity);
|
|
@@ -44,3 +50,5 @@ export const asResourceFormatIdentities = (xs) => xs.map(asResourceFormatIdentit
|
|
|
44
50
|
export const asWhileStepIdentities = (xs) => xs.map(asWhileStepIdentity);
|
|
45
51
|
export const asStatelessStrategyIdentities = (xs) => xs.map(asStatelessStrategyIdentity);
|
|
46
52
|
export const asStatefulStrategyIdentities = (xs) => xs.map(asStatefulStrategyIdentity);
|
|
53
|
+
export const asStrategyRunIdentities = (xs) => xs.map(asStrategyRunIdentity);
|
|
54
|
+
export const asStrategyThreadIdentities = (xs) => xs.map(asStrategyThreadIdentity);
|