diff --git a/package-lock.json b/package-lock.json index ba51b992..d188752a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1574,9 +1574,8 @@ "dev": true }, "@exabyte-io/esse.js": { - "version": "2023.9.29-0", - "resolved": "https://registry.npmjs.org/@exabyte-io/esse.js/-/esse.js-2023.9.29-0.tgz", - "integrity": "sha512-KNitdwZkbIOY2HR8Hh6jU3NT8xiYuL7YPcOVdstkWX0x1+P8mOjs8lpwAmJePuPZVsUeYhlUi2wVADt8dnlCRQ==", + "version": "git+https://github.com/Exabyte-io/esse.git#dfb2133abe9b1254ced7d60d0660a5452fb6b2ff", + "from": "git+https://github.com/Exabyte-io/esse.git#dfb2133abe9b1254ced7d60d0660a5452fb6b2ff", "requires": { "@babel/cli": "7.16.0", "@babel/core": "7.16.0", @@ -5508,7 +5507,7 @@ "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "requires": { "wrappy": "1" } @@ -5590,12 +5589,12 @@ "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==" }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==" }, "path-key": { "version": "3.1.1", @@ -6084,7 +6083,7 @@ "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==" }, "source-map-support": { "version": "0.5.21", @@ -6158,7 +6157,7 @@ "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, "string-argv": { @@ -6345,7 +6344,7 @@ "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==" }, "to-regex-range": { "version": "5.0.1", @@ -6686,7 +6685,7 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, "write-file-atomic": { "version": "3.0.3", diff --git a/package.json b/package.json index 40d10153..30d1f85d 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@babel/preset-react": "7.16.7", "@babel/register": "^7.16.0", "@babel/runtime-corejs3": "7.16.8", - "@exabyte-io/esse.js": "^2023.9.29-0", + "@exabyte-io/esse.js": "https://github.com/Exabyte-io/esse.git#dfb2133abe9b1254ced7d60d0660a5452fb6b2ff", "@types/chai": "^4.3.5", "@types/crypto-js": "^4.1.1", "@types/js-yaml": "^4.0.5", diff --git a/src/context/index.ts b/src/context/index.ts index 1c59abec..50c83bfe 100644 --- a/src/context/index.ts +++ b/src/context/index.ts @@ -6,6 +6,7 @@ import { MaterialsContextMixin, MaterialsSetContextMixin, MethodDataContextMixin, + ModelContextMixin, WorkflowContextMixin, } from "./mixins"; import { JobContextPickKeysForMixin, WorkflowContextPickKeysForMixin } from "./pickers"; @@ -31,4 +32,5 @@ export { MethodDataContextMixin, JobContextMixin, WorkflowContextMixin, + ModelContextMixin, }; diff --git a/src/context/mixins.ts b/src/context/mixins.ts index c01d297c..7d611803 100644 --- a/src/context/mixins.ts +++ b/src/context/mixins.ts @@ -4,7 +4,13 @@ import CryptoJS from "crypto-js"; import { InMemoryEntity } from "../entity"; import { DefaultableMixin } from "../entity/mixins/props"; import { compareEntitiesInOrderedSetForSorting } from "../entity/set/ordered/utils"; -import { ApplicationSchemaBase, JobSchema, MaterialSchema, WorkflowSchema } from "../types"; +import { + ApplicationSchemaBase, + BaseModel, + JobSchema, + MaterialSchema, + WorkflowSchema, +} from "../types"; type Constructor = new (...args: any[]) => T; @@ -228,3 +234,26 @@ export function JobContextMixin(superclass: T) { } }; } + +export function ModelContextMixin(superclass: T) { + return class ModelContextMixin extends superclass { + _model: BaseModel; + + constructor(...args: any) { + super(...args); + // @ts-ignore + if (!this.constructor.Model) { + throw Error("ModelContextMixin: Model is undefined"); + } + const config = args[0]; + this._model = + (config.context && config.context.model) || + // @ts-ignore + (this.constructor.Model as Defaultable).createDefault(); + } + + get model() { + return this._model; + } + }; +}