@mat3ra/esse 2025.11.19-0 → 2025.11.25-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.
@@ -28,4 +28,17 @@ export default class JSONSchemasInterface {
28
28
  * })
29
29
  */
30
30
  static matchSchema(query: JSONSchemasInterfaceQuery): import("json-schema").JSONSchema7 | undefined;
31
+ /**
32
+ * Get a patched copy of a schema without modifying the cached version
33
+ * @param schemaId - The ID of the schema to patch
34
+ * @param propertyPatches - Object with property names as keys and patch objects as values
35
+ * @returns A new schema with patched properties
36
+ *
37
+ * @example
38
+ * JSONSchemasInterface.getPatchedSchema("boundary-conditions-provider", {
39
+ * type: { default: "pbc" },
40
+ * offset: { default: 0 }
41
+ * });
42
+ */
43
+ static getPatchedSchemaById(schemaId: string, patchConfig: Record<string, unknown>): JSONSchema | undefined;
31
44
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("./utils");
3
4
  class JSONSchemasInterface {
4
5
  static setSchemas(schema) {
5
6
  schema.forEach((schema) => this.addSchema(schema));
@@ -43,6 +44,27 @@ class JSONSchemasInterface {
43
44
  });
44
45
  });
45
46
  }
47
+ /**
48
+ * Get a patched copy of a schema without modifying the cached version
49
+ * @param schemaId - The ID of the schema to patch
50
+ * @param propertyPatches - Object with property names as keys and patch objects as values
51
+ * @returns A new schema with patched properties
52
+ *
53
+ * @example
54
+ * JSONSchemasInterface.getPatchedSchema("boundary-conditions-provider", {
55
+ * type: { default: "pbc" },
56
+ * offset: { default: 0 }
57
+ * });
58
+ */
59
+ static getPatchedSchemaById(schemaId, patchConfig) {
60
+ const baseSchema = this.getSchemaById(schemaId);
61
+ if (!baseSchema) {
62
+ return undefined;
63
+ }
64
+ const patchedSchema = JSON.parse(JSON.stringify(baseSchema));
65
+ (0, utils_1.applyPatchTree)(patchedSchema, patchConfig, []);
66
+ return patchedSchema;
67
+ }
46
68
  }
47
69
  exports.default = JSONSchemasInterface;
48
70
  JSONSchemasInterface.schemasCache = new Map();
@@ -12,3 +12,5 @@ export interface JSONSchemaWithPath {
12
12
  }
13
13
  export declare function parseIncludeReferenceStatementsByDir(dirPath: string, wrapInDataAndPath: true): JSONSchemaWithPath[];
14
14
  export declare function parseIncludeReferenceStatementsByDir(dirPath: string, wrapInDataAndPath?: false): JSONSchema[];
15
+ export declare function applyPatchWithDotNotation(target: Record<string, unknown>, path: string, patchValue: unknown): void;
16
+ export declare function applyPatchTree(schema: Record<string, unknown>, patchNode: Record<string, unknown>, pathPrefix: string[]): void;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parseIncludeReferenceStatementsByDir = exports.parseIncludeReferenceStatements = void 0;
6
+ exports.applyPatchTree = exports.applyPatchWithDotNotation = exports.parseIncludeReferenceStatementsByDir = exports.parseIncludeReferenceStatements = void 0;
7
7
  // @ts-ignore
8
8
  const json_schema_deref_sync_1 = __importDefault(require("json-schema-deref-sync"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -59,3 +59,52 @@ function parseIncludeReferenceStatementsByDir(dirPath, wrapInDataAndPath = false
59
59
  return wrapInDataAndPath ? schemasWithPath : schemas;
60
60
  }
61
61
  exports.parseIncludeReferenceStatementsByDir = parseIncludeReferenceStatementsByDir;
62
+ function isPlainObject(value) {
63
+ return value !== null && typeof value === "object" && !Array.isArray(value);
64
+ }
65
+ function applyPatchWithDotNotation(target, path, patchValue) {
66
+ const keys = path.split(".");
67
+ let current = target;
68
+ // Navigate to parent of final key
69
+ for (let index = 0; index < keys.length - 1; index += 1) {
70
+ const key = keys[index];
71
+ if (!isPlainObject(current[key])) {
72
+ // Path does not exist or is not an object → skip patch
73
+ return;
74
+ }
75
+ current = current[key];
76
+ }
77
+ const finalKey = keys[keys.length - 1];
78
+ const existingValue = current[finalKey];
79
+ if (isPlainObject(existingValue) && isPlainObject(patchValue)) {
80
+ // Merge object into existing object
81
+ Object.assign(existingValue, patchValue);
82
+ }
83
+ else if (existingValue !== undefined) {
84
+ // Overwrite leaf value
85
+ current[finalKey] = patchValue;
86
+ }
87
+ // If existingValue is undefined, we skip;
88
+ }
89
+ exports.applyPatchWithDotNotation = applyPatchWithDotNotation;
90
+ function applyPatchTree(schema, patchNode, pathPrefix) {
91
+ Object.entries(patchNode).forEach(([key, value]) => {
92
+ if (key.includes(".")) {
93
+ // Dot notation relative to current prefix
94
+ const fullPathSegments = [...pathPrefix, ...key.split(".")];
95
+ const fullPath = fullPathSegments.join(".");
96
+ applyPatchWithDotNotation(schema, fullPath, value);
97
+ }
98
+ else if (isPlainObject(value)) {
99
+ // Nested subtree → recurse with extended prefix
100
+ applyPatchTree(schema, value, [...pathPrefix, key]);
101
+ }
102
+ else {
103
+ // Leaf patch (primitive / array) → treat as direct field patch
104
+ const fullPathSegments = [...pathPrefix, key];
105
+ const fullPath = fullPathSegments.join(".");
106
+ applyPatchWithDotNotation(schema, fullPath, value);
107
+ }
108
+ });
109
+ }
110
+ exports.applyPatchTree = applyPatchTree;
@@ -0,0 +1,93 @@
1
+ {
2
+ "$id": "context-provider",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "context provider schema",
5
+ "type": "object",
6
+ "required": [
7
+ "name"
8
+ ],
9
+ "additionalProperties": true,
10
+ "properties": {
11
+ "name": {
12
+ "type": "string",
13
+ "enum": [
14
+ "PlanewaveCutoffDataManager",
15
+ "KGridFormDataManager",
16
+ "QGridFormDataManager",
17
+ "IGridFormDataManager",
18
+ "QPathFormDataManager",
19
+ "IPathFormDataManager",
20
+ "KPathFormDataManager",
21
+ "ExplicitKPathFormDataManager",
22
+ "ExplicitKPath2PIBAFormDataManager",
23
+ "HubbardJContextManager",
24
+ "HubbardUContextManager",
25
+ "HubbardVContextManager",
26
+ "HubbardContextManagerLegacy",
27
+ "NEBFormDataManager",
28
+ "BoundaryConditionsFormDataManager",
29
+ "MLSettingsDataManager",
30
+ "MLTrainTestSplitDataManager",
31
+ "IonDynamicsContextProvider",
32
+ "CollinearMagnetizationDataManager",
33
+ "NonCollinearMagnetizationDataManager",
34
+ "QEPWXInputDataManager",
35
+ "QENEBInputDataManager",
36
+ "VASPInputDataManager",
37
+ "VASPNEBInputDataManager",
38
+ "NWChemInputDataManager"
39
+ ],
40
+ "tsEnumNames": [
41
+ "PlanewaveCutoffDataManager",
42
+ "KGridFormDataManager",
43
+ "QGridFormDataManager",
44
+ "IGridFormDataManager",
45
+ "QPathFormDataManager",
46
+ "IPathFormDataManager",
47
+ "KPathFormDataManager",
48
+ "ExplicitKPathFormDataManager",
49
+ "ExplicitKPath2PIBAFormDataManager",
50
+ "HubbardJContextManager",
51
+ "HubbardUContextManager",
52
+ "HubbardVContextManager",
53
+ "HubbardContextManagerLegacy",
54
+ "NEBFormDataManager",
55
+ "BoundaryConditionsFormDataManager",
56
+ "MLSettingsDataManager",
57
+ "MLTrainTestSplitDataManager",
58
+ "IonDynamicsContextProvider",
59
+ "CollinearMagnetizationDataManager",
60
+ "NonCollinearMagnetizationDataManager",
61
+ "QEPWXInputDataManager",
62
+ "QENEBInputDataManager",
63
+ "VASPInputDataManager",
64
+ "VASPNEBInputDataManager",
65
+ "NWChemInputDataManager"
66
+ ]
67
+ },
68
+ "domain": {
69
+ "description": "domain of the context provider",
70
+ "type": "string"
71
+ },
72
+ "entityName": {
73
+ "description": "entity name associated with the context provider",
74
+ "type": "string"
75
+ },
76
+ "data": {
77
+ "description": "data object for the context provider",
78
+ "type": "object"
79
+ },
80
+ "extraData": {
81
+ "description": "additional data object for the context provider",
82
+ "type": "object"
83
+ },
84
+ "isEdited": {
85
+ "description": "flag indicating if the context provider has been edited",
86
+ "type": "boolean"
87
+ },
88
+ "context": {
89
+ "description": "context object for the context provider",
90
+ "type": "object"
91
+ }
92
+ }
93
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "$id": "context-providers-directory/boundary-conditions-provider",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Boundary Conditions Provider Schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "type": {
8
+ "type": "string",
9
+ "title": "Type"
10
+ },
11
+ "offset": {
12
+ "type": "number",
13
+ "title": "Offset (A)"
14
+ },
15
+ "electricField": {
16
+ "type": "number",
17
+ "title": "Electric Field (eV/A)"
18
+ },
19
+ "targetFermiEnergy": {
20
+ "type": "number",
21
+ "title": "Target Fermi Energy (eV)"
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "$id": "context-providers-directory/enum",
3
+ "definitions": {
4
+ "ContextProviderNameEnum": {
5
+ "type": "string",
6
+ "enum": [
7
+ "PlanewaveCutoffDataManager",
8
+ "KGridFormDataManager",
9
+ "QGridFormDataManager",
10
+ "IGridFormDataManager",
11
+ "QPathFormDataManager",
12
+ "IPathFormDataManager",
13
+ "KPathFormDataManager",
14
+ "ExplicitKPathFormDataManager",
15
+ "ExplicitKPath2PIBAFormDataManager",
16
+ "HubbardJContextManager",
17
+ "HubbardUContextManager",
18
+ "HubbardVContextManager",
19
+ "HubbardContextManagerLegacy",
20
+ "NEBFormDataManager",
21
+ "BoundaryConditionsFormDataManager",
22
+ "MLSettingsDataManager",
23
+ "MLTrainTestSplitDataManager",
24
+ "IonDynamicsContextProvider",
25
+ "CollinearMagnetizationDataManager",
26
+ "NonCollinearMagnetizationDataManager",
27
+ "QEPWXInputDataManager",
28
+ "QENEBInputDataManager",
29
+ "VASPInputDataManager",
30
+ "VASPNEBInputDataManager",
31
+ "NWChemInputDataManager"
32
+ ],
33
+ "tsEnumNames": [
34
+ "PlanewaveCutoffDataManager",
35
+ "KGridFormDataManager",
36
+ "QGridFormDataManager",
37
+ "IGridFormDataManager",
38
+ "QPathFormDataManager",
39
+ "IPathFormDataManager",
40
+ "KPathFormDataManager",
41
+ "ExplicitKPathFormDataManager",
42
+ "ExplicitKPath2PIBAFormDataManager",
43
+ "HubbardJContextManager",
44
+ "HubbardUContextManager",
45
+ "HubbardVContextManager",
46
+ "HubbardContextManagerLegacy",
47
+ "NEBFormDataManager",
48
+ "BoundaryConditionsFormDataManager",
49
+ "MLSettingsDataManager",
50
+ "MLTrainTestSplitDataManager",
51
+ "IonDynamicsContextProvider",
52
+ "CollinearMagnetizationDataManager",
53
+ "NonCollinearMagnetizationDataManager",
54
+ "QEPWXInputDataManager",
55
+ "QENEBInputDataManager",
56
+ "VASPInputDataManager",
57
+ "VASPNEBInputDataManager",
58
+ "NWChemInputDataManager"
59
+ ]
60
+ }
61
+ }
62
+ }