@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
@@ -1,114 +1,114 @@
1
- export function isObject(value: unknown): value is Record<string, unknown> {
2
- return value !== null && typeof value === 'object' && !Array.isArray(value);
3
- }
4
-
5
- export function deepClone<T>(value: T): T {
6
- if (Array.isArray(value)) return value.map((item) => deepClone(item)) as T;
7
- if (isObject(value)) {
8
- const out: Record<string, unknown> = {};
9
- for (const key of Object.keys(value)) out[key] = deepClone(value[key]);
10
- return out as T;
11
- }
12
- return value;
13
- }
14
-
15
- export function extractPointerDefName(ref: string): string | null {
16
- if (!ref || !ref.startsWith('#/')) return null;
17
- const parts = ref.slice(2).split('/');
18
- if (parts.length !== 2) return null;
19
- if (parts[0] !== '$defs') return null;
20
- const defName = parts[1];
21
- if (defName === undefined) return null;
22
- return defName.replace(/~1/g, '/').replace(/~0/g, '~');
23
- }
24
-
25
- export function collectLocalDefClosure(node: unknown, rootDefs: Record<string, unknown>): Set<string> {
26
- const needed = new Set<string>();
27
- const queue: string[] = [];
28
-
29
- function visit(value: unknown) {
30
- if (Array.isArray(value)) {
31
- for (const item of value) visit(item);
32
- return;
33
- }
34
- if (!isObject(value)) return;
35
-
36
- if (typeof value.$ref === 'string') {
37
- const name = extractPointerDefName(value.$ref);
38
- if (name && !needed.has(name)) {
39
- needed.add(name);
40
- queue.push(name);
41
- }
42
- }
43
-
44
- for (const nested of Object.values(value)) visit(nested);
45
- }
46
-
47
- visit(node);
48
-
49
- while (queue.length > 0) {
50
- const name = queue.shift();
51
- if (!name) continue;
52
- const def = rootDefs[name];
53
- if (def === undefined) continue;
54
- visit(def);
55
- }
56
-
57
- return needed;
58
- }
59
-
60
- export function extractStandaloneSchema(
61
- schemasDocument: { $defs?: Record<string, unknown> },
62
- name: string,
63
- ): { schema: unknown; warnings: string[] } {
64
- const rootDefs = schemasDocument.$defs;
65
- if (!rootDefs || typeof rootDefs !== 'object') {
66
- throw new Error('No $defs object found in schema document');
67
- }
68
-
69
- const target = rootDefs[name];
70
- if (target === undefined) {
71
- throw new Error(`Subschema named '${name}' not found under $defs in schema document`);
72
- }
73
-
74
- const needed = collectLocalDefClosure(target, rootDefs);
75
- const targetClone = deepClone(target);
76
- const defsOut: Record<string, unknown> = {};
77
- const warnings: string[] = [];
78
-
79
- for (const defName of needed) {
80
- if (defName === name) continue;
81
- const defSchema = rootDefs[defName];
82
- if (defSchema === undefined) {
83
- warnings.push(`Warning: referenced def '${defName}' missing in root $defs (skipped).`);
84
- continue;
85
- }
86
- defsOut[defName] = deepClone(defSchema);
87
- }
88
-
89
- const existingInner = isObject(targetClone) && isObject(targetClone.$defs)
90
- ? targetClone.$defs
91
- : {};
92
-
93
- if (isObject(targetClone)) {
94
- targetClone.$defs = { ...existingInner, ...defsOut };
95
- }
96
-
97
- return { schema: targetClone, warnings };
98
- }
99
-
100
- export function generateStandaloneSchemas(
101
- schemasDocument: { $defs?: Record<string, unknown> },
102
- names: string[],
103
- ): { standaloneSchemas: Record<string, unknown>; warnings: string[] } {
104
- const standaloneSchemas: Record<string, unknown> = {};
105
- const warnings: string[] = [];
106
-
107
- for (const name of names) {
108
- const result = extractStandaloneSchema(schemasDocument, name);
109
- standaloneSchemas[name] = result.schema;
110
- warnings.push(...result.warnings);
111
- }
112
-
113
- return { standaloneSchemas, warnings };
1
+ export function isObject(value: unknown): value is Record<string, unknown> {
2
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
3
+ }
4
+
5
+ export function deepClone<T>(value: T): T {
6
+ if (Array.isArray(value)) return value.map((item) => deepClone(item)) as T;
7
+ if (isObject(value)) {
8
+ const out: Record<string, unknown> = {};
9
+ for (const key of Object.keys(value)) out[key] = deepClone(value[key]);
10
+ return out as T;
11
+ }
12
+ return value;
13
+ }
14
+
15
+ export function extractPointerDefName(ref: string): string | null {
16
+ if (!ref || !ref.startsWith('#/')) return null;
17
+ const parts = ref.slice(2).split('/');
18
+ if (parts.length !== 2) return null;
19
+ if (parts[0] !== '$defs') return null;
20
+ const defName = parts[1];
21
+ if (defName === undefined) return null;
22
+ return defName.replace(/~1/g, '/').replace(/~0/g, '~');
23
+ }
24
+
25
+ export function collectLocalDefClosure(node: unknown, rootDefs: Record<string, unknown>): Set<string> {
26
+ const needed = new Set<string>();
27
+ const queue: string[] = [];
28
+
29
+ function visit(value: unknown) {
30
+ if (Array.isArray(value)) {
31
+ for (const item of value) visit(item);
32
+ return;
33
+ }
34
+ if (!isObject(value)) return;
35
+
36
+ if (typeof value.$ref === 'string') {
37
+ const name = extractPointerDefName(value.$ref);
38
+ if (name && !needed.has(name)) {
39
+ needed.add(name);
40
+ queue.push(name);
41
+ }
42
+ }
43
+
44
+ for (const nested of Object.values(value)) visit(nested);
45
+ }
46
+
47
+ visit(node);
48
+
49
+ while (queue.length > 0) {
50
+ const name = queue.shift();
51
+ if (!name) continue;
52
+ const def = rootDefs[name];
53
+ if (def === undefined) continue;
54
+ visit(def);
55
+ }
56
+
57
+ return needed;
58
+ }
59
+
60
+ export function extractStandaloneSchema(
61
+ schemasDocument: { $defs?: Record<string, unknown> },
62
+ name: string,
63
+ ): { schema: unknown; warnings: string[] } {
64
+ const rootDefs = schemasDocument.$defs;
65
+ if (!rootDefs || typeof rootDefs !== 'object') {
66
+ throw new Error('No $defs object found in schema document');
67
+ }
68
+
69
+ const target = rootDefs[name];
70
+ if (target === undefined) {
71
+ throw new Error(`Subschema named '${name}' not found under $defs in schema document`);
72
+ }
73
+
74
+ const needed = collectLocalDefClosure(target, rootDefs);
75
+ const targetClone = deepClone(target);
76
+ const defsOut: Record<string, unknown> = {};
77
+ const warnings: string[] = [];
78
+
79
+ for (const defName of needed) {
80
+ if (defName === name) continue;
81
+ const defSchema = rootDefs[defName];
82
+ if (defSchema === undefined) {
83
+ warnings.push(`Warning: referenced def '${defName}' missing in root $defs (skipped).`);
84
+ continue;
85
+ }
86
+ defsOut[defName] = deepClone(defSchema);
87
+ }
88
+
89
+ const existingInner = isObject(targetClone) && isObject(targetClone.$defs)
90
+ ? targetClone.$defs
91
+ : {};
92
+
93
+ if (isObject(targetClone)) {
94
+ targetClone.$defs = { ...existingInner, ...defsOut };
95
+ }
96
+
97
+ return { schema: targetClone, warnings };
98
+ }
99
+
100
+ export function generateStandaloneSchemas(
101
+ schemasDocument: { $defs?: Record<string, unknown> },
102
+ names: string[],
103
+ ): { standaloneSchemas: Record<string, unknown>; warnings: string[] } {
104
+ const standaloneSchemas: Record<string, unknown> = {};
105
+ const warnings: string[] = [];
106
+
107
+ for (const name of names) {
108
+ const result = extractStandaloneSchema(schemasDocument, name);
109
+ standaloneSchemas[name] = result.schema;
110
+ warnings.push(...result.warnings);
111
+ }
112
+
113
+ return { standaloneSchemas, warnings };
114
114
  }
@@ -1,28 +1,28 @@
1
- export function generateStandaloneTypeContent(name: string): string {
2
- const header = '// Auto-generated strict composite type. Do not edit.\n';
3
- const standaloneResourceTypeName = `${name}Resource`;
4
-
5
- const ts =
6
- `import type { ResourcePointer, ${name} as ValueSchema } from "../types.js";\n` +
7
- `export type ${standaloneResourceTypeName} = ResourcePointer & { value: ValueSchema };\n`;
8
- return header + ts;
9
- }
10
-
11
- export function validateStandaloneSchemaForWarnings(schema: any): string[] {
12
- const warnings: string[] = [];
13
- if (schema?.$schema && schema.$schema !== 'https://json-schema.org/draft/2020-12/schema') {
14
- warnings.push(
15
- `Warning: schema $schema is '${String(schema.$schema)}', expected draft 2020-12. Proceeding anyway.`,
16
- );
17
- }
18
- return warnings;
19
- }
20
-
21
- export function generateStandaloneTypeArtifacts(name: string): { dtsFileName: string; jsFileName: string; dtsContent: string; jsContent: string } {
22
- return {
23
- dtsFileName: `${name}Resource.d.ts`,
24
- jsFileName: `${name}Resource.js`,
25
- dtsContent: generateStandaloneTypeContent(name),
26
- jsContent: 'export {}\n',
27
- };
1
+ export function generateStandaloneTypeContent(name: string): string {
2
+ const header = '// Auto-generated strict composite type. Do not edit.\n';
3
+ const standaloneResourceTypeName = `${name}Resource`;
4
+
5
+ const ts =
6
+ `import type { ResourcePointer, ${name} as ProjectionSchema } from "../types.js";\n` +
7
+ `export type ${standaloneResourceTypeName} = ResourcePointer & { projection: ProjectionSchema };\n`;
8
+ return header + ts;
9
+ }
10
+
11
+ export function validateStandaloneSchemaForWarnings(schema: any): string[] {
12
+ const warnings: string[] = [];
13
+ if (schema?.$schema && schema.$schema !== 'https://json-schema.org/draft/2020-12/schema') {
14
+ warnings.push(
15
+ `Warning: schema $schema is '${String(schema.$schema)}', expected draft 2020-12. Proceeding anyway.`,
16
+ );
17
+ }
18
+ return warnings;
19
+ }
20
+
21
+ export function generateStandaloneTypeArtifacts(name: string): { dtsFileName: string; jsFileName: string; dtsContent: string; jsContent: string } {
22
+ return {
23
+ dtsFileName: `${name}Resource.d.ts`,
24
+ jsFileName: `${name}Resource.js`,
25
+ dtsContent: generateStandaloneTypeContent(name),
26
+ jsContent: 'export {}\n',
27
+ };
28
28
  }
@@ -1,72 +1,72 @@
1
- import { jsonSchemaToZodExpressions, type JsonSchemaToZodWarning } from './zodCodegen.js';
2
-
3
- export type GeneratedZodModule = {
4
- fileName: string;
5
- content: string;
6
- warnings: JsonSchemaToZodWarning[];
7
- };
8
-
9
- function isValidIdentifier(name: string): boolean {
10
- return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);
11
- }
12
-
13
- function toIdentifier(name: string): string {
14
- let out = name.replace(/[^A-Za-z0-9_]/g, '_');
15
- if (!/^[A-Za-z_]/.test(out)) out = `_${out}`;
16
- return out;
17
- }
18
-
19
- function emitHeader(name: string): string {
20
- return (
21
- `// Auto-generated from standalone schema '${name}'. Do not edit.\n` +
22
- `import { z } from 'zod/v4';\n\n`
23
- );
24
- }
25
-
26
- function emitModule(name: string, expressionsByName: Record<string, string>, warnings: JsonSchemaToZodWarning[]): string {
27
- const lines: string[] = [];
28
- lines.push(emitHeader(name));
29
-
30
- if (warnings.length > 0) {
31
- const warningsName = `${toIdentifier(name)}ZodGenerationWarnings`;
32
- lines.push(`export const ${warningsName} = ${JSON.stringify(warnings, null, 2)} as const;\n`);
33
- }
34
-
35
- const rootIdent = toIdentifier(name);
36
- const defNames = Object.keys(expressionsByName)
37
- .filter((schemaName) => schemaName !== name)
38
- .sort((a, b) => a.localeCompare(b));
39
-
40
- for (const schemaName of defNames) {
41
- const ident = toIdentifier(schemaName);
42
- if (!isValidIdentifier(ident)) {
43
- throw new Error(`Invalid generated identifier for schema '${schemaName}': '${ident}'`);
44
- }
45
- const expr = expressionsByName[schemaName];
46
- lines.push(`const ${ident}Schema: z.ZodTypeAny = z.lazy(() => ${expr});`);
47
- }
48
-
49
- lines.push('');
50
-
51
- const rootExpr = expressionsByName[name];
52
- lines.push(`export const ${rootIdent}Schema: z.ZodTypeAny = z.lazy(() => ${rootExpr});`);
53
-
54
- return lines.join('\n') + '\n';
55
- }
56
-
57
- export function generateStandaloneZodModule(name: string, standaloneSchema: unknown): GeneratedZodModule {
58
- const { expressionsByName, warnings } = jsonSchemaToZodExpressions(standaloneSchema, name);
59
- return {
60
- fileName: `${name}.ts`,
61
- content: emitModule(name, expressionsByName, warnings),
62
- warnings,
63
- };
64
- }
65
-
66
- export function generateStandaloneZodBarrel(names: string[]): string {
67
- const exports = names
68
- .slice()
69
- .sort((a, b) => a.localeCompare(b))
70
- .map((name) => `export { ${toIdentifier(name)}Schema } from './${name}.js';`);
71
- return `// Auto-generated barrel file. Do not edit.\n${exports.join('\n')}\n`;
1
+ import { jsonSchemaToZodExpressions, type JsonSchemaToZodWarning } from './zodCodegen.js';
2
+
3
+ export type GeneratedZodModule = {
4
+ fileName: string;
5
+ content: string;
6
+ warnings: JsonSchemaToZodWarning[];
7
+ };
8
+
9
+ function isValidIdentifier(name: string): boolean {
10
+ return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);
11
+ }
12
+
13
+ function toIdentifier(name: string): string {
14
+ let out = name.replace(/[^A-Za-z0-9_]/g, '_');
15
+ if (!/^[A-Za-z_]/.test(out)) out = `_${out}`;
16
+ return out;
17
+ }
18
+
19
+ function emitHeader(name: string): string {
20
+ return (
21
+ `// Auto-generated from standalone schema '${name}'. Do not edit.\n` +
22
+ `import { z } from 'zod/v4';\n\n`
23
+ );
24
+ }
25
+
26
+ function emitModule(name: string, expressionsByName: Record<string, string>, warnings: JsonSchemaToZodWarning[]): string {
27
+ const lines: string[] = [];
28
+ lines.push(emitHeader(name));
29
+
30
+ if (warnings.length > 0) {
31
+ const warningsName = `${toIdentifier(name)}ZodGenerationWarnings`;
32
+ lines.push(`export const ${warningsName} = ${JSON.stringify(warnings, null, 2)} as const;\n`);
33
+ }
34
+
35
+ const rootIdent = toIdentifier(name);
36
+ const defNames = Object.keys(expressionsByName)
37
+ .filter((schemaName) => schemaName !== name)
38
+ .sort((a, b) => a.localeCompare(b));
39
+
40
+ for (const schemaName of defNames) {
41
+ const ident = toIdentifier(schemaName);
42
+ if (!isValidIdentifier(ident)) {
43
+ throw new Error(`Invalid generated identifier for schema '${schemaName}': '${ident}'`);
44
+ }
45
+ const expr = expressionsByName[schemaName];
46
+ lines.push(`const ${ident}Schema: z.ZodTypeAny = z.lazy(() => ${expr});`);
47
+ }
48
+
49
+ lines.push('');
50
+
51
+ const rootExpr = expressionsByName[name];
52
+ lines.push(`export const ${rootIdent}Schema: z.ZodTypeAny = z.lazy(() => ${rootExpr});`);
53
+
54
+ return lines.join('\n') + '\n';
55
+ }
56
+
57
+ export function generateStandaloneZodModule(name: string, standaloneSchema: unknown): GeneratedZodModule {
58
+ const { expressionsByName, warnings } = jsonSchemaToZodExpressions(standaloneSchema, name);
59
+ return {
60
+ fileName: `${name}.ts`,
61
+ content: emitModule(name, expressionsByName, warnings),
62
+ warnings,
63
+ };
64
+ }
65
+
66
+ export function generateStandaloneZodBarrel(names: string[]): string {
67
+ const exports = names
68
+ .slice()
69
+ .sort((a, b) => a.localeCompare(b))
70
+ .map((name) => `export { ${toIdentifier(name)}Schema } from './${name}.js';`);
71
+ return `// Auto-generated barrel file. Do not edit.\n${exports.join('\n')}\n`;
72
72
  }
@@ -0,0 +1,42 @@
1
+ type JsonObject = Record<string, unknown>;
2
+
3
+ type TimestampedResource = JsonObject & {
4
+ id: string;
5
+ resourceTypeHandle: string;
6
+ provenance: {
7
+ resourceProvenanceKind: 'genesis';
8
+ };
9
+ timestamp: string;
10
+ projection: unknown;
11
+ };
12
+
13
+ type GenerateTimestampedResourcesOptions = {
14
+ resourceTypeHandle: string;
15
+ getResourceId: (projection: unknown) => string;
16
+ };
17
+
18
+ const GENESIS_TIMESTAMP = '2025-11-30T00:00:00.000Z';
19
+
20
+ export function generateTimestampedResources(
21
+ declarations: unknown[],
22
+ options: GenerateTimestampedResourcesOptions,
23
+ ): TimestampedResource[] {
24
+ return declarations.map((projection) => {
25
+ return createTimestampedResource(projection, options);
26
+ });
27
+ }
28
+
29
+ function createTimestampedResource(
30
+ projection: unknown,
31
+ options: GenerateTimestampedResourcesOptions,
32
+ ): TimestampedResource {
33
+ return {
34
+ id: options.getResourceId(projection),
35
+ resourceTypeHandle: options.resourceTypeHandle,
36
+ provenance: {
37
+ resourceProvenanceKind: 'genesis',
38
+ },
39
+ timestamp: GENESIS_TIMESTAMP,
40
+ projection,
41
+ };
42
+ }
@@ -1,31 +1,31 @@
1
- import { compile } from 'json-schema-to-typescript';
2
- import { finalizeOutputDts, postProcessEmittedTypes } from './typeGenerationPostProcess.js';
3
- import { normalizeSchemaForGenerator, validateSchemaArrayKeywords } from './typeGenerationPreflight.js';
4
-
5
- export async function generateTypeDeclarations(parsedSchema: any, rootName: string): Promise<string> {
6
- const validationIssues = validateSchemaArrayKeywords(parsedSchema);
7
- if (validationIssues.length) {
8
- throw new Error(
9
- 'Schema is not in canonical form for type generation:\n' +
10
- validationIssues.map((issue) => `- ${issue}`).join('\n'),
11
- );
12
- }
13
-
14
- const normalizedSchema = normalizeSchemaForGenerator(parsedSchema);
15
-
16
- let ts = await compile(normalizedSchema, rootName, {
17
- bannerComment: '',
18
- declareExternallyReferenced: true,
19
- unreachableDefinitions: true,
20
- $refOptions: {
21
- resolve: {
22
- file: { order: 2 },
23
- http: false,
24
- https: false,
25
- },
26
- } as any,
27
- });
28
-
29
- ts = postProcessEmittedTypes(ts, parsedSchema);
30
- return finalizeOutputDts(ts);
1
+ import { compile } from 'json-schema-to-typescript';
2
+ import { finalizeOutputDts, postProcessEmittedTypes } from './typeGenerationPostProcess.js';
3
+ import { normalizeSchemaForGenerator, validateSchemaArrayKeywords } from './typeGenerationPreflight.js';
4
+
5
+ export async function generateTypeDeclarations(parsedSchema: any, rootName: string): Promise<string> {
6
+ const validationIssues = validateSchemaArrayKeywords(parsedSchema);
7
+ if (validationIssues.length) {
8
+ throw new Error(
9
+ 'Schema is not in canonical form for type generation:\n' +
10
+ validationIssues.map((issue) => `- ${issue}`).join('\n'),
11
+ );
12
+ }
13
+
14
+ const normalizedSchema = normalizeSchemaForGenerator(parsedSchema);
15
+
16
+ let ts = await compile(normalizedSchema, rootName, {
17
+ bannerComment: '',
18
+ declareExternallyReferenced: true,
19
+ unreachableDefinitions: true,
20
+ $refOptions: {
21
+ resolve: {
22
+ file: { order: 2 },
23
+ http: false,
24
+ https: false,
25
+ },
26
+ } as any,
27
+ });
28
+
29
+ ts = postProcessEmittedTypes(ts, parsedSchema);
30
+ return finalizeOutputDts(ts);
31
31
  }