@mat3ra/ade 2026.4.29-0 → 2026.5.28-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.
Files changed (78) hide show
  1. package/dist/js/Application.d.ts +23 -0
  2. package/dist/js/Application.js +37 -0
  3. package/dist/js/Executable.d.ts +20 -0
  4. package/dist/js/Executable.js +35 -0
  5. package/dist/js/Flavor.d.ts +17 -0
  6. package/dist/js/Flavor.js +38 -0
  7. package/dist/js/Template.d.ts +16 -0
  8. package/dist/js/Template.js +29 -0
  9. package/dist/js/generated/ApplicationSchemaMixin.d.ts +5 -0
  10. package/dist/js/generated/ApplicationSchemaMixin.js +63 -0
  11. package/dist/js/generated/ExecutableSchemaMixin.d.ts +5 -0
  12. package/dist/js/generated/ExecutableSchemaMixin.js +27 -0
  13. package/dist/js/generated/FlavorSchemaMixin.d.ts +5 -0
  14. package/dist/js/generated/FlavorSchemaMixin.js +33 -0
  15. package/dist/js/generated/TemplateSchemaMixin.d.ts +5 -0
  16. package/dist/js/generated/TemplateSchemaMixin.js +39 -0
  17. package/dist/js/index.d.ts +1 -14
  18. package/dist/js/index.js +14 -29
  19. package/dist/js/typeUtils.d.ts +5 -0
  20. package/dist/js/typeUtils.js +2 -0
  21. package/dist/js/types.d.ts +6 -6
  22. package/dist/js/types.js +12 -0
  23. package/package.json +8 -14
  24. package/src/js/Application.ts +64 -0
  25. package/src/js/Executable.ts +64 -0
  26. package/src/js/Flavor.ts +54 -0
  27. package/src/js/Template.ts +43 -0
  28. package/src/js/generated/ApplicationSchemaMixin.ts +77 -0
  29. package/src/js/generated/ExecutableSchemaMixin.ts +42 -0
  30. package/src/js/generated/FlavorSchemaMixin.ts +42 -0
  31. package/src/js/generated/TemplateSchemaMixin.ts +52 -0
  32. package/src/js/index.ts +1 -32
  33. package/src/js/typeUtils.ts +5 -0
  34. package/src/js/types.ts +6 -14
  35. package/dist/js/ApplicationRegistry.d.ts +0 -57
  36. package/dist/js/ApplicationRegistry.js +0 -171
  37. package/dist/js/application.d.ts +0 -9
  38. package/dist/js/application.js +0 -13
  39. package/dist/js/applicationMixin.d.ts +0 -23
  40. package/dist/js/applicationMixin.js +0 -47
  41. package/dist/js/context/ContextProvider.d.ts +0 -50
  42. package/dist/js/context/ContextProvider.js +0 -98
  43. package/dist/js/context/ContextProviderJinja.d.ts +0 -10
  44. package/dist/js/context/ContextProviderJinja.js +0 -13
  45. package/dist/js/context/ContextProviderRegistryContainer.d.ts +0 -24
  46. package/dist/js/context/ContextProviderRegistryContainer.js +0 -30
  47. package/dist/js/context/JSONSchemaDataProvider.d.ts +0 -7
  48. package/dist/js/context/JSONSchemaDataProvider.js +0 -16
  49. package/dist/js/context/JSONSchemaFormDataProvider.d.ts +0 -18
  50. package/dist/js/context/JSONSchemaFormDataProvider.js +0 -40
  51. package/dist/js/context/JinjaContextProvider.d.ts +0 -10
  52. package/dist/js/context/JinjaContextProvider.js +0 -13
  53. package/dist/js/executable.d.ts +0 -8
  54. package/dist/js/executable.js +0 -12
  55. package/dist/js/executableMixin.d.ts +0 -22
  56. package/dist/js/executableMixin.js +0 -28
  57. package/dist/js/flavor.d.ts +0 -9
  58. package/dist/js/flavor.js +0 -12
  59. package/dist/js/flavorMixin.d.ts +0 -21
  60. package/dist/js/flavorMixin.js +0 -51
  61. package/dist/js/template.d.ts +0 -8
  62. package/dist/js/template.js +0 -10
  63. package/dist/js/templateMixin.d.ts +0 -39
  64. package/dist/js/templateMixin.js +0 -162
  65. package/src/js/ApplicationRegistry.ts +0 -250
  66. package/src/js/application.ts +0 -25
  67. package/src/js/applicationMixin.ts +0 -85
  68. package/src/js/context/ContextProvider.ts +0 -155
  69. package/src/js/context/ContextProviderRegistryContainer.ts +0 -41
  70. package/src/js/context/JSONSchemaDataProvider.ts +0 -11
  71. package/src/js/context/JSONSchemaFormDataProvider.ts +0 -43
  72. package/src/js/context/JinjaContextProvider.ts +0 -16
  73. package/src/js/executable.ts +0 -14
  74. package/src/js/executableMixin.ts +0 -49
  75. package/src/js/flavor.ts +0 -19
  76. package/src/js/flavorMixin.ts +0 -77
  77. package/src/js/template.ts +0 -17
  78. package/src/js/templateMixin.ts +0 -243
@@ -0,0 +1,64 @@
1
+ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import {
3
+ type Defaultable,
4
+ defaultableEntityMixin,
5
+ } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin";
6
+ import {
7
+ type NamedEntity,
8
+ namedEntityMixin,
9
+ } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin";
10
+ import { runtimeItemsMixin } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin";
11
+ import type { RuntimeItemsInMemoryEntity } from "@mat3ra/code/dist/js/generated/RuntimeItemsSchemaMixin";
12
+ import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface";
13
+ import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
14
+ import type { JSONSchema } from "@mat3ra/esse/dist/js/esse/utils";
15
+ import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types";
16
+
17
+ import {
18
+ type ExecutableSchemaMixin,
19
+ executableSchemaMixin,
20
+ } from "./generated/ExecutableSchemaMixin";
21
+ import type { PartialBy } from "./typeUtils";
22
+
23
+ /** Input for {@link Executable}: runtime item lists default to empty when omitted. */
24
+ export type ExecutableConstructorData = PartialBy<
25
+ ExecutableSchema,
26
+ "monitors" | "results" | "postProcessors" | "preProcessors"
27
+ >;
28
+
29
+ interface Executable
30
+ extends ExecutableSchemaMixin,
31
+ RuntimeItemsInMemoryEntity,
32
+ NamedEntity,
33
+ Defaultable {}
34
+
35
+ class Executable extends InMemoryEntity implements ExecutableSchema {
36
+ constructor(data: ExecutableConstructorData) {
37
+ super({
38
+ ...data,
39
+ monitors: data.monitors ?? [],
40
+ results: data.results ?? [],
41
+ postProcessors: data.postProcessors ?? [],
42
+ preProcessors: data.preProcessors ?? [],
43
+ });
44
+ }
45
+
46
+ static get jsonSchema(): JSONSchema {
47
+ const schema = JSONSchemasInterface.getSchemaById("software/executable");
48
+ if (schema === undefined) {
49
+ throw new Error('JSONSchemasInterface: missing schema id "software/executable"');
50
+ }
51
+ return schema;
52
+ }
53
+
54
+ declare static createDefault: () => Executable;
55
+
56
+ declare toJSON: () => ExecutableSchema & AnyObject;
57
+ }
58
+
59
+ namedEntityMixin(Executable.prototype);
60
+ defaultableEntityMixin(Executable);
61
+ runtimeItemsMixin(Executable.prototype);
62
+ executableSchemaMixin(Executable.prototype);
63
+
64
+ export default Executable;
@@ -0,0 +1,54 @@
1
+ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import {
3
+ type Defaultable,
4
+ defaultableEntityMixin,
5
+ } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin";
6
+ import {
7
+ type NamedEntity,
8
+ namedEntityMixin,
9
+ } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin";
10
+ import { runtimeItemsMixin } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin";
11
+ import type { RuntimeItemsInMemoryEntity } from "@mat3ra/code/dist/js/generated/RuntimeItemsSchemaMixin";
12
+ import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface";
13
+ import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
14
+ import type { JSONSchema } from "@mat3ra/esse/dist/js/esse/utils";
15
+ import type { FlavorSchema } from "@mat3ra/esse/dist/js/types";
16
+
17
+ import { type FlavorSchemaMixin, flavorSchemaMixin } from "./generated/FlavorSchemaMixin";
18
+
19
+ interface Flavor extends FlavorSchemaMixin, RuntimeItemsInMemoryEntity, NamedEntity, Defaultable {}
20
+
21
+ class Flavor extends InMemoryEntity implements FlavorSchema {
22
+ constructor(data: Partial<FlavorSchema> = {}) {
23
+ super({
24
+ monitors: [],
25
+ results: [],
26
+ postProcessors: [],
27
+ preProcessors: [],
28
+ input: [],
29
+ executableId: "",
30
+ executableName: "",
31
+ applicationName: "",
32
+ ...data,
33
+ });
34
+ }
35
+
36
+ static get jsonSchema(): JSONSchema {
37
+ const schema = JSONSchemasInterface.getSchemaById("software/flavor");
38
+ if (schema === undefined) {
39
+ throw new Error('JSONSchemasInterface: missing schema id "software/flavor"');
40
+ }
41
+ return schema;
42
+ }
43
+
44
+ declare static createDefault: () => Flavor;
45
+
46
+ declare toJSON: () => FlavorSchema & AnyObject;
47
+ }
48
+
49
+ namedEntityMixin(Flavor.prototype);
50
+ defaultableEntityMixin(Flavor);
51
+ runtimeItemsMixin(Flavor.prototype);
52
+ flavorSchemaMixin(Flavor.prototype);
53
+
54
+ export default Flavor;
@@ -0,0 +1,43 @@
1
+ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import {
3
+ type NamedEntity,
4
+ namedEntityMixin,
5
+ } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin";
6
+ import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface";
7
+ import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
8
+ import type { JSONSchema } from "@mat3ra/esse/dist/js/esse/utils";
9
+ import type { TemplateSchema } from "@mat3ra/esse/dist/js/types";
10
+
11
+ import { type TemplateSchemaMixin, templateSchemaMixin } from "./generated/TemplateSchemaMixin";
12
+ import type { PartialBy } from "./typeUtils";
13
+
14
+ interface Template extends TemplateSchemaMixin, NamedEntity {}
15
+
16
+ export type DefaultTemplateConfig = PartialBy<TemplateSchema, "content" | "contextProviders">;
17
+
18
+ class Template extends InMemoryEntity implements TemplateSchema {
19
+ constructor(data: DefaultTemplateConfig) {
20
+ const templateData: TemplateSchema = {
21
+ content: "",
22
+ contextProviders: [],
23
+ ...data,
24
+ };
25
+
26
+ super(templateData);
27
+ }
28
+
29
+ static get jsonSchema(): JSONSchema {
30
+ const schema = JSONSchemasInterface.getSchemaById("software/template");
31
+ if (schema === undefined) {
32
+ throw new Error('JSONSchemasInterface: missing schema id "software/template"');
33
+ }
34
+ return schema;
35
+ }
36
+
37
+ declare toJSON: () => TemplateSchema & AnyObject;
38
+ }
39
+
40
+ namedEntityMixin(Template.prototype);
41
+ templateSchemaMixin(Template.prototype);
42
+
43
+ export default Template;
@@ -0,0 +1,77 @@
1
+ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import type { ApplicationPropertiesSchema } from "@mat3ra/esse/dist/js/types";
3
+
4
+ export type ApplicationSchemaMixin = ApplicationPropertiesSchema;
5
+
6
+ export type ApplicationInMemoryEntity = InMemoryEntity & ApplicationSchemaMixin;
7
+
8
+ export function applicationSchemaMixin<T extends InMemoryEntity>(
9
+ item: InMemoryEntity,
10
+ ): asserts item is T & ApplicationSchemaMixin {
11
+ // @ts-expect-error
12
+ const properties: InMemoryEntity & ApplicationSchemaMixin = {
13
+ get shortName() {
14
+ return this.requiredProp<ApplicationPropertiesSchema["shortName"]>("shortName");
15
+ },
16
+ set shortName(value: ApplicationPropertiesSchema["shortName"]) {
17
+ this.setProp("shortName", value);
18
+ },
19
+ get summary() {
20
+ return this.requiredProp<ApplicationPropertiesSchema["summary"]>("summary");
21
+ },
22
+ set summary(value: ApplicationPropertiesSchema["summary"]) {
23
+ this.setProp("summary", value);
24
+ },
25
+ get version() {
26
+ return this.requiredProp<ApplicationPropertiesSchema["version"]>("version");
27
+ },
28
+ set version(value: ApplicationPropertiesSchema["version"]) {
29
+ this.setProp("version", value);
30
+ },
31
+ get build() {
32
+ return this.requiredProp<ApplicationPropertiesSchema["build"]>("build");
33
+ },
34
+ set build(value: ApplicationPropertiesSchema["build"]) {
35
+ this.setProp("build", value);
36
+ },
37
+ get isDefault() {
38
+ return this.prop<ApplicationPropertiesSchema["isDefault"]>("isDefault");
39
+ },
40
+ set isDefault(value: ApplicationPropertiesSchema["isDefault"]) {
41
+ this.setProp("isDefault", value);
42
+ },
43
+ get isDefaultVersion() {
44
+ return this.prop<ApplicationPropertiesSchema["isDefaultVersion"]>("isDefaultVersion");
45
+ },
46
+ set isDefaultVersion(value: ApplicationPropertiesSchema["isDefaultVersion"]) {
47
+ this.setProp("isDefaultVersion", value);
48
+ },
49
+ get hasAdvancedComputeOptions() {
50
+ return this.prop<ApplicationPropertiesSchema["hasAdvancedComputeOptions"]>(
51
+ "hasAdvancedComputeOptions",
52
+ );
53
+ },
54
+ set hasAdvancedComputeOptions(
55
+ value: ApplicationPropertiesSchema["hasAdvancedComputeOptions"],
56
+ ) {
57
+ this.setProp("hasAdvancedComputeOptions", value);
58
+ },
59
+ get isLicensed() {
60
+ return this.prop<ApplicationPropertiesSchema["isLicensed"]>("isLicensed");
61
+ },
62
+ set isLicensed(value: ApplicationPropertiesSchema["isLicensed"]) {
63
+ this.setProp("isLicensed", value);
64
+ },
65
+ get isUsingMaterial() {
66
+ return this.prop<ApplicationPropertiesSchema["isUsingMaterial"]>(
67
+ "isUsingMaterial",
68
+ false,
69
+ );
70
+ },
71
+ set isUsingMaterial(value: ApplicationPropertiesSchema["isUsingMaterial"]) {
72
+ this.setProp("isUsingMaterial", value);
73
+ },
74
+ };
75
+
76
+ Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
77
+ }
@@ -0,0 +1,42 @@
1
+ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import type { ExecutablePropertiesSchema } from "@mat3ra/esse/dist/js/types";
3
+
4
+ export type ExecutableSchemaMixin = ExecutablePropertiesSchema;
5
+
6
+ export type ExecutableInMemoryEntity = InMemoryEntity & ExecutableSchemaMixin;
7
+
8
+ export function executableSchemaMixin<T extends InMemoryEntity>(
9
+ item: InMemoryEntity,
10
+ ): asserts item is T & ExecutableSchemaMixin {
11
+ // @ts-expect-error
12
+ const properties: InMemoryEntity & ExecutableSchemaMixin = {
13
+ get applicationName() {
14
+ return this.requiredProp<ExecutablePropertiesSchema["applicationName"]>(
15
+ "applicationName",
16
+ );
17
+ },
18
+ set applicationName(value: ExecutablePropertiesSchema["applicationName"]) {
19
+ this.setProp("applicationName", value);
20
+ },
21
+ get applicationVersion() {
22
+ return this.requiredProp<ExecutablePropertiesSchema["applicationVersion"]>(
23
+ "applicationVersion",
24
+ );
25
+ },
26
+ set applicationVersion(value: ExecutablePropertiesSchema["applicationVersion"]) {
27
+ this.setProp("applicationVersion", value);
28
+ },
29
+ get hasAdvancedComputeOptions() {
30
+ return this.prop<ExecutablePropertiesSchema["hasAdvancedComputeOptions"]>(
31
+ "hasAdvancedComputeOptions",
32
+ );
33
+ },
34
+ set hasAdvancedComputeOptions(
35
+ value: ExecutablePropertiesSchema["hasAdvancedComputeOptions"],
36
+ ) {
37
+ this.setProp("hasAdvancedComputeOptions", value);
38
+ },
39
+ };
40
+
41
+ Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
42
+ }
@@ -0,0 +1,42 @@
1
+ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import type { FlavorPropertiesSchema } from "@mat3ra/esse/dist/js/types";
3
+
4
+ export type FlavorSchemaMixin = FlavorPropertiesSchema;
5
+
6
+ export type FlavorInMemoryEntity = InMemoryEntity & FlavorSchemaMixin;
7
+
8
+ export function flavorSchemaMixin<T extends InMemoryEntity>(
9
+ item: InMemoryEntity,
10
+ ): asserts item is T & FlavorSchemaMixin {
11
+ // @ts-expect-error
12
+ const properties: InMemoryEntity & FlavorSchemaMixin = {
13
+ get executableName() {
14
+ return this.requiredProp<FlavorPropertiesSchema["executableName"]>("executableName");
15
+ },
16
+ set executableName(value: FlavorPropertiesSchema["executableName"]) {
17
+ this.setProp("executableName", value);
18
+ },
19
+ get applicationName() {
20
+ return this.requiredProp<FlavorPropertiesSchema["applicationName"]>("applicationName");
21
+ },
22
+ set applicationName(value: FlavorPropertiesSchema["applicationName"]) {
23
+ this.setProp("applicationName", value);
24
+ },
25
+ get applicationVersion() {
26
+ return this.requiredProp<FlavorPropertiesSchema["applicationVersion"]>(
27
+ "applicationVersion",
28
+ );
29
+ },
30
+ set applicationVersion(value: FlavorPropertiesSchema["applicationVersion"]) {
31
+ this.setProp("applicationVersion", value);
32
+ },
33
+ get input() {
34
+ return this.requiredProp<FlavorPropertiesSchema["input"]>("input");
35
+ },
36
+ set input(value: FlavorPropertiesSchema["input"]) {
37
+ this.setProp("input", value);
38
+ },
39
+ };
40
+
41
+ Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
42
+ }
@@ -0,0 +1,52 @@
1
+ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import type { TemplatePropertiesSchema } from "@mat3ra/esse/dist/js/types";
3
+
4
+ export type TemplateSchemaMixin = TemplatePropertiesSchema;
5
+
6
+ export type TemplateInMemoryEntity = InMemoryEntity & TemplateSchemaMixin;
7
+
8
+ export function templateSchemaMixin<T extends InMemoryEntity>(
9
+ item: InMemoryEntity,
10
+ ): asserts item is T & TemplateSchemaMixin {
11
+ // @ts-expect-error
12
+ const properties: InMemoryEntity & TemplateSchemaMixin = {
13
+ get executableName() {
14
+ return this.requiredProp<TemplatePropertiesSchema["executableName"]>("executableName");
15
+ },
16
+ set executableName(value: TemplatePropertiesSchema["executableName"]) {
17
+ this.setProp("executableName", value);
18
+ },
19
+ get applicationName() {
20
+ return this.requiredProp<TemplatePropertiesSchema["applicationName"]>(
21
+ "applicationName",
22
+ );
23
+ },
24
+ set applicationName(value: TemplatePropertiesSchema["applicationName"]) {
25
+ this.setProp("applicationName", value);
26
+ },
27
+ get applicationVersion() {
28
+ return this.requiredProp<TemplatePropertiesSchema["applicationVersion"]>(
29
+ "applicationVersion",
30
+ );
31
+ },
32
+ set applicationVersion(value: TemplatePropertiesSchema["applicationVersion"]) {
33
+ this.setProp("applicationVersion", value);
34
+ },
35
+ get contextProviders() {
36
+ return this.requiredProp<TemplatePropertiesSchema["contextProviders"]>(
37
+ "contextProviders",
38
+ );
39
+ },
40
+ set contextProviders(value: TemplatePropertiesSchema["contextProviders"]) {
41
+ this.setProp("contextProviders", value);
42
+ },
43
+ get content() {
44
+ return this.requiredProp<TemplatePropertiesSchema["content"]>("content");
45
+ },
46
+ set content(value: TemplatePropertiesSchema["content"]) {
47
+ this.setProp("content", value);
48
+ },
49
+ };
50
+
51
+ Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
52
+ }
package/src/js/index.ts CHANGED
@@ -1,32 +1 @@
1
- import Application from "./application";
2
- import { applicationMixin, applicationStaticMixin } from "./applicationMixin";
3
- import ApplicationRegistry from "./ApplicationRegistry";
4
- import ContextProvider from "./context/ContextProvider";
5
- import JSONSchemaFormDataProvider from "./context/JSONSchemaFormDataProvider";
6
- import Executable from "./executable";
7
- import { executableMixin } from "./executableMixin";
8
- import Flavor from "./flavor";
9
- import { flavorMixin } from "./flavorMixin";
10
- import Template from "./template";
11
- import { templateMixin, templateStaticMixin } from "./templateMixin";
12
-
13
- const allApplications = ApplicationRegistry.getUniqueAvailableApplicationNames();
14
-
15
- export {
16
- Application,
17
- Executable,
18
- Flavor,
19
- Template,
20
- ApplicationRegistry,
21
- ContextProvider,
22
- JSONSchemaFormDataProvider,
23
- executableMixin,
24
- flavorMixin,
25
- applicationMixin,
26
- applicationStaticMixin,
27
- templateMixin,
28
- templateStaticMixin,
29
- allApplications,
30
- };
31
-
32
- export type * from "./types";
1
+ export * from "./types";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * `T` with the listed keys made optional. Equivalent to
3
+ * `Omit<T, K> & Partial<Pick<T, K>>`.
4
+ */
5
+ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
package/src/js/types.ts CHANGED
@@ -1,15 +1,7 @@
1
- import type { ApplicationMixin, ApplicationStaticMixin } from "./applicationMixin";
2
- import type { CreateApplicationConfig } from "./ApplicationRegistry";
3
- import type { ExecutableMixin } from "./executableMixin";
4
- import type { FlavorMixin } from "./flavorMixin";
5
- import type { TemplateMixin, TemplateStaticMixin } from "./templateMixin";
1
+ import Application from "./Application";
2
+ import Executable from "./Executable";
3
+ import Flavor from "./Flavor";
4
+ import Template from "./Template";
5
+ import type { PartialBy } from "./typeUtils";
6
6
 
7
- export type {
8
- FlavorMixin,
9
- ExecutableMixin,
10
- ApplicationMixin,
11
- ApplicationStaticMixin,
12
- CreateApplicationConfig,
13
- TemplateMixin,
14
- TemplateStaticMixin,
15
- };
7
+ export { Executable, Flavor, Template, Application, PartialBy };
@@ -1,57 +0,0 @@
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 {};
@@ -1,171 +0,0 @@
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;