@toolproof-core/genesis 1.0.53 → 1.0.54
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/booleans.d.ts +2 -0
- package/{generated-src → dist/generated-src}/declarations/booleans.json +1 -1
- package/dist/generated-src/declarations/naturals.d.ts +2 -0
- package/{generated-src → dist/generated-src}/declarations/naturals.json +1 -1
- package/dist/generated-src/declarations/resourceTypes.d.ts +2 -0
- package/{generated-src → dist/generated-src}/declarations/resourceTypes.json +1 -1
- package/dist/generated-src/declarations/tools.d.ts +2 -0
- package/{generated-src → dist/generated-src}/declarations/tools.json +1 -1
- package/dist/generated-src/implementations/tools.d.ts +100 -0
- package/dist/generated-src/implementations/tools.js +135 -0
- package/dist/generated-src/lookups/constants.d.ts +195 -0
- package/{generated-src/lookups/constants.ts → dist/generated-src/lookups/constants.js} +1 -2
- package/dist/generated-src/lookups/mappings.d.ts +11 -0
- package/{generated-src/lookups/mappings.ts → dist/generated-src/lookups/mappings.js} +1 -2
- package/dist/generated-src/schemas/schemas.d.ts +2 -0
- package/{generated-src → dist/generated-src}/schemas/schemas.json +1 -1
- package/dist/generated-src/schemas/standalone/Boolean.d.ts +2 -0
- package/dist/generated-src/schemas/standalone/Boolean.json +5 -0
- package/dist/generated-src/schemas/standalone/Error.d.ts +2 -0
- package/dist/generated-src/schemas/standalone/Error.json +78 -0
- package/dist/generated-src/schemas/standalone/Goal.d.ts +2 -0
- package/dist/generated-src/schemas/standalone/Goal.json +53 -0
- package/dist/generated-src/schemas/standalone/Natural.d.ts +2 -0
- package/dist/generated-src/schemas/standalone/Natural.json +6 -0
- package/dist/generated-src/schemas/standalone/Resource.d.ts +2 -0
- package/dist/generated-src/schemas/standalone/Resource.json +166 -0
- package/dist/generated-src/schemas/standalone/ResourceType.d.ts +2 -0
- package/dist/generated-src/schemas/standalone/ResourceType.json +147 -0
- package/dist/generated-src/schemas/standalone/Strategy.d.ts +2 -0
- package/dist/generated-src/schemas/standalone/Strategy.json +637 -0
- package/dist/generated-src/schemas/standalone/StrategyTrace.d.ts +2 -0
- package/dist/generated-src/schemas/standalone/StrategyTrace.json +816 -0
- package/dist/generated-src/schemas/standalone/Suite.d.ts +2 -0
- package/dist/generated-src/schemas/standalone/Suite.json +646 -0
- package/dist/generated-src/schemas/standalone/Tool.d.ts +2 -0
- package/dist/generated-src/schemas/standalone/Tool.json +533 -0
- package/dist/generated-src/schemas/zod/Boolean.d.ts +2 -0
- package/{generated-src/schemas/zod/Boolean.ts → dist/generated-src/schemas/zod/Boolean.js} +1 -4
- package/dist/generated-src/schemas/zod/Error.d.ts +2 -0
- package/dist/generated-src/schemas/zod/Error.js +8 -0
- package/dist/generated-src/schemas/zod/Goal.d.ts +2 -0
- package/dist/generated-src/schemas/zod/Goal.js +5 -0
- package/dist/generated-src/schemas/zod/Natural.d.ts +2 -0
- package/{generated-src/schemas/zod/Natural.ts → dist/generated-src/schemas/zod/Natural.js} +1 -4
- package/dist/generated-src/schemas/zod/Resource.d.ts +2 -0
- package/dist/generated-src/schemas/zod/Resource.js +18 -0
- package/dist/generated-src/schemas/zod/ResourceType.d.ts +2 -0
- package/dist/generated-src/schemas/zod/ResourceType.js +11 -0
- package/dist/generated-src/schemas/zod/Strategy.d.ts +12 -0
- package/dist/generated-src/schemas/zod/Strategy.js +70 -0
- package/dist/generated-src/schemas/zod/StrategyTrace.d.ts +12 -0
- package/dist/generated-src/schemas/zod/StrategyTrace.js +74 -0
- package/dist/generated-src/schemas/zod/Suite.d.ts +15 -0
- package/dist/generated-src/schemas/zod/Suite.js +40 -0
- package/dist/generated-src/schemas/zod/Tool.d.ts +9 -0
- package/dist/generated-src/schemas/zod/Tool.js +30 -0
- package/dist/generated-src/schemas/zod/index.d.ts +10 -0
- package/dist/generated-src/timestampedResources/booleans.d.ts +2 -0
- package/{generated-src → dist/generated-src}/timestampedResources/booleans.json +1 -1
- package/dist/generated-src/timestampedResources/naturals.d.ts +2 -0
- package/{generated-src → dist/generated-src}/timestampedResources/naturals.json +1 -1
- package/dist/generated-src/timestampedResources/resourceTypes.d.ts +2 -0
- package/{generated-src → dist/generated-src}/timestampedResources/resourceTypes.json +1 -1
- package/dist/generated-src/timestampedResources/tools.d.ts +2 -0
- package/{generated-src → dist/generated-src}/timestampedResources/tools.json +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/scripts/_lib/config.d.ts +83 -0
- package/dist/scripts/_lib/config.js +269 -0
- package/dist/scripts/generateConstantsAndMappings.d.ts +1 -0
- package/dist/scripts/generateConstantsAndMappings.js +41 -0
- package/dist/scripts/generateCoreProjection.d.ts +1 -0
- package/dist/scripts/generateCoreProjection.js +56 -0
- package/dist/scripts/generateDeclarations.d.ts +1 -0
- package/dist/scripts/generateDeclarations.js +43 -0
- package/dist/scripts/generateDependencies.d.ts +1 -0
- package/dist/scripts/generateDependencies.js +25 -0
- package/dist/scripts/generateImplementations.d.ts +1 -0
- package/dist/scripts/generateImplementations.js +45 -0
- package/dist/scripts/generateResourceTypes.d.ts +1 -0
- package/dist/scripts/generateResourceTypes.js +33 -0
- package/dist/scripts/generateSchemaShims.d.ts +1 -0
- package/dist/scripts/generateSchemaShims.js +39 -0
- package/dist/scripts/generateStandaloneSchemas.d.ts +1 -0
- package/dist/scripts/generateStandaloneSchemas.js +37 -0
- package/dist/scripts/generateStandaloneTypes.d.ts +1 -0
- package/dist/scripts/generateStandaloneTypes.js +39 -0
- package/dist/scripts/generateStandaloneZodSchemas.d.ts +1 -0
- package/dist/scripts/generateStandaloneZodSchemas.js +36 -0
- package/dist/scripts/generateTerminals.d.ts +1 -0
- package/dist/scripts/generateTerminals.js +26 -0
- package/dist/scripts/generateTimestampedResources.d.ts +1 -0
- package/dist/scripts/generateTimestampedResources.js +79 -0
- package/dist/scripts/generateTypes.d.ts +1 -0
- package/dist/scripts/generateTypes.js +40 -0
- package/dist/scripts/normalizeAnchorsToPointers.d.ts +1 -0
- package/dist/scripts/normalizeAnchorsToPointers.js +32 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +42 -8
- package/generated-src/implementations/tools.ts +0 -214
- package/generated-src/metadata/Core.json +0 -1929
- package/generated-src/metadata/dependencyMap.json +0 -297
- package/generated-src/metadata/terminals.json +0 -16
- package/generated-src/schemas/standalone/Boolean.json +0 -5
- package/generated-src/schemas/standalone/Error.json +0 -78
- package/generated-src/schemas/standalone/Goal.json +0 -53
- package/generated-src/schemas/standalone/Natural.json +0 -6
- package/generated-src/schemas/standalone/Resource.json +0 -166
- package/generated-src/schemas/standalone/ResourceType.json +0 -147
- package/generated-src/schemas/standalone/Strategy.json +0 -637
- package/generated-src/schemas/standalone/StrategyTrace.json +0 -816
- package/generated-src/schemas/standalone/Suite.json +0 -646
- package/generated-src/schemas/standalone/Tool.json +0 -533
- package/generated-src/schemas/zod/Error.ts +0 -11
- package/generated-src/schemas/zod/Goal.ts +0 -8
- package/generated-src/schemas/zod/Resource.ts +0 -21
- package/generated-src/schemas/zod/ResourceType.ts +0 -14
- package/generated-src/schemas/zod/Strategy.ts +0 -68
- package/generated-src/schemas/zod/StrategyTrace.ts +0 -75
- package/generated-src/schemas/zod/Suite.ts +0 -44
- package/generated-src/schemas/zod/Tool.ts +0 -34
- package/src/declarations/booleans.json +0 -4
- package/src/declarations/naturals.json +0 -13
- package/src/declarations/resourceTypes/resourceTypeShells.json +0 -53
- package/src/declarations/resourceTypes/schemas.json +0 -1839
- package/src/declarations/tools.json +0 -705
- package/src/implementations/tools.ts +0 -214
- package/src/index.ts +0 -131
- package/src/utils/constantsAndMappings.ts +0 -361
- package/src/utils/coreProjection.ts +0 -53
- package/src/utils/resourceTypes.ts +0 -71
- package/src/utils/schemaDependencies.ts +0 -115
- package/src/utils/schemaObjectNormalization.ts +0 -71
- package/src/utils/schemaRefNormalization.ts +0 -83
- package/src/utils/schemaShims.ts +0 -17
- package/src/utils/standaloneSchemas.ts +0 -114
- package/src/utils/standaloneTypes.ts +0 -28
- package/src/utils/standaloneZodSchemas.ts +0 -72
- package/src/utils/timestampedResources.ts +0 -42
- package/src/utils/typeGeneration.ts +0 -31
- package/src/utils/typeGenerationPostProcess.ts +0 -246
- package/src/utils/typeGenerationPreflight.ts +0 -119
- package/src/utils/zodCodegen.ts +0 -549
- /package/{generated-src/declarations/booleans.ts → dist/generated-src/declarations/booleans.js} +0 -0
- /package/{generated-src/declarations/naturals.ts → dist/generated-src/declarations/naturals.js} +0 -0
- /package/{generated-src/declarations/resourceTypes.ts → dist/generated-src/declarations/resourceTypes.js} +0 -0
- /package/{generated-src/declarations/tools.ts → dist/generated-src/declarations/tools.js} +0 -0
- /package/{generated-src/schemas/schemas.ts → dist/generated-src/schemas/schemas.js} +0 -0
- /package/{generated-src/schemas/standalone/Boolean.ts → dist/generated-src/schemas/standalone/Boolean.js} +0 -0
- /package/{generated-src/schemas/standalone/Error.ts → dist/generated-src/schemas/standalone/Error.js} +0 -0
- /package/{generated-src/schemas/standalone/Goal.ts → dist/generated-src/schemas/standalone/Goal.js} +0 -0
- /package/{generated-src/schemas/standalone/Natural.ts → dist/generated-src/schemas/standalone/Natural.js} +0 -0
- /package/{generated-src/schemas/standalone/Resource.ts → dist/generated-src/schemas/standalone/Resource.js} +0 -0
- /package/{generated-src/schemas/standalone/ResourceType.ts → dist/generated-src/schemas/standalone/ResourceType.js} +0 -0
- /package/{generated-src/schemas/standalone/Strategy.ts → dist/generated-src/schemas/standalone/Strategy.js} +0 -0
- /package/{generated-src/schemas/standalone/StrategyTrace.ts → dist/generated-src/schemas/standalone/StrategyTrace.js} +0 -0
- /package/{generated-src/schemas/standalone/Suite.ts → dist/generated-src/schemas/standalone/Suite.js} +0 -0
- /package/{generated-src/schemas/standalone/Tool.ts → dist/generated-src/schemas/standalone/Tool.js} +0 -0
- /package/{generated-src/schemas/zod/index.ts → dist/generated-src/schemas/zod/index.js} +0 -0
- /package/{generated-src/timestampedResources/booleans.ts → dist/generated-src/timestampedResources/booleans.js} +0 -0
- /package/{generated-src/timestampedResources/naturals.ts → dist/generated-src/timestampedResources/naturals.js} +0 -0
- /package/{generated-src/timestampedResources/resourceTypes.ts → dist/generated-src/timestampedResources/resourceTypes.js} +0 -0
- /package/{generated-src/timestampedResources/tools.ts → dist/generated-src/timestampedResources/tools.js} +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/BooleanResource.d.ts +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/BooleanResource.js +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/ErrorResource.d.ts +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/ErrorResource.js +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/GoalResource.d.ts +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/GoalResource.js +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/NaturalResource.d.ts +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/NaturalResource.js +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/ResourceResource.d.ts +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/ResourceResource.js +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/ResourceTypeResource.d.ts +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/ResourceTypeResource.js +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/StrategyResource.d.ts +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/StrategyResource.js +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/StrategyTraceResource.d.ts +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/StrategyTraceResource.js +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/SuiteResource.d.ts +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/SuiteResource.js +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/ToolResource.d.ts +0 -0
- /package/{generated-src → dist/generated-src}/types/standalone/ToolResource.js +0 -0
- /package/{generated-src → dist/generated-src}/types/types.d.ts +0 -0
- /package/{generated-src → dist/generated-src}/types/types.js +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import { getConfig } from './_lib/config.js';
|
|
3
|
+
import { generateStandaloneZodBarrel, generateStandaloneZodModule, } from '../src/utils/standaloneZodSchemas.js';
|
|
4
|
+
function main() {
|
|
5
|
+
try {
|
|
6
|
+
const config = getConfig();
|
|
7
|
+
const resourceTypeShellsPath = config.getResourceTypeShellsSourcePath();
|
|
8
|
+
if (!fs.existsSync(resourceTypeShellsPath)) {
|
|
9
|
+
throw new Error(`Resource type records source file not found at ${resourceTypeShellsPath}`);
|
|
10
|
+
}
|
|
11
|
+
const resourceTypeShells = JSON.parse(fs.readFileSync(resourceTypeShellsPath, 'utf8'));
|
|
12
|
+
const names = Object.keys(resourceTypeShells);
|
|
13
|
+
const zodDir = config.getZodSchemasDir();
|
|
14
|
+
fs.mkdirSync(zodDir, { recursive: true });
|
|
15
|
+
for (const name of names) {
|
|
16
|
+
const inPath = config.getStandaloneSchemaPath(`${name}.json`);
|
|
17
|
+
if (!fs.existsSync(inPath)) {
|
|
18
|
+
throw new Error(`Standalone schema not found at ${inPath}. Run generateStandaloneSchemas first.`);
|
|
19
|
+
}
|
|
20
|
+
const parsed = JSON.parse(fs.readFileSync(inPath, 'utf8'));
|
|
21
|
+
const generated = generateStandaloneZodModule(name, parsed);
|
|
22
|
+
const outPath = config.getZodSchemaPath(generated.fileName);
|
|
23
|
+
fs.writeFileSync(outPath, generated.content, 'utf8');
|
|
24
|
+
if (generated.warnings.length > 0) {
|
|
25
|
+
console.warn(`Generated Zod schema '${name}' with ${generated.warnings.length} warning(s).`);
|
|
26
|
+
}
|
|
27
|
+
console.log(`Wrote ${outPath}`);
|
|
28
|
+
}
|
|
29
|
+
fs.writeFileSync(config.getZodIndexPath(), generateStandaloneZodBarrel(names), 'utf8');
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error(error?.message ?? error);
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
void main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
import { computeTerminalsInKeyOrder, normalizeDependencyMap, } from '../src/utils/schemaDependencies.js';
|
|
5
|
+
function main() {
|
|
6
|
+
try {
|
|
7
|
+
const config = getConfig();
|
|
8
|
+
const inPath = config.getDependencyMapPath();
|
|
9
|
+
const outPath = config.getTerminalsPath();
|
|
10
|
+
if (!fs.existsSync(inPath)) {
|
|
11
|
+
throw new Error(`Dependency map not found at ${inPath}. Run generateDependencies first.`);
|
|
12
|
+
}
|
|
13
|
+
const raw = fs.readFileSync(inPath, 'utf8');
|
|
14
|
+
const parsed = JSON.parse(raw);
|
|
15
|
+
const dependencyMap = normalizeDependencyMap(parsed);
|
|
16
|
+
const terminals = computeTerminalsInKeyOrder(dependencyMap);
|
|
17
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
18
|
+
fs.writeFileSync(outPath, JSON.stringify(terminals, null, 4), 'utf8');
|
|
19
|
+
console.log(`Wrote terminals to ${outPath}`);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error(error?.message ?? error);
|
|
23
|
+
process.exitCode = 1;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
import { generateTimestampedResources } from '../src/utils/timestampedResources.js';
|
|
5
|
+
/**
|
|
6
|
+
* Wrap canonical declarations with TimestampedResource records.
|
|
7
|
+
*/
|
|
8
|
+
// IMPURE: Script entrypoint (config + filesystem I/O + console + process exit code).
|
|
9
|
+
function main() {
|
|
10
|
+
try {
|
|
11
|
+
const config = getConfig();
|
|
12
|
+
const jobs = [
|
|
13
|
+
{
|
|
14
|
+
inPath: config.getResourceTypesDeclarationPath(),
|
|
15
|
+
outPath: config.getResourceTypeTimestampedResourcesPath(),
|
|
16
|
+
label: 'resource type',
|
|
17
|
+
resourceTypeHandle: 'TYPE-ResourceType',
|
|
18
|
+
getResourceId: (value) => getResourceIdFromHandle(value),
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
inPath: config.getToolsDeclarationPath(),
|
|
22
|
+
outPath: config.getToolTimestampedResourcesPath(),
|
|
23
|
+
label: 'tool',
|
|
24
|
+
resourceTypeHandle: 'TYPE-Tool',
|
|
25
|
+
getResourceId: (value) => getResourceIdFromHandle(value),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
inPath: config.getBooleansDeclarationPath(),
|
|
29
|
+
outPath: config.getBooleanTimestampedResourcesPath(),
|
|
30
|
+
label: 'boolean',
|
|
31
|
+
resourceTypeHandle: 'TYPE-Boolean',
|
|
32
|
+
getResourceId: (value) => `RESOURCE-BOOLEAN:${value === true ? 'True' : 'False'}`,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
inPath: config.getNaturalsDeclarationPath(),
|
|
36
|
+
outPath: config.getNaturalTimestampedResourcesPath(),
|
|
37
|
+
label: 'natural',
|
|
38
|
+
resourceTypeHandle: 'TYPE-Natural',
|
|
39
|
+
getResourceId: (value) => `RESOURCE-NATURAL:${String(value)}`,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
for (const job of jobs) {
|
|
43
|
+
if (!fs.existsSync(job.inPath)) {
|
|
44
|
+
throw new Error(`Generated ${job.label} declarations file not found at ${job.inPath}`);
|
|
45
|
+
}
|
|
46
|
+
const declarations = JSON.parse(fs.readFileSync(job.inPath, 'utf-8'));
|
|
47
|
+
if (!Array.isArray(declarations)) {
|
|
48
|
+
throw new Error(`Generated ${job.label} declarations file must be an array at ${job.inPath}`);
|
|
49
|
+
}
|
|
50
|
+
const timestampedResources = generateTimestampedResources(declarations, {
|
|
51
|
+
resourceTypeHandle: job.resourceTypeHandle,
|
|
52
|
+
getResourceId: job.getResourceId,
|
|
53
|
+
});
|
|
54
|
+
fs.mkdirSync(path.dirname(job.outPath), { recursive: true });
|
|
55
|
+
fs.writeFileSync(job.outPath, JSON.stringify(timestampedResources, null, 4), 'utf-8');
|
|
56
|
+
console.log(`Generated ${timestampedResources.length} ${job.label} timestamped resources -> ${job.outPath}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error(error?.message ?? error);
|
|
61
|
+
process.exitCode = 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function getResourceIdFromHandle(value) {
|
|
65
|
+
if (value && typeof value === 'object' && 'handle' in value && typeof value.handle === 'string') {
|
|
66
|
+
return formatResourceIdFromHandle(value.handle);
|
|
67
|
+
}
|
|
68
|
+
throw new Error('Timestamped resource generation requires declaration values with a string handle.');
|
|
69
|
+
}
|
|
70
|
+
function formatResourceIdFromHandle(handle) {
|
|
71
|
+
const separatorIndex = handle.indexOf('-');
|
|
72
|
+
if (separatorIndex === -1) {
|
|
73
|
+
return `RESOURCE-${handle}`;
|
|
74
|
+
}
|
|
75
|
+
const namespace = handle.slice(0, separatorIndex);
|
|
76
|
+
const localPart = handle.slice(separatorIndex + 1);
|
|
77
|
+
return `RESOURCE-${namespace}:${localPart}`;
|
|
78
|
+
}
|
|
79
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
import { generateTypeDeclarations } from '../src/utils/typeGeneration.js';
|
|
5
|
+
async function main() {
|
|
6
|
+
try {
|
|
7
|
+
const config = getConfig();
|
|
8
|
+
const schemaPath = config.getSchemasPath();
|
|
9
|
+
const srcTypesDir = config.getTypesSrcDir();
|
|
10
|
+
const distTypesDir = config.getTypesDistDir();
|
|
11
|
+
const srcOutputPath = config.getTypesDtsSrcPath();
|
|
12
|
+
const distOutputPath = config.getTypesDtsDistPath();
|
|
13
|
+
const srcJsPath = config.getTypesJsSrcPath();
|
|
14
|
+
const distJsPath = config.getTypesJsDistPath();
|
|
15
|
+
if (!fs.existsSync(schemaPath)) {
|
|
16
|
+
throw new Error(`Generated schemas file not found at ${schemaPath}\n` +
|
|
17
|
+
'Run the normalization step first (for example: pnpm run normalizeAnchorsToPointers).');
|
|
18
|
+
}
|
|
19
|
+
const parsedSchema = JSON.parse(fs.readFileSync(schemaPath, 'utf8'));
|
|
20
|
+
const rootName = path.basename(schemaPath, path.extname(schemaPath));
|
|
21
|
+
const output = await generateTypeDeclarations(parsedSchema, rootName);
|
|
22
|
+
fs.mkdirSync(srcTypesDir, { recursive: true });
|
|
23
|
+
fs.writeFileSync(srcOutputPath, output, 'utf8');
|
|
24
|
+
console.log(`Wrote ${srcOutputPath}`);
|
|
25
|
+
fs.mkdirSync(distTypesDir, { recursive: true });
|
|
26
|
+
fs.writeFileSync(distOutputPath, output, 'utf8');
|
|
27
|
+
console.log(`Wrote ${distOutputPath}`);
|
|
28
|
+
if (!fs.existsSync(srcJsPath)) {
|
|
29
|
+
fs.writeFileSync(srcJsPath, 'export {}\n', 'utf8');
|
|
30
|
+
console.log(`Wrote ${srcJsPath}`);
|
|
31
|
+
}
|
|
32
|
+
fs.writeFileSync(distJsPath, 'export {}\n', 'utf8');
|
|
33
|
+
console.log(`Wrote ${distJsPath}`);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error(error?.message ?? error);
|
|
37
|
+
process.exitCode = 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
void main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
import { normalizeAnchorsToPointers } from '../src/utils/schemaRefNormalization.js';
|
|
5
|
+
/**
|
|
6
|
+
* Rewrite local anchor refs in the configured source schema document to JSON pointers.
|
|
7
|
+
*/
|
|
8
|
+
// IMPURE: Script entrypoint (config + filesystem I/O + console + process exit code).
|
|
9
|
+
function main() {
|
|
10
|
+
try {
|
|
11
|
+
const config = getConfig();
|
|
12
|
+
const inPath = config.getSchemasSourcePath();
|
|
13
|
+
const outPath = config.getSchemasPath();
|
|
14
|
+
if (!fs.existsSync(inPath)) {
|
|
15
|
+
throw new Error(`Schema source file not found at ${inPath}`);
|
|
16
|
+
}
|
|
17
|
+
const raw = fs.readFileSync(inPath, 'utf-8');
|
|
18
|
+
const schemas = JSON.parse(raw);
|
|
19
|
+
if (!schemas.$defs || typeof schemas.$defs !== 'object') {
|
|
20
|
+
throw new Error('Source schema document must have root $defs');
|
|
21
|
+
}
|
|
22
|
+
const normalizedSchemas = normalizeAnchorsToPointers(schemas);
|
|
23
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
24
|
+
fs.writeFileSync(outPath, JSON.stringify(normalizedSchemas, null, 4), 'utf-8');
|
|
25
|
+
console.log(`Wrote generated schemas with pointer refs to ${outPath}`);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.error(error?.message ?? error);
|
|
29
|
+
process.exitCode = 1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../index.ts","../src/index.ts","../src/implementations/tools.ts","../src/utils/constantsandmappings.ts","../src/utils/coreprojection.ts","../src/utils/resourcetypes.ts","../src/utils/schemadependencies.ts","../src/utils/schemaobjectnormalization.ts","../src/utils/schemarefnormalization.ts","../src/utils/schemashims.ts","../src/utils/standaloneschemas.ts","../src/utils/standalonetypes.ts","../src/utils/standalonezodschemas.ts","../src/utils/timestampedresources.ts","../src/utils/typegeneration.ts","../src/utils/typegenerationpostprocess.ts","../src/utils/typegenerationpreflight.ts","../src/utils/zodcodegen.ts","../generated-src/declarations/booleans.ts","../generated-src/declarations/naturals.ts","../generated-src/declarations/resourcetypes.ts","../generated-src/declarations/tools.ts","../generated-src/implementations/tools.ts","../generated-src/lookups/constants.ts","../generated-src/lookups/mappings.ts","../generated-src/schemas/schemas.ts","../generated-src/schemas/standalone/boolean.ts","../generated-src/schemas/standalone/error.ts","../generated-src/schemas/standalone/goal.ts","../generated-src/schemas/standalone/natural.ts","../generated-src/schemas/standalone/resource.ts","../generated-src/schemas/standalone/resourcetype.ts","../generated-src/schemas/standalone/strategy.ts","../generated-src/schemas/standalone/strategytrace.ts","../generated-src/schemas/standalone/suite.ts","../generated-src/schemas/standalone/tool.ts","../generated-src/schemas/zod/boolean.ts","../generated-src/schemas/zod/error.ts","../generated-src/schemas/zod/goal.ts","../generated-src/schemas/zod/natural.ts","../generated-src/schemas/zod/resource.ts","../generated-src/schemas/zod/resourcetype.ts","../generated-src/schemas/zod/strategy.ts","../generated-src/schemas/zod/strategytrace.ts","../generated-src/schemas/zod/suite.ts","../generated-src/schemas/zod/tool.ts","../generated-src/schemas/zod/index.ts","../generated-src/timestampedresources/booleans.ts","../generated-src/timestampedresources/naturals.ts","../generated-src/timestampedresources/resourcetypes.ts","../generated-src/timestampedresources/tools.ts","../generated-src/types/types.d.ts","../generated-src/types/standalone/booleanresource.d.ts","../generated-src/types/standalone/errorresource.d.ts","../generated-src/types/standalone/goalresource.d.ts","../generated-src/types/standalone/naturalresource.d.ts","../generated-src/types/standalone/resourceresource.d.ts","../generated-src/types/standalone/resourcetyperesource.d.ts","../generated-src/types/standalone/strategyresource.d.ts","../generated-src/types/standalone/strategytraceresource.d.ts","../generated-src/types/standalone/suiteresource.d.ts","../generated-src/types/standalone/toolresource.d.ts","../scripts/generateconstantsandmappings.ts","../scripts/generatecoreprojection.ts","../scripts/generatedeclarations.ts","../scripts/generatedependencies.ts","../scripts/generateimplementations.ts","../scripts/generateresourcetypes.ts","../scripts/generateschemashims.ts","../scripts/generatestandaloneschemas.ts","../scripts/generatestandalonetypes.ts","../scripts/generatestandalonezodschemas.ts","../scripts/generateterminals.ts","../scripts/generatetimestampedresources.ts","../scripts/generatetypes.ts","../scripts/normalizeanchorstopointers.ts","../scripts/_lib/config.ts"],"version":"5.9.3"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toolproof-core/genesis",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"description": "Core ToolProof ontology, schemas, declarations, implementations, and generated type artifacts.",
|
|
5
|
-
"main": "dist/
|
|
6
|
-
"types": "dist/
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"import": "./dist/
|
|
10
|
-
"types": "./dist/
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./lookups/constants": {
|
|
13
|
+
"import": "./dist/generated-src/lookups/constants.js",
|
|
14
|
+
"types": "./dist/generated-src/lookups/constants.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./lookups/mappings": {
|
|
17
|
+
"import": "./dist/generated-src/lookups/mappings.js",
|
|
18
|
+
"types": "./dist/generated-src/lookups/mappings.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./types": {
|
|
21
|
+
"import": "./dist/generated-src/types/types.js",
|
|
22
|
+
"types": "./dist/generated-src/types/types.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./schemas": {
|
|
25
|
+
"import": "./dist/generated-src/schemas/schemas.js",
|
|
26
|
+
"types": "./dist/generated-src/schemas/schemas.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./implementations/tools": {
|
|
29
|
+
"import": "./dist/generated-src/implementations/tools.js",
|
|
30
|
+
"types": "./dist/generated-src/implementations/tools.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./timestamped-resources/resource-types": {
|
|
33
|
+
"import": "./dist/generated-src/timestampedResources/resourceTypes.js",
|
|
34
|
+
"types": "./dist/generated-src/timestampedResources/resourceTypes.d.ts"
|
|
35
|
+
},
|
|
36
|
+
"./timestamped-resources/tools": {
|
|
37
|
+
"import": "./dist/generated-src/timestampedResources/tools.js",
|
|
38
|
+
"types": "./dist/generated-src/timestampedResources/tools.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"./timestamped-resources/booleans": {
|
|
41
|
+
"import": "./dist/generated-src/timestampedResources/booleans.js",
|
|
42
|
+
"types": "./dist/generated-src/timestampedResources/booleans.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./timestamped-resources/naturals": {
|
|
45
|
+
"import": "./dist/generated-src/timestampedResources/naturals.js",
|
|
46
|
+
"types": "./dist/generated-src/timestampedResources/naturals.d.ts"
|
|
11
47
|
}
|
|
12
48
|
},
|
|
13
49
|
"files": [
|
|
14
50
|
"toolproof.json",
|
|
15
|
-
"dist
|
|
16
|
-
"src",
|
|
17
|
-
"generated-src"
|
|
51
|
+
"dist"
|
|
18
52
|
],
|
|
19
53
|
"type": "module",
|
|
20
54
|
"keywords": [],
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Boolean,
|
|
3
|
-
Natural,
|
|
4
|
-
ResourceType,
|
|
5
|
-
Tool,
|
|
6
|
-
} from '../types/types.js';
|
|
7
|
-
|
|
8
|
-
type GenericAssignmentByRoleName<GenericRoleName extends string> = Record<GenericRoleName, ResourceType>;
|
|
9
|
-
|
|
10
|
-
type InstantiationToolHandleBySpecializationKey = Record<string, Tool>;
|
|
11
|
-
|
|
12
|
-
type TemplateInputs<GenericRoleName extends string> = {
|
|
13
|
-
GenericAssignmentByRoleName: GenericAssignmentByRoleName<GenericRoleName>;
|
|
14
|
-
InstantiationToolHandleBySpecializationKey: InstantiationToolHandleBySpecializationKey;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type TemplateOutputs = {
|
|
18
|
-
InstantiationTool: Tool;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type OperandTemplateInputs = TemplateInputs<'OperandType'>;
|
|
22
|
-
|
|
23
|
-
const OPERAND_TYPE_ROLE_NAMES = ['OperandType'] as const;
|
|
24
|
-
|
|
25
|
-
function assertExactKeys(actualKeys: string[], expectedKeys: readonly string[], label: string): void {
|
|
26
|
-
const sortedActualKeys = [...actualKeys].sort();
|
|
27
|
-
const sortedExpectedKeys = [...expectedKeys].sort();
|
|
28
|
-
|
|
29
|
-
if (sortedActualKeys.length !== sortedExpectedKeys.length) {
|
|
30
|
-
throw new Error(
|
|
31
|
-
`${label} must contain exactly [${sortedExpectedKeys.join(', ')}], got [${sortedActualKeys.join(', ')}]`
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
for (let index = 0; index < sortedExpectedKeys.length; index += 1) {
|
|
36
|
-
if (sortedActualKeys[index] !== sortedExpectedKeys[index]) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
`${label} must contain exactly [${sortedExpectedKeys.join(', ')}], got [${sortedActualKeys.join(', ')}]`
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function asNatural(value: number, label: string): Natural {
|
|
45
|
-
if (!Number.isInteger(value) || value < 0) {
|
|
46
|
-
throw new Error(`${label} must be a non-negative integer, got ${value}`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return value as Natural;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function createSpecializationKey(assignments: Record<string, ResourceType>): string {
|
|
53
|
-
return JSON.stringify(
|
|
54
|
-
Object.entries(assignments)
|
|
55
|
-
.sort(([leftRoleName], [rightRoleName]) => leftRoleName.localeCompare(rightRoleName))
|
|
56
|
-
.map(([roleName, resourceType]) => [roleName, resourceType.handle])
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function resolveTemplateInstantiation<GenericRoleName extends string>(
|
|
61
|
-
inputs: TemplateInputs<GenericRoleName>,
|
|
62
|
-
expectedGenericRoleNames: readonly GenericRoleName[]
|
|
63
|
-
): TemplateOutputs {
|
|
64
|
-
const { GenericAssignmentByRoleName, InstantiationToolHandleBySpecializationKey } = inputs;
|
|
65
|
-
|
|
66
|
-
assertExactKeys(
|
|
67
|
-
Object.keys(GenericAssignmentByRoleName),
|
|
68
|
-
expectedGenericRoleNames,
|
|
69
|
-
'GenericAssignmentByRoleName'
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const specializationKey = createSpecializationKey(GenericAssignmentByRoleName);
|
|
73
|
-
const instantiationTool = InstantiationToolHandleBySpecializationKey[specializationKey];
|
|
74
|
-
|
|
75
|
-
if (!instantiationTool) {
|
|
76
|
-
throw new Error(`No instantiation tool registered for specializationKey ${specializationKey}`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
InstantiationTool: instantiationTool,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function Identity(inputs: OperandTemplateInputs): TemplateOutputs {
|
|
85
|
-
return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function Add(inputs: OperandTemplateInputs): TemplateOutputs {
|
|
89
|
-
return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function Subtract(inputs: OperandTemplateInputs): TemplateOutputs {
|
|
93
|
-
return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function Multiply(inputs: OperandTemplateInputs): TemplateOutputs {
|
|
97
|
-
return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function Divide(inputs: OperandTemplateInputs): TemplateOutputs {
|
|
101
|
-
return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function Double(inputs: OperandTemplateInputs): TemplateOutputs {
|
|
105
|
-
return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export function LessThan(inputs: OperandTemplateInputs): TemplateOutputs {
|
|
109
|
-
return resolveTemplateInstantiation(inputs, OPERAND_TYPE_ROLE_NAMES);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function BooleanIdentity(inputs: { In: Boolean }): { Out: Boolean } {
|
|
113
|
-
return {
|
|
114
|
-
Out: inputs.In,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function NaturalIdentity(inputs: { In: Natural }): { Out: Natural } {
|
|
119
|
-
return {
|
|
120
|
-
Out: inputs.In,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function NaturalLessThan(inputs: {
|
|
125
|
-
LessThanSource: Natural;
|
|
126
|
-
LessThanTarget: Natural;
|
|
127
|
-
}): { LessThanDecision: Boolean } {
|
|
128
|
-
return {
|
|
129
|
-
LessThanDecision: inputs.LessThanSource < inputs.LessThanTarget,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export function NaturalAdd(inputs: {
|
|
134
|
-
AddendOne: Natural;
|
|
135
|
-
AddendTwo: Natural;
|
|
136
|
-
}): { Sum: Natural } {
|
|
137
|
-
return {
|
|
138
|
-
Sum: asNatural(inputs.AddendOne + inputs.AddendTwo, 'Sum'),
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export function NaturalSubtract(inputs: {
|
|
143
|
-
Minuend: Natural;
|
|
144
|
-
Subtrahend: Natural;
|
|
145
|
-
}): { Difference: Natural } {
|
|
146
|
-
return {
|
|
147
|
-
Difference: asNatural(inputs.Minuend - inputs.Subtrahend, 'Difference'),
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export function NaturalMultiply(inputs: {
|
|
152
|
-
Multiplicand: Natural;
|
|
153
|
-
Multiplier: Natural;
|
|
154
|
-
}): { Product: Natural } {
|
|
155
|
-
return {
|
|
156
|
-
Product: asNatural(inputs.Multiplicand * inputs.Multiplier, 'Product'),
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export function NaturalDivide(inputs: {
|
|
161
|
-
Dividend: Natural;
|
|
162
|
-
Divisor: Natural;
|
|
163
|
-
}): { Quotient: Natural; Remainder: Natural } {
|
|
164
|
-
if (inputs.Divisor === 0) {
|
|
165
|
-
throw new Error('Divisor must be non-zero');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return {
|
|
169
|
-
Quotient: asNatural(Math.floor(inputs.Dividend / inputs.Divisor), 'Quotient'),
|
|
170
|
-
Remainder: asNatural(inputs.Dividend % inputs.Divisor, 'Remainder'),
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export function NaturalDouble(inputs: { N: Natural }): { Doubled: Natural } {
|
|
175
|
-
return {
|
|
176
|
-
Doubled: asNatural(inputs.N * 2, 'Doubled'),
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export const TOOL_IMPLEMENTATION_BY_NAME = {
|
|
181
|
-
Identity,
|
|
182
|
-
Add,
|
|
183
|
-
Subtract,
|
|
184
|
-
Multiply,
|
|
185
|
-
Divide,
|
|
186
|
-
Double,
|
|
187
|
-
LessThan,
|
|
188
|
-
BooleanIdentity,
|
|
189
|
-
NaturalIdentity,
|
|
190
|
-
NaturalLessThan,
|
|
191
|
-
NaturalAdd,
|
|
192
|
-
NaturalSubtract,
|
|
193
|
-
NaturalMultiply,
|
|
194
|
-
NaturalDivide,
|
|
195
|
-
NaturalDouble,
|
|
196
|
-
} as const;
|
|
197
|
-
|
|
198
|
-
export const TOOL_IMPLEMENTATION_BY_HANDLE = {
|
|
199
|
-
'TOOL-Identity': Identity,
|
|
200
|
-
'TOOL-Add': Add,
|
|
201
|
-
'TOOL-Subtract': Subtract,
|
|
202
|
-
'TOOL-Multiply': Multiply,
|
|
203
|
-
'TOOL-Divide': Divide,
|
|
204
|
-
'TOOL-Double': Double,
|
|
205
|
-
'TOOL-LessThan': LessThan,
|
|
206
|
-
'TOOL-BooleanIdentity': BooleanIdentity,
|
|
207
|
-
'TOOL-NaturalIdentity': NaturalIdentity,
|
|
208
|
-
'TOOL-NaturalLessThan': NaturalLessThan,
|
|
209
|
-
'TOOL-NaturalAdd': NaturalAdd,
|
|
210
|
-
'TOOL-NaturalSubtract': NaturalSubtract,
|
|
211
|
-
'TOOL-NaturalMultiply': NaturalMultiply,
|
|
212
|
-
'TOOL-NaturalDivide': NaturalDivide,
|
|
213
|
-
'TOOL-NaturalDouble': NaturalDouble,
|
|
214
|
-
} as const;
|