@mat3ra/esse 2026.10.31-0 → 2026.10.31-1
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.
|
@@ -14,7 +14,13 @@ export default class JSONSchemasGenerator implements JSONSchemasGeneratorConfig
|
|
|
14
14
|
readonly schemasDir: string;
|
|
15
15
|
readonly examplesDir?: string;
|
|
16
16
|
readonly propertiesManifestDir?: string;
|
|
17
|
+
private resolvedSchemas?;
|
|
17
18
|
constructor(config?: JSONSchemasGeneratorConfig);
|
|
19
|
+
/**
|
|
20
|
+
* The schemas with every `allOf` merged into its parent, as dist/js/schema
|
|
21
|
+
* holds them. Computed once: the JS assets and the Python modules share it.
|
|
22
|
+
*/
|
|
23
|
+
getResolvedSchemas(skipMergeAllOff?: boolean): JSONSchema[];
|
|
18
24
|
writeResolvedSchemas(subfolder: string, skipMergeAllOff?: boolean): void;
|
|
19
25
|
writeResolvedExamples(subfolder: string): void;
|
|
20
26
|
}
|
|
@@ -32,15 +32,28 @@ class JSONSchemasGenerator {
|
|
|
32
32
|
.map((k) => (k[1].isResult ? k[0] : null))
|
|
33
33
|
.filter((x) => x);
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The schemas with every `allOf` merged into its parent, as dist/js/schema
|
|
37
|
+
* holds them. Computed once: the JS assets and the Python modules share it.
|
|
38
|
+
*/
|
|
39
|
+
getResolvedSchemas(skipMergeAllOff = false) {
|
|
40
|
+
if (skipMergeAllOff)
|
|
41
|
+
return this.schemas;
|
|
42
|
+
if (this.resolvedSchemas)
|
|
43
|
+
return this.resolvedSchemas;
|
|
38
44
|
const mergeAllOfConfig = {
|
|
39
45
|
resolvers: { defaultResolver: json_schema_merge_allof_1.default.options.resolvers.title },
|
|
40
46
|
};
|
|
41
|
-
|
|
47
|
+
this.resolvedSchemas = this.schemas.map((schema) => {
|
|
42
48
|
console.log(`Resolving schema: ${schema.$id}`);
|
|
43
|
-
|
|
49
|
+
return (0, json_schema_merge_allof_1.default)(schema, mergeAllOfConfig);
|
|
50
|
+
});
|
|
51
|
+
return this.resolvedSchemas;
|
|
52
|
+
}
|
|
53
|
+
writeResolvedSchemas(subfolder, skipMergeAllOff = false) {
|
|
54
|
+
const schemasFolder = `${subfolder}/schema`;
|
|
55
|
+
fs_1.default.rmSync(schemasFolder, { recursive: true, force: true });
|
|
56
|
+
const schemas = this.getResolvedSchemas(skipMergeAllOff).map((mergedSchema) => {
|
|
44
57
|
let idAsPath = mergedSchema.$id;
|
|
45
58
|
if (!idAsPath) {
|
|
46
59
|
throw new Error(`Schema ID is missing:
|
package/package.json
CHANGED