From f93b1af43a4d3127336ccc07b3c7646659e02c0e Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Tue, 25 Nov 2025 18:09:29 +0200 Subject: [PATCH 01/16] update: code/new mixins --- dist/js/executable.d.ts | 9 +- dist/js/executable.js | 19 +- dist/js/flavor.d.ts | 10 +- dist/js/flavor.js | 19 +- dist/js/flavorMixin.d.ts | 4 +- dist/js/templateMixin.d.ts | 8 +- package-lock.json | 463 +++++++++---------------------------- package.json | 4 +- src/js/executable.ts | 38 ++- src/js/flavor.ts | 39 +++- tests/js/flavor.test.ts | 16 +- 11 files changed, 236 insertions(+), 393 deletions(-) diff --git a/dist/js/executable.d.ts b/dist/js/executable.d.ts index 4f521d3..f8194aa 100644 --- a/dist/js/executable.d.ts +++ b/dist/js/executable.d.ts @@ -1,8 +1,13 @@ -import { NamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import { 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 RuntimeItemsStringInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsStringMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types"; import { type ExecutableMixin } from "./executableMixin"; -type Base = Constructor & typeof NamedDefaultableInMemoryEntity; +type Base = Constructor & Constructor & Constructor & Constructor & typeof InMemoryEntity; declare const Executable_base: Base; export default class Executable extends Executable_base { + constructor(data?: Partial); } export {}; diff --git a/dist/js/executable.js b/dist/js/executable.js index 878cfaa..5fbf0b1 100644 --- a/dist/js/executable.js +++ b/dist/js/executable.js @@ -1,12 +1,25 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const entity_1 = require("@mat3ra/code/dist/js/entity"); -const RuntimeItemsMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"); +const DefaultableMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"); +const NamedEntityMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"); +const RuntimeItemsStringMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/RuntimeItemsStringMixin"); const executableMixin_1 = require("./executableMixin"); -class Executable extends entity_1.NamedDefaultableInMemoryEntity { +class Executable extends entity_1.InMemoryEntity { + constructor(data = {}) { + super({ + monitors: [], + results: [], + postProcessors: [], + preProcessors: [], + ...data, + }); + } } exports.default = Executable; // Apply mixins -(0, RuntimeItemsMixin_1.runtimeItemsMixin)(Executable.prototype); +(0, RuntimeItemsStringMixin_1.runtimeItemsStringMixin)(Executable.prototype); (0, executableMixin_1.executableMixin)(Executable.prototype); (0, executableMixin_1.executableStaticMixin)(Executable); +(0, NamedEntityMixin_1.namedEntityMixin)(Executable.prototype); +(0, DefaultableMixin_1.defaultableEntityMixin)(Executable); diff --git a/dist/js/flavor.d.ts b/dist/js/flavor.d.ts index 4134aff..b229353 100644 --- a/dist/js/flavor.d.ts +++ b/dist/js/flavor.d.ts @@ -1,9 +1,13 @@ -import { NamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import { type RuntimeItemsInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; +import { 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 RuntimeItemsStringInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsStringMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { FlavorSchema } from "@mat3ra/esse/dist/js/types"; import { type FlavorMixin } from "./flavorMixin"; -type Base = typeof NamedDefaultableInMemoryEntity & Constructor & Constructor; +type Base = typeof InMemoryEntity & Constructor & Constructor & Constructor & Constructor; declare const Flavor_base: Base; export default class Flavor extends Flavor_base { + constructor(data?: Partial); } export {}; diff --git a/dist/js/flavor.js b/dist/js/flavor.js index 956e74c..f14c624 100644 --- a/dist/js/flavor.js +++ b/dist/js/flavor.js @@ -1,12 +1,25 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const entity_1 = require("@mat3ra/code/dist/js/entity"); -const RuntimeItemsMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"); +const DefaultableMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"); +const NamedEntityMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"); +const RuntimeItemsStringMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/RuntimeItemsStringMixin"); const flavorMixin_1 = require("./flavorMixin"); -class Flavor extends entity_1.NamedDefaultableInMemoryEntity { +class Flavor extends entity_1.InMemoryEntity { + constructor(data = {}) { + super({ + monitors: [], + results: [], + postProcessors: [], + preProcessors: [], + ...data, + }); + } } exports.default = Flavor; // Apply mixins (0, flavorMixin_1.flavorMixin)(Flavor.prototype); -(0, RuntimeItemsMixin_1.runtimeItemsMixin)(Flavor.prototype); +(0, RuntimeItemsStringMixin_1.runtimeItemsStringMixin)(Flavor.prototype); +(0, NamedEntityMixin_1.namedEntityMixin)(Flavor.prototype); +(0, DefaultableMixin_1.defaultableEntityMixin)(Flavor); (0, flavorMixin_1.flavorStaticMixin)(Flavor); diff --git a/dist/js/flavorMixin.d.ts b/dist/js/flavorMixin.d.ts index 3c42e3d..4ace9ab 100644 --- a/dist/js/flavorMixin.d.ts +++ b/dist/js/flavorMixin.d.ts @@ -13,7 +13,9 @@ export type FlavorMixin = { supportedApplicationVersions?: string[]; getInputAsRenderedTemplates: (context: Record) => Record[]; }; -export declare function flavorMixin(item: Base): FlavorMixin & InMemoryEntity & NamedInMemoryEntity; +export declare function flavorMixin(item: Base): FlavorMixin & InMemoryEntity & import("@mat3ra/esse/dist/js/types").NameEntitySchema & { + setName: (name: string) => void; +}; export declare function flavorStaticMixin(Flavor: Constructor): void; export type FlavorStaticMixin = { jsonSchema: FlavorSchema; diff --git a/dist/js/templateMixin.d.ts b/dist/js/templateMixin.d.ts index 3f87088..ec14e17 100644 --- a/dist/js/templateMixin.d.ts +++ b/dist/js/templateMixin.d.ts @@ -25,7 +25,9 @@ export type TemplateMixin = { getDataFromProvidersForPersistentContext: (providerContext?: Record) => Record; getRenderingContext: (externalContext?: Record) => Record; }; -export declare function templateMixin(item: TemplateBase): TemplateMixin & InMemoryEntity & NamedInMemoryEntity; +export declare function templateMixin(item: TemplateBase): TemplateMixin & InMemoryEntity & import("@mat3ra/esse/dist/js/types").NameEntitySchema & { + setName: (name: string) => void; +}; export type ContextProviderConfigMapEntry = { providerCls: typeof ContextProvider; config: ContextProviderConfig; @@ -36,4 +38,6 @@ export type TemplateStaticMixin = { setContextProvidersConfig: (classConfigMap: ContextProviderConfigMap) => void; jsonSchema: TemplateSchema; }; -export declare function templateStaticMixin(item: Constructor): TemplateStaticMixin & Constructor; +export declare function templateStaticMixin(item: Constructor): TemplateStaticMixin & Constructor void; +} & TemplateMixin>; diff --git a/package-lock.json b/package-lock.json index 7638a91..069be62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,8 +17,8 @@ "devDependencies": { "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", - "@mat3ra/code": "2025.8.7-0", - "@mat3ra/esse": "2025.8.14-0", + "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#2f5206cb8db85af8c9af3d450a8dc551bb6b9b61", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#a91ed6431f436b52689a1aff82096f3f9d618654", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", @@ -73,6 +73,24 @@ "node": ">=6.0.0" } }, + "node_modules/@apidevtools/json-schema-ref-parser": { + "version": "11.9.3", + "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-11.9.3.tgz", + "integrity": "sha512-60vepv88RwcJtSHrD6MjIL6Ta3SOYbgfnkHb+ppAVK+o9mXprRtulx7VlRl3lN3bbvysAfCS7WMVfhUYemB0IQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.15", + "js-yaml": "^4.1.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/philsturgeon" + } + }, "node_modules/@babel/cli": { "version": "7.28.3", "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.28.3.tgz", @@ -2410,25 +2428,6 @@ "node": ">=6.9.0" } }, - "node_modules/@bcherny/json-schema-ref-parser": { - "version": "10.0.5-fork", - "resolved": "https://registry.npmjs.org/@bcherny/json-schema-ref-parser/-/json-schema-ref-parser-10.0.5-fork.tgz", - "integrity": "sha512-E/jKbPoca1tfUPj3iSbitDZTGnq6FUFjkH6L8U2oDwSuwK1WhnnVtCG7oFOTg/DDnyoXbQYUiUiGOibHqaGVnw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jsdevtools/ono": "^7.1.3", - "@types/json-schema": "^7.0.6", - "call-me-maybe": "^1.0.1", - "js-yaml": "^4.1.0" - }, - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://github.com/sponsors/philsturgeon" - } - }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -3195,9 +3194,9 @@ "license": "MIT" }, "node_modules/@mat3ra/code": { - "version": "2025.8.7-0", - "resolved": "https://registry.npmjs.org/@mat3ra/code/-/code-2025.8.7-0.tgz", - "integrity": "sha512-Bx5mFWQfpNU70vgSt2CR9zYWNsW7b8mU5emmPrsnGKIfKi1UH6xKwhaz7Fy77bju5NHi0iv3IE9UDXf0nr6SGQ==", + "version": "0.0.0", + "resolved": "git+ssh://git@github.com/Exabyte-io/code.git#2f5206cb8db85af8c9af3d450a8dc551bb6b9b61", + "integrity": "sha512-24YL0+n8EpWUYURbGp7Pw9MKH456teZStoW4QsUME07CqgrOKUcxV9Z9XVtpLRFSq+A5e7TszSiIJ7FAdlLZTQ==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -3235,9 +3234,9 @@ } }, "node_modules/@mat3ra/esse": { - "version": "2025.8.14-0", - "resolved": "https://registry.npmjs.org/@mat3ra/esse/-/esse-2025.8.14-0.tgz", - "integrity": "sha512-p8Fijembng3eiXEwXXRNp34eVqUq8BueCGqA20aKFJTNROoJCws7ODZoHrGeYn91LXkEJ+lfsg4wa96GxYNZyg==", + "version": "0.0.0", + "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#a91ed6431f436b52689a1aff82096f3f9d618654", + "integrity": "sha512-h04GnW7PFepbPDp2rAtmFvNGQ0IjvaYVsEUgQ0IS3k087ZsSjxfToDaJ/jftOHpJvOPF8EI48aHZezrdPIDpkw==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -3260,7 +3259,7 @@ "json-schema": "^0.4.0", "json-schema-deref-sync": "0.14.0", "json-schema-merge-allof": "^0.8.1", - "json-schema-to-typescript": "^13.1.2", + "json-schema-to-typescript": "^15.0.4", "lodash": "4.17.21" }, "engines": { @@ -4391,17 +4390,6 @@ "@types/chai": "*" } }, - "node_modules/@types/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/minimatch": "*", - "@types/node": "*" - } - }, "node_modules/@types/js-yaml": { "version": "4.0.9", "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz", @@ -4433,9 +4421,9 @@ "license": "MIT" }, "node_modules/@types/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-H3MHACvFUEiujabxhaI/ImO6gUrd8oOurg7LQtS7mbwIXA/cUqWrvBsaeJ23aZEPk1TAYkurjfMbSELfoCXlGA==", + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-FOvQ0YPD5NOfPgMzJihoT+Za5pdkDJWcbpuj1DjaKZIr/gxodQjY/uWEFlTNqW2ugXHUiL8lRQgw63dzKHZdeQ==", "dev": true, "license": "MIT" }, @@ -4449,13 +4437,6 @@ "decimal.js": "^10.0.0" } }, - "node_modules/@types/minimatch": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", - "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/mocha": { "version": "10.0.10", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.10.tgz", @@ -4469,6 +4450,7 @@ "integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~7.16.0" } @@ -4480,13 +4462,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/prettier": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", - "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/react": { "version": "19.2.5", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.5.tgz", @@ -4968,13 +4943,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", - "dev": true, - "license": "MIT" - }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -5519,13 +5487,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/call-me-maybe": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", - "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==", - "dev": true, - "license": "MIT" - }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -5661,23 +5622,6 @@ "node": ">=6" } }, - "node_modules/cli-color": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.4.tgz", - "integrity": "sha512-zlnpg0jNcibNrO7GG9IeHH7maWFeCz+Ja1wx/7tZNU5ASSSSZ+/qZciM0/LHCYxSdqv5h2sdbQ/PXYdOuetXvA==", - "dev": true, - "license": "ISC", - "dependencies": { - "d": "^1.0.1", - "es5-ext": "^0.10.64", - "es6-iterator": "^2.0.3", - "memoizee": "^0.4.15", - "timers-ext": "^0.1.7" - }, - "engines": { - "node": ">=0.10" - } - }, "node_modules/cli-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", @@ -5977,20 +5921,6 @@ "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", "license": "MIT" }, - "node_modules/d": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.2.tgz", - "integrity": "sha512-MOqHvMWF9/9MX6nza0KgvFH4HpMU0EF5uUDXqX/BtxtU8NfB0QzRtJ8Oe/6SuS4kbhyzVJwjd97EA4PKrzJ8bw==", - "dev": true, - "license": "ISC", - "dependencies": { - "es5-ext": "^0.10.64", - "type": "^2.7.2" - }, - "engines": { - "node": ">=0.12" - } - }, "node_modules/dag-map": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/dag-map/-/dag-map-1.0.2.tgz", @@ -6447,23 +6377,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/es5-ext": { - "version": "0.10.64", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz", - "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==", - "dev": true, - "hasInstallScript": true, - "license": "ISC", - "dependencies": { - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.3", - "esniff": "^2.0.1", - "next-tick": "^1.1.0" - }, - "engines": { - "node": ">=0.10" - } - }, "node_modules/es6-error": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", @@ -6471,45 +6384,6 @@ "dev": true, "license": "MIT" }, - "node_modules/es6-iterator": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", - "dev": true, - "license": "MIT", - "dependencies": { - "d": "1", - "es5-ext": "^0.10.35", - "es6-symbol": "^3.1.1" - } - }, - "node_modules/es6-symbol": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.4.tgz", - "integrity": "sha512-U9bFFjX8tFiATgtkJ1zg25+KviIXpgRvRHS8sau3GfhVzThRQrOeksPeT0BWW2MNZs1OEWJ1DPXOQMn0KKRkvg==", - "dev": true, - "license": "ISC", - "dependencies": { - "d": "^1.0.2", - "ext": "^1.7.0" - }, - "engines": { - "node": ">=0.12" - } - }, - "node_modules/es6-weak-map": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", - "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", - "dev": true, - "license": "ISC", - "dependencies": { - "d": "1", - "es5-ext": "^0.10.46", - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.1" - } - }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", @@ -7258,22 +7132,6 @@ "dev": true, "license": "BSD-3-Clause" }, - "node_modules/esniff": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz", - "integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==", - "dev": true, - "license": "ISC", - "dependencies": { - "d": "^1.0.1", - "es5-ext": "^0.10.62", - "event-emitter": "^0.3.5", - "type": "^2.7.2" - }, - "engines": { - "node": ">=0.10" - } - }, "node_modules/espree": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", @@ -7359,17 +7217,6 @@ "node": ">=0.10.0" } }, - "node_modules/event-emitter": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", - "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", - "dev": true, - "license": "MIT", - "dependencies": { - "d": "1", - "es5-ext": "~0.10.14" - } - }, "node_modules/execa": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", @@ -7394,16 +7241,6 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, - "node_modules/ext": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", - "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", - "dev": true, - "license": "ISC", - "dependencies": { - "type": "^2.7.2" - } - }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -7791,19 +7628,6 @@ "node": ">= 0.4" } }, - "node_modules/get-stdin": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", - "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/get-stream": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", @@ -7870,26 +7694,6 @@ "node": ">= 6" } }, - "node_modules/glob-promise": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/glob-promise/-/glob-promise-4.2.2.tgz", - "integrity": "sha512-xcUzJ8NWN5bktoTIX7eOclO1Npxd/dyVqUJxlLIDasT4C7KZyqlPIwkdJ0Ypiy3p2ZKahTjK4M9uC3sNSfNMzw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/glob": "^7.1.3" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "type": "individual", - "url": "https://github.com/sponsors/ahmadnassri" - }, - "peerDependencies": { - "glob": "^7.1.6" - } - }, "node_modules/globals": { "version": "13.24.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", @@ -8575,13 +8379,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-promise": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", - "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==", - "dev": true, - "license": "MIT" - }, "node_modules/is-regex": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", @@ -9077,32 +8874,43 @@ } }, "node_modules/json-schema-to-typescript": { - "version": "13.1.2", - "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-13.1.2.tgz", - "integrity": "sha512-17G+mjx4nunvOpkPvcz7fdwUwYCEwyH8vR3Ym3rFiQ8uzAL3go+c1306Kk7iGRk8HuXBXqy+JJJmpYl0cvOllw==", + "version": "15.0.4", + "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-15.0.4.tgz", + "integrity": "sha512-Su9oK8DR4xCmDsLlyvadkXzX6+GGXJpbhwoLtOGArAG61dvbW4YQmSEno2y66ahpIdmLMg6YUf/QHLgiwvkrHQ==", "dev": true, "license": "MIT", "dependencies": { - "@bcherny/json-schema-ref-parser": "10.0.5-fork", - "@types/json-schema": "^7.0.11", - "@types/lodash": "^4.14.182", - "@types/prettier": "^2.6.1", - "cli-color": "^2.0.2", - "get-stdin": "^8.0.0", - "glob": "^7.1.6", - "glob-promise": "^4.2.2", + "@apidevtools/json-schema-ref-parser": "^11.5.5", + "@types/json-schema": "^7.0.15", + "@types/lodash": "^4.17.7", "is-glob": "^4.0.3", + "js-yaml": "^4.1.0", "lodash": "^4.17.21", - "minimist": "^1.2.6", - "mkdirp": "^1.0.4", - "mz": "^2.7.0", - "prettier": "^2.6.2" + "minimist": "^1.2.8", + "prettier": "^3.2.5", + "tinyglobby": "^0.2.9" }, "bin": { "json2ts": "dist/src/cli.js" }, "engines": { - "node": ">=12.0.0" + "node": ">=16.0.0" + } + }, + "node_modules/json-schema-to-typescript/node_modules/prettier": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" } }, "node_modules/json-schema-traverse": { @@ -9623,16 +9431,6 @@ "yallist": "^3.0.2" } }, - "node_modules/lru-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", - "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "es5-ext": "~0.10.2" - } - }, "node_modules/make-dir": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", @@ -9716,26 +9514,6 @@ "is-buffer": "~1.1.1" } }, - "node_modules/memoizee": { - "version": "0.4.17", - "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.17.tgz", - "integrity": "sha512-DGqD7Hjpi/1or4F/aYAspXKNm5Yili0QDAFAY4QYvpqpgiY6+1jOfqpmByzjxbWd/T9mChbCArXAbDAsTm5oXA==", - "dev": true, - "license": "ISC", - "dependencies": { - "d": "^1.0.2", - "es5-ext": "^0.10.64", - "es6-weak-map": "^2.0.3", - "event-emitter": "^0.3.5", - "is-promise": "^2.2.2", - "lru-queue": "^0.1.0", - "next-tick": "^1.1.0", - "timers-ext": "^0.1.7" - }, - "engines": { - "node": ">=0.12" - } - }, "node_modules/memory-cache": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/memory-cache/-/memory-cache-0.2.0.tgz", @@ -9814,19 +9592,6 @@ "dev": true, "license": "Apache-2.0" }, - "node_modules/mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true, - "license": "MIT", - "bin": { - "mkdirp": "bin/cmd.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/mocha": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz", @@ -10018,18 +9783,6 @@ "dev": true, "license": "MIT" }, - "node_modules/mz": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", - "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "any-promise": "^1.0.0", - "object-assign": "^4.0.1", - "thenify-all": "^1.0.0" - } - }, "node_modules/nanoid": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", @@ -10057,13 +9810,6 @@ "dev": true, "license": "MIT" }, - "node_modules/next-tick": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", - "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==", - "dev": true, - "license": "ISC" - }, "node_modules/node-preload": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", @@ -12190,29 +11936,6 @@ "dev": true, "license": "MIT" }, - "node_modules/thenify": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", - "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", - "dev": true, - "license": "MIT", - "dependencies": { - "any-promise": "^1.0.0" - } - }, - "node_modules/thenify-all": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", - "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", - "dev": true, - "license": "MIT", - "dependencies": { - "thenify": ">= 3.1.0 < 4" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -12220,26 +11943,60 @@ "dev": true, "license": "MIT" }, - "node_modules/timers-ext": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.8.tgz", - "integrity": "sha512-wFH7+SEAcKfJpfLPkrgMPvvwnEtj8W4IurvEyrKsDleXnKLCDw71w8jltvfLa8Rm4qQxxT4jmDBYbJG/z7qoww==", + "node_modules/tiny-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", "dev": true, - "license": "ISC", + "license": "MIT" + }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", "dependencies": { - "es5-ext": "^0.10.64", - "next-tick": "^1.1.0" + "fdir": "^6.5.0", + "picomatch": "^4.0.3" }, "engines": { - "node": ">=0.12" + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" } }, - "node_modules/tiny-emitter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", - "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", "dev": true, - "license": "MIT" + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } }, "node_modules/to-regex-range": { "version": "5.0.1", @@ -12405,13 +12162,6 @@ "dev": true, "license": "0BSD" }, - "node_modules/type": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/type/-/type-2.7.3.tgz", - "integrity": "sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ==", - "dev": true, - "license": "ISC" - }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -12627,7 +12377,8 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/unicode-canonical-property-names-ecmascript": { "version": "2.0.1", diff --git a/package.json b/package.json index 856d91c..94f2298 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,8 @@ "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/utils": "2025.9.20-0", - "@mat3ra/code": "2025.8.7-0", - "@mat3ra/esse": "2025.8.14-0", + "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#2f5206cb8db85af8c9af3d450a8dc551bb6b9b61", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#a91ed6431f436b52689a1aff82096f3f9d618654", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", diff --git a/src/js/executable.ts b/src/js/executable.ts index 0a60939..fd0db93 100644 --- a/src/js/executable.ts +++ b/src/js/executable.ts @@ -1,14 +1,42 @@ -import { NamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import { runtimeItemsMixin } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; +import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import { + type DefaultableInMemoryEntity, + defaultableEntityMixin, +} from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; +import { + type NamedInMemoryEntity, + namedEntityMixin, +} from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; +import { + type RuntimeItemsStringInMemoryEntity, + runtimeItemsStringMixin, +} from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsStringMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types"; import { type ExecutableMixin, executableMixin, executableStaticMixin } from "./executableMixin"; -type Base = Constructor & typeof NamedDefaultableInMemoryEntity; +type Base = Constructor & + Constructor & + Constructor & + Constructor & + typeof InMemoryEntity; -export default class Executable extends (NamedDefaultableInMemoryEntity as Base) {} +export default class Executable extends (InMemoryEntity as Base) { + constructor(data: Partial = {}) { + super({ + monitors: [], + results: [], + postProcessors: [], + preProcessors: [], + ...data, + }); + } +} // Apply mixins -runtimeItemsMixin(Executable.prototype); +runtimeItemsStringMixin(Executable.prototype); executableMixin(Executable.prototype); executableStaticMixin(Executable); +namedEntityMixin(Executable.prototype); +defaultableEntityMixin(Executable); diff --git a/src/js/flavor.ts b/src/js/flavor.ts index f8230b0..0746731 100644 --- a/src/js/flavor.ts +++ b/src/js/flavor.ts @@ -1,19 +1,42 @@ -import { NamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; import { - type RuntimeItemsInMemoryEntity, - runtimeItemsMixin, -} from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; + type DefaultableInMemoryEntity, + defaultableEntityMixin, +} from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; +import { + type NamedInMemoryEntity, + namedEntityMixin, +} from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; +import { + type RuntimeItemsStringInMemoryEntity, + runtimeItemsStringMixin, +} from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsStringMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { FlavorSchema } from "@mat3ra/esse/dist/js/types"; import { type FlavorMixin, flavorMixin, flavorStaticMixin } from "./flavorMixin"; -type Base = typeof NamedDefaultableInMemoryEntity & +type Base = typeof InMemoryEntity & Constructor & - Constructor; + Constructor & + Constructor & + Constructor; -export default class Flavor extends (NamedDefaultableInMemoryEntity as Base) {} +export default class Flavor extends (InMemoryEntity as Base) { + constructor(data: Partial = {}) { + super({ + monitors: [], + results: [], + postProcessors: [], + preProcessors: [], + ...data, + }); + } +} // Apply mixins flavorMixin(Flavor.prototype); -runtimeItemsMixin(Flavor.prototype); +runtimeItemsStringMixin(Flavor.prototype); +namedEntityMixin(Flavor.prototype); +defaultableEntityMixin(Flavor); flavorStaticMixin(Flavor); diff --git a/tests/js/flavor.test.ts b/tests/js/flavor.test.ts index 6a459b4..ee12ecd 100644 --- a/tests/js/flavor.test.ts +++ b/tests/js/flavor.test.ts @@ -12,13 +12,13 @@ describe("Flavor", () => { }, ); expect(pwscfFlavor?.results).to.deep.equal([ - { name: "atomic_forces" }, - { name: "fermi_energy" }, - { name: "pressure" }, - { name: "stress_tensor" }, - { name: "total_energy" }, - { name: "total_energy_contributions" }, - { name: "total_force" }, + "atomic_forces", + "fermi_energy", + "pressure", + "stress_tensor", + "total_energy", + "total_energy_contributions", + "total_force", ]); }); @@ -82,7 +82,7 @@ describe("Flavor", () => { flavor.setProp("supportedApplicationVersions", ["6.3", "7.0"]); expect(flavor.supportedApplicationVersions).to.deep.equal(["6.3", "7.0"]); }); - + // Added with LLM to help with coverage it("should handle getInputAsRenderedTemplates with different template types", () => { const mockTemplate = { getRenderedJSON: () => ({ rendered: true }) }; From 5adf0bfbdb6d1259b0c2a933e83d9050ad3be74a Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Thu, 27 Nov 2025 01:51:42 +0200 Subject: [PATCH 02/16] update: add mixin generation --- .nycrc | 1 + dist/js/ApplicationRegistry.js | 1 + dist/js/application.js | 3 +- dist/js/applicationMixin.d.ts | 7 +- dist/js/applicationMixin.js | 27 +- dist/js/executable.js | 4 +- dist/js/executableMixin.d.ts | 7 +- dist/js/executableMixin.js | 18 +- dist/js/flavor.js | 8 +- dist/js/flavorMixin.d.ts | 20 +- dist/js/flavorMixin.js | 49 +- dist/js/generated/ApplicationMixin.d.ts | 5 + dist/js/generated/ApplicationMixin.js | 45 ++ dist/js/generated/ApplicationSchemaMixin.d.ts | 5 + dist/js/generated/ApplicationSchemaMixin.js | 45 ++ dist/js/generated/ExecutableMixin.d.ts | 5 + dist/js/generated/ExecutableMixin.js | 27 + dist/js/generated/ExecutableSchemaMixin.d.ts | 5 + dist/js/generated/ExecutableSchemaMixin.js | 27 + dist/js/generated/FlavorMixin.d.ts | 5 + dist/js/generated/FlavorMixin.js | 39 ++ dist/js/generated/FlavorSchemaMixin.d.ts | 5 + dist/js/generated/FlavorSchemaMixin.js | 39 ++ dist/js/generated/TemplateMixin.d.ts | 5 + dist/js/generated/TemplateMixin.js | 57 ++ dist/js/generated/TemplateSchemaMixin.d.ts | 5 + dist/js/generated/TemplateSchemaMixin.js | 57 ++ dist/js/index.d.ts | 6 +- dist/js/index.js | 4 +- dist/js/template.d.ts | 7 +- dist/js/template.js | 17 +- dist/js/templateMixin.d.ts | 21 +- dist/js/templateMixin.js | 60 +-- dist/js/types.d.ts | 4 +- package-lock.json | 503 +++++++++++++++++- package.json | 5 +- scripts/generate-mixins.ts | 37 ++ src/js/ApplicationRegistry.ts | 1 + src/js/application.ts | 4 +- src/js/applicationMixin.ts | 48 +- src/js/executable.ts | 6 +- src/js/executableMixin.ts | 25 +- src/js/flavor.ts | 10 +- src/js/flavorMixin.ts | 73 +-- src/js/generated/ApplicationSchemaMixin.ts | 56 ++ src/js/generated/ExecutableSchemaMixin.ts | 38 ++ src/js/generated/FlavorSchemaMixin.ts | 50 ++ src/js/generated/TemplateSchemaMixin.ts | 68 +++ src/js/index.ts | 6 +- src/js/template.ts | 36 +- src/js/templateMixin.ts | 113 ++-- src/js/types.ts | 3 +- tests/js/ApplicationRegistry.test.ts | 8 +- tests/js/JSONSchemaFormDataProvider.test.ts | 68 +++ tests/js/application.test.ts | 52 -- tests/js/flavor.test.ts | 29 +- tests/js/template.test.ts | 92 ++-- 57 files changed, 1492 insertions(+), 479 deletions(-) create mode 100644 dist/js/generated/ApplicationMixin.d.ts create mode 100644 dist/js/generated/ApplicationMixin.js create mode 100644 dist/js/generated/ApplicationSchemaMixin.d.ts create mode 100644 dist/js/generated/ApplicationSchemaMixin.js create mode 100644 dist/js/generated/ExecutableMixin.d.ts create mode 100644 dist/js/generated/ExecutableMixin.js create mode 100644 dist/js/generated/ExecutableSchemaMixin.d.ts create mode 100644 dist/js/generated/ExecutableSchemaMixin.js create mode 100644 dist/js/generated/FlavorMixin.d.ts create mode 100644 dist/js/generated/FlavorMixin.js create mode 100644 dist/js/generated/FlavorSchemaMixin.d.ts create mode 100644 dist/js/generated/FlavorSchemaMixin.js create mode 100644 dist/js/generated/TemplateMixin.d.ts create mode 100644 dist/js/generated/TemplateMixin.js create mode 100644 dist/js/generated/TemplateSchemaMixin.d.ts create mode 100644 dist/js/generated/TemplateSchemaMixin.js create mode 100644 scripts/generate-mixins.ts create mode 100644 src/js/generated/ApplicationSchemaMixin.ts create mode 100644 src/js/generated/ExecutableSchemaMixin.ts create mode 100644 src/js/generated/FlavorSchemaMixin.ts create mode 100644 src/js/generated/TemplateSchemaMixin.ts create mode 100644 tests/js/JSONSchemaFormDataProvider.test.ts diff --git a/.nycrc b/.nycrc index 3cd94a5..c8908b6 100644 --- a/.nycrc +++ b/.nycrc @@ -6,6 +6,7 @@ "src/**/*.ts" ], "exclude": [ + "src/js/generated/**/*", "tests/**/*", "**/*.test.ts", "**/*.spec.ts", diff --git a/dist/js/ApplicationRegistry.js b/dist/js/ApplicationRegistry.js index 7afe7e0..989d3d4 100644 --- a/dist/js/ApplicationRegistry.js +++ b/dist/js/ApplicationRegistry.js @@ -52,6 +52,7 @@ class ApplicationRegistry { appTreeItem[version] = appVersion; const applicationConfig = { ...appData, + // @ts-ignore build: buildToUse, ...versionInfo, }; diff --git a/dist/js/application.js b/dist/js/application.js index 129810e..cf464cd 100644 --- a/dist/js/application.js +++ b/dist/js/application.js @@ -5,5 +5,4 @@ const applicationMixin_1 = require("./applicationMixin"); class Application extends entity_1.NamedDefaultableInMemoryEntity { } exports.default = Application; -(0, applicationMixin_1.applicationMixin)(Application.prototype); -(0, applicationMixin_1.applicationStaticMixin)(Application); +(0, applicationMixin_1.applicationMixin)(Application); diff --git a/dist/js/applicationMixin.d.ts b/dist/js/applicationMixin.d.ts index 11aab73..3334cc6 100644 --- a/dist/js/applicationMixin.d.ts +++ b/dist/js/applicationMixin.d.ts @@ -4,12 +4,12 @@ import type { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/Nam import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { ApplicationSchemaBase } from "@mat3ra/esse/dist/js/types"; import Executable from "./executable"; +import { type ApplicationSchemaMixin } from "./generated/ApplicationSchemaMixin"; type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity; export type BaseConstructor = Constructor & { constructCustomExecutable?: (config: object) => Executable; }; -export type ApplicationConstructor = Constructor & ApplicationStaticMixin; -export type ApplicationMixin = Pick & { +export type ApplicationMixin = ApplicationSchemaMixin & { name: Required["name"]; isUsingMaterial: boolean; }; @@ -18,6 +18,5 @@ export type ApplicationStaticMixin = { defaultConfig: DefaultApplicationConfig; jsonSchema: ApplicationSchemaBase; }; -export declare function applicationMixin(item: Base): void; -export declare function applicationStaticMixin(Application: T): void; +export declare function applicationMixin(Item: BaseConstructor): void; export {}; diff --git a/dist/js/applicationMixin.js b/dist/js/applicationMixin.js index 7d7945f..4ddadc7 100644 --- a/dist/js/applicationMixin.js +++ b/dist/js/applicationMixin.js @@ -4,30 +4,13 @@ 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) { + (0, ApplicationSchemaMixin_1.applicationSchemaMixin)(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); @@ -46,3 +29,7 @@ function applicationStaticMixin(Application) { }; Object.defineProperties(Application, Object.getOwnPropertyDescriptors(properties)); } +function applicationMixin(Item) { + applicationPropertiesMixin(Item.prototype); + applicationStaticMixin(Item); +} diff --git a/dist/js/executable.js b/dist/js/executable.js index 5fbf0b1..e31e9fa 100644 --- a/dist/js/executable.js +++ b/dist/js/executable.js @@ -12,6 +12,7 @@ class Executable extends entity_1.InMemoryEntity { results: [], postProcessors: [], preProcessors: [], + applicationId: [], ...data, }); } @@ -19,7 +20,6 @@ class Executable extends entity_1.InMemoryEntity { exports.default = Executable; // Apply mixins (0, RuntimeItemsStringMixin_1.runtimeItemsStringMixin)(Executable.prototype); -(0, executableMixin_1.executableMixin)(Executable.prototype); -(0, executableMixin_1.executableStaticMixin)(Executable); (0, NamedEntityMixin_1.namedEntityMixin)(Executable.prototype); (0, DefaultableMixin_1.defaultableEntityMixin)(Executable); +(0, executableMixin_1.executableMixin)(Executable); diff --git a/dist/js/executableMixin.d.ts b/dist/js/executableMixin.d.ts index 87b9d2a..fed8963 100644 --- a/dist/js/executableMixin.d.ts +++ b/dist/js/executableMixin.d.ts @@ -5,18 +5,17 @@ import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types"; import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types"; import type { FlavorMixin } from "./flavorMixin"; +import { ExecutableSchemaMixin } from "./generated/ExecutableSchemaMixin"; type BaseFlavor = FlavorMixin & NamedInMemoryEntity & InMemoryEntity; type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity; -export declare function executableMixin(item: Base): void; -export declare function executableStaticMixin(Executable: Constructor): void; export type BaseConstructor = Constructor & { constructCustomFlavor?: (config: object) => BaseFlavor; }; -export type ExecutableMixin = { - applicationId: string[]; +export type ExecutableMixin = ExecutableSchemaMixin & { toJSON: () => ExecutableSchema & AnyObject; }; export type ExecutableStaticMixin = { jsonSchema: ExecutableSchema; }; +export declare function executableMixin(Item: BaseConstructor): void; export {}; diff --git a/dist/js/executableMixin.js b/dist/js/executableMixin.js index bf3169d..eff4125 100644 --- a/dist/js/executableMixin.js +++ b/dist/js/executableMixin.js @@ -4,20 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.executableMixin = executableMixin; -exports.executableStaticMixin = executableStaticMixin; const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -function executableMixin(item) { - // @ts-expect-error - const properties = { - get applicationId() { - return this.prop("applicationId", []); - }, - set applicationId(value) { - this.setProp("applicationId", value); - }, - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} +const ExecutableSchemaMixin_1 = require("./generated/ExecutableSchemaMixin"); function executableStaticMixin(Executable) { const properties = { get jsonSchema() { @@ -26,3 +14,7 @@ function executableStaticMixin(Executable) { }; Object.defineProperties(Executable, Object.getOwnPropertyDescriptors(properties)); } +function executableMixin(Item) { + (0, ExecutableSchemaMixin_1.executableSchemaMixin)(Item.prototype); + executableStaticMixin(Item); +} diff --git a/dist/js/flavor.js b/dist/js/flavor.js index f14c624..537bed5 100644 --- a/dist/js/flavor.js +++ b/dist/js/flavor.js @@ -12,14 +12,16 @@ class Flavor extends entity_1.InMemoryEntity { results: [], postProcessors: [], preProcessors: [], + input: [], + executableId: "", + executableName: "", + applicationName: "", ...data, }); } } exports.default = Flavor; -// Apply mixins -(0, flavorMixin_1.flavorMixin)(Flavor.prototype); (0, RuntimeItemsStringMixin_1.runtimeItemsStringMixin)(Flavor.prototype); (0, NamedEntityMixin_1.namedEntityMixin)(Flavor.prototype); (0, DefaultableMixin_1.defaultableEntityMixin)(Flavor); -(0, flavorMixin_1.flavorStaticMixin)(Flavor); +(0, flavorMixin_1.flavorMixin)(Flavor); diff --git a/dist/js/flavorMixin.d.ts b/dist/js/flavorMixin.d.ts index 4ace9ab..a494611 100644 --- a/dist/js/flavorMixin.d.ts +++ b/dist/js/flavorMixin.d.ts @@ -1,23 +1,9 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import type { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { FlavorSchema } from "@mat3ra/esse/dist/js/types"; -type Base = InMemoryEntity & NamedInMemoryEntity; -type Input = Required["input"]; -export type FlavorMixin = { - input: Input; - disableRenderMaterials: boolean; - executableId: string; - executableName: string; - applicationName: string; - supportedApplicationVersions?: string[]; - getInputAsRenderedTemplates: (context: Record) => Record[]; -}; -export declare function flavorMixin(item: Base): FlavorMixin & InMemoryEntity & import("@mat3ra/esse/dist/js/types").NameEntitySchema & { - setName: (name: string) => void; -}; -export declare function flavorStaticMixin(Flavor: Constructor): void; +import { type FlavorSchemaMixin } from "./generated/FlavorSchemaMixin"; +export type FlavorMixin = FlavorSchemaMixin & {}; export type FlavorStaticMixin = { jsonSchema: FlavorSchema; }; -export {}; +export declare function flavorMixin(Item: Constructor): void; diff --git a/dist/js/flavorMixin.js b/dist/js/flavorMixin.js index c771bf7..ab09b52 100644 --- a/dist/js/flavorMixin.js +++ b/dist/js/flavorMixin.js @@ -4,39 +4,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.flavorMixin = flavorMixin; -exports.flavorStaticMixin = flavorStaticMixin; const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const FlavorSchemaMixin_1 = require("./generated/FlavorSchemaMixin"); // TODO: should we add fields from esse schema (executableId, executableName, applicationName)? -function flavorMixin(item) { +function flavorPropertiesMixin(item) { // @ts-expect-error const properties = { - get input() { - return this.prop("input", []); - }, - get disableRenderMaterials() { - return this.prop("isMultiMaterial", false); - }, - get executableId() { - return this.prop("executableId", ""); - }, - get executableName() { - return this.prop("executableName", ""); - }, - get applicationName() { - return this.prop("applicationName", ""); - }, - get supportedApplicationVersions() { - return this.prop("supportedApplicationVersions"); - }, - getInputAsRenderedTemplates(context) { - const input = this.input; - return input.map((template) => { - if (template && typeof template === "object" && "getRenderedJSON" in template) { - return template.getRenderedJSON(context); - } - return template; - }); - }, + // TODO: there is no "isMultiMaterial" field in the schema; should we add it? + // get disableRenderMaterials() { + // return this.prop("isMultiMaterial", false); + // }, + // TODO: do we actually use this method anywhere? + // getInputAsRenderedTemplates(context: Record) { + // return this.input?.map((template) => { + // if (template && typeof template === "object" && "getRenderedJSON" in template) { + // return template.getRenderedJSON(context); + // } + // return template; + // }); + // }, }; Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); return properties; @@ -49,3 +35,8 @@ function flavorStaticMixin(Flavor) { }; Object.defineProperties(Flavor, Object.getOwnPropertyDescriptors(properties)); } +function flavorMixin(Item) { + (0, FlavorSchemaMixin_1.flavorSchemaMixin)(Item.prototype); + flavorPropertiesMixin(Item.prototype); + flavorStaticMixin(Item); +} diff --git a/dist/js/generated/ApplicationMixin.d.ts b/dist/js/generated/ApplicationMixin.d.ts new file mode 100644 index 0000000..27024b9 --- /dev/null +++ b/dist/js/generated/ApplicationMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { ApplicationMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type ApplicationMixin = ApplicationMixinSchema; +export type ApplicationMixin = InMemoryEntity & ApplicationMixin; +export declare function applicationMixin(item: InMemoryEntity): asserts item is T & ApplicationMixin; diff --git a/dist/js/generated/ApplicationMixin.js b/dist/js/generated/ApplicationMixin.js new file mode 100644 index 0000000..2510ffb --- /dev/null +++ b/dist/js/generated/ApplicationMixin.js @@ -0,0 +1,45 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.applicationMixin = applicationMixin; +function applicationMixin(item) { + // @ts-expect-error + const properties = { + get shortName() { + return this.prop("shortName"); + }, + set shortName(value) { + this.setProp("shortName", value); + }, + get summary() { + return this.prop("summary"); + }, + set summary(value) { + this.setProp("summary", value); + }, + get version() { + return this.prop("version"); + }, + set version(value) { + this.setProp("version", value); + }, + get build() { + return this.prop("build"); + }, + set build(value) { + this.setProp("build", value); + }, + get hasAdvancedComputeOptions() { + return this.prop("hasAdvancedComputeOptions"); + }, + set hasAdvancedComputeOptions(value) { + this.setProp("hasAdvancedComputeOptions", value); + }, + get isLicensed() { + return this.prop("isLicensed"); + }, + set isLicensed(value) { + this.setProp("isLicensed", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/ApplicationSchemaMixin.d.ts b/dist/js/generated/ApplicationSchemaMixin.d.ts new file mode 100644 index 0000000..11fd11a --- /dev/null +++ b/dist/js/generated/ApplicationSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { ApplicationPropertiesSchema } from "@mat3ra/esse/dist/js/types"; +export type ApplicationSchemaMixin = ApplicationPropertiesSchema; +export type ApplicationInMemoryEntity = InMemoryEntity & ApplicationSchemaMixin; +export declare function applicationSchemaMixin(item: InMemoryEntity): asserts item is T & ApplicationSchemaMixin; diff --git a/dist/js/generated/ApplicationSchemaMixin.js b/dist/js/generated/ApplicationSchemaMixin.js new file mode 100644 index 0000000..63a8df0 --- /dev/null +++ b/dist/js/generated/ApplicationSchemaMixin.js @@ -0,0 +1,45 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.applicationSchemaMixin = applicationSchemaMixin; +function applicationSchemaMixin(item) { + // @ts-expect-error + const properties = { + get shortName() { + return this.requiredProp("shortName"); + }, + set shortName(value) { + this.setProp("shortName", value); + }, + get summary() { + return this.requiredProp("summary"); + }, + set summary(value) { + this.setProp("summary", value); + }, + get version() { + return this.requiredProp("version"); + }, + set version(value) { + this.setProp("version", value); + }, + get build() { + return this.requiredProp("build"); + }, + set build(value) { + this.setProp("build", value); + }, + get hasAdvancedComputeOptions() { + return this.prop("hasAdvancedComputeOptions"); + }, + set hasAdvancedComputeOptions(value) { + this.setProp("hasAdvancedComputeOptions", value); + }, + get isLicensed() { + return this.prop("isLicensed"); + }, + set isLicensed(value) { + this.setProp("isLicensed", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/ExecutableMixin.d.ts b/dist/js/generated/ExecutableMixin.d.ts new file mode 100644 index 0000000..d720eb1 --- /dev/null +++ b/dist/js/generated/ExecutableMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { ExecutableMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type ExecutableMixin = ExecutableMixinSchema; +export type ExecutableMixin = InMemoryEntity & ExecutableMixin; +export declare function executableMixin(item: InMemoryEntity): asserts item is T & ExecutableMixin; diff --git a/dist/js/generated/ExecutableMixin.js b/dist/js/generated/ExecutableMixin.js new file mode 100644 index 0000000..ce15d0e --- /dev/null +++ b/dist/js/generated/ExecutableMixin.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.executableMixin = executableMixin; +function executableMixin(item) { + // @ts-expect-error + const properties = { + get name() { + return this.requiredProp("name"); + }, + set name(value) { + this.setProp("name", value); + }, + get applicationId() { + return this.prop("applicationId"); + }, + set applicationId(value) { + this.setProp("applicationId", value); + }, + get hasAdvancedComputeOptions() { + return this.prop("hasAdvancedComputeOptions"); + }, + set hasAdvancedComputeOptions(value) { + this.setProp("hasAdvancedComputeOptions", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/ExecutableSchemaMixin.d.ts b/dist/js/generated/ExecutableSchemaMixin.d.ts new file mode 100644 index 0000000..11f70b8 --- /dev/null +++ b/dist/js/generated/ExecutableSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { ExecutablePropertiesSchema } from "@mat3ra/esse/dist/js/types"; +export type ExecutableSchemaMixin = ExecutablePropertiesSchema; +export type ExecutableInMemoryEntity = InMemoryEntity & ExecutableSchemaMixin; +export declare function executableSchemaMixin(item: InMemoryEntity): asserts item is T & ExecutableSchemaMixin; diff --git a/dist/js/generated/ExecutableSchemaMixin.js b/dist/js/generated/ExecutableSchemaMixin.js new file mode 100644 index 0000000..6ab21d3 --- /dev/null +++ b/dist/js/generated/ExecutableSchemaMixin.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.executableSchemaMixin = executableSchemaMixin; +function executableSchemaMixin(item) { + // @ts-expect-error + const properties = { + get name() { + return this.requiredProp("name"); + }, + set name(value) { + this.setProp("name", value); + }, + get applicationId() { + return this.requiredProp("applicationId"); + }, + set applicationId(value) { + this.setProp("applicationId", value); + }, + get hasAdvancedComputeOptions() { + return this.prop("hasAdvancedComputeOptions"); + }, + set hasAdvancedComputeOptions(value) { + this.setProp("hasAdvancedComputeOptions", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/FlavorMixin.d.ts b/dist/js/generated/FlavorMixin.d.ts new file mode 100644 index 0000000..3ff6703 --- /dev/null +++ b/dist/js/generated/FlavorMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { FlavorMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type FlavorMixin = FlavorMixinSchema; +export type FlavorMixin = InMemoryEntity & FlavorMixin; +export declare function flavorMixin(item: InMemoryEntity): asserts item is T & FlavorMixin; diff --git a/dist/js/generated/FlavorMixin.js b/dist/js/generated/FlavorMixin.js new file mode 100644 index 0000000..1bead61 --- /dev/null +++ b/dist/js/generated/FlavorMixin.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.flavorMixin = flavorMixin; +function flavorMixin(item) { + // @ts-expect-error + const properties = { + get executableId() { + return this.prop("executableId"); + }, + set executableId(value) { + this.setProp("executableId", value); + }, + get executableName() { + return this.prop("executableName"); + }, + set executableName(value) { + this.setProp("executableName", value); + }, + get applicationName() { + return this.prop("applicationName"); + }, + set applicationName(value) { + this.setProp("applicationName", value); + }, + get input() { + return this.prop("input"); + }, + set input(value) { + this.setProp("input", value); + }, + get supportedApplicationVersions() { + return this.prop("supportedApplicationVersions"); + }, + set supportedApplicationVersions(value) { + this.setProp("supportedApplicationVersions", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/FlavorSchemaMixin.d.ts b/dist/js/generated/FlavorSchemaMixin.d.ts new file mode 100644 index 0000000..c239783 --- /dev/null +++ b/dist/js/generated/FlavorSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { FlavorPropertiesSchema } from "@mat3ra/esse/dist/js/types"; +export type FlavorSchemaMixin = FlavorPropertiesSchema; +export type FlavorInMemoryEntity = InMemoryEntity & FlavorSchemaMixin; +export declare function flavorSchemaMixin(item: InMemoryEntity): asserts item is T & FlavorSchemaMixin; diff --git a/dist/js/generated/FlavorSchemaMixin.js b/dist/js/generated/FlavorSchemaMixin.js new file mode 100644 index 0000000..cf3434f --- /dev/null +++ b/dist/js/generated/FlavorSchemaMixin.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.flavorSchemaMixin = flavorSchemaMixin; +function flavorSchemaMixin(item) { + // @ts-expect-error + const properties = { + get executableId() { + return this.requiredProp("executableId"); + }, + set executableId(value) { + this.setProp("executableId", value); + }, + get executableName() { + return this.prop("executableName"); + }, + set executableName(value) { + this.setProp("executableName", value); + }, + get applicationName() { + return this.prop("applicationName"); + }, + set applicationName(value) { + this.setProp("applicationName", value); + }, + get input() { + return this.requiredProp("input"); + }, + set input(value) { + this.setProp("input", value); + }, + get supportedApplicationVersions() { + return this.prop("supportedApplicationVersions"); + }, + set supportedApplicationVersions(value) { + this.setProp("supportedApplicationVersions", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/TemplateMixin.d.ts b/dist/js/generated/TemplateMixin.d.ts new file mode 100644 index 0000000..7a53e08 --- /dev/null +++ b/dist/js/generated/TemplateMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { TemplateMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type TemplateMixin = TemplateMixinSchema; +export type TemplateMixin = InMemoryEntity & TemplateMixin; +export declare function templateMixin(item: InMemoryEntity): asserts item is T & TemplateMixin; diff --git a/dist/js/generated/TemplateMixin.js b/dist/js/generated/TemplateMixin.js new file mode 100644 index 0000000..7cb1302 --- /dev/null +++ b/dist/js/generated/TemplateMixin.js @@ -0,0 +1,57 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.templateMixin = templateMixin; +function templateMixin(item) { + // @ts-expect-error + const properties = { + get applicationName() { + return this.prop("applicationName"); + }, + set applicationName(value) { + this.setProp("applicationName", value); + }, + get applicationVersion() { + return this.prop("applicationVersion"); + }, + set applicationVersion(value) { + this.setProp("applicationVersion", value); + }, + get executableName() { + return this.prop("executableName"); + }, + set executableName(value) { + this.setProp("executableName", value); + }, + get contextProviders() { + return this.prop("contextProviders"); + }, + set contextProviders(value) { + this.setProp("contextProviders", value); + }, + get isManuallyChanged() { + return this.prop("isManuallyChanged"); + }, + set isManuallyChanged(value) { + this.setProp("isManuallyChanged", value); + }, + get name() { + return this.requiredProp("name"); + }, + set name(value) { + this.setProp("name", value); + }, + get content() { + return this.requiredProp("content"); + }, + set content(value) { + this.setProp("content", value); + }, + get rendered() { + return this.prop("rendered"); + }, + set rendered(value) { + this.setProp("rendered", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/TemplateSchemaMixin.d.ts b/dist/js/generated/TemplateSchemaMixin.d.ts new file mode 100644 index 0000000..0c81a08 --- /dev/null +++ b/dist/js/generated/TemplateSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { TemplatePropertiesSchema } from "@mat3ra/esse/dist/js/types"; +export type TemplateSchemaMixin = TemplatePropertiesSchema; +export type TemplateInMemoryEntity = InMemoryEntity & TemplateSchemaMixin; +export declare function templateSchemaMixin(item: InMemoryEntity): asserts item is T & TemplateSchemaMixin; diff --git a/dist/js/generated/TemplateSchemaMixin.js b/dist/js/generated/TemplateSchemaMixin.js new file mode 100644 index 0000000..80d218c --- /dev/null +++ b/dist/js/generated/TemplateSchemaMixin.js @@ -0,0 +1,57 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.templateSchemaMixin = templateSchemaMixin; +function templateSchemaMixin(item) { + // @ts-expect-error + const properties = { + get applicationName() { + return this.requiredProp("applicationName"); + }, + set applicationName(value) { + this.setProp("applicationName", value); + }, + get applicationVersion() { + return this.prop("applicationVersion"); + }, + set applicationVersion(value) { + this.setProp("applicationVersion", value); + }, + get executableName() { + return this.requiredProp("executableName"); + }, + set executableName(value) { + this.setProp("executableName", value); + }, + get contextProviders() { + return this.requiredProp("contextProviders"); + }, + set contextProviders(value) { + this.setProp("contextProviders", value); + }, + get isManuallyChanged() { + return this.prop("isManuallyChanged"); + }, + set isManuallyChanged(value) { + this.setProp("isManuallyChanged", value); + }, + get name() { + return this.requiredProp("name"); + }, + set name(value) { + this.setProp("name", value); + }, + get content() { + return this.requiredProp("content"); + }, + set content(value) { + this.setProp("content", value); + }, + get rendered() { + return this.prop("rendered"); + }, + set rendered(value) { + this.setProp("rendered", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/index.d.ts b/dist/js/index.d.ts index 4b5801c..c550fcf 100644 --- a/dist/js/index.d.ts +++ b/dist/js/index.d.ts @@ -1,5 +1,5 @@ import Application from "./application"; -import { applicationMixin, applicationStaticMixin } from "./applicationMixin"; +import { applicationMixin } from "./applicationMixin"; import ApplicationRegistry from "./ApplicationRegistry"; import ContextProvider from "./context/ContextProvider"; import JSONSchemaFormDataProvider from "./context/JSONSchemaFormDataProvider"; @@ -8,6 +8,6 @@ import { executableMixin } from "./executableMixin"; import Flavor from "./flavor"; import { flavorMixin } from "./flavorMixin"; import Template from "./template"; -import { templateMixin, templateStaticMixin } from "./templateMixin"; +import { templateMixin } from "./templateMixin"; declare const allApplications: string[]; -export { Application, Executable, Flavor, Template, ApplicationRegistry, ContextProvider, JSONSchemaFormDataProvider, executableMixin, flavorMixin, applicationMixin, applicationStaticMixin, templateMixin, templateStaticMixin, allApplications, }; +export { Application, Executable, Flavor, Template, ApplicationRegistry, ContextProvider, JSONSchemaFormDataProvider, executableMixin, flavorMixin, applicationMixin, templateMixin, allApplications, }; diff --git a/dist/js/index.js b/dist/js/index.js index 58497ad..5cfd4d3 100644 --- a/dist/js/index.js +++ b/dist/js/index.js @@ -3,12 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.allApplications = exports.templateStaticMixin = exports.templateMixin = exports.applicationStaticMixin = exports.applicationMixin = exports.flavorMixin = exports.executableMixin = exports.JSONSchemaFormDataProvider = exports.ContextProvider = exports.ApplicationRegistry = exports.Template = exports.Flavor = exports.Executable = exports.Application = void 0; +exports.allApplications = exports.templateMixin = exports.applicationMixin = exports.flavorMixin = exports.executableMixin = exports.JSONSchemaFormDataProvider = exports.ContextProvider = exports.ApplicationRegistry = exports.Template = exports.Flavor = exports.Executable = exports.Application = void 0; const application_1 = __importDefault(require("./application")); exports.Application = application_1.default; const applicationMixin_1 = require("./applicationMixin"); Object.defineProperty(exports, "applicationMixin", { enumerable: true, get: function () { return applicationMixin_1.applicationMixin; } }); -Object.defineProperty(exports, "applicationStaticMixin", { enumerable: true, get: function () { return applicationMixin_1.applicationStaticMixin; } }); const ApplicationRegistry_1 = __importDefault(require("./ApplicationRegistry")); exports.ApplicationRegistry = ApplicationRegistry_1.default; const ContextProvider_1 = __importDefault(require("./context/ContextProvider")); @@ -27,6 +26,5 @@ const template_1 = __importDefault(require("./template")); exports.Template = template_1.default; const templateMixin_1 = require("./templateMixin"); Object.defineProperty(exports, "templateMixin", { enumerable: true, get: function () { return templateMixin_1.templateMixin; } }); -Object.defineProperty(exports, "templateStaticMixin", { enumerable: true, get: function () { return templateMixin_1.templateStaticMixin; } }); const allApplications = ApplicationRegistry_1.default.getUniqueAvailableApplicationNames(); exports.allApplications = allApplications; diff --git a/dist/js/template.d.ts b/dist/js/template.d.ts index f507f98..799dff5 100644 --- a/dist/js/template.d.ts +++ b/dist/js/template.d.ts @@ -1,8 +1,11 @@ -import { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import { type NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { TemplateSchema } from "@mat3ra/esse/dist/js/types"; import { type TemplateMixin, type TemplateStaticMixin } from "./templateMixin"; -type Base = typeof NamedInMemoryEntity & Constructor & TemplateStaticMixin; +type Base = typeof InMemoryEntity & Constructor & Constructor & TemplateStaticMixin; declare const Template_base: Base; export default class Template extends Template_base { + constructor(data?: Partial); } export {}; diff --git a/dist/js/template.js b/dist/js/template.js index f92273c..bb1c44f 100644 --- a/dist/js/template.js +++ b/dist/js/template.js @@ -1,10 +1,19 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const entity_1 = require("@mat3ra/code/dist/js/entity"); +const NamedEntityMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"); const templateMixin_1 = require("./templateMixin"); -class Template extends entity_1.NamedInMemoryEntity { +class Template extends entity_1.InMemoryEntity { + constructor(data = {}) { + super({ + applicationName: "", + executableName: "", + content: "", + contextProviders: [], + ...data, + }); + } } exports.default = Template; -// Apply mixins -(0, templateMixin_1.templateMixin)(Template.prototype); -(0, templateMixin_1.templateStaticMixin)(Template); +(0, NamedEntityMixin_1.namedEntityMixin)(Template.prototype); +(0, templateMixin_1.templateMixin)(Template); diff --git a/dist/js/templateMixin.d.ts b/dist/js/templateMixin.d.ts index ec14e17..f925926 100644 --- a/dist/js/templateMixin.d.ts +++ b/dist/js/templateMixin.d.ts @@ -1,20 +1,12 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import type { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types"; import type { TemplateSchema } from "@mat3ra/esse/dist/js/types"; import ContextProvider, { type ContextProviderConfig, type ContextProviderName } from "./context/ContextProvider"; import ContextProviderRegistryContainer from "./context/ContextProviderRegistryContainer"; -export type TemplateBase = InMemoryEntity & NamedInMemoryEntity; -export type TemplateMixin = { - isManuallyChanged: boolean; - content: string; - rendered: string | undefined; - applicationName: string | undefined; - executableName: string | undefined; - contextProviders: ContextProvider[]; - addContextProvider: (provider: ContextProvider) => void; - removeContextProvider: (provider: ContextProvider) => void; +import { type TemplateSchemaMixin } from "./generated/TemplateSchemaMixin"; +export type TemplateBase = InMemoryEntity; +export type TemplateMixin = TemplateSchemaMixin & { render: (externalContext?: Record) => void; getRenderedJSON: (context?: Record) => AnyObject; _cleanRenderingContext: (object: Record) => Record; @@ -25,9 +17,6 @@ export type TemplateMixin = { getDataFromProvidersForPersistentContext: (providerContext?: Record) => Record; getRenderingContext: (externalContext?: Record) => Record; }; -export declare function templateMixin(item: TemplateBase): TemplateMixin & InMemoryEntity & import("@mat3ra/esse/dist/js/types").NameEntitySchema & { - setName: (name: string) => void; -}; export type ContextProviderConfigMapEntry = { providerCls: typeof ContextProvider; config: ContextProviderConfig; @@ -38,6 +27,4 @@ export type TemplateStaticMixin = { setContextProvidersConfig: (classConfigMap: ContextProviderConfigMap) => void; jsonSchema: TemplateSchema; }; -export declare function templateStaticMixin(item: Constructor): TemplateStaticMixin & Constructor void; -} & TemplateMixin>; +export declare function templateMixin(Item: Constructor): void; diff --git a/dist/js/templateMixin.js b/dist/js/templateMixin.js index b2d5389..92cd68a 100644 --- a/dist/js/templateMixin.js +++ b/dist/js/templateMixin.js @@ -4,47 +4,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.templateMixin = templateMixin; -exports.templateStaticMixin = templateStaticMixin; -const utils_1 = require("@mat3ra/utils"); const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const utils_1 = require("@mat3ra/utils"); const nunjucks_1 = __importDefault(require("nunjucks")); const ContextProviderRegistryContainer_1 = __importDefault(require("./context/ContextProviderRegistryContainer")); -function templateMixin(item) { - // @ts-ignore +const TemplateSchemaMixin_1 = require("./generated/TemplateSchemaMixin"); +function templatePropertiesMixin(item) { + // @ts-expect-error const properties = { - get isManuallyChanged() { - return this.prop("isManuallyChanged", false); - }, - get content() { - return this.prop("content", ""); - }, setContent(text) { - return this.setProp("content", text); - }, - get rendered() { - return this.prop("rendered") || this.content; + this.content = text; + if (!this.rendered) { + this.rendered = text; + } }, setRendered(text) { - return this.setProp("rendered", text); - }, - get applicationName() { - return this.prop("applicationName"); - }, - get executableName() { - return this.prop("executableName"); - }, - get contextProviders() { - return this.prop("contextProviders", []); - }, - addContextProvider(provider) { - this.setProp("contextProviders", [...this.contextProviders, provider]); - }, - removeContextProvider(provider) { - const contextProviders = this.contextProviders.filter((p) => { - return p.name !== provider.name && p.domain !== provider.domain; - }); - this.setProp("contextProviders", contextProviders); - }, + this.rendered = text; + }, + // addContextProvider(provider: ContextProvider) { + // this.setProp("contextProviders", [...this.contextProviders, provider]); + // }, + // removeContextProvider(provider: ContextProvider) { + // const contextProviders = this.contextProviders.filter((p) => { + // return p.name !== provider.name && p.domain !== provider.domain; + // }); + // this.setProp("contextProviders", contextProviders); + // }, render(externalContext) { const renderingContext = this.getRenderingContext(externalContext); if (!this.isManuallyChanged) { @@ -137,7 +122,6 @@ function templateMixin(item) { }, }; Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); - return properties; } function templateStaticMixin(item) { // @ts-ignore @@ -158,5 +142,9 @@ function templateStaticMixin(item) { }, }; Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); - return properties; +} +function templateMixin(Item) { + (0, TemplateSchemaMixin_1.templateSchemaMixin)(Item.prototype); + templatePropertiesMixin(Item.prototype); + templateStaticMixin(Item); } diff --git a/dist/js/types.d.ts b/dist/js/types.d.ts index 9373ca3..b002bc0 100644 --- a/dist/js/types.d.ts +++ b/dist/js/types.d.ts @@ -2,5 +2,5 @@ import { ApplicationMixin, ApplicationStaticMixin } from "./applicationMixin"; import { CreateApplicationConfig } from "./ApplicationRegistry"; import { ExecutableMixin } from "./executableMixin"; import { FlavorMixin } from "./flavorMixin"; -import { TemplateMixin, TemplateStaticMixin } from "./templateMixin"; -export type { FlavorMixin, ExecutableMixin, ApplicationMixin, ApplicationStaticMixin, CreateApplicationConfig, TemplateMixin, TemplateStaticMixin, }; +import { TemplateMixin } from "./templateMixin"; +export type { FlavorMixin, ExecutableMixin, ApplicationMixin, ApplicationStaticMixin, CreateApplicationConfig, TemplateMixin, }; diff --git a/package-lock.json b/package-lock.json index 069be62..ff4653d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#2f5206cb8db85af8c9af3d450a8dc551bb6b9b61", - "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#a91ed6431f436b52689a1aff82096f3f9d618654", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#c248a30803e421f6da33e8270602bd1571945fb6", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", @@ -3235,8 +3235,8 @@ }, "node_modules/@mat3ra/esse": { "version": "0.0.0", - "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#a91ed6431f436b52689a1aff82096f3f9d618654", - "integrity": "sha512-h04GnW7PFepbPDp2rAtmFvNGQ0IjvaYVsEUgQ0IS3k087ZsSjxfToDaJ/jftOHpJvOPF8EI48aHZezrdPIDpkw==", + "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#c248a30803e421f6da33e8270602bd1571945fb6", + "integrity": "sha512-9o07vskHfdIsaHkTPvN0gEEaUrVdZBgjXQToy1TXW+I4KH0y5Sa4GWp21IuO9Ww322vI8QdXLx7SfnhzcZzWeQ==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -3249,6 +3249,7 @@ "@babel/preset-typescript": "^7.27.0", "@babel/register": "^7.25.9", "@babel/runtime-corejs3": "^7.27.0", + "@mat3ra/utils": "^2025.11.20-0", "@types/chai": "^4.3.20", "@types/js-yaml": "^4.0.9", "@types/json-schema-merge-allof": "^0.6.5", @@ -3266,6 +3267,502 @@ "node": ">=14.0.0" } }, + "node_modules/@mat3ra/esse/node_modules/@babel/helper-define-polyfill-provider": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.3.tgz", + "integrity": "sha512-z5aQKU4IzbqCC1XH0nAqfsFLMVSo22SBKUc0BxGrLkolTdPTructy0ToNnlO2zA4j9Q/7pjMZf0DSY+DSTYzww==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-compilation-targets": "^7.17.7", + "@babel/helper-plugin-utils": "^7.16.7", + "debug": "^4.1.1", + "lodash.debounce": "^4.0.8", + "resolve": "^1.14.2", + "semver": "^6.1.2" + }, + "peerDependencies": { + "@babel/core": "^7.4.0-0" + } + }, + "node_modules/@mat3ra/esse/node_modules/@babel/plugin-proposal-private-property-in-object": { + "version": "7.21.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz", + "integrity": "sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-create-class-features-plugin": "^7.21.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@mat3ra/esse/node_modules/@babel/preset-modules": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.6.tgz", + "integrity": "sha512-ID2yj6K/4lKfhuU3+EX4UvNbIt7eACFbHmNUjzA+ep+B5971CknnA/9DEWKbRokfbbtblxxxXFJJrH47UEAMVg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", + "@babel/plugin-transform-dotall-regex": "^7.4.4", + "@babel/types": "^7.4.4", + "esutils": "^2.0.2" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0 || ^8.0.0-0 <8.0.0" + } + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils": { + "version": "2025.11.20-0", + "resolved": "https://registry.npmjs.org/@mat3ra/utils/-/utils-2025.11.20-0.tgz", + "integrity": "sha512-igkswFIPrvIsOKiGdLE6ifgKGa3nruepjq2pPs9us+gHRn4tCaFNsBJqHw3ysw1dLgCtoYhHyYbMdpQu46+FCw==", + "dev": true, + "license": "ISC", + "dependencies": { + "@babel/cli": "7.16.0", + "@babel/core": "7.24.1", + "@babel/eslint-parser": "7.16.3", + "@babel/plugin-proposal-class-properties": "7.16.0", + "@babel/preset-env": "7.16.4", + "@babel/preset-react": "7.16.7", + "@babel/preset-typescript": "^7.22.5", + "@babel/register": "^7.16.0", + "@babel/runtime-corejs3": "7.16.8", + "crypto-js": "^4.1.1", + "js-yaml": "^4.1.0", + "lodash": "^4.17.21", + "mathjs": "12.4.1", + "semver": "^7.5.3", + "ts-node": "^10.9.1", + "typescript": "^4.5.5", + "underscore": "^1.13.3", + "underscore.string": "^3.3.4", + "uuid": "8.3.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils/node_modules/@babel/cli": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.16.0.tgz", + "integrity": "sha512-WLrM42vKX/4atIoQB+eb0ovUof53UUvecb4qGjU2PDDWRiZr50ZpiV8NpcLo7iSxeGYrRG0Mqembsa+UrTAV6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "commander": "^4.0.1", + "convert-source-map": "^1.1.0", + "fs-readdir-recursive": "^1.1.0", + "glob": "^7.0.0", + "make-dir": "^2.1.0", + "slash": "^2.0.0", + "source-map": "^0.5.0" + }, + "bin": { + "babel": "bin/babel.js", + "babel-external-helpers": "bin/babel-external-helpers.js" + }, + "engines": { + "node": ">=6.9.0" + }, + "optionalDependencies": { + "@nicolo-ribaudo/chokidar-2": "2.1.8-no-fsevents.3", + "chokidar": "^3.4.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils/node_modules/@babel/cli/node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true, + "license": "MIT" + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils/node_modules/@babel/core": { + "version": "7.24.1", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.1.tgz", + "integrity": "sha512-F82udohVyIgGAY2VVj/g34TpFUG606rumIHjTfVbssPg2zTR7PuuEpZcX8JA6sgBfIYmJrFtWgPvHQuJamVqZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.24.1", + "@babel/generator": "^7.24.1", + "@babel/helper-compilation-targets": "^7.23.6", + "@babel/helper-module-transforms": "^7.23.3", + "@babel/helpers": "^7.24.1", + "@babel/parser": "^7.24.1", + "@babel/template": "^7.24.0", + "@babel/traverse": "^7.24.1", + "@babel/types": "^7.24.0", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils/node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils/node_modules/@babel/eslint-parser": { + "version": "7.16.3", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.16.3.tgz", + "integrity": "sha512-iB4ElZT0jAt7PKVaeVulOECdGe6UnmA/O0P9jlF5g5GBOwDVbna8AXhHRu4s27xQf6OkveyA8iTDv1jHdDejgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-scope": "^5.1.1", + "eslint-visitor-keys": "^2.1.0", + "semver": "^6.3.0" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || >=14.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.11.0", + "eslint": "^7.5.0 || ^8.0.0" + } + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils/node_modules/@babel/eslint-parser/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils/node_modules/@babel/plugin-proposal-class-properties": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.16.0.tgz", + "integrity": "sha512-mCF3HcuZSY9Fcx56Lbn+CGdT44ioBMMvjNVldpKtj8tpniETdLjnxdHI1+sDWXIM1nNt+EanJOZ3IG9lzVjs7A==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.16.0", + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils/node_modules/@babel/preset-env": { + "version": "7.16.4", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.16.4.tgz", + "integrity": "sha512-v0QtNd81v/xKj4gNKeuAerQ/azeNn/G1B1qMLeXOcV8+4TWlD2j3NV1u8q29SDFBXx/NBq5kyEAO+0mpRgacjA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.16.4", + "@babel/helper-compilation-targets": "^7.16.3", + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/helper-validator-option": "^7.14.5", + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.16.2", + "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.16.0", + "@babel/plugin-proposal-async-generator-functions": "^7.16.4", + "@babel/plugin-proposal-class-properties": "^7.16.0", + "@babel/plugin-proposal-class-static-block": "^7.16.0", + "@babel/plugin-proposal-dynamic-import": "^7.16.0", + "@babel/plugin-proposal-export-namespace-from": "^7.16.0", + "@babel/plugin-proposal-json-strings": "^7.16.0", + "@babel/plugin-proposal-logical-assignment-operators": "^7.16.0", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0", + "@babel/plugin-proposal-numeric-separator": "^7.16.0", + "@babel/plugin-proposal-object-rest-spread": "^7.16.0", + "@babel/plugin-proposal-optional-catch-binding": "^7.16.0", + "@babel/plugin-proposal-optional-chaining": "^7.16.0", + "@babel/plugin-proposal-private-methods": "^7.16.0", + "@babel/plugin-proposal-private-property-in-object": "^7.16.0", + "@babel/plugin-proposal-unicode-property-regex": "^7.16.0", + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-class-properties": "^7.12.13", + "@babel/plugin-syntax-class-static-block": "^7.14.5", + "@babel/plugin-syntax-dynamic-import": "^7.8.3", + "@babel/plugin-syntax-export-namespace-from": "^7.8.3", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.10.4", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5", + "@babel/plugin-syntax-top-level-await": "^7.14.5", + "@babel/plugin-transform-arrow-functions": "^7.16.0", + "@babel/plugin-transform-async-to-generator": "^7.16.0", + "@babel/plugin-transform-block-scoped-functions": "^7.16.0", + "@babel/plugin-transform-block-scoping": "^7.16.0", + "@babel/plugin-transform-classes": "^7.16.0", + "@babel/plugin-transform-computed-properties": "^7.16.0", + "@babel/plugin-transform-destructuring": "^7.16.0", + "@babel/plugin-transform-dotall-regex": "^7.16.0", + "@babel/plugin-transform-duplicate-keys": "^7.16.0", + "@babel/plugin-transform-exponentiation-operator": "^7.16.0", + "@babel/plugin-transform-for-of": "^7.16.0", + "@babel/plugin-transform-function-name": "^7.16.0", + "@babel/plugin-transform-literals": "^7.16.0", + "@babel/plugin-transform-member-expression-literals": "^7.16.0", + "@babel/plugin-transform-modules-amd": "^7.16.0", + "@babel/plugin-transform-modules-commonjs": "^7.16.0", + "@babel/plugin-transform-modules-systemjs": "^7.16.0", + "@babel/plugin-transform-modules-umd": "^7.16.0", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.16.0", + "@babel/plugin-transform-new-target": "^7.16.0", + "@babel/plugin-transform-object-super": "^7.16.0", + "@babel/plugin-transform-parameters": "^7.16.3", + "@babel/plugin-transform-property-literals": "^7.16.0", + "@babel/plugin-transform-regenerator": "^7.16.0", + "@babel/plugin-transform-reserved-words": "^7.16.0", + "@babel/plugin-transform-shorthand-properties": "^7.16.0", + "@babel/plugin-transform-spread": "^7.16.0", + "@babel/plugin-transform-sticky-regex": "^7.16.0", + "@babel/plugin-transform-template-literals": "^7.16.0", + "@babel/plugin-transform-typeof-symbol": "^7.16.0", + "@babel/plugin-transform-unicode-escapes": "^7.16.0", + "@babel/plugin-transform-unicode-regex": "^7.16.0", + "@babel/preset-modules": "^0.1.5", + "@babel/types": "^7.16.0", + "babel-plugin-polyfill-corejs2": "^0.3.0", + "babel-plugin-polyfill-corejs3": "^0.4.0", + "babel-plugin-polyfill-regenerator": "^0.3.0", + "core-js-compat": "^3.19.1", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils/node_modules/@babel/preset-env/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils/node_modules/@babel/preset-react": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/preset-react/-/preset-react-7.16.7.tgz", + "integrity": "sha512-fWpyI8UM/HE6DfPBzD8LnhQ/OcH8AgTaqcqP2nGOXEUV+VKBR5JRN9hCk9ai+zQQ57vtm9oWeXguBCPNUjytgA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-validator-option": "^7.16.7", + "@babel/plugin-transform-react-display-name": "^7.16.7", + "@babel/plugin-transform-react-jsx": "^7.16.7", + "@babel/plugin-transform-react-jsx-development": "^7.16.7", + "@babel/plugin-transform-react-pure-annotations": "^7.16.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils/node_modules/@babel/runtime-corejs3": { + "version": "7.16.8", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.16.8.tgz", + "integrity": "sha512-3fKhuICS1lMz0plI5ktOE/yEtBRMVxplzRkdn6mJQ197XiY0JnrzYV0+Mxozq3JZ8SBV9Ecurmw1XsGbwOf+Sg==", + "dev": true, + "license": "MIT", + "dependencies": { + "core-js-pure": "^3.20.2", + "regenerator-runtime": "^0.13.4" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@mat3ra/esse/node_modules/@mat3ra/utils/node_modules/semver": { + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@mat3ra/esse/node_modules/babel-plugin-polyfill-corejs2": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz", + "integrity": "sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.17.7", + "@babel/helper-define-polyfill-provider": "^0.3.3", + "semver": "^6.1.1" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@mat3ra/esse/node_modules/babel-plugin-polyfill-corejs3": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.4.0.tgz", + "integrity": "sha512-YxFreYwUfglYKdLUGvIF2nJEsGwj+RhWSX/ije3D2vQPOXuyMLMtg/cCGMDpOA7Nd+MwlNdnGODbd2EwUZPlsw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-define-polyfill-provider": "^0.3.0", + "core-js-compat": "^3.18.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@mat3ra/esse/node_modules/babel-plugin-polyfill-regenerator": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.3.1.tgz", + "integrity": "sha512-Y2B06tvgHYt1x0yz17jGkGeeMr5FeKUu+ASJ+N6nB5lQ8Dapfg42i0OVrf8PNGJ3zKL4A23snMi1IRwrqqND7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-define-polyfill-provider": "^0.3.1" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@mat3ra/esse/node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/@mat3ra/esse/node_modules/complex.js": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/complex.js/-/complex.js-2.4.3.tgz", + "integrity": "sha512-UrQVSUur14tNX6tiP4y8T4w4FeJAX3bi2cIv0pu/DTLFNxoq7z2Yh83Vfzztj6Px3X/lubqQ9IrPp7Bpn6p4MQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/rawify" + } + }, + "node_modules/@mat3ra/esse/node_modules/fraction.js": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.4.tgz", + "integrity": "sha512-pwiTgt0Q7t+GHZA4yaLjObx4vXmmdcS0iSJ19o8d/goUGgItX9UZWKWNnLHehxviD8wU2IWRsnR8cD5+yOJP2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + }, + "funding": { + "type": "patreon", + "url": "https://github.com/sponsors/rawify" + } + }, + "node_modules/@mat3ra/esse/node_modules/mathjs": { + "version": "12.4.1", + "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-12.4.1.tgz", + "integrity": "sha512-welnW3khgwYjPYvECFHO+xkCxAx9IKIIPDDWPi8B5rKAvmgoEHnQX9slEmHKZTNaJiE+OS4qrJJcB4sfDn/4sw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.24.0", + "complex.js": "^2.1.1", + "decimal.js": "^10.4.3", + "escape-latex": "^1.2.0", + "fraction.js": "4.3.4", + "javascript-natural-sort": "^0.7.1", + "seedrandom": "^3.0.5", + "tiny-emitter": "^2.1.0", + "typed-function": "^4.1.1" + }, + "bin": { + "mathjs": "bin/cli.js" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@mat3ra/esse/node_modules/source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@mat3ra/esse/node_modules/typed-function": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/typed-function/-/typed-function-4.2.1.tgz", + "integrity": "sha512-EGjWssW7Tsk4DGfE+5yluuljS1OGYWiI1J6e8puZz9nTMM51Oug8CD5Zo4gWMsOhq5BI+1bF+rWTm4Vbj3ivRA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 18" + } + }, + "node_modules/@mat3ra/esse/node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/@mat3ra/made": { "version": "2025.7.15-0", "resolved": "https://registry.npmjs.org/@mat3ra/made/-/made-2025.7.15-0.tgz", diff --git a/package.json b/package.json index 94f2298..47d04df 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "lint:fix": "eslint --fix --cache src/js tests/js && prettier --write src/js tests/js", "transpile": "tsc -p tsconfig-transpile.json", "prettier": "prettier --check src/js tests/js", - "prepare": "husky install" + "prepare": "husky install", + "generate-mixins": "ts-node scripts/generate-mixins.ts" }, "repository": { "type": "git", @@ -52,7 +53,7 @@ "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/utils": "2025.9.20-0", "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#2f5206cb8db85af8c9af3d450a8dc551bb6b9b61", - "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#a91ed6431f436b52689a1aff82096f3f9d618654", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#c248a30803e421f6da33e8270602bd1571945fb6", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", diff --git a/scripts/generate-mixins.ts b/scripts/generate-mixins.ts new file mode 100644 index 0000000..0670b86 --- /dev/null +++ b/scripts/generate-mixins.ts @@ -0,0 +1,37 @@ +#!/usr/bin/env node + +/** + * Script to generate mixin properties from JSON schema + * + * This script generates mixin functions for property/holder, property/meta_holder, + * and property/proto_holder schemas automatically. + * + * Usage: + * npx ts-node scripts/generate-mixin-properties.ts + */ + +import generateSchemaMixin from "@mat3ra/code/dist/js/generateSchemaMixin"; +import allSchemas from "@mat3ra/esse/dist/js/schemas.json"; +import type { JSONSchema7 } from "json-schema"; + +/** + * Output file paths for each schema + */ +const OUTPUT_PATHS = { + "software/executable_properties": "src/js/generated/ExecutableSchemaMixin.ts", + "software/flavor_properties": "src/js/generated/FlavorSchemaMixin.ts", + "software/application_properties": "src/js/generated/ApplicationSchemaMixin.ts", + "software/template_properties": "src/js/generated/TemplateSchemaMixin.ts", +}; + +function main() { + // Type assertion to handle schema compatibility - the schemas from esse may have slightly different types + const result = generateSchemaMixin(allSchemas as JSONSchema7[], OUTPUT_PATHS); + + if (result.errorCount > 0) { + process.exit(1); + } +} + +// Run the script if it's executed directly +main(); diff --git a/src/js/ApplicationRegistry.ts b/src/js/ApplicationRegistry.ts index e1c8a74..5c04830 100644 --- a/src/js/ApplicationRegistry.ts +++ b/src/js/ApplicationRegistry.ts @@ -87,6 +87,7 @@ export default class ApplicationRegistry { const applicationConfig: ApplicationSchemaBase = { ...appData, + // @ts-ignore build: buildToUse, ...versionInfo, }; diff --git a/src/js/application.ts b/src/js/application.ts index 7a980d0..2f4ce54 100644 --- a/src/js/application.ts +++ b/src/js/application.ts @@ -5,7 +5,6 @@ import { type ApplicationMixin, type ApplicationStaticMixin, applicationMixin, - applicationStaticMixin, } from "./applicationMixin"; type Base = typeof NamedDefaultableInMemoryEntity & @@ -14,5 +13,4 @@ type Base = typeof NamedDefaultableInMemoryEntity & export default class Application extends (NamedDefaultableInMemoryEntity as Base) {} -applicationMixin(Application.prototype); -applicationStaticMixin(Application); +applicationMixin(Application); diff --git a/src/js/applicationMixin.ts b/src/js/applicationMixin.ts index f1c59bc..435304d 100644 --- a/src/js/applicationMixin.ts +++ b/src/js/applicationMixin.ts @@ -7,6 +7,10 @@ import type { ApplicationSchemaBase } from "@mat3ra/esse/dist/js/types"; import { ApplicationStandata } from "@mat3ra/standata"; import Executable from "./executable"; +import { + type ApplicationSchemaMixin, + applicationSchemaMixin, +} from "./generated/ApplicationSchemaMixin"; type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity; @@ -14,12 +18,7 @@ export type BaseConstructor = Constructor & { constructCustomExecutable?: (config: object) => Executable; }; -export type ApplicationConstructor = Constructor & ApplicationStaticMixin; - -export type ApplicationMixin = Pick< - ApplicationSchemaBase, - "summary" | "version" | "build" | "shortName" | "hasAdvancedComputeOptions" | "isLicensed" -> & { +export type ApplicationMixin = ApplicationSchemaMixin & { name: Required["name"]; isUsingMaterial: boolean; }; @@ -34,33 +33,13 @@ export type ApplicationStaticMixin = { jsonSchema: ApplicationSchemaBase; }; -export function applicationMixin(item: Base) { +function applicationPropertiesMixin( + item: T, +): asserts item is T & ApplicationMixin { + applicationSchemaMixin(item); + // @ts-expect-error const properties: ApplicationMixin & Base = { - 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); @@ -70,7 +49,7 @@ export function applicationMixin(item: Base) { Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); } -export function applicationStaticMixin(Application: T) { +function applicationStaticMixin(Application: T) { const properties: ApplicationStaticMixin = { get defaultConfig() { return new ApplicationStandata().getDefaultConfig(); @@ -84,3 +63,8 @@ export function applicationStaticMixin(Application: T Object.defineProperties(Application, Object.getOwnPropertyDescriptors(properties)); } + +export function applicationMixin(Item: BaseConstructor) { + applicationPropertiesMixin(Item.prototype); + applicationStaticMixin(Item); +} diff --git a/src/js/executable.ts b/src/js/executable.ts index fd0db93..c04b0b9 100644 --- a/src/js/executable.ts +++ b/src/js/executable.ts @@ -14,7 +14,7 @@ import { import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types"; -import { type ExecutableMixin, executableMixin, executableStaticMixin } from "./executableMixin"; +import { type ExecutableMixin, executableMixin } from "./executableMixin"; type Base = Constructor & Constructor & @@ -29,6 +29,7 @@ export default class Executable extends (InMemoryEntity as Base) { results: [], postProcessors: [], preProcessors: [], + applicationId: [], ...data, }); } @@ -36,7 +37,6 @@ export default class Executable extends (InMemoryEntity as Base) { // Apply mixins runtimeItemsStringMixin(Executable.prototype); -executableMixin(Executable.prototype); -executableStaticMixin(Executable); namedEntityMixin(Executable.prototype); defaultableEntityMixin(Executable); +executableMixin(Executable); diff --git a/src/js/executableMixin.ts b/src/js/executableMixin.ts index 3b5d6c5..e441c93 100644 --- a/src/js/executableMixin.ts +++ b/src/js/executableMixin.ts @@ -7,25 +7,12 @@ import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types"; import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types"; import type { FlavorMixin } from "./flavorMixin"; +import { ExecutableSchemaMixin, executableSchemaMixin } from "./generated/ExecutableSchemaMixin"; type BaseFlavor = FlavorMixin & NamedInMemoryEntity & InMemoryEntity; type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity; -export function executableMixin(item: Base) { - // @ts-expect-error - const properties: ExecutableMixin & Base = { - get applicationId() { - return this.prop("applicationId", []); - }, - set applicationId(value: string[]) { - this.setProp("applicationId", value); - }, - }; - - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} - -export function executableStaticMixin(Executable: Constructor) { +function executableStaticMixin(Executable: Constructor) { const properties: ExecutableStaticMixin = { get jsonSchema() { return JSONSchemasInterface.getSchemaById("software/executable") as ExecutableSchema; @@ -39,11 +26,15 @@ export type BaseConstructor = Constructor & { constructCustomFlavor?: (config: object) => BaseFlavor; }; -export type ExecutableMixin = { - applicationId: string[]; +export type ExecutableMixin = ExecutableSchemaMixin & { toJSON: () => ExecutableSchema & AnyObject; }; export type ExecutableStaticMixin = { jsonSchema: ExecutableSchema; }; + +export function executableMixin(Item: BaseConstructor) { + executableSchemaMixin(Item.prototype); + executableStaticMixin(Item); +} diff --git a/src/js/flavor.ts b/src/js/flavor.ts index 0746731..c7b9183 100644 --- a/src/js/flavor.ts +++ b/src/js/flavor.ts @@ -14,7 +14,7 @@ import { import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { FlavorSchema } from "@mat3ra/esse/dist/js/types"; -import { type FlavorMixin, flavorMixin, flavorStaticMixin } from "./flavorMixin"; +import { type FlavorMixin, flavorMixin } from "./flavorMixin"; type Base = typeof InMemoryEntity & Constructor & @@ -29,14 +29,16 @@ export default class Flavor extends (InMemoryEntity as Base) { results: [], postProcessors: [], preProcessors: [], + input: [], + executableId: "", + executableName: "", + applicationName: "", ...data, }); } } -// Apply mixins -flavorMixin(Flavor.prototype); runtimeItemsStringMixin(Flavor.prototype); namedEntityMixin(Flavor.prototype); defaultableEntityMixin(Flavor); -flavorStaticMixin(Flavor); +flavorMixin(Flavor); diff --git a/src/js/flavorMixin.ts b/src/js/flavorMixin.ts index d668a6f..34489b5 100644 --- a/src/js/flavorMixin.ts +++ b/src/js/flavorMixin.ts @@ -1,60 +1,31 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import type { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface"; import type { FlavorSchema } from "@mat3ra/esse/dist/js/types"; -type Base = InMemoryEntity & NamedInMemoryEntity; +import { type FlavorSchemaMixin, flavorSchemaMixin } from "./generated/FlavorSchemaMixin"; -type Input = Required["input"]; - -export type FlavorMixin = { - input: Input; - disableRenderMaterials: boolean; - executableId: string; - executableName: string; - applicationName: string; - supportedApplicationVersions?: string[]; - getInputAsRenderedTemplates: (context: Record) => Record[]; +export type FlavorMixin = FlavorSchemaMixin & { + // getInputAsRenderedTemplates: (context: Record) => Record[]; }; // TODO: should we add fields from esse schema (executableId, executableName, applicationName)? -export function flavorMixin(item: Base) { +function flavorPropertiesMixin(item: InMemoryEntity & FlavorSchemaMixin) { // @ts-expect-error - const properties: FlavorMixin & Base = { - get input() { - return this.prop("input", []); - }, - - get disableRenderMaterials() { - return this.prop("isMultiMaterial", false); - }, - - get executableId() { - return this.prop("executableId", ""); - }, - - get executableName() { - return this.prop("executableName", ""); - }, - - get applicationName() { - return this.prop("applicationName", ""); - }, - - get supportedApplicationVersions() { - return this.prop("supportedApplicationVersions"); - }, - - getInputAsRenderedTemplates(context: Record) { - const input = this.input; - return input.map((template) => { - if (template && typeof template === "object" && "getRenderedJSON" in template) { - return (template as any).getRenderedJSON(context); - } - return template; - }); - }, + const properties: FlavorMixin & InMemoryEntity & FlavorSchemaMixin = { + // TODO: there is no "isMultiMaterial" field in the schema; should we add it? + // get disableRenderMaterials() { + // return this.prop("isMultiMaterial", false); + // }, + // TODO: do we actually use this method anywhere? + // getInputAsRenderedTemplates(context: Record) { + // return this.input?.map((template) => { + // if (template && typeof template === "object" && "getRenderedJSON" in template) { + // return template.getRenderedJSON(context); + // } + // return template; + // }); + // }, }; Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); @@ -62,7 +33,7 @@ export function flavorMixin(item: Base) { return properties; } -export function flavorStaticMixin(Flavor: Constructor) { +function flavorStaticMixin(Flavor: Constructor) { const properties: FlavorStaticMixin = { get jsonSchema() { return JSONSchemasInterface.getSchemaById("software/flavor") as FlavorSchema; @@ -75,3 +46,9 @@ export function flavorStaticMixin(Flavor: Constructor) { export type FlavorStaticMixin = { jsonSchema: FlavorSchema; }; + +export function flavorMixin(Item: Constructor) { + flavorSchemaMixin(Item.prototype); + flavorPropertiesMixin(Item.prototype); + flavorStaticMixin(Item); +} diff --git a/src/js/generated/ApplicationSchemaMixin.ts b/src/js/generated/ApplicationSchemaMixin.ts new file mode 100644 index 0000000..d136674 --- /dev/null +++ b/src/js/generated/ApplicationSchemaMixin.ts @@ -0,0 +1,56 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { ApplicationPropertiesSchema } from "@mat3ra/esse/dist/js/types"; + +export type ApplicationSchemaMixin = ApplicationPropertiesSchema; + +export type ApplicationInMemoryEntity = InMemoryEntity & ApplicationSchemaMixin; + +export function applicationSchemaMixin( + item: InMemoryEntity, +): asserts item is T & ApplicationSchemaMixin { + // @ts-expect-error + const properties: InMemoryEntity & ApplicationSchemaMixin = { + get shortName() { + return this.requiredProp("shortName"); + }, + set shortName(value: ApplicationPropertiesSchema["shortName"]) { + this.setProp("shortName", value); + }, + get summary() { + return this.requiredProp("summary"); + }, + set summary(value: ApplicationPropertiesSchema["summary"]) { + this.setProp("summary", value); + }, + get version() { + return this.requiredProp("version"); + }, + set version(value: ApplicationPropertiesSchema["version"]) { + this.setProp("version", value); + }, + get build() { + return this.requiredProp("build"); + }, + set build(value: ApplicationPropertiesSchema["build"]) { + this.setProp("build", value); + }, + get hasAdvancedComputeOptions() { + return this.prop( + "hasAdvancedComputeOptions", + ); + }, + set hasAdvancedComputeOptions( + value: ApplicationPropertiesSchema["hasAdvancedComputeOptions"], + ) { + this.setProp("hasAdvancedComputeOptions", value); + }, + get isLicensed() { + return this.prop("isLicensed"); + }, + set isLicensed(value: ApplicationPropertiesSchema["isLicensed"]) { + this.setProp("isLicensed", value); + }, + }; + + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/src/js/generated/ExecutableSchemaMixin.ts b/src/js/generated/ExecutableSchemaMixin.ts new file mode 100644 index 0000000..80e554e --- /dev/null +++ b/src/js/generated/ExecutableSchemaMixin.ts @@ -0,0 +1,38 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { ExecutablePropertiesSchema } from "@mat3ra/esse/dist/js/types"; + +export type ExecutableSchemaMixin = ExecutablePropertiesSchema; + +export type ExecutableInMemoryEntity = InMemoryEntity & ExecutableSchemaMixin; + +export function executableSchemaMixin( + item: InMemoryEntity, +): asserts item is T & ExecutableSchemaMixin { + // @ts-expect-error + const properties: InMemoryEntity & ExecutableSchemaMixin = { + get name() { + return this.requiredProp("name"); + }, + set name(value: ExecutablePropertiesSchema["name"]) { + this.setProp("name", value); + }, + get applicationId() { + return this.requiredProp("applicationId"); + }, + set applicationId(value: ExecutablePropertiesSchema["applicationId"]) { + this.setProp("applicationId", value); + }, + get hasAdvancedComputeOptions() { + return this.prop( + "hasAdvancedComputeOptions", + ); + }, + set hasAdvancedComputeOptions( + value: ExecutablePropertiesSchema["hasAdvancedComputeOptions"], + ) { + this.setProp("hasAdvancedComputeOptions", value); + }, + }; + + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/src/js/generated/FlavorSchemaMixin.ts b/src/js/generated/FlavorSchemaMixin.ts new file mode 100644 index 0000000..024cb69 --- /dev/null +++ b/src/js/generated/FlavorSchemaMixin.ts @@ -0,0 +1,50 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { FlavorPropertiesSchema } from "@mat3ra/esse/dist/js/types"; + +export type FlavorSchemaMixin = FlavorPropertiesSchema; + +export type FlavorInMemoryEntity = InMemoryEntity & FlavorSchemaMixin; + +export function flavorSchemaMixin( + item: InMemoryEntity, +): asserts item is T & FlavorSchemaMixin { + // @ts-expect-error + const properties: InMemoryEntity & FlavorSchemaMixin = { + get executableId() { + return this.requiredProp("executableId"); + }, + set executableId(value: FlavorPropertiesSchema["executableId"]) { + this.setProp("executableId", value); + }, + get executableName() { + return this.prop("executableName"); + }, + set executableName(value: FlavorPropertiesSchema["executableName"]) { + this.setProp("executableName", value); + }, + get applicationName() { + return this.prop("applicationName"); + }, + set applicationName(value: FlavorPropertiesSchema["applicationName"]) { + this.setProp("applicationName", value); + }, + get input() { + return this.requiredProp("input"); + }, + set input(value: FlavorPropertiesSchema["input"]) { + this.setProp("input", value); + }, + get supportedApplicationVersions() { + return this.prop( + "supportedApplicationVersions", + ); + }, + set supportedApplicationVersions( + value: FlavorPropertiesSchema["supportedApplicationVersions"], + ) { + this.setProp("supportedApplicationVersions", value); + }, + }; + + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/src/js/generated/TemplateSchemaMixin.ts b/src/js/generated/TemplateSchemaMixin.ts new file mode 100644 index 0000000..7fa58fe --- /dev/null +++ b/src/js/generated/TemplateSchemaMixin.ts @@ -0,0 +1,68 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { TemplatePropertiesSchema } from "@mat3ra/esse/dist/js/types"; + +export type TemplateSchemaMixin = TemplatePropertiesSchema; + +export type TemplateInMemoryEntity = InMemoryEntity & TemplateSchemaMixin; + +export function templateSchemaMixin( + item: InMemoryEntity, +): asserts item is T & TemplateSchemaMixin { + // @ts-expect-error + const properties: InMemoryEntity & TemplateSchemaMixin = { + get applicationName() { + return this.requiredProp( + "applicationName", + ); + }, + set applicationName(value: TemplatePropertiesSchema["applicationName"]) { + this.setProp("applicationName", value); + }, + get applicationVersion() { + return this.prop("applicationVersion"); + }, + set applicationVersion(value: TemplatePropertiesSchema["applicationVersion"]) { + this.setProp("applicationVersion", value); + }, + get executableName() { + return this.requiredProp("executableName"); + }, + set executableName(value: TemplatePropertiesSchema["executableName"]) { + this.setProp("executableName", value); + }, + get contextProviders() { + return this.requiredProp( + "contextProviders", + ); + }, + set contextProviders(value: TemplatePropertiesSchema["contextProviders"]) { + this.setProp("contextProviders", value); + }, + get isManuallyChanged() { + return this.prop("isManuallyChanged"); + }, + set isManuallyChanged(value: TemplatePropertiesSchema["isManuallyChanged"]) { + this.setProp("isManuallyChanged", value); + }, + get name() { + return this.requiredProp("name"); + }, + set name(value: TemplatePropertiesSchema["name"]) { + this.setProp("name", value); + }, + get content() { + return this.requiredProp("content"); + }, + set content(value: TemplatePropertiesSchema["content"]) { + this.setProp("content", value); + }, + get rendered() { + return this.prop("rendered"); + }, + set rendered(value: TemplatePropertiesSchema["rendered"]) { + this.setProp("rendered", value); + }, + }; + + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/src/js/index.ts b/src/js/index.ts index 0f9f5b2..fe63c05 100644 --- a/src/js/index.ts +++ b/src/js/index.ts @@ -1,5 +1,5 @@ import Application from "./application"; -import { applicationMixin, applicationStaticMixin } from "./applicationMixin"; +import { applicationMixin } from "./applicationMixin"; import ApplicationRegistry from "./ApplicationRegistry"; import ContextProvider from "./context/ContextProvider"; import JSONSchemaFormDataProvider from "./context/JSONSchemaFormDataProvider"; @@ -8,7 +8,7 @@ import { executableMixin } from "./executableMixin"; import Flavor from "./flavor"; import { flavorMixin } from "./flavorMixin"; import Template from "./template"; -import { templateMixin, templateStaticMixin } from "./templateMixin"; +import { templateMixin } from "./templateMixin"; const allApplications = ApplicationRegistry.getUniqueAvailableApplicationNames(); @@ -23,8 +23,6 @@ export { executableMixin, flavorMixin, applicationMixin, - applicationStaticMixin, templateMixin, - templateStaticMixin, allApplications, }; diff --git a/src/js/template.ts b/src/js/template.ts index ab2af9c..0907e82 100644 --- a/src/js/template.ts +++ b/src/js/template.ts @@ -1,17 +1,29 @@ -import { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import { + type NamedInMemoryEntity, + namedEntityMixin, +} from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { TemplateSchema } from "@mat3ra/esse/dist/js/types"; -import { - type TemplateMixin, - type TemplateStaticMixin, - templateMixin, - templateStaticMixin, -} from "./templateMixin"; +import { type TemplateMixin, type TemplateStaticMixin, templateMixin } from "./templateMixin"; -type Base = typeof NamedInMemoryEntity & Constructor & TemplateStaticMixin; +type Base = typeof InMemoryEntity & + Constructor & + Constructor & + TemplateStaticMixin; -export default class Template extends (NamedInMemoryEntity as Base) {} +export default class Template extends (InMemoryEntity as Base) { + constructor(data: Partial = {}) { + super({ + applicationName: "", + executableName: "", + content: "", + contextProviders: [], + ...data, + }); + } +} -// Apply mixins -templateMixin(Template.prototype); -templateStaticMixin(Template); +namedEntityMixin(Template.prototype); +templateMixin(Template); diff --git a/src/js/templateMixin.ts b/src/js/templateMixin.ts index 4d74880..9cb3a20 100644 --- a/src/js/templateMixin.ts +++ b/src/js/templateMixin.ts @@ -1,10 +1,9 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import type { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; -import { Utils } from "@mat3ra/utils"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface"; import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types"; import type { TemplateSchema } from "@mat3ra/esse/dist/js/types"; +import { Utils } from "@mat3ra/utils"; import nunjucks from "nunjucks"; import ContextProvider, { @@ -12,18 +11,13 @@ import ContextProvider, { type ContextProviderName, } from "./context/ContextProvider"; import ContextProviderRegistryContainer from "./context/ContextProviderRegistryContainer"; +import { type TemplateSchemaMixin, templateSchemaMixin } from "./generated/TemplateSchemaMixin"; -export type TemplateBase = InMemoryEntity & NamedInMemoryEntity; - -export type TemplateMixin = { - isManuallyChanged: boolean; - content: string; - rendered: string | undefined; - applicationName: string | undefined; - executableName: string | undefined; - contextProviders: ContextProvider[]; - addContextProvider: (provider: ContextProvider) => void; - removeContextProvider: (provider: ContextProvider) => void; +export type TemplateBase = InMemoryEntity; + +export type TemplateMixin = TemplateSchemaMixin & { + // addContextProvider: (provider: ContextProvider) => void; + // removeContextProvider: (provider: ContextProvider) => void; render: (externalContext?: Record) => void; getRenderedJSON: (context?: Record) => AnyObject; _cleanRenderingContext: (object: Record) => Record; @@ -41,52 +35,46 @@ export type TemplateMixin = { getRenderingContext: (externalContext?: Record) => Record; }; -export function templateMixin(item: TemplateBase) { - // @ts-ignore - const properties: TemplateMixin & TemplateBase = { - get isManuallyChanged() { - return this.prop("isManuallyChanged", false); - }, +export type ContextProviderConfigMapEntry = { + providerCls: typeof ContextProvider; + config: ContextProviderConfig; +}; - get content() { - return this.prop("content", ""); - }, +export type ContextProviderConfigMap = Partial< + Record +>; - setContent(text: string) { - return this.setProp("content", text); - }, +export type TemplateStaticMixin = { + contextProviderRegistry: ContextProviderRegistryContainer | null; + setContextProvidersConfig: (classConfigMap: ContextProviderConfigMap) => void; + jsonSchema: TemplateSchema; +}; - get rendered() { - return this.prop("rendered") || this.content; +function templatePropertiesMixin(item: InMemoryEntity) { + // @ts-expect-error + const properties: TemplateMixin & TemplateBase = { + setContent(text: string) { + this.content = text; + if (!this.rendered) { + this.rendered = text; + } }, setRendered(text: string) { - return this.setProp("rendered", text); - }, - - get applicationName() { - return this.prop("applicationName"); + this.rendered = text; }, - get executableName() { - return this.prop("executableName"); - }, + // addContextProvider(provider: ContextProvider) { + // this.setProp("contextProviders", [...this.contextProviders, provider]); + // }, - get contextProviders() { - return this.prop("contextProviders", []); - }, + // removeContextProvider(provider: ContextProvider) { + // const contextProviders = this.contextProviders.filter((p) => { + // return p.name !== provider.name && p.domain !== provider.domain; + // }); - addContextProvider(provider: ContextProvider) { - this.setProp("contextProviders", [...this.contextProviders, provider]); - }, - - removeContextProvider(provider: ContextProvider) { - const contextProviders = this.contextProviders.filter((p) => { - return p.name !== provider.name && p.domain !== provider.domain; - }); - - this.setProp("contextProviders", contextProviders); - }, + // this.setProp("contextProviders", contextProviders); + // }, render(externalContext?: Record) { const renderingContext = this.getRenderingContext(externalContext); @@ -194,28 +182,11 @@ export function templateMixin(item: TemplateBase) { }; Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); - - return properties; } -export type ContextProviderConfigMapEntry = { - providerCls: typeof ContextProvider; - config: ContextProviderConfig; -}; - -export type ContextProviderConfigMap = Partial< - Record ->; - -export type TemplateStaticMixin = { - contextProviderRegistry: ContextProviderRegistryContainer | null; - setContextProvidersConfig: (classConfigMap: ContextProviderConfigMap) => void; - jsonSchema: TemplateSchema; -}; - -export function templateStaticMixin(item: Constructor) { +function templateStaticMixin(item: Constructor) { // @ts-ignore - const properties: TemplateStaticMixin & Constructor = { + const properties: TemplateStaticMixin & Constructor = { contextProviderRegistry: null, get jsonSchema() { @@ -237,6 +208,10 @@ export function templateStaticMixin(item: Constructor) { + templateSchemaMixin(Item.prototype); + templatePropertiesMixin(Item.prototype); + templateStaticMixin(Item); } diff --git a/src/js/types.ts b/src/js/types.ts index 267ca35..1205631 100644 --- a/src/js/types.ts +++ b/src/js/types.ts @@ -2,7 +2,7 @@ import { ApplicationMixin, ApplicationStaticMixin } from "./applicationMixin"; import { CreateApplicationConfig } from "./ApplicationRegistry"; import { ExecutableMixin } from "./executableMixin"; import { FlavorMixin } from "./flavorMixin"; -import { TemplateMixin, TemplateStaticMixin } from "./templateMixin"; +import { TemplateMixin } from "./templateMixin"; export type { FlavorMixin, @@ -11,5 +11,4 @@ export type { ApplicationStaticMixin, CreateApplicationConfig, TemplateMixin, - TemplateStaticMixin, }; diff --git a/tests/js/ApplicationRegistry.test.ts b/tests/js/ApplicationRegistry.test.ts index 0fd4a63..b2ae47d 100644 --- a/tests/js/ApplicationRegistry.test.ts +++ b/tests/js/ApplicationRegistry.test.ts @@ -349,7 +349,12 @@ describe("ApplicationRegistry", () => { }); it("should handle flavor with no input", () => { - const templates = ApplicationRegistry.getInputAsTemplates(new Flavor()); + const templates = ApplicationRegistry.getInputAsTemplates( + new Flavor({ + executableId: "espresso_pw", + input: [], + }), + ); expect(templates).to.be.an("array"); expect(templates.length).to.equal(0); @@ -358,6 +363,7 @@ describe("ApplicationRegistry", () => { it("should handle input with templateName", () => { const templates = ApplicationRegistry.getInputAsTemplates( new Flavor({ + executableId: "espresso_pw", applicationName: "espresso", executableName: "pw", input: [{ name: "input", templateName: "test_template" }], diff --git a/tests/js/JSONSchemaFormDataProvider.test.ts b/tests/js/JSONSchemaFormDataProvider.test.ts new file mode 100644 index 0000000..2092850 --- /dev/null +++ b/tests/js/JSONSchemaFormDataProvider.test.ts @@ -0,0 +1,68 @@ +import { expect } from "chai"; + +import { ContextProviderName } from "../../src/js/context/ContextProvider"; +import JSONSchemaFormDataProvider from "../../src/js/context/JSONSchemaFormDataProvider"; + +describe("JSONSchemaFormDataProvider", () => { + const baseConfig = { + name: ContextProviderName.KGridFormDataManager, + }; + + it("respects isUsingJinjaVariables flag", () => { + const providerTrue = new JSONSchemaFormDataProvider({ + ...baseConfig, + isUsingJinjaVariables: true, + }); + const providerFalse = new JSONSchemaFormDataProvider({ + ...baseConfig, + isUsingJinjaVariables: false, + }); + const providerUndefined = new JSONSchemaFormDataProvider(baseConfig); + + expect(providerTrue.isUsingJinjaVariables).to.equal(true); + expect(providerFalse.isUsingJinjaVariables).to.equal(false); + expect(providerUndefined.isUsingJinjaVariables).to.equal(false); + }); + + it("returns styled uiSchema from uiSchemaStyled", () => { + const provider = new JSONSchemaFormDataProvider(baseConfig); + + // Monkey-patch abstract getters to avoid "Not implemented." errors + Object.defineProperty(provider, "uiSchema", { + get() { + return { + field1: { + "ui:widget": "text", + classNames: "original-class", + }, + field2: { + "ui:widget": "number", + }, + }; + }, + }); + + Object.defineProperty(provider, "defaultFieldStyles", { + get() { + return { + "ui:options": { + label: true, + }, + }; + }, + }); + + const styled = provider.uiSchemaStyled; + + expect(styled).to.have.property("field1"); + expect(styled).to.have.property("field2"); + + expect(styled.field1["ui:widget"]).to.equal("text"); + expect(styled.field1["ui:options"]).to.deep.equal({ label: true }); + expect(styled.field1.classNames).to.equal("original-class"); + + expect(styled.field2["ui:widget"]).to.equal("number"); + expect(styled.field2["ui:options"]).to.deep.equal({ label: true }); + expect(styled.field2.classNames).to.equal(""); + }); +}); diff --git a/tests/js/application.test.ts b/tests/js/application.test.ts index ea6222f..e36d1af 100644 --- a/tests/js/application.test.ts +++ b/tests/js/application.test.ts @@ -19,59 +19,11 @@ describe("Application", () => { app = new Application(obj); }); - describe("summary property", () => { - it("should return summary when set", () => { - app.setProp("summary", "Test summary"); - expect(app.summary).to.equal("Test summary"); - }); - - it("should return undefined when summary is not set", () => { - expect(app.summary).to.be.undefined; - }); - }); - - describe("version property", () => { - it("should return version when set", () => { - app.setProp("version", "1.2.3"); - expect(app.version).to.equal("1.2.3"); - }); - - it("should return empty string as default when version is not set", () => { - expect(app.version).to.equal(""); - }); - }); - - describe("build property", () => { - it("should return build when set", () => { - app.setProp("build", "debug"); - expect(app.build).to.equal("debug"); - }); - - it("should return undefined when build is not set", () => { - expect(app.build).to.be.undefined; - }); - }); - - describe("shortName property", () => { - it("should return shortName when set", () => { - app.setProp("shortName", "qe"); - expect(app.shortName).to.equal("qe"); - }); - - it("should return name as default when shortName is not set", () => { - expect(app.shortName).to.equal("espresso"); - }); - }); - describe("hasAdvancedComputeOptions property", () => { it("should return true when set", () => { app.setProp("hasAdvancedComputeOptions", true); expect(app.hasAdvancedComputeOptions).to.be.true; }); - - it("should return false as default when not set", () => { - expect(app.hasAdvancedComputeOptions).to.be.false; - }); }); describe("isLicensed property", () => { @@ -79,10 +31,6 @@ describe("Application", () => { app.setProp("isLicensed", true); expect(app.isLicensed).to.be.true; }); - - it("should return false as default when not set", () => { - expect(app.isLicensed).to.be.false; - }); }); describe("isUsingMaterial property", () => { diff --git a/tests/js/flavor.test.ts b/tests/js/flavor.test.ts index ee12ecd..01a22f3 100644 --- a/tests/js/flavor.test.ts +++ b/tests/js/flavor.test.ts @@ -38,15 +38,6 @@ describe("Flavor", () => { expect(flavor.input).to.deep.equal(input); }); - it("should have disableRenderMaterials as false by default", () => { - expect(flavor.disableRenderMaterials).to.be.false; - }); - - it("should return disableRenderMaterials as true when isMultiMaterial is set", () => { - flavor.setProp("isMultiMaterial", true); - expect(flavor.disableRenderMaterials).to.be.true; - }); - it("should have executableId as empty string by default", () => { expect(flavor.executableId).to.equal(""); }); @@ -84,16 +75,16 @@ describe("Flavor", () => { }); // Added with LLM to help with coverage - it("should handle getInputAsRenderedTemplates with different template types", () => { - const mockTemplate = { getRenderedJSON: () => ({ rendered: true }) }; - const simpleTemplate = { name: "simple" }; - flavor.setProp("input", [mockTemplate, simpleTemplate]); - - const result = flavor.getInputAsRenderedTemplates({}); - expect(result).to.have.length(2); - expect(result[0]).to.deep.equal({ rendered: true }); - expect(result[1]).to.deep.equal({ name: "simple" }); - }); + // it("should handle getInputAsRenderedTemplates with different template types", () => { + // const mockTemplate = { getRenderedJSON: () => ({ rendered: true }) }; + // const simpleTemplate = { name: "simple" }; + // flavor.setProp("input", [mockTemplate, simpleTemplate]); + + // const result = flavor.getInputAsRenderedTemplates({}); + // expect(result).to.have.length(2); + // expect(result[0]).to.deep.equal({ rendered: true }); + // expect(result[1]).to.deep.equal({ name: "simple" }); + // }); }); describe("flavorStaticMixin", () => { diff --git a/tests/js/template.test.ts b/tests/js/template.test.ts index 33bdb61..68b04e7 100644 --- a/tests/js/template.test.ts +++ b/tests/js/template.test.ts @@ -121,17 +121,6 @@ describe("Template", () => { }); describe("templateMixin properties", () => { - describe("isManuallyChanged property", () => { - it("should return false by default", () => { - expect(template.isManuallyChanged).to.be.false; - }); - - it("should return true when set", () => { - template.setProp("isManuallyChanged", true); - expect(template.isManuallyChanged).to.be.true; - }); - }); - describe("content property", () => { it("should return empty string by default", () => { expect(template.content).to.equal(""); @@ -167,8 +156,8 @@ describe("Template", () => { }); describe("applicationName property", () => { - it("should return undefined by default", () => { - expect(template.applicationName).to.be.undefined; + it("should return empty string by default", () => { + expect(template.applicationName).to.equal(""); }); it("should return applicationName when set", () => { @@ -178,8 +167,8 @@ describe("Template", () => { }); describe("executableName property", () => { - it("should return undefined by default", () => { - expect(template.executableName).to.be.undefined; + it("should return empty string by default", () => { + expect(template.executableName).to.equal(""); }); it("should return executableName when set", () => { @@ -200,35 +189,35 @@ describe("Template", () => { }); }); - describe("addContextProvider method", () => { - it("should add a context provider", () => { - const provider = new MockContextProvider({ - name: "QGridFormDataManager", - domain: "test", - }); - const initialLength = template.contextProviders.length; - template.addContextProvider(provider); - // The method sets the new length, so we check that it increased - expect(template.contextProviders.length).to.be.greaterThan(initialLength); - }); - }); - - describe("removeContextProvider method", () => { - it("should remove a context provider by name and domain", () => { - const provider1 = new MockContextProvider({ - name: "QGridFormDataManager", - domain: "domain1", - }); - const provider2 = new MockContextProvider({ - name: "PlanewaveCutoffDataManager", - domain: "domain2", - }); - template.setProp("contextProviders", [provider1, provider2]); - - template.removeContextProvider(provider1); - expect(template.contextProviders).to.deep.equal([provider2]); - }); - }); + // describe("addContextProvider method", () => { + // it("should add a context provider", () => { + // const provider = new MockContextProvider({ + // name: "QGridFormDataManager", + // domain: "test", + // }); + // const initialLength = template.contextProviders.length; + // template.addContextProvider(provider); + // // The method sets the new length, so we check that it increased + // expect(template.contextProviders.length).to.be.greaterThan(initialLength); + // }); + // }); + + // describe("removeContextProvider method", () => { + // it("should remove a context provider by name and domain", () => { + // const provider1 = new MockContextProvider({ + // name: "QGridFormDataManager", + // domain: "domain1", + // }); + // const provider2 = new MockContextProvider({ + // name: "PlanewaveCutoffDataManager", + // domain: "domain2", + // }); + // template.setProp("contextProviders", [provider1, provider2]); + + // template.removeContextProvider(provider1); + // expect(template.contextProviders).to.deep.equal([provider2]); + // }); + // }); describe("_cleanRenderingContext method", () => { it("should remove job property and deep clone the object", () => { @@ -316,15 +305,24 @@ describe("Template", () => { // Added with LLM to help with coverage it("should handle getDataFromProvidersForPersistentContext with edited providers", () => { - const editedProvider = new MockContextProvider({ name: "QGridFormDataManager", domain: "test" }); + const editedProvider = new MockContextProvider({ + name: "QGridFormDataManager", + domain: "test", + }); editedProvider.isEdited = true; editedProvider.yieldData = () => ({ data: { value: 1 } }); - const nonEditedProvider = new MockContextProvider({ name: "PlanewaveCutoffDataManager", domain: "test" }); + const nonEditedProvider = new MockContextProvider({ + name: "PlanewaveCutoffDataManager", + domain: "test", + }); nonEditedProvider.isEdited = false; nonEditedProvider.yieldData = () => ({ data: { value: 2 } }); - template.getContextProvidersAsClassInstances = () => [editedProvider, nonEditedProvider]; + template.getContextProvidersAsClassInstances = () => [ + editedProvider, + nonEditedProvider, + ]; const result = template.getDataFromProvidersForPersistentContext(); expect(result).to.deep.equal({ data: { value: 1 } }); }); From fa0212460146e35a7db50fb5b364e40cf869c692 Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Thu, 27 Nov 2025 01:52:39 +0200 Subject: [PATCH 03/16] update: add mixin generation (dist) --- dist/js/generated/ApplicationMixin.d.ts | 5 --- dist/js/generated/ApplicationMixin.js | 45 ------------------- dist/js/generated/ExecutableMixin.d.ts | 5 --- dist/js/generated/ExecutableMixin.js | 27 ------------ dist/js/generated/FlavorMixin.d.ts | 5 --- dist/js/generated/FlavorMixin.js | 39 ----------------- dist/js/generated/TemplateMixin.d.ts | 5 --- dist/js/generated/TemplateMixin.js | 57 ------------------------- 8 files changed, 188 deletions(-) delete mode 100644 dist/js/generated/ApplicationMixin.d.ts delete mode 100644 dist/js/generated/ApplicationMixin.js delete mode 100644 dist/js/generated/ExecutableMixin.d.ts delete mode 100644 dist/js/generated/ExecutableMixin.js delete mode 100644 dist/js/generated/FlavorMixin.d.ts delete mode 100644 dist/js/generated/FlavorMixin.js delete mode 100644 dist/js/generated/TemplateMixin.d.ts delete mode 100644 dist/js/generated/TemplateMixin.js diff --git a/dist/js/generated/ApplicationMixin.d.ts b/dist/js/generated/ApplicationMixin.d.ts deleted file mode 100644 index 27024b9..0000000 --- a/dist/js/generated/ApplicationMixin.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import type { ApplicationMixinSchema } from "@mat3ra/esse/dist/js/types"; -export type ApplicationMixin = ApplicationMixinSchema; -export type ApplicationMixin = InMemoryEntity & ApplicationMixin; -export declare function applicationMixin(item: InMemoryEntity): asserts item is T & ApplicationMixin; diff --git a/dist/js/generated/ApplicationMixin.js b/dist/js/generated/ApplicationMixin.js deleted file mode 100644 index 2510ffb..0000000 --- a/dist/js/generated/ApplicationMixin.js +++ /dev/null @@ -1,45 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.applicationMixin = applicationMixin; -function applicationMixin(item) { - // @ts-expect-error - const properties = { - get shortName() { - return this.prop("shortName"); - }, - set shortName(value) { - this.setProp("shortName", value); - }, - get summary() { - return this.prop("summary"); - }, - set summary(value) { - this.setProp("summary", value); - }, - get version() { - return this.prop("version"); - }, - set version(value) { - this.setProp("version", value); - }, - get build() { - return this.prop("build"); - }, - set build(value) { - this.setProp("build", value); - }, - get hasAdvancedComputeOptions() { - return this.prop("hasAdvancedComputeOptions"); - }, - set hasAdvancedComputeOptions(value) { - this.setProp("hasAdvancedComputeOptions", value); - }, - get isLicensed() { - return this.prop("isLicensed"); - }, - set isLicensed(value) { - this.setProp("isLicensed", value); - }, - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} diff --git a/dist/js/generated/ExecutableMixin.d.ts b/dist/js/generated/ExecutableMixin.d.ts deleted file mode 100644 index d720eb1..0000000 --- a/dist/js/generated/ExecutableMixin.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import type { ExecutableMixinSchema } from "@mat3ra/esse/dist/js/types"; -export type ExecutableMixin = ExecutableMixinSchema; -export type ExecutableMixin = InMemoryEntity & ExecutableMixin; -export declare function executableMixin(item: InMemoryEntity): asserts item is T & ExecutableMixin; diff --git a/dist/js/generated/ExecutableMixin.js b/dist/js/generated/ExecutableMixin.js deleted file mode 100644 index ce15d0e..0000000 --- a/dist/js/generated/ExecutableMixin.js +++ /dev/null @@ -1,27 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.executableMixin = executableMixin; -function executableMixin(item) { - // @ts-expect-error - const properties = { - get name() { - return this.requiredProp("name"); - }, - set name(value) { - this.setProp("name", value); - }, - get applicationId() { - return this.prop("applicationId"); - }, - set applicationId(value) { - this.setProp("applicationId", value); - }, - get hasAdvancedComputeOptions() { - return this.prop("hasAdvancedComputeOptions"); - }, - set hasAdvancedComputeOptions(value) { - this.setProp("hasAdvancedComputeOptions", value); - }, - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} diff --git a/dist/js/generated/FlavorMixin.d.ts b/dist/js/generated/FlavorMixin.d.ts deleted file mode 100644 index 3ff6703..0000000 --- a/dist/js/generated/FlavorMixin.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import type { FlavorMixinSchema } from "@mat3ra/esse/dist/js/types"; -export type FlavorMixin = FlavorMixinSchema; -export type FlavorMixin = InMemoryEntity & FlavorMixin; -export declare function flavorMixin(item: InMemoryEntity): asserts item is T & FlavorMixin; diff --git a/dist/js/generated/FlavorMixin.js b/dist/js/generated/FlavorMixin.js deleted file mode 100644 index 1bead61..0000000 --- a/dist/js/generated/FlavorMixin.js +++ /dev/null @@ -1,39 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.flavorMixin = flavorMixin; -function flavorMixin(item) { - // @ts-expect-error - const properties = { - get executableId() { - return this.prop("executableId"); - }, - set executableId(value) { - this.setProp("executableId", value); - }, - get executableName() { - return this.prop("executableName"); - }, - set executableName(value) { - this.setProp("executableName", value); - }, - get applicationName() { - return this.prop("applicationName"); - }, - set applicationName(value) { - this.setProp("applicationName", value); - }, - get input() { - return this.prop("input"); - }, - set input(value) { - this.setProp("input", value); - }, - get supportedApplicationVersions() { - return this.prop("supportedApplicationVersions"); - }, - set supportedApplicationVersions(value) { - this.setProp("supportedApplicationVersions", value); - }, - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} diff --git a/dist/js/generated/TemplateMixin.d.ts b/dist/js/generated/TemplateMixin.d.ts deleted file mode 100644 index 7a53e08..0000000 --- a/dist/js/generated/TemplateMixin.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import type { TemplateMixinSchema } from "@mat3ra/esse/dist/js/types"; -export type TemplateMixin = TemplateMixinSchema; -export type TemplateMixin = InMemoryEntity & TemplateMixin; -export declare function templateMixin(item: InMemoryEntity): asserts item is T & TemplateMixin; diff --git a/dist/js/generated/TemplateMixin.js b/dist/js/generated/TemplateMixin.js deleted file mode 100644 index 7cb1302..0000000 --- a/dist/js/generated/TemplateMixin.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.templateMixin = templateMixin; -function templateMixin(item) { - // @ts-expect-error - const properties = { - get applicationName() { - return this.prop("applicationName"); - }, - set applicationName(value) { - this.setProp("applicationName", value); - }, - get applicationVersion() { - return this.prop("applicationVersion"); - }, - set applicationVersion(value) { - this.setProp("applicationVersion", value); - }, - get executableName() { - return this.prop("executableName"); - }, - set executableName(value) { - this.setProp("executableName", value); - }, - get contextProviders() { - return this.prop("contextProviders"); - }, - set contextProviders(value) { - this.setProp("contextProviders", value); - }, - get isManuallyChanged() { - return this.prop("isManuallyChanged"); - }, - set isManuallyChanged(value) { - this.setProp("isManuallyChanged", value); - }, - get name() { - return this.requiredProp("name"); - }, - set name(value) { - this.setProp("name", value); - }, - get content() { - return this.requiredProp("content"); - }, - set content(value) { - this.setProp("content", value); - }, - get rendered() { - return this.prop("rendered"); - }, - set rendered(value) { - this.setProp("rendered", value); - }, - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} From e85c8b7c72b2dd205cf1bee359f9b9e9a1944ef0 Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Thu, 27 Nov 2025 16:17:31 +0200 Subject: [PATCH 04/16] chore: rentime_items --- dist/js/ApplicationRegistry.js | 1 + dist/js/applicationMixin.d.ts | 4 ++-- dist/js/applicationMixin.js | 2 +- dist/js/executable.d.ts | 6 +++--- dist/js/executable.js | 5 ++--- dist/js/executableMixin.d.ts | 6 +++--- dist/js/flavor.d.ts | 6 +++--- dist/js/flavor.js | 4 ++-- dist/js/template.d.ts | 4 ++-- package-lock.json | 12 ++++++------ package.json | 4 ++-- scripts/generate-mixins.ts | 8 ++++---- src/js/ApplicationRegistry.ts | 2 ++ src/js/applicationMixin.ts | 7 +++---- src/js/executable.ts | 15 +++++++-------- src/js/executableMixin.ts | 26 +++++++++++++------------- src/js/flavor.ts | 14 +++++++------- src/js/template.ts | 4 ++-- tests/js/executable.test.ts | 2 ++ 19 files changed, 67 insertions(+), 65 deletions(-) diff --git a/dist/js/ApplicationRegistry.js b/dist/js/ApplicationRegistry.js index 989d3d4..ce33342 100644 --- a/dist/js/ApplicationRegistry.js +++ b/dist/js/ApplicationRegistry.js @@ -119,6 +119,7 @@ class ApplicationRegistry { } static getExecutableByName(appName, execName) { const appTree = new standata_1.ApplicationStandata().getAppTreeForApplication(appName); + console.log("================", appTree); Object.entries(appTree).forEach(([name, exec]) => { exec.name = name; }); diff --git a/dist/js/applicationMixin.d.ts b/dist/js/applicationMixin.d.ts index 3334cc6..b4ecbc0 100644 --- a/dist/js/applicationMixin.d.ts +++ b/dist/js/applicationMixin.d.ts @@ -1,11 +1,11 @@ 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 { 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"; import { type ApplicationSchemaMixin } from "./generated/ApplicationSchemaMixin"; -type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity; +type Base = InMemoryEntity & NamedEntity & DefaultableInMemoryEntity; export type BaseConstructor = Constructor & { constructCustomExecutable?: (config: object) => Executable; }; diff --git a/dist/js/applicationMixin.js b/dist/js/applicationMixin.js index 4ddadc7..11ed596 100644 --- a/dist/js/applicationMixin.js +++ b/dist/js/applicationMixin.js @@ -8,7 +8,6 @@ const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/ess const standata_1 = require("@mat3ra/standata"); const ApplicationSchemaMixin_1 = require("./generated/ApplicationSchemaMixin"); function applicationPropertiesMixin(item) { - (0, ApplicationSchemaMixin_1.applicationSchemaMixin)(item); // @ts-expect-error const properties = { get isUsingMaterial() { @@ -30,6 +29,7 @@ function applicationStaticMixin(Application) { Object.defineProperties(Application, Object.getOwnPropertyDescriptors(properties)); } function applicationMixin(Item) { + (0, ApplicationSchemaMixin_1.applicationSchemaMixin)(Item.prototype); applicationPropertiesMixin(Item.prototype); applicationStaticMixin(Item); } diff --git a/dist/js/executable.d.ts b/dist/js/executable.d.ts index f8194aa..7aac21f 100644 --- a/dist/js/executable.d.ts +++ b/dist/js/executable.d.ts @@ -1,11 +1,11 @@ import { 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 RuntimeItemsStringInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsStringMixin"; +import { type NamedEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; +import { type RuntimeItems } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types"; import { type ExecutableMixin } from "./executableMixin"; -type Base = Constructor & Constructor & Constructor & Constructor & typeof InMemoryEntity; +type Base = Constructor & Constructor & Constructor & Constructor & typeof InMemoryEntity; declare const Executable_base: Base; export default class Executable extends Executable_base { constructor(data?: Partial); diff --git a/dist/js/executable.js b/dist/js/executable.js index e31e9fa..161a8d6 100644 --- a/dist/js/executable.js +++ b/dist/js/executable.js @@ -3,7 +3,7 @@ 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 RuntimeItemsStringMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/RuntimeItemsStringMixin"); +const RuntimeItemsMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"); const executableMixin_1 = require("./executableMixin"); class Executable extends entity_1.InMemoryEntity { constructor(data = {}) { @@ -18,8 +18,7 @@ class Executable extends entity_1.InMemoryEntity { } } exports.default = Executable; -// Apply mixins -(0, RuntimeItemsStringMixin_1.runtimeItemsStringMixin)(Executable.prototype); (0, NamedEntityMixin_1.namedEntityMixin)(Executable.prototype); (0, DefaultableMixin_1.defaultableEntityMixin)(Executable); +(0, RuntimeItemsMixin_1.runtimeItemsMixin)(Executable.prototype); (0, executableMixin_1.executableMixin)(Executable); diff --git a/dist/js/executableMixin.d.ts b/dist/js/executableMixin.d.ts index fed8963..efbd15f 100644 --- a/dist/js/executableMixin.d.ts +++ b/dist/js/executableMixin.d.ts @@ -1,13 +1,13 @@ 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 { NamedEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types"; import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types"; import type { FlavorMixin } from "./flavorMixin"; import { ExecutableSchemaMixin } from "./generated/ExecutableSchemaMixin"; -type BaseFlavor = FlavorMixin & NamedInMemoryEntity & InMemoryEntity; -type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity; +type BaseFlavor = FlavorMixin & NamedEntity & InMemoryEntity; +type Base = InMemoryEntity & NamedEntity & DefaultableInMemoryEntity; export type BaseConstructor = Constructor & { constructCustomFlavor?: (config: object) => BaseFlavor; }; diff --git a/dist/js/flavor.d.ts b/dist/js/flavor.d.ts index b229353..cebc2be 100644 --- a/dist/js/flavor.d.ts +++ b/dist/js/flavor.d.ts @@ -1,11 +1,11 @@ import { 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 RuntimeItemsStringInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsStringMixin"; +import { type NamedEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; +import { type RuntimeItems } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { FlavorSchema } from "@mat3ra/esse/dist/js/types"; import { type FlavorMixin } from "./flavorMixin"; -type Base = typeof InMemoryEntity & Constructor & Constructor & Constructor & Constructor; +type Base = typeof InMemoryEntity & Constructor & Constructor & Constructor & Constructor; declare const Flavor_base: Base; export default class Flavor extends Flavor_base { constructor(data?: Partial); diff --git a/dist/js/flavor.js b/dist/js/flavor.js index 537bed5..9cd0c1e 100644 --- a/dist/js/flavor.js +++ b/dist/js/flavor.js @@ -3,7 +3,7 @@ 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 RuntimeItemsStringMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/RuntimeItemsStringMixin"); +const RuntimeItemsMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"); const flavorMixin_1 = require("./flavorMixin"); class Flavor extends entity_1.InMemoryEntity { constructor(data = {}) { @@ -21,7 +21,7 @@ class Flavor extends entity_1.InMemoryEntity { } } exports.default = Flavor; -(0, RuntimeItemsStringMixin_1.runtimeItemsStringMixin)(Flavor.prototype); +(0, RuntimeItemsMixin_1.runtimeItemsMixin)(Flavor.prototype); (0, NamedEntityMixin_1.namedEntityMixin)(Flavor.prototype); (0, DefaultableMixin_1.defaultableEntityMixin)(Flavor); (0, flavorMixin_1.flavorMixin)(Flavor); diff --git a/dist/js/template.d.ts b/dist/js/template.d.ts index 799dff5..d24b0e9 100644 --- a/dist/js/template.d.ts +++ b/dist/js/template.d.ts @@ -1,9 +1,9 @@ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import { type NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; +import { type NamedEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { TemplateSchema } from "@mat3ra/esse/dist/js/types"; import { type TemplateMixin, type TemplateStaticMixin } from "./templateMixin"; -type Base = typeof InMemoryEntity & Constructor & Constructor & TemplateStaticMixin; +type Base = typeof InMemoryEntity & Constructor & Constructor & TemplateStaticMixin; declare const Template_base: Base; export default class Template extends Template_base { constructor(data?: Partial); diff --git a/package-lock.json b/package-lock.json index ff4653d..36f58ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,8 +17,8 @@ "devDependencies": { "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", - "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#2f5206cb8db85af8c9af3d450a8dc551bb6b9b61", - "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#c248a30803e421f6da33e8270602bd1571945fb6", + "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#19c904dcdae87b83f88b38c756abd746e2bd7927", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#9cd6ac3b66837a45011974e2c637ca8e8a2d6c41", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", @@ -3195,8 +3195,8 @@ }, "node_modules/@mat3ra/code": { "version": "0.0.0", - "resolved": "git+ssh://git@github.com/Exabyte-io/code.git#2f5206cb8db85af8c9af3d450a8dc551bb6b9b61", - "integrity": "sha512-24YL0+n8EpWUYURbGp7Pw9MKH456teZStoW4QsUME07CqgrOKUcxV9Z9XVtpLRFSq+A5e7TszSiIJ7FAdlLZTQ==", + "resolved": "git+ssh://git@github.com/Exabyte-io/code.git#19c904dcdae87b83f88b38c756abd746e2bd7927", + "integrity": "sha512-uhE+7eKKL/r7K+TDgO9THVsYZ0a3Vxfvmga2MZOI3yZJYDrOqAO62T6EGfmoEX0IixXEPe87aO/9jP07SVm4DA==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -3235,8 +3235,8 @@ }, "node_modules/@mat3ra/esse": { "version": "0.0.0", - "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#c248a30803e421f6da33e8270602bd1571945fb6", - "integrity": "sha512-9o07vskHfdIsaHkTPvN0gEEaUrVdZBgjXQToy1TXW+I4KH0y5Sa4GWp21IuO9Ww322vI8QdXLx7SfnhzcZzWeQ==", + "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#9cd6ac3b66837a45011974e2c637ca8e8a2d6c41", + "integrity": "sha512-9n1FTk0n5xg0xf2gIPRjcv37OaoUeg4jzAxeBWB2neVsXn4xDJxfdGDcWVLo/2HnLAA0tC93ufx/T26pUSH8Aw==", "dev": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index 47d04df..da2b164 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/utils": "2025.9.20-0", - "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#2f5206cb8db85af8c9af3d450a8dc551bb6b9b61", - "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#c248a30803e421f6da33e8270602bd1571945fb6", + "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#19c904dcdae87b83f88b38c756abd746e2bd7927", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#9cd6ac3b66837a45011974e2c637ca8e8a2d6c41", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", diff --git a/scripts/generate-mixins.ts b/scripts/generate-mixins.ts index 0670b86..38370ee 100644 --- a/scripts/generate-mixins.ts +++ b/scripts/generate-mixins.ts @@ -18,10 +18,10 @@ import type { JSONSchema7 } from "json-schema"; * Output file paths for each schema */ const OUTPUT_PATHS = { - "software/executable_properties": "src/js/generated/ExecutableSchemaMixin.ts", - "software/flavor_properties": "src/js/generated/FlavorSchemaMixin.ts", - "software/application_properties": "src/js/generated/ApplicationSchemaMixin.ts", - "software/template_properties": "src/js/generated/TemplateSchemaMixin.ts", + "software/executable-properties": "src/js/generated/ExecutableSchemaMixin.ts", + "software/flavor-properties": "src/js/generated/FlavorSchemaMixin.ts", + "software/application-properties": "src/js/generated/ApplicationSchemaMixin.ts", + "software/template-properties": "src/js/generated/TemplateSchemaMixin.ts", }; function main() { diff --git a/src/js/ApplicationRegistry.ts b/src/js/ApplicationRegistry.ts index 5c04830..bc33ef8 100644 --- a/src/js/ApplicationRegistry.ts +++ b/src/js/ApplicationRegistry.ts @@ -176,6 +176,8 @@ export default class ApplicationRegistry { static getExecutableByName(appName: string, execName?: string) { const appTree = new ApplicationStandata().getAppTreeForApplication(appName); + console.log("================", appTree); + Object.entries(appTree).forEach(([name, exec]) => { exec.name = name; }); diff --git a/src/js/applicationMixin.ts b/src/js/applicationMixin.ts index 435304d..cdb060c 100644 --- a/src/js/applicationMixin.ts +++ b/src/js/applicationMixin.ts @@ -1,6 +1,6 @@ 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 { NamedEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface"; import type { ApplicationSchemaBase } from "@mat3ra/esse/dist/js/types"; @@ -12,7 +12,7 @@ import { applicationSchemaMixin, } from "./generated/ApplicationSchemaMixin"; -type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity; +type Base = InMemoryEntity & NamedEntity & DefaultableInMemoryEntity; export type BaseConstructor = Constructor & { constructCustomExecutable?: (config: object) => Executable; @@ -36,8 +36,6 @@ export type ApplicationStaticMixin = { function applicationPropertiesMixin( item: T, ): asserts item is T & ApplicationMixin { - applicationSchemaMixin(item); - // @ts-expect-error const properties: ApplicationMixin & Base = { get isUsingMaterial() { @@ -65,6 +63,7 @@ function applicationStaticMixin(Application: T) { } export function applicationMixin(Item: BaseConstructor) { + applicationSchemaMixin(Item.prototype); applicationPropertiesMixin(Item.prototype); applicationStaticMixin(Item); } diff --git a/src/js/executable.ts b/src/js/executable.ts index c04b0b9..0c312f1 100644 --- a/src/js/executable.ts +++ b/src/js/executable.ts @@ -4,21 +4,21 @@ import { defaultableEntityMixin, } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; import { - type NamedInMemoryEntity, + type NamedEntity, namedEntityMixin, } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import { - type RuntimeItemsStringInMemoryEntity, - runtimeItemsStringMixin, -} from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsStringMixin"; + type RuntimeItems, + runtimeItemsMixin, +} from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types"; import { type ExecutableMixin, executableMixin } from "./executableMixin"; type Base = Constructor & - Constructor & - Constructor & + Constructor & + Constructor & Constructor & typeof InMemoryEntity; @@ -35,8 +35,7 @@ export default class Executable extends (InMemoryEntity as Base) { } } -// Apply mixins -runtimeItemsStringMixin(Executable.prototype); namedEntityMixin(Executable.prototype); defaultableEntityMixin(Executable); +runtimeItemsMixin(Executable.prototype); executableMixin(Executable); diff --git a/src/js/executableMixin.ts b/src/js/executableMixin.ts index e441c93..69bce1d 100644 --- a/src/js/executableMixin.ts +++ b/src/js/executableMixin.ts @@ -1,6 +1,6 @@ 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 { NamedEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface"; import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types"; @@ -9,18 +9,8 @@ import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types"; import type { FlavorMixin } from "./flavorMixin"; import { ExecutableSchemaMixin, executableSchemaMixin } from "./generated/ExecutableSchemaMixin"; -type BaseFlavor = FlavorMixin & NamedInMemoryEntity & InMemoryEntity; -type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity; - -function executableStaticMixin(Executable: Constructor) { - const properties: ExecutableStaticMixin = { - get jsonSchema() { - return JSONSchemasInterface.getSchemaById("software/executable") as ExecutableSchema; - }, - }; - - Object.defineProperties(Executable, Object.getOwnPropertyDescriptors(properties)); -} +type BaseFlavor = FlavorMixin & NamedEntity & InMemoryEntity; +type Base = InMemoryEntity & NamedEntity & DefaultableInMemoryEntity; export type BaseConstructor = Constructor & { constructCustomFlavor?: (config: object) => BaseFlavor; @@ -34,6 +24,16 @@ export type ExecutableStaticMixin = { jsonSchema: ExecutableSchema; }; +function executableStaticMixin(Executable: Constructor) { + const properties: ExecutableStaticMixin = { + get jsonSchema() { + return JSONSchemasInterface.getSchemaById("software/executable") as ExecutableSchema; + }, + }; + + Object.defineProperties(Executable, Object.getOwnPropertyDescriptors(properties)); +} + export function executableMixin(Item: BaseConstructor) { executableSchemaMixin(Item.prototype); executableStaticMixin(Item); diff --git a/src/js/flavor.ts b/src/js/flavor.ts index c7b9183..49946ad 100644 --- a/src/js/flavor.ts +++ b/src/js/flavor.ts @@ -4,13 +4,13 @@ import { defaultableEntityMixin, } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; import { - type NamedInMemoryEntity, + type NamedEntity, namedEntityMixin, } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import { - type RuntimeItemsStringInMemoryEntity, - runtimeItemsStringMixin, -} from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsStringMixin"; + type RuntimeItems, + runtimeItemsMixin, +} from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { FlavorSchema } from "@mat3ra/esse/dist/js/types"; @@ -18,8 +18,8 @@ import { type FlavorMixin, flavorMixin } from "./flavorMixin"; type Base = typeof InMemoryEntity & Constructor & - Constructor & - Constructor & + Constructor & + Constructor & Constructor; export default class Flavor extends (InMemoryEntity as Base) { @@ -38,7 +38,7 @@ export default class Flavor extends (InMemoryEntity as Base) { } } -runtimeItemsStringMixin(Flavor.prototype); +runtimeItemsMixin(Flavor.prototype); namedEntityMixin(Flavor.prototype); defaultableEntityMixin(Flavor); flavorMixin(Flavor); diff --git a/src/js/template.ts b/src/js/template.ts index 0907e82..7361e9e 100644 --- a/src/js/template.ts +++ b/src/js/template.ts @@ -1,6 +1,6 @@ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; import { - type NamedInMemoryEntity, + type NamedEntity, namedEntityMixin, } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; @@ -10,7 +10,7 @@ import { type TemplateMixin, type TemplateStaticMixin, templateMixin } from "./t type Base = typeof InMemoryEntity & Constructor & - Constructor & + Constructor & TemplateStaticMixin; export default class Template extends (InMemoryEntity as Base) { diff --git a/tests/js/executable.test.ts b/tests/js/executable.test.ts index b029f21..dae16d5 100644 --- a/tests/js/executable.test.ts +++ b/tests/js/executable.test.ts @@ -21,6 +21,8 @@ describe("Executable", () => { expect(executable).to.be.instanceOf(Executable); expect(executable.name).to.equal("pw.x"); + console.log("================", executable._json); + // Get JSON representation const json = executable.toJSON(); From 58c7899e6d85fe5083fc655106fbd035aef1cfce Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Fri, 28 Nov 2025 14:23:22 +0200 Subject: [PATCH 05/16] chore: update code --- dist/js/application.d.ts | 11 ++++++++--- dist/js/application.js | 11 ++++++++++- dist/js/applicationMixin.d.ts | 4 ++-- dist/js/executable.d.ts | 10 +++++----- dist/js/executableMixin.d.ts | 4 ++-- dist/js/flavor.d.ts | 10 +++++----- dist/js/flavor.js | 2 +- dist/js/template.d.ts | 6 +++--- package-lock.json | 6 +++--- package.json | 2 +- src/js/application.ts | 27 ++++++++++++++++++++++++--- src/js/applicationMixin.ts | 4 ++-- src/js/executable.ts | 14 +++++++------- src/js/executableMixin.ts | 4 ++-- src/js/flavor.ts | 16 ++++++++-------- src/js/template.ts | 6 +++--- tests/js/application.test.ts | 3 +-- 17 files changed, 87 insertions(+), 53 deletions(-) diff --git a/dist/js/application.d.ts b/dist/js/application.d.ts index fd78625..3ef2f5a 100644 --- a/dist/js/application.d.ts +++ b/dist/js/application.d.ts @@ -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 { ApplicationSchemaBase } from "@mat3ra/esse/dist/js/types"; import { type ApplicationMixin, type ApplicationStaticMixin } from "./applicationMixin"; -type Base = typeof NamedDefaultableInMemoryEntity & Constructor & ApplicationStaticMixin; +type Base = typeof InMemoryEntity & NamedInMemoryEntityConstructor & DefaultableInMemoryEntityConstructor & Constructor & ApplicationStaticMixin; declare const Application_base: Base; -export default class Application extends Application_base { +export default class Application extends Application_base implements ApplicationSchemaBase { + constructor(data?: Partial); + [k: string]: unknown; } export {}; diff --git a/dist/js/application.js b/dist/js/application.js index cf464cd..8f344d9 100644 --- a/dist/js/application.js +++ b/dist/js/application.js @@ -1,8 +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, NamedEntityMixin_1.namedEntityMixin)(Application.prototype); +(0, DefaultableMixin_1.defaultableEntityMixin)(Application); (0, applicationMixin_1.applicationMixin)(Application); diff --git a/dist/js/applicationMixin.d.ts b/dist/js/applicationMixin.d.ts index b4ecbc0..9fa840d 100644 --- a/dist/js/applicationMixin.d.ts +++ b/dist/js/applicationMixin.d.ts @@ -1,11 +1,11 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import type { DefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; +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"; import { type ApplicationSchemaMixin } from "./generated/ApplicationSchemaMixin"; -type Base = InMemoryEntity & NamedEntity & DefaultableInMemoryEntity; +type Base = InMemoryEntity & NamedEntity & Defaultable; export type BaseConstructor = Constructor & { constructCustomExecutable?: (config: object) => Executable; }; diff --git a/dist/js/executable.d.ts b/dist/js/executable.d.ts index 7aac21f..60fc3c2 100644 --- a/dist/js/executable.d.ts +++ b/dist/js/executable.d.ts @@ -1,13 +1,13 @@ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import { type DefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; -import { type NamedEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; -import { type RuntimeItems } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; +import { type DefaultableInMemoryEntityConstructor } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; +import { type NamedInMemoryEntityConstructor } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; +import { type RuntimeItemsInMemoryEntityConstructor } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types"; import { type ExecutableMixin } from "./executableMixin"; -type Base = Constructor & Constructor & Constructor & Constructor & typeof InMemoryEntity; +type Base = Constructor & RuntimeItemsInMemoryEntityConstructor & NamedInMemoryEntityConstructor & DefaultableInMemoryEntityConstructor & typeof InMemoryEntity; declare const Executable_base: Base; -export default class Executable extends Executable_base { +export default class Executable extends Executable_base implements ExecutableSchema { constructor(data?: Partial); } export {}; diff --git a/dist/js/executableMixin.d.ts b/dist/js/executableMixin.d.ts index efbd15f..aa8f597 100644 --- a/dist/js/executableMixin.d.ts +++ b/dist/js/executableMixin.d.ts @@ -1,5 +1,5 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import type { DefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; +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 { AnyObject } from "@mat3ra/esse/dist/js/esse/types"; @@ -7,7 +7,7 @@ import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types"; import type { FlavorMixin } from "./flavorMixin"; import { ExecutableSchemaMixin } from "./generated/ExecutableSchemaMixin"; type BaseFlavor = FlavorMixin & NamedEntity & InMemoryEntity; -type Base = InMemoryEntity & NamedEntity & DefaultableInMemoryEntity; +type Base = InMemoryEntity & NamedEntity & Defaultable; export type BaseConstructor = Constructor & { constructCustomFlavor?: (config: object) => BaseFlavor; }; diff --git a/dist/js/flavor.d.ts b/dist/js/flavor.d.ts index cebc2be..697db87 100644 --- a/dist/js/flavor.d.ts +++ b/dist/js/flavor.d.ts @@ -1,13 +1,13 @@ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import { type DefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; -import { type NamedEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; -import { type RuntimeItems } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; +import { type DefaultableInMemoryEntityConstructor } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; +import { NamedInMemoryEntityConstructor } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; +import { type RuntimeItemsInMemoryEntityConstructor } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { FlavorSchema } from "@mat3ra/esse/dist/js/types"; import { type FlavorMixin } from "./flavorMixin"; -type Base = typeof InMemoryEntity & Constructor & Constructor & Constructor & Constructor; +type Base = typeof InMemoryEntity & Constructor & RuntimeItemsInMemoryEntityConstructor & NamedInMemoryEntityConstructor & DefaultableInMemoryEntityConstructor; declare const Flavor_base: Base; -export default class Flavor extends Flavor_base { +export default class Flavor extends Flavor_base implements FlavorSchema { constructor(data?: Partial); } export {}; diff --git a/dist/js/flavor.js b/dist/js/flavor.js index 9cd0c1e..ed31a4f 100644 --- a/dist/js/flavor.js +++ b/dist/js/flavor.js @@ -21,7 +21,7 @@ class Flavor extends entity_1.InMemoryEntity { } } exports.default = Flavor; -(0, RuntimeItemsMixin_1.runtimeItemsMixin)(Flavor.prototype); (0, NamedEntityMixin_1.namedEntityMixin)(Flavor.prototype); (0, DefaultableMixin_1.defaultableEntityMixin)(Flavor); +(0, RuntimeItemsMixin_1.runtimeItemsMixin)(Flavor.prototype); (0, flavorMixin_1.flavorMixin)(Flavor); diff --git a/dist/js/template.d.ts b/dist/js/template.d.ts index d24b0e9..0c7be83 100644 --- a/dist/js/template.d.ts +++ b/dist/js/template.d.ts @@ -1,11 +1,11 @@ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import { type NamedEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; +import { type NamedInMemoryEntityConstructor } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { TemplateSchema } from "@mat3ra/esse/dist/js/types"; import { type TemplateMixin, type TemplateStaticMixin } from "./templateMixin"; -type Base = typeof InMemoryEntity & Constructor & Constructor & TemplateStaticMixin; +type Base = typeof InMemoryEntity & Constructor & NamedInMemoryEntityConstructor & TemplateStaticMixin; declare const Template_base: Base; -export default class Template extends Template_base { +export default class Template extends Template_base implements TemplateSchema { constructor(data?: Partial); } export {}; diff --git a/package-lock.json b/package-lock.json index 36f58ab..e8b8033 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "devDependencies": { "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", - "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#19c904dcdae87b83f88b38c756abd746e2bd7927", + "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#5803c543e812727ad32dffefd1426497694a427b", "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#9cd6ac3b66837a45011974e2c637ca8e8a2d6c41", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", @@ -3195,8 +3195,8 @@ }, "node_modules/@mat3ra/code": { "version": "0.0.0", - "resolved": "git+ssh://git@github.com/Exabyte-io/code.git#19c904dcdae87b83f88b38c756abd746e2bd7927", - "integrity": "sha512-uhE+7eKKL/r7K+TDgO9THVsYZ0a3Vxfvmga2MZOI3yZJYDrOqAO62T6EGfmoEX0IixXEPe87aO/9jP07SVm4DA==", + "resolved": "git+ssh://git@github.com/Exabyte-io/code.git#5803c543e812727ad32dffefd1426497694a427b", + "integrity": "sha512-z/9Bipd5XEKBj3/KqxuB4XHshxEkVrmLp41NOwVf96ny9two9lpUapkpzFWdM5uypYm76au04//p59Oo7GWRPQ==", "dev": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index 1b318c2..8c6956b 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/utils": "2025.9.20-0", - "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#19c904dcdae87b83f88b38c756abd746e2bd7927", + "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#5803c543e812727ad32dffefd1426497694a427b", "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#9cd6ac3b66837a45011974e2c637ca8e8a2d6c41", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", diff --git a/src/js/application.ts b/src/js/application.ts index 2f4ce54..e76c223 100644 --- a/src/js/application.ts +++ b/src/js/application.ts @@ -1,5 +1,14 @@ -import { NamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import { + type DefaultableInMemoryEntityConstructor, + defaultableEntityMixin, +} from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; +import { + type NamedInMemoryEntityConstructor, + namedEntityMixin, +} 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 { type ApplicationMixin, @@ -7,10 +16,22 @@ import { applicationMixin, } from "./applicationMixin"; -type Base = typeof NamedDefaultableInMemoryEntity & +type Base = typeof InMemoryEntity & + NamedInMemoryEntityConstructor & + DefaultableInMemoryEntityConstructor & Constructor & ApplicationStaticMixin; -export default class Application extends (NamedDefaultableInMemoryEntity as Base) {} +export default class Application extends (InMemoryEntity as Base) implements ApplicationSchemaBase { + constructor(data: Partial = {}) { + super({ + ...data, + }); + } + + [k: string]: unknown; +} +namedEntityMixin(Application.prototype); +defaultableEntityMixin(Application); applicationMixin(Application); diff --git a/src/js/applicationMixin.ts b/src/js/applicationMixin.ts index cdb060c..982629a 100644 --- a/src/js/applicationMixin.ts +++ b/src/js/applicationMixin.ts @@ -1,5 +1,5 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import type { DefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; +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 JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface"; @@ -12,7 +12,7 @@ import { applicationSchemaMixin, } from "./generated/ApplicationSchemaMixin"; -type Base = InMemoryEntity & NamedEntity & DefaultableInMemoryEntity; +type Base = InMemoryEntity & NamedEntity & Defaultable; export type BaseConstructor = Constructor & { constructCustomExecutable?: (config: object) => Executable; diff --git a/src/js/executable.ts b/src/js/executable.ts index 0c312f1..1c99757 100644 --- a/src/js/executable.ts +++ b/src/js/executable.ts @@ -1,14 +1,14 @@ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; import { - type DefaultableInMemoryEntity, + type DefaultableInMemoryEntityConstructor, defaultableEntityMixin, } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; import { - type NamedEntity, + type NamedInMemoryEntityConstructor, namedEntityMixin, } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import { - type RuntimeItems, + type RuntimeItemsInMemoryEntityConstructor, runtimeItemsMixin, } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; @@ -17,12 +17,12 @@ import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types"; import { type ExecutableMixin, executableMixin } from "./executableMixin"; type Base = Constructor & - Constructor & - Constructor & - Constructor & + RuntimeItemsInMemoryEntityConstructor & + NamedInMemoryEntityConstructor & + DefaultableInMemoryEntityConstructor & typeof InMemoryEntity; -export default class Executable extends (InMemoryEntity as Base) { +export default class Executable extends (InMemoryEntity as Base) implements ExecutableSchema { constructor(data: Partial = {}) { super({ monitors: [], diff --git a/src/js/executableMixin.ts b/src/js/executableMixin.ts index 69bce1d..dbb080e 100644 --- a/src/js/executableMixin.ts +++ b/src/js/executableMixin.ts @@ -1,5 +1,5 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; -import type { DefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; +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 JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface"; @@ -10,7 +10,7 @@ import type { FlavorMixin } from "./flavorMixin"; import { ExecutableSchemaMixin, executableSchemaMixin } from "./generated/ExecutableSchemaMixin"; type BaseFlavor = FlavorMixin & NamedEntity & InMemoryEntity; -type Base = InMemoryEntity & NamedEntity & DefaultableInMemoryEntity; +type Base = InMemoryEntity & NamedEntity & Defaultable; export type BaseConstructor = Constructor & { constructCustomFlavor?: (config: object) => BaseFlavor; diff --git a/src/js/flavor.ts b/src/js/flavor.ts index 49946ad..8f48ef4 100644 --- a/src/js/flavor.ts +++ b/src/js/flavor.ts @@ -1,14 +1,14 @@ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; import { - type DefaultableInMemoryEntity, + type DefaultableInMemoryEntityConstructor, defaultableEntityMixin, } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; import { - type NamedEntity, namedEntityMixin, + NamedInMemoryEntityConstructor, } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import { - type RuntimeItems, + type RuntimeItemsInMemoryEntityConstructor, runtimeItemsMixin, } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; @@ -18,11 +18,11 @@ import { type FlavorMixin, flavorMixin } from "./flavorMixin"; type Base = typeof InMemoryEntity & Constructor & - Constructor & - Constructor & - Constructor; + RuntimeItemsInMemoryEntityConstructor & + NamedInMemoryEntityConstructor & + DefaultableInMemoryEntityConstructor; -export default class Flavor extends (InMemoryEntity as Base) { +export default class Flavor extends (InMemoryEntity as Base) implements FlavorSchema { constructor(data: Partial = {}) { super({ monitors: [], @@ -38,7 +38,7 @@ export default class Flavor extends (InMemoryEntity as Base) { } } -runtimeItemsMixin(Flavor.prototype); namedEntityMixin(Flavor.prototype); defaultableEntityMixin(Flavor); +runtimeItemsMixin(Flavor.prototype); flavorMixin(Flavor); diff --git a/src/js/template.ts b/src/js/template.ts index 7361e9e..6ccefa7 100644 --- a/src/js/template.ts +++ b/src/js/template.ts @@ -1,6 +1,6 @@ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; import { - type NamedEntity, + type NamedInMemoryEntityConstructor, namedEntityMixin, } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; @@ -10,10 +10,10 @@ import { type TemplateMixin, type TemplateStaticMixin, templateMixin } from "./t type Base = typeof InMemoryEntity & Constructor & - Constructor & + NamedInMemoryEntityConstructor & TemplateStaticMixin; -export default class Template extends (InMemoryEntity as Base) { +export default class Template extends (InMemoryEntity as Base) implements TemplateSchema { constructor(data: Partial = {}) { super({ applicationName: "", diff --git a/tests/js/application.test.ts b/tests/js/application.test.ts index 30a34a0..f27c35b 100644 --- a/tests/js/application.test.ts +++ b/tests/js/application.test.ts @@ -2,10 +2,9 @@ import { expect } from "chai"; import Application from "../../src/js/application"; -import type { CreateApplicationConfig } from "../../src/js/ApplicationRegistry"; describe("Application", () => { - const obj: CreateApplicationConfig = { name: "espresso" }; + const obj = { name: "espresso" }; it("can be created", () => { const app = new Application(obj); From 775d0babcf8ed8d3d45037875c6384b9f71169f1 Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Fri, 28 Nov 2025 15:33:22 +0200 Subject: [PATCH 06/16] chore: new esse --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index e8b8033..68ac3ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#5803c543e812727ad32dffefd1426497694a427b", - "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#9cd6ac3b66837a45011974e2c637ca8e8a2d6c41", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#1b47917bb8feadf49c46d8aa4b33a4255a06788a", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", @@ -3235,8 +3235,8 @@ }, "node_modules/@mat3ra/esse": { "version": "0.0.0", - "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#9cd6ac3b66837a45011974e2c637ca8e8a2d6c41", - "integrity": "sha512-9n1FTk0n5xg0xf2gIPRjcv37OaoUeg4jzAxeBWB2neVsXn4xDJxfdGDcWVLo/2HnLAA0tC93ufx/T26pUSH8Aw==", + "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#1b47917bb8feadf49c46d8aa4b33a4255a06788a", + "integrity": "sha512-TEiTzxWwdpSKjKCZdT72917riOPDVAgENFQ9WXhVVbYrOwDmv5Ia0irvP3XlHrfgvmtJW02P/Voib/+zekVwBg==", "dev": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index 8c6956b..b53d4fd 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/utils": "2025.9.20-0", "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#5803c543e812727ad32dffefd1426497694a427b", - "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#9cd6ac3b66837a45011974e2c637ca8e8a2d6c41", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#1b47917bb8feadf49c46d8aa4b33a4255a06788a", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", From e40a16a49bea0629266eca8cb5eb31b3fda013bd Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Fri, 28 Nov 2025 15:55:26 +0200 Subject: [PATCH 07/16] chore: improve ts types of JSONSchemaDataProvider --- dist/js/context/JSONSchemaDataProvider.d.ts | 6 ++++-- dist/js/context/JSONSchemaDataProvider.js | 1 - src/js/context/JSONSchemaDataProvider.ts | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dist/js/context/JSONSchemaDataProvider.d.ts b/dist/js/context/JSONSchemaDataProvider.d.ts index 30f033f..58e9e8f 100644 --- a/dist/js/context/JSONSchemaDataProvider.d.ts +++ b/dist/js/context/JSONSchemaDataProvider.d.ts @@ -1,7 +1,9 @@ +import type { JSONSchema } from "@mat3ra/esse/dist/js/esse/utils"; import JinjaContextProvider from "./JinjaContextProvider"; /** * @summary Provides jsonSchema only. */ -export default class JSONSchemaDataProvider extends JinjaContextProvider { - get jsonSchema(): void; +declare abstract class JSONSchemaDataProvider extends JinjaContextProvider { + get jsonSchema(): JSONSchema; } +export default JSONSchemaDataProvider; diff --git a/dist/js/context/JSONSchemaDataProvider.js b/dist/js/context/JSONSchemaDataProvider.js index 6f2c8bf..a9c9bcb 100644 --- a/dist/js/context/JSONSchemaDataProvider.js +++ b/dist/js/context/JSONSchemaDataProvider.js @@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -/* eslint-disable class-methods-use-this */ const JinjaContextProvider_1 = __importDefault(require("./JinjaContextProvider")); /** * @summary Provides jsonSchema only. diff --git a/src/js/context/JSONSchemaDataProvider.ts b/src/js/context/JSONSchemaDataProvider.ts index 2159395..4ac61c2 100644 --- a/src/js/context/JSONSchemaDataProvider.ts +++ b/src/js/context/JSONSchemaDataProvider.ts @@ -1,11 +1,15 @@ /* eslint-disable class-methods-use-this */ +import type { JSONSchema } from "@mat3ra/esse/dist/js/esse/utils"; + import JinjaContextProvider from "./JinjaContextProvider"; /** * @summary Provides jsonSchema only. */ -export default class JSONSchemaDataProvider extends JinjaContextProvider { - get jsonSchema() { +abstract class JSONSchemaDataProvider extends JinjaContextProvider { + get jsonSchema(): JSONSchema { throw new Error("Not implemented."); } } + +export default JSONSchemaDataProvider; From cdbb99d4ca9406b881ef6c5d4d6011fd4cdb9cfd Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Mon, 1 Dec 2025 18:05:59 +0200 Subject: [PATCH 08/16] chore: remove JSONSchemaFormDataProvider --- dist/js/index.d.ts | 4 +- dist/js/index.js | 6 +-- scripts/generate-mixins.ts | 1 - src/js/context/JSONSchemaFormDataProvider.ts | 43 -------------------- src/js/index.ts | 4 +- 5 files changed, 7 insertions(+), 51 deletions(-) delete mode 100644 src/js/context/JSONSchemaFormDataProvider.ts diff --git a/dist/js/index.d.ts b/dist/js/index.d.ts index 5d5323e..fd831d9 100644 --- a/dist/js/index.d.ts +++ b/dist/js/index.d.ts @@ -2,7 +2,7 @@ import Application from "./application"; import { applicationMixin } from "./applicationMixin"; import ApplicationRegistry from "./ApplicationRegistry"; import ContextProvider from "./context/ContextProvider"; -import JSONSchemaFormDataProvider from "./context/JSONSchemaFormDataProvider"; +import JSONSchemaDataProvider from "./context/JSONSchemaDataProvider"; import Executable from "./executable"; import { executableMixin } from "./executableMixin"; import Flavor from "./flavor"; @@ -10,5 +10,5 @@ import { flavorMixin } from "./flavorMixin"; import Template from "./template"; import { templateMixin } from "./templateMixin"; declare const allApplications: string[]; -export { Application, Executable, Flavor, Template, ApplicationRegistry, ContextProvider, JSONSchemaFormDataProvider, executableMixin, flavorMixin, applicationMixin, templateMixin, allApplications, }; +export { Application, Executable, Flavor, Template, ApplicationRegistry, ContextProvider, JSONSchemaDataProvider, executableMixin, flavorMixin, applicationMixin, templateMixin, allApplications, }; export type * from "./types"; diff --git a/dist/js/index.js b/dist/js/index.js index 5cfd4d3..1ae159a 100644 --- a/dist/js/index.js +++ b/dist/js/index.js @@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.allApplications = exports.templateMixin = exports.applicationMixin = exports.flavorMixin = exports.executableMixin = exports.JSONSchemaFormDataProvider = exports.ContextProvider = exports.ApplicationRegistry = exports.Template = exports.Flavor = exports.Executable = exports.Application = void 0; +exports.allApplications = exports.templateMixin = exports.applicationMixin = exports.flavorMixin = exports.executableMixin = exports.JSONSchemaDataProvider = exports.ContextProvider = exports.ApplicationRegistry = exports.Template = exports.Flavor = exports.Executable = exports.Application = void 0; const application_1 = __importDefault(require("./application")); exports.Application = application_1.default; const applicationMixin_1 = require("./applicationMixin"); @@ -12,8 +12,8 @@ const ApplicationRegistry_1 = __importDefault(require("./ApplicationRegistry")); exports.ApplicationRegistry = ApplicationRegistry_1.default; const ContextProvider_1 = __importDefault(require("./context/ContextProvider")); exports.ContextProvider = ContextProvider_1.default; -const JSONSchemaFormDataProvider_1 = __importDefault(require("./context/JSONSchemaFormDataProvider")); -exports.JSONSchemaFormDataProvider = JSONSchemaFormDataProvider_1.default; +const JSONSchemaDataProvider_1 = __importDefault(require("./context/JSONSchemaDataProvider")); +exports.JSONSchemaDataProvider = JSONSchemaDataProvider_1.default; const executable_1 = __importDefault(require("./executable")); exports.Executable = executable_1.default; const executableMixin_1 = require("./executableMixin"); diff --git a/scripts/generate-mixins.ts b/scripts/generate-mixins.ts index 38370ee..cb6fcad 100644 --- a/scripts/generate-mixins.ts +++ b/scripts/generate-mixins.ts @@ -25,7 +25,6 @@ const OUTPUT_PATHS = { }; function main() { - // Type assertion to handle schema compatibility - the schemas from esse may have slightly different types const result = generateSchemaMixin(allSchemas as JSONSchema7[], OUTPUT_PATHS); if (result.errorCount > 0) { diff --git a/src/js/context/JSONSchemaFormDataProvider.ts b/src/js/context/JSONSchemaFormDataProvider.ts deleted file mode 100644 index 05c97cc..0000000 --- a/src/js/context/JSONSchemaFormDataProvider.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* eslint-disable class-methods-use-this */ -import type { UiSchema } from "react-jsonschema-form"; - -import JSONSchemaDataProvider from "./JSONSchemaDataProvider"; - -/** - * @summary Provides jsonSchema and uiSchema for generating react-jsonschema-form - * See https://github.com/mozilla-services/react-jsonschema-form for Form UI. - * Form generation example: - * ``` - *
- * ``` - */ -// TODO: MOVE to WebApp/ave or wove -export default class JSONSchemaFormDataProvider extends JSONSchemaDataProvider { - get uiSchema(): UiSchema { - throw new Error("Not implemented."); - } - - get fields() { - return {}; - } - - get defaultFieldStyles() { - return {}; - } - - get uiSchemaStyled(): UiSchema { - const schema = this.uiSchema; - return Object.fromEntries( - Object.entries(schema).map(([key, value]) => [ - key, - { - ...value, - ...this.defaultFieldStyles, - classNames: `${value.classNames || ""}`, - }, - ]), - ); - } -} diff --git a/src/js/index.ts b/src/js/index.ts index 6ec04b0..bc4f4cb 100644 --- a/src/js/index.ts +++ b/src/js/index.ts @@ -2,7 +2,7 @@ import Application from "./application"; import { applicationMixin } from "./applicationMixin"; import ApplicationRegistry from "./ApplicationRegistry"; import ContextProvider from "./context/ContextProvider"; -import JSONSchemaFormDataProvider from "./context/JSONSchemaFormDataProvider"; +import JSONSchemaDataProvider from "./context/JSONSchemaDataProvider"; import Executable from "./executable"; import { executableMixin } from "./executableMixin"; import Flavor from "./flavor"; @@ -19,7 +19,7 @@ export { Template, ApplicationRegistry, ContextProvider, - JSONSchemaFormDataProvider, + JSONSchemaDataProvider, executableMixin, flavorMixin, applicationMixin, From 956f0317cd770746775d8861773afae56d4f061e Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Mon, 1 Dec 2025 22:41:41 +0200 Subject: [PATCH 09/16] chore: remove JSONSchemaDataProvider and JinjaContextProvider --- dist/js/index.d.ts | 3 +- dist/js/index.js | 4 +- src/js/context/JSONSchemaDataProvider.ts | 15 --- src/js/context/JinjaContextProvider.ts | 16 --- src/js/index.ts | 2 - tests/js/JSONSchemaFormDataProvider.test.ts | 114 +++++++++---------- tests/js/JSONSchemaProvider.test.ts | 118 ++++++++++---------- 7 files changed, 118 insertions(+), 154 deletions(-) delete mode 100644 src/js/context/JSONSchemaDataProvider.ts delete mode 100644 src/js/context/JinjaContextProvider.ts diff --git a/dist/js/index.d.ts b/dist/js/index.d.ts index fd831d9..4f8b77f 100644 --- a/dist/js/index.d.ts +++ b/dist/js/index.d.ts @@ -2,7 +2,6 @@ import Application from "./application"; import { applicationMixin } from "./applicationMixin"; import ApplicationRegistry from "./ApplicationRegistry"; import ContextProvider from "./context/ContextProvider"; -import JSONSchemaDataProvider from "./context/JSONSchemaDataProvider"; import Executable from "./executable"; import { executableMixin } from "./executableMixin"; import Flavor from "./flavor"; @@ -10,5 +9,5 @@ import { flavorMixin } from "./flavorMixin"; import Template from "./template"; import { templateMixin } from "./templateMixin"; declare const allApplications: string[]; -export { Application, Executable, Flavor, Template, ApplicationRegistry, ContextProvider, JSONSchemaDataProvider, executableMixin, flavorMixin, applicationMixin, templateMixin, allApplications, }; +export { Application, Executable, Flavor, Template, ApplicationRegistry, ContextProvider, executableMixin, flavorMixin, applicationMixin, templateMixin, allApplications, }; export type * from "./types"; diff --git a/dist/js/index.js b/dist/js/index.js index 1ae159a..c97e90c 100644 --- a/dist/js/index.js +++ b/dist/js/index.js @@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.allApplications = exports.templateMixin = exports.applicationMixin = exports.flavorMixin = exports.executableMixin = exports.JSONSchemaDataProvider = exports.ContextProvider = exports.ApplicationRegistry = exports.Template = exports.Flavor = exports.Executable = exports.Application = void 0; +exports.allApplications = exports.templateMixin = exports.applicationMixin = exports.flavorMixin = exports.executableMixin = exports.ContextProvider = exports.ApplicationRegistry = exports.Template = exports.Flavor = exports.Executable = exports.Application = void 0; const application_1 = __importDefault(require("./application")); exports.Application = application_1.default; const applicationMixin_1 = require("./applicationMixin"); @@ -12,8 +12,6 @@ const ApplicationRegistry_1 = __importDefault(require("./ApplicationRegistry")); exports.ApplicationRegistry = ApplicationRegistry_1.default; const ContextProvider_1 = __importDefault(require("./context/ContextProvider")); exports.ContextProvider = ContextProvider_1.default; -const JSONSchemaDataProvider_1 = __importDefault(require("./context/JSONSchemaDataProvider")); -exports.JSONSchemaDataProvider = JSONSchemaDataProvider_1.default; const executable_1 = __importDefault(require("./executable")); exports.Executable = executable_1.default; const executableMixin_1 = require("./executableMixin"); diff --git a/src/js/context/JSONSchemaDataProvider.ts b/src/js/context/JSONSchemaDataProvider.ts deleted file mode 100644 index 4ac61c2..0000000 --- a/src/js/context/JSONSchemaDataProvider.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* eslint-disable class-methods-use-this */ -import type { JSONSchema } from "@mat3ra/esse/dist/js/esse/utils"; - -import JinjaContextProvider from "./JinjaContextProvider"; - -/** - * @summary Provides jsonSchema only. - */ -abstract class JSONSchemaDataProvider extends JinjaContextProvider { - get jsonSchema(): JSONSchema { - throw new Error("Not implemented."); - } -} - -export default JSONSchemaDataProvider; diff --git a/src/js/context/JinjaContextProvider.ts b/src/js/context/JinjaContextProvider.ts deleted file mode 100644 index cdceb65..0000000 --- a/src/js/context/JinjaContextProvider.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ContextProviderSchema } from "@mat3ra/esse/dist/js/types"; - -import ContextProvider from "./ContextProvider"; - -interface JSONSchemaDataProviderConfig extends ContextProviderSchema { - isUsingJinjaVariables?: boolean; -} - -export default class JinjaContextProvider extends ContextProvider { - isUsingJinjaVariables: boolean; - - constructor(config: JSONSchemaDataProviderConfig) { - super(config); - this.isUsingJinjaVariables = Boolean(config.isUsingJinjaVariables); - } -} diff --git a/src/js/index.ts b/src/js/index.ts index bc4f4cb..f0f0991 100644 --- a/src/js/index.ts +++ b/src/js/index.ts @@ -2,7 +2,6 @@ import Application from "./application"; import { applicationMixin } from "./applicationMixin"; import ApplicationRegistry from "./ApplicationRegistry"; import ContextProvider from "./context/ContextProvider"; -import JSONSchemaDataProvider from "./context/JSONSchemaDataProvider"; import Executable from "./executable"; import { executableMixin } from "./executableMixin"; import Flavor from "./flavor"; @@ -19,7 +18,6 @@ export { Template, ApplicationRegistry, ContextProvider, - JSONSchemaDataProvider, executableMixin, flavorMixin, applicationMixin, diff --git a/tests/js/JSONSchemaFormDataProvider.test.ts b/tests/js/JSONSchemaFormDataProvider.test.ts index ba85c05..f9f79f8 100644 --- a/tests/js/JSONSchemaFormDataProvider.test.ts +++ b/tests/js/JSONSchemaFormDataProvider.test.ts @@ -1,68 +1,68 @@ -import { Name as ContextProviderName } from "@mat3ra/esse/dist/js/types"; -import { expect } from "chai"; +// import { Name as ContextProviderName } from "@mat3ra/esse/dist/js/types"; +// import { expect } from "chai"; -import JSONSchemaFormDataProvider from "../../src/js/context/JSONSchemaFormDataProvider"; +// import JSONSchemaFormDataProvider from "../../src/js/context/JSONSchemaFormDataProvider"; -describe("JSONSchemaFormDataProvider", () => { - const baseConfig = { - name: ContextProviderName.KGridFormDataManager, - }; +// describe("JSONSchemaFormDataProvider", () => { +// const baseConfig = { +// name: ContextProviderName.KGridFormDataManager, +// }; - it("respects isUsingJinjaVariables flag", () => { - const providerTrue = new JSONSchemaFormDataProvider({ - ...baseConfig, - isUsingJinjaVariables: true, - }); - const providerFalse = new JSONSchemaFormDataProvider({ - ...baseConfig, - isUsingJinjaVariables: false, - }); - const providerUndefined = new JSONSchemaFormDataProvider(baseConfig); +// it("respects isUsingJinjaVariables flag", () => { +// const providerTrue = new JSONSchemaFormDataProvider({ +// ...baseConfig, +// isUsingJinjaVariables: true, +// }); +// const providerFalse = new JSONSchemaFormDataProvider({ +// ...baseConfig, +// isUsingJinjaVariables: false, +// }); +// const providerUndefined = new JSONSchemaFormDataProvider(baseConfig); - expect(providerTrue.isUsingJinjaVariables).to.equal(true); - expect(providerFalse.isUsingJinjaVariables).to.equal(false); - expect(providerUndefined.isUsingJinjaVariables).to.equal(false); - }); +// expect(providerTrue.isUsingJinjaVariables).to.equal(true); +// expect(providerFalse.isUsingJinjaVariables).to.equal(false); +// expect(providerUndefined.isUsingJinjaVariables).to.equal(false); +// }); - it("returns styled uiSchema from uiSchemaStyled", () => { - const provider = new JSONSchemaFormDataProvider(baseConfig); +// it("returns styled uiSchema from uiSchemaStyled", () => { +// const provider = new JSONSchemaFormDataProvider(baseConfig); - // Monkey-patch abstract getters to avoid "Not implemented." errors - Object.defineProperty(provider, "uiSchema", { - get() { - return { - field1: { - "ui:widget": "text", - classNames: "original-class", - }, - field2: { - "ui:widget": "number", - }, - }; - }, - }); +// // Monkey-patch abstract getters to avoid "Not implemented." errors +// Object.defineProperty(provider, "uiSchema", { +// get() { +// return { +// field1: { +// "ui:widget": "text", +// classNames: "original-class", +// }, +// field2: { +// "ui:widget": "number", +// }, +// }; +// }, +// }); - Object.defineProperty(provider, "defaultFieldStyles", { - get() { - return { - "ui:options": { - label: true, - }, - }; - }, - }); +// Object.defineProperty(provider, "defaultFieldStyles", { +// get() { +// return { +// "ui:options": { +// label: true, +// }, +// }; +// }, +// }); - const styled = provider.uiSchemaStyled; +// const styled = provider.uiSchemaStyled; - expect(styled).to.have.property("field1"); - expect(styled).to.have.property("field2"); +// expect(styled).to.have.property("field1"); +// expect(styled).to.have.property("field2"); - expect(styled.field1["ui:widget"]).to.equal("text"); - expect(styled.field1["ui:options"]).to.deep.equal({ label: true }); - expect(styled.field1.classNames).to.equal("original-class"); +// expect(styled.field1["ui:widget"]).to.equal("text"); +// expect(styled.field1["ui:options"]).to.deep.equal({ label: true }); +// expect(styled.field1.classNames).to.equal("original-class"); - expect(styled.field2["ui:widget"]).to.equal("number"); - expect(styled.field2["ui:options"]).to.deep.equal({ label: true }); - expect(styled.field2.classNames).to.equal(""); - }); -}); +// expect(styled.field2["ui:widget"]).to.equal("number"); +// expect(styled.field2["ui:options"]).to.deep.equal({ label: true }); +// expect(styled.field2.classNames).to.equal(""); +// }); +// }); diff --git a/tests/js/JSONSchemaProvider.test.ts b/tests/js/JSONSchemaProvider.test.ts index aa1320a..54f2fb0 100644 --- a/tests/js/JSONSchemaProvider.test.ts +++ b/tests/js/JSONSchemaProvider.test.ts @@ -1,67 +1,67 @@ -import { Name as ContextProviderNameEnum } from "@mat3ra/esse/dist/js/types"; -import { expect } from "chai"; +// import { Name as ContextProviderNameEnum } from "@mat3ra/esse/dist/js/types"; +// import { expect } from "chai"; -import JSONSchemaDataProvider from "../../src/js/context/JSONSchemaDataProvider"; -import JSONSchemaFormDataProvider from "../../src/js/context/JSONSchemaFormDataProvider"; +// import JSONSchemaDataProvider from "../../src/js/context/JSONSchemaDataProvider"; +// import JSONSchemaFormDataProvider from "../../src/js/context/JSONSchemaFormDataProvider"; -describe("JSONSchemaDataProvider", () => { - it("should set isUsingJinjaVariables", () => { - const provider = new JSONSchemaDataProvider({ - name: ContextProviderNameEnum.KGridFormDataManager, - isUsingJinjaVariables: true, - }); - expect(provider.isUsingJinjaVariables).to.equal(true); - }); +// describe("JSONSchemaDataProvider", () => { +// it("should set isUsingJinjaVariables", () => { +// const provider = new JSONSchemaDataProvider({ +// name: ContextProviderNameEnum.KGridFormDataManager, +// isUsingJinjaVariables: true, +// }); +// expect(provider.isUsingJinjaVariables).to.equal(true); +// }); - it("should throw error when accessing jsonSchema", () => { - const provider = new JSONSchemaDataProvider({ - name: ContextProviderNameEnum.KGridFormDataManager, - }); - expect(() => provider.jsonSchema).to.throw("Not implemented."); - }); -}); +// it("should throw error when accessing jsonSchema", () => { +// const provider = new JSONSchemaDataProvider({ +// name: ContextProviderNameEnum.KGridFormDataManager, +// }); +// expect(() => provider.jsonSchema).to.throw("Not implemented."); +// }); +// }); -describe("JSONSchemaFormDataProvider", () => { - it("can be created", () => { - const provider = new JSONSchemaFormDataProvider({ - name: ContextProviderNameEnum.KGridFormDataManager, - }); - expect(provider).to.exist; - }); +// describe("JSONSchemaFormDataProvider", () => { +// it("can be created", () => { +// const provider = new JSONSchemaFormDataProvider({ +// name: ContextProviderNameEnum.KGridFormDataManager, +// }); +// expect(provider).to.exist; +// }); - it("should throw error when accessing uiSchema", () => { - const provider = new JSONSchemaFormDataProvider({ - name: ContextProviderNameEnum.KGridFormDataManager, - }); - expect(() => provider.uiSchema).to.throw("Not implemented."); - }); +// it("should throw error when accessing uiSchema", () => { +// const provider = new JSONSchemaFormDataProvider({ +// name: ContextProviderNameEnum.KGridFormDataManager, +// }); +// expect(() => provider.uiSchema).to.throw("Not implemented."); +// }); - it("should return empty fields object", () => { - const provider = new JSONSchemaFormDataProvider({ - name: ContextProviderNameEnum.KGridFormDataManager, - }); - expect(provider.fields).to.deep.equal({}); - }); +// it("should return empty fields object", () => { +// const provider = new JSONSchemaFormDataProvider({ +// name: ContextProviderNameEnum.KGridFormDataManager, +// }); +// expect(provider.fields).to.deep.equal({}); +// }); - it("should return empty defaultFieldStyles object", () => { - const provider = new JSONSchemaFormDataProvider({ - name: ContextProviderNameEnum.KGridFormDataManager, - }); - expect(provider.defaultFieldStyles).to.deep.equal({}); - }); +// it("should return empty defaultFieldStyles object", () => { +// const provider = new JSONSchemaFormDataProvider({ +// name: ContextProviderNameEnum.KGridFormDataManager, +// }); +// expect(provider.defaultFieldStyles).to.deep.equal({}); +// }); - it("should return uiSchemaStyled", () => { - class TestProvider extends JSONSchemaFormDataProvider { - // eslint-disable-next-line class-methods-use-this - get uiSchema() { - return { field1: { classNames: "test" }, field2: {} }; - } - } - const provider = new TestProvider({ - name: ContextProviderNameEnum.KGridFormDataManager, - }); - const styled = provider.uiSchemaStyled; - expect(styled).to.have.property("field1"); - expect(styled.field1).to.have.property("classNames", "test"); - }); -}); +// it("should return uiSchemaStyled", () => { +// class TestProvider extends JSONSchemaFormDataProvider { +// // eslint-disable-next-line class-methods-use-this +// get uiSchema() { +// return { field1: { classNames: "test" }, field2: {} }; +// } +// } +// const provider = new TestProvider({ +// name: ContextProviderNameEnum.KGridFormDataManager, +// }); +// const styled = provider.uiSchemaStyled; +// expect(styled).to.have.property("field1"); +// expect(styled.field1).to.have.property("classNames", "test"); +// }); +// }); From 562677d7b7d94a0ef66e43ea378716d308f46b15 Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Mon, 1 Dec 2025 23:17:31 +0200 Subject: [PATCH 10/16] chore: remove JSONSchemaDataProvider and JinjaContextProvider dist --- dist/js/context/JSONSchemaDataProvider.d.ts | 9 ----- dist/js/context/JSONSchemaDataProvider.js | 15 ------- .../context/JSONSchemaFormDataProvider.d.ts | 18 --------- dist/js/context/JSONSchemaFormDataProvider.js | 40 ------------------- dist/js/context/JinjaContextProvider.d.ts | 10 ----- dist/js/context/JinjaContextProvider.js | 13 ------ 6 files changed, 105 deletions(-) delete mode 100644 dist/js/context/JSONSchemaDataProvider.d.ts delete mode 100644 dist/js/context/JSONSchemaDataProvider.js delete mode 100644 dist/js/context/JSONSchemaFormDataProvider.d.ts delete mode 100644 dist/js/context/JSONSchemaFormDataProvider.js delete mode 100644 dist/js/context/JinjaContextProvider.d.ts delete mode 100644 dist/js/context/JinjaContextProvider.js diff --git a/dist/js/context/JSONSchemaDataProvider.d.ts b/dist/js/context/JSONSchemaDataProvider.d.ts deleted file mode 100644 index 58e9e8f..0000000 --- a/dist/js/context/JSONSchemaDataProvider.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { JSONSchema } from "@mat3ra/esse/dist/js/esse/utils"; -import JinjaContextProvider from "./JinjaContextProvider"; -/** - * @summary Provides jsonSchema only. - */ -declare abstract class JSONSchemaDataProvider extends JinjaContextProvider { - get jsonSchema(): JSONSchema; -} -export default JSONSchemaDataProvider; diff --git a/dist/js/context/JSONSchemaDataProvider.js b/dist/js/context/JSONSchemaDataProvider.js deleted file mode 100644 index a9c9bcb..0000000 --- a/dist/js/context/JSONSchemaDataProvider.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const JinjaContextProvider_1 = __importDefault(require("./JinjaContextProvider")); -/** - * @summary Provides jsonSchema only. - */ -class JSONSchemaDataProvider extends JinjaContextProvider_1.default { - get jsonSchema() { - throw new Error("Not implemented."); - } -} -exports.default = JSONSchemaDataProvider; diff --git a/dist/js/context/JSONSchemaFormDataProvider.d.ts b/dist/js/context/JSONSchemaFormDataProvider.d.ts deleted file mode 100644 index 349ad61..0000000 --- a/dist/js/context/JSONSchemaFormDataProvider.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type { UiSchema } from "react-jsonschema-form"; -import JSONSchemaDataProvider from "./JSONSchemaDataProvider"; -/** - * @summary Provides jsonSchema and uiSchema for generating react-jsonschema-form - * See https://github.com/mozilla-services/react-jsonschema-form for Form UI. - * Form generation example: - * ``` - * - * ``` - */ -export default class JSONSchemaFormDataProvider extends JSONSchemaDataProvider { - get uiSchema(): UiSchema; - get fields(): {}; - get defaultFieldStyles(): {}; - get uiSchemaStyled(): UiSchema; -} diff --git a/dist/js/context/JSONSchemaFormDataProvider.js b/dist/js/context/JSONSchemaFormDataProvider.js deleted file mode 100644 index e9454a2..0000000 --- a/dist/js/context/JSONSchemaFormDataProvider.js +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const JSONSchemaDataProvider_1 = __importDefault(require("./JSONSchemaDataProvider")); -/** - * @summary Provides jsonSchema and uiSchema for generating react-jsonschema-form - * See https://github.com/mozilla-services/react-jsonschema-form for Form UI. - * Form generation example: - * ``` - * - * ``` - */ -// TODO: MOVE to WebApp/ave or wove -class JSONSchemaFormDataProvider extends JSONSchemaDataProvider_1.default { - get uiSchema() { - throw new Error("Not implemented."); - } - get fields() { - return {}; - } - get defaultFieldStyles() { - return {}; - } - get uiSchemaStyled() { - const schema = this.uiSchema; - return Object.fromEntries(Object.entries(schema).map(([key, value]) => [ - key, - { - ...value, - ...this.defaultFieldStyles, - classNames: `${value.classNames || ""}`, - }, - ])); - } -} -exports.default = JSONSchemaFormDataProvider; diff --git a/dist/js/context/JinjaContextProvider.d.ts b/dist/js/context/JinjaContextProvider.d.ts deleted file mode 100644 index 68f0f86..0000000 --- a/dist/js/context/JinjaContextProvider.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { ContextProviderSchema } from "@mat3ra/esse/dist/js/types"; -import ContextProvider from "./ContextProvider"; -interface JSONSchemaDataProviderConfig extends ContextProviderSchema { - isUsingJinjaVariables?: boolean; -} -export default class JinjaContextProvider extends ContextProvider { - isUsingJinjaVariables: boolean; - constructor(config: JSONSchemaDataProviderConfig); -} -export {}; diff --git a/dist/js/context/JinjaContextProvider.js b/dist/js/context/JinjaContextProvider.js deleted file mode 100644 index d0adbb2..0000000 --- a/dist/js/context/JinjaContextProvider.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const ContextProvider_1 = __importDefault(require("./ContextProvider")); -class JinjaContextProvider extends ContextProvider_1.default { - constructor(config) { - super(config); - this.isUsingJinjaVariables = Boolean(config.isUsingJinjaVariables); - } -} -exports.default = JinjaContextProvider; From 704687a380527165579c6c271cae1676161eef0a Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Fri, 26 Dec 2025 19:15:07 +0200 Subject: [PATCH 11/16] update: remove template rendering logic --- dist/js/ApplicationRegistry.d.ts | 12 +- dist/js/ApplicationRegistry.js | 36 +-- dist/js/applicationMixin.d.ts | 2 +- dist/js/generated/TemplateSchemaMixin.js | 18 -- dist/js/index.d.ts | 11 +- dist/js/index.js | 20 +- dist/js/templateMixin.d.ts | 24 +- dist/js/templateMixin.js | 129 --------- package-lock.json | 12 +- package.json | 4 +- src/js/{application.ts => Application.ts} | 0 src/js/ApplicationRegistry.ts | 37 ++- src/js/{executable.ts => Executable.ts} | 0 src/js/{flavor.ts => Flavor.ts} | 0 src/js/{template.ts => Template.ts} | 0 src/js/applicationMixin.ts | 2 +- src/js/context/ContextProvider.ts | 155 ---------- .../ContextProviderRegistryContainer.ts | 41 --- src/js/generated/TemplateSchemaMixin.ts | 18 -- src/js/index.ts | 10 +- src/js/templateMixin.ts | 192 +----------- tests/js/ApplicationRegistry.test.ts | 63 +--- .../ContextProviderRegistryContainer.test.ts | 274 ------------------ tests/js/JSONSchemaFormDataProvider.test.ts | 68 ----- tests/js/JSONSchemaProvider.test.ts | 67 ----- tests/js/application.test.ts | 2 +- tests/js/executable.test.ts | 2 +- tests/js/flavor.test.ts | 2 +- tests/js/provider.tests.ts | 51 ---- tests/js/template.test.ts | 109 +------ 30 files changed, 91 insertions(+), 1270 deletions(-) rename src/js/{application.ts => Application.ts} (100%) rename src/js/{executable.ts => Executable.ts} (100%) rename src/js/{flavor.ts => Flavor.ts} (100%) rename src/js/{template.ts => Template.ts} (100%) delete mode 100644 src/js/context/ContextProvider.ts delete mode 100644 src/js/context/ContextProviderRegistryContainer.ts delete mode 100644 tests/js/ContextProviderRegistryContainer.test.ts delete mode 100644 tests/js/JSONSchemaFormDataProvider.test.ts delete mode 100644 tests/js/JSONSchemaProvider.test.ts delete mode 100644 tests/js/provider.tests.ts diff --git a/dist/js/ApplicationRegistry.d.ts b/dist/js/ApplicationRegistry.d.ts index b277021..2981f21 100644 --- a/dist/js/ApplicationRegistry.d.ts +++ b/dist/js/ApplicationRegistry.d.ts @@ -1,8 +1,8 @@ -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 { ApplicationSchemaBase, 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; }; @@ -51,7 +51,7 @@ export default class ApplicationRegistry { name: string; }): Flavor | undefined; static getInputAsTemplates(flavor: Flavor): Template[]; - static getInputAsRenderedTemplates(flavor: Flavor, context: Record): import("@mat3ra/esse/dist/js/esse/types").AnyObject[]; + static getInput(flavor: Flavor): TemplateSchema[]; static getAllFlavorsForApplication(appName: string, version?: string): Flavor[]; } export {}; diff --git a/dist/js/ApplicationRegistry.js b/dist/js/ApplicationRegistry.js index 989d3d4..b2fe069 100644 --- a/dist/js/ApplicationRegistry.js +++ b/dist/js/ApplicationRegistry.js @@ -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 }), @@ -115,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); @@ -125,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) { @@ -134,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, }); @@ -146,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)); diff --git a/dist/js/applicationMixin.d.ts b/dist/js/applicationMixin.d.ts index 9fa840d..3efc012 100644 --- a/dist/js/applicationMixin.d.ts +++ b/dist/js/applicationMixin.d.ts @@ -3,7 +3,7 @@ import type { Defaultable } from "@mat3ra/code/dist/js/entity/mixins/Defaultable 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"; +import Executable from "./Executable"; import { type ApplicationSchemaMixin } from "./generated/ApplicationSchemaMixin"; type Base = InMemoryEntity & NamedEntity & Defaultable; export type BaseConstructor = Constructor & { diff --git a/dist/js/generated/TemplateSchemaMixin.js b/dist/js/generated/TemplateSchemaMixin.js index 80d218c..b9c0916 100644 --- a/dist/js/generated/TemplateSchemaMixin.js +++ b/dist/js/generated/TemplateSchemaMixin.js @@ -28,30 +28,12 @@ function templateSchemaMixin(item) { set contextProviders(value) { this.setProp("contextProviders", value); }, - get isManuallyChanged() { - return this.prop("isManuallyChanged"); - }, - set isManuallyChanged(value) { - this.setProp("isManuallyChanged", value); - }, - get name() { - return this.requiredProp("name"); - }, - set name(value) { - this.setProp("name", value); - }, get content() { return this.requiredProp("content"); }, set content(value) { this.setProp("content", value); }, - get rendered() { - return this.prop("rendered"); - }, - set rendered(value) { - this.setProp("rendered", value); - }, }; Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); } diff --git a/dist/js/index.d.ts b/dist/js/index.d.ts index 4f8b77f..dcaa237 100644 --- a/dist/js/index.d.ts +++ b/dist/js/index.d.ts @@ -1,13 +1,12 @@ -import Application from "./application"; +import Application from "./Application"; import { applicationMixin } from "./applicationMixin"; import ApplicationRegistry from "./ApplicationRegistry"; -import ContextProvider from "./context/ContextProvider"; -import Executable from "./executable"; +import Executable from "./Executable"; import { executableMixin } from "./executableMixin"; -import Flavor from "./flavor"; +import Flavor from "./Flavor"; import { flavorMixin } from "./flavorMixin"; -import Template from "./template"; +import Template from "./Template"; import { templateMixin } from "./templateMixin"; declare const allApplications: string[]; -export { Application, Executable, Flavor, Template, ApplicationRegistry, ContextProvider, executableMixin, flavorMixin, applicationMixin, templateMixin, allApplications, }; +export { Application, Executable, Flavor, Template, ApplicationRegistry, executableMixin, flavorMixin, applicationMixin, templateMixin, allApplications, }; export type * from "./types"; diff --git a/dist/js/index.js b/dist/js/index.js index c97e90c..90d6fee 100644 --- a/dist/js/index.js +++ b/dist/js/index.js @@ -3,25 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.allApplications = exports.templateMixin = exports.applicationMixin = exports.flavorMixin = exports.executableMixin = exports.ContextProvider = exports.ApplicationRegistry = exports.Template = exports.Flavor = exports.Executable = exports.Application = void 0; -const application_1 = __importDefault(require("./application")); -exports.Application = application_1.default; +exports.allApplications = exports.templateMixin = exports.applicationMixin = exports.flavorMixin = exports.executableMixin = exports.ApplicationRegistry = exports.Template = exports.Flavor = exports.Executable = exports.Application = void 0; +const Application_1 = __importDefault(require("./Application")); +exports.Application = Application_1.default; const applicationMixin_1 = require("./applicationMixin"); Object.defineProperty(exports, "applicationMixin", { enumerable: true, get: function () { return applicationMixin_1.applicationMixin; } }); const ApplicationRegistry_1 = __importDefault(require("./ApplicationRegistry")); exports.ApplicationRegistry = ApplicationRegistry_1.default; -const ContextProvider_1 = __importDefault(require("./context/ContextProvider")); -exports.ContextProvider = ContextProvider_1.default; -const executable_1 = __importDefault(require("./executable")); -exports.Executable = executable_1.default; +const Executable_1 = __importDefault(require("./Executable")); +exports.Executable = Executable_1.default; const executableMixin_1 = require("./executableMixin"); Object.defineProperty(exports, "executableMixin", { enumerable: true, get: function () { return executableMixin_1.executableMixin; } }); -const flavor_1 = __importDefault(require("./flavor")); -exports.Flavor = flavor_1.default; +const Flavor_1 = __importDefault(require("./Flavor")); +exports.Flavor = Flavor_1.default; const flavorMixin_1 = require("./flavorMixin"); Object.defineProperty(exports, "flavorMixin", { enumerable: true, get: function () { return flavorMixin_1.flavorMixin; } }); -const template_1 = __importDefault(require("./template")); -exports.Template = template_1.default; +const Template_1 = __importDefault(require("./Template")); +exports.Template = Template_1.default; const templateMixin_1 = require("./templateMixin"); Object.defineProperty(exports, "templateMixin", { enumerable: true, get: function () { return templateMixin_1.templateMixin; } }); const allApplications = ApplicationRegistry_1.default.getUniqueAvailableApplicationNames(); diff --git a/dist/js/templateMixin.d.ts b/dist/js/templateMixin.d.ts index 593acf2..e04262a 100644 --- a/dist/js/templateMixin.d.ts +++ b/dist/js/templateMixin.d.ts @@ -1,30 +1,10 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; -import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types"; -import type { ContextProviderNameEnum, ContextProviderSchema, TemplateSchema } from "@mat3ra/esse/dist/js/types"; -import ContextProvider from "./context/ContextProvider"; -import ContextProviderRegistryContainer from "./context/ContextProviderRegistryContainer"; +import type { TemplateSchema } from "@mat3ra/esse/dist/js/types"; import { type TemplateSchemaMixin } from "./generated/TemplateSchemaMixin"; export type TemplateBase = InMemoryEntity; -export type TemplateMixin = TemplateSchemaMixin & { - render: (externalContext?: Record) => void; - getRenderedJSON: (context?: Record) => AnyObject; - _cleanRenderingContext: (object: Record) => Record; - getDataFromProvidersForRenderingContext: (context?: Record) => Record; - setContent: (text: string) => void; - setRendered: (text: string) => void; - getContextProvidersAsClassInstances: (providerContext?: Record) => ContextProvider[]; - getDataFromProvidersForPersistentContext: (providerContext?: Record) => Record; - getRenderingContext: (externalContext?: Record) => Record; -}; -export type ContextProviderConfigMapEntry = { - providerCls: typeof ContextProvider; - config: ContextProviderSchema; -}; -export type ContextProviderConfigMap = Partial>; +export type TemplateMixin = TemplateSchemaMixin; export type TemplateStaticMixin = { - contextProviderRegistry: ContextProviderRegistryContainer | null; - setContextProvidersConfig: (classConfigMap: ContextProviderConfigMap) => void; jsonSchema: TemplateSchema; }; export declare function templateStaticMixin(item: Constructor): void; diff --git a/dist/js/templateMixin.js b/dist/js/templateMixin.js index dfe849f..c821258 100644 --- a/dist/js/templateMixin.js +++ b/dist/js/templateMixin.js @@ -6,146 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.templateStaticMixin = templateStaticMixin; exports.templateMixin = templateMixin; const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -const utils_1 = require("@mat3ra/utils"); -const nunjucks_1 = __importDefault(require("nunjucks")); -const ContextProviderRegistryContainer_1 = __importDefault(require("./context/ContextProviderRegistryContainer")); const TemplateSchemaMixin_1 = require("./generated/TemplateSchemaMixin"); -function templatePropertiesMixin(item) { - // @ts-expect-error - const properties = { - setContent(text) { - this.content = text; - if (!this.rendered) { - this.rendered = text; - } - }, - setRendered(text) { - this.rendered = text; - }, - // addContextProvider(provider: ContextProvider) { - // this.setProp("contextProviders", [...this.contextProviders, provider]); - // }, - // removeContextProvider(provider: ContextProvider) { - // const contextProviders = this.contextProviders.filter((p) => { - // return p.name !== provider.name && p.domain !== provider.domain; - // }); - // this.setProp("contextProviders", contextProviders); - // }, - render(externalContext) { - const renderingContext = this.getRenderingContext(externalContext); - if (!this.isManuallyChanged) { - try { - const template = nunjucks_1.default.compile(this.content); - // deepClone to pass JSON data without classes - const rendered = template.render(this._cleanRenderingContext(renderingContext)); - this.setRendered(this.isManuallyChanged ? rendered : rendered || this.content); - } - catch (e) { - console.log(`Template is not compiled: ${e}`); - console.log({ - content: this.content, - _cleanRenderingContext: this._cleanRenderingContext(renderingContext), - }); - } - } - }, - getRenderedJSON(context) { - this.render(context); - return this.toJSON(); - }, - // Remove "bulky" items and JSON stringify before passing it to rendering engine (eg. jinja) to compile. - // This way the context should still be passed in full to contextProviders, but not to final text template. - // eslint-disable-next-line class-methods-use-this - _cleanRenderingContext(object) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { job, ...clone } = object; - return utils_1.Utils.clone.deepClone(clone); - }, - /* - * @summary Initializes context provider class instances. `providerContext` is used to pass the data about any - * previously stored values. That is if data was previously saved in database, the context provider - * shall receive it on initialization through providerContext and prioritize this value over the default. - */ - getContextProvidersAsClassInstances(providerContext) { - return this.contextProviders.map((p) => { - var _a; - const providerInstance = (_a = this.constructor.contextProviderRegistry) === null || _a === void 0 ? void 0 : _a.findProviderInstanceByName(p.name); - if (!providerInstance) { - throw new Error(`Provider ${p.name} not found`); - } - const clsInstance = new providerInstance.constructor({ - ...providerInstance.config, - context: providerContext, - }); - return clsInstance; - }); - }, - /* - * @summary Extracts the the data from all context providers for further use during render. - */ - getDataFromProvidersForRenderingContext(providerContext) { - const result = {}; - this.getContextProvidersAsClassInstances(providerContext).forEach((contextProvider) => { - const context = contextProvider.yieldDataForRendering(); - Object.keys(context).forEach((key) => { - // merge context keys if they are objects otherwise override them. - result[key] = - result[key] !== null && typeof result[key] === "object" - ? // @ts-ignore - { ...result[key], ...context[key] } - : context[key]; - }); - }); - return result; - }, - /* - * @summary Extracts the the data from all context providers for further save in persistent context. - */ - // TODO: optimize logic to prevent re-initializing the context provider classes again below, reuse above function - getDataFromProvidersForPersistentContext(providerContext) { - const result = {}; - this.getContextProvidersAsClassInstances(providerContext).forEach((contextProvider) => { - // only save in the persistent context the data from providers that were edited (or able to be edited) - Object.assign(result, contextProvider.isEdited ? contextProvider.yieldData() : {}); - }); - return result; - }, - /* - * @summary Combines rendering context (in order of preference): - * - context from templates initialized with external context - * - "external" context and - */ - getRenderingContext(externalContext) { - return { - ...externalContext, - ...this.getDataFromProvidersForRenderingContext(externalContext), - }; - }, - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} function templateStaticMixin(item) { // @ts-ignore const properties = { - contextProviderRegistry: null, get jsonSchema() { return JSONSchemasInterface_1.default.getSchemaById("software/template"); }, - setContextProvidersConfig(classConfigMap) { - const contextProviderRegistry = new ContextProviderRegistryContainer_1.default(); - Object.entries(classConfigMap).forEach(([name, { providerCls, config }]) => { - contextProviderRegistry.addProvider({ - instance: providerCls.getConstructorConfig(config), - name, - }); - }); - this.contextProviderRegistry = contextProviderRegistry; - }, }; Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); } function templateMixin(Item) { (0, TemplateSchemaMixin_1.templateSchemaMixin)(Item.prototype); - templatePropertiesMixin(Item.prototype); templateStaticMixin(Item); } diff --git a/package-lock.json b/package-lock.json index 68ac3ae..23ee86f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,8 +17,8 @@ "devDependencies": { "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", - "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#5803c543e812727ad32dffefd1426497694a427b", - "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#1b47917bb8feadf49c46d8aa4b33a4255a06788a", + "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#cf4115b459e7d308e708b606adfca7918185e525", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#aa1aefcfadb1643c69b43deadaafad08ca6d807c", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", @@ -3195,8 +3195,8 @@ }, "node_modules/@mat3ra/code": { "version": "0.0.0", - "resolved": "git+ssh://git@github.com/Exabyte-io/code.git#5803c543e812727ad32dffefd1426497694a427b", - "integrity": "sha512-z/9Bipd5XEKBj3/KqxuB4XHshxEkVrmLp41NOwVf96ny9two9lpUapkpzFWdM5uypYm76au04//p59Oo7GWRPQ==", + "resolved": "git+ssh://git@github.com/Exabyte-io/code.git#cf4115b459e7d308e708b606adfca7918185e525", + "integrity": "sha512-LWw+caG75Z4nNHinKcKOUXzeFwZHNPXlJ9Lm6/wVJ4Y7He7mNf5YQfkYSVbctWWzYAi4IlH34ZSb6tyTS0FCCw==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -3235,8 +3235,8 @@ }, "node_modules/@mat3ra/esse": { "version": "0.0.0", - "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#1b47917bb8feadf49c46d8aa4b33a4255a06788a", - "integrity": "sha512-TEiTzxWwdpSKjKCZdT72917riOPDVAgENFQ9WXhVVbYrOwDmv5Ia0irvP3XlHrfgvmtJW02P/Voib/+zekVwBg==", + "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#aa1aefcfadb1643c69b43deadaafad08ca6d807c", + "integrity": "sha512-WThYT68q2lbV69D7qeEoIM33tsr6BHH44EemqKTythIwoVyyCViYAI/+i+L0ttE76lq1cMG+YoYJLYeeJXJb4A==", "dev": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index b53d4fd..62ca140 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/utils": "2025.9.20-0", - "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#5803c543e812727ad32dffefd1426497694a427b", - "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#1b47917bb8feadf49c46d8aa4b33a4255a06788a", + "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#cf4115b459e7d308e708b606adfca7918185e525", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#aa1aefcfadb1643c69b43deadaafad08ca6d807c", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", diff --git a/src/js/application.ts b/src/js/Application.ts similarity index 100% rename from src/js/application.ts rename to src/js/Application.ts diff --git a/src/js/ApplicationRegistry.ts b/src/js/ApplicationRegistry.ts index 5c04830..d436145 100644 --- a/src/js/ApplicationRegistry.ts +++ b/src/js/ApplicationRegistry.ts @@ -1,11 +1,15 @@ import { getOneMatchFromObject } from "@mat3ra/code/dist/js/utils/object"; -import type { ApplicationSchemaBase, ExecutableSchema } from "@mat3ra/esse/dist/js/types"; +import type { + ApplicationSchemaBase, + ExecutableSchema, + TemplateSchema, +} from "@mat3ra/esse/dist/js/types"; import { ApplicationStandata } from "@mat3ra/standata"; -import Application from "./application"; -import Executable from "./executable"; -import Flavor from "./flavor"; -import Template from "./template"; +import Application from "./Application"; +import Executable from "./Executable"; +import Flavor from "./Flavor"; +import Template from "./Template"; type ApplicationVersion = { [build: string]: ApplicationSchemaBase; @@ -213,12 +217,15 @@ export default class ApplicationRegistry { return this.getFlavorByName(executable, config?.name); } - // flavors static getInputAsTemplates(flavor: Flavor) { - const appName = flavor.prop("applicationName", ""); - const execName = flavor.prop("executableName", ""); + return this.getInput(flavor).map((template) => new Template(template)); + } + + static getInput(flavor: Flavor): TemplateSchema[] { + const appName = flavor.applicationName || ""; + const execName = flavor.executableName || ""; - return flavor.input.map((input) => { + return flavor.input.map((input): TemplateSchema => { const inputName = input.templateName || input.name; const filtered = new ApplicationStandata().getTemplatesByName( @@ -233,15 +240,15 @@ export default class ApplicationRegistry { ); } - return new Template({ ...filtered[0], name: input.name }); + return { ...filtered[0], name: input.name || "" }; }); } - static getInputAsRenderedTemplates(flavor: Flavor, context: Record) { - return this.getInputAsTemplates(flavor).map((template) => { - return template.getRenderedJSON(context); - }); - } + // static getInputAsRenderedTemplates(flavor: Flavor, context: ContextProviderConfig) { + // return this.getInputAsTemplates(flavor).map((template) => { + // return template.setContext(context).render().toJSON(); + // }); + // } static getAllFlavorsForApplication(appName: string, version?: string) { const allExecutables = this.getExecutables({ name: appName, version }); diff --git a/src/js/executable.ts b/src/js/Executable.ts similarity index 100% rename from src/js/executable.ts rename to src/js/Executable.ts diff --git a/src/js/flavor.ts b/src/js/Flavor.ts similarity index 100% rename from src/js/flavor.ts rename to src/js/Flavor.ts diff --git a/src/js/template.ts b/src/js/Template.ts similarity index 100% rename from src/js/template.ts rename to src/js/Template.ts diff --git a/src/js/applicationMixin.ts b/src/js/applicationMixin.ts index 982629a..16e1c52 100644 --- a/src/js/applicationMixin.ts +++ b/src/js/applicationMixin.ts @@ -6,7 +6,7 @@ import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface import type { ApplicationSchemaBase } from "@mat3ra/esse/dist/js/types"; import { ApplicationStandata } from "@mat3ra/standata"; -import Executable from "./executable"; +import Executable from "./Executable"; import { type ApplicationSchemaMixin, applicationSchemaMixin, diff --git a/src/js/context/ContextProvider.ts b/src/js/context/ContextProvider.ts deleted file mode 100644 index 3bd6c87..0000000 --- a/src/js/context/ContextProvider.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* - * @summary This is a standalone class that contains "data" for a property with "name". Helps facilitate UI logic. - * Can be initialized from context when user edits are present: - * - user edits the corresponding property, eg. "kpath" - * - isKpathEdited is set to `true` - * - context property is updated for the parent entity (eg. Unit) in a way that persists in Redux state - * - new entity inherits the "data" through "context" field in config - * - `extraData` field is used to store any other data that should be passed from one instance of provider - * to next one, for example data about material to track when it is changed. - * @notes Should hold static data only (see `setData` method), no classes or functions - */ -import { ContextProviderSchema, Name as ContextProviderNameEnum } from "@mat3ra/esse/dist/js/types"; -import { Utils } from "@mat3ra/utils"; -import lodash from "lodash"; - -export interface ContextProviderInstance { - constructor: typeof ContextProvider; - config: ContextProviderSchema; -} - -export interface ContextProviderStatic { - getConstructorConfig: (config: ContextProviderSchema) => ContextProviderInstance; - createConfigFromContext: (config: ContextProviderSchema) => ContextProviderSchema; - getExtraDataKeyByName: (name: string) => string; - getIsEditedKeyByName: (name: string) => string; -} - -export default class ContextProvider implements ContextProviderSchema { - config: ContextProviderSchema; - - name: ContextProviderNameEnum; - - domain?: string; - - entityName?: string; - - data?: object; - - extraData?: object; - - isEdited?: boolean; - - context?: object; - - [k: string]: unknown; - - constructor(config: ContextProviderSchema) { - this.config = config; - this.name = config.name; // property name, ie. "kpath" - this.domain = config.domain || "default"; - - // if context is passed inside config, treat it as additional config - // eslint-disable-next-line no-param-reassign - if (config.context) config = ContextProvider.createConfigFromContext(config); - - this.entityName = config.entityName || "unit"; // entity this provider yields data to, eg. "unit", "subworkflow" - this.data = config.data; // property data container - this.extraData = config.extraData; // property extraData container, used track changes to data, for example - this.isEdited = config.isEdited; // whether property was edited by user, available under `isEdited` key - - this.setIsEdited = this.setIsEdited.bind(this); - this.getData = this.getData.bind(this); - this.setData = this.setData.bind(this); - this.transformData = this.transformData.bind(this); - this.yieldData = this.yieldData.bind(this); - } - - static getConstructorConfig(config: ContextProviderSchema): ContextProviderInstance { - return { - constructor: this.prototype.constructor as typeof ContextProvider, - config, - }; - } - - static createConfigFromContext(config: ContextProviderSchema) { - const data = lodash.get(config.context, config.name); - const isEdited = lodash.get(config.context, this.getIsEditedKeyByName(config.name)); - const extraData = lodash.get(config.context, this.getExtraDataKeyByName(config.name)); - return Object.assign( - config, - data - ? { - data, - extraData, - isEdited, - } - : {}, - ); - } - - setIsEdited(isEdited: boolean) { - this.isEdited = isEdited; - } - - getData() { - return this.isEdited ? this.data : this.defaultData; - } - - setData(data: object) { - this.data = Utils.clone.deepClone(data); - } - - // override in children - // eslint-disable-next-line class-methods-use-this - get defaultData(): object { - throw new Error("Not implemented."); - } - - // override in children - // eslint-disable-next-line class-methods-use-this - transformData(data: object) { - return data; - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - yieldData(...transformDataArgs: any) { - const extraDataObject = this.extraData ? { [this.extraDataKey]: this.extraData } : {}; - return { - ...extraDataObject, - // @ts-ignore - [this.name]: this.transformData(this.getData(), ...transformDataArgs), - [this.isEditedKey]: this.isEdited, - }; - } - - // override when this.data needs additional processing before making it available to rendering context - // used to calculate explicit points path, for example - yieldDataForRendering() { - return this.yieldData(); - } - - get extraDataKey() { - return `${this.name}ExtraData`; - } - - static getExtraDataKeyByName(name: string) { - return `${name}ExtraData`; - } - - get isEditedKey() { - return `is${lodash.capitalize(this.name)}Edited`; - } - - static getIsEditedKeyByName(name: string) { - return `is${lodash.capitalize(name)}Edited`; - } - - get isUnitContextProvider() { - return this.entityName === "unit"; - } - - get isSubworkflowContextProvider() { - return this.entityName === "subworkflow"; - } -} diff --git a/src/js/context/ContextProviderRegistryContainer.ts b/src/js/context/ContextProviderRegistryContainer.ts deleted file mode 100644 index 159af9e..0000000 --- a/src/js/context/ContextProviderRegistryContainer.ts +++ /dev/null @@ -1,41 +0,0 @@ -import type { ContextProviderInstance } from "./ContextProvider"; -import ContextProvider from "./ContextProvider"; - -export default class ContextProviderRegistryContainer { - _providers: { - name: string; - instance: ContextProviderInstance; - }[]; - - constructor() { - this._providers = []; - } - - get providers() { - return this._providers; - } - - set providers(p) { - this._providers = p; - } - - addProvider({ name, instance }: { name: string; instance: ContextProviderInstance }) { - this._providers.push({ - name, - instance, - }); - } - - findProviderInstanceByName(name: string) { - const provider = this.providers.find((p) => p.name === name); - return provider && provider.instance; - } - - removeProvider(providerCls: ContextProvider) { - this.providers = this.providers.filter((p) => p.name !== providerCls.name); - } - - removeProviderByName(name: string) { - this.providers = this.providers.filter((p) => p.name !== name); - } -} diff --git a/src/js/generated/TemplateSchemaMixin.ts b/src/js/generated/TemplateSchemaMixin.ts index 7fa58fe..276af42 100644 --- a/src/js/generated/TemplateSchemaMixin.ts +++ b/src/js/generated/TemplateSchemaMixin.ts @@ -38,30 +38,12 @@ export function templateSchemaMixin( set contextProviders(value: TemplatePropertiesSchema["contextProviders"]) { this.setProp("contextProviders", value); }, - get isManuallyChanged() { - return this.prop("isManuallyChanged"); - }, - set isManuallyChanged(value: TemplatePropertiesSchema["isManuallyChanged"]) { - this.setProp("isManuallyChanged", value); - }, - get name() { - return this.requiredProp("name"); - }, - set name(value: TemplatePropertiesSchema["name"]) { - this.setProp("name", value); - }, get content() { return this.requiredProp("content"); }, set content(value: TemplatePropertiesSchema["content"]) { this.setProp("content", value); }, - get rendered() { - return this.prop("rendered"); - }, - set rendered(value: TemplatePropertiesSchema["rendered"]) { - this.setProp("rendered", value); - }, }; Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); diff --git a/src/js/index.ts b/src/js/index.ts index f0f0991..a869848 100644 --- a/src/js/index.ts +++ b/src/js/index.ts @@ -1,12 +1,11 @@ -import Application from "./application"; +import Application from "./Application"; import { applicationMixin } from "./applicationMixin"; import ApplicationRegistry from "./ApplicationRegistry"; -import ContextProvider from "./context/ContextProvider"; -import Executable from "./executable"; +import Executable from "./Executable"; import { executableMixin } from "./executableMixin"; -import Flavor from "./flavor"; +import Flavor from "./Flavor"; import { flavorMixin } from "./flavorMixin"; -import Template from "./template"; +import Template from "./Template"; import { templateMixin } from "./templateMixin"; const allApplications = ApplicationRegistry.getUniqueAvailableApplicationNames(); @@ -17,7 +16,6 @@ export { Flavor, Template, ApplicationRegistry, - ContextProvider, executableMixin, flavorMixin, applicationMixin, diff --git a/src/js/templateMixin.ts b/src/js/templateMixin.ts index c887578..071f9d4 100644 --- a/src/js/templateMixin.ts +++ b/src/js/templateMixin.ts @@ -1,211 +1,24 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface"; -import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types"; -import type { - ContextProviderNameEnum, - ContextProviderSchema, - TemplateSchema, -} from "@mat3ra/esse/dist/js/types"; -import { Utils } from "@mat3ra/utils"; -import nunjucks from "nunjucks"; +import type { TemplateSchema } from "@mat3ra/esse/dist/js/types"; -import ContextProvider from "./context/ContextProvider"; -import ContextProviderRegistryContainer from "./context/ContextProviderRegistryContainer"; import { type TemplateSchemaMixin, templateSchemaMixin } from "./generated/TemplateSchemaMixin"; export type TemplateBase = InMemoryEntity; -export type TemplateMixin = TemplateSchemaMixin & { - // addContextProvider: (provider: ContextProvider) => void; - // removeContextProvider: (provider: ContextProvider) => void; - render: (externalContext?: Record) => void; - getRenderedJSON: (context?: Record) => AnyObject; - _cleanRenderingContext: (object: Record) => Record; - getDataFromProvidersForRenderingContext: ( - context?: Record, - ) => Record; - setContent: (text: string) => void; - setRendered: (text: string) => void; - getContextProvidersAsClassInstances: ( - providerContext?: Record, - ) => ContextProvider[]; - getDataFromProvidersForPersistentContext: ( - providerContext?: Record, - ) => Record; - getRenderingContext: (externalContext?: Record) => Record; -}; - -export type ContextProviderConfigMapEntry = { - providerCls: typeof ContextProvider; - config: ContextProviderSchema; -}; - -export type ContextProviderConfigMap = Partial< - Record ->; +export type TemplateMixin = TemplateSchemaMixin; export type TemplateStaticMixin = { - contextProviderRegistry: ContextProviderRegistryContainer | null; - setContextProvidersConfig: (classConfigMap: ContextProviderConfigMap) => void; jsonSchema: TemplateSchema; }; -function templatePropertiesMixin(item: InMemoryEntity) { - // @ts-expect-error - const properties: TemplateMixin & TemplateBase = { - setContent(text: string) { - this.content = text; - if (!this.rendered) { - this.rendered = text; - } - }, - - setRendered(text: string) { - this.rendered = text; - }, - - // addContextProvider(provider: ContextProvider) { - // this.setProp("contextProviders", [...this.contextProviders, provider]); - // }, - - // removeContextProvider(provider: ContextProvider) { - // const contextProviders = this.contextProviders.filter((p) => { - // return p.name !== provider.name && p.domain !== provider.domain; - // }); - - // this.setProp("contextProviders", contextProviders); - // }, - - render(externalContext?: Record) { - const renderingContext = this.getRenderingContext(externalContext); - if (!this.isManuallyChanged) { - try { - const template = nunjucks.compile(this.content); - - // deepClone to pass JSON data without classes - const rendered = template.render( - this._cleanRenderingContext(renderingContext), - ) as string; - - this.setRendered(this.isManuallyChanged ? rendered : rendered || this.content); - } catch (e) { - console.log(`Template is not compiled: ${e}`); - console.log({ - content: this.content, - _cleanRenderingContext: this._cleanRenderingContext(renderingContext), - }); - } - } - }, - - getRenderedJSON(context?: Record) { - this.render(context); - return this.toJSON(); - }, - - // Remove "bulky" items and JSON stringify before passing it to rendering engine (eg. jinja) to compile. - // This way the context should still be passed in full to contextProviders, but not to final text template. - // eslint-disable-next-line class-methods-use-this - _cleanRenderingContext(object: Record) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { job, ...clone } = object; - return Utils.clone.deepClone(clone); - }, - - /* - * @summary Initializes context provider class instances. `providerContext` is used to pass the data about any - * previously stored values. That is if data was previously saved in database, the context provider - * shall receive it on initialization through providerContext and prioritize this value over the default. - */ - getContextProvidersAsClassInstances(providerContext?: Record) { - return this.contextProviders.map((p) => { - const providerInstance = ( - this.constructor as unknown as TemplateStaticMixin - ).contextProviderRegistry?.findProviderInstanceByName(p.name); - - if (!providerInstance) { - throw new Error(`Provider ${p.name} not found`); - } - - const clsInstance = new providerInstance.constructor({ - ...providerInstance.config, - context: providerContext, - }); - - return clsInstance; - }); - }, - - /* - * @summary Extracts the the data from all context providers for further use during render. - */ - getDataFromProvidersForRenderingContext(providerContext?: Record) { - const result: AnyObject = {}; - this.getContextProvidersAsClassInstances(providerContext).forEach((contextProvider) => { - const context = contextProvider.yieldDataForRendering(); - Object.keys(context).forEach((key) => { - // merge context keys if they are objects otherwise override them. - result[key] = - result[key] !== null && typeof result[key] === "object" - ? // @ts-ignore - { ...result[key], ...context[key] } - : context[key]; - }); - }); - return result; - }, - - /* - * @summary Extracts the the data from all context providers for further save in persistent context. - */ - // TODO: optimize logic to prevent re-initializing the context provider classes again below, reuse above function - getDataFromProvidersForPersistentContext(providerContext?: Record) { - const result = {}; - this.getContextProvidersAsClassInstances(providerContext).forEach((contextProvider) => { - // only save in the persistent context the data from providers that were edited (or able to be edited) - Object.assign(result, contextProvider.isEdited ? contextProvider.yieldData() : {}); - }); - return result; - }, - - /* - * @summary Combines rendering context (in order of preference): - * - context from templates initialized with external context - * - "external" context and - */ - getRenderingContext(externalContext?: Record) { - return { - ...externalContext, - ...this.getDataFromProvidersForRenderingContext(externalContext), - }; - }, - }; - - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} - export function templateStaticMixin(item: Constructor) { // @ts-ignore const properties: TemplateStaticMixin & Constructor = { - contextProviderRegistry: null, - get jsonSchema() { return JSONSchemasInterface.getSchemaById("software/template") as TemplateSchema; }, - - setContextProvidersConfig(classConfigMap: ContextProviderConfigMap) { - const contextProviderRegistry = new ContextProviderRegistryContainer(); - - Object.entries(classConfigMap).forEach(([name, { providerCls, config }]) => { - contextProviderRegistry.addProvider({ - instance: providerCls.getConstructorConfig(config), - name, - }); - }); - - this.contextProviderRegistry = contextProviderRegistry; - }, }; Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); @@ -213,6 +26,5 @@ export function templateStaticMixin(item: Constructor) { export function templateMixin(Item: Constructor) { templateSchemaMixin(Item.prototype); - templatePropertiesMixin(Item.prototype); templateStaticMixin(Item); } diff --git a/tests/js/ApplicationRegistry.test.ts b/tests/js/ApplicationRegistry.test.ts index 22da031..7d6023a 100644 --- a/tests/js/ApplicationRegistry.test.ts +++ b/tests/js/ApplicationRegistry.test.ts @@ -1,40 +1,18 @@ /* eslint-disable no-unused-expressions */ -import { Name as ContextProviderNameEnum } from "@mat3ra/esse/dist/js/types"; import { expect } from "chai"; -import type { ContextProviderConfigMapEntry } from "src/js/templateMixin"; -import Application from "../../src/js/application"; +import Application from "../../src/js/Application"; import type { CreateApplicationConfig } from "../../src/js/ApplicationRegistry"; import ApplicationRegistry from "../../src/js/ApplicationRegistry"; -import ContextProvider from "../../src/js/context/ContextProvider"; -import Executable from "../../src/js/executable"; -import Flavor from "../../src/js/flavor"; -import Template from "../../src/js/template"; - -class MockContextProvider extends ContextProvider { - // eslint-disable-next-line class-methods-use-this - get defaultData() { - return { test: "value" }; - } -} +import Executable from "../../src/js/Executable"; +import Flavor from "../../src/js/Flavor"; +import Template from "../../src/js/Template"; describe("ApplicationRegistry", () => { beforeEach(() => { // Reset static properties before each test ApplicationRegistry.applicationsTree = undefined; ApplicationRegistry.applicationsArray = undefined; - - const mockConfig: ContextProviderConfigMapEntry = { - providerCls: MockContextProvider, - config: { name: ContextProviderNameEnum.QGridFormDataManager }, - }; - - Template.setContextProvidersConfig({ - QGridFormDataManager: mockConfig, - PlanewaveCutoffDataManager: mockConfig, - KGridFormDataManager: mockConfig, - QEPWXInputDataManager: mockConfig, - }); }); describe("createApplication", () => { @@ -377,39 +355,6 @@ describe("ApplicationRegistry", () => { }); }); - describe("getInputAsRenderedTemplates", () => { - it("should return rendered templates for flavor input", () => { - const executable = ApplicationRegistry.getExecutableByName("espresso", "pw.x"); - const flavor = ApplicationRegistry.getFlavorByName(executable, "pw_scf"); - - if (flavor) { - const context = { test: "value" }; - const renderedTemplates = ApplicationRegistry.getInputAsRenderedTemplates( - flavor, - context, - ); - - expect(renderedTemplates).to.be.an("array"); - renderedTemplates.forEach((template) => { - expect(template).to.be.an("object"); - }); - } - }); - - it("should handle empty context", () => { - const executable = ApplicationRegistry.getExecutableByName("espresso", "pw.x"); - const flavor = ApplicationRegistry.getFlavorByName(executable, "pw_scf"); - - if (!flavor) { - throw new Error("Flavor not found"); - } - - const renderedTemplates = ApplicationRegistry.getInputAsRenderedTemplates(flavor, {}); - - expect(renderedTemplates).to.be.an("array"); - }); - }); - describe("getAllFlavorsForApplication", () => { it("should return all flavors for application without version filter", () => { const flavors = ApplicationRegistry.getAllFlavorsForApplication("espresso"); diff --git a/tests/js/ContextProviderRegistryContainer.test.ts b/tests/js/ContextProviderRegistryContainer.test.ts deleted file mode 100644 index 1405900..0000000 --- a/tests/js/ContextProviderRegistryContainer.test.ts +++ /dev/null @@ -1,274 +0,0 @@ -import { Name as ContextProviderNameEnum } from "@mat3ra/esse/dist/js/types"; -import { expect } from "chai"; - -import ContextProvider, { - type ContextProviderInstance, -} from "../../src/js/context/ContextProvider"; -import ContextProviderRegistryContainer from "../../src/js/context/ContextProviderRegistryContainer"; - -// Mock context provider for testing -class MockContextProvider extends ContextProvider { - // eslint-disable-next-line class-methods-use-this - get defaultData() { - return { test: "value" }; - } -} - -describe("ContextProviderRegistryContainer", () => { - let container: ContextProviderRegistryContainer; - let mockProviderInstance: ContextProviderInstance; - - beforeEach(() => { - container = new ContextProviderRegistryContainer(); - mockProviderInstance = { - constructor: MockContextProvider, - config: { name: ContextProviderNameEnum.QGridFormDataManager }, - }; - }); - - describe("constructor", () => { - it("should initialize with empty providers array", () => { - expect(container.providers).to.deep.equal([]); - }); - }); - - describe("providers getter and setter", () => { - it("should get providers array", () => { - expect(container.providers).to.be.an("array"); - }); - - it("should set providers array", () => { - const newProviders = [ - { name: "provider1", instance: mockProviderInstance }, - { name: "provider2", instance: mockProviderInstance }, - ]; - container.providers = newProviders; - expect(container.providers).to.deep.equal(newProviders); - }); - }); - - describe("addProvider", () => { - it("should add a provider to the registry", () => { - container.addProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - instance: mockProviderInstance, - }); - expect(container.providers).to.have.length(1); - expect(container.providers[0]).to.deep.equal({ - name: ContextProviderNameEnum.QGridFormDataManager, - instance: mockProviderInstance, - }); - }); - - it("should add multiple providers", () => { - const provider2 = { - constructor: MockContextProvider, - config: { name: ContextProviderNameEnum.PlanewaveCutoffDataManager }, - }; - - container.addProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - instance: mockProviderInstance, - }); - container.addProvider({ - name: ContextProviderNameEnum.PlanewaveCutoffDataManager, - instance: provider2, - }); - - expect(container.providers).to.have.length(2); - expect(container.providers[0].name).to.equal( - ContextProviderNameEnum.QGridFormDataManager, - ); - expect(container.providers[1].name).to.equal( - ContextProviderNameEnum.PlanewaveCutoffDataManager, - ); - }); - }); - - describe("findProviderInstanceByName", () => { - it("should find provider instance by name", () => { - container.addProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - instance: mockProviderInstance, - }); - - const found = container.findProviderInstanceByName( - ContextProviderNameEnum.QGridFormDataManager, - ); - expect(found).to.equal(mockProviderInstance); - }); - - it("should return undefined for non-existent provider", () => { - const found = container.findProviderInstanceByName( - ContextProviderNameEnum.KGridFormDataManager, - ); - expect(found).to.be.undefined; - }); - - it("should find provider when multiple providers exist", () => { - const provider2 = { - constructor: MockContextProvider, - config: { name: ContextProviderNameEnum.PlanewaveCutoffDataManager }, - }; - - container.addProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - instance: mockProviderInstance, - }); - container.addProvider({ - name: ContextProviderNameEnum.PlanewaveCutoffDataManager, - instance: provider2, - }); - - const found = container.findProviderInstanceByName( - ContextProviderNameEnum.PlanewaveCutoffDataManager, - ); - expect(found).to.equal(provider2); - }); - }); - - describe("removeProvider", () => { - it("should remove provider by ContextProvider instance", () => { - container.addProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - instance: mockProviderInstance, - }); - - const providerInstance = new MockContextProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - }); - container.removeProvider(providerInstance); - - // The removeProvider method should remove the matching provider - expect(container.providers).to.have.length(0); - }); - - it("should remove only the matching provider", () => { - const provider2 = { - constructor: MockContextProvider, - config: { name: ContextProviderNameEnum.PlanewaveCutoffDataManager }, - }; - - container.addProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - instance: mockProviderInstance, - }); - container.addProvider({ - name: ContextProviderNameEnum.PlanewaveCutoffDataManager, - instance: provider2, - }); - - const providerInstance = new MockContextProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - }); - container.removeProvider(providerInstance); - - // The removeProvider method should remove the matching provider - expect(container.providers).to.have.length(1); - expect(container.providers[0].name).to.equal( - ContextProviderNameEnum.PlanewaveCutoffDataManager, - ); - }); - - it("should not remove anything if provider not found", () => { - container.addProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - instance: mockProviderInstance, - }); - - const nonExistentProvider = new MockContextProvider({ - name: ContextProviderNameEnum.KGridFormDataManager, - }); - container.removeProvider(nonExistentProvider); - - expect(container.providers).to.have.length(1); - }); - }); - - describe("removeProviderByName", () => { - it("should remove provider by name", () => { - container.addProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - instance: mockProviderInstance, - }); - - expect(container.providers).to.have.length(1); - - container.removeProviderByName(ContextProviderNameEnum.QGridFormDataManager); - - expect(container.providers).to.have.length(0); - }); - - it("should remove only the matching provider by name", () => { - const provider2 = { - constructor: MockContextProvider, - config: { name: ContextProviderNameEnum.PlanewaveCutoffDataManager }, - }; - - container.addProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - instance: mockProviderInstance, - }); - container.addProvider({ - name: ContextProviderNameEnum.PlanewaveCutoffDataManager, - instance: provider2, - }); - - container.removeProviderByName(ContextProviderNameEnum.QGridFormDataManager); - - expect(container.providers).to.have.length(1); - expect(container.providers[0].name).to.equal( - ContextProviderNameEnum.PlanewaveCutoffDataManager, - ); - }); - - it("should not remove anything if provider name not found", () => { - container.addProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - instance: mockProviderInstance, - }); - - container.removeProviderByName(ContextProviderNameEnum.KGridFormDataManager); - - expect(container.providers).to.have.length(1); - }); - }); - - describe("integration tests", () => { - it("should handle full lifecycle: add, find, remove", () => { - // Add providers - container.addProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - instance: mockProviderInstance, - }); - container.addProvider({ - name: ContextProviderNameEnum.PlanewaveCutoffDataManager, - instance: mockProviderInstance, - }); - - // Verify they exist - expect( - container.findProviderInstanceByName(ContextProviderNameEnum.QGridFormDataManager), - ).to.equal(mockProviderInstance); - expect( - container.findProviderInstanceByName( - ContextProviderNameEnum.PlanewaveCutoffDataManager, - ), - ).to.equal(mockProviderInstance); - - // Remove one - container.removeProviderByName(ContextProviderNameEnum.QGridFormDataManager); - - // Verify state - expect( - container.findProviderInstanceByName(ContextProviderNameEnum.QGridFormDataManager), - ).to.be.undefined; - expect( - container.findProviderInstanceByName( - ContextProviderNameEnum.PlanewaveCutoffDataManager, - ), - ).to.equal(mockProviderInstance); - expect(container.providers).to.have.length(1); - }); - }); -}); diff --git a/tests/js/JSONSchemaFormDataProvider.test.ts b/tests/js/JSONSchemaFormDataProvider.test.ts deleted file mode 100644 index f9f79f8..0000000 --- a/tests/js/JSONSchemaFormDataProvider.test.ts +++ /dev/null @@ -1,68 +0,0 @@ -// import { Name as ContextProviderName } from "@mat3ra/esse/dist/js/types"; -// import { expect } from "chai"; - -// import JSONSchemaFormDataProvider from "../../src/js/context/JSONSchemaFormDataProvider"; - -// describe("JSONSchemaFormDataProvider", () => { -// const baseConfig = { -// name: ContextProviderName.KGridFormDataManager, -// }; - -// it("respects isUsingJinjaVariables flag", () => { -// const providerTrue = new JSONSchemaFormDataProvider({ -// ...baseConfig, -// isUsingJinjaVariables: true, -// }); -// const providerFalse = new JSONSchemaFormDataProvider({ -// ...baseConfig, -// isUsingJinjaVariables: false, -// }); -// const providerUndefined = new JSONSchemaFormDataProvider(baseConfig); - -// expect(providerTrue.isUsingJinjaVariables).to.equal(true); -// expect(providerFalse.isUsingJinjaVariables).to.equal(false); -// expect(providerUndefined.isUsingJinjaVariables).to.equal(false); -// }); - -// it("returns styled uiSchema from uiSchemaStyled", () => { -// const provider = new JSONSchemaFormDataProvider(baseConfig); - -// // Monkey-patch abstract getters to avoid "Not implemented." errors -// Object.defineProperty(provider, "uiSchema", { -// get() { -// return { -// field1: { -// "ui:widget": "text", -// classNames: "original-class", -// }, -// field2: { -// "ui:widget": "number", -// }, -// }; -// }, -// }); - -// Object.defineProperty(provider, "defaultFieldStyles", { -// get() { -// return { -// "ui:options": { -// label: true, -// }, -// }; -// }, -// }); - -// const styled = provider.uiSchemaStyled; - -// expect(styled).to.have.property("field1"); -// expect(styled).to.have.property("field2"); - -// expect(styled.field1["ui:widget"]).to.equal("text"); -// expect(styled.field1["ui:options"]).to.deep.equal({ label: true }); -// expect(styled.field1.classNames).to.equal("original-class"); - -// expect(styled.field2["ui:widget"]).to.equal("number"); -// expect(styled.field2["ui:options"]).to.deep.equal({ label: true }); -// expect(styled.field2.classNames).to.equal(""); -// }); -// }); diff --git a/tests/js/JSONSchemaProvider.test.ts b/tests/js/JSONSchemaProvider.test.ts deleted file mode 100644 index 54f2fb0..0000000 --- a/tests/js/JSONSchemaProvider.test.ts +++ /dev/null @@ -1,67 +0,0 @@ -// import { Name as ContextProviderNameEnum } from "@mat3ra/esse/dist/js/types"; -// import { expect } from "chai"; - -// import JSONSchemaDataProvider from "../../src/js/context/JSONSchemaDataProvider"; -// import JSONSchemaFormDataProvider from "../../src/js/context/JSONSchemaFormDataProvider"; - -// describe("JSONSchemaDataProvider", () => { -// it("should set isUsingJinjaVariables", () => { -// const provider = new JSONSchemaDataProvider({ -// name: ContextProviderNameEnum.KGridFormDataManager, -// isUsingJinjaVariables: true, -// }); -// expect(provider.isUsingJinjaVariables).to.equal(true); -// }); - -// it("should throw error when accessing jsonSchema", () => { -// const provider = new JSONSchemaDataProvider({ -// name: ContextProviderNameEnum.KGridFormDataManager, -// }); -// expect(() => provider.jsonSchema).to.throw("Not implemented."); -// }); -// }); - -// describe("JSONSchemaFormDataProvider", () => { -// it("can be created", () => { -// const provider = new JSONSchemaFormDataProvider({ -// name: ContextProviderNameEnum.KGridFormDataManager, -// }); -// expect(provider).to.exist; -// }); - -// it("should throw error when accessing uiSchema", () => { -// const provider = new JSONSchemaFormDataProvider({ -// name: ContextProviderNameEnum.KGridFormDataManager, -// }); -// expect(() => provider.uiSchema).to.throw("Not implemented."); -// }); - -// it("should return empty fields object", () => { -// const provider = new JSONSchemaFormDataProvider({ -// name: ContextProviderNameEnum.KGridFormDataManager, -// }); -// expect(provider.fields).to.deep.equal({}); -// }); - -// it("should return empty defaultFieldStyles object", () => { -// const provider = new JSONSchemaFormDataProvider({ -// name: ContextProviderNameEnum.KGridFormDataManager, -// }); -// expect(provider.defaultFieldStyles).to.deep.equal({}); -// }); - -// it("should return uiSchemaStyled", () => { -// class TestProvider extends JSONSchemaFormDataProvider { -// // eslint-disable-next-line class-methods-use-this -// get uiSchema() { -// return { field1: { classNames: "test" }, field2: {} }; -// } -// } -// const provider = new TestProvider({ -// name: ContextProviderNameEnum.KGridFormDataManager, -// }); -// const styled = provider.uiSchemaStyled; -// expect(styled).to.have.property("field1"); -// expect(styled.field1).to.have.property("classNames", "test"); -// }); -// }); diff --git a/tests/js/application.test.ts b/tests/js/application.test.ts index f27c35b..22ae331 100644 --- a/tests/js/application.test.ts +++ b/tests/js/application.test.ts @@ -1,7 +1,7 @@ /* eslint-disable no-unused-expressions */ import { expect } from "chai"; -import Application from "../../src/js/application"; +import Application from "../../src/js/Application"; describe("Application", () => { const obj = { name: "espresso" }; diff --git a/tests/js/executable.test.ts b/tests/js/executable.test.ts index b029f21..0411394 100644 --- a/tests/js/executable.test.ts +++ b/tests/js/executable.test.ts @@ -2,7 +2,7 @@ import { expect } from "chai"; import ApplicationRegistry from "../../src/js/ApplicationRegistry"; -import Executable from "../../src/js/executable"; +import Executable from "../../src/js/Executable"; describe("Executable", () => { it("toJSON works as expected", () => { diff --git a/tests/js/flavor.test.ts b/tests/js/flavor.test.ts index 01a22f3..a271207 100644 --- a/tests/js/flavor.test.ts +++ b/tests/js/flavor.test.ts @@ -2,7 +2,7 @@ import { expect } from "chai"; import ApplicationRegistry from "../../src/js/ApplicationRegistry"; -import Flavor from "../../src/js/flavor"; +import Flavor from "../../src/js/Flavor"; describe("Flavor", () => { it("results are correct", () => { diff --git a/tests/js/provider.tests.ts b/tests/js/provider.tests.ts deleted file mode 100644 index 0f1e1f5..0000000 --- a/tests/js/provider.tests.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Name as ContextProviderNameEnum } from "@mat3ra/esse/dist/js/types"; -import { expect } from "chai"; - -import ContextProvider from "../../src/js/context/ContextProvider"; - -describe("ContextProvider", () => { - const minimal = { name: ContextProviderNameEnum.KGridFormDataManager }; - const data = { a: "test" }; - - it("can be created", () => { - const provider = new ContextProvider(minimal); - // eslint-disable-next-line no-unused-expressions - expect(provider).to.exist; - }); - - it("sets and gets data", () => { - const provider = new ContextProvider(minimal); - provider.setData(data); - expect(() => provider.getData()).to.throw("Not implemented."); - provider.setIsEdited(true); - expect(JSON.stringify(provider.getData())).to.equal(JSON.stringify(data)); - expect(() => provider.defaultData).to.throw("Not implemented."); - }); - - it("should return extraDataKey", () => { - const provider = new ContextProvider(minimal); - expect(provider.extraDataKey).to.equal(`${provider.name}ExtraData`); - }); - - it("should return isEditedKey", () => { - const provider = new ContextProvider(minimal); - expect(provider.isEditedKey).to.include("Edited"); - expect(provider.isEditedKey).to.include("is"); - }); - - it("should return isUnitContextProvider", () => { - const provider = new ContextProvider({ ...minimal, entityName: "unit" }); - expect(provider.isUnitContextProvider).to.be.true; - const nonUnitProvider = new ContextProvider({ ...minimal, entityName: "subworkflow" }); - expect(nonUnitProvider.isUnitContextProvider).to.be.false; - }); - - it("should return isSubworkflowContextProvider", () => { - const provider = new ContextProvider({ ...minimal, entityName: "subworkflow" }); - expect(provider.isSubworkflowContextProvider).to.be.true; - const nonSubworkflowProvider = new ContextProvider({ ...minimal, entityName: "unit" }); - expect(nonSubworkflowProvider.isSubworkflowContextProvider).to.be.false; - }); - - // transform, yieldData, yieldDataForRendering -}); diff --git a/tests/js/template.test.ts b/tests/js/template.test.ts index 3fc70ca..1fa1f7f 100644 --- a/tests/js/template.test.ts +++ b/tests/js/template.test.ts @@ -1,60 +1,7 @@ /* eslint-disable no-unused-expressions */ -import { Name as ContextProviderNameEnum } from "@mat3ra/esse/dist/js/types"; import { expect } from "chai"; -import ContextProvider from "../../src/js/context/ContextProvider"; -import Template from "../../src/js/template"; -import type { - ContextProviderConfigMap, - ContextProviderConfigMapEntry, -} from "../../src/js/templateMixin"; - -// Mock context provider class -class MockContextProvider extends ContextProvider { - // eslint-disable-next-line class-methods-use-this - get defaultData() { - return { test: "value" }; - } -} - -// Set up the static context provider registry before tests -const mockConfig: ContextProviderConfigMapEntry = { - providerCls: MockContextProvider, - config: { name: ContextProviderNameEnum.QGridFormDataManager }, -}; - -const providersConfig: ContextProviderConfigMap = { - QGridFormDataManager: mockConfig, - PlanewaveCutoffDataManager: mockConfig, - KGridFormDataManager: mockConfig, - IGridFormDataManager: mockConfig, - QPathFormDataManager: mockConfig, - IPathFormDataManager: mockConfig, - KPathFormDataManager: mockConfig, - ExplicitKPathFormDataManager: mockConfig, - ExplicitKPath2PIBAFormDataManager: mockConfig, - HubbardJContextManager: mockConfig, - HubbardUContextManager: mockConfig, - HubbardVContextManager: mockConfig, - HubbardContextManagerLegacy: mockConfig, - NEBFormDataManager: mockConfig, - BoundaryConditionsFormDataManager: mockConfig, - MLSettingsDataManager: mockConfig, - MLTrainTestSplitDataManager: mockConfig, - IonDynamicsContextProvider: mockConfig, - CollinearMagnetizationDataManager: mockConfig, - NonCollinearMagnetizationDataManager: mockConfig, - QEPWXInputDataManager: mockConfig, - QENEBInputDataManager: mockConfig, - VASPInputDataManager: mockConfig, - VASPNEBInputDataManager: mockConfig, - NWChemInputDataManager: mockConfig, -}; - -before(() => { - // Register the mock provider - Template.setContextProvidersConfig(providersConfig); -}); +import Template from "../../src/js/Template"; describe("Template", () => { let template: Template; @@ -64,9 +11,7 @@ describe("Template", () => { }); it("toJSON works as expected", () => { - const template = new Template({ name: "test_template" }); - template.setContent("test content"); - template.setRendered("test content"); + const template = new Template({ name: "test_template", content: "test content" }); const json = template.toJSON(); // Check basic properties from NamedInMemoryEntity @@ -84,14 +29,9 @@ describe("Template", () => { }); it("toJSON includes all template properties when set", () => { - const template = new Template({ name: "test_template" }); + const template = new Template({ name: "test_template", content: "test content" }); // Set various properties - template.setContent("test content"); - template.setProp("isManuallyChanged", true); - template.setProp("applicationName", "espresso"); - template.setProp("executableName", "pw"); - template.setRendered("rendered content"); const json = template.toJSON(); @@ -108,8 +48,8 @@ describe("Template", () => { it("getRenderedJSON returns valid JSON after rendering", () => { const template = new Template({ name: "test_template" }); - template.setContent("Hello {{ name }}!"); - template.setProp("isManuallyChanged", false); + template.content = "Hello {{ name }}!"; + template.isManuallyChanged = false; const json = template.getRenderedJSON({ name: "World" }); @@ -302,48 +242,9 @@ describe("Template", () => { template.getDataFromProvidersForRenderingContext = originalMethod; }); }); - - // Added with LLM to help with coverage - it("should handle getDataFromProvidersForPersistentContext with edited providers", () => { - const editedProvider = new MockContextProvider({ - name: ContextProviderNameEnum.QGridFormDataManager, - domain: "test", - }); - editedProvider.isEdited = true; - editedProvider.yieldData = () => ({ data: { value: 1 } }); - - const nonEditedProvider = new MockContextProvider({ - name: ContextProviderNameEnum.PlanewaveCutoffDataManager, - domain: "test", - }); - nonEditedProvider.isEdited = false; - nonEditedProvider.yieldData = () => ({ data: { value: 2 } }); - - template.getContextProvidersAsClassInstances = () => [ - editedProvider, - nonEditedProvider, - ]; - const result = template.getDataFromProvidersForPersistentContext(); - expect(result).to.deep.equal({ data: { value: 1 } }); - }); - - it("should throw error when provider not found", () => { - template.setProp("contextProviders", [ - { name: ContextProviderNameEnum.KGridFormDataManager }, - ]); - Template.contextProviderRegistry = null; - expect(() => template.getContextProvidersAsClassInstances()).to.throw( - /Provider .* not found/, - ); - }); }); describe("templateStaticMixin properties", () => { - it("should set context providers config", () => { - Template.setContextProvidersConfig(providersConfig); - expect(Template.contextProviderRegistry).to.not.be.null; - }); - it("should have jsonSchema property", () => { expect(Template.jsonSchema).to.exist; }); From 59f68f3f0d3add49d70f634b7611d1740abbfb5b Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Mon, 29 Dec 2025 16:38:52 +0200 Subject: [PATCH 12/16] chore: esse --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 23ee86f..aca2908 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#cf4115b459e7d308e708b606adfca7918185e525", - "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#aa1aefcfadb1643c69b43deadaafad08ca6d807c", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#9216482d292bbd1a679c02d167fe676f9d7b7cf4", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", @@ -3235,8 +3235,8 @@ }, "node_modules/@mat3ra/esse": { "version": "0.0.0", - "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#aa1aefcfadb1643c69b43deadaafad08ca6d807c", - "integrity": "sha512-WThYT68q2lbV69D7qeEoIM33tsr6BHH44EemqKTythIwoVyyCViYAI/+i+L0ttE76lq1cMG+YoYJLYeeJXJb4A==", + "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#9216482d292bbd1a679c02d167fe676f9d7b7cf4", + "integrity": "sha512-t5D3hVL5bNFadGr0uzLuiyL6jS7O+6OF2Q+fCR2UjzgnA/AqT3ViuZjBsytiXfCedQF6yxjR0m/y8i2s/dMxWg==", "dev": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index 62ca140..8038787 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/utils": "2025.9.20-0", "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#cf4115b459e7d308e708b606adfca7918185e525", - "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#aa1aefcfadb1643c69b43deadaafad08ca6d807c", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#9216482d292bbd1a679c02d167fe676f9d7b7cf4", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", From ffa43e27414ecbb9a9b40ed3f9f6ef6945c66e3d Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Mon, 29 Dec 2025 16:56:53 +0200 Subject: [PATCH 13/16] chore: simplify tests --- dist/js/flavorMixin.d.ts | 2 +- dist/js/flavorMixin.js | 22 ---- package-lock.json | 188 +++++----------------------- package.json | 6 +- src/js/flavorMixin.ts | 29 +---- tests/js/application.test.ts | 36 ------ tests/js/executable.test.ts | 50 -------- tests/js/flavor.test.ts | 65 ---------- tests/js/template.test.ts | 229 ----------------------------------- 9 files changed, 32 insertions(+), 595 deletions(-) diff --git a/dist/js/flavorMixin.d.ts b/dist/js/flavorMixin.d.ts index a494611..117baab 100644 --- a/dist/js/flavorMixin.d.ts +++ b/dist/js/flavorMixin.d.ts @@ -2,7 +2,7 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import type { FlavorSchema } from "@mat3ra/esse/dist/js/types"; import { type FlavorSchemaMixin } from "./generated/FlavorSchemaMixin"; -export type FlavorMixin = FlavorSchemaMixin & {}; +export type FlavorMixin = FlavorSchemaMixin; export type FlavorStaticMixin = { jsonSchema: FlavorSchema; }; diff --git a/dist/js/flavorMixin.js b/dist/js/flavorMixin.js index ab09b52..96fa3ca 100644 --- a/dist/js/flavorMixin.js +++ b/dist/js/flavorMixin.js @@ -6,27 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.flavorMixin = flavorMixin; const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); const FlavorSchemaMixin_1 = require("./generated/FlavorSchemaMixin"); -// TODO: should we add fields from esse schema (executableId, executableName, applicationName)? -function flavorPropertiesMixin(item) { - // @ts-expect-error - const properties = { - // TODO: there is no "isMultiMaterial" field in the schema; should we add it? - // get disableRenderMaterials() { - // return this.prop("isMultiMaterial", false); - // }, - // TODO: do we actually use this method anywhere? - // getInputAsRenderedTemplates(context: Record) { - // return this.input?.map((template) => { - // if (template && typeof template === "object" && "getRenderedJSON" in template) { - // return template.getRenderedJSON(context); - // } - // return template; - // }); - // }, - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); - return properties; -} function flavorStaticMixin(Flavor) { const properties = { get jsonSchema() { @@ -37,6 +16,5 @@ function flavorStaticMixin(Flavor) { } function flavorMixin(Item) { (0, FlavorSchemaMixin_1.flavorSchemaMixin)(Item.prototype); - flavorPropertiesMixin(Item.prototype); flavorStaticMixin(Item); } diff --git a/package-lock.json b/package-lock.json index aca2908..7bbb5e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,7 @@ "version": "0.0.0", "license": "Apache-2.0", "dependencies": { - "@types/react-jsonschema-form": "^1.7.13", - "lodash": "^4.17.21", - "nunjucks": "^3.2.4", - "react-jsonschema-form": "^1.8.1" + "lodash": "^4.17.21" }, "devDependencies": { "@babel/eslint-parser": "^7.16.3", @@ -23,7 +20,6 @@ "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", "@mat3ra/utils": "2025.9.20-0", - "@types/nunjucks": "^3.2.6", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", "chai": "^4.3.4", @@ -2355,18 +2351,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/runtime-corejs2": { - "version": "7.28.4", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs2/-/runtime-corejs2-7.28.4.tgz", - "integrity": "sha512-chjPHn3p+okNMesTjKU/pnpVT06oiJG1sVDJHTkAwYTCnVdM/2V5LI5xz3Y2y7MNngn8fQ19fpXjV3f9Jqun9w==", - "license": "MIT", - "dependencies": { - "core-js": "^2.6.12" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/runtime-corejs3": { "version": "7.28.4", "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.28.4.tgz", @@ -4898,6 +4882,7 @@ "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, "license": "MIT" }, "node_modules/@types/json-schema-merge-allof": { @@ -4952,32 +4937,6 @@ "undici-types": "~7.16.0" } }, - "node_modules/@types/nunjucks": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/@types/nunjucks/-/nunjucks-3.2.6.tgz", - "integrity": "sha512-pHiGtf83na1nCzliuAdq8GowYiXvH5l931xZ0YEHaLMNFgynpEqx+IPStlu7UaDkehfvl01e4x/9Tpwhy7Ue3w==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/react": { - "version": "19.2.5", - "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.5.tgz", - "integrity": "sha512-keKxkZMqnDicuvFoJbzrhbtdLSPhj/rZThDlKWCDbgXmUg0rEUFtRssDXKYmtXluZlIqiC5VqkCgRwzuyLHKHw==", - "license": "MIT", - "dependencies": { - "csstype": "^3.0.2" - } - }, - "node_modules/@types/react-jsonschema-form": { - "version": "1.7.13", - "resolved": "https://registry.npmjs.org/@types/react-jsonschema-form/-/react-jsonschema-form-1.7.13.tgz", - "integrity": "sha512-C2jgO7/ow76oCSfUK++jKKox17R0A7ryMYNE5hJ2dR1Ske9jhuvjIlurvzMePh+Xjk8wey0nzB2C7HFKe2pRdg==", - "license": "MIT", - "dependencies": { - "@types/json-schema": "*", - "@types/react": "*" - } - }, "node_modules/@types/semver": { "version": "7.7.1", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.1.tgz", @@ -5261,6 +5220,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/a-sync-waterfall/-/a-sync-waterfall-1.0.1.tgz", "integrity": "sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA==", + "dev": true, "license": "MIT" }, "node_modules/acorn": { @@ -5444,7 +5404,7 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "devOptional": true, + "dev": true, "license": "ISC", "dependencies": { "normalize-path": "^3.0.0", @@ -5683,6 +5643,7 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", + "dev": true, "license": "MIT" }, "node_modules/assertion-error": { @@ -5821,7 +5782,7 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -5845,7 +5806,7 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "fill-range": "^7.1.1" @@ -6088,6 +6049,7 @@ "version": "3.6.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -6339,14 +6301,6 @@ "dev": true, "license": "MIT" }, - "node_modules/core-js": { - "version": "2.6.12", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", - "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", - "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", - "hasInstallScript": true, - "license": "MIT" - }, "node_modules/core-js-compat": { "version": "3.46.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.46.0.tgz", @@ -6412,12 +6366,6 @@ "dev": true, "license": "MIT" }, - "node_modules/csstype": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", - "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", - "license": "MIT" - }, "node_modules/dag-map": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/dag-map/-/dag-map-1.0.2.tgz", @@ -7742,6 +7690,7 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, "license": "MIT" }, "node_modules/fast-diff": { @@ -7772,6 +7721,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, "license": "MIT" }, "node_modules/fast-levenshtein": { @@ -7825,7 +7775,7 @@ "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" @@ -8182,7 +8132,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "devOptional": true, + "dev": true, "license": "ISC", "dependencies": { "is-glob": "^4.0.1" @@ -8595,7 +8545,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "binary-extensions": "^2.0.0" @@ -8696,7 +8646,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -8755,7 +8705,7 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "is-extglob": "^2.1.1" @@ -8830,7 +8780,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=0.12.0" @@ -9273,6 +9223,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, "license": "MIT" }, "node_modules/js-yaml": { @@ -9900,6 +9851,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, "license": "MIT", "dependencies": { "js-tokens": "^3.0.0 || ^4.0.0" @@ -10331,7 +10283,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -10354,6 +10306,7 @@ "version": "3.2.4", "resolved": "https://registry.npmjs.org/nunjucks/-/nunjucks-3.2.4.tgz", "integrity": "sha512-26XRV6BhkgK0VOxfbU5cQI+ICFUtMLixv1noZn1tGU38kQH5A5nmmbk/O45xdyBhD1esk47nKrY0mvQpZIhRjQ==", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "a-sync-waterfall": "^1.0.0", @@ -10379,6 +10332,7 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 6" @@ -10666,6 +10620,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -11001,7 +10956,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=8.6" @@ -11198,6 +11153,7 @@ "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "dev": true, "license": "MIT", "dependencies": { "loose-envify": "^1.4.0", @@ -11209,6 +11165,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -11245,79 +11202,18 @@ "safe-buffer": "^5.1.0" } }, - "node_modules/react": { - "version": "19.2.0", - "resolved": "https://registry.npmjs.org/react/-/react-19.2.0.tgz", - "integrity": "sha512-tmbWg6W31tQLeB5cdIBOicJDJRR2KzXsV7uSK9iNfLWQ5bIZfxuPEHp7M8wiHyHnn0DD1i7w3Zmin0FtkrwoCQ==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "license": "MIT" - }, - "node_modules/react-jsonschema-form": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/react-jsonschema-form/-/react-jsonschema-form-1.8.1.tgz", - "integrity": "sha512-aaDloxNAcGXOOOcdKOxxqEEn5oDlPUZgWcs8unXXB9vjBRgCF8rCm/wVSv1u2G5ih0j/BX6Ewd/WjI2g00lPdg==", - "deprecated": "react-jsonschema-form has been moved to @rjsf/core", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs2": "^7.4.5", - "ajv": "^6.7.0", - "core-js": "^2.5.7", - "lodash": "^4.17.15", - "prop-types": "^15.5.8", - "react-is": "^16.8.4", - "react-lifecycles-compat": "^3.0.4", - "shortid": "^2.2.14" - }, - "engines": { - "node": ">=6", - "npm": ">=2.14.7" - }, - "peerDependencies": { - "react": ">=15" - } - }, - "node_modules/react-jsonschema-form/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/react-jsonschema-form/node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "license": "MIT" - }, - "node_modules/react-lifecycles-compat": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", - "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==", + "dev": true, "license": "MIT" }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "picomatch": "^2.2.1" @@ -11834,33 +11730,6 @@ "node": ">=8" } }, - "node_modules/shortid": { - "version": "2.2.17", - "resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.17.tgz", - "integrity": "sha512-GpbM3gLF1UUXZvQw6MCyulHkWbRseNO4cyBEZresZRorwl1+SLu1ZdqgVtuwqz8mB6RpwPkm541mYSqrKyJSaA==", - "license": "MIT", - "dependencies": { - "nanoid": "^3.3.8" - } - }, - "node_modules/shortid/node_modules/nanoid": { - "version": "3.3.11", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", - "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, "node_modules/side-channel": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", @@ -12499,7 +12368,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "is-number": "^7.0.0" @@ -12956,6 +12825,7 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "punycode": "^2.1.0" diff --git a/package.json b/package.json index 8038787..805b964 100644 --- a/package.json +++ b/package.json @@ -43,10 +43,7 @@ "license": "Apache-2.0", "homepage": "https://github.com/Exabyte-io/ade", "dependencies": { - "@types/react-jsonschema-form": "^1.7.13", - "lodash": "^4.17.21", - "nunjucks": "^3.2.4", - "react-jsonschema-form": "^1.8.1" + "lodash": "^4.17.21" }, "devDependencies": { "@babel/eslint-parser": "^7.16.3", @@ -57,7 +54,6 @@ "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", - "@types/nunjucks": "^3.2.6", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", "chai": "^4.3.4", diff --git a/src/js/flavorMixin.ts b/src/js/flavorMixin.ts index 34489b5..a061b26 100644 --- a/src/js/flavorMixin.ts +++ b/src/js/flavorMixin.ts @@ -5,33 +5,7 @@ import type { FlavorSchema } from "@mat3ra/esse/dist/js/types"; import { type FlavorSchemaMixin, flavorSchemaMixin } from "./generated/FlavorSchemaMixin"; -export type FlavorMixin = FlavorSchemaMixin & { - // getInputAsRenderedTemplates: (context: Record) => Record[]; -}; - -// TODO: should we add fields from esse schema (executableId, executableName, applicationName)? -function flavorPropertiesMixin(item: InMemoryEntity & FlavorSchemaMixin) { - // @ts-expect-error - const properties: FlavorMixin & InMemoryEntity & FlavorSchemaMixin = { - // TODO: there is no "isMultiMaterial" field in the schema; should we add it? - // get disableRenderMaterials() { - // return this.prop("isMultiMaterial", false); - // }, - // TODO: do we actually use this method anywhere? - // getInputAsRenderedTemplates(context: Record) { - // return this.input?.map((template) => { - // if (template && typeof template === "object" && "getRenderedJSON" in template) { - // return template.getRenderedJSON(context); - // } - // return template; - // }); - // }, - }; - - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); - - return properties; -} +export type FlavorMixin = FlavorSchemaMixin; function flavorStaticMixin(Flavor: Constructor) { const properties: FlavorStaticMixin = { @@ -49,6 +23,5 @@ export type FlavorStaticMixin = { export function flavorMixin(Item: Constructor) { flavorSchemaMixin(Item.prototype); - flavorPropertiesMixin(Item.prototype); flavorStaticMixin(Item); } diff --git a/tests/js/application.test.ts b/tests/js/application.test.ts index 22ae331..9893063 100644 --- a/tests/js/application.test.ts +++ b/tests/js/application.test.ts @@ -4,34 +4,7 @@ import { expect } from "chai"; import Application from "../../src/js/Application"; describe("Application", () => { - const obj = { name: "espresso" }; - - it("can be created", () => { - const app = new Application(obj); - expect(app.name).to.equal("espresso"); - }); - describe("applicationMixin properties", () => { - let app: Application; - - beforeEach(() => { - app = new Application(obj); - }); - - describe("hasAdvancedComputeOptions property", () => { - it("should return true when set", () => { - app.setProp("hasAdvancedComputeOptions", true); - expect(app.hasAdvancedComputeOptions).to.be.true; - }); - }); - - describe("isLicensed property", () => { - it("should return true when set", () => { - app.setProp("isLicensed", true); - expect(app.isLicensed).to.be.true; - }); - }); - describe("isUsingMaterial property", () => { it("should return true for vasp application", () => { const vaspApp = new Application({ name: "vasp" }); @@ -56,15 +29,6 @@ describe("Application", () => { }); describe("applicationStaticMixin properties", () => { - it("should have defaultConfig with correct structure", () => { - const config = Application.defaultConfig; - expect(config).to.have.property("name", "espresso"); - expect(config).to.have.property("shortName", "qe"); - expect(config).to.have.property("version", "6.3"); - expect(config).to.have.property("summary", "Quantum ESPRESSO"); - expect(config).to.have.property("build", "GNU"); - }); - it("should return the complete defaultConfig object", () => { expect(Application.defaultConfig).to.deep.equal({ name: "espresso", diff --git a/tests/js/executable.test.ts b/tests/js/executable.test.ts index 0411394..757cb83 100644 --- a/tests/js/executable.test.ts +++ b/tests/js/executable.test.ts @@ -1,7 +1,6 @@ /* eslint-disable no-unused-expressions */ import { expect } from "chai"; -import ApplicationRegistry from "../../src/js/ApplicationRegistry"; import Executable from "../../src/js/Executable"; describe("Executable", () => { @@ -13,55 +12,6 @@ describe("Executable", () => { expect(json).to.have.property("schemaVersion"); }); - it("should find executable via ApplicationRegistry and validate JSON structure", () => { - // Find an executable using ApplicationRegistry - const executable = ApplicationRegistry.getExecutableByName("espresso", "pw.x"); - - // Verify we got a valid executable - expect(executable).to.be.instanceOf(Executable); - expect(executable.name).to.equal("pw.x"); - - // Get JSON representation - const json = executable.toJSON(); - - // Validate JSON structure contains expected properties - expect(json).to.be.an("object"); - expect(json).to.have.property("name"); - expect(json.name).to.equal("pw.x"); - - // Verify core executable properties - expect(json).to.have.property("isDefault"); - expect(json.isDefault).to.be.a("boolean"); - - expect(json).to.not.have.property("flavors"); - - // Verify arrays of configuration data - expect(json).to.have.property("monitors"); - expect(json.monitors).to.be.an("array"); - - expect(json).to.have.property("results"); - expect(json.results).to.be.an("array"); - - // The JSON should be comprehensive - expect(Object.keys(json).length).to.be.greaterThan(2); - }); - - describe("executableMixin properties", () => { - let executable: Executable; - beforeEach(() => { - executable = new Executable({ name: "test_exec" }); - }); - - it("should get default applicationId as empty array", () => { - expect(executable.applicationId).to.deep.equal([]); - }); - - it("should set and get applicationId", () => { - executable.applicationId = ["app1", "app2"]; - expect(executable.applicationId).to.deep.equal(["app1", "app2"]); - }); - }); - describe("executableStaticMixin", () => { it("should have jsonSchema property", () => { expect(Executable.jsonSchema).to.exist; diff --git a/tests/js/flavor.test.ts b/tests/js/flavor.test.ts index a271207..20efe3f 100644 --- a/tests/js/flavor.test.ts +++ b/tests/js/flavor.test.ts @@ -22,71 +22,6 @@ describe("Flavor", () => { ]); }); - describe("flavorMixin properties", () => { - let flavor: Flavor; - beforeEach(() => { - flavor = new Flavor({ name: "test_flavor" }); - }); - - it("should have default input as empty array", () => { - expect(flavor.input).to.deep.equal([]); - }); - - it("should return input when set", () => { - const input = [{ name: "param1" }, { name: "param2" }]; - flavor.setProp("input", input); - expect(flavor.input).to.deep.equal(input); - }); - - it("should have executableId as empty string by default", () => { - expect(flavor.executableId).to.equal(""); - }); - - it("should return executableId when set", () => { - flavor.setProp("executableId", "exec123"); - expect(flavor.executableId).to.equal("exec123"); - }); - - it("should have executableName as empty string by default", () => { - expect(flavor.executableName).to.equal(""); - }); - - it("should return executableName when set", () => { - flavor.setProp("executableName", "pw"); - expect(flavor.executableName).to.equal("pw"); - }); - - it("should have applicationName as empty string by default", () => { - expect(flavor.applicationName).to.equal(""); - }); - - it("should return applicationName when set", () => { - flavor.setProp("applicationName", "espresso"); - expect(flavor.applicationName).to.equal("espresso"); - }); - - it("should have supportedApplicationVersions as undefined by default", () => { - expect(flavor.supportedApplicationVersions).to.be.undefined; - }); - - it("should return supportedApplicationVersions when set", () => { - flavor.setProp("supportedApplicationVersions", ["6.3", "7.0"]); - expect(flavor.supportedApplicationVersions).to.deep.equal(["6.3", "7.0"]); - }); - - // Added with LLM to help with coverage - // it("should handle getInputAsRenderedTemplates with different template types", () => { - // const mockTemplate = { getRenderedJSON: () => ({ rendered: true }) }; - // const simpleTemplate = { name: "simple" }; - // flavor.setProp("input", [mockTemplate, simpleTemplate]); - - // const result = flavor.getInputAsRenderedTemplates({}); - // expect(result).to.have.length(2); - // expect(result[0]).to.deep.equal({ rendered: true }); - // expect(result[1]).to.deep.equal({ name: "simple" }); - // }); - }); - describe("flavorStaticMixin", () => { it("should have jsonSchema property", () => { expect(Flavor.jsonSchema).to.exist; diff --git a/tests/js/template.test.ts b/tests/js/template.test.ts index 1fa1f7f..3cf6949 100644 --- a/tests/js/template.test.ts +++ b/tests/js/template.test.ts @@ -4,244 +4,15 @@ import { expect } from "chai"; import Template from "../../src/js/Template"; describe("Template", () => { - let template: Template; - - beforeEach(() => { - template = new Template({ name: "test_template" }); - }); - it("toJSON works as expected", () => { const template = new Template({ name: "test_template", content: "test content" }); const json = template.toJSON(); - // Check basic properties from NamedInMemoryEntity expect(json).to.have.property("name", "test_template"); expect(json).to.have.property("schemaVersion"); - - // Check required template properties expect(json).to.have.property("content", "test content"); - expect(json).to.have.property("rendered", "test content"); - - // Verify data types expect(json.content).to.be.a("string"); - expect(json.rendered).to.be.a("string"); - expect(json.schemaVersion).to.be.a("string"); - }); - - it("toJSON includes all template properties when set", () => { - const template = new Template({ name: "test_template", content: "test content" }); - - // Set various properties - - const json = template.toJSON(); - - // Check required properties - expect(json.name).to.equal("test_template"); - expect(json.content).to.equal("test content"); - expect(json.rendered).to.equal("rendered content"); expect(json.schemaVersion).to.be.a("string"); - - // Check that the JSON contains the expected structure - expect(json).to.be.an("object"); - expect(Object.keys(json).length).to.be.greaterThan(3); - }); - - it("getRenderedJSON returns valid JSON after rendering", () => { - const template = new Template({ name: "test_template" }); - template.content = "Hello {{ name }}!"; - template.isManuallyChanged = false; - - const json = template.getRenderedJSON({ name: "World" }); - - // Check that it returns a valid JSON object - expect(json).to.be.an("object"); - expect(json).to.have.property("name", "test_template"); - expect(json).to.have.property("content", "Hello {{ name }}!"); - expect(json).to.have.property("rendered", "Hello World!"); - expect(json).to.have.property("schemaVersion"); - }); - - describe("templateMixin properties", () => { - describe("content property", () => { - it("should return empty string by default", () => { - expect(template.content).to.equal(""); - }); - - it("should return content when set", () => { - template.setContent("test content"); - expect(template.content).to.equal("test content"); - }); - - it("should set content via setContent method", () => { - template.setContent("new content"); - expect(template.content).to.equal("new content"); - }); - }); - - describe("rendered property", () => { - it("should return content when rendered is not set", () => { - template.setContent("test content"); - expect(template.rendered).to.equal("test content"); - }); - - it("should return rendered content when set", () => { - template.setContent("test content"); - template.setRendered("rendered content"); - expect(template.rendered).to.equal("rendered content"); - }); - - it("should set rendered via setRendered method", () => { - template.setRendered("rendered text"); - expect(template.rendered).to.equal("rendered text"); - }); - }); - - describe("applicationName property", () => { - it("should return empty string by default", () => { - expect(template.applicationName).to.equal(""); - }); - - it("should return applicationName when set", () => { - template.setProp("applicationName", "espresso"); - expect(template.applicationName).to.equal("espresso"); - }); - }); - - describe("executableName property", () => { - it("should return empty string by default", () => { - expect(template.executableName).to.equal(""); - }); - - it("should return executableName when set", () => { - template.setProp("executableName", "pw"); - expect(template.executableName).to.equal("pw"); - }); - }); - - describe("contextProviders property", () => { - it("should return empty array by default", () => { - expect(template.contextProviders).to.deep.equal([]); - }); - - it("should return contextProviders when set", () => { - const providers = [{ name: "provider1" }, { name: "provider2" }]; - template.setProp("contextProviders", providers); - expect(template.contextProviders).to.deep.equal(providers); - }); - }); - - // describe("addContextProvider method", () => { - // it("should add a context provider", () => { - // const provider = new MockContextProvider({ - // name: ContextProviderNameEnum.QGridFormDataManager, - // domain: "test", - // }); - // const initialLength = template.contextProviders.length; - // template.addContextProvider(provider); - // // The method sets the new length, so we check that it increased - // expect(template.contextProviders.length).to.be.greaterThan(initialLength); - // }); - // }); - - // describe("removeContextProvider method", () => { - // it("should remove a context provider by name and domain", () => { - // const provider1 = new MockContextProvider({ - // name: ContextProviderNameEnum.QGridFormDataManager, - // domain: "domain1", - // }); - // const provider2 = new MockContextProvider({ - // name: ContextProviderNameEnum.PlanewaveCutoffDataManager, - // domain: "domain2", - // }); - // template.setProp("contextProviders", [provider1, provider2]); - // template.removeContextProvider(provider1); - // expect(template.contextProviders).to.deep.equal([provider2]); - // }); - // }); - - describe("_cleanRenderingContext method", () => { - it("should remove job property and deep clone the object", () => { - const context = { - job: { id: 123 }, - name: "test", - data: { value: 456 }, - }; - - const result = template._cleanRenderingContext(context); - expect(result).to.not.have.property("job"); - expect(result).to.have.property("name", "test"); - expect(result.data).to.deep.equal({ value: 456 }); - }); - }); - - describe("render method", () => { - it("should render template with nunjucks when not manually changed", () => { - template.setContent("Hello {{ name }}!"); - template.setProp("isManuallyChanged", false); - - template.render({ name: "World" }); - expect(template.rendered).to.equal("Hello World!"); - }); - - it("should not render when manually changed", () => { - template.setContent("Original content"); - template.setProp("isManuallyChanged", true); - - template.render({ name: "World" }); - expect(template.rendered).to.equal("Original content"); - }); - - it("should handle template compilation errors gracefully", () => { - template.setContent("Invalid template {{ name }"); - template.setProp("isManuallyChanged", false); - - // Capture console.log calls - const originalLog = console.log; - let logCalled = false; - console.log = () => { - logCalled = true; - }; - - template.render({ name: "World" }); - - expect(logCalled).to.be.true; - expect(template.rendered).to.equal("Invalid template {{ name }"); - - // Restore console.log - console.log = originalLog; - }); - }); - - describe("getRenderedJSON method", () => { - it("should render template and return JSON", () => { - template.setContent("Hello {{ name }}!"); - template.setProp("isManuallyChanged", false); - - const result = template.getRenderedJSON({ name: "World" }); - expect(result).to.have.property("name", "test_template"); - expect(template.rendered).to.equal("Hello World!"); - }); - }); - - describe("getRenderingContext method", () => { - it("should combine external context with provider context", () => { - const externalContext = { external: "value" }; - const providerContext = { provider: "data" }; - - // Mock getDataFromProvidersForRenderingContext - const originalMethod = template.getDataFromProvidersForRenderingContext; - template.getDataFromProvidersForRenderingContext = () => providerContext; - - const result = template.getRenderingContext(externalContext); - expect(result).to.deep.equal({ - external: "value", - provider: "data", - }); - - // Restore original method - template.getDataFromProvidersForRenderingContext = originalMethod; - }); - }); }); describe("templateStaticMixin properties", () => { From 291051ef5fbb364d4870acdfae1c6e74bf9b6d60 Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Wed, 31 Dec 2025 19:10:18 +0200 Subject: [PATCH 14/16] chore: new application schema --- dist/js/ApplicationRegistry.d.ts | 10 +++++----- dist/js/application.d.ts | 7 +++---- dist/js/applicationMixin.d.ts | 8 ++++---- package-lock.json | 6 +++--- package.json | 2 +- src/js/Application.ts | 8 +++----- src/js/ApplicationRegistry.ts | 10 +++++----- src/js/applicationMixin.ts | 12 +++++------- src/py/mat3ra/ade/application.py | 4 ++-- 9 files changed, 31 insertions(+), 36 deletions(-) diff --git a/dist/js/ApplicationRegistry.d.ts b/dist/js/ApplicationRegistry.d.ts index 2981f21..361db44 100644 --- a/dist/js/ApplicationRegistry.d.ts +++ b/dist/js/ApplicationRegistry.d.ts @@ -1,10 +1,10 @@ -import type { ApplicationSchemaBase, TemplateSchema } from "@mat3ra/esse/dist/js/types"; +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; @@ -18,7 +18,7 @@ export type CreateApplicationConfig = { type ApplicationTree = Partial>; export default class ApplicationRegistry { static applicationsTree?: ApplicationTree; - static applicationsArray?: ApplicationSchemaBase[]; + static applicationsArray?: ApplicationSchema[]; static createApplication({ name, version, build }: CreateApplicationConfig): Application; static getUniqueAvailableApplicationNames(): string[]; /** @@ -27,7 +27,7 @@ export default class ApplicationRegistry { */ static getAllApplications(): { applicationsTree: Partial>; - applicationsArray: ApplicationSchemaBase[]; + applicationsArray: ApplicationSchema[]; }; /** * @summary Get an application from the constructed applications @@ -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; diff --git a/dist/js/application.d.ts b/dist/js/application.d.ts index 3ef2f5a..04b6768 100644 --- a/dist/js/application.d.ts +++ b/dist/js/application.d.ts @@ -2,12 +2,11 @@ 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 { ApplicationSchemaBase } from "@mat3ra/esse/dist/js/types"; +import type { ApplicationSchema } from "@mat3ra/esse/dist/js/types"; import { type ApplicationMixin, type ApplicationStaticMixin } from "./applicationMixin"; type Base = typeof InMemoryEntity & NamedInMemoryEntityConstructor & DefaultableInMemoryEntityConstructor & Constructor & ApplicationStaticMixin; declare const Application_base: Base; -export default class Application extends Application_base implements ApplicationSchemaBase { - constructor(data?: Partial); - [k: string]: unknown; +export default class Application extends Application_base implements ApplicationSchema { + constructor(data?: Partial); } export {}; diff --git a/dist/js/applicationMixin.d.ts b/dist/js/applicationMixin.d.ts index 3efc012..621e752 100644 --- a/dist/js/applicationMixin.d.ts +++ b/dist/js/applicationMixin.d.ts @@ -2,7 +2,7 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; 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 type { ApplicationSchema } from "@mat3ra/esse/dist/js/types"; import Executable from "./Executable"; import { type ApplicationSchemaMixin } from "./generated/ApplicationSchemaMixin"; type Base = InMemoryEntity & NamedEntity & Defaultable; @@ -10,13 +10,13 @@ export type BaseConstructor = Constructor & { constructCustomExecutable?: (config: object) => Executable; }; export type ApplicationMixin = ApplicationSchemaMixin & { - name: Required["name"]; + name: Required["name"]; isUsingMaterial: boolean; }; -export type DefaultApplicationConfig = Pick; +export type DefaultApplicationConfig = Pick; export type ApplicationStaticMixin = { defaultConfig: DefaultApplicationConfig; - jsonSchema: ApplicationSchemaBase; + jsonSchema: ApplicationSchema; }; export declare function applicationMixin(Item: BaseConstructor): void; export {}; diff --git a/package-lock.json b/package-lock.json index 7bbb5e2..f100236 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#cf4115b459e7d308e708b606adfca7918185e525", - "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#9216482d292bbd1a679c02d167fe676f9d7b7cf4", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#dfa3f260d19cea3a07aac1278bcebd59d242e346", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", @@ -3219,8 +3219,8 @@ }, "node_modules/@mat3ra/esse": { "version": "0.0.0", - "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#9216482d292bbd1a679c02d167fe676f9d7b7cf4", - "integrity": "sha512-t5D3hVL5bNFadGr0uzLuiyL6jS7O+6OF2Q+fCR2UjzgnA/AqT3ViuZjBsytiXfCedQF6yxjR0m/y8i2s/dMxWg==", + "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#dfa3f260d19cea3a07aac1278bcebd59d242e346", + "integrity": "sha512-fqYHPctqxOUu67owdooAaSgyFc7SLgU5zYGrT7SFysZJbUzXUd5cCY5Yl25qSIrWtJ8OmlMkHQWPmWFXJqrpZg==", "dev": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index 805b964..71e8059 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/utils": "2025.9.20-0", "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#cf4115b459e7d308e708b606adfca7918185e525", - "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#9216482d292bbd1a679c02d167fe676f9d7b7cf4", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse#dfa3f260d19cea3a07aac1278bcebd59d242e346", "@mat3ra/made": "2025.7.15-0", "@mat3ra/standata": "2025.10.1-0", "@mat3ra/tsconfig": "2024.6.3-0", diff --git a/src/js/Application.ts b/src/js/Application.ts index e76c223..de6995c 100644 --- a/src/js/Application.ts +++ b/src/js/Application.ts @@ -8,7 +8,7 @@ import { namedEntityMixin, } 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 type { ApplicationSchema } from "@mat3ra/esse/dist/js/types"; import { type ApplicationMixin, @@ -22,14 +22,12 @@ type Base = typeof InMemoryEntity & Constructor & ApplicationStaticMixin; -export default class Application extends (InMemoryEntity as Base) implements ApplicationSchemaBase { - constructor(data: Partial = {}) { +export default class Application extends (InMemoryEntity as Base) implements ApplicationSchema { + constructor(data: Partial = {}) { super({ ...data, }); } - - [k: string]: unknown; } namedEntityMixin(Application.prototype); diff --git a/src/js/ApplicationRegistry.ts b/src/js/ApplicationRegistry.ts index d436145..95fbaf5 100644 --- a/src/js/ApplicationRegistry.ts +++ b/src/js/ApplicationRegistry.ts @@ -1,6 +1,6 @@ import { getOneMatchFromObject } from "@mat3ra/code/dist/js/utils/object"; import type { - ApplicationSchemaBase, + ApplicationSchema, ExecutableSchema, TemplateSchema, } from "@mat3ra/esse/dist/js/types"; @@ -12,7 +12,7 @@ import Flavor from "./Flavor"; import Template from "./Template"; type ApplicationVersion = { - [build: string]: ApplicationSchemaBase; + [build: string]: ApplicationSchema; }; type ApplicationTreeItem = { @@ -32,7 +32,7 @@ export default class ApplicationRegistry { // applications static applicationsTree?: ApplicationTree; - static applicationsArray?: ApplicationSchemaBase[]; + static applicationsArray?: ApplicationSchema[]; static createApplication({ name, version = null, build = null }: CreateApplicationConfig) { const staticConfig = ApplicationRegistry.getApplicationConfig({ name, version, build }); @@ -61,7 +61,7 @@ export default class ApplicationRegistry { } const applicationsTree: ApplicationTree = {}; - const applicationsArray: ApplicationSchemaBase[] = []; + const applicationsArray: ApplicationSchema[] = []; const allApplications = new ApplicationStandata().getAllApplicationNames(); allApplications.forEach((appName) => { @@ -89,7 +89,7 @@ export default class ApplicationRegistry { appTreeItem[version] = appVersion; - const applicationConfig: ApplicationSchemaBase = { + const applicationConfig: ApplicationSchema = { ...appData, // @ts-ignore build: buildToUse, diff --git a/src/js/applicationMixin.ts b/src/js/applicationMixin.ts index 16e1c52..ff78658 100644 --- a/src/js/applicationMixin.ts +++ b/src/js/applicationMixin.ts @@ -3,7 +3,7 @@ import type { Defaultable } from "@mat3ra/code/dist/js/entity/mixins/Defaultable import type { NamedEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; import JSONSchemasInterface from "@mat3ra/esse/dist/js/esse/JSONSchemasInterface"; -import type { ApplicationSchemaBase } from "@mat3ra/esse/dist/js/types"; +import type { ApplicationSchema } from "@mat3ra/esse/dist/js/types"; import { ApplicationStandata } from "@mat3ra/standata"; import Executable from "./Executable"; @@ -19,18 +19,18 @@ export type BaseConstructor = Constructor & { }; export type ApplicationMixin = ApplicationSchemaMixin & { - name: Required["name"]; + name: Required["name"]; isUsingMaterial: boolean; }; export type DefaultApplicationConfig = Pick< - ApplicationSchemaBase, + ApplicationSchema, "name" | "shortName" | "version" | "summary" | "build" >; export type ApplicationStaticMixin = { defaultConfig: DefaultApplicationConfig; - jsonSchema: ApplicationSchemaBase; + jsonSchema: ApplicationSchema; }; function applicationPropertiesMixin( @@ -53,9 +53,7 @@ function applicationStaticMixin(Application: T) { return new ApplicationStandata().getDefaultConfig(); }, get jsonSchema() { - return JSONSchemasInterface.getSchemaById( - "software/application", - ) as ApplicationSchemaBase; + return JSONSchemasInterface.getSchemaById("software/application") as ApplicationSchema; }, }; diff --git a/src/py/mat3ra/ade/application.py b/src/py/mat3ra/ade/application.py index ed2c8c2..642a8b9 100644 --- a/src/py/mat3ra/ade/application.py +++ b/src/py/mat3ra/ade/application.py @@ -1,8 +1,8 @@ from mat3ra.code.entity import InMemoryEntitySnakeCase -from mat3ra.esse.models.software.application import ApplicationSchemaBase +from mat3ra.esse.models.software.application import ApplicationSchema -class Application(ApplicationSchemaBase, InMemoryEntitySnakeCase): +class Application(ApplicationSchema, InMemoryEntitySnakeCase): """ Application class representing a software application. From c64bc68f88fcb3e34c68bff214c51c0de91b0eb7 Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Fri, 2 Jan 2026 15:35:34 +0200 Subject: [PATCH 15/16] chore: declare createDefault TS --- dist/js/application.d.ts | 1 + dist/js/executable.d.ts | 1 + dist/js/flavor.d.ts | 1 + src/js/Application.ts | 2 ++ src/js/Executable.ts | 2 ++ src/js/Flavor.ts | 2 ++ 6 files changed, 9 insertions(+) diff --git a/dist/js/application.d.ts b/dist/js/application.d.ts index 04b6768..0445e06 100644 --- a/dist/js/application.d.ts +++ b/dist/js/application.d.ts @@ -8,5 +8,6 @@ type Base = typeof InMemoryEntity & NamedInMemoryEntityConstructor & Defaultable declare const Application_base: Base; export default class Application extends Application_base implements ApplicationSchema { constructor(data?: Partial); + createDefault: () => Application; } export {}; diff --git a/dist/js/executable.d.ts b/dist/js/executable.d.ts index 60fc3c2..4be76ca 100644 --- a/dist/js/executable.d.ts +++ b/dist/js/executable.d.ts @@ -9,5 +9,6 @@ type Base = Constructor & RuntimeItemsInMemoryEntityConstructor declare const Executable_base: Base; export default class Executable extends Executable_base implements ExecutableSchema { constructor(data?: Partial); + createDefault: () => Executable; } export {}; diff --git a/dist/js/flavor.d.ts b/dist/js/flavor.d.ts index 697db87..44c7224 100644 --- a/dist/js/flavor.d.ts +++ b/dist/js/flavor.d.ts @@ -9,5 +9,6 @@ type Base = typeof InMemoryEntity & Constructor & RuntimeItemsInMem declare const Flavor_base: Base; export default class Flavor extends Flavor_base implements FlavorSchema { constructor(data?: Partial); + createDefault: () => Flavor; } export {}; diff --git a/src/js/Application.ts b/src/js/Application.ts index de6995c..a0bea15 100644 --- a/src/js/Application.ts +++ b/src/js/Application.ts @@ -28,6 +28,8 @@ export default class Application extends (InMemoryEntity as Base) implements App ...data, }); } + + declare createDefault: () => Application; } namedEntityMixin(Application.prototype); diff --git a/src/js/Executable.ts b/src/js/Executable.ts index 1c99757..7123cb6 100644 --- a/src/js/Executable.ts +++ b/src/js/Executable.ts @@ -33,6 +33,8 @@ export default class Executable extends (InMemoryEntity as Base) implements Exec ...data, }); } + + declare createDefault: () => Executable; } namedEntityMixin(Executable.prototype); diff --git a/src/js/Flavor.ts b/src/js/Flavor.ts index 8f48ef4..c770303 100644 --- a/src/js/Flavor.ts +++ b/src/js/Flavor.ts @@ -36,6 +36,8 @@ export default class Flavor extends (InMemoryEntity as Base) implements FlavorSc ...data, }); } + + declare createDefault: () => Flavor; } namedEntityMixin(Flavor.prototype); From e2d636491f47dfe2277b60f580c1275acec501dd Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Fri, 2 Jan 2026 15:42:39 +0200 Subject: [PATCH 16/16] chore: declare createDefault TS --- dist/js/application.d.ts | 2 +- dist/js/executable.d.ts | 2 +- dist/js/flavor.d.ts | 2 +- src/js/Application.ts | 2 +- src/js/Executable.ts | 2 +- src/js/Flavor.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/js/application.d.ts b/dist/js/application.d.ts index 0445e06..2131e0f 100644 --- a/dist/js/application.d.ts +++ b/dist/js/application.d.ts @@ -8,6 +8,6 @@ type Base = typeof InMemoryEntity & NamedInMemoryEntityConstructor & Defaultable declare const Application_base: Base; export default class Application extends Application_base implements ApplicationSchema { constructor(data?: Partial); - createDefault: () => Application; + static createDefault: () => Application; } export {}; diff --git a/dist/js/executable.d.ts b/dist/js/executable.d.ts index 4be76ca..3777e58 100644 --- a/dist/js/executable.d.ts +++ b/dist/js/executable.d.ts @@ -9,6 +9,6 @@ type Base = Constructor & RuntimeItemsInMemoryEntityConstructor declare const Executable_base: Base; export default class Executable extends Executable_base implements ExecutableSchema { constructor(data?: Partial); - createDefault: () => Executable; + static createDefault: () => Executable; } export {}; diff --git a/dist/js/flavor.d.ts b/dist/js/flavor.d.ts index 44c7224..f6f4285 100644 --- a/dist/js/flavor.d.ts +++ b/dist/js/flavor.d.ts @@ -9,6 +9,6 @@ type Base = typeof InMemoryEntity & Constructor & RuntimeItemsInMem declare const Flavor_base: Base; export default class Flavor extends Flavor_base implements FlavorSchema { constructor(data?: Partial); - createDefault: () => Flavor; + static createDefault: () => Flavor; } export {}; diff --git a/src/js/Application.ts b/src/js/Application.ts index a0bea15..0aee2e0 100644 --- a/src/js/Application.ts +++ b/src/js/Application.ts @@ -29,7 +29,7 @@ export default class Application extends (InMemoryEntity as Base) implements App }); } - declare createDefault: () => Application; + declare static createDefault: () => Application; } namedEntityMixin(Application.prototype); diff --git a/src/js/Executable.ts b/src/js/Executable.ts index 7123cb6..cfaba03 100644 --- a/src/js/Executable.ts +++ b/src/js/Executable.ts @@ -34,7 +34,7 @@ export default class Executable extends (InMemoryEntity as Base) implements Exec }); } - declare createDefault: () => Executable; + declare static createDefault: () => Executable; } namedEntityMixin(Executable.prototype); diff --git a/src/js/Flavor.ts b/src/js/Flavor.ts index c770303..c774e26 100644 --- a/src/js/Flavor.ts +++ b/src/js/Flavor.ts @@ -37,7 +37,7 @@ export default class Flavor extends (InMemoryEntity as Base) implements FlavorSc }); } - declare createDefault: () => Flavor; + declare static createDefault: () => Flavor; } namedEntityMixin(Flavor.prototype);