@toolproof-core/schema 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/generated/dependencyMap.json +292 -0
  2. package/dist/generated/normalized/Genesis.d.ts +2 -0
  3. package/dist/generated/normalized/Genesis.js +2 -0
  4. package/dist/generated/normalized/Genesis.json +2000 -0
  5. package/dist/generated/resources/Genesis.d.ts +2 -0
  6. package/dist/generated/resources/Genesis.js +2 -0
  7. package/dist/generated/resources/Genesis.json +2899 -0
  8. package/dist/generated/schemas/Genesis.d.ts +2 -0
  9. package/dist/generated/schemas/Genesis.js +2 -0
  10. package/dist/generated/schemas/Genesis.json +1458 -0
  11. package/dist/generated/schemas/standalone/Goal.d.ts +2 -0
  12. package/dist/generated/schemas/standalone/Goal.js +2 -0
  13. package/dist/generated/schemas/standalone/Goal.json +86 -0
  14. package/dist/generated/schemas/standalone/Job.d.ts +2 -0
  15. package/dist/generated/schemas/standalone/Job.js +2 -0
  16. package/dist/generated/schemas/standalone/Job.json +236 -0
  17. package/dist/generated/schemas/standalone/RawStrategy.d.ts +2 -0
  18. package/dist/generated/schemas/standalone/RawStrategy.js +2 -0
  19. package/dist/generated/schemas/standalone/RawStrategy.json +642 -0
  20. package/dist/generated/schemas/standalone/ResourceType.d.ts +2 -0
  21. package/dist/generated/schemas/standalone/ResourceType.js +2 -0
  22. package/dist/generated/schemas/standalone/ResourceType.json +140 -0
  23. package/dist/generated/schemas/standalone/RunnableStrategy.d.ts +2 -0
  24. package/dist/generated/schemas/standalone/RunnableStrategy.js +2 -0
  25. package/dist/generated/schemas/standalone/RunnableStrategy.json +712 -0
  26. package/dist/generated/schemas/standalone/StrategyRun.d.ts +2 -0
  27. package/dist/generated/schemas/standalone/StrategyRun.js +2 -0
  28. package/dist/generated/schemas/standalone/StrategyRun.json +994 -0
  29. package/dist/index.d.ts +13 -0
  30. package/dist/index.js +7 -0
  31. package/package.json +9 -8
  32. package/src/Genesis.json +1999 -1999
  33. package/src/generated/types/standalone/Resource_Genesis.js +1 -1
  34. package/src/generated/types/standalone/Resource_Job.js +1 -1
  35. package/src/generated/types/standalone/Resource_RawStrategy.js +1 -1
  36. package/src/generated/types/standalone/Resource_ResourceType.js +1 -1
  37. package/src/generated/types/standalone/Resource_RunnableStrategy.js +1 -1
  38. package/src/index.ts +93 -1
  39. package/src/scripts/_lib/config.ts +205 -205
  40. package/src/scripts/extractSchemasFromResourceTypeShells.ts +218 -218
  41. package/src/scripts/generateDependencies.ts +120 -120
  42. package/src/scripts/generateSchemaShims.ts +135 -135
  43. package/src/scripts/generateStandaloneSchema.ts +175 -175
  44. package/src/scripts/generateStandaloneType.ts +119 -119
  45. package/src/scripts/generateTypes.ts +614 -614
  46. package/src/scripts/normalizeAnchorsToPointers.ts +123 -123
  47. package/src/scripts/wrapResourceTypesWithResourceShells.ts +84 -84
@@ -1 +1 @@
1
- export {}
1
+ export {}
@@ -1 +1 @@
1
- export {}
1
+ export {}
@@ -1 +1 @@
1
- export {}
1
+ export {}
@@ -1 +1 @@
1
- export {}
1
+ export {}
@@ -1 +1 @@
1
- export {}
1
+ export {}
package/src/index.ts CHANGED
@@ -1 +1,93 @@
1
- export {}
1
+ import { JobStepIdentity, BranchStepIdentity, WhileStepIdentity, ForStepIdentity } from './generated/types/types.js';
2
+
3
+ // Re-export JSON schemas via .ts shims to avoid .json re-exports in declarations
4
+ export { default as SchemaGenesis } from './generated/schemas/Genesis.js';
5
+ export { default as SchemaJob } from './generated/schemas/standalone/Job.js';
6
+ export { default as SchemaStrategyRun } from './generated/schemas/standalone/StrategyRun.js';
7
+ export { default as ResourceTypeGenesis } from './generated/resources/Genesis.js';
8
+ export { default as dependencies } from './generated/dependencyMap.json';
9
+ // export { default as terminals } from './generated/terminals.json';
10
+
11
+ export type {
12
+ Resource_Genesis as Resource_GenesisJson
13
+ } from './generated/types/standalone/Resource_Genesis.js';
14
+
15
+ // export type {
16
+ // Resource_ResourceFormat as Resource_ResourceFormatJson
17
+ // } from './generated/types/standalone/Resource_ResourceFormat.js';
18
+ export type {
19
+ Resource_ResourceType as Resource_ResourceTypeJson
20
+ } from './generated/types/standalone/Resource_ResourceType.js';
21
+ export type {
22
+ Resource_Job as Resource_JobJson
23
+ } from './generated/types/standalone/Resource_Job.js';
24
+ // export type {
25
+ // Resource_StatelessStrategy as Resource_StatelessStrategyJson
26
+ // } from './generated/types/standalone/Resource_StatelessStrategy.js';
27
+ export type {
28
+ Resource_RawStrategy as Resource_RawStrategyJson
29
+ } from './generated/types/standalone/Resource_RawStrategy.js';
30
+ export type {
31
+ Resource_RunnableStrategy as Resource_RunnableStrategyJson
32
+ } from './generated/types/standalone/Resource_RunnableStrategy.js';
33
+
34
+
35
+ export type StepIdentityJson = JobStepIdentity | BranchStepIdentity | WhileStepIdentity | ForStepIdentity;
36
+
37
+
38
+ export type {
39
+ DocumentationFacet as DocumentationFacetJson,
40
+ // ResourceFormatIdentity as ResourceFormatIdentityJson,
41
+ // ResourceFormat as ResourceFormatJson,
42
+ NucleusFacet as NucleusFacetJson,
43
+ // IdentityProp as IdentityPropJson,
44
+ // MeritProp as MeritPropJson,
45
+ ResourceTypeIdentity as ResourceTypeIdentityJson,
46
+ ResourceType as ResourceTypeJson,
47
+ ResourceRoleIdentity as ResourceRoleIdentityJson,
48
+ ResourceRoleValue as ResourceRoleValueJson,
49
+ // ExecutionIdentity as ExecutionIdentityJson,
50
+ // Execution as ExecutionJson,
51
+ Conditional as ConditionalJson,
52
+ RoleMap as RoleMapJson,
53
+ Roles as RolesJson,
54
+ // RoleBindingMap as RoleBindingMapJson,
55
+ RoleBindings as RoleBindingsJson,
56
+ ResourceIdentity as ResourceIdentityJson,
57
+ JobStepIdentity as JobStepIdentityJson,
58
+ BranchStepIdentity as BranchStepIdentityJson,
59
+ WhileStepIdentity as WhileStepIdentityJson,
60
+ ForStepIdentity as ForStepIdentityJson,
61
+ JobStep as JobStepJson,
62
+ BranchStep as BranchStepJson,
63
+ WhileStep as WhileStepJson,
64
+ ForStep as ForStepJson,
65
+ StepKind as StepKindJson,
66
+ Step as StepJson,
67
+ CreationContext as CreationContextJson,
68
+ ResourceMissing as ResourceMissingJson,
69
+ // ResourcePotentialInput as ResourcePotentialInputJson,
70
+ // ResourcePotentialOutput as ResourcePotentialOutputJson,
71
+ // ResourceMetaBase as ResourceMetaJson, // ATTENTION: type not generated for ResourceMeta
72
+ Resource as ResourceJson,
73
+ StrategyState as StrategyStateJson,
74
+ // StepsFacetIdentity as StatelessStrategyIdentityJson,
75
+ StepsFacet as StepsFacetJson,
76
+ // StatefulStrategyIdentity as StatefulStrategyIdentityJson,
77
+ RawStrategy as RawStrategyJson,
78
+ RunnableStrategyIdentity as RunnableStrategyIdentityJson,
79
+ RunnableStrategyStatus as RunnableStrategyStatusJson,
80
+ RunnableStrategy as RunnableStrategyJson,
81
+ RunnableStrategyUpdate as RunnableStrategyUpdateJson,
82
+ Domain as DomainJson,
83
+ JobIdentity as JobIdentityJson,
84
+ Job as JobJson,
85
+ JsonData as JsonDataJson,
86
+ StrategyThreadIdentity as StrategyThreadIdentityJson,
87
+ StrategyThreadMap as StrategyThreadMapJson,
88
+ // ExecutionSocket as ExecutionSocketJson,
89
+ Timestamp as TimestampJson,
90
+ Goal as GoalJson,
91
+ } from './generated/types/types.js';
92
+
93
+ // export { isResourceRoleIdentityJson, isStrategyThreadIdentityJson } from './identityGuards.js';
@@ -1,205 +1,205 @@
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 resourcesDir: string;
28
- private readonly dependencyMapPath: 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
- // Intermediate, generated artifact produced by normalizeAnchorsToPointers.
42
- // This should NOT live next to the source-of-truth schemas.
43
- this.normalizedDir = getEnv('TP_SCHEMA_NORMALIZED_DIR', 'src/generated/normalized');
44
- this.schemasDir = getEnv('TP_SCHEMA_SCHEMAS_DIR', 'src/generated/schemas');
45
- this.resourcesDir = getEnv('TP_SCHEMA_RESOURCES_DIR', 'src/generated/resources');
46
- this.dependencyMapPath = getEnv('TP_SCHEMA_DEPENDENCY_MAP_PATH', 'src/generated/dependencyMap.json');
47
- this.typesSrcDir = getEnv('TP_SCHEMA_TYPES_SRC_DIR', 'src/generated/types');
48
- this.typesDistDir = getEnv('TP_SCHEMA_TYPES_DIST_DIR', 'dist/generated/types');
49
- this.baseUrl = getEnv('TP_SCHEMA_BASE_URL', 'https://schemas.toolproof.com');
50
- this.version = getEnv('TP_SCHEMA_VERSION', 'v0');
51
- }
52
-
53
- // Path getters
54
- getRoot(): string {
55
- return this.root;
56
- }
57
-
58
- getSourceDir(): string {
59
- return path.isAbsolute(this.sourceDir)
60
- ? this.sourceDir
61
- : path.join(this.root, this.sourceDir);
62
- }
63
-
64
- getSourceFile(): string {
65
- return this.sourceFile;
66
- }
67
-
68
- getSourcePath(): string {
69
- return path.join(this.getSourceDir(), this.sourceFile);
70
- }
71
-
72
- getNormalizedDir(): string {
73
- return path.isAbsolute(this.normalizedDir)
74
- ? this.normalizedDir
75
- : path.join(this.root, this.normalizedDir);
76
- }
77
-
78
- getNormalizedSourceFile(): string {
79
- // We keep the same basename (Genesis.json) in the generated folder.
80
- // The source-of-truth Genesis.json lives under `TP_SCHEMA_SOURCE_DIR`.
81
- // The generated/normalized Genesis.json lives under `TP_SCHEMA_NORMALIZED_DIR`.
82
- return this.sourceFile;
83
- }
84
-
85
- getNormalizedSourcePath(): string {
86
- return path.join(this.getNormalizedDir(), this.getNormalizedSourceFile());
87
- }
88
-
89
- getSchemasDir(): string {
90
- return path.isAbsolute(this.schemasDir)
91
- ? this.schemasDir
92
- : path.join(this.root, this.schemasDir);
93
- }
94
-
95
- getSchemaPath(filename: string): string {
96
- return path.join(this.getSchemasDir(), filename);
97
- }
98
-
99
- getSchemasStandaloneDir(): string {
100
- return path.join(this.getSchemasDir(), 'standalone');
101
- }
102
-
103
- getSchemaStandalonePath(filename: string): string {
104
- return path.join(this.getSchemasStandaloneDir(), filename);
105
- }
106
-
107
- getTypesSrcDir(): string {
108
- return path.isAbsolute(this.typesSrcDir)
109
- ? this.typesSrcDir
110
- : path.join(this.root, this.typesSrcDir);
111
- }
112
-
113
- getTypesDistDir(): string {
114
- return path.isAbsolute(this.typesDistDir)
115
- ? this.typesDistDir
116
- : path.join(this.root, this.typesDistDir);
117
- }
118
-
119
- getTypesSrcPath(filename: string): string {
120
- return path.join(this.getTypesSrcDir(), filename);
121
- }
122
-
123
- getTypesDistPath(filename: string): string {
124
- return path.join(this.getTypesDistDir(), filename);
125
- }
126
-
127
- getTypesStandaloneSrcDir(): string {
128
- return path.join(this.getTypesSrcDir(), 'standalone');
129
- }
130
-
131
- getTypesStandaloneDistDir(): string {
132
- return path.join(this.getTypesDistDir(), 'standalone');
133
- }
134
-
135
- getTypesStandaloneSrcPath(filename: string): string {
136
- return path.join(this.getTypesStandaloneSrcDir(), filename);
137
- }
138
-
139
- getTypesStandaloneDistPath(filename: string): string {
140
- return path.join(this.getTypesStandaloneDistDir(), filename);
141
- }
142
-
143
- getResourcesDir(): string {
144
- return path.isAbsolute(this.resourcesDir)
145
- ? this.resourcesDir
146
- : path.join(this.root, this.resourcesDir);
147
- }
148
-
149
- getDependencyMapPath(): string {
150
- return path.isAbsolute(this.dependencyMapPath)
151
- ? this.dependencyMapPath
152
- : path.join(this.root, this.dependencyMapPath);
153
- }
154
-
155
- // Schema URL methods
156
- getBaseUrl(): string {
157
- return this.baseUrl;
158
- }
159
-
160
- getVersion(): string {
161
- return this.version;
162
- }
163
-
164
- getSchemaId(schemaName: string): string {
165
- return `${this.baseUrl}/${this.version}/${schemaName}.json`;
166
- }
167
-
168
- /**
169
- * Check if a URL matches the configured schema base URL pattern
170
- */
171
- isSchemaUrl(url: string): boolean {
172
- const baseUrlPattern = this.baseUrl.replace('https://', 'https?://');
173
- return new RegExp(`^${baseUrlPattern}/`, 'i').test(url);
174
- }
175
-
176
- /**
177
- * Extract schema name from URL (removes base URL and version prefix)
178
- */
179
- extractSchemaName(url: string): string {
180
- // Remove base URL
181
- let name = url.replace(new RegExp(`^${this.baseUrl}/`, 'i'), '');
182
-
183
- // Remove version prefix (v0/, v1/, etc.)
184
- name = name.replace(/^v\d+\//, '');
185
-
186
- // Remove .json extension
187
- name = name.replace(/\.json$/, '');
188
-
189
- return name;
190
- }
191
- }
192
-
193
- // Singleton instance
194
- let configInstance: SchemaConfig | null = null;
195
-
196
- /**
197
- * Get the schema configuration singleton
198
- * Throws error if required environment variables are not set
199
- */
200
- export function getConfig(): SchemaConfig {
201
- if (!configInstance) {
202
- configInstance = new SchemaConfig();
203
- }
204
- return configInstance;
205
- }
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 resourcesDir: string;
28
+ private readonly dependencyMapPath: 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
+ // Intermediate, generated artifact produced by normalizeAnchorsToPointers.
42
+ // This should NOT live next to the source-of-truth schemas.
43
+ this.normalizedDir = getEnv('TP_SCHEMA_NORMALIZED_DIR', 'src/generated/normalized');
44
+ this.schemasDir = getEnv('TP_SCHEMA_SCHEMAS_DIR', 'src/generated/schemas');
45
+ this.resourcesDir = getEnv('TP_SCHEMA_RESOURCES_DIR', 'src/generated/resources');
46
+ this.dependencyMapPath = getEnv('TP_SCHEMA_DEPENDENCY_MAP_PATH', 'src/generated/dependencyMap.json');
47
+ this.typesSrcDir = getEnv('TP_SCHEMA_TYPES_SRC_DIR', 'src/generated/types');
48
+ this.typesDistDir = getEnv('TP_SCHEMA_TYPES_DIST_DIR', 'dist/generated/types');
49
+ this.baseUrl = getEnv('TP_SCHEMA_BASE_URL', 'https://schemas.toolproof.com');
50
+ this.version = getEnv('TP_SCHEMA_VERSION', 'v0');
51
+ }
52
+
53
+ // Path getters
54
+ getRoot(): string {
55
+ return this.root;
56
+ }
57
+
58
+ getSourceDir(): string {
59
+ return path.isAbsolute(this.sourceDir)
60
+ ? this.sourceDir
61
+ : path.join(this.root, this.sourceDir);
62
+ }
63
+
64
+ getSourceFile(): string {
65
+ return this.sourceFile;
66
+ }
67
+
68
+ getSourcePath(): string {
69
+ return path.join(this.getSourceDir(), this.sourceFile);
70
+ }
71
+
72
+ getNormalizedDir(): string {
73
+ return path.isAbsolute(this.normalizedDir)
74
+ ? this.normalizedDir
75
+ : path.join(this.root, this.normalizedDir);
76
+ }
77
+
78
+ getNormalizedSourceFile(): string {
79
+ // We keep the same basename (Genesis.json) in the generated folder.
80
+ // The source-of-truth Genesis.json lives under `TP_SCHEMA_SOURCE_DIR`.
81
+ // The generated/normalized Genesis.json lives under `TP_SCHEMA_NORMALIZED_DIR`.
82
+ return this.sourceFile;
83
+ }
84
+
85
+ getNormalizedSourcePath(): string {
86
+ return path.join(this.getNormalizedDir(), this.getNormalizedSourceFile());
87
+ }
88
+
89
+ getSchemasDir(): string {
90
+ return path.isAbsolute(this.schemasDir)
91
+ ? this.schemasDir
92
+ : path.join(this.root, this.schemasDir);
93
+ }
94
+
95
+ getSchemaPath(filename: string): string {
96
+ return path.join(this.getSchemasDir(), filename);
97
+ }
98
+
99
+ getSchemasStandaloneDir(): string {
100
+ return path.join(this.getSchemasDir(), 'standalone');
101
+ }
102
+
103
+ getSchemaStandalonePath(filename: string): string {
104
+ return path.join(this.getSchemasStandaloneDir(), filename);
105
+ }
106
+
107
+ getTypesSrcDir(): string {
108
+ return path.isAbsolute(this.typesSrcDir)
109
+ ? this.typesSrcDir
110
+ : path.join(this.root, this.typesSrcDir);
111
+ }
112
+
113
+ getTypesDistDir(): string {
114
+ return path.isAbsolute(this.typesDistDir)
115
+ ? this.typesDistDir
116
+ : path.join(this.root, this.typesDistDir);
117
+ }
118
+
119
+ getTypesSrcPath(filename: string): string {
120
+ return path.join(this.getTypesSrcDir(), filename);
121
+ }
122
+
123
+ getTypesDistPath(filename: string): string {
124
+ return path.join(this.getTypesDistDir(), filename);
125
+ }
126
+
127
+ getTypesStandaloneSrcDir(): string {
128
+ return path.join(this.getTypesSrcDir(), 'standalone');
129
+ }
130
+
131
+ getTypesStandaloneDistDir(): string {
132
+ return path.join(this.getTypesDistDir(), 'standalone');
133
+ }
134
+
135
+ getTypesStandaloneSrcPath(filename: string): string {
136
+ return path.join(this.getTypesStandaloneSrcDir(), filename);
137
+ }
138
+
139
+ getTypesStandaloneDistPath(filename: string): string {
140
+ return path.join(this.getTypesStandaloneDistDir(), filename);
141
+ }
142
+
143
+ getResourcesDir(): string {
144
+ return path.isAbsolute(this.resourcesDir)
145
+ ? this.resourcesDir
146
+ : path.join(this.root, this.resourcesDir);
147
+ }
148
+
149
+ getDependencyMapPath(): string {
150
+ return path.isAbsolute(this.dependencyMapPath)
151
+ ? this.dependencyMapPath
152
+ : path.join(this.root, this.dependencyMapPath);
153
+ }
154
+
155
+ // Schema URL methods
156
+ getBaseUrl(): string {
157
+ return this.baseUrl;
158
+ }
159
+
160
+ getVersion(): string {
161
+ return this.version;
162
+ }
163
+
164
+ getSchemaId(schemaName: string): string {
165
+ return `${this.baseUrl}/${this.version}/${schemaName}.json`;
166
+ }
167
+
168
+ /**
169
+ * Check if a URL matches the configured schema base URL pattern
170
+ */
171
+ isSchemaUrl(url: string): boolean {
172
+ const baseUrlPattern = this.baseUrl.replace('https://', 'https?://');
173
+ return new RegExp(`^${baseUrlPattern}/`, 'i').test(url);
174
+ }
175
+
176
+ /**
177
+ * Extract schema name from URL (removes base URL and version prefix)
178
+ */
179
+ extractSchemaName(url: string): string {
180
+ // Remove base URL
181
+ let name = url.replace(new RegExp(`^${this.baseUrl}/`, 'i'), '');
182
+
183
+ // Remove version prefix (v0/, v1/, etc.)
184
+ name = name.replace(/^v\d+\//, '');
185
+
186
+ // Remove .json extension
187
+ name = name.replace(/\.json$/, '');
188
+
189
+ return name;
190
+ }
191
+ }
192
+
193
+ // Singleton instance
194
+ let configInstance: SchemaConfig | null = null;
195
+
196
+ /**
197
+ * Get the schema configuration singleton
198
+ * Throws error if required environment variables are not set
199
+ */
200
+ export function getConfig(): SchemaConfig {
201
+ if (!configInstance) {
202
+ configInstance = new SchemaConfig();
203
+ }
204
+ return configInstance;
205
+ }