@toolproof-core/schema 1.0.15 → 1.0.17

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.
Files changed (47) hide show
  1. package/dist/generated/artifacts/constants.d.ts +0 -1
  2. package/dist/generated/artifacts/constants.js +0 -1
  3. package/dist/generated/normalized/Genesis.json +2 -37
  4. package/dist/generated/resources/Genesis.json +2 -49
  5. package/dist/generated/schemas/Genesis.json +2 -32
  6. package/dist/generated/schemas/zod/Goal.d.ts +2 -0
  7. package/dist/generated/schemas/zod/Goal.js +5 -0
  8. package/dist/generated/schemas/zod/Job.d.ts +6 -0
  9. package/dist/generated/schemas/zod/Job.js +25 -0
  10. package/dist/generated/schemas/zod/RawStrategy.d.ts +12 -0
  11. package/dist/generated/schemas/zod/RawStrategy.js +66 -0
  12. package/dist/generated/schemas/zod/ResourceType.d.ts +2 -0
  13. package/dist/generated/schemas/zod/ResourceType.js +18 -0
  14. package/dist/generated/schemas/zod/RunnableStrategy.d.ts +12 -0
  15. package/dist/generated/schemas/zod/RunnableStrategy.js +74 -0
  16. package/dist/generated/schemas/zod/StrategyRun.d.ts +12 -0
  17. package/dist/generated/schemas/zod/StrategyRun.js +88 -0
  18. package/dist/generated/schemas/zod/index.d.ts +6 -0
  19. package/dist/generated/schemas/zod/index.js +7 -0
  20. package/dist/generated/types/types.d.ts +0 -14
  21. package/dist/index.d.ts +8 -1
  22. package/dist/index.js +8 -0
  23. package/dist/scripts/_lib/config.d.ts +3 -0
  24. package/dist/scripts/_lib/config.js +9 -0
  25. package/dist/scripts/_lib/utils/jsonSchemaToZod.d.ts +18 -0
  26. package/dist/scripts/_lib/utils/jsonSchemaToZod.js +607 -0
  27. package/dist/scripts/generateStandaloneZodSchema.d.ts +1 -0
  28. package/dist/scripts/generateStandaloneZodSchema.js +116 -0
  29. package/package.json +6 -2
  30. package/src/Genesis.json +2 -38
  31. package/src/generated/artifacts/constants.ts +0 -1
  32. package/src/generated/artifacts/dependencyMap.json +1 -4
  33. package/src/generated/normalized/Genesis.json +2 -37
  34. package/src/generated/resources/Genesis.json +2 -49
  35. package/src/generated/schemas/Genesis.json +2 -32
  36. package/src/generated/schemas/zod/Goal.ts +8 -0
  37. package/src/generated/schemas/zod/Job.ts +26 -0
  38. package/src/generated/schemas/zod/RawStrategy.ts +64 -0
  39. package/src/generated/schemas/zod/ResourceType.ts +13 -0
  40. package/src/generated/schemas/zod/RunnableStrategy.ts +69 -0
  41. package/src/generated/schemas/zod/StrategyRun.ts +83 -0
  42. package/src/generated/schemas/zod/index.ts +7 -0
  43. package/src/generated/types/types.d.ts +0 -14
  44. package/src/index.ts +10 -1
  45. package/src/scripts/_lib/config.ts +12 -0
  46. package/src/scripts/_lib/utils/jsonSchemaToZod.ts +646 -0
  47. package/src/scripts/generateStandaloneZodSchema.ts +139 -0
@@ -0,0 +1,83 @@
1
+ // Auto-generated from standalone schema 'StrategyRun'. Do not edit.
2
+ import { z } from 'zod/v4';
3
+
4
+
5
+ export const StrategyRunZodGenerationWarnings = [
6
+ {
7
+ "path": "$defs.StepArray.uniqueItems",
8
+ "message": "uniqueItems not enforced by generated Zod."
9
+ },
10
+ {
11
+ "path": "$defs.BranchStep.allOfMerged.properties.cases.uniqueItems",
12
+ "message": "uniqueItems not enforced by generated Zod."
13
+ },
14
+ {
15
+ "path": "$defs.Path.format",
16
+ "message": "Ignoring format 'uri-reference' (not enforced by generated Zod)."
17
+ }
18
+ ] as const;
19
+
20
+ const BranchStepSchema: z.ZodTypeAny = z.lazy(() => z.object({ "identity": BranchStepIdentitySchema, "stepKind": z.intersection(z.literal("branch"), StepKindSchema), "cases": z.array(CaseSchema).min(1) }));
21
+ const BranchStepIdentitySchema: z.ZodTypeAny = z.lazy(() => z.string().regex(new RegExp("^BRANCH_STEP-.+$")));
22
+ const CaseSchema: z.ZodTypeAny = z.lazy(() => z.object({ "when": JobStepSchema, "what": JobStepSchema }).strict());
23
+ const CreationContextSchema: z.ZodTypeAny = z.lazy(() => z.object({ "resourceRoleHandle": ResourceRoleIdentitySchema, "jobStepHandle": JobStepIdentitySchema }));
24
+ const CreationContextFacetSchema: z.ZodTypeAny = z.lazy(() => z.object({ "creationContext": CreationContextSchema }));
25
+ const ForStepSchema: z.ZodTypeAny = z.lazy(() => z.object({ "identity": ForStepIdentitySchema, "stepKind": z.intersection(z.literal("for"), StepKindSchema), "case": CaseSchema }));
26
+ const ForStepIdentitySchema: z.ZodTypeAny = z.lazy(() => z.string().regex(new RegExp("^FOR_STEP-.+$")));
27
+ const GraphEndRunEventSchema: z.ZodTypeAny = z.lazy(() => z.object({ "runEventKind": z.intersection(RunEventKindSchema, z.literal("graph_end")), "runnableStrategyHandle": RunnableStrategyIdentitySchema, "strategyThreadHandle": StrategyThreadIdentitySchema, "createdAt": TimestampSchema, "nodeName": z.string(), "eventSeq": z.number().int(), "counters": RunEventCountersSchema.optional(), "stepMetadata": RunEventStepMetadataSchema.optional(), "updates": RunEventUpdatesSchema.optional() }));
28
+ const GraphStartRunEventSchema: z.ZodTypeAny = z.lazy(() => z.object({ "runEventKind": z.intersection(RunEventKindSchema, z.literal("graph_start")), "runnableStrategyHandle": RunnableStrategyIdentitySchema, "strategyThreadHandle": StrategyThreadIdentitySchema, "createdAt": TimestampSchema, "nodeName": z.string(), "eventSeq": z.number().int(), "counters": RunEventCountersSchema.optional(), "stepMetadata": RunEventStepMetadataSchema.optional(), "updates": RunEventUpdatesSchema.optional(), "runnableStrategySeed": RunnableStrategySchema }));
29
+ const InterruptRunEventSchema: z.ZodTypeAny = z.lazy(() => z.object({ "runEventKind": z.intersection(RunEventKindSchema, z.literal("interrupt")), "runnableStrategyHandle": RunnableStrategyIdentitySchema, "strategyThreadHandle": StrategyThreadIdentitySchema, "createdAt": TimestampSchema, "nodeName": z.string(), "eventSeq": z.number().int(), "counters": RunEventCountersSchema.optional(), "stepMetadata": RunEventStepMetadataSchema.optional(), "updates": RunEventUpdatesSchema.optional() }));
30
+ const JobIdentitySchema: z.ZodTypeAny = z.lazy(() => z.string().regex(new RegExp("^JOB-.+$")));
31
+ const JobStepSchema: z.ZodTypeAny = z.lazy(() => z.object({ "identity": JobStepIdentitySchema, "stepKind": z.intersection(z.literal("job"), StepKindSchema), "jobHandle": JobIdentitySchema, "roleBindings": RoleBindingsSchema }));
32
+ const JobStepIdentitySchema: z.ZodTypeAny = z.lazy(() => z.string().regex(new RegExp("^JOB_STEP-.+$")));
33
+ const JobStepSocketSchema: z.ZodTypeAny = z.lazy(() => z.record(z.string(), z.union([ResourcePotentialSchema, ResourceSchema])).superRefine((obj, ctx) => { for (const k of Object.keys(obj)) { if (!new RegExp("^ROLE-.+$").test(k)) ctx.addIssue({ code: 'custom', message: 'Invalid key: ' + k }); } }));
34
+ const NucleusFacetSchema: z.ZodTypeAny = z.lazy(() => z.object({ "nucleus": z.any() }));
35
+ const PathSchema: z.ZodTypeAny = z.lazy(() => z.string());
36
+ const PathFacetSchema: z.ZodTypeAny = z.lazy(() => z.object({ "path": PathSchema }));
37
+ const ResourceSchema: z.ZodTypeAny = z.lazy(() => z.object({ "version": z.literal(1), "resourceShellKind": z.intersection(z.intersection(z.literal("materialized"), ResourceShellKindSchema), ResourceShellKindSchema), "identity": ResourceIdentitySchema, "resourceTypeHandle": ResourceTypeIdentitySchema, "creationContext": CreationContextSchema, "timestamp": TimestampSchema, "path": PathSchema, "nucleus": z.any() }).strict());
38
+ const ResourceIdentitySchema: z.ZodTypeAny = z.lazy(() => z.string().regex(new RegExp("^RESOURCE-.+$")));
39
+ const ResourceInputPotentialSchema: z.ZodTypeAny = z.lazy(() => ShellInputPotentialSchema);
40
+ const ResourceMissingSchema: z.ZodTypeAny = z.lazy(() => ShellMissingSchema);
41
+ const ResourceOutputPotentialSchema: z.ZodTypeAny = z.lazy(() => ShellOutputPotentialSchema);
42
+ const ResourcePotentialSchema: z.ZodTypeAny = z.lazy(() => z.union([ResourceMissingSchema, ResourceInputPotentialSchema, ResourceOutputPotentialSchema]));
43
+ const ResourceRoleIdentitySchema: z.ZodTypeAny = z.lazy(() => z.string().regex(new RegExp("^ROLE-.+$")));
44
+ const ResourceShellBaseSchema: z.ZodTypeAny = z.lazy(() => z.object({ "identity": ResourceIdentitySchema, "resourceTypeHandle": ResourceTypeIdentitySchema, "resourceShellKind": ResourceShellKindSchema }));
45
+ const ResourceShellKindSchema: z.ZodTypeAny = z.lazy(() => z.union([z.literal("missing"), z.literal("inputPotential"), z.literal("outputPotential"), z.literal("materialized")]));
46
+ const ResourceShellKindFacetSchema: z.ZodTypeAny = z.lazy(() => z.object({ "resourceShellKind": ResourceShellKindSchema }));
47
+ const ResourceTypeIdentitySchema: z.ZodTypeAny = z.lazy(() => z.string().regex(new RegExp("^TYPE-.+$")));
48
+ const RoleBindingArraySchema: z.ZodTypeAny = z.lazy(() => z.array(ResourceRoleIdentitySchema));
49
+ const RoleBindingsSchema: z.ZodTypeAny = z.lazy(() => z.object({ "inputBindings": RoleBindingArraySchema, "outputBindings": RoleBindingArraySchema }));
50
+ const RoleBindingsFacetSchema: z.ZodTypeAny = z.lazy(() => z.object({ "roleBindings": RoleBindingsSchema }));
51
+ const RunEventSchema: z.ZodTypeAny = z.lazy(() => z.union([GraphStartRunEventSchema, TickRunEventSchema, InterruptRunEventSchema, GraphEndRunEventSchema]));
52
+ const RunEventBaseSchema: z.ZodTypeAny = z.lazy(() => z.object({ "runEventKind": RunEventKindSchema, "runnableStrategyHandle": RunnableStrategyIdentitySchema, "strategyThreadHandle": StrategyThreadIdentitySchema, "createdAt": TimestampSchema, "nodeName": z.string(), "eventSeq": z.number().int(), "counters": RunEventCountersSchema.optional(), "stepMetadata": RunEventStepMetadataSchema.optional(), "updates": RunEventUpdatesSchema.optional() }));
53
+ const RunEventCountersSchema: z.ZodTypeAny = z.lazy(() => z.object({ "stepCounterAfter": z.number().int().optional(), "iterationCounterAfter": z.number().int().optional() }));
54
+ const RunEventKindSchema: z.ZodTypeAny = z.lazy(() => z.union([z.literal("graph_start"), z.literal("tick"), z.literal("interrupt"), z.literal("graph_end")]));
55
+ const RunEventStepMetadataSchema: z.ZodTypeAny = z.lazy(() => z.object({ "stepHandle": StepIdentitySchema, "stepKind": StepKindSchema, "threadStepIndex": z.number().int() }));
56
+ const RunEventUpdatesSchema: z.ZodTypeAny = z.lazy(() => z.object({ "stepsMutation": z.object({ "insertAt": z.number().int(), "inserted": StepArraySchema }).optional(), "interruptData": z.union([z.object({ }), z.null()]).optional(), "strategyStateUpdate": StrategyStateSchema }));
57
+ const RunnableStrategySchema: z.ZodTypeAny = z.lazy(() => z.object({ "identity": RunnableStrategyIdentitySchema, "runnableStrategyContext": RunnableStrategyContextSchema, "strategyThreadDict": StrategyThreadDictSchema, "strategyState": StrategyStateSchema }).strict());
58
+ const RunnableStrategyContextSchema: z.ZodTypeAny = z.lazy(() => z.object({ "status": RunnableStrategyStatusSchema, "startedAt": TimestampSchema.optional(), "completedAt": TimestampSchema.optional() }).strict());
59
+ const RunnableStrategyIdentitySchema: z.ZodTypeAny = z.lazy(() => z.string().regex(new RegExp("^RUNNABLE_STRATEGY-.+$")));
60
+ const RunnableStrategyStatusSchema: z.ZodTypeAny = z.lazy(() => z.union([z.literal("pending"), z.literal("running"), z.literal("completed"), z.literal("failed"), z.literal("cancelled")]));
61
+ const ShellInputPotentialSchema: z.ZodTypeAny = z.lazy(() => z.object({ "resourceShellKind": z.intersection(z.intersection(z.literal("inputPotential"), ResourceShellKindSchema), ResourceShellKindSchema), "identity": ResourceIdentitySchema, "resourceTypeHandle": ResourceTypeIdentitySchema, "creationContext": CreationContextSchema }).strict());
62
+ const ShellMaterializedBaseSchema: z.ZodTypeAny = z.lazy(() => z.object({ "version": z.literal(1), "resourceShellKind": z.intersection(z.intersection(z.literal("materialized"), ResourceShellKindSchema), ResourceShellKindSchema), "identity": ResourceIdentitySchema, "resourceTypeHandle": ResourceTypeIdentitySchema, "creationContext": CreationContextSchema, "timestamp": TimestampSchema, "path": PathSchema }));
63
+ const ShellMissingSchema: z.ZodTypeAny = z.lazy(() => z.object({ "resourceShellKind": z.intersection(z.intersection(z.literal("missing"), ResourceShellKindSchema), ResourceShellKindSchema), "identity": ResourceIdentitySchema, "resourceTypeHandle": ResourceTypeIdentitySchema }).strict());
64
+ const ShellOutputPotentialSchema: z.ZodTypeAny = z.lazy(() => z.object({ "resourceShellKind": z.intersection(z.intersection(z.literal("outputPotential"), ResourceShellKindSchema), ResourceShellKindSchema), "identity": ResourceIdentitySchema, "resourceTypeHandle": ResourceTypeIdentitySchema, "creationContext": CreationContextSchema }).strict());
65
+ const StepSchema: z.ZodTypeAny = z.lazy(() => z.union([JobStepSchema, BranchStepSchema, WhileStepSchema, ForStepSchema]));
66
+ const StepArraySchema: z.ZodTypeAny = z.lazy(() => z.array(StepSchema));
67
+ const StepIdentitySchema: z.ZodTypeAny = z.lazy(() => z.union([JobStepIdentitySchema, BranchStepIdentitySchema, WhileStepIdentitySchema, ForStepIdentitySchema]));
68
+ const StepKindSchema: z.ZodTypeAny = z.lazy(() => z.union([z.literal("job"), z.literal("branch"), z.literal("while"), z.literal("for")]));
69
+ const StepKindFacetSchema: z.ZodTypeAny = z.lazy(() => z.object({ "stepKind": StepKindSchema }));
70
+ const StrategyRunIdentitySchema: z.ZodTypeAny = z.lazy(() => z.string().regex(new RegExp("^STRATEGY_RUN-.+$")));
71
+ const StrategyStateSchema: z.ZodTypeAny = z.lazy(() => z.record(z.string(), JobStepSocketSchema).superRefine((obj, ctx) => { for (const k of Object.keys(obj)) { if (!new RegExp("^JOB_STEP-.+$").test(k)) ctx.addIssue({ code: 'custom', message: 'Invalid key: ' + k }); } }));
72
+ const StrategyStateDeltaSchema: z.ZodTypeAny = z.lazy(() => z.object({ "strategyStateUpdate": StrategyStateSchema }));
73
+ const StrategyStateFacetSchema: z.ZodTypeAny = z.lazy(() => z.object({ "strategyState": StrategyStateSchema }));
74
+ const StrategyThreadDictSchema: z.ZodTypeAny = z.lazy(() => z.record(z.string(), StepArraySchema).superRefine((obj, ctx) => { for (const k of Object.keys(obj)) { if (!new RegExp("^STRATEGY_THREAD-.+$").test(k)) ctx.addIssue({ code: 'custom', message: 'Invalid key: ' + k }); } }));
75
+ const StrategyThreadDictFacetSchema: z.ZodTypeAny = z.lazy(() => z.object({ "strategyThreadDict": StrategyThreadDictSchema }));
76
+ const StrategyThreadIdentitySchema: z.ZodTypeAny = z.lazy(() => z.string().regex(new RegExp("^STRATEGY_THREAD-.+$")));
77
+ const TickRunEventSchema: z.ZodTypeAny = z.lazy(() => z.object({ "runEventKind": z.intersection(RunEventKindSchema, z.literal("tick")), "runnableStrategyHandle": RunnableStrategyIdentitySchema, "strategyThreadHandle": StrategyThreadIdentitySchema, "createdAt": TimestampSchema, "nodeName": z.string(), "eventSeq": z.number().int(), "counters": RunEventCountersSchema.optional(), "stepMetadata": RunEventStepMetadataSchema.optional(), "updates": RunEventUpdatesSchema.optional() }));
78
+ const TimestampSchema: z.ZodTypeAny = z.lazy(() => z.string().datetime());
79
+ const TimestampFacetSchema: z.ZodTypeAny = z.lazy(() => z.object({ "timestamp": TimestampSchema }));
80
+ const WhileStepSchema: z.ZodTypeAny = z.lazy(() => z.object({ "identity": WhileStepIdentitySchema, "stepKind": z.intersection(z.literal("while"), StepKindSchema), "case": CaseSchema }));
81
+ const WhileStepIdentitySchema: z.ZodTypeAny = z.lazy(() => z.string().regex(new RegExp("^WHILE_STEP-.+$")));
82
+
83
+ export const StrategyRunSchema: z.ZodTypeAny = z.lazy(() => z.object({ "identity": StrategyRunIdentitySchema, "runnableStrategyHandle": RunnableStrategyIdentitySchema, "recordedAt": TimestampSchema, "runEvents": z.array(RunEventSchema) }).strict());
@@ -0,0 +1,7 @@
1
+ // Auto-generated barrel file. Do not edit.
2
+ export { GoalSchema } from './Goal.js';
3
+ export { JobSchema } from './Job.js';
4
+ export { RawStrategySchema } from './RawStrategy.js';
5
+ export { ResourceTypeSchema } from './ResourceType.js';
6
+ export { RunnableStrategySchema } from './RunnableStrategy.js';
7
+ export { StrategyRunSchema } from './StrategyRun.js';
@@ -299,19 +299,6 @@ export type ResourceOutputPotentialJson =
299
299
  */
300
300
  export type ResourcePotentialJson =
301
301
  ResourceMissingJson | ResourceInputPotentialJson | ResourceOutputPotentialJson;
302
- /**
303
- * This interface was referenced by `Genesis`'s JSON-Schema
304
- * via the `definition` "JsonData".
305
- */
306
- export type JsonDataJson =
307
- | null
308
- | boolean
309
- | number
310
- | string
311
- | JsonDataJson[]
312
- | {
313
- [k: string]: JsonDataJson;
314
- };
315
302
  /**
316
303
  * This interface was referenced by `Genesis`'s JSON-Schema
317
304
  * via the `definition` "Resource".
@@ -576,7 +563,6 @@ export interface PathFacetJson {
576
563
  * via the `definition` "Nucleus".
577
564
  */
578
565
  export interface NucleusJson {
579
- [k: string]: JsonDataJson;
580
566
  }
581
567
  /**
582
568
  * This interface was referenced by `Genesis`'s JSON-Schema
package/src/index.ts CHANGED
@@ -8,6 +8,15 @@ export { default as ResourceGenesis } from './generated/resources/Genesis.js';
8
8
  export { default as CONSTANTS } from './generated/artifacts/constants.js';
9
9
  export { default as MAPPINGS } from './generated/artifacts/mappings.js';
10
10
 
11
+ // Re-export generated Zod validators
12
+ export { JobSchema as ZodJobSchema } from './generated/schemas/zod/Job.js';
13
+ export { ResourceTypeSchema as ZodResourceTypeSchema } from './generated/schemas/zod/ResourceType.js';
14
+ export { RawStrategySchema as ZodRawStrategySchema } from './generated/schemas/zod/RawStrategy.js';
15
+ export { RunnableStrategySchema as ZodRunnableStrategySchema } from './generated/schemas/zod/RunnableStrategy.js';
16
+ export { StrategyRunSchema as ZodStrategyRunSchema } from './generated/schemas/zod/StrategyRun.js';
17
+ export { GoalSchema as ZodGoalSchema } from './generated/schemas/zod/Goal.js';
18
+ export * as ZodSchemas from './generated/schemas/zod/index.js';
19
+
11
20
 
12
21
  export type {
13
22
  Resource_Genesis as Resource_GenesisJson
@@ -54,6 +63,7 @@ export type {
54
63
  ResourceMissingJson,
55
64
  ResourceInputPotentialJson,
56
65
  ResourceOutputPotentialJson,
66
+ ResourcePotentialJson,
57
67
  ShellMaterializedBaseJson,
58
68
  ResourceJson,
59
69
  StrategyStateJson,
@@ -65,7 +75,6 @@ export type {
65
75
  RunnableStrategyUpdateJson,
66
76
  JobIdentityJson,
67
77
  JobJson,
68
- JsonDataJson,
69
78
  StrategyThreadIdentityJson,
70
79
  StrategyThreadDictJson,
71
80
  JobStepSocketJson,
@@ -24,6 +24,7 @@ export class SchemaConfig {
24
24
  private readonly sourceFile: string;
25
25
  private readonly normalizedDir: string;
26
26
  private readonly schemasDir: string;
27
+ private readonly zodSchemasDir: string;
27
28
  private readonly artifactsDir: string;
28
29
  private readonly resourcesDir: string;
29
30
  private readonly typesSrcDir: string;
@@ -40,6 +41,7 @@ export class SchemaConfig {
40
41
  this.sourceFile = getEnv('TP_SCHEMA_SOURCE_FILE', 'Genesis.json');
41
42
  this.normalizedDir = getEnv('TP_SCHEMA_NORMALIZED_DIR', 'src/generated/normalized');
42
43
  this.schemasDir = getEnv('TP_SCHEMA_SCHEMAS_DIR', 'src/generated/schemas');
44
+ this.zodSchemasDir = getEnv('TP_SCHEMA_ZOD_SCHEMAS_DIR', 'src/generated/schemas/zod');
43
45
  this.artifactsDir = getEnv('TP_SCHEMA_ARTIFACTS_DIR', 'src/generated/artifacts');
44
46
  this.resourcesDir = getEnv('TP_SCHEMA_RESOURCES_DIR', 'src/generated/resources');
45
47
  this.typesSrcDir = getEnv('TP_SCHEMA_TYPES_SRC_DIR', 'src/generated/types');
@@ -90,6 +92,16 @@ export class SchemaConfig {
90
92
  : path.join(this.root, this.schemasDir);
91
93
  }
92
94
 
95
+ getZodSchemasDir(): string {
96
+ return path.isAbsolute(this.zodSchemasDir)
97
+ ? this.zodSchemasDir
98
+ : path.join(this.root, this.zodSchemasDir);
99
+ }
100
+
101
+ getZodSchemaPath(filename: string): string {
102
+ return path.join(this.getZodSchemasDir(), filename);
103
+ }
104
+
93
105
  getSchemaPath(filename: string): string {
94
106
  return path.join(this.getSchemasDir(), filename);
95
107
  }