@mat3ra/esse 2025.5.13-0 → 2025.5.16-0
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/js/esse/JSONSchemasGenerator.js +10 -2
- package/dist/js/esse/utils.js +6 -0
- package/dist/js/example/apse/materials/builders/slab/pymatgen/parameters.json +6 -0
- package/dist/js/example/material/builders/base/selector_parameters.json +3 -0
- package/dist/js/example/material/builders/single_material/two_dimensional/slab/selector_parameters.json +6 -0
- package/dist/js/schema/apse/materials/builders/slab/pymatgen/parameters.json +33 -0
- package/dist/js/schema/material/builders/base/selector_parameters.json +15 -0
- package/dist/js/schema/material/builders/single_material/two_dimensional/slab/builder_parameters.json +33 -0
- package/dist/js/schema/material/builders/single_material/two_dimensional/slab/selector_parameters.json +31 -0
- package/dist/js/schemas.json +1 -1
- package/dist/js/types.d.ts +73 -0
- package/example/apse/materials/builders/slab/pymatgen/parameters.json +6 -0
- package/example/material/builders/base/selector_parameters.json +3 -0
- package/example/material/builders/single_material/two_dimensional/slab/selector_parameters.json +6 -0
- package/package.json +1 -1
- package/schema/apse/materials/builders/slab/pymatgen/parameters.json +33 -0
- package/schema/material/builders/base/selector_parameters.json +15 -0
- package/schema/material/builders/single_material/two_dimensional/slab/builder_parameters.json +12 -0
- package/schema/material/builders/single_material/two_dimensional/slab/selector_parameters.json +12 -0
- package/src/js/esse/JSONSchemasGenerator.ts +11 -1
- package/src/js/esse/utils.ts +8 -2
|
@@ -39,10 +39,18 @@ class JSONSchemasGenerator {
|
|
|
39
39
|
resolvers: { defaultResolver: json_schema_merge_allof_1.default.options.resolvers.title },
|
|
40
40
|
};
|
|
41
41
|
const schemas = this.schemas.map((schema) => {
|
|
42
|
-
var _a;
|
|
43
42
|
console.log(`Resolving schema: ${schema.$id}`);
|
|
44
43
|
const mergedSchema = skipMergeAllOff ? schema : (0, json_schema_merge_allof_1.default)(schema, mergeAllOfConfig);
|
|
45
|
-
|
|
44
|
+
let idAsPath = mergedSchema.$id;
|
|
45
|
+
if (!idAsPath) {
|
|
46
|
+
throw new Error(`Schema ID is missing:
|
|
47
|
+
${JSON.stringify(mergedSchema)}`);
|
|
48
|
+
}
|
|
49
|
+
const schemaHasDash = idAsPath.includes("-");
|
|
50
|
+
if (schemaHasDash) {
|
|
51
|
+
// replace dashes with underscores
|
|
52
|
+
idAsPath = idAsPath.replace(/-/g, "_");
|
|
53
|
+
}
|
|
46
54
|
const fullPath = `${schemasFolder}/${idAsPath}.json`;
|
|
47
55
|
fs_1.default.mkdirSync(path_1.default.dirname(fullPath), { recursive: true });
|
|
48
56
|
fs_1.default.writeFileSync(fullPath, JSON.stringify(mergedSchema, null, 4), "utf8");
|
package/dist/js/esse/utils.js
CHANGED
|
@@ -17,11 +17,17 @@ function parseIncludeReferenceStatements(filePath) {
|
|
|
17
17
|
const jsonResolver = new json_include_1.JSONInclude();
|
|
18
18
|
const parsed = jsonResolver.parseIncludeStatements(filePath);
|
|
19
19
|
const dirPath = path_1.default.dirname(filePath);
|
|
20
|
+
// Store the original $id before dereferencing
|
|
21
|
+
const originalId = parsed.$id;
|
|
20
22
|
let dereferenced = (0, json_schema_deref_sync_1.default)(parsed, { baseFolder: dirPath, removeIds: true });
|
|
21
23
|
// handle circular references and use non-dereferenced source
|
|
22
24
|
if (dereferenced instanceof Error && dereferenced.message === "Circular self reference") {
|
|
23
25
|
dereferenced = parsed;
|
|
24
26
|
}
|
|
27
|
+
// Restore the original $id after dereferencing
|
|
28
|
+
if (originalId) {
|
|
29
|
+
dereferenced.$id = originalId;
|
|
30
|
+
}
|
|
25
31
|
return dereferenced;
|
|
26
32
|
}
|
|
27
33
|
exports.parseIncludeReferenceStatements = parseIncludeReferenceStatements;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "apse/materials/builders/slab/pymatgen/parameters",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"title": "Pymatgen Slab Generator Parameters Schema",
|
|
5
|
+
"description": "Parameters for the Pymatgen slab generator. https://github.com/materialsproject/pymatgen/blob/585bb673c4aa222669c4b0d72ffeec3dbf092630/pymatgen/core/surface.py#L1187",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"min_vacuum_size": {
|
|
9
|
+
"description": "Minimum size of the vacuum in layers or angstroms",
|
|
10
|
+
"type": [
|
|
11
|
+
"integer",
|
|
12
|
+
"number"
|
|
13
|
+
],
|
|
14
|
+
"minimum": 0,
|
|
15
|
+
"default": 1
|
|
16
|
+
},
|
|
17
|
+
"in_unit_planes": {
|
|
18
|
+
"description": "Whether to cleave in unit planes",
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"default": true
|
|
21
|
+
},
|
|
22
|
+
"reorient_lattice": {
|
|
23
|
+
"description": "Whether to reorient the lattice",
|
|
24
|
+
"type": "boolean",
|
|
25
|
+
"default": true
|
|
26
|
+
},
|
|
27
|
+
"symmetrize": {
|
|
28
|
+
"description": "Whether to symmetrize the slab",
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"default": true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "material/builders/base/selector-parameters",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"title": "Base Selector Parameters Schema",
|
|
5
|
+
"description": "Base parameters for all builder selectors",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"default_index": {
|
|
9
|
+
"description": "Default index for the selector",
|
|
10
|
+
"type": "integer",
|
|
11
|
+
"minimum": 0,
|
|
12
|
+
"default": 0
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "material/builders/single-material/two-dimensional/slab/builder-parameters",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"title": "Slab Builder Parameters Schema",
|
|
5
|
+
"description": "Parameters for the slab builder",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"min_vacuum_size": {
|
|
9
|
+
"description": "Minimum size of the vacuum in layers or angstroms",
|
|
10
|
+
"type": [
|
|
11
|
+
"integer",
|
|
12
|
+
"number"
|
|
13
|
+
],
|
|
14
|
+
"minimum": 0,
|
|
15
|
+
"default": 1
|
|
16
|
+
},
|
|
17
|
+
"in_unit_planes": {
|
|
18
|
+
"description": "Whether to cleave in unit planes",
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"default": true
|
|
21
|
+
},
|
|
22
|
+
"reorient_lattice": {
|
|
23
|
+
"description": "Whether to reorient the lattice",
|
|
24
|
+
"type": "boolean",
|
|
25
|
+
"default": true
|
|
26
|
+
},
|
|
27
|
+
"symmetrize": {
|
|
28
|
+
"description": "Whether to symmetrize the slab",
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"default": true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "material/builders/single-material/two-dimensional/slab/selector-parameters",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"title": "Slab Selector Parameters Schema",
|
|
5
|
+
"description": "Parameters for slab selection",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"termination": {
|
|
9
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
10
|
+
"title": "Termination Schema",
|
|
11
|
+
"description": "Defines a specific termination of a slab",
|
|
12
|
+
"type": "object",
|
|
13
|
+
"required": [
|
|
14
|
+
"chemical_elements",
|
|
15
|
+
"space_group_symmetry_label"
|
|
16
|
+
],
|
|
17
|
+
"properties": {
|
|
18
|
+
"chemical_elements": {
|
|
19
|
+
"title": "Chemical Elements",
|
|
20
|
+
"description": "Chemical elements at the termination",
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"space_group_symmetry_label": {
|
|
24
|
+
"title": "Space Group Symmetry Label",
|
|
25
|
+
"description": "Space group symmetry designation for the termination",
|
|
26
|
+
"type": "string"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|