@mat3ra/mode 2025.11.23-0 → 2025.12.2-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/models/factory.js +6 -4
- package/dist/js/tree.d.ts +1 -0
- package/dist/js/tree.js +7 -1
- package/package.json +1 -1
- package/src/js/models/factory.ts +14 -7
- package/src/js/tree.ts +9 -0
|
@@ -18,11 +18,13 @@ class ModelFactory {
|
|
|
18
18
|
if (!application) {
|
|
19
19
|
throw new Error("ModelFactory.createFromApplication: application is required");
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
|
|
21
|
+
const tree = (0, tree_1.getTreeByApplicationNameAndVersion)(application);
|
|
22
|
+
if (Object.keys(tree).length === 0) {
|
|
23
|
+
return this.create({ ...config, type: "unknown", subtype: "unknown" });
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
const type = (0, tree_1.getDefaultModelTypeForApplication)(application);
|
|
26
|
+
const subtype = (0, tree_1.getDefaultModelSubtypeForApplicationAndType)(application, type) || "unknown";
|
|
27
|
+
return this.create({ ...config, type, subtype });
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
exports.ModelFactory = ModelFactory;
|
package/dist/js/tree.d.ts
CHANGED
|
@@ -73,3 +73,4 @@ export declare const getDFTFunctionalsByApproximation: (approximation: string) =
|
|
|
73
73
|
export declare const treeSlugToNamedObject: (modelSlug: string) => SlugifiedEntry;
|
|
74
74
|
export declare const getTreeByApplicationNameAndVersion: ({ name, }: Pick<ApplicationSchemaBase, "name" | "version">) => ModelTree;
|
|
75
75
|
export declare const getDefaultModelTypeForApplication: (application: ApplicationSchemaBase) => string;
|
|
76
|
+
export declare const getDefaultModelSubtypeForApplicationAndType: (application: ApplicationSchemaBase, type: string) => string | undefined;
|
package/dist/js/tree.js
CHANGED
|
@@ -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.getDefaultModelTypeForApplication = exports.getTreeByApplicationNameAndVersion = exports.treeSlugToNamedObject = exports.getDFTFunctionalsByApproximation = exports.getDFTFunctionalsFromTree = exports.getPseudopotentialTypesFromTree = exports.METHODS = exports.MODEL_NAMES = exports.MODEL_TREE = void 0;
|
|
6
|
+
exports.getDefaultModelSubtypeForApplicationAndType = exports.getDefaultModelTypeForApplication = exports.getTreeByApplicationNameAndVersion = exports.treeSlugToNamedObject = exports.getDFTFunctionalsByApproximation = exports.getDFTFunctionalsFromTree = exports.getPseudopotentialTypesFromTree = exports.METHODS = exports.MODEL_NAMES = exports.MODEL_TREE = void 0;
|
|
7
7
|
const modelsTreeConfigByApplication_json_1 = __importDefault(require("@mat3ra/standata/dist/js/runtime_data/models/modelsTreeConfigByApplication.json"));
|
|
8
8
|
const modelTree_json_1 = __importDefault(require("@mat3ra/standata/dist/js/runtime_data/models/modelTree.json"));
|
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
@@ -47,3 +47,9 @@ const getDefaultModelTypeForApplication = (application) => {
|
|
|
47
47
|
return Object.keys((0, exports.getTreeByApplicationNameAndVersion)(application))[0];
|
|
48
48
|
};
|
|
49
49
|
exports.getDefaultModelTypeForApplication = getDefaultModelTypeForApplication;
|
|
50
|
+
const getDefaultModelSubtypeForApplicationAndType = (application, type) => {
|
|
51
|
+
const tree = (0, exports.getTreeByApplicationNameAndVersion)(application);
|
|
52
|
+
const subtypes = Object.keys(tree[type] || {});
|
|
53
|
+
return subtypes[0];
|
|
54
|
+
};
|
|
55
|
+
exports.getDefaultModelSubtypeForApplicationAndType = getDefaultModelSubtypeForApplicationAndType;
|
package/package.json
CHANGED
package/src/js/models/factory.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Model } from "../model";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getDefaultModelSubtypeForApplicationAndType,
|
|
4
|
+
getDefaultModelTypeForApplication,
|
|
5
|
+
getTreeByApplicationNameAndVersion,
|
|
6
|
+
} from "../tree";
|
|
3
7
|
import type { ModelConfig } from "../types";
|
|
4
8
|
import { DFTModel } from "./dft";
|
|
5
9
|
|
|
@@ -22,12 +26,15 @@ export class ModelFactory {
|
|
|
22
26
|
if (!application) {
|
|
23
27
|
throw new Error("ModelFactory.createFromApplication: application is required");
|
|
24
28
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
29
|
+
|
|
30
|
+
const tree = getTreeByApplicationNameAndVersion(application);
|
|
31
|
+
if (Object.keys(tree).length === 0) {
|
|
32
|
+
return this.create({ ...config, type: "unknown", subtype: "unknown" });
|
|
30
33
|
}
|
|
31
|
-
|
|
34
|
+
|
|
35
|
+
const type = getDefaultModelTypeForApplication(application);
|
|
36
|
+
const subtype = getDefaultModelSubtypeForApplicationAndType(application, type) || "unknown";
|
|
37
|
+
|
|
38
|
+
return this.create({ ...config, type, subtype });
|
|
32
39
|
}
|
|
33
40
|
}
|
package/src/js/tree.ts
CHANGED
|
@@ -47,3 +47,12 @@ export const getTreeByApplicationNameAndVersion = ({
|
|
|
47
47
|
export const getDefaultModelTypeForApplication = (application: ApplicationSchemaBase): string => {
|
|
48
48
|
return Object.keys(getTreeByApplicationNameAndVersion(application))[0];
|
|
49
49
|
};
|
|
50
|
+
|
|
51
|
+
export const getDefaultModelSubtypeForApplicationAndType = (
|
|
52
|
+
application: ApplicationSchemaBase,
|
|
53
|
+
type: string,
|
|
54
|
+
): string | undefined => {
|
|
55
|
+
const tree = getTreeByApplicationNameAndVersion(application);
|
|
56
|
+
const subtypes = Object.keys(tree[type] || {});
|
|
57
|
+
return subtypes[0];
|
|
58
|
+
};
|