@mat3ra/ade 2025.10.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/.babelrc +17 -0
- package/LICENSE.md +15 -0
- package/README.md +106 -0
- package/dist/js/ApplicationRegistry.d.ts +57 -0
- package/dist/js/ApplicationRegistry.js +171 -0
- package/dist/js/application.d.ts +8 -0
- package/dist/js/application.js +9 -0
- package/dist/js/applicationMixin.d.ts +23 -0
- package/dist/js/applicationMixin.js +48 -0
- package/dist/js/context/ContextProvider.d.ts +83 -0
- package/dist/js/context/ContextProvider.js +139 -0
- package/dist/js/context/ContextProviderRegistryContainer.d.ts +24 -0
- package/dist/js/context/ContextProviderRegistryContainer.js +30 -0
- package/dist/js/context/JSONSchemaFormDataProvider.d.ts +25 -0
- package/dist/js/context/JSONSchemaFormDataProvider.js +46 -0
- package/dist/js/executable.d.ts +8 -0
- package/dist/js/executable.js +12 -0
- package/dist/js/executableMixin.d.ts +22 -0
- package/dist/js/executableMixin.js +28 -0
- package/dist/js/flavor.d.ts +9 -0
- package/dist/js/flavor.js +12 -0
- package/dist/js/flavorMixin.d.ts +21 -0
- package/dist/js/flavorMixin.js +51 -0
- package/dist/js/index.d.ts +5 -0
- package/dist/js/index.js +14 -0
- package/dist/js/template.d.ts +8 -0
- package/dist/js/template.js +10 -0
- package/dist/js/templateMixin.d.ts +39 -0
- package/dist/js/templateMixin.js +162 -0
- package/package.json +88 -0
- package/src/js/ApplicationRegistry.ts +250 -0
- package/src/js/application.ts +18 -0
- package/src/js/applicationMixin.ts +86 -0
- package/src/js/context/ContextProvider.ts +189 -0
- package/src/js/context/ContextProviderRegistryContainer.ts +41 -0
- package/src/js/context/JSONSchemaFormDataProvider.ts +57 -0
- package/src/js/executable.ts +14 -0
- package/src/js/executableMixin.ts +49 -0
- package/src/js/flavor.ts +19 -0
- package/src/js/flavorMixin.ts +77 -0
- package/src/js/index.ts +6 -0
- package/src/js/template.ts +17 -0
- package/src/js/templateMixin.ts +242 -0
- package/tsconfig.json +3 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ContextProviderName = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* @summary This is a standalone class that contains "data" for a property with "name". Helps facilitate UI logic.
|
|
9
|
+
* Can be initialized from context when user edits are present:
|
|
10
|
+
* - user edits the corresponding property, eg. "kpath"
|
|
11
|
+
* - isKpathEdited is set to `true`
|
|
12
|
+
* - context property is updated for the parent entity (eg. Unit) in a way that persists in Redux state
|
|
13
|
+
* - new entity inherits the "data" through "context" field in config
|
|
14
|
+
* - `extraData` field is used to store any other data that should be passed from one instance of provider
|
|
15
|
+
* to next one, for example data about material to track when it is changed.
|
|
16
|
+
* @notes Should hold static data only (see `setData` method), no classes or functions
|
|
17
|
+
*/
|
|
18
|
+
const utils_1 = require("@mat3ra/utils");
|
|
19
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
20
|
+
// TODO: separate application-specific CPs
|
|
21
|
+
var ContextProviderName;
|
|
22
|
+
(function (ContextProviderName) {
|
|
23
|
+
ContextProviderName["PlanewaveCutoffDataManager"] = "PlanewaveCutoffDataManager";
|
|
24
|
+
ContextProviderName["KGridFormDataManager"] = "KGridFormDataManager";
|
|
25
|
+
ContextProviderName["QGridFormDataManager"] = "QGridFormDataManager";
|
|
26
|
+
ContextProviderName["IGridFormDataManager"] = "IGridFormDataManager";
|
|
27
|
+
ContextProviderName["QPathFormDataManager"] = "QPathFormDataManager";
|
|
28
|
+
ContextProviderName["IPathFormDataManager"] = "IPathFormDataManager";
|
|
29
|
+
ContextProviderName["KPathFormDataManager"] = "KPathFormDataManager";
|
|
30
|
+
ContextProviderName["ExplicitKPathFormDataManager"] = "ExplicitKPathFormDataManager";
|
|
31
|
+
ContextProviderName["ExplicitKPath2PIBAFormDataManager"] = "ExplicitKPath2PIBAFormDataManager";
|
|
32
|
+
ContextProviderName["HubbardJContextManager"] = "HubbardJContextManager";
|
|
33
|
+
ContextProviderName["HubbardUContextManager"] = "HubbardUContextManager";
|
|
34
|
+
ContextProviderName["HubbardVContextManager"] = "HubbardVContextManager";
|
|
35
|
+
ContextProviderName["HubbardContextManagerLegacy"] = "HubbardContextManagerLegacy";
|
|
36
|
+
ContextProviderName["NEBFormDataManager"] = "NEBFormDataManager";
|
|
37
|
+
ContextProviderName["BoundaryConditionsFormDataManager"] = "BoundaryConditionsFormDataManager";
|
|
38
|
+
ContextProviderName["MLSettingsDataManager"] = "MLSettingsDataManager";
|
|
39
|
+
ContextProviderName["MLTrainTestSplitDataManager"] = "MLTrainTestSplitDataManager";
|
|
40
|
+
ContextProviderName["IonDynamicsContextProvider"] = "IonDynamicsContextProvider";
|
|
41
|
+
ContextProviderName["CollinearMagnetizationDataManager"] = "CollinearMagnetizationDataManager";
|
|
42
|
+
ContextProviderName["NonCollinearMagnetizationDataManager"] = "NonCollinearMagnetizationDataManager";
|
|
43
|
+
ContextProviderName["QEPWXInputDataManager"] = "QEPWXInputDataManager";
|
|
44
|
+
ContextProviderName["QENEBInputDataManager"] = "QENEBInputDataManager";
|
|
45
|
+
ContextProviderName["VASPInputDataManager"] = "VASPInputDataManager";
|
|
46
|
+
ContextProviderName["VASPNEBInputDataManager"] = "VASPNEBInputDataManager";
|
|
47
|
+
ContextProviderName["NWChemInputDataManager"] = "NWChemInputDataManager";
|
|
48
|
+
})(ContextProviderName || (exports.ContextProviderName = ContextProviderName = {}));
|
|
49
|
+
class ContextProvider {
|
|
50
|
+
constructor(config) {
|
|
51
|
+
this.config = config;
|
|
52
|
+
this.name = config.name; // property name, ie. "kpath"
|
|
53
|
+
this.domain = config.domain || "default";
|
|
54
|
+
// if context is passed inside config, treat it as additional config
|
|
55
|
+
// eslint-disable-next-line no-param-reassign
|
|
56
|
+
if (config.context)
|
|
57
|
+
config = ContextProvider.createConfigFromContext(config);
|
|
58
|
+
this.entityName = config.entityName || "unit"; // entity this provider yields data to, eg. "unit", "subworkflow"
|
|
59
|
+
this.data = config.data; // property data container
|
|
60
|
+
this.extraData = config.extraData; // property extraData container, used track changes to data, for example
|
|
61
|
+
this.isEdited = config.isEdited; // whether property was edited by user, available under `isEdited` key
|
|
62
|
+
this.setIsEdited = this.setIsEdited.bind(this);
|
|
63
|
+
this.getData = this.getData.bind(this);
|
|
64
|
+
this.setData = this.setData.bind(this);
|
|
65
|
+
this.transformData = this.transformData.bind(this);
|
|
66
|
+
this.yieldData = this.yieldData.bind(this);
|
|
67
|
+
}
|
|
68
|
+
static getConstructorConfig(config) {
|
|
69
|
+
return {
|
|
70
|
+
constructor: this.prototype.constructor,
|
|
71
|
+
config,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
static createConfigFromContext(config) {
|
|
75
|
+
const data = lodash_1.default.get(config.context, config.name);
|
|
76
|
+
const isEdited = lodash_1.default.get(config.context, this.getIsEditedKeyByName(config.name));
|
|
77
|
+
const extraData = lodash_1.default.get(config.context, this.getExtraDataKeyByName(config.name));
|
|
78
|
+
return Object.assign(config, data
|
|
79
|
+
? {
|
|
80
|
+
data,
|
|
81
|
+
extraData,
|
|
82
|
+
isEdited,
|
|
83
|
+
}
|
|
84
|
+
: {});
|
|
85
|
+
}
|
|
86
|
+
setIsEdited(isEdited) {
|
|
87
|
+
this.isEdited = isEdited;
|
|
88
|
+
}
|
|
89
|
+
getData() {
|
|
90
|
+
return this.isEdited ? this.data : this.defaultData;
|
|
91
|
+
}
|
|
92
|
+
setData(data) {
|
|
93
|
+
this.data = utils_1.Utils.clone.deepClone(data);
|
|
94
|
+
}
|
|
95
|
+
// override in children
|
|
96
|
+
// eslint-disable-next-line class-methods-use-this
|
|
97
|
+
get defaultData() {
|
|
98
|
+
throw new Error("Not implemented.");
|
|
99
|
+
}
|
|
100
|
+
// override in children
|
|
101
|
+
// eslint-disable-next-line class-methods-use-this
|
|
102
|
+
transformData(data) {
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
|
+
yieldData(...transformDataArgs) {
|
|
107
|
+
const extraDataObject = this.extraData ? { [this.extraDataKey]: this.extraData } : {};
|
|
108
|
+
return {
|
|
109
|
+
...extraDataObject,
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
[this.name]: this.transformData(this.getData(), ...transformDataArgs),
|
|
112
|
+
[this.isEditedKey]: this.isEdited,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
// override when this.data needs additional processing before making it available to rendering context
|
|
116
|
+
// used to calculate explicit points path, for example
|
|
117
|
+
yieldDataForRendering() {
|
|
118
|
+
return this.yieldData();
|
|
119
|
+
}
|
|
120
|
+
get extraDataKey() {
|
|
121
|
+
return `${this.name}ExtraData`;
|
|
122
|
+
}
|
|
123
|
+
static getExtraDataKeyByName(name) {
|
|
124
|
+
return `${name}ExtraData`;
|
|
125
|
+
}
|
|
126
|
+
get isEditedKey() {
|
|
127
|
+
return `is${lodash_1.default.capitalize(this.name)}Edited`;
|
|
128
|
+
}
|
|
129
|
+
static getIsEditedKeyByName(name) {
|
|
130
|
+
return `is${lodash_1.default.capitalize(name)}Edited`;
|
|
131
|
+
}
|
|
132
|
+
get isUnitContextProvider() {
|
|
133
|
+
return this.entityName === "unit";
|
|
134
|
+
}
|
|
135
|
+
get isSubworkflowContextProvider() {
|
|
136
|
+
return this.entityName === "subworkflow";
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.default = ContextProvider;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ContextProviderInstance } from "./ContextProvider";
|
|
2
|
+
import ContextProvider from "./ContextProvider";
|
|
3
|
+
export default class ContextProviderRegistryContainer {
|
|
4
|
+
_providers: {
|
|
5
|
+
name: string;
|
|
6
|
+
instance: ContextProviderInstance;
|
|
7
|
+
}[];
|
|
8
|
+
constructor();
|
|
9
|
+
get providers(): {
|
|
10
|
+
name: string;
|
|
11
|
+
instance: ContextProviderInstance;
|
|
12
|
+
}[];
|
|
13
|
+
set providers(p: {
|
|
14
|
+
name: string;
|
|
15
|
+
instance: ContextProviderInstance;
|
|
16
|
+
}[]);
|
|
17
|
+
addProvider({ name, instance }: {
|
|
18
|
+
name: string;
|
|
19
|
+
instance: ContextProviderInstance;
|
|
20
|
+
}): void;
|
|
21
|
+
findProviderInstanceByName(name: string): ContextProviderInstance | undefined;
|
|
22
|
+
removeProvider(providerCls: ContextProvider): void;
|
|
23
|
+
removeProviderByName(name: string): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class ContextProviderRegistryContainer {
|
|
4
|
+
constructor() {
|
|
5
|
+
this._providers = [];
|
|
6
|
+
}
|
|
7
|
+
get providers() {
|
|
8
|
+
return this._providers;
|
|
9
|
+
}
|
|
10
|
+
set providers(p) {
|
|
11
|
+
this._providers = p;
|
|
12
|
+
}
|
|
13
|
+
addProvider({ name, instance }) {
|
|
14
|
+
this._providers.push({
|
|
15
|
+
name,
|
|
16
|
+
instance,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
findProviderInstanceByName(name) {
|
|
20
|
+
const provider = this.providers.find((p) => p.name === name);
|
|
21
|
+
return provider && provider.instance;
|
|
22
|
+
}
|
|
23
|
+
removeProvider(providerCls) {
|
|
24
|
+
this.providers = this.providers.filter((p) => p.name !== providerCls.name);
|
|
25
|
+
}
|
|
26
|
+
removeProviderByName(name) {
|
|
27
|
+
this.providers = this.providers.filter((p) => p.name !== name);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = ContextProviderRegistryContainer;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { UiSchema } from "react-jsonschema-form";
|
|
2
|
+
import ContextProvider, { type ContextProviderConfig } from "./ContextProvider";
|
|
3
|
+
interface JSONSchemaFormDataProviderConfig extends ContextProviderConfig {
|
|
4
|
+
isUsingJinjaVariables?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @summary Provides jsonSchema and uiSchema for generating react-jsonschema-form
|
|
8
|
+
* See https://github.com/mozilla-services/react-jsonschema-form for Form UI.
|
|
9
|
+
* Form generation example:
|
|
10
|
+
* ```
|
|
11
|
+
* <Form schema={provider.jsonSchema}
|
|
12
|
+
* uiSchema={provider.uiSchema}
|
|
13
|
+
* formData={provider.getData(unit.important)} />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export default class JSONSchemaFormDataProvider extends ContextProvider {
|
|
17
|
+
isUsingJinjaVariables: boolean;
|
|
18
|
+
constructor(config: JSONSchemaFormDataProviderConfig);
|
|
19
|
+
get jsonSchema(): void;
|
|
20
|
+
get uiSchema(): UiSchema;
|
|
21
|
+
get fields(): {};
|
|
22
|
+
get defaultFieldStyles(): {};
|
|
23
|
+
get uiSchemaStyled(): UiSchema;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ContextProvider_1 = __importDefault(require("./ContextProvider"));
|
|
7
|
+
/**
|
|
8
|
+
* @summary Provides jsonSchema and uiSchema for generating react-jsonschema-form
|
|
9
|
+
* See https://github.com/mozilla-services/react-jsonschema-form for Form UI.
|
|
10
|
+
* Form generation example:
|
|
11
|
+
* ```
|
|
12
|
+
* <Form schema={provider.jsonSchema}
|
|
13
|
+
* uiSchema={provider.uiSchema}
|
|
14
|
+
* formData={provider.getData(unit.important)} />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
class JSONSchemaFormDataProvider extends ContextProvider_1.default {
|
|
18
|
+
constructor(config) {
|
|
19
|
+
super(config);
|
|
20
|
+
this.isUsingJinjaVariables = Boolean(config === null || config === void 0 ? void 0 : config.isUsingJinjaVariables);
|
|
21
|
+
}
|
|
22
|
+
get jsonSchema() {
|
|
23
|
+
throw new Error("Not implemented.");
|
|
24
|
+
}
|
|
25
|
+
get uiSchema() {
|
|
26
|
+
throw new Error("Not implemented.");
|
|
27
|
+
}
|
|
28
|
+
get fields() {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
get defaultFieldStyles() {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
get uiSchemaStyled() {
|
|
35
|
+
const schema = this.uiSchema;
|
|
36
|
+
return Object.fromEntries(Object.entries(schema).map(([key, value]) => [
|
|
37
|
+
key,
|
|
38
|
+
{
|
|
39
|
+
...value,
|
|
40
|
+
...this.defaultFieldStyles,
|
|
41
|
+
classNames: `${value.classNames || ""}`,
|
|
42
|
+
},
|
|
43
|
+
]));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.default = JSONSchemaFormDataProvider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity";
|
|
2
|
+
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
|
|
3
|
+
import { type ExecutableMixin } from "./executableMixin";
|
|
4
|
+
type Base = Constructor<ExecutableMixin> & typeof NamedDefaultableInMemoryEntity;
|
|
5
|
+
declare const Executable_base: Base;
|
|
6
|
+
export default class Executable extends Executable_base {
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const entity_1 = require("@mat3ra/code/dist/js/entity");
|
|
4
|
+
const RuntimeItemsMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin");
|
|
5
|
+
const executableMixin_1 = require("./executableMixin");
|
|
6
|
+
class Executable extends entity_1.NamedDefaultableInMemoryEntity {
|
|
7
|
+
}
|
|
8
|
+
exports.default = Executable;
|
|
9
|
+
// Apply mixins
|
|
10
|
+
(0, RuntimeItemsMixin_1.runtimeItemsMixin)(Executable.prototype);
|
|
11
|
+
(0, executableMixin_1.executableMixin)(Executable.prototype);
|
|
12
|
+
(0, executableMixin_1.executableStaticMixin)(Executable);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
|
|
2
|
+
import type { DefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin";
|
|
3
|
+
import type { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin";
|
|
4
|
+
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
|
|
5
|
+
import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
|
|
6
|
+
import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types";
|
|
7
|
+
import type { FlavorMixin } from "./flavorMixin";
|
|
8
|
+
type BaseFlavor = FlavorMixin & NamedInMemoryEntity & InMemoryEntity;
|
|
9
|
+
type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity;
|
|
10
|
+
export declare function executableMixin(item: Base): void;
|
|
11
|
+
export declare function executableStaticMixin(Executable: Constructor<Base>): void;
|
|
12
|
+
export type BaseConstructor = Constructor<Base> & {
|
|
13
|
+
constructCustomFlavor?: (config: object) => BaseFlavor;
|
|
14
|
+
};
|
|
15
|
+
export type ExecutableMixin = {
|
|
16
|
+
applicationId: string[];
|
|
17
|
+
toJSON: () => ExecutableSchema & AnyObject;
|
|
18
|
+
};
|
|
19
|
+
export type ExecutableStaticMixin = {
|
|
20
|
+
jsonSchema: ExecutableSchema;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.executableMixin = executableMixin;
|
|
7
|
+
exports.executableStaticMixin = executableStaticMixin;
|
|
8
|
+
const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface"));
|
|
9
|
+
function executableMixin(item) {
|
|
10
|
+
// @ts-expect-error
|
|
11
|
+
const properties = {
|
|
12
|
+
get applicationId() {
|
|
13
|
+
return this.prop("applicationId", []);
|
|
14
|
+
},
|
|
15
|
+
set applicationId(value) {
|
|
16
|
+
this.setProp("applicationId", value);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
|
|
20
|
+
}
|
|
21
|
+
function executableStaticMixin(Executable) {
|
|
22
|
+
const properties = {
|
|
23
|
+
get jsonSchema() {
|
|
24
|
+
return JSONSchemasInterface_1.default.getSchemaById("software/executable");
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperties(Executable, Object.getOwnPropertyDescriptors(properties));
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity";
|
|
2
|
+
import { type RuntimeItemsInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin";
|
|
3
|
+
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
|
|
4
|
+
import { type FlavorMixin } from "./flavorMixin";
|
|
5
|
+
type Base = typeof NamedDefaultableInMemoryEntity & Constructor<FlavorMixin> & Constructor<RuntimeItemsInMemoryEntity>;
|
|
6
|
+
declare const Flavor_base: Base;
|
|
7
|
+
export default class Flavor extends Flavor_base {
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const entity_1 = require("@mat3ra/code/dist/js/entity");
|
|
4
|
+
const RuntimeItemsMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin");
|
|
5
|
+
const flavorMixin_1 = require("./flavorMixin");
|
|
6
|
+
class Flavor extends entity_1.NamedDefaultableInMemoryEntity {
|
|
7
|
+
}
|
|
8
|
+
exports.default = Flavor;
|
|
9
|
+
// Apply mixins
|
|
10
|
+
(0, flavorMixin_1.flavorMixin)(Flavor.prototype);
|
|
11
|
+
(0, RuntimeItemsMixin_1.runtimeItemsMixin)(Flavor.prototype);
|
|
12
|
+
(0, flavorMixin_1.flavorStaticMixin)(Flavor);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
|
|
2
|
+
import type { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin";
|
|
3
|
+
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
|
|
4
|
+
import type { FlavorSchema } from "@mat3ra/esse/dist/js/types";
|
|
5
|
+
type Base = InMemoryEntity & NamedInMemoryEntity;
|
|
6
|
+
type Input = Required<FlavorSchema>["input"];
|
|
7
|
+
export type FlavorMixin = {
|
|
8
|
+
input: Input;
|
|
9
|
+
disableRenderMaterials: boolean;
|
|
10
|
+
executableId: string;
|
|
11
|
+
executableName: string;
|
|
12
|
+
applicationName: string;
|
|
13
|
+
supportedApplicationVersions?: string[];
|
|
14
|
+
getInputAsRenderedTemplates: (context: Record<string, unknown>) => Record<string, unknown>[];
|
|
15
|
+
};
|
|
16
|
+
export declare function flavorMixin(item: Base): FlavorMixin & InMemoryEntity & NamedInMemoryEntity;
|
|
17
|
+
export declare function flavorStaticMixin(Flavor: Constructor<Base>): void;
|
|
18
|
+
export type FlavorStaticMixin = {
|
|
19
|
+
jsonSchema: FlavorSchema;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.flavorMixin = flavorMixin;
|
|
7
|
+
exports.flavorStaticMixin = flavorStaticMixin;
|
|
8
|
+
const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface"));
|
|
9
|
+
// TODO: should we add fields from esse schema (executableId, executableName, applicationName)?
|
|
10
|
+
function flavorMixin(item) {
|
|
11
|
+
// @ts-expect-error
|
|
12
|
+
const properties = {
|
|
13
|
+
get input() {
|
|
14
|
+
return this.prop("input", []);
|
|
15
|
+
},
|
|
16
|
+
get disableRenderMaterials() {
|
|
17
|
+
return this.prop("isMultiMaterial", false);
|
|
18
|
+
},
|
|
19
|
+
get executableId() {
|
|
20
|
+
return this.prop("executableId", "");
|
|
21
|
+
},
|
|
22
|
+
get executableName() {
|
|
23
|
+
return this.prop("executableName", "");
|
|
24
|
+
},
|
|
25
|
+
get applicationName() {
|
|
26
|
+
return this.prop("applicationName", "");
|
|
27
|
+
},
|
|
28
|
+
get supportedApplicationVersions() {
|
|
29
|
+
return this.prop("supportedApplicationVersions");
|
|
30
|
+
},
|
|
31
|
+
getInputAsRenderedTemplates(context) {
|
|
32
|
+
const input = this.input;
|
|
33
|
+
return input.map((template) => {
|
|
34
|
+
if (template && typeof template === "object" && "getRenderedJSON" in template) {
|
|
35
|
+
return template.getRenderedJSON(context);
|
|
36
|
+
}
|
|
37
|
+
return template;
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
|
|
42
|
+
return properties;
|
|
43
|
+
}
|
|
44
|
+
function flavorStaticMixin(Flavor) {
|
|
45
|
+
const properties = {
|
|
46
|
+
get jsonSchema() {
|
|
47
|
+
return JSONSchemasInterface_1.default.getSchemaById("software/flavor");
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperties(Flavor, Object.getOwnPropertyDescriptors(properties));
|
|
51
|
+
}
|
package/dist/js/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Template = exports.Flavor = exports.Executable = exports.Application = void 0;
|
|
7
|
+
const application_1 = __importDefault(require("./application"));
|
|
8
|
+
exports.Application = application_1.default;
|
|
9
|
+
const executable_1 = __importDefault(require("./executable"));
|
|
10
|
+
exports.Executable = executable_1.default;
|
|
11
|
+
const flavor_1 = __importDefault(require("./flavor"));
|
|
12
|
+
exports.Flavor = flavor_1.default;
|
|
13
|
+
const template_1 = __importDefault(require("./template"));
|
|
14
|
+
exports.Template = template_1.default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity";
|
|
2
|
+
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
|
|
3
|
+
import { type TemplateMixin, type TemplateStaticMixin } from "./templateMixin";
|
|
4
|
+
type Base = typeof NamedInMemoryEntity & Constructor<TemplateMixin> & TemplateStaticMixin;
|
|
5
|
+
declare const Template_base: Base;
|
|
6
|
+
export default class Template extends Template_base {
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const entity_1 = require("@mat3ra/code/dist/js/entity");
|
|
4
|
+
const templateMixin_1 = require("./templateMixin");
|
|
5
|
+
class Template extends entity_1.NamedInMemoryEntity {
|
|
6
|
+
}
|
|
7
|
+
exports.default = Template;
|
|
8
|
+
// Apply mixins
|
|
9
|
+
(0, templateMixin_1.templateMixin)(Template.prototype);
|
|
10
|
+
(0, templateMixin_1.templateStaticMixin)(Template);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
|
|
2
|
+
import type { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin";
|
|
3
|
+
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
|
|
4
|
+
import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
|
|
5
|
+
import type { TemplateSchema } from "@mat3ra/esse/dist/js/types";
|
|
6
|
+
import ContextProvider, { type ContextProviderConfig, type ContextProviderName } from "./context/ContextProvider";
|
|
7
|
+
import ContextProviderRegistryContainer from "./context/ContextProviderRegistryContainer";
|
|
8
|
+
export type TemplateBase = InMemoryEntity & NamedInMemoryEntity;
|
|
9
|
+
export type TemplateMixin = {
|
|
10
|
+
isManuallyChanged: boolean;
|
|
11
|
+
content: string;
|
|
12
|
+
rendered: string | undefined;
|
|
13
|
+
applicationName: string | undefined;
|
|
14
|
+
executableName: string | undefined;
|
|
15
|
+
contextProviders: ContextProvider[];
|
|
16
|
+
addContextProvider: (provider: ContextProvider) => void;
|
|
17
|
+
removeContextProvider: (provider: ContextProvider) => void;
|
|
18
|
+
render: (externalContext?: Record<string, unknown>) => void;
|
|
19
|
+
getRenderedJSON: (context?: Record<string, unknown>) => AnyObject;
|
|
20
|
+
_cleanRenderingContext: (object: Record<string, unknown>) => Record<string, unknown>;
|
|
21
|
+
getDataFromProvidersForRenderingContext: (context?: Record<string, unknown>) => Record<string, unknown>;
|
|
22
|
+
setContent: (text: string) => void;
|
|
23
|
+
setRendered: (text: string) => void;
|
|
24
|
+
getContextProvidersAsClassInstances: (providerContext?: Record<string, unknown>) => ContextProvider[];
|
|
25
|
+
getDataFromProvidersForPersistentContext: (providerContext?: Record<string, unknown>) => Record<string, unknown>;
|
|
26
|
+
getRenderingContext: (externalContext?: Record<string, unknown>) => Record<string, unknown>;
|
|
27
|
+
};
|
|
28
|
+
export declare function templateMixin(item: TemplateBase): TemplateMixin & InMemoryEntity & NamedInMemoryEntity;
|
|
29
|
+
export type ContextProviderConfigMapEntry = {
|
|
30
|
+
providerCls: typeof ContextProvider;
|
|
31
|
+
config: ContextProviderConfig;
|
|
32
|
+
};
|
|
33
|
+
export type ContextProviderConfigMap = Partial<Record<ContextProviderName, ContextProviderConfigMapEntry>>;
|
|
34
|
+
export type TemplateStaticMixin = {
|
|
35
|
+
contextProviderRegistry: ContextProviderRegistryContainer | null;
|
|
36
|
+
setContextProvidersConfig: (classConfigMap: ContextProviderConfigMap) => void;
|
|
37
|
+
jsonSchema: TemplateSchema;
|
|
38
|
+
};
|
|
39
|
+
export declare function templateStaticMixin(item: Constructor<TemplateBase & TemplateMixin>): TemplateStaticMixin & Constructor<InMemoryEntity & NamedInMemoryEntity & TemplateMixin>;
|