@toolproof-core/schema 1.0.9 → 1.0.11
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/artifacts/constants.d.ts +121 -0
- package/dist/generated/artifacts/constants.js +121 -0
- package/dist/generated/artifacts/mappings.d.ts +23 -0
- package/dist/generated/artifacts/mappings.js +23 -0
- package/dist/generated/normalized/Genesis.json +117 -78
- package/dist/generated/resources/Genesis.json +489 -264
- package/dist/generated/schemas/Genesis.json +94 -61
- package/dist/generated/schemas/standalone/Job.json +9 -8
- package/dist/generated/schemas/standalone/RawStrategy.json +86 -110
- package/dist/generated/schemas/standalone/ResourceType.json +4 -4
- package/dist/generated/schemas/standalone/RunnableStrategy.json +115 -139
- package/dist/generated/schemas/standalone/StrategyRun.json +93 -117
- package/dist/generated/types/standalone/Resource_Genesis.d.ts +1 -1
- package/dist/generated/types/standalone/Resource_Job.d.ts +1 -1
- package/dist/generated/types/standalone/Resource_RawStrategy.d.ts +1 -1
- package/dist/generated/types/standalone/Resource_ResourceType.d.ts +1 -1
- package/dist/generated/types/standalone/Resource_RunnableStrategy.d.ts +1 -1
- package/dist/generated/types/types.d.ts +247 -239
- package/dist/index.d.ts +6 -3
- package/dist/index.js +5 -2
- package/dist/scripts/_lib/config.d.ts +3 -5
- package/dist/scripts/_lib/config.js +8 -14
- package/dist/scripts/generateConstantsAndMappings.d.ts +31 -0
- package/dist/scripts/generateConstantsAndMappings.js +243 -0
- package/dist/scripts/generateDependencies.js +1 -1
- package/dist/scripts/generateStandaloneType.js +2 -1
- package/dist/scripts/generateTerminals.js +2 -2
- package/dist/scripts/generateTypes.js +183 -5
- package/dist/scripts/wrapResourceTypesWithResourceShells.js +7 -3
- package/package.json +9 -10
- package/src/Genesis.json +1873 -1833
- package/src/generated/artifacts/constants.ts +122 -0
- package/src/generated/{dependencies → artifacts}/dependencyMap.json +282 -280
- package/src/generated/artifacts/mappings.ts +24 -0
- package/src/generated/{dependencies → artifacts}/terminals.json +13 -11
- package/src/generated/normalized/Genesis.json +1785 -1746
- package/src/generated/resources/Genesis.json +2833 -2608
- package/src/generated/schemas/Genesis.json +1348 -1315
- package/src/generated/schemas/standalone/Job.json +195 -194
- package/src/generated/schemas/standalone/RawStrategy.json +86 -110
- package/src/generated/schemas/standalone/ResourceType.json +106 -106
- package/src/generated/schemas/standalone/RunnableStrategy.json +645 -669
- package/src/generated/schemas/standalone/StrategyRun.json +913 -937
- package/src/generated/types/standalone/Resource_Genesis.d.ts +3 -3
- package/src/generated/types/standalone/Resource_Job.d.ts +3 -3
- package/src/generated/types/standalone/Resource_RawStrategy.d.ts +3 -3
- package/src/generated/types/standalone/Resource_ResourceType.d.ts +3 -3
- package/src/generated/types/standalone/Resource_RunnableStrategy.d.ts +3 -3
- package/src/generated/types/types.d.ts +717 -709
- package/src/index.ts +77 -70
- package/src/scripts/_lib/config.ts +207 -215
- package/src/scripts/extractSchemasFromResourceTypeShells.ts +261 -261
- package/src/scripts/generateConstantsAndMappings.ts +309 -0
- package/src/scripts/generateDependencies.ts +121 -121
- package/src/scripts/generateSchemaShims.ts +127 -127
- package/src/scripts/generateStandaloneSchema.ts +185 -185
- package/src/scripts/generateStandaloneType.ts +129 -127
- package/src/scripts/generateTerminals.ts +73 -73
- package/src/scripts/generateTypes.ts +733 -531
- package/src/scripts/normalizeAnchorsToPointers.ts +141 -141
- package/src/scripts/wrapResourceTypesWithResourceShells.ts +86 -82
- package/dist/generated/constants/constants.d.ts +0 -60
- package/dist/generated/constants/constants.js +0 -60
- package/dist/scripts/generateConstants.d.ts +0 -12
- package/dist/scripts/generateConstants.js +0 -179
- package/src/generated/constants/constants.ts +0 -61
- package/src/scripts/generateConstants.ts +0 -217
package/src/index.ts
CHANGED
|
@@ -1,70 +1,77 @@
|
|
|
1
|
-
// Re-export JSON schemas via .ts shims to avoid .json re-exports in declarations
|
|
2
|
-
export { default as SchemaGenesis } from './generated/schemas/Genesis.js';
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
6
|
-
export { default as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type {
|
|
13
|
-
|
|
14
|
-
} from './generated/types/standalone/
|
|
15
|
-
export type {
|
|
16
|
-
|
|
17
|
-
} from './generated/types/standalone/
|
|
18
|
-
export type {
|
|
19
|
-
|
|
20
|
-
} from './generated/types/standalone/
|
|
21
|
-
export type {
|
|
22
|
-
|
|
23
|
-
} from './generated/types/standalone/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
// Re-export JSON schemas via .ts shims to avoid .json re-exports in declarations
|
|
2
|
+
export { default as SchemaGenesis } from './generated/schemas/Genesis.js';
|
|
3
|
+
export { default as SchemaResourceType } from './generated/schemas/standalone/ResourceType.js';
|
|
4
|
+
export { default as SchemaJob } from './generated/schemas/standalone/Job.js';
|
|
5
|
+
export { default as SchemaRunnableStrategy } from './generated/schemas/standalone/RunnableStrategy.js';
|
|
6
|
+
export { default as SchemaStrategyRun } from './generated/schemas/standalone/StrategyRun.js';
|
|
7
|
+
export { default as ResourceGenesis } from './generated/resources/Genesis.js';
|
|
8
|
+
export { default as CONSTANTS } from './generated/artifacts/constants.js';
|
|
9
|
+
export { default as MAPPINGS } from './generated/artifacts/mappings.js';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export type {
|
|
13
|
+
Resource_Genesis as Resource_GenesisJson
|
|
14
|
+
} from './generated/types/standalone/Resource_Genesis.js';
|
|
15
|
+
export type {
|
|
16
|
+
Resource_ResourceType as Resource_ResourceTypeJson
|
|
17
|
+
} from './generated/types/standalone/Resource_ResourceType.js';
|
|
18
|
+
export type {
|
|
19
|
+
Resource_Job as Resource_JobJson
|
|
20
|
+
} from './generated/types/standalone/Resource_Job.js';
|
|
21
|
+
export type {
|
|
22
|
+
Resource_RawStrategy as Resource_RawStrategyJson
|
|
23
|
+
} from './generated/types/standalone/Resource_RawStrategy.js';
|
|
24
|
+
export type {
|
|
25
|
+
Resource_RunnableStrategy as Resource_RunnableStrategyJson
|
|
26
|
+
} from './generated/types/standalone/Resource_RunnableStrategy.js';
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export type {
|
|
30
|
+
DocumentationFacetJson,
|
|
31
|
+
NucleusFacetJson,
|
|
32
|
+
ResourceTypeIdentityJson,
|
|
33
|
+
ResourceTypeJson,
|
|
34
|
+
ResourceRoleIdentityJson,
|
|
35
|
+
ResourceRoleValueJson,
|
|
36
|
+
ResourceRoleJson,
|
|
37
|
+
ConditionalJson,
|
|
38
|
+
RoleDictJson,
|
|
39
|
+
RolesJson,
|
|
40
|
+
RoleBindingsJson,
|
|
41
|
+
ResourceIdentityJson,
|
|
42
|
+
JobStepIdentityJson,
|
|
43
|
+
BranchStepIdentityJson,
|
|
44
|
+
WhileStepIdentityJson,
|
|
45
|
+
ForStepIdentityJson,
|
|
46
|
+
JobStepJson,
|
|
47
|
+
BranchStepJson,
|
|
48
|
+
WhileStepJson,
|
|
49
|
+
ForStepJson,
|
|
50
|
+
StepKindJson,
|
|
51
|
+
StepIdentityJson,
|
|
52
|
+
StepJson,
|
|
53
|
+
CreationContextJson,
|
|
54
|
+
ResourceMissingJson,
|
|
55
|
+
ResourceInputPotentialJson,
|
|
56
|
+
ResourceOutputPotentialJson,
|
|
57
|
+
ShellMaterializedBaseJson,
|
|
58
|
+
ResourceJson,
|
|
59
|
+
StrategyStateJson,
|
|
60
|
+
StepsFacetJson,
|
|
61
|
+
RawStrategyJson,
|
|
62
|
+
RunnableStrategyIdentityJson,
|
|
63
|
+
RunnableStrategyStatusJson,
|
|
64
|
+
RunnableStrategyJson,
|
|
65
|
+
RunnableStrategyUpdateJson,
|
|
66
|
+
JobIdentityJson,
|
|
67
|
+
JobJson,
|
|
68
|
+
JsonDataJson,
|
|
69
|
+
StrategyThreadIdentityJson,
|
|
70
|
+
StrategyThreadDictJson,
|
|
71
|
+
JobStepSocketJson,
|
|
72
|
+
TimestampJson,
|
|
73
|
+
StrategyRunIdentityJson,
|
|
74
|
+
GoalIdentityJson,
|
|
75
|
+
GoalJson,
|
|
76
|
+
ErrorJson,
|
|
77
|
+
} from './generated/types/types.js';
|
|
@@ -1,215 +1,207 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration for schema generation scripts
|
|
3
|
-
* All paths are configurable via environment variables
|
|
4
|
-
* Provides sensible defaults for standard project structure
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import path from 'path';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Get environment variable with optional default
|
|
11
|
-
*/
|
|
12
|
-
function getEnv(name: string, defaultValue: string): string {
|
|
13
|
-
const value = process.env[name];
|
|
14
|
-
return value || defaultValue;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Schema configuration with required environment variables
|
|
19
|
-
*/
|
|
20
|
-
export class SchemaConfig {
|
|
21
|
-
// Base paths
|
|
22
|
-
private readonly root: string;
|
|
23
|
-
private readonly sourceDir: string;
|
|
24
|
-
private readonly sourceFile: string;
|
|
25
|
-
private readonly normalizedDir: string;
|
|
26
|
-
private readonly schemasDir: string;
|
|
27
|
-
private readonly
|
|
28
|
-
private readonly resourcesDir: string;
|
|
29
|
-
private readonly
|
|
30
|
-
private readonly
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
private readonly
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return this.baseUrl
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
*
|
|
180
|
-
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
* Throws error if required environment variables are not set
|
|
209
|
-
*/
|
|
210
|
-
export function getConfig(): SchemaConfig {
|
|
211
|
-
if (!configInstance) {
|
|
212
|
-
configInstance = new SchemaConfig();
|
|
213
|
-
}
|
|
214
|
-
return configInstance;
|
|
215
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for schema generation scripts
|
|
3
|
+
* All paths are configurable via environment variables
|
|
4
|
+
* Provides sensible defaults for standard project structure
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import path from 'path';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get environment variable with optional default
|
|
11
|
+
*/
|
|
12
|
+
function getEnv(name: string, defaultValue: string): string {
|
|
13
|
+
const value = process.env[name];
|
|
14
|
+
return value || defaultValue;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Schema configuration with required environment variables
|
|
19
|
+
*/
|
|
20
|
+
export class SchemaConfig {
|
|
21
|
+
// Base paths
|
|
22
|
+
private readonly root: string;
|
|
23
|
+
private readonly sourceDir: string;
|
|
24
|
+
private readonly sourceFile: string;
|
|
25
|
+
private readonly normalizedDir: string;
|
|
26
|
+
private readonly schemasDir: string;
|
|
27
|
+
private readonly artifactsDir: string;
|
|
28
|
+
private readonly resourcesDir: string;
|
|
29
|
+
private readonly typesSrcDir: string;
|
|
30
|
+
private readonly typesDistDir: string;
|
|
31
|
+
|
|
32
|
+
// Schema metadata
|
|
33
|
+
private readonly baseUrl: string;
|
|
34
|
+
private readonly version: string;
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
// Environment variables with sensible defaults
|
|
38
|
+
this.root = getEnv('TP_SCHEMA_ROOT', process.cwd());
|
|
39
|
+
this.sourceDir = getEnv('TP_SCHEMA_SOURCE_DIR', 'src/');
|
|
40
|
+
this.sourceFile = getEnv('TP_SCHEMA_SOURCE_FILE', 'Genesis.json');
|
|
41
|
+
this.normalizedDir = getEnv('TP_SCHEMA_NORMALIZED_DIR', 'src/generated/normalized');
|
|
42
|
+
this.schemasDir = getEnv('TP_SCHEMA_SCHEMAS_DIR', 'src/generated/schemas');
|
|
43
|
+
this.artifactsDir = getEnv('TP_SCHEMA_ARTIFACTS_DIR', 'src/generated/artifacts');
|
|
44
|
+
this.resourcesDir = getEnv('TP_SCHEMA_RESOURCES_DIR', 'src/generated/resources');
|
|
45
|
+
this.typesSrcDir = getEnv('TP_SCHEMA_TYPES_SRC_DIR', 'src/generated/types');
|
|
46
|
+
this.typesDistDir = getEnv('TP_SCHEMA_TYPES_DIST_DIR', 'dist/generated/types');
|
|
47
|
+
this.baseUrl = getEnv('TP_SCHEMA_BASE_URL', 'https://schemas.toolproof.com');
|
|
48
|
+
this.version = getEnv('TP_SCHEMA_VERSION', 'v1');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Path getters
|
|
52
|
+
getRoot(): string {
|
|
53
|
+
return this.root;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getSourceDir(): string {
|
|
57
|
+
return path.isAbsolute(this.sourceDir)
|
|
58
|
+
? this.sourceDir
|
|
59
|
+
: path.join(this.root, this.sourceDir);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getSourceFile(): string {
|
|
63
|
+
return this.sourceFile;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getSourcePath(): string {
|
|
67
|
+
return path.join(this.getSourceDir(), this.sourceFile);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getNormalizedDir(): string {
|
|
71
|
+
return path.isAbsolute(this.normalizedDir)
|
|
72
|
+
? this.normalizedDir
|
|
73
|
+
: path.join(this.root, this.normalizedDir);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getNormalizedSourceFile(): string {
|
|
77
|
+
// We keep the same basename (Genesis.json) in the generated folder.
|
|
78
|
+
// The source-of-truth Genesis.json lives under `TP_SCHEMA_SOURCE_DIR`.
|
|
79
|
+
// The generated/normalized Genesis.json lives under `TP_SCHEMA_NORMALIZED_DIR`.
|
|
80
|
+
return this.sourceFile;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getNormalizedSourcePath(): string {
|
|
84
|
+
return path.join(this.getNormalizedDir(), this.getNormalizedSourceFile());
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
getSchemasDir(): string {
|
|
88
|
+
return path.isAbsolute(this.schemasDir)
|
|
89
|
+
? this.schemasDir
|
|
90
|
+
: path.join(this.root, this.schemasDir);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
getSchemaPath(filename: string): string {
|
|
94
|
+
return path.join(this.getSchemasDir(), filename);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
getArtifactsDir(): string {
|
|
98
|
+
return path.isAbsolute(this.artifactsDir)
|
|
99
|
+
? this.artifactsDir
|
|
100
|
+
: path.join(this.root, this.artifactsDir);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getArtifactsPath(filename: string): string {
|
|
104
|
+
return path.join(this.getArtifactsDir(), filename);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
getStandaloneSchemaDir(): string {
|
|
108
|
+
return path.join(this.getSchemasDir(), 'standalone');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
getStandaloneSchemaPath(filename: string): string {
|
|
112
|
+
return path.join(this.getStandaloneSchemaDir(), filename);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
getTypesSrcDir(): string {
|
|
116
|
+
return path.isAbsolute(this.typesSrcDir)
|
|
117
|
+
? this.typesSrcDir
|
|
118
|
+
: path.join(this.root, this.typesSrcDir);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
getTypesDistDir(): string {
|
|
122
|
+
return path.isAbsolute(this.typesDistDir)
|
|
123
|
+
? this.typesDistDir
|
|
124
|
+
: path.join(this.root, this.typesDistDir);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
getTypesSrcPath(filename: string): string {
|
|
128
|
+
return path.join(this.getTypesSrcDir(), filename);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
getTypesDistPath(filename: string): string {
|
|
132
|
+
return path.join(this.getTypesDistDir(), filename);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
getStandaloneTypeSrcDir(): string {
|
|
136
|
+
return path.join(this.getTypesSrcDir(), 'standalone');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
getStandaloneTypeDistDir(): string {
|
|
140
|
+
return path.join(this.getTypesDistDir(), 'standalone');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
getStandaloneTypeSrcPath(filename: string): string {
|
|
144
|
+
return path.join(this.getStandaloneTypeSrcDir(), filename);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getStandaloneTypeDistPath(filename: string): string {
|
|
148
|
+
return path.join(this.getStandaloneTypeDistDir(), filename);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
getResourcesDir(): string {
|
|
152
|
+
return path.isAbsolute(this.resourcesDir)
|
|
153
|
+
? this.resourcesDir
|
|
154
|
+
: path.join(this.root, this.resourcesDir);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Schema URL methods
|
|
158
|
+
getBaseUrl(): string {
|
|
159
|
+
return this.baseUrl;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
getVersion(): string {
|
|
163
|
+
return this.version;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
getSchemaId(schemaName: string): string {
|
|
167
|
+
return `${this.baseUrl}/${this.version}/${schemaName}.json`;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Check if a URL matches the configured schema base URL pattern
|
|
172
|
+
*/
|
|
173
|
+
isSchemaUrl(url: string): boolean {
|
|
174
|
+
const baseUrlPattern = this.baseUrl.replace('https://', 'https?://');
|
|
175
|
+
return new RegExp(`^${baseUrlPattern}/`, 'i').test(url);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Extract schema name from URL (removes base URL and version prefix)
|
|
180
|
+
*/
|
|
181
|
+
extractSchemaName(url: string): string {
|
|
182
|
+
// Remove base URL
|
|
183
|
+
let name = url.replace(new RegExp(`^${this.baseUrl}/`, 'i'), '');
|
|
184
|
+
|
|
185
|
+
// Remove version prefix (v0/, v1/, etc.)
|
|
186
|
+
name = name.replace(/^v\d+\//, '');
|
|
187
|
+
|
|
188
|
+
// Remove .json extension
|
|
189
|
+
name = name.replace(/\.json$/, '');
|
|
190
|
+
|
|
191
|
+
return name;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Singleton instance
|
|
196
|
+
let configInstance: SchemaConfig | null = null;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Get the schema configuration singleton
|
|
200
|
+
* Throws error if required environment variables are not set
|
|
201
|
+
*/
|
|
202
|
+
export function getConfig(): SchemaConfig {
|
|
203
|
+
if (!configInstance) {
|
|
204
|
+
configInstance = new SchemaConfig();
|
|
205
|
+
}
|
|
206
|
+
return configInstance;
|
|
207
|
+
}
|