@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
package/.babelrc
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright 2022 Exabyte Inc.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
[](https://badge.fury.io/js/%40mat3ra%2Fade.js)
|
|
2
|
+
[](https://www.apache.org/licenses/LICENSE-2.0)
|
|
3
|
+
|
|
4
|
+
# @mat3ra/ade
|
|
5
|
+
|
|
6
|
+
ade.js houses entity definitions for use in the Mat3ra platform.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Installation
|
|
10
|
+
|
|
11
|
+
For usage within a javascript project:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @mat3ra/ade.js
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For development:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
git clone https://github.com/Exabyte-io/ade.git
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Contribution
|
|
25
|
+
|
|
26
|
+
This repository is an [open-source](LICENSE.md) work-in-progress and we welcome contributions.
|
|
27
|
+
|
|
28
|
+
We regularly deploy the latest code containing all accepted contributions online as part of the
|
|
29
|
+
[Mat3ra.com](https://mat3ra.com) platform, so contributors will see their code in action there.
|
|
30
|
+
|
|
31
|
+
See [ESSE](https://github.com/Exabyte-io/esse) for additional context regarding the data schemas used here.
|
|
32
|
+
|
|
33
|
+
Useful commands for development:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# run linter without persistence
|
|
37
|
+
npm run lint
|
|
38
|
+
|
|
39
|
+
# run linter and save edits
|
|
40
|
+
npm run lint:fix
|
|
41
|
+
|
|
42
|
+
# compile the library
|
|
43
|
+
npm run transpile
|
|
44
|
+
|
|
45
|
+
# run tests
|
|
46
|
+
npm run test
|
|
47
|
+
|
|
48
|
+
# run tests with coverage
|
|
49
|
+
npm run test:coverage
|
|
50
|
+
|
|
51
|
+
# run tests with coverage and check thresholds
|
|
52
|
+
npm run test:coverage:check
|
|
53
|
+
|
|
54
|
+
# generate HTML coverage report
|
|
55
|
+
npm run test:coverage:html
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Code Coverage
|
|
59
|
+
|
|
60
|
+
This project includes comprehensive code coverage reporting with multiple viewing options:
|
|
61
|
+
|
|
62
|
+
### Local Coverage
|
|
63
|
+
- Run `npm run test:coverage:html` to generate an HTML coverage report locally
|
|
64
|
+
- Open `coverage/index.html` in your browser to view the report
|
|
65
|
+
|
|
66
|
+
### GitHub Integration
|
|
67
|
+
The project uses GitHub Actions to automatically generate and display coverage reports:
|
|
68
|
+
|
|
69
|
+
1. **PR Coverage Comments**: Every pull request automatically gets a coverage report comment showing:
|
|
70
|
+
- Overall coverage percentages
|
|
71
|
+
- Coverage changes compared to the base branch
|
|
72
|
+
- Detailed file-by-file coverage breakdown
|
|
73
|
+
|
|
74
|
+
2. **Coverage Artifacts**: Coverage reports are uploaded as GitHub artifacts for each PR and commit
|
|
75
|
+
- Download from the Actions tab in GitHub
|
|
76
|
+
- Available for 30 days for main branch, 7 days for PRs
|
|
77
|
+
|
|
78
|
+
3. **GitHub Pages** (Optional): Coverage reports are published to GitHub Pages for easy browser viewing
|
|
79
|
+
- Available at: `https://exabyte-io.github.io/ade/`
|
|
80
|
+
- Updated on every push to main branch
|
|
81
|
+
|
|
82
|
+
### Coverage Thresholds
|
|
83
|
+
The project enforces minimum coverage thresholds:
|
|
84
|
+
- **Statements**: 85%
|
|
85
|
+
- **Branches**: 80%
|
|
86
|
+
- **Functions**: 80%
|
|
87
|
+
- **Lines**: 85%
|
|
88
|
+
|
|
89
|
+
### External Coverage Services
|
|
90
|
+
- **Codecov**: Coverage data is automatically uploaded to Codecov for historical tracking and trend analysis
|
|
91
|
+
|
|
92
|
+
ADe
|
|
93
|
+
===
|
|
94
|
+
|
|
95
|
+
The`ADe` package sits just below the `WoDe` package in the Mat3ra workflow
|
|
96
|
+
ecosystem, where `ADe` houses entity definitions for:
|
|
97
|
+
|
|
98
|
+
- `Application` - uniquely determined by `name, [version], [build]`
|
|
99
|
+
- `Executable` - defined for a given application and accessible from application by name
|
|
100
|
+
- `Flavor` - defined for a given executable and accessible from executable by name
|
|
101
|
+
- `Template` - a jinja template for an application input file
|
|
102
|
+
|
|
103
|
+
The relevant data parameterizing these entities is housed in
|
|
104
|
+
the [Application Flavors](https://github.com/Exabyte-io/standata)
|
|
105
|
+
repository. This includes the supported applications, executables, flavors,
|
|
106
|
+
and defined templates.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ApplicationSchemaBase } from "@mat3ra/esse/dist/js/types";
|
|
2
|
+
import Application from "./application";
|
|
3
|
+
import Executable from "./executable";
|
|
4
|
+
import Flavor from "./flavor";
|
|
5
|
+
import Template from "./template";
|
|
6
|
+
type ApplicationVersion = {
|
|
7
|
+
[build: string]: ApplicationSchemaBase;
|
|
8
|
+
};
|
|
9
|
+
type ApplicationTreeItem = {
|
|
10
|
+
defaultVersion: string;
|
|
11
|
+
[version: string]: ApplicationVersion | string;
|
|
12
|
+
};
|
|
13
|
+
export type CreateApplicationConfig = {
|
|
14
|
+
name: string;
|
|
15
|
+
version?: string | null;
|
|
16
|
+
build?: string | null;
|
|
17
|
+
};
|
|
18
|
+
type ApplicationTree = Partial<Record<string, ApplicationTreeItem>>;
|
|
19
|
+
export default class ApplicationRegistry {
|
|
20
|
+
static applicationsTree?: ApplicationTree;
|
|
21
|
+
static applicationsArray?: ApplicationSchemaBase[];
|
|
22
|
+
static createApplication({ name, version, build }: CreateApplicationConfig): Application;
|
|
23
|
+
static getUniqueAvailableApplicationNames(): string[];
|
|
24
|
+
/**
|
|
25
|
+
* @summary Return all applications as both a nested object of Applications and an array of config objects
|
|
26
|
+
* @returns containing applications and applicationConfigs
|
|
27
|
+
*/
|
|
28
|
+
static getAllApplications(): {
|
|
29
|
+
applicationsTree: Partial<Record<string, ApplicationTreeItem>>;
|
|
30
|
+
applicationsArray: ApplicationSchemaBase[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* @summary Get an application from the constructed applications
|
|
34
|
+
* @param name name of the application
|
|
35
|
+
* @param version version of the application (optional, defaults to defaultVersion)
|
|
36
|
+
* @param build the build to use (optional, defaults to Default)
|
|
37
|
+
* @return an application
|
|
38
|
+
*/
|
|
39
|
+
static getApplicationConfig({ name, version, build }: CreateApplicationConfig): ApplicationSchemaBase | null;
|
|
40
|
+
static getExecutables({ name, version }: {
|
|
41
|
+
name: string;
|
|
42
|
+
version?: string;
|
|
43
|
+
}): Executable[];
|
|
44
|
+
static getExecutableByName(appName: string, execName?: string): Executable;
|
|
45
|
+
static getExecutableByConfig(appName: string, config?: {
|
|
46
|
+
name: string;
|
|
47
|
+
}): Executable;
|
|
48
|
+
static getExecutableFlavors(executable: Executable): Flavor[];
|
|
49
|
+
static getFlavorByName(executable: Executable, name?: string): Flavor | undefined;
|
|
50
|
+
static getFlavorByConfig(executable: Executable, config?: {
|
|
51
|
+
name: string;
|
|
52
|
+
}): Flavor | undefined;
|
|
53
|
+
static getInputAsTemplates(flavor: Flavor): Template[];
|
|
54
|
+
static getInputAsRenderedTemplates(flavor: Flavor, context: Record<string, unknown>): import("@mat3ra/esse/dist/js/esse/types").AnyObject[];
|
|
55
|
+
static getAllFlavorsForApplication(appName: string, version?: string): Flavor[];
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
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 object_1 = require("@mat3ra/code/dist/js/utils/object");
|
|
7
|
+
const standata_1 = require("@mat3ra/standata");
|
|
8
|
+
const application_1 = __importDefault(require("./application"));
|
|
9
|
+
const executable_1 = __importDefault(require("./executable"));
|
|
10
|
+
const flavor_1 = __importDefault(require("./flavor"));
|
|
11
|
+
const template_1 = __importDefault(require("./template"));
|
|
12
|
+
class ApplicationRegistry {
|
|
13
|
+
static createApplication({ name, version = null, build = null }) {
|
|
14
|
+
const staticConfig = ApplicationRegistry.getApplicationConfig({ name, version, build });
|
|
15
|
+
return new application_1.default({
|
|
16
|
+
...staticConfig,
|
|
17
|
+
name,
|
|
18
|
+
...(version && { version }),
|
|
19
|
+
...(build && { build }),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
static getUniqueAvailableApplicationNames() {
|
|
23
|
+
return new standata_1.ApplicationStandata().getAllApplicationNames();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @summary Return all applications as both a nested object of Applications and an array of config objects
|
|
27
|
+
* @returns containing applications and applicationConfigs
|
|
28
|
+
*/
|
|
29
|
+
static getAllApplications() {
|
|
30
|
+
if (this.applicationsTree && this.applicationsArray) {
|
|
31
|
+
return {
|
|
32
|
+
applicationsTree: this.applicationsTree,
|
|
33
|
+
applicationsArray: this.applicationsArray,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const applicationsTree = {};
|
|
37
|
+
const applicationsArray = [];
|
|
38
|
+
const allApplications = new standata_1.ApplicationStandata().getAllApplicationNames();
|
|
39
|
+
allApplications.forEach((appName) => {
|
|
40
|
+
const { versions, defaultVersion, ...appData } = new standata_1.ApplicationStandata().getAppDataForApplication(appName);
|
|
41
|
+
const appTreeItem = { defaultVersion };
|
|
42
|
+
versions.forEach((versionInfo) => {
|
|
43
|
+
const { version, build } = versionInfo;
|
|
44
|
+
let buildToUse = build;
|
|
45
|
+
if (!build) {
|
|
46
|
+
buildToUse = standata_1.ApplicationStandata.getDefaultBuildForApplicationAndVersion(appName, version);
|
|
47
|
+
versionInfo.build = buildToUse;
|
|
48
|
+
}
|
|
49
|
+
const appVersion = version in appTreeItem && typeof appTreeItem[version] === "object"
|
|
50
|
+
? appTreeItem[version]
|
|
51
|
+
: {};
|
|
52
|
+
appTreeItem[version] = appVersion;
|
|
53
|
+
const applicationConfig = {
|
|
54
|
+
...appData,
|
|
55
|
+
build: buildToUse,
|
|
56
|
+
...versionInfo,
|
|
57
|
+
};
|
|
58
|
+
if (buildToUse) {
|
|
59
|
+
appVersion[buildToUse] = applicationConfig;
|
|
60
|
+
}
|
|
61
|
+
applicationsArray.push(applicationConfig);
|
|
62
|
+
});
|
|
63
|
+
applicationsTree[appName] = appTreeItem;
|
|
64
|
+
});
|
|
65
|
+
this.applicationsTree = applicationsTree;
|
|
66
|
+
this.applicationsArray = applicationsArray;
|
|
67
|
+
return {
|
|
68
|
+
applicationsTree,
|
|
69
|
+
applicationsArray: this.applicationsArray,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @summary Get an application from the constructed applications
|
|
74
|
+
* @param name name of the application
|
|
75
|
+
* @param version version of the application (optional, defaults to defaultVersion)
|
|
76
|
+
* @param build the build to use (optional, defaults to Default)
|
|
77
|
+
* @return an application
|
|
78
|
+
*/
|
|
79
|
+
static getApplicationConfig({ name, version = null, build = null }) {
|
|
80
|
+
var _a;
|
|
81
|
+
const { applicationsTree } = this.getAllApplications();
|
|
82
|
+
const app = applicationsTree[name];
|
|
83
|
+
if (!app) {
|
|
84
|
+
throw new Error(`Application ${name} not found`);
|
|
85
|
+
}
|
|
86
|
+
let buildToUse = build;
|
|
87
|
+
if (!build) {
|
|
88
|
+
try {
|
|
89
|
+
buildToUse = standata_1.ApplicationStandata.getDefaultBuildForApplicationAndVersion(name, version || app.defaultVersion);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.warn(`Failed to get default build for ${name} version ${version || app.defaultVersion}: ${error}`);
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const version_ = version || app.defaultVersion;
|
|
97
|
+
const appVersion = app[version_];
|
|
98
|
+
if (!appVersion || typeof appVersion === "string") {
|
|
99
|
+
console.warn(`Version ${version_} not available for ${name} !`);
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
if (!buildToUse) {
|
|
103
|
+
console.warn(`No build specified for ${name} version ${version_}`);
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
return (_a = appVersion[buildToUse]) !== null && _a !== void 0 ? _a : null;
|
|
107
|
+
}
|
|
108
|
+
static getExecutables({ name, version }) {
|
|
109
|
+
const tree = new standata_1.ApplicationStandata().getAppTreeForApplication(name);
|
|
110
|
+
return Object.keys(tree)
|
|
111
|
+
.filter((key) => {
|
|
112
|
+
const executable = tree[key];
|
|
113
|
+
const { supportedApplicationVersions } = executable;
|
|
114
|
+
return (!supportedApplicationVersions ||
|
|
115
|
+
(version && supportedApplicationVersions.includes(version)));
|
|
116
|
+
})
|
|
117
|
+
.map((key) => new executable_1.default({ ...tree[key], name: key }));
|
|
118
|
+
}
|
|
119
|
+
static getExecutableByName(appName, execName) {
|
|
120
|
+
const appTree = new standata_1.ApplicationStandata().getAppTreeForApplication(appName);
|
|
121
|
+
Object.entries(appTree).forEach(([name, exec]) => {
|
|
122
|
+
exec.name = name;
|
|
123
|
+
});
|
|
124
|
+
const config = execName
|
|
125
|
+
? appTree[execName]
|
|
126
|
+
: (0, object_1.getOneMatchFromObject)(appTree, "isDefault", true);
|
|
127
|
+
return new executable_1.default(config);
|
|
128
|
+
}
|
|
129
|
+
// TODO: remove this method and use getApplicationExecutableByName directly
|
|
130
|
+
static getExecutableByConfig(appName, config) {
|
|
131
|
+
return this.getExecutableByName(appName, config === null || config === void 0 ? void 0 : config.name);
|
|
132
|
+
}
|
|
133
|
+
static getExecutableFlavors(executable) {
|
|
134
|
+
const flavorsTree = executable.prop("flavors", {});
|
|
135
|
+
return Object.keys(flavorsTree).map((key) => {
|
|
136
|
+
return new flavor_1.default({
|
|
137
|
+
...flavorsTree[key],
|
|
138
|
+
name: key,
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
static getFlavorByName(executable, name) {
|
|
143
|
+
return this.getExecutableFlavors(executable).find((flavor) => name ? flavor.name === name : flavor.isDefault);
|
|
144
|
+
}
|
|
145
|
+
static getFlavorByConfig(executable, config) {
|
|
146
|
+
return this.getFlavorByName(executable, config === null || config === void 0 ? void 0 : config.name);
|
|
147
|
+
}
|
|
148
|
+
// flavors
|
|
149
|
+
static getInputAsTemplates(flavor) {
|
|
150
|
+
const appName = flavor.prop("applicationName", "");
|
|
151
|
+
const execName = flavor.prop("executableName", "");
|
|
152
|
+
return flavor.input.map((input) => {
|
|
153
|
+
const inputName = input.templateName || input.name;
|
|
154
|
+
const filtered = new standata_1.ApplicationStandata().getTemplatesByName(appName, execName, inputName);
|
|
155
|
+
if (filtered.length !== 1) {
|
|
156
|
+
console.log(`found ${filtered.length} templates for app=${appName} exec=${execName} name=${inputName} expected 1`);
|
|
157
|
+
}
|
|
158
|
+
return new template_1.default({ ...filtered[0], name: input.name });
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
static getInputAsRenderedTemplates(flavor, context) {
|
|
162
|
+
return this.getInputAsTemplates(flavor).map((template) => {
|
|
163
|
+
return template.getRenderedJSON(context);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
static getAllFlavorsForApplication(appName, version) {
|
|
167
|
+
const allExecutables = this.getExecutables({ name: appName, version });
|
|
168
|
+
return allExecutables.flatMap((executable) => this.getExecutableFlavors(executable));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
exports.default = ApplicationRegistry;
|
|
@@ -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 ApplicationMixin, type ApplicationStaticMixin } from "./applicationMixin";
|
|
4
|
+
type Base = typeof NamedDefaultableInMemoryEntity & Constructor<ApplicationMixin> & ApplicationStaticMixin;
|
|
5
|
+
declare const Application_base: Base;
|
|
6
|
+
export default class Application extends Application_base {
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const entity_1 = require("@mat3ra/code/dist/js/entity");
|
|
4
|
+
const applicationMixin_1 = require("./applicationMixin");
|
|
5
|
+
class Application extends entity_1.NamedDefaultableInMemoryEntity {
|
|
6
|
+
}
|
|
7
|
+
exports.default = Application;
|
|
8
|
+
(0, applicationMixin_1.applicationMixin)(Application.prototype);
|
|
9
|
+
(0, applicationMixin_1.applicationStaticMixin)(Application);
|
|
@@ -0,0 +1,23 @@
|
|
|
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 { ApplicationSchemaBase } from "@mat3ra/esse/dist/js/types";
|
|
6
|
+
import Executable from "./executable";
|
|
7
|
+
type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity;
|
|
8
|
+
export type BaseConstructor = Constructor<Base> & {
|
|
9
|
+
constructCustomExecutable?: (config: object) => Executable;
|
|
10
|
+
};
|
|
11
|
+
export type ApplicationConstructor = Constructor<ApplicationMixin> & ApplicationStaticMixin;
|
|
12
|
+
export type ApplicationMixin = Pick<ApplicationSchemaBase, "summary" | "version" | "build" | "shortName" | "hasAdvancedComputeOptions" | "isLicensed"> & {
|
|
13
|
+
name: Required<ApplicationSchemaBase>["name"];
|
|
14
|
+
isUsingMaterial: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type DefaultApplicationConfig = Pick<ApplicationSchemaBase, "name" | "shortName" | "version" | "summary" | "build">;
|
|
17
|
+
export type ApplicationStaticMixin = {
|
|
18
|
+
defaultConfig: DefaultApplicationConfig;
|
|
19
|
+
jsonSchema: ApplicationSchemaBase;
|
|
20
|
+
};
|
|
21
|
+
export declare function applicationMixin(item: Base): void;
|
|
22
|
+
export declare function applicationStaticMixin<T extends BaseConstructor>(Application: T): void;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
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.applicationMixin = applicationMixin;
|
|
7
|
+
exports.applicationStaticMixin = applicationStaticMixin;
|
|
8
|
+
const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface"));
|
|
9
|
+
const standata_1 = require("@mat3ra/standata");
|
|
10
|
+
function applicationMixin(item) {
|
|
11
|
+
// @ts-expect-error
|
|
12
|
+
const properties = {
|
|
13
|
+
get summary() {
|
|
14
|
+
return this.prop("summary");
|
|
15
|
+
},
|
|
16
|
+
get version() {
|
|
17
|
+
return this.prop("version", "");
|
|
18
|
+
},
|
|
19
|
+
get build() {
|
|
20
|
+
return this.prop("build");
|
|
21
|
+
},
|
|
22
|
+
get shortName() {
|
|
23
|
+
return this.prop("shortName", this.name);
|
|
24
|
+
},
|
|
25
|
+
get hasAdvancedComputeOptions() {
|
|
26
|
+
return this.prop("hasAdvancedComputeOptions", false);
|
|
27
|
+
},
|
|
28
|
+
get isLicensed() {
|
|
29
|
+
return this.prop("isLicensed", false);
|
|
30
|
+
},
|
|
31
|
+
get isUsingMaterial() {
|
|
32
|
+
const materialUsingApplications = ["vasp", "nwchem", "espresso"];
|
|
33
|
+
return materialUsingApplications.includes(this.name);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
|
|
37
|
+
}
|
|
38
|
+
function applicationStaticMixin(Application) {
|
|
39
|
+
const properties = {
|
|
40
|
+
get defaultConfig() {
|
|
41
|
+
return new standata_1.ApplicationStandata().getDefaultConfig();
|
|
42
|
+
},
|
|
43
|
+
get jsonSchema() {
|
|
44
|
+
return JSONSchemasInterface_1.default.getSchemaById("software/application");
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperties(Application, Object.getOwnPropertyDescriptors(properties));
|
|
48
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface ContextProviderInstance {
|
|
2
|
+
constructor: typeof ContextProvider;
|
|
3
|
+
config: ContextProviderConfig;
|
|
4
|
+
}
|
|
5
|
+
export interface ContextProviderConfig {
|
|
6
|
+
name: ContextProviderName | `${ContextProviderName}`;
|
|
7
|
+
domain?: string;
|
|
8
|
+
entityName?: string;
|
|
9
|
+
data?: object;
|
|
10
|
+
extraData?: object;
|
|
11
|
+
isEdited?: boolean;
|
|
12
|
+
context?: object;
|
|
13
|
+
}
|
|
14
|
+
export declare enum ContextProviderName {
|
|
15
|
+
PlanewaveCutoffDataManager = "PlanewaveCutoffDataManager",
|
|
16
|
+
KGridFormDataManager = "KGridFormDataManager",
|
|
17
|
+
QGridFormDataManager = "QGridFormDataManager",
|
|
18
|
+
IGridFormDataManager = "IGridFormDataManager",
|
|
19
|
+
QPathFormDataManager = "QPathFormDataManager",
|
|
20
|
+
IPathFormDataManager = "IPathFormDataManager",
|
|
21
|
+
KPathFormDataManager = "KPathFormDataManager",
|
|
22
|
+
ExplicitKPathFormDataManager = "ExplicitKPathFormDataManager",
|
|
23
|
+
ExplicitKPath2PIBAFormDataManager = "ExplicitKPath2PIBAFormDataManager",
|
|
24
|
+
HubbardJContextManager = "HubbardJContextManager",
|
|
25
|
+
HubbardUContextManager = "HubbardUContextManager",
|
|
26
|
+
HubbardVContextManager = "HubbardVContextManager",
|
|
27
|
+
HubbardContextManagerLegacy = "HubbardContextManagerLegacy",
|
|
28
|
+
NEBFormDataManager = "NEBFormDataManager",
|
|
29
|
+
BoundaryConditionsFormDataManager = "BoundaryConditionsFormDataManager",
|
|
30
|
+
MLSettingsDataManager = "MLSettingsDataManager",
|
|
31
|
+
MLTrainTestSplitDataManager = "MLTrainTestSplitDataManager",
|
|
32
|
+
IonDynamicsContextProvider = "IonDynamicsContextProvider",
|
|
33
|
+
CollinearMagnetizationDataManager = "CollinearMagnetizationDataManager",
|
|
34
|
+
NonCollinearMagnetizationDataManager = "NonCollinearMagnetizationDataManager",
|
|
35
|
+
QEPWXInputDataManager = "QEPWXInputDataManager",
|
|
36
|
+
QENEBInputDataManager = "QENEBInputDataManager",
|
|
37
|
+
VASPInputDataManager = "VASPInputDataManager",
|
|
38
|
+
VASPNEBInputDataManager = "VASPNEBInputDataManager",
|
|
39
|
+
NWChemInputDataManager = "NWChemInputDataManager"
|
|
40
|
+
}
|
|
41
|
+
export interface ContextProviderStatic {
|
|
42
|
+
getConstructorConfig: (config: ContextProviderConfig) => ContextProviderInstance;
|
|
43
|
+
createConfigFromContext: (config: ContextProviderConfig) => ContextProviderConfig;
|
|
44
|
+
getExtraDataKeyByName: (name: string) => string;
|
|
45
|
+
getIsEditedKeyByName: (name: string) => string;
|
|
46
|
+
}
|
|
47
|
+
export default class ContextProvider {
|
|
48
|
+
config: ContextProviderConfig;
|
|
49
|
+
name: `${ContextProviderName}`;
|
|
50
|
+
domain?: string;
|
|
51
|
+
entityName?: string;
|
|
52
|
+
data?: object;
|
|
53
|
+
extraData?: object;
|
|
54
|
+
isEdited?: boolean;
|
|
55
|
+
constructor(config: ContextProviderConfig);
|
|
56
|
+
static getConstructorConfig(config: ContextProviderConfig): ContextProviderInstance;
|
|
57
|
+
static createConfigFromContext(config: ContextProviderConfig): ContextProviderConfig & ({
|
|
58
|
+
data: never;
|
|
59
|
+
extraData: any;
|
|
60
|
+
isEdited: any;
|
|
61
|
+
} | {
|
|
62
|
+
data?: undefined;
|
|
63
|
+
extraData?: undefined;
|
|
64
|
+
isEdited?: undefined;
|
|
65
|
+
});
|
|
66
|
+
setIsEdited(isEdited: boolean): void;
|
|
67
|
+
getData(): object | undefined;
|
|
68
|
+
setData(data: object): void;
|
|
69
|
+
get defaultData(): object;
|
|
70
|
+
transformData(data: object): object;
|
|
71
|
+
yieldData(...transformDataArgs: any): {
|
|
72
|
+
[x: string]: boolean | object | undefined;
|
|
73
|
+
};
|
|
74
|
+
yieldDataForRendering(): {
|
|
75
|
+
[x: string]: boolean | object | undefined;
|
|
76
|
+
};
|
|
77
|
+
get extraDataKey(): string;
|
|
78
|
+
static getExtraDataKeyByName(name: string): string;
|
|
79
|
+
get isEditedKey(): string;
|
|
80
|
+
static getIsEditedKeyByName(name: string): string;
|
|
81
|
+
get isUnitContextProvider(): boolean;
|
|
82
|
+
get isSubworkflowContextProvider(): boolean;
|
|
83
|
+
}
|