@toolproof-core/genesis 1.0.48 → 1.0.50

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 (93) hide show
  1. package/dist/src/implementations/tools.d.ts +100 -0
  2. package/dist/src/implementations/tools.js +135 -0
  3. package/dist/src/index.d.ts +9 -8
  4. package/dist/src/index.js +4 -3
  5. package/dist/src/utils/resourceTypes.d.ts +2 -1
  6. package/dist/src/utils/resourceTypes.js +22 -6
  7. package/dist/src/utils/schemaRefNormalization.js +3 -3
  8. package/dist/src/utils/standaloneTypes.js +2 -2
  9. package/dist/src/utils/timestampedResources.d.ts +16 -0
  10. package/dist/src/utils/timestampedResources.js +17 -0
  11. package/dist/src/utils/typeGenerationPostProcess.js +2 -2
  12. package/dist/src/utils/zodCodegen.js +3 -3
  13. package/generated-src/declarations/booleans.json +4 -0
  14. package/generated-src/declarations/booleans.ts +2 -0
  15. package/generated-src/declarations/naturals.json +13 -0
  16. package/generated-src/declarations/naturals.ts +2 -0
  17. package/generated-src/{resourceTypes → declarations}/resourceTypes.json +176 -39
  18. package/generated-src/declarations/resourceTypes.ts +2 -0
  19. package/generated-src/declarations/tools.json +705 -0
  20. package/generated-src/declarations/tools.ts +2 -0
  21. package/generated-src/implementations/tools.ts +214 -0
  22. package/generated-src/{derived → lookups}/constants.ts +4 -5
  23. package/generated-src/metadata/Core.json +51 -114
  24. package/generated-src/metadata/dependencyMap.json +16 -2
  25. package/generated-src/metadata/terminals.json +3 -4
  26. package/generated-src/schemas/schemas.json +198 -29
  27. package/generated-src/schemas/standalone/Resource.json +4 -8
  28. package/generated-src/schemas/standalone/ResourceType.json +21 -5
  29. package/generated-src/schemas/standalone/Strategy.json +4 -8
  30. package/generated-src/schemas/standalone/StrategyTrace.json +4 -8
  31. package/generated-src/schemas/standalone/Suite.json +646 -0
  32. package/generated-src/schemas/standalone/Suite.ts +2 -0
  33. package/generated-src/schemas/standalone/Tool.json +48 -23
  34. package/generated-src/schemas/zod/Resource.ts +2 -2
  35. package/generated-src/schemas/zod/ResourceType.ts +1 -1
  36. package/generated-src/schemas/zod/Strategy.ts +3 -3
  37. package/generated-src/schemas/zod/StrategyTrace.ts +3 -3
  38. package/generated-src/schemas/zod/Suite.ts +44 -0
  39. package/generated-src/schemas/zod/Tool.ts +7 -2
  40. package/generated-src/schemas/zod/index.ts +1 -0
  41. package/{src/genesis/resources → generated-src/timestampedResources}/booleans.json +19 -23
  42. package/generated-src/timestampedResources/booleans.ts +2 -0
  43. package/{src/genesis/resources → generated-src/timestampedResources}/naturals.json +100 -111
  44. package/generated-src/timestampedResources/naturals.ts +2 -0
  45. package/generated-src/{resources → timestampedResources}/resourceTypes.json +202 -66
  46. package/generated-src/timestampedResources/resourceTypes.ts +2 -0
  47. package/{src/genesis/resources → generated-src/timestampedResources}/tools.json +824 -839
  48. package/generated-src/timestampedResources/tools.ts +2 -0
  49. package/generated-src/types/standalone/BooleanResource.d.ts +2 -2
  50. package/generated-src/types/standalone/ErrorResource.d.ts +2 -2
  51. package/generated-src/types/standalone/GoalResource.d.ts +2 -2
  52. package/generated-src/types/standalone/NaturalResource.d.ts +2 -2
  53. package/generated-src/types/standalone/ResourceResource.d.ts +2 -2
  54. package/generated-src/types/standalone/ResourceTypeResource.d.ts +2 -2
  55. package/generated-src/types/standalone/StrategyResource.d.ts +2 -2
  56. package/generated-src/types/standalone/StrategyTraceResource.d.ts +2 -2
  57. package/generated-src/types/standalone/SuiteResource.d.ts +3 -0
  58. package/generated-src/types/standalone/SuiteResource.js +1 -0
  59. package/generated-src/types/standalone/ToolResource.d.ts +2 -2
  60. package/generated-src/types/types.d.ts +57 -14
  61. package/package.json +18 -13
  62. package/src/declarations/booleans.json +4 -0
  63. package/src/declarations/naturals.json +13 -0
  64. package/src/{genesis → declarations/resourceTypes}/resourceTypeShells.json +52 -46
  65. package/src/{genesis → declarations/resourceTypes}/schemas.json +1838 -1669
  66. package/src/declarations/tools.json +705 -0
  67. package/src/implementations/tools.ts +214 -0
  68. package/src/index.ts +131 -27
  69. package/src/utils/constantsAndMappings.ts +194 -194
  70. package/src/utils/coreProjection.ts +52 -52
  71. package/src/utils/resourceTypes.ts +70 -38
  72. package/src/utils/schemaDependencies.ts +114 -114
  73. package/src/utils/schemaObjectNormalization.ts +70 -70
  74. package/src/utils/schemaRefNormalization.ts +82 -82
  75. package/src/utils/schemaShims.ts +16 -16
  76. package/src/utils/standaloneSchemas.ts +113 -113
  77. package/src/utils/standaloneTypes.ts +27 -27
  78. package/src/utils/standaloneZodSchemas.ts +71 -71
  79. package/src/utils/timestampedResources.ts +42 -0
  80. package/src/utils/typeGeneration.ts +30 -30
  81. package/src/utils/typeGenerationPostProcess.ts +245 -245
  82. package/src/utils/typeGenerationPreflight.ts +118 -118
  83. package/src/utils/zodCodegen.ts +548 -548
  84. package/toolproof.json +19 -0
  85. package/dist/src/genesis/resources/implementations/foo.d.ts +0 -1
  86. package/dist/src/genesis/resources/implementations/foo.js +0 -184
  87. package/dist/src/utils/resources.d.ts +0 -5
  88. package/dist/src/utils/resources.js +0 -17
  89. package/generated-src/resourceTypes/resourceTypes.ts +0 -2
  90. package/generated-src/resources/resourceTypes.ts +0 -2
  91. package/src/genesis/resources/implementations/foo.ts +0 -183
  92. package/src/utils/resources.ts +0 -26
  93. /package/generated-src/{derived → lookups}/mappings.ts +0 -0
@@ -0,0 +1,100 @@
1
+ import type { Boolean, Natural, ResourceType, Tool } from '../../generated-src/types/types.js';
2
+ type GenericAssignmentByRoleName<GenericRoleName extends string> = Record<GenericRoleName, ResourceType>;
3
+ type InstantiationToolHandleBySpecializationKey = Record<string, Tool>;
4
+ type TemplateInputs<GenericRoleName extends string> = {
5
+ GenericAssignmentByRoleName: GenericAssignmentByRoleName<GenericRoleName>;
6
+ InstantiationToolHandleBySpecializationKey: InstantiationToolHandleBySpecializationKey;
7
+ };
8
+ type TemplateOutputs = {
9
+ InstantiationTool: Tool;
10
+ };
11
+ type OperandTemplateInputs = TemplateInputs<'OperandType'>;
12
+ export declare function createSpecializationKey(assignments: Record<string, ResourceType>): string;
13
+ export declare function Identity(inputs: OperandTemplateInputs): TemplateOutputs;
14
+ export declare function Add(inputs: OperandTemplateInputs): TemplateOutputs;
15
+ export declare function Subtract(inputs: OperandTemplateInputs): TemplateOutputs;
16
+ export declare function Multiply(inputs: OperandTemplateInputs): TemplateOutputs;
17
+ export declare function Divide(inputs: OperandTemplateInputs): TemplateOutputs;
18
+ export declare function Double(inputs: OperandTemplateInputs): TemplateOutputs;
19
+ export declare function LessThan(inputs: OperandTemplateInputs): TemplateOutputs;
20
+ export declare function BooleanIdentity(inputs: {
21
+ In: Boolean;
22
+ }): {
23
+ Out: Boolean;
24
+ };
25
+ export declare function NaturalIdentity(inputs: {
26
+ In: Natural;
27
+ }): {
28
+ Out: Natural;
29
+ };
30
+ export declare function NaturalLessThan(inputs: {
31
+ LessThanSource: Natural;
32
+ LessThanTarget: Natural;
33
+ }): {
34
+ LessThanDecision: Boolean;
35
+ };
36
+ export declare function NaturalAdd(inputs: {
37
+ AddendOne: Natural;
38
+ AddendTwo: Natural;
39
+ }): {
40
+ Sum: Natural;
41
+ };
42
+ export declare function NaturalSubtract(inputs: {
43
+ Minuend: Natural;
44
+ Subtrahend: Natural;
45
+ }): {
46
+ Difference: Natural;
47
+ };
48
+ export declare function NaturalMultiply(inputs: {
49
+ Multiplicand: Natural;
50
+ Multiplier: Natural;
51
+ }): {
52
+ Product: Natural;
53
+ };
54
+ export declare function NaturalDivide(inputs: {
55
+ Dividend: Natural;
56
+ Divisor: Natural;
57
+ }): {
58
+ Quotient: Natural;
59
+ Remainder: Natural;
60
+ };
61
+ export declare function NaturalDouble(inputs: {
62
+ N: Natural;
63
+ }): {
64
+ Doubled: Natural;
65
+ };
66
+ export declare const TOOL_IMPLEMENTATION_BY_NAME: {
67
+ readonly Identity: typeof Identity;
68
+ readonly Add: typeof Add;
69
+ readonly Subtract: typeof Subtract;
70
+ readonly Multiply: typeof Multiply;
71
+ readonly Divide: typeof Divide;
72
+ readonly Double: typeof Double;
73
+ readonly LessThan: typeof LessThan;
74
+ readonly BooleanIdentity: typeof BooleanIdentity;
75
+ readonly NaturalIdentity: typeof NaturalIdentity;
76
+ readonly NaturalLessThan: typeof NaturalLessThan;
77
+ readonly NaturalAdd: typeof NaturalAdd;
78
+ readonly NaturalSubtract: typeof NaturalSubtract;
79
+ readonly NaturalMultiply: typeof NaturalMultiply;
80
+ readonly NaturalDivide: typeof NaturalDivide;
81
+ readonly NaturalDouble: typeof NaturalDouble;
82
+ };
83
+ export declare const TOOL_IMPLEMENTATION_BY_HANDLE: {
84
+ readonly 'TOOL-Identity': typeof Identity;
85
+ readonly 'TOOL-Add': typeof Add;
86
+ readonly 'TOOL-Subtract': typeof Subtract;
87
+ readonly 'TOOL-Multiply': typeof Multiply;
88
+ readonly 'TOOL-Divide': typeof Divide;
89
+ readonly 'TOOL-Double': typeof Double;
90
+ readonly 'TOOL-LessThan': typeof LessThan;
91
+ readonly 'TOOL-BooleanIdentity': typeof BooleanIdentity;
92
+ readonly 'TOOL-NaturalIdentity': typeof NaturalIdentity;
93
+ readonly 'TOOL-NaturalLessThan': typeof NaturalLessThan;
94
+ readonly 'TOOL-NaturalAdd': typeof NaturalAdd;
95
+ readonly 'TOOL-NaturalSubtract': typeof NaturalSubtract;
96
+ readonly 'TOOL-NaturalMultiply': typeof NaturalMultiply;
97
+ readonly 'TOOL-NaturalDivide': typeof NaturalDivide;
98
+ readonly 'TOOL-NaturalDouble': typeof NaturalDouble;
99
+ };
100
+ export {};
@@ -0,0 +1,135 @@
1
+ const OPERAND_TYPE_ROLE_NAMES = ['OperandType'];
2
+ function assertExactKeys(actualKeys, expectedKeys, label) {
3
+ const sortedActualKeys = [...actualKeys].sort();
4
+ const sortedExpectedKeys = [...expectedKeys].sort();
5
+ if (sortedActualKeys.length !== sortedExpectedKeys.length) {
6
+ throw new Error(`${label} must contain exactly [${sortedExpectedKeys.join(', ')}], got [${sortedActualKeys.join(', ')}]`);
7
+ }
8
+ for (let index = 0; index < sortedExpectedKeys.length; index += 1) {
9
+ if (sortedActualKeys[index] !== sortedExpectedKeys[index]) {
10
+ throw new Error(`${label} must contain exactly [${sortedExpectedKeys.join(', ')}], got [${sortedActualKeys.join(', ')}]`);
11
+ }
12
+ }
13
+ }
14
+ function asNatural(value, label) {
15
+ if (!Number.isInteger(value) || value < 0) {
16
+ throw new Error(`${label} must be a non-negative integer, got ${value}`);
17
+ }
18
+ return value;
19
+ }
20
+ export function createSpecializationKey(assignments) {
21
+ return JSON.stringify(Object.entries(assignments)
22
+ .sort(([leftRoleName], [rightRoleName]) => leftRoleName.localeCompare(rightRoleName))
23
+ .map(([roleName, resourceType]) => [roleName, resourceType.handle]));
24
+ }
25
+ function resolveTemplateInstantiation(inputs, expectedGenericRoleNames) {
26
+ const { GenericAssignmentByRoleName, InstantiationToolHandleBySpecializationKey } = inputs;
27
+ assertExactKeys(Object.keys(GenericAssignmentByRoleName), expectedGenericRoleNames, 'GenericAssignmentByRoleName');
28
+ const specializationKey = createSpecializationKey(GenericAssignmentByRoleName);
29
+ const instantiationTool = InstantiationToolHandleBySpecializationKey[specializationKey];
30
+ if (!instantiationTool) {
31
+ throw new Error(`No instantiation tool registered for specializationKey ${specializationKey}`);
32
+ }
33
+ return {
34
+ InstantiationTool: instantiationTool,
35
+ };
36
+ }
37
+ export function Identity(inputs) {
38
+ return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
39
+ }
40
+ export function Add(inputs) {
41
+ return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
42
+ }
43
+ export function Subtract(inputs) {
44
+ return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
45
+ }
46
+ export function Multiply(inputs) {
47
+ return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
48
+ }
49
+ export function Divide(inputs) {
50
+ return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
51
+ }
52
+ export function Double(inputs) {
53
+ return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
54
+ }
55
+ export function LessThan(inputs) {
56
+ return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
57
+ }
58
+ export function BooleanIdentity(inputs) {
59
+ return {
60
+ Out: inputs.In,
61
+ };
62
+ }
63
+ export function NaturalIdentity(inputs) {
64
+ return {
65
+ Out: inputs.In,
66
+ };
67
+ }
68
+ export function NaturalLessThan(inputs) {
69
+ return {
70
+ LessThanDecision: inputs.LessThanSource < inputs.LessThanTarget,
71
+ };
72
+ }
73
+ export function NaturalAdd(inputs) {
74
+ return {
75
+ Sum: asNatural(inputs.AddendOne + inputs.AddendTwo, 'Sum'),
76
+ };
77
+ }
78
+ export function NaturalSubtract(inputs) {
79
+ return {
80
+ Difference: asNatural(inputs.Minuend - inputs.Subtrahend, 'Difference'),
81
+ };
82
+ }
83
+ export function NaturalMultiply(inputs) {
84
+ return {
85
+ Product: asNatural(inputs.Multiplicand * inputs.Multiplier, 'Product'),
86
+ };
87
+ }
88
+ export function NaturalDivide(inputs) {
89
+ if (inputs.Divisor === 0) {
90
+ throw new Error('Divisor must be non-zero');
91
+ }
92
+ return {
93
+ Quotient: asNatural(Math.floor(inputs.Dividend / inputs.Divisor), 'Quotient'),
94
+ Remainder: asNatural(inputs.Dividend % inputs.Divisor, 'Remainder'),
95
+ };
96
+ }
97
+ export function NaturalDouble(inputs) {
98
+ return {
99
+ Doubled: asNatural(inputs.N * 2, 'Doubled'),
100
+ };
101
+ }
102
+ export const TOOL_IMPLEMENTATION_BY_NAME = {
103
+ Identity,
104
+ Add,
105
+ Subtract,
106
+ Multiply,
107
+ Divide,
108
+ Double,
109
+ LessThan,
110
+ BooleanIdentity,
111
+ NaturalIdentity,
112
+ NaturalLessThan,
113
+ NaturalAdd,
114
+ NaturalSubtract,
115
+ NaturalMultiply,
116
+ NaturalDivide,
117
+ NaturalDouble,
118
+ };
119
+ export const TOOL_IMPLEMENTATION_BY_HANDLE = {
120
+ 'TOOL-Identity': Identity,
121
+ 'TOOL-Add': Add,
122
+ 'TOOL-Subtract': Subtract,
123
+ 'TOOL-Multiply': Multiply,
124
+ 'TOOL-Divide': Divide,
125
+ 'TOOL-Double': Double,
126
+ 'TOOL-LessThan': LessThan,
127
+ 'TOOL-BooleanIdentity': BooleanIdentity,
128
+ 'TOOL-NaturalIdentity': NaturalIdentity,
129
+ 'TOOL-NaturalLessThan': NaturalLessThan,
130
+ 'TOOL-NaturalAdd': NaturalAdd,
131
+ 'TOOL-NaturalSubtract': NaturalSubtract,
132
+ 'TOOL-NaturalMultiply': NaturalMultiply,
133
+ 'TOOL-NaturalDivide': NaturalDivide,
134
+ 'TOOL-NaturalDouble': NaturalDouble,
135
+ };
@@ -9,11 +9,12 @@ export { StrategySchema as ZodStrategySchema } from '../generated-src/schemas/zo
9
9
  export { StrategyTraceSchema as ZodStrategyTraceSchema } from '../generated-src/schemas/zod/StrategyTrace.js';
10
10
  export { GoalSchema as ZodGoalSchema } from '../generated-src/schemas/zod/Goal.js';
11
11
  export * as ZodSchemas from '../generated-src/schemas/zod/index.js';
12
- export { default as ResourceTypes } from '../generated-src/resources/resourceTypes.js';
13
- export { default as CONSTANTS } from '../generated-src/derived/constants.js';
14
- export { default as MAPPINGS } from '../generated-src/derived/mappings.js';
15
- export type * from '../generated-src/types/types.js';
16
- export type * from '../generated-src/types/standalone/ResourceTypeResource.js';
17
- export type * from '../generated-src/types/standalone/ToolResource.js';
18
- export type * from '../generated-src/types/standalone/StrategyResource.js';
19
- export type * from '../generated-src/types/standalone/StrategyTraceResource.js';
12
+ export { default as ResourceTypeTimestampedResources } from '../generated-src/timestampedResources/resourceTypes.js';
13
+ export { Add, BooleanIdentity, createSpecializationKey, Divide, Double, Identity, LessThan, Multiply, NaturalAdd, NaturalDivide, NaturalDouble, NaturalIdentity, NaturalLessThan, NaturalMultiply, NaturalSubtract, Subtract, TOOL_IMPLEMENTATION_BY_HANDLE, TOOL_IMPLEMENTATION_BY_NAME, } from '../generated-src/implementations/tools.js';
14
+ export { default as CONSTANTS } from '../generated-src/lookups/constants.js';
15
+ export { default as MAPPINGS } from '../generated-src/lookups/mappings.js';
16
+ export type { ResourceTypeResource, } from '../generated-src/types/standalone/ResourceTypeResource.js';
17
+ export type { ToolResource, } from '../generated-src/types/standalone/ToolResource.js';
18
+ export type { StrategyResource, } from '../generated-src/types/standalone/StrategyResource.js';
19
+ export type { StrategyTraceResource, } from '../generated-src/types/standalone/StrategyTraceResource.js';
20
+ export type { BaseResource, BaseStrategy, BaseToolStepPathSpec, Boolean, BranchStep, Case, ContainerKind, DeferredStrategyProvenance, Description, DescriptionFacet, DocumentationSpec, ExternalInputPotential, GenesisProvenance, Goal, InputPotential, InputResource, InternalInputPotential, JsonSchemaObject, JsonSchemaObject1, JsonSchemaObject2, Name, NameFacet, Natural, OutputAddress, Provenance, ProvenanceFacet, ProvenanceKind, Resource, ResourceId, ResourcePointer, ResourceType, ResourceTypeHandle, RoleBindingSpec, RoleBindingSpecFacet, RoleBindingSpecFacet1, RoleName, RoleNameArray, RoleSpec, RoleSpecFacet, RoleValue, RoleValueByName, Step, StepArray, StepArrayArray, StepKind, StepKindFacet, Strategy, StrategyHandle, StrategyKind, StrategyProvenance, StrategyStateInputEntry, StrategyStateInputEntryByRoleName, StrategyStateInputKind, StrategyTrace, StrategyTraceHandle, ThreadedStrategy, ThreadedStrategyState, ThreadedStrategyStateFacet, ThreadedToolStepPath, ThreadedToolStepPathSpec, Tool, ToolHandle, ToolStep, ToolStepPath, ToolStepPathSlot, ToolStepPathSlotFacet, TypeRef, UnthreadedStrategy, UnthreadedStrategyState, UnthreadedStrategyStateFacet, UnthreadedToolStepPath, UnthreadedToolStepPathSpec, WhileStep, ForStep, } from '../generated-src/types/types.js';
package/dist/src/index.js CHANGED
@@ -11,6 +11,7 @@ export { StrategySchema as ZodStrategySchema } from '../generated-src/schemas/zo
11
11
  export { StrategyTraceSchema as ZodStrategyTraceSchema } from '../generated-src/schemas/zod/StrategyTrace.js';
12
12
  export { GoalSchema as ZodGoalSchema } from '../generated-src/schemas/zod/Goal.js';
13
13
  export * as ZodSchemas from '../generated-src/schemas/zod/index.js';
14
- export { default as ResourceTypes } from '../generated-src/resources/resourceTypes.js';
15
- export { default as CONSTANTS } from '../generated-src/derived/constants.js';
16
- export { default as MAPPINGS } from '../generated-src/derived/mappings.js';
14
+ export { default as ResourceTypeTimestampedResources } from '../generated-src/timestampedResources/resourceTypes.js';
15
+ export { Add, BooleanIdentity, createSpecializationKey, Divide, Double, Identity, LessThan, Multiply, NaturalAdd, NaturalDivide, NaturalDouble, NaturalIdentity, NaturalLessThan, NaturalMultiply, NaturalSubtract, Subtract, TOOL_IMPLEMENTATION_BY_HANDLE, TOOL_IMPLEMENTATION_BY_NAME, } from '../generated-src/implementations/tools.js';
16
+ export { default as CONSTANTS } from '../generated-src/lookups/constants.js';
17
+ export { default as MAPPINGS } from '../generated-src/lookups/mappings.js';
@@ -6,7 +6,8 @@ type ResourceTypeShell = JsonObject & {
6
6
  handle?: unknown;
7
7
  name?: unknown;
8
8
  description?: unknown;
9
+ ingestorToolInputSchema?: unknown;
9
10
  };
10
11
  type ResourceTypeShellByName = Record<string, ResourceTypeShell>;
11
- export declare function generateResourceTypes(schemasDocument: SchemasDocument, resourceTypeShells: ResourceTypeShellByName): ResourceTypeShellByName;
12
+ export declare function generateResourceTypes(schemasDocument: SchemasDocument, resourceTypeShells: ResourceTypeShellByName): ResourceTypeShell[];
12
13
  export {};
@@ -2,16 +2,32 @@ export function generateResourceTypes(schemasDocument, resourceTypeShells) {
2
2
  if (!schemasDocument.$defs || typeof schemasDocument.$defs !== 'object') {
3
3
  throw new Error('Schema document must have root $defs');
4
4
  }
5
- const resourceTypes = {};
5
+ const resourceTypes = [];
6
6
  for (const [resourceTypeName, resourceTypeShell] of Object.entries(resourceTypeShells)) {
7
- const valueSchema = schemasDocument.$defs[resourceTypeName];
8
- if (!valueSchema || typeof valueSchema !== 'object' || Array.isArray(valueSchema)) {
7
+ const projectionSchema = schemasDocument.$defs[resourceTypeName];
8
+ const ingestorToolInputSchemaDefName = resourceTypeShell.ingestorToolInputSchema;
9
+ if (!projectionSchema || typeof projectionSchema !== 'object' || Array.isArray(projectionSchema)) {
9
10
  throw new Error(`Missing matching schema for resource type record ${resourceTypeName}`);
10
11
  }
11
- resourceTypes[resourceTypeName] = {
12
+ if (ingestorToolInputSchemaDefName !== undefined &&
13
+ typeof ingestorToolInputSchemaDefName !== 'string') {
14
+ throw new Error(`ingestorToolInputSchema for resource type record ${resourceTypeName} must be a schema definition name when present`);
15
+ }
16
+ const ingestorToolInputSchema = typeof ingestorToolInputSchemaDefName === 'string'
17
+ ? schemasDocument.$defs[ingestorToolInputSchemaDefName]
18
+ : undefined;
19
+ if (typeof ingestorToolInputSchemaDefName === 'string' && !ingestorToolInputSchema) {
20
+ throw new Error(`Missing ingestor input schema ${ingestorToolInputSchemaDefName} for resource type record ${resourceTypeName}`);
21
+ }
22
+ if (ingestorToolInputSchema !== undefined &&
23
+ (typeof ingestorToolInputSchema !== 'object' || Array.isArray(ingestorToolInputSchema))) {
24
+ throw new Error(`Ingestor input schema ${ingestorToolInputSchemaDefName} for resource type record ${resourceTypeName} must be an object`);
25
+ }
26
+ resourceTypes.push({
12
27
  ...resourceTypeShell,
13
- valueSchema,
14
- };
28
+ projectionSchema,
29
+ ...(ingestorToolInputSchema ? { ingestorToolInputSchema } : {}),
30
+ });
15
31
  }
16
32
  return resourceTypes;
17
33
  }
@@ -37,9 +37,9 @@ export function normalizeAnchorsToPointers(input) {
37
37
  if (!defValue || typeof defValue !== 'object')
38
38
  continue;
39
39
  const envelope = defValue;
40
- const valueSchema = envelope.valueSchema;
41
- if (valueSchema && typeof valueSchema === 'object') {
42
- const anchor = valueSchema.$anchor;
40
+ const projectionSchema = envelope.projectionSchema;
41
+ if (projectionSchema && typeof projectionSchema === 'object') {
42
+ const anchor = projectionSchema.$anchor;
43
43
  if (typeof anchor === 'string' && !anchorToDef[anchor]) {
44
44
  anchorToDef[anchor] = defName;
45
45
  }
@@ -1,8 +1,8 @@
1
1
  export function generateStandaloneTypeContent(name) {
2
2
  const header = '// Auto-generated strict composite type. Do not edit.\n';
3
3
  const standaloneResourceTypeName = `${name}Resource`;
4
- const ts = `import type { ResourcePointer, ${name} as ValueSchema } from "../types.js";\n` +
5
- `export type ${standaloneResourceTypeName} = ResourcePointer & { value: ValueSchema };\n`;
4
+ const ts = `import type { ResourcePointer, ${name} as ProjectionSchema } from "../types.js";\n` +
5
+ `export type ${standaloneResourceTypeName} = ResourcePointer & { projection: ProjectionSchema };\n`;
6
6
  return header + ts;
7
7
  }
8
8
  export function validateStandaloneSchemaForWarnings(schema) {
@@ -0,0 +1,16 @@
1
+ type JsonObject = Record<string, unknown>;
2
+ type TimestampedResource = JsonObject & {
3
+ id: string;
4
+ resourceTypeHandle: string;
5
+ provenance: {
6
+ resourceProvenanceKind: 'genesis';
7
+ };
8
+ timestamp: string;
9
+ projection: unknown;
10
+ };
11
+ type GenerateTimestampedResourcesOptions = {
12
+ resourceTypeHandle: string;
13
+ getResourceId: (projection: unknown) => string;
14
+ };
15
+ export declare function generateTimestampedResources(declarations: unknown[], options: GenerateTimestampedResourcesOptions): TimestampedResource[];
16
+ export {};
@@ -0,0 +1,17 @@
1
+ const GENESIS_TIMESTAMP = '2025-11-30T00:00:00.000Z';
2
+ export function generateTimestampedResources(declarations, options) {
3
+ return declarations.map((projection) => {
4
+ return createTimestampedResource(projection, options);
5
+ });
6
+ }
7
+ function createTimestampedResource(projection, options) {
8
+ return {
9
+ id: options.getResourceId(projection),
10
+ resourceTypeHandle: options.resourceTypeHandle,
11
+ provenance: {
12
+ resourceProvenanceKind: 'genesis',
13
+ },
14
+ timestamp: GENESIS_TIMESTAMP,
15
+ projection,
16
+ };
17
+ }
@@ -53,9 +53,9 @@ function escapeRegExpLiteral(value) {
53
53
  return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
54
54
  }
55
55
  function deriveStrategyStateInputEntryByRoleNameValueType(parsedSchema) {
56
- const defs = parsedSchema?.$defs ?? parsedSchema?.valueSchema?.$defs;
56
+ const defs = parsedSchema?.$defs ?? parsedSchema?.projectionSchema?.$defs;
57
57
  const def = defs?.StrategyStateInputEntryByRoleName;
58
- const schemaNode = def?.valueSchema ?? def;
58
+ const schemaNode = def?.projectionSchema ?? def;
59
59
  const additionalProperties = schemaNode?.additionalProperties;
60
60
  if (!additionalProperties || typeof additionalProperties !== 'object' || Array.isArray(additionalProperties)) {
61
61
  return 'StrategyStateInputEntry';
@@ -66,8 +66,8 @@ function isRecordLikeObjectSchema(node) {
66
66
  return !hasFixedProps && hasPropertyNames && hasAdditionalSchema;
67
67
  }
68
68
  function emitRecordLikeObjectSchema(node, ctx, path) {
69
- const valueSchemaNode = node.additionalProperties;
70
- const valueExpr = emitSchema(valueSchemaNode, ctx, pathJoin(path, 'additionalProperties'));
69
+ const projectionSchemaNode = node.additionalProperties;
70
+ const valueExpr = emitSchema(projectionSchemaNode, ctx, pathJoin(path, 'additionalProperties'));
71
71
  const pn = node.propertyNames;
72
72
  let keyPattern;
73
73
  if (isObject(pn)) {
@@ -481,7 +481,7 @@ function buildAnchorMap(defs) {
481
481
  const top = defSchema.$anchor;
482
482
  if (typeof top === 'string' && top)
483
483
  map[top] = defName;
484
- const nested = defSchema.valueSchema;
484
+ const nested = defSchema.projectionSchema;
485
485
  if (isObject(nested) && typeof nested.$anchor === 'string' && nested.$anchor) {
486
486
  map[nested.$anchor] = defName;
487
487
  }
@@ -0,0 +1,4 @@
1
+ [
2
+ false,
3
+ true
4
+ ]
@@ -0,0 +1,2 @@
1
+ import declarations from './booleans.json' with { type: 'json' };
2
+ export default declarations;
@@ -0,0 +1,13 @@
1
+ [
2
+ 0,
3
+ 1,
4
+ 2,
5
+ 3,
6
+ 4,
7
+ 5,
8
+ 6,
9
+ 7,
10
+ 8,
11
+ 9,
12
+ 100
13
+ ]
@@ -0,0 +1,2 @@
1
+ import declarations from './naturals.json' with { type: 'json' };
2
+ export default declarations;