Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"src/**/*.ts"
],
"exclude": [
"src/js/generated/**/*",
"tests/**/*",
"**/*.test.ts",
"**/*.spec.ts",
Expand Down
20 changes: 10 additions & 10 deletions dist/js/ApplicationRegistry.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { ApplicationSchemaBase } from "@mat3ra/esse/dist/js/types";
import Application from "./application";
import Executable from "./executable";
import Flavor from "./flavor";
import Template from "./template";
import type { ApplicationSchema, TemplateSchema } from "@mat3ra/esse/dist/js/types";
import Application from "./Application";
import Executable from "./Executable";
import Flavor from "./Flavor";
import Template from "./Template";
type ApplicationVersion = {
[build: string]: ApplicationSchemaBase;
[build: string]: ApplicationSchema;
};
type ApplicationTreeItem = {
defaultVersion: string;
Expand All @@ -18,7 +18,7 @@ export type CreateApplicationConfig = {
type ApplicationTree = Partial<Record<string, ApplicationTreeItem>>;
export default class ApplicationRegistry {
static applicationsTree?: ApplicationTree;
static applicationsArray?: ApplicationSchemaBase[];
static applicationsArray?: ApplicationSchema[];
static createApplication({ name, version, build }: CreateApplicationConfig): Application;
static getUniqueAvailableApplicationNames(): string[];
/**
Expand All @@ -27,7 +27,7 @@ export default class ApplicationRegistry {
*/
static getAllApplications(): {
applicationsTree: Partial<Record<string, ApplicationTreeItem>>;
applicationsArray: ApplicationSchemaBase[];
applicationsArray: ApplicationSchema[];
};
/**
* @summary Get an application from the constructed applications
Expand All @@ -36,7 +36,7 @@ export default class ApplicationRegistry {
* @param build the build to use (optional, defaults to Default)
* @return an application
*/
static getApplicationConfig({ name, version, build }: CreateApplicationConfig): ApplicationSchemaBase | null;
static getApplicationConfig({ name, version, build }: CreateApplicationConfig): ApplicationSchema | null;
static getExecutables({ name, version }: {
name: string;
version?: string;
Expand All @@ -51,7 +51,7 @@ export default class ApplicationRegistry {
name: string;
}): Flavor | undefined;
static getInputAsTemplates(flavor: Flavor): Template[];
static getInputAsRenderedTemplates(flavor: Flavor, context: Record<string, unknown>): import("@mat3ra/esse/dist/js/esse/types").AnyObject[];
static getInput(flavor: Flavor): TemplateSchema[];
static getAllFlavorsForApplication(appName: string, version?: string): Flavor[];
}
export {};
37 changes: 20 additions & 17 deletions dist/js/ApplicationRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
const object_1 = require("@mat3ra/code/dist/js/utils/object");
const standata_1 = require("@mat3ra/standata");
const application_1 = __importDefault(require("./application"));
const executable_1 = __importDefault(require("./executable"));
const flavor_1 = __importDefault(require("./flavor"));
const template_1 = __importDefault(require("./template"));
const Application_1 = __importDefault(require("./Application"));
const Executable_1 = __importDefault(require("./Executable"));
const Flavor_1 = __importDefault(require("./Flavor"));
const Template_1 = __importDefault(require("./Template"));
class ApplicationRegistry {
static createApplication({ name, version = null, build = null }) {
const staticConfig = ApplicationRegistry.getApplicationConfig({ name, version, build });
return new application_1.default({
return new Application_1.default({
...staticConfig,
name,
...(version && { version }),
Expand Down Expand Up @@ -52,6 +52,7 @@ class ApplicationRegistry {
appTreeItem[version] = appVersion;
const applicationConfig = {
...appData,
// @ts-ignore
build: buildToUse,
...versionInfo,
};
Expand Down Expand Up @@ -114,7 +115,7 @@ class ApplicationRegistry {
return (!supportedApplicationVersions ||
(version && supportedApplicationVersions.includes(version)));
})
.map((key) => new executable_1.default({ ...tree[key], name: key }));
.map((key) => new Executable_1.default({ ...tree[key], name: key }));
}
static getExecutableByName(appName, execName) {
const appTree = new standata_1.ApplicationStandata().getAppTreeForApplication(appName);
Expand All @@ -124,7 +125,7 @@ class ApplicationRegistry {
const config = execName
? appTree[execName]
: (0, object_1.getOneMatchFromObject)(appTree, "isDefault", true);
return new executable_1.default(config);
return new Executable_1.default(config);
}
// TODO: remove this method and use getApplicationExecutableByName directly
static getExecutableByConfig(appName, config) {
Expand All @@ -133,7 +134,7 @@ class ApplicationRegistry {
static getExecutableFlavors(executable) {
const flavorsTree = executable.prop("flavors", {});
return Object.keys(flavorsTree).map((key) => {
return new flavor_1.default({
return new Flavor_1.default({
...flavorsTree[key],
name: key,
});
Expand All @@ -145,24 +146,26 @@ class ApplicationRegistry {
static getFlavorByConfig(executable, config) {
return this.getFlavorByName(executable, config === null || config === void 0 ? void 0 : config.name);
}
// flavors
static getInputAsTemplates(flavor) {
const appName = flavor.prop("applicationName", "");
const execName = flavor.prop("executableName", "");
return this.getInput(flavor).map((template) => new Template_1.default(template));
}
static getInput(flavor) {
const appName = flavor.applicationName || "";
const execName = flavor.executableName || "";
return flavor.input.map((input) => {
const inputName = input.templateName || input.name;
const filtered = new standata_1.ApplicationStandata().getTemplatesByName(appName, execName, inputName);
if (filtered.length !== 1) {
console.log(`found ${filtered.length} templates for app=${appName} exec=${execName} name=${inputName} expected 1`);
}
return new template_1.default({ ...filtered[0], name: input.name });
});
}
static getInputAsRenderedTemplates(flavor, context) {
return this.getInputAsTemplates(flavor).map((template) => {
return template.getRenderedJSON(context);
return { ...filtered[0], name: input.name || "" };
});
}
// static getInputAsRenderedTemplates(flavor: Flavor, context: ContextProviderConfig) {
// return this.getInputAsTemplates(flavor).map((template) => {
// return template.setContext(context).render().toJSON();
// });
// }
static getAllFlavorsForApplication(appName, version) {
const allExecutables = this.getExecutables({ name: appName, version });
return allExecutables.flatMap((executable) => this.getExecutableFlavors(executable));
Expand Down
11 changes: 8 additions & 3 deletions dist/js/application.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { NamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity";
import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
import { type DefaultableInMemoryEntityConstructor } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin";
import { type NamedInMemoryEntityConstructor } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin";
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
import type { ApplicationSchema } from "@mat3ra/esse/dist/js/types";
import { type ApplicationMixin, type ApplicationStaticMixin } from "./applicationMixin";
type Base = typeof NamedDefaultableInMemoryEntity & Constructor<ApplicationMixin> & ApplicationStaticMixin;
type Base = typeof InMemoryEntity & NamedInMemoryEntityConstructor & DefaultableInMemoryEntityConstructor & Constructor<ApplicationMixin> & ApplicationStaticMixin;
declare const Application_base: Base;
export default class Application extends Application_base {
export default class Application extends Application_base implements ApplicationSchema {
constructor(data?: Partial<ApplicationSchema>);
static createDefault: () => Application;
}
export {};
14 changes: 11 additions & 3 deletions dist/js/application.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const entity_1 = require("@mat3ra/code/dist/js/entity");
const DefaultableMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/DefaultableMixin");
const NamedEntityMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin");
const applicationMixin_1 = require("./applicationMixin");
class Application extends entity_1.NamedDefaultableInMemoryEntity {
class Application extends entity_1.InMemoryEntity {
constructor(data = {}) {
super({
...data,
});
}
}
exports.default = Application;
(0, applicationMixin_1.applicationMixin)(Application.prototype);
(0, applicationMixin_1.applicationStaticMixin)(Application);
(0, NamedEntityMixin_1.namedEntityMixin)(Application.prototype);
(0, DefaultableMixin_1.defaultableEntityMixin)(Application);
(0, applicationMixin_1.applicationMixin)(Application);
23 changes: 11 additions & 12 deletions dist/js/applicationMixin.d.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
import type { DefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin";
import type { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin";
import type { Defaultable } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin";
import type { NamedEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin";
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
import type { ApplicationSchemaBase } from "@mat3ra/esse/dist/js/types";
import Executable from "./executable";
type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity;
import type { ApplicationSchema } from "@mat3ra/esse/dist/js/types";
import Executable from "./Executable";
import { type ApplicationSchemaMixin } from "./generated/ApplicationSchemaMixin";
type Base = InMemoryEntity & NamedEntity & Defaultable;
export type BaseConstructor = Constructor<Base> & {
constructCustomExecutable?: (config: object) => Executable;
};
export type ApplicationConstructor = Constructor<ApplicationMixin> & ApplicationStaticMixin;
export type ApplicationMixin = Pick<ApplicationSchemaBase, "summary" | "version" | "build" | "shortName" | "hasAdvancedComputeOptions" | "isLicensed"> & {
name: Required<ApplicationSchemaBase>["name"];
export type ApplicationMixin = ApplicationSchemaMixin & {
name: Required<ApplicationSchema>["name"];
isUsingMaterial: boolean;
};
export type DefaultApplicationConfig = Pick<ApplicationSchemaBase, "name" | "shortName" | "version" | "summary" | "build">;
export type DefaultApplicationConfig = Pick<ApplicationSchema, "name" | "shortName" | "version" | "summary" | "build">;
export type ApplicationStaticMixin = {
defaultConfig: DefaultApplicationConfig;
jsonSchema: ApplicationSchemaBase;
jsonSchema: ApplicationSchema;
};
export declare function applicationMixin(item: Base): void;
export declare function applicationStaticMixin<T extends BaseConstructor>(Application: T): void;
export declare function applicationMixin(Item: BaseConstructor): void;
export {};
27 changes: 7 additions & 20 deletions dist/js/applicationMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.applicationMixin = applicationMixin;
exports.applicationStaticMixin = applicationStaticMixin;
const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface"));
const standata_1 = require("@mat3ra/standata");
function applicationMixin(item) {
const ApplicationSchemaMixin_1 = require("./generated/ApplicationSchemaMixin");
function applicationPropertiesMixin(item) {
// @ts-expect-error
const properties = {
get summary() {
return this.prop("summary");
},
get version() {
return this.prop("version", "");
},
get build() {
return this.prop("build");
},
get shortName() {
return this.prop("shortName", this.name);
},
get hasAdvancedComputeOptions() {
return this.prop("hasAdvancedComputeOptions", false);
},
get isLicensed() {
return this.prop("isLicensed", false);
},
get isUsingMaterial() {
const materialUsingApplications = ["vasp", "nwchem", "espresso"];
return materialUsingApplications.includes(this.name);
Expand All @@ -46,3 +28,8 @@ function applicationStaticMixin(Application) {
};
Object.defineProperties(Application, Object.getOwnPropertyDescriptors(properties));
}
function applicationMixin(Item) {
(0, ApplicationSchemaMixin_1.applicationSchemaMixin)(Item.prototype);
applicationPropertiesMixin(Item.prototype);
applicationStaticMixin(Item);
}
10 changes: 0 additions & 10 deletions dist/js/context/ContextProviderJinja.d.ts

This file was deleted.

13 changes: 0 additions & 13 deletions dist/js/context/ContextProviderJinja.js

This file was deleted.

7 changes: 0 additions & 7 deletions dist/js/context/JSONSchemaDataProvider.d.ts

This file was deleted.

16 changes: 0 additions & 16 deletions dist/js/context/JSONSchemaDataProvider.js

This file was deleted.

18 changes: 0 additions & 18 deletions dist/js/context/JSONSchemaFormDataProvider.d.ts

This file was deleted.

40 changes: 0 additions & 40 deletions dist/js/context/JSONSchemaFormDataProvider.js

This file was deleted.

10 changes: 0 additions & 10 deletions dist/js/context/JinjaContextProvider.d.ts

This file was deleted.

Loading
Loading