@toolproof-core/genesis 1.0.56 → 1.0.58
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/generated-src/declarations/resourceTypes.json +12 -3
- package/dist/generated-src/lookups/constants.d.ts +10 -24
- package/dist/generated-src/lookups/constants.js +10 -24
- package/dist/generated-src/schemas/schemas.json +57 -181
- package/dist/generated-src/schemas/standalone/Resource.json +2 -17
- package/dist/generated-src/schemas/standalone/Strategy.json +101 -215
- package/dist/generated-src/schemas/standalone/StrategyTrace.json +56 -97
- package/dist/generated-src/schemas/standalone/Suite.json +1 -2
- package/dist/generated-src/schemas/standalone/Tool.json +1 -2
- package/dist/generated-src/schemas/zod/Resource.js +1 -3
- package/dist/generated-src/schemas/zod/Strategy.d.ts +0 -6
- package/dist/generated-src/schemas/zod/Strategy.js +7 -27
- package/dist/generated-src/schemas/zod/StrategyTrace.d.ts +0 -6
- package/dist/generated-src/schemas/zod/StrategyTrace.js +16 -28
- package/dist/generated-src/timestampedResources/booleans.json +2 -2
- package/dist/generated-src/timestampedResources/naturals.json +11 -11
- package/dist/generated-src/timestampedResources/resourceTypes.json +22 -13
- package/dist/generated-src/timestampedResources/tools.json +15 -15
- package/dist/generated-src/types/types.d.ts +36 -119
- package/dist/src/index.d.ts +1 -1
- package/dist/src/utils/standaloneZodSchemas.js +6 -6
- package/dist/src/utils/timestampedResources.d.ts +1 -1
- package/dist/src/utils/timestampedResources.js +1 -1
- package/dist/src/utils/typeGenerationPostProcess.js +7 -37
- package/dist/src/utils/zodCodegen.d.ts +1 -1
- package/dist/src/utils/zodCodegen.js +7 -7
- package/package.json +1 -1
|
@@ -108,27 +108,15 @@ function fixRecursiveArrayAliasSelfReference(ts, typeName) {
|
|
|
108
108
|
}
|
|
109
109
|
return lines.join('\n');
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
return ts.replace(/\/\*\*\r?\n \* This interface was referenced by `Genesis`'s JSON-Schema\r?\n \* via the `definition` "ToolStepPath"\.\r?\n \*\/\r?\nexport type ToolStepPath =\r?\n[\s\S]
|
|
111
|
+
function brandToolStepPathAlias(ts) {
|
|
112
|
+
return ts.replace(/\/\*\*\r?\n \* This interface was referenced by `Genesis`'s JSON-Schema\r?\n \* via the `definition` "ToolStepPath"\.\r?\n \*\/\r?\nexport type ToolStepPath =\r?\n[\s\S]*?;/, `/**
|
|
113
113
|
* This interface was referenced by \`Genesis\`'s JSON-Schema
|
|
114
114
|
* via the \`definition\` "ToolStepPath".
|
|
115
115
|
*/
|
|
116
116
|
export type ToolStepPath =
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* This interface was referenced by \`Genesis\`'s JSON-Schema
|
|
120
|
-
* via the \`definition\` "UnthreadedToolStepPath".
|
|
121
|
-
*/
|
|
122
|
-
export type UnthreadedToolStepPath =
|
|
123
|
-
string & { readonly __brand: 'UnthreadedToolStepPath' };
|
|
124
|
-
/**
|
|
125
|
-
* This interface was referenced by \`Genesis\`'s JSON-Schema
|
|
126
|
-
* via the \`definition\` "ThreadedToolStepPath".
|
|
127
|
-
*/
|
|
128
|
-
export type ThreadedToolStepPath =
|
|
129
|
-
string & { readonly __brand: 'ThreadedToolStepPath' };`);
|
|
117
|
+
string & { readonly __brand: 'ToolStepPath' };`);
|
|
130
118
|
}
|
|
131
|
-
function
|
|
119
|
+
function addTypedToolStepRoleAddressAlias(ts) {
|
|
132
120
|
return ts.replace(/\/\*\*\r?\n \* This interface was referenced by `Genesis`'s JSON-Schema\r?\n \* via the `definition` "ToolStepRoleAddress"\.\r?\n \*\/\r?\nexport interface ToolStepRoleAddress \{\r?\n roleName: (?:string|RoleName);\r?\n toolStepPath: ToolStepPath;\r?\n\}/, `/**
|
|
133
121
|
* This interface was referenced by \`Genesis\`'s JSON-Schema
|
|
134
122
|
* via the \`definition\` "ToolStepRoleAddress".
|
|
@@ -136,19 +124,7 @@ function addTypedToolStepRoleAddressAliases(ts) {
|
|
|
136
124
|
export interface ToolStepRoleAddress {
|
|
137
125
|
roleName: RoleName;
|
|
138
126
|
toolStepPath: ToolStepPath;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* This interface was referenced by \`Genesis\`'s JSON-Schema
|
|
142
|
-
* via the \`definition\` "UnthreadedToolStepRoleAddress".
|
|
143
|
-
*/
|
|
144
|
-
export type UnthreadedToolStepRoleAddress =
|
|
145
|
-
ToolStepRoleAddress & { toolStepPath: UnthreadedToolStepPath };
|
|
146
|
-
/**
|
|
147
|
-
* This interface was referenced by \`Genesis\`'s JSON-Schema
|
|
148
|
-
* via the \`definition\` "ThreadedToolStepRoleAddress".
|
|
149
|
-
*/
|
|
150
|
-
export type ThreadedToolStepRoleAddress =
|
|
151
|
-
ToolStepRoleAddress & { toolStepPath: ThreadedToolStepPath };`);
|
|
127
|
+
}`);
|
|
152
128
|
}
|
|
153
129
|
export function postProcessEmittedTypes(ts, parsedSchema) {
|
|
154
130
|
ts = ts.replace(/^\s*\[k:\s*string\]:\s*unknown;\s*(?:\r?\n)?/gm, '');
|
|
@@ -175,20 +151,14 @@ export function postProcessEmittedTypes(ts, parsedSchema) {
|
|
|
175
151
|
const tmpl = patternTemplates[typeName];
|
|
176
152
|
return `${p1}${typeName}${p3}${tmpl ?? 'string'};`;
|
|
177
153
|
});
|
|
178
|
-
ts =
|
|
179
|
-
ts =
|
|
154
|
+
ts = brandToolStepPathAlias(ts);
|
|
155
|
+
ts = addTypedToolStepRoleAddressAlias(ts);
|
|
180
156
|
const roleNameKeyType = 'RoleName';
|
|
181
|
-
const unthreadedToolStepPathKeyType = 'UnthreadedToolStepPath';
|
|
182
|
-
const threadedToolStepPathKeyType = 'ThreadedToolStepPath';
|
|
183
157
|
const toolStepPathKeyType = 'ToolStepPath';
|
|
184
158
|
ts = ts.replace(/export interface RoleValueByName\s*\{\s*\[k:\s*string\]:\s*RoleValue;\s*\}/g, `export type RoleValueByName = Record<${roleNameKeyType}, RoleValue>;`);
|
|
185
159
|
const strategyStateInputEntryByRoleNameValueType = deriveStrategyStateInputEntryByRoleNameValueType(parsedSchema);
|
|
186
160
|
ts = ts.replace(/export interface StrategyStateInputEntryByRoleName\s*\{\s*\[k:\s*string\]:\s*[^;]+;\s*\}/g, `export type StrategyStateInputEntryByRoleName = Record<${roleNameKeyType}, ${strategyStateInputEntryByRoleNameValueType}>;`);
|
|
187
161
|
ts = ts.replace(/export\s+type\s+StrategyStateInputEntryByRoleName\s*=\s*Record<\s*RoleName\s*,\s*[^>]+>\s*;/g, `export type StrategyStateInputEntryByRoleName = Record<${roleNameKeyType}, ${strategyStateInputEntryByRoleNameValueType}>;`);
|
|
188
|
-
ts = ts.replace(/export interface StrategyStateInputEntryByRoleNameByUnthreadedToolStepPath\s*\{\s*\[k:\s*string\]:\s*StrategyStateInputEntryByRoleName;\s*\}/g, `export type StrategyStateInputEntryByRoleNameByUnthreadedToolStepPath = Record<${unthreadedToolStepPathKeyType}, StrategyStateInputEntryByRoleName>;`);
|
|
189
|
-
ts = ts.replace(/export interface StrategyStateInputEntryByRoleNameByThreadedToolStepPath\s*\{\s*\[k:\s*string\]:\s*StrategyStateInputEntryByRoleName;\s*\}/g, `export type StrategyStateInputEntryByRoleNameByThreadedToolStepPath = Record<${threadedToolStepPathKeyType}, StrategyStateInputEntryByRoleName>;`);
|
|
190
|
-
ts = ts.replace(/export\s+type\s+UnthreadedStrategyState\s*=\s*StrategyStateInputEntryByRoleNameByUnthreadedToolStepPath\s*;/g, `export type UnthreadedStrategyState = Record<${unthreadedToolStepPathKeyType}, StrategyStateInputEntryByRoleName>;`);
|
|
191
|
-
ts = ts.replace(/export\s+type\s+ThreadedStrategyState\s*=\s*StrategyStateInputEntryByRoleNameByThreadedToolStepPath\s*;/g, `export type ThreadedStrategyState = Record<${threadedToolStepPathKeyType}, StrategyStateInputEntryByRoleName>;`);
|
|
192
162
|
ts = ts.replace(/(strategyState\??:\s*)\{\s*\[k:\s*string\]:\s*StrategyStateInputEntryByRoleName;\s*\};/g, `$1Record<${toolStepPathKeyType}, StrategyStateInputEntryByRoleName>;`);
|
|
193
163
|
ts = ts.replace(/(strategyStateUpdate\??:\s*)\{\s*\[k:\s*string\]:\s*StrategyStateInputEntryByRoleName;\s*\};/g, `$1Record<${toolStepPathKeyType}, StrategyStateInputEntryByRoleName>;`);
|
|
194
164
|
ts = ts.replace(/export interface StepsByThreadIndexFacet\s*\{\s*stepsByThreadIndex:\s*StepArrayArray;\s*\}/g, 'export interface StepsByThreadIndexFacet {\n stepsByThreadIndex: StepArrayArray;\n}');
|
|
@@ -4,7 +4,7 @@ export type JsonSchemaToZodWarning = {
|
|
|
4
4
|
message: string;
|
|
5
5
|
};
|
|
6
6
|
export type JsonSchemaToZodResult = {
|
|
7
|
-
|
|
7
|
+
expressionByName: Record<string, string>;
|
|
8
8
|
warnings: JsonSchemaToZodWarning[];
|
|
9
9
|
};
|
|
10
10
|
export declare function jsonSchemaToZodExpressions(standaloneSchema: JsonSchema, rootName: string): JsonSchemaToZodResult;
|
|
@@ -76,7 +76,7 @@ function emitRecordLikeObjectSchema(node, ctx, path) {
|
|
|
76
76
|
}
|
|
77
77
|
else if (typeof pn.$ref === 'string') {
|
|
78
78
|
const defName = resolveLocalRef(pn.$ref, ctx);
|
|
79
|
-
const resolved = defName ? ctx.
|
|
79
|
+
const resolved = defName ? ctx.defByName[defName] : undefined;
|
|
80
80
|
if (isObject(resolved) && typeof resolved.pattern === 'string') {
|
|
81
81
|
keyPattern = resolved.pattern;
|
|
82
82
|
}
|
|
@@ -112,7 +112,7 @@ function resolveSchemaIfRef(node, ctx) {
|
|
|
112
112
|
if (isObject(node) && typeof node.$ref === 'string') {
|
|
113
113
|
const defName = resolveLocalRef(node.$ref, ctx);
|
|
114
114
|
if (defName)
|
|
115
|
-
return ctx.
|
|
115
|
+
return ctx.defByName[defName];
|
|
116
116
|
}
|
|
117
117
|
return node;
|
|
118
118
|
}
|
|
@@ -508,14 +508,14 @@ export function jsonSchemaToZodExpressions(standaloneSchema, rootName) {
|
|
|
508
508
|
const defNames = new Set(Object.keys(defs));
|
|
509
509
|
const ctx = {
|
|
510
510
|
defNames,
|
|
511
|
-
|
|
511
|
+
defByName: defs,
|
|
512
512
|
anchorToDefName: buildAnchorMap(defs),
|
|
513
513
|
warnings: []
|
|
514
514
|
};
|
|
515
|
-
const
|
|
515
|
+
const expressionByName = {};
|
|
516
516
|
for (const defName of Object.keys(defs)) {
|
|
517
|
-
|
|
517
|
+
expressionByName[defName] = emitSchema(defs[defName], ctx, `$defs.${defName}`);
|
|
518
518
|
}
|
|
519
|
-
|
|
520
|
-
return {
|
|
519
|
+
expressionByName[rootName] = emitSchema(normalized, ctx, rootName);
|
|
520
|
+
return { expressionByName, warnings: ctx.warnings };
|
|
521
521
|
}
|
package/package.json
CHANGED