@mat3ra/esse 2025.4.26-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.
Files changed (59) hide show
  1. package/.eslintrc.json +3 -9
  2. package/.prettierrc +2 -1
  3. package/dist/js/esse/JSONSchemasGenerator.js +10 -2
  4. package/dist/js/esse/utils.js +6 -0
  5. package/dist/js/example/apse/materials/builders/slab/pymatgen/parameters.json +6 -0
  6. package/dist/js/example/material/builders/base/selector_parameters.json +3 -0
  7. package/dist/js/example/material/builders/single_material/two_dimensional/slab/selector_parameters.json +6 -0
  8. package/dist/js/example/material/reusable/repetitions.json +5 -0
  9. package/dist/js/example/material/reusable/slab/miller_indices.json +5 -0
  10. package/dist/js/example/material/reusable/slab/number_of_layers.json +1 -0
  11. package/dist/js/example/material/reusable/slab/termination.json +4 -0
  12. package/dist/js/example/material/reusable/slab/vacuum.json +1 -0
  13. package/dist/js/example/material/reusable/supercell_matrix_2d.json +10 -0
  14. package/dist/js/example/material/reusable/supercell_matrix_3d.json +17 -0
  15. package/dist/js/example/materials_category/single_material/two_dimensional/slab/configuration.json +150 -0
  16. package/dist/js/schema/apse/materials/builders/slab/pymatgen/parameters.json +33 -0
  17. package/dist/js/schema/core/abstract/coordinate_2d.json +11 -0
  18. package/dist/js/schema/material/builders/base/selector_parameters.json +15 -0
  19. package/dist/js/schema/material/builders/single_material/two_dimensional/slab/builder_parameters.json +33 -0
  20. package/dist/js/schema/material/builders/single_material/two_dimensional/slab/selector_parameters.json +31 -0
  21. package/dist/js/schema/material/reusable/repetitions.json +18 -0
  22. package/dist/js/schema/material/reusable/slab/enums.json +11 -0
  23. package/dist/js/schema/material/reusable/slab/miller_indices.json +17 -0
  24. package/dist/js/schema/material/reusable/slab/number_of_layers.json +9 -0
  25. package/dist/js/schema/material/reusable/slab/termination.json +23 -0
  26. package/dist/js/schema/material/reusable/slab/vacuum.json +9 -0
  27. package/dist/js/schema/material/reusable/supercell_matrix_2d.json +27 -0
  28. package/dist/js/schema/material/reusable/supercell_matrix_3d.json +34 -0
  29. package/dist/js/schema/materials_category/single_material/two_dimensional/slab/configuration.json +709 -0
  30. package/dist/js/schemas.json +1 -1
  31. package/dist/js/types.d.ts +433 -0
  32. package/example/apse/materials/builders/slab/pymatgen/parameters.json +6 -0
  33. package/example/material/builders/base/selector_parameters.json +3 -0
  34. package/example/material/builders/single_material/two_dimensional/slab/selector_parameters.json +6 -0
  35. package/example/material/reusable/repetitions.json +1 -0
  36. package/example/material/reusable/slab/miller_indices.json +5 -0
  37. package/example/material/reusable/slab/number_of_layers.json +1 -0
  38. package/example/material/reusable/slab/termination.json +4 -0
  39. package/example/material/reusable/slab/vacuum.json +1 -0
  40. package/example/material/reusable/supercell_matrix_2d.json +10 -0
  41. package/example/material/reusable/supercell_matrix_3d.json +5 -0
  42. package/example/materials_category/single_material/two_dimensional/slab/configuration.json +25 -0
  43. package/package.json +10 -4
  44. package/schema/apse/materials/builders/slab/pymatgen/parameters.json +33 -0
  45. package/schema/core/abstract/coordinate_2d.json +11 -0
  46. package/schema/material/builders/base/selector_parameters.json +15 -0
  47. package/schema/material/builders/single_material/two_dimensional/slab/builder_parameters.json +12 -0
  48. package/schema/material/builders/single_material/two_dimensional/slab/selector_parameters.json +12 -0
  49. package/schema/material/reusable/repetitions.json +18 -0
  50. package/schema/material/reusable/slab/enums.json +11 -0
  51. package/schema/material/reusable/slab/miller_indices.json +17 -0
  52. package/schema/material/reusable/slab/number_of_layers.json +9 -0
  53. package/schema/material/reusable/slab/termination.json +23 -0
  54. package/schema/material/reusable/slab/vacuum.json +9 -0
  55. package/schema/material/reusable/supercell_matrix_2d.json +27 -0
  56. package/schema/material/reusable/supercell_matrix_3d.json +34 -0
  57. package/schema/materials_category/single_material/two_dimensional/slab/configuration.json +42 -0
  58. package/src/js/esse/JSONSchemasGenerator.ts +11 -1
  59. package/src/js/esse/utils.ts +8 -2
@@ -0,0 +1,18 @@
1
+ {
2
+ "$id": "material/reusable/repetitions",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Crystal Repetitions Schema",
5
+ "description": "Number of unit cells to repeat in each direction for a crystal structure.",
6
+ "type": "array",
7
+ "items": {
8
+ "type": "integer",
9
+ "minimum": 1
10
+ },
11
+ "minItems": 3,
12
+ "maxItems": 3,
13
+ "default": [
14
+ 1,
15
+ 1,
16
+ 1
17
+ ]
18
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "$id": "material/reusable/slab/enums",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Surface Types Enum",
5
+ "$comment": "The surface types used by passivation and surface analysis",
6
+ "enum": [
7
+ "top",
8
+ "bottom",
9
+ "both"
10
+ ]
11
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "$id": "material/reusable/slab/miller-indices",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Miller Indices Schema",
5
+ "description": "Miller indices for crystallographic plane designation",
6
+ "type": "array",
7
+ "items": {
8
+ "type": "integer"
9
+ },
10
+ "minItems": 3,
11
+ "maxItems": 3,
12
+ "default": [
13
+ 0,
14
+ 0,
15
+ 1
16
+ ]
17
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "$id": "material/reusable/slab/number-of-layers",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "number_of_layers Schema",
5
+ "description": "Number of atomic layers in a structural component",
6
+ "type": "integer",
7
+ "minimum": 1,
8
+ "default": 1
9
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "$id": "material/reusable/slab/termination",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Termination Schema",
5
+ "description": "Defines a specific termination of a slab",
6
+ "type": "object",
7
+ "required": [
8
+ "chemical_elements",
9
+ "space_group_symmetry_label"
10
+ ],
11
+ "properties": {
12
+ "chemical_elements": {
13
+ "title": "Chemical Elements",
14
+ "description": "Chemical elements at the termination",
15
+ "type": "string"
16
+ },
17
+ "space_group_symmetry_label": {
18
+ "title": "Space Group Symmetry Label",
19
+ "description": "Space group symmetry designation for the termination",
20
+ "type": "string"
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "$id": "material/reusable/slab/vacuum",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Vacuum Schema",
5
+ "description": "Vacuum thickness in Angstroms",
6
+ "type": "number",
7
+ "minimum": 0.0,
8
+ "default": 5.0
9
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$id": "material/reusable/supercell-matrix-2d",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Supercell Matrix 2D Schema",
5
+ "description": "Supercell matrix for xy plane transformations",
6
+ "type": "array",
7
+ "items": {
8
+ "type": "array",
9
+ "items": {
10
+ "type": "integer"
11
+ },
12
+ "minItems": 2,
13
+ "maxItems": 2
14
+ },
15
+ "minItems": 2,
16
+ "maxItems": 2,
17
+ "default": [
18
+ [
19
+ 1,
20
+ 0
21
+ ],
22
+ [
23
+ 0,
24
+ 1
25
+ ]
26
+ ]
27
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "$id": "material/reusable/supercell-matrix-3d",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Supercell Matrix 3D Schema",
5
+ "description": "3x3 matrix of integers for transforming a unit cell into a supercell",
6
+ "type": "array",
7
+ "items": {
8
+ "type": "array",
9
+ "items": {
10
+ "type": "integer"
11
+ },
12
+ "minItems": 3,
13
+ "maxItems": 3
14
+ },
15
+ "minItems": 3,
16
+ "maxItems": 3,
17
+ "default": [
18
+ [
19
+ 1,
20
+ 0,
21
+ 0
22
+ ],
23
+ [
24
+ 0,
25
+ 1,
26
+ 0
27
+ ],
28
+ [
29
+ 0,
30
+ 0,
31
+ 1
32
+ ]
33
+ ]
34
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "$id": "materials-category/single-material/two-dimensional/slab/configuration",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Slab Configuration Schema",
5
+ "description": "Configuration for creating a slab from a bulk material",
6
+ "type": "object",
7
+ "properties": {
8
+ "bulk": {
9
+ "$ref": "../../../../material.json"
10
+ },
11
+ "miller_indices": {
12
+ "$ref": "../../../../material/reusable/slab/miller_indices.json"
13
+ },
14
+ "number_of_layers": {
15
+ "$ref": "../../../../material/reusable/slab/number_of_layers.json"
16
+ },
17
+ "vacuum": {
18
+ "$ref": "../../../../material/reusable/slab/vacuum.json"
19
+ },
20
+ "xy_supercell_matrix": {
21
+ "$ref": "../../../../material/reusable/supercell_matrix_2d.json"
22
+ },
23
+ "use_conventional_cell": {
24
+ "title": "Use Conventional Cell",
25
+ "description": "Whether to use conventional cell",
26
+ "type": "boolean",
27
+ "default": true
28
+ },
29
+ "use_orthogonal_z": {
30
+ "title": "Use Orthogonal Z",
31
+ "description": "Whether to make z-axis orthogonal",
32
+ "type": "boolean",
33
+ "default": false
34
+ },
35
+ "make_primitive": {
36
+ "title": "Make Primitive",
37
+ "description": "Whether to make the slab primitive",
38
+ "type": "boolean",
39
+ "default": false
40
+ }
41
+ }
42
+ }
@@ -69,7 +69,17 @@ export default class JSONSchemasGenerator implements JSONSchemasGeneratorConfig
69
69
  const schemas = this.schemas.map((schema) => {
70
70
  console.log(`Resolving schema: ${schema.$id}`);
71
71
  const mergedSchema = skipMergeAllOff ? schema : mergeAllOf(schema, mergeAllOfConfig);
72
- const idAsPath = mergedSchema.$id?.replace(/-/g, "_");
72
+ let idAsPath = mergedSchema.$id;
73
+ if (!idAsPath) {
74
+ throw new Error(`Schema ID is missing:
75
+ ${JSON.stringify(mergedSchema)}`);
76
+ }
77
+ const schemaHasDash = idAsPath.includes("-");
78
+ if (schemaHasDash) {
79
+ // replace dashes with underscores
80
+ idAsPath = idAsPath.replace(/-/g, "_");
81
+ }
82
+
73
83
  const fullPath = `${schemasFolder}/${idAsPath}.json`;
74
84
 
75
85
  fs.mkdirSync(path.dirname(fullPath), { recursive: true });
@@ -16,12 +16,18 @@ export type JSONSchemaDefinition = JSONSchema7Definition;
16
16
  */
17
17
  export function parseIncludeReferenceStatements(filePath: string): JSONSchema {
18
18
  const jsonResolver = new JSONInclude();
19
- const parsed = jsonResolver.parseIncludeStatements(filePath);
19
+ const parsed = jsonResolver.parseIncludeStatements(filePath) as JSONSchema;
20
20
  const dirPath = path.dirname(filePath);
21
+ // Store the original $id before dereferencing
22
+ const originalId = parsed.$id;
21
23
  let dereferenced = deref(parsed, { baseFolder: dirPath, removeIds: true });
22
24
  // handle circular references and use non-dereferenced source
23
25
  if (dereferenced instanceof Error && dereferenced.message === "Circular self reference") {
24
- dereferenced = parsed as JSONSchema;
26
+ dereferenced = parsed;
27
+ }
28
+ // Restore the original $id after dereferencing
29
+ if (originalId) {
30
+ dereferenced.$id = originalId;
25
31
  }
26
32
  return dereferenced;
27
33
  }