@toolproof-core/genesis 1.0.52 → 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} +68 -2
- package/dist/generated-src/lookups/mappings.d.ts +11 -0
- package/{generated-src/lookups/mappings.ts → dist/generated-src/lookups/mappings.js} +2 -3
- 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/src/utils/constantsAndMappings.d.ts +20 -2
- package/dist/src/utils/constantsAndMappings.js +113 -5
- 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 -195
- 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,269 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
function getEnv(name, defaultValue) {
|
|
3
|
+
const value = process.env[name];
|
|
4
|
+
return value || defaultValue;
|
|
5
|
+
}
|
|
6
|
+
function toPosixPath(value) {
|
|
7
|
+
return value.split(path.sep).join('/');
|
|
8
|
+
}
|
|
9
|
+
export class SchemaConfig {
|
|
10
|
+
root;
|
|
11
|
+
coreRepoRoot;
|
|
12
|
+
declarationsSourceDir;
|
|
13
|
+
resourceTypesSourceDir;
|
|
14
|
+
implementationsSourceDir;
|
|
15
|
+
schemasSourceFile;
|
|
16
|
+
resourceTypeShellsSourceFile;
|
|
17
|
+
toolsSourceFile;
|
|
18
|
+
booleansSourceFile;
|
|
19
|
+
naturalsSourceFile;
|
|
20
|
+
schemasDir;
|
|
21
|
+
lookupsDir;
|
|
22
|
+
metadataDir;
|
|
23
|
+
zodSchemasDir;
|
|
24
|
+
standaloneSchemasDir;
|
|
25
|
+
declarationsDir;
|
|
26
|
+
implementationsDir;
|
|
27
|
+
timestampedResourcesDir;
|
|
28
|
+
typesSrcDir;
|
|
29
|
+
typesDistDir;
|
|
30
|
+
standaloneTypeSrcDir;
|
|
31
|
+
standaloneTypeDistDir;
|
|
32
|
+
constructor() {
|
|
33
|
+
this.root = getEnv('TP_SCHEMA_ROOT', process.cwd());
|
|
34
|
+
this.coreRepoRoot = getEnv('TP_SCHEMA_CORE_REPO_ROOT', path.resolve(this.root, '..', '..'));
|
|
35
|
+
this.declarationsSourceDir = getEnv('TP_SCHEMA_DECLARATIONS_SOURCE_DIR', 'src/declarations');
|
|
36
|
+
this.resourceTypesSourceDir = getEnv('TP_SCHEMA_RESOURCE_TYPES_SOURCE_DIR', 'src/declarations/resourceTypes');
|
|
37
|
+
this.implementationsSourceDir = getEnv('TP_SCHEMA_IMPLEMENTATIONS_SOURCE_DIR', 'src/implementations');
|
|
38
|
+
this.schemasSourceFile = getEnv('TP_SCHEMA_SOURCE_FILE', 'schemas.json');
|
|
39
|
+
this.resourceTypeShellsSourceFile = getEnv('TP_SCHEMA_RESOURCE_TYPE_RECORDS_FILE', 'resourceTypeShells.json');
|
|
40
|
+
this.toolsSourceFile = getEnv('TP_SCHEMA_TOOLS_SOURCE_FILE', 'tools.json');
|
|
41
|
+
this.booleansSourceFile = getEnv('TP_SCHEMA_BOOLEANS_SOURCE_FILE', 'booleans.json');
|
|
42
|
+
this.naturalsSourceFile = getEnv('TP_SCHEMA_NATURALS_SOURCE_FILE', 'naturals.json');
|
|
43
|
+
this.schemasDir = getEnv('TP_SCHEMA_SCHEMAS_DIR', 'generated-src/schemas');
|
|
44
|
+
this.lookupsDir = getEnv('TP_SCHEMA_LOOKUPS_DIR', 'generated-src/lookups');
|
|
45
|
+
this.metadataDir = getEnv('TP_SCHEMA_METADATA_DIR', 'generated-src/metadata');
|
|
46
|
+
this.zodSchemasDir = getEnv('TP_SCHEMA_ZOD_SCHEMAS_DIR', 'generated-src/schemas/zod');
|
|
47
|
+
this.standaloneSchemasDir = getEnv('TP_SCHEMA_STANDALONE_SCHEMAS_DIR', 'generated-src/schemas/standalone');
|
|
48
|
+
this.declarationsDir = getEnv('TP_SCHEMA_DECLARATIONS_DIR', 'generated-src/declarations');
|
|
49
|
+
this.implementationsDir = getEnv('TP_SCHEMA_IMPLEMENTATIONS_DIR', 'generated-src/implementations');
|
|
50
|
+
this.timestampedResourcesDir = getEnv('TP_SCHEMA_TIMESTAMPED_RESOURCES_DIR', 'generated-src/timestampedResources');
|
|
51
|
+
this.typesSrcDir = getEnv('TP_SCHEMA_TYPES_SRC_DIR', 'generated-src/types');
|
|
52
|
+
this.typesDistDir = getEnv('TP_SCHEMA_TYPES_DIST_DIR', 'dist/generated-src/types');
|
|
53
|
+
this.standaloneTypeSrcDir = getEnv('TP_SCHEMA_STANDALONE_TYPE_SRC_DIR', 'generated-src/types/standalone');
|
|
54
|
+
this.standaloneTypeDistDir = getEnv('TP_SCHEMA_STANDALONE_TYPE_DIST_DIR', 'dist/generated-src/types/standalone');
|
|
55
|
+
}
|
|
56
|
+
getRoot() {
|
|
57
|
+
return this.root;
|
|
58
|
+
}
|
|
59
|
+
getCoreRepoRoot() {
|
|
60
|
+
return path.isAbsolute(this.coreRepoRoot)
|
|
61
|
+
? this.coreRepoRoot
|
|
62
|
+
: path.join(this.root, this.coreRepoRoot);
|
|
63
|
+
}
|
|
64
|
+
getDeclarationsSourceDir() {
|
|
65
|
+
return path.isAbsolute(this.declarationsSourceDir)
|
|
66
|
+
? this.declarationsSourceDir
|
|
67
|
+
: path.join(this.root, this.declarationsSourceDir);
|
|
68
|
+
}
|
|
69
|
+
getResourceTypesSourceDir() {
|
|
70
|
+
return path.isAbsolute(this.resourceTypesSourceDir)
|
|
71
|
+
? this.resourceTypesSourceDir
|
|
72
|
+
: path.join(this.root, this.resourceTypesSourceDir);
|
|
73
|
+
}
|
|
74
|
+
getImplementationsSourceDir() {
|
|
75
|
+
return path.isAbsolute(this.implementationsSourceDir)
|
|
76
|
+
? this.implementationsSourceDir
|
|
77
|
+
: path.join(this.root, this.implementationsSourceDir);
|
|
78
|
+
}
|
|
79
|
+
getSchemasSourceFile() {
|
|
80
|
+
return this.schemasSourceFile;
|
|
81
|
+
}
|
|
82
|
+
getSchemasSourcePath() {
|
|
83
|
+
return path.join(this.getResourceTypesSourceDir(), this.getSchemasSourceFile());
|
|
84
|
+
}
|
|
85
|
+
getResourceTypeShellsSourceFile() {
|
|
86
|
+
return this.resourceTypeShellsSourceFile;
|
|
87
|
+
}
|
|
88
|
+
getResourceTypeShellsSourcePath() {
|
|
89
|
+
return path.join(this.getResourceTypesSourceDir(), this.getResourceTypeShellsSourceFile());
|
|
90
|
+
}
|
|
91
|
+
getToolsSourcePath() {
|
|
92
|
+
return path.join(this.getDeclarationsSourceDir(), this.toolsSourceFile);
|
|
93
|
+
}
|
|
94
|
+
getBooleansSourcePath() {
|
|
95
|
+
return path.join(this.getDeclarationsSourceDir(), this.booleansSourceFile);
|
|
96
|
+
}
|
|
97
|
+
getNaturalsSourcePath() {
|
|
98
|
+
return path.join(this.getDeclarationsSourceDir(), this.naturalsSourceFile);
|
|
99
|
+
}
|
|
100
|
+
getSchemasDir() {
|
|
101
|
+
return path.isAbsolute(this.schemasDir)
|
|
102
|
+
? this.schemasDir
|
|
103
|
+
: path.join(this.root, this.schemasDir);
|
|
104
|
+
}
|
|
105
|
+
getSchemasPath() {
|
|
106
|
+
return path.join(this.getSchemasDir(), this.getSchemasSourceFile());
|
|
107
|
+
}
|
|
108
|
+
getZodSchemasDir() {
|
|
109
|
+
return path.isAbsolute(this.zodSchemasDir)
|
|
110
|
+
? this.zodSchemasDir
|
|
111
|
+
: path.join(this.root, this.zodSchemasDir);
|
|
112
|
+
}
|
|
113
|
+
getZodSchemaPath(filename) {
|
|
114
|
+
return path.join(this.getZodSchemasDir(), filename);
|
|
115
|
+
}
|
|
116
|
+
getZodIndexPath() {
|
|
117
|
+
return this.getZodSchemaPath('index.ts');
|
|
118
|
+
}
|
|
119
|
+
getLookupsDir() {
|
|
120
|
+
return path.isAbsolute(this.lookupsDir)
|
|
121
|
+
? this.lookupsDir
|
|
122
|
+
: path.join(this.root, this.lookupsDir);
|
|
123
|
+
}
|
|
124
|
+
getLookupsPath(filename) {
|
|
125
|
+
return path.join(this.getLookupsDir(), filename);
|
|
126
|
+
}
|
|
127
|
+
getConstantsPath() {
|
|
128
|
+
return this.getLookupsPath('constants.ts');
|
|
129
|
+
}
|
|
130
|
+
getMappingsPath() {
|
|
131
|
+
return this.getLookupsPath('mappings.ts');
|
|
132
|
+
}
|
|
133
|
+
getMetadataDir() {
|
|
134
|
+
return path.isAbsolute(this.metadataDir)
|
|
135
|
+
? this.metadataDir
|
|
136
|
+
: path.join(this.root, this.metadataDir);
|
|
137
|
+
}
|
|
138
|
+
getMetadataPath(filename) {
|
|
139
|
+
return path.join(this.getMetadataDir(), filename);
|
|
140
|
+
}
|
|
141
|
+
getDependencyMapPath() {
|
|
142
|
+
return this.getMetadataPath('dependencyMap.json');
|
|
143
|
+
}
|
|
144
|
+
getTerminalsPath() {
|
|
145
|
+
return this.getMetadataPath('terminals.json');
|
|
146
|
+
}
|
|
147
|
+
getCoreProjectionPath() {
|
|
148
|
+
return this.getMetadataPath('Core.json');
|
|
149
|
+
}
|
|
150
|
+
getLegacyGeneratedDir() {
|
|
151
|
+
return path.join(this.root, 'generated-src');
|
|
152
|
+
}
|
|
153
|
+
getGeneratedDir() {
|
|
154
|
+
return path.dirname(this.getSchemasDir());
|
|
155
|
+
}
|
|
156
|
+
getCoreProjectionExcludedRelativePrefixes() {
|
|
157
|
+
const coreRepoRoot = this.getCoreRepoRoot();
|
|
158
|
+
return [this.getLegacyGeneratedDir(), this.getGeneratedDir()].map((dirPath) => {
|
|
159
|
+
return toPosixPath(path.relative(coreRepoRoot, dirPath));
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
getStandaloneSchemasDir() {
|
|
163
|
+
return path.isAbsolute(this.standaloneSchemasDir)
|
|
164
|
+
? this.standaloneSchemasDir
|
|
165
|
+
: path.join(this.root, this.standaloneSchemasDir);
|
|
166
|
+
}
|
|
167
|
+
getStandaloneSchemaPath(filename) {
|
|
168
|
+
return path.join(this.getStandaloneSchemasDir(), filename);
|
|
169
|
+
}
|
|
170
|
+
getDeclarationsDir() {
|
|
171
|
+
return path.isAbsolute(this.declarationsDir)
|
|
172
|
+
? this.declarationsDir
|
|
173
|
+
: path.join(this.root, this.declarationsDir);
|
|
174
|
+
}
|
|
175
|
+
getImplementationsDir() {
|
|
176
|
+
return path.isAbsolute(this.implementationsDir)
|
|
177
|
+
? this.implementationsDir
|
|
178
|
+
: path.join(this.root, this.implementationsDir);
|
|
179
|
+
}
|
|
180
|
+
getDeclarationPath(filename) {
|
|
181
|
+
return path.join(this.getDeclarationsDir(), filename);
|
|
182
|
+
}
|
|
183
|
+
getImplementationPath(filename) {
|
|
184
|
+
return path.join(this.getImplementationsDir(), filename);
|
|
185
|
+
}
|
|
186
|
+
getResourceTypesDeclarationPath() {
|
|
187
|
+
return this.getDeclarationPath('resourceTypes.json');
|
|
188
|
+
}
|
|
189
|
+
getToolsDeclarationPath() {
|
|
190
|
+
return this.getDeclarationPath('tools.json');
|
|
191
|
+
}
|
|
192
|
+
getBooleansDeclarationPath() {
|
|
193
|
+
return this.getDeclarationPath('booleans.json');
|
|
194
|
+
}
|
|
195
|
+
getNaturalsDeclarationPath() {
|
|
196
|
+
return this.getDeclarationPath('naturals.json');
|
|
197
|
+
}
|
|
198
|
+
getTimestampedResourcesDir() {
|
|
199
|
+
return path.isAbsolute(this.timestampedResourcesDir)
|
|
200
|
+
? this.timestampedResourcesDir
|
|
201
|
+
: path.join(this.root, this.timestampedResourcesDir);
|
|
202
|
+
}
|
|
203
|
+
getTimestampedResourcePath(filename) {
|
|
204
|
+
return path.join(this.getTimestampedResourcesDir(), filename);
|
|
205
|
+
}
|
|
206
|
+
getResourceTypeTimestampedResourcesPath() {
|
|
207
|
+
return this.getTimestampedResourcePath('resourceTypes.json');
|
|
208
|
+
}
|
|
209
|
+
getToolTimestampedResourcesPath() {
|
|
210
|
+
return this.getTimestampedResourcePath('tools.json');
|
|
211
|
+
}
|
|
212
|
+
getBooleanTimestampedResourcesPath() {
|
|
213
|
+
return this.getTimestampedResourcePath('booleans.json');
|
|
214
|
+
}
|
|
215
|
+
getNaturalTimestampedResourcesPath() {
|
|
216
|
+
return this.getTimestampedResourcePath('naturals.json');
|
|
217
|
+
}
|
|
218
|
+
getTypesSrcDir() {
|
|
219
|
+
return path.isAbsolute(this.typesSrcDir)
|
|
220
|
+
? this.typesSrcDir
|
|
221
|
+
: path.join(this.root, this.typesSrcDir);
|
|
222
|
+
}
|
|
223
|
+
getTypesDistDir() {
|
|
224
|
+
return path.isAbsolute(this.typesDistDir)
|
|
225
|
+
? this.typesDistDir
|
|
226
|
+
: path.join(this.root, this.typesDistDir);
|
|
227
|
+
}
|
|
228
|
+
getTypesSrcPath(filename) {
|
|
229
|
+
return path.join(this.getTypesSrcDir(), filename);
|
|
230
|
+
}
|
|
231
|
+
getTypesDistPath(filename) {
|
|
232
|
+
return path.join(this.getTypesDistDir(), filename);
|
|
233
|
+
}
|
|
234
|
+
getTypesDtsSrcPath() {
|
|
235
|
+
return this.getTypesSrcPath('types.d.ts');
|
|
236
|
+
}
|
|
237
|
+
getTypesDtsDistPath() {
|
|
238
|
+
return this.getTypesDistPath('types.d.ts');
|
|
239
|
+
}
|
|
240
|
+
getTypesJsSrcPath() {
|
|
241
|
+
return this.getTypesSrcPath('types.js');
|
|
242
|
+
}
|
|
243
|
+
getTypesJsDistPath() {
|
|
244
|
+
return this.getTypesDistPath('types.js');
|
|
245
|
+
}
|
|
246
|
+
getStandaloneTypeSrcDir() {
|
|
247
|
+
return path.isAbsolute(this.standaloneTypeSrcDir)
|
|
248
|
+
? this.standaloneTypeSrcDir
|
|
249
|
+
: path.join(this.root, this.standaloneTypeSrcDir);
|
|
250
|
+
}
|
|
251
|
+
getStandaloneTypeDistDir() {
|
|
252
|
+
return path.isAbsolute(this.standaloneTypeDistDir)
|
|
253
|
+
? this.standaloneTypeDistDir
|
|
254
|
+
: path.join(this.root, this.standaloneTypeDistDir);
|
|
255
|
+
}
|
|
256
|
+
getStandaloneTypeSrcPath(filename) {
|
|
257
|
+
return path.join(this.getStandaloneTypeSrcDir(), filename);
|
|
258
|
+
}
|
|
259
|
+
getStandaloneTypeDistPath(filename) {
|
|
260
|
+
return path.join(this.getStandaloneTypeDistDir(), filename);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
let configInstance = null;
|
|
264
|
+
export function getConfig() {
|
|
265
|
+
if (!configInstance) {
|
|
266
|
+
configInstance = new SchemaConfig();
|
|
267
|
+
}
|
|
268
|
+
return configInstance;
|
|
269
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
import { extractGeneratedConstantsAndMappings, renderConstantsTs, renderMappingsTs, } from '../src/utils/constantsAndMappings.js';
|
|
5
|
+
function main() {
|
|
6
|
+
try {
|
|
7
|
+
const config = getConfig();
|
|
8
|
+
const inPath = config.getSchemasPath();
|
|
9
|
+
const resourceTypeShellsPath = config.getResourceTypeShellsSourcePath();
|
|
10
|
+
const toolsPath = config.getToolsSourcePath();
|
|
11
|
+
const outConstantsPath = config.getConstantsPath();
|
|
12
|
+
const outMappingsPath = config.getMappingsPath();
|
|
13
|
+
if (!fs.existsSync(inPath)) {
|
|
14
|
+
throw new Error(`Generated schemas file not found at ${inPath}. Run normalizeAnchorsToPointers first.`);
|
|
15
|
+
}
|
|
16
|
+
if (!fs.existsSync(resourceTypeShellsPath)) {
|
|
17
|
+
throw new Error(`Resource type records source file not found at ${resourceTypeShellsPath}`);
|
|
18
|
+
}
|
|
19
|
+
if (!fs.existsSync(toolsPath)) {
|
|
20
|
+
throw new Error(`Tools source file not found at ${toolsPath}`);
|
|
21
|
+
}
|
|
22
|
+
const raw = fs.readFileSync(inPath, 'utf8');
|
|
23
|
+
const doc = JSON.parse(raw);
|
|
24
|
+
const resourceTypeShells = JSON.parse(fs.readFileSync(resourceTypeShellsPath, 'utf8'));
|
|
25
|
+
const tools = JSON.parse(fs.readFileSync(toolsPath, 'utf8'));
|
|
26
|
+
const toolRecords = Object.fromEntries(tools.map((tool, index) => [String(index), tool]));
|
|
27
|
+
const { CONSTANTS, MAPPINGS } = extractGeneratedConstantsAndMappings(doc, resourceTypeShells, toolRecords);
|
|
28
|
+
const constantsTs = renderConstantsTs(CONSTANTS);
|
|
29
|
+
const mappingsTs = renderMappingsTs(MAPPINGS);
|
|
30
|
+
fs.mkdirSync(path.dirname(outConstantsPath), { recursive: true });
|
|
31
|
+
fs.writeFileSync(outConstantsPath, constantsTs, 'utf8');
|
|
32
|
+
fs.writeFileSync(outMappingsPath, mappingsTs, 'utf8');
|
|
33
|
+
console.log(`Wrote constants to ${outConstantsPath}`);
|
|
34
|
+
console.log(`Wrote mappings to ${outMappingsPath}`);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error(`Error generating constants/mappings: ${error?.message ?? error}`);
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
import { compareNodes, shouldExclude, toPosixPath, } from '../src/utils/coreProjection.js';
|
|
5
|
+
function readProjectionNode(rootPath, currentPath, excludedRelativePathPrefixes) {
|
|
6
|
+
const relativePath = currentPath === rootPath
|
|
7
|
+
? '.'
|
|
8
|
+
: toPosixPath(path.relative(rootPath, currentPath));
|
|
9
|
+
const children = [];
|
|
10
|
+
const entries = fs.readdirSync(currentPath, { withFileTypes: true });
|
|
11
|
+
for (const entry of entries) {
|
|
12
|
+
const fullPath = path.join(currentPath, entry.name);
|
|
13
|
+
const entryRelativePath = toPosixPath(path.relative(rootPath, fullPath));
|
|
14
|
+
if (shouldExclude(entryRelativePath, entry.isDirectory(), excludedRelativePathPrefixes)) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (entry.isDirectory()) {
|
|
18
|
+
children.push(readProjectionNode(rootPath, fullPath, excludedRelativePathPrefixes));
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (entry.isFile()) {
|
|
22
|
+
children.push({
|
|
23
|
+
kind: 'file',
|
|
24
|
+
name: entry.name,
|
|
25
|
+
path: entryRelativePath,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
children.sort(compareNodes);
|
|
30
|
+
return {
|
|
31
|
+
kind: 'directory',
|
|
32
|
+
name: path.basename(currentPath),
|
|
33
|
+
path: relativePath,
|
|
34
|
+
children,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function main() {
|
|
38
|
+
try {
|
|
39
|
+
const config = getConfig();
|
|
40
|
+
const rootPath = config.getCoreRepoRoot();
|
|
41
|
+
const outPath = config.getCoreProjectionPath();
|
|
42
|
+
const excludedRelativePathPrefixes = config.getCoreProjectionExcludedRelativePrefixes();
|
|
43
|
+
if (!fs.existsSync(rootPath)) {
|
|
44
|
+
throw new Error(`Core repo root not found at ${rootPath}`);
|
|
45
|
+
}
|
|
46
|
+
const projection = readProjectionNode(rootPath, rootPath, excludedRelativePathPrefixes);
|
|
47
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
48
|
+
fs.writeFileSync(outPath, `${JSON.stringify(projection, null, 4)}\n`, 'utf8');
|
|
49
|
+
console.log(`Wrote Core projection to ${outPath}`);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error(error?.message ?? error);
|
|
53
|
+
process.exitCode = 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
import { generateResourceTypes } from '../src/utils/resourceTypes.js';
|
|
5
|
+
// IMPURE: Script entrypoint (config + filesystem I/O + console + process exit code).
|
|
6
|
+
function main() {
|
|
7
|
+
try {
|
|
8
|
+
const config = getConfig();
|
|
9
|
+
const schemasPath = config.getSchemasPath();
|
|
10
|
+
const resourceTypeShellsPath = config.getResourceTypeShellsSourcePath();
|
|
11
|
+
if (!fs.existsSync(schemasPath)) {
|
|
12
|
+
throw new Error(`Generated schemas file not found at ${schemasPath}`);
|
|
13
|
+
}
|
|
14
|
+
if (!fs.existsSync(resourceTypeShellsPath)) {
|
|
15
|
+
throw new Error(`Resource type records source file not found at ${resourceTypeShellsPath}`);
|
|
16
|
+
}
|
|
17
|
+
const schemas = JSON.parse(fs.readFileSync(schemasPath, 'utf-8'));
|
|
18
|
+
const resourceTypeShells = JSON.parse(fs.readFileSync(resourceTypeShellsPath, 'utf-8'));
|
|
19
|
+
const resourceTypes = generateResourceTypes(schemas, resourceTypeShells);
|
|
20
|
+
writeJsonFile(config.getResourceTypesDeclarationPath(), resourceTypes);
|
|
21
|
+
console.log(`Generated ${resourceTypes.length} resource type declarations -> ${config.getResourceTypesDeclarationPath()}`);
|
|
22
|
+
projectDeclaration(config.getToolsSourcePath(), config.getToolsDeclarationPath(), 'tool');
|
|
23
|
+
projectDeclaration(config.getBooleansSourcePath(), config.getBooleansDeclarationPath(), 'boolean');
|
|
24
|
+
projectDeclaration(config.getNaturalsSourcePath(), config.getNaturalsDeclarationPath(), 'natural');
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error(error?.message ?? error);
|
|
28
|
+
process.exitCode = 1;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function projectDeclaration(sourcePath, outPath, label) {
|
|
32
|
+
if (!fs.existsSync(sourcePath)) {
|
|
33
|
+
throw new Error(`${label} declarations source file not found at ${sourcePath}`);
|
|
34
|
+
}
|
|
35
|
+
const parsed = JSON.parse(fs.readFileSync(sourcePath, 'utf-8'));
|
|
36
|
+
writeJsonFile(outPath, parsed);
|
|
37
|
+
console.log(`Projected ${label} declarations -> ${outPath}`);
|
|
38
|
+
}
|
|
39
|
+
function writeJsonFile(outPath, value) {
|
|
40
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
41
|
+
fs.writeFileSync(outPath, JSON.stringify(value, null, 4), 'utf-8');
|
|
42
|
+
}
|
|
43
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
import { generateDependencyMap } from '../src/utils/schemaDependencies.js';
|
|
5
|
+
function main() {
|
|
6
|
+
try {
|
|
7
|
+
const config = getConfig();
|
|
8
|
+
const inPath = config.getSchemasPath();
|
|
9
|
+
const outPath = config.getDependencyMapPath();
|
|
10
|
+
if (!fs.existsSync(inPath)) {
|
|
11
|
+
throw new Error(`Generated schemas file not found at ${inPath}. Run normalizeAnchorsToPointers first.`);
|
|
12
|
+
}
|
|
13
|
+
const raw = fs.readFileSync(inPath, 'utf8');
|
|
14
|
+
const doc = JSON.parse(raw);
|
|
15
|
+
const dependencyMap = generateDependencyMap(doc);
|
|
16
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
17
|
+
fs.writeFileSync(outPath, JSON.stringify(dependencyMap, null, 4), 'utf8');
|
|
18
|
+
console.log(`Wrote dependency map to ${outPath}`);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error(error?.message ?? error);
|
|
22
|
+
process.exitCode = 1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
function main() {
|
|
5
|
+
try {
|
|
6
|
+
const config = getConfig();
|
|
7
|
+
const sourceDir = config.getImplementationsSourceDir();
|
|
8
|
+
const outDir = config.getImplementationsDir();
|
|
9
|
+
if (!fs.existsSync(sourceDir)) {
|
|
10
|
+
throw new Error(`Implementations source directory not found at ${sourceDir}`);
|
|
11
|
+
}
|
|
12
|
+
const copiedFileCount = copyImplementationDirectory(sourceDir, outDir);
|
|
13
|
+
console.log(`Projected ${copiedFileCount} implementation file(s) -> ${outDir}`);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.error(error?.message ?? error);
|
|
17
|
+
process.exitCode = 1;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function copyImplementationDirectory(sourceDir, outDir) {
|
|
21
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
22
|
+
let copiedFileCount = 0;
|
|
23
|
+
for (const dirent of fs.readdirSync(sourceDir, { withFileTypes: true })) {
|
|
24
|
+
const sourcePath = path.join(sourceDir, dirent.name);
|
|
25
|
+
const outPath = path.join(outDir, dirent.name);
|
|
26
|
+
if (dirent.isDirectory()) {
|
|
27
|
+
copiedFileCount += copyImplementationDirectory(sourcePath, outPath);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (!dirent.isFile() || !dirent.name.endsWith('.ts')) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const sourceContent = fs.readFileSync(sourcePath, 'utf8');
|
|
34
|
+
const outContent = rewriteGeneratedImportPaths(sourceContent);
|
|
35
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
36
|
+
fs.writeFileSync(outPath, outContent, 'utf8');
|
|
37
|
+
console.log(`Projected implementation -> ${outPath}`);
|
|
38
|
+
copiedFileCount += 1;
|
|
39
|
+
}
|
|
40
|
+
return copiedFileCount;
|
|
41
|
+
}
|
|
42
|
+
function rewriteGeneratedImportPaths(source) {
|
|
43
|
+
return source.replaceAll('../../generated-src/', '../');
|
|
44
|
+
}
|
|
45
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
import { generateResourceTypes } from '../src/utils/resourceTypes.js';
|
|
5
|
+
/**
|
|
6
|
+
* Combine resource type records with matching schemas as projectionSchema.
|
|
7
|
+
*/
|
|
8
|
+
// IMPURE: Script entrypoint (config + filesystem I/O + console + process exit code).
|
|
9
|
+
function main() {
|
|
10
|
+
try {
|
|
11
|
+
const config = getConfig();
|
|
12
|
+
const schemasPath = config.getSchemasPath();
|
|
13
|
+
const resourceTypeShellsPath = config.getResourceTypeShellsSourcePath();
|
|
14
|
+
const outPath = config.getResourceTypesDeclarationPath();
|
|
15
|
+
if (!fs.existsSync(schemasPath)) {
|
|
16
|
+
throw new Error(`Generated schemas file not found at ${schemasPath}`);
|
|
17
|
+
}
|
|
18
|
+
if (!fs.existsSync(resourceTypeShellsPath)) {
|
|
19
|
+
throw new Error(`Resource type records source file not found at ${resourceTypeShellsPath}`);
|
|
20
|
+
}
|
|
21
|
+
const schemas = JSON.parse(fs.readFileSync(schemasPath, 'utf-8'));
|
|
22
|
+
const resourceTypeShells = JSON.parse(fs.readFileSync(resourceTypeShellsPath, 'utf-8'));
|
|
23
|
+
const resourceTypes = generateResourceTypes(schemas, resourceTypeShells);
|
|
24
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
25
|
+
fs.writeFileSync(outPath, JSON.stringify(resourceTypes, null, 4), 'utf-8');
|
|
26
|
+
console.log(`Generated ${Object.keys(resourceTypes).length} resource types -> ${outPath}`);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error(error?.message ?? error);
|
|
30
|
+
process.exitCode = 1;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getConfig } from './_lib/config.js';
|
|
4
|
+
import { getShimsForFiles } from '../src/utils/schemaShims.js';
|
|
5
|
+
function main() {
|
|
6
|
+
try {
|
|
7
|
+
const config = getConfig();
|
|
8
|
+
let totalCount = 0;
|
|
9
|
+
totalCount += writeShimsForDirectory(config.getSchemasDir(), 'schema', 'schema');
|
|
10
|
+
totalCount += writeShimsForDirectory(config.getStandaloneSchemasDir(), 'schema', 'standalone schema');
|
|
11
|
+
totalCount += writeShimsForDirectory(config.getDeclarationsDir(), 'declarations', 'declaration');
|
|
12
|
+
totalCount += writeShimsForDirectory(config.getTimestampedResourcesDir(), 'timestampedResources', 'timestamped resource');
|
|
13
|
+
console.log(`Generated ${totalCount} total TypeScript shims`);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.error(error?.message ?? error);
|
|
17
|
+
process.exitCode = 1;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function listJsonFiles(dirPath) {
|
|
21
|
+
if (!fs.existsSync(dirPath)) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
return fs
|
|
25
|
+
.readdirSync(dirPath)
|
|
26
|
+
.filter((fileName) => fileName.endsWith('.json') && !fileName.startsWith('.'));
|
|
27
|
+
}
|
|
28
|
+
function writeShimsForDirectory(dirPath, variableName, label) {
|
|
29
|
+
const jsonFiles = listJsonFiles(dirPath);
|
|
30
|
+
const shims = getShimsForFiles(jsonFiles, variableName);
|
|
31
|
+
for (const [tsFile, content] of Object.entries(shims)) {
|
|
32
|
+
const outPath = path.join(dirPath, tsFile);
|
|
33
|
+
fs.writeFileSync(outPath, content, 'utf8');
|
|
34
|
+
console.log(`Generated ${tsFile} in ${dirPath}`);
|
|
35
|
+
}
|
|
36
|
+
console.log(`Generated ${jsonFiles.length} TypeScript ${label} shims in ${dirPath}`);
|
|
37
|
+
return jsonFiles.length;
|
|
38
|
+
}
|
|
39
|
+
void main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import { getConfig } from './_lib/config.js';
|
|
3
|
+
import { generateStandaloneSchemas } from '../src/utils/standaloneSchemas.js';
|
|
4
|
+
/**
|
|
5
|
+
* Create standalone JSON Schemas for each resource type record.
|
|
6
|
+
*/
|
|
7
|
+
// IMPURE: Script entrypoint (config + filesystem I/O + console + process exit code).
|
|
8
|
+
function main() {
|
|
9
|
+
try {
|
|
10
|
+
const config = getConfig();
|
|
11
|
+
const schemasPath = config.getSchemasPath();
|
|
12
|
+
const resourceTypeShellsPath = config.getResourceTypeShellsSourcePath();
|
|
13
|
+
if (!fs.existsSync(schemasPath)) {
|
|
14
|
+
throw new Error(`Generated schemas file not found at ${schemasPath}`);
|
|
15
|
+
}
|
|
16
|
+
if (!fs.existsSync(resourceTypeShellsPath)) {
|
|
17
|
+
throw new Error(`Resource type records source file not found at ${resourceTypeShellsPath}`);
|
|
18
|
+
}
|
|
19
|
+
const schemasDocument = JSON.parse(fs.readFileSync(schemasPath, 'utf-8'));
|
|
20
|
+
const resourceTypeShells = JSON.parse(fs.readFileSync(resourceTypeShellsPath, 'utf-8'));
|
|
21
|
+
const names = Object.keys(resourceTypeShells);
|
|
22
|
+
const { standaloneSchemas, warnings } = generateStandaloneSchemas(schemasDocument, names);
|
|
23
|
+
for (const warning of warnings)
|
|
24
|
+
console.warn(warning);
|
|
25
|
+
fs.mkdirSync(config.getStandaloneSchemasDir(), { recursive: true });
|
|
26
|
+
for (const [name, standaloneSchema] of Object.entries(standaloneSchemas)) {
|
|
27
|
+
const outPath = config.getStandaloneSchemaPath(`${name}.json`);
|
|
28
|
+
fs.writeFileSync(outPath, JSON.stringify(standaloneSchema, null, 2) + '\n');
|
|
29
|
+
console.log(`Created standalone schema '${name}' -> ${outPath}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error(error?.message ?? error);
|
|
34
|
+
process.exitCode = 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import { getConfig } from './_lib/config.js';
|
|
3
|
+
import { generateStandaloneTypeArtifacts, validateStandaloneSchemaForWarnings, } from '../src/utils/standaloneTypes.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
|
+
fs.mkdirSync(config.getStandaloneTypeSrcDir(), { recursive: true });
|
|
14
|
+
fs.mkdirSync(config.getStandaloneTypeDistDir(), { recursive: true });
|
|
15
|
+
for (const name of names) {
|
|
16
|
+
const schemaPath = config.getStandaloneSchemaPath(`${name}.json`);
|
|
17
|
+
if (!fs.existsSync(schemaPath)) {
|
|
18
|
+
throw new Error(`Standalone schema file not found at ${schemaPath}. Run generateStandaloneSchemas first.`);
|
|
19
|
+
}
|
|
20
|
+
const parsed = JSON.parse(fs.readFileSync(schemaPath, 'utf8'));
|
|
21
|
+
for (const warning of validateStandaloneSchemaForWarnings(parsed))
|
|
22
|
+
console.warn(warning);
|
|
23
|
+
const artifacts = generateStandaloneTypeArtifacts(name);
|
|
24
|
+
fs.writeFileSync(config.getStandaloneTypeSrcPath(artifacts.dtsFileName), artifacts.dtsContent, 'utf8');
|
|
25
|
+
fs.writeFileSync(config.getStandaloneTypeDistPath(artifacts.dtsFileName), artifacts.dtsContent, 'utf8');
|
|
26
|
+
fs.writeFileSync(config.getStandaloneTypeSrcPath(artifacts.jsFileName), artifacts.jsContent, 'utf8');
|
|
27
|
+
fs.writeFileSync(config.getStandaloneTypeDistPath(artifacts.jsFileName), artifacts.jsContent, 'utf8');
|
|
28
|
+
console.log(`Wrote ${config.getStandaloneTypeSrcPath(artifacts.dtsFileName)}`);
|
|
29
|
+
console.log(`Wrote ${config.getStandaloneTypeSrcPath(artifacts.jsFileName)}`);
|
|
30
|
+
console.log(`Wrote ${config.getStandaloneTypeDistPath(artifacts.dtsFileName)}`);
|
|
31
|
+
console.log(`Wrote ${config.getStandaloneTypeDistPath(artifacts.jsFileName)}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error(error?.message ?? error);
|
|
36
|
+
process.exitCode = 1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|