From 02f7f7a075657bbe233c7eac6c029787dd666cd5 Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Tue, 13 Jan 2026 18:55:20 +0200 Subject: [PATCH] chore: update dist files --- dist/js/ExecutionUnitInput.d.ts | 28 + dist/js/ExecutionUnitInput.js | 58 + dist/js/RuntimeItemsUILogicMixin.d.ts | 27 + dist/js/RuntimeItemsUILogicMixin.js | 56 + dist/js/context/context.js | 49 - .../mixins/ApplicationContextMixin.d.ts | 10 + .../context/mixins/ApplicationContextMixin.js | 28 +- .../mixins/ContextAndRenderFieldsMixin.d.ts | 17 + .../mixins/ContextAndRenderFieldsMixin.js | 34 + .../ImportantSettingsProviderMixin.d.ts | 17 + .../mixins/ImportantSettingsProviderMixin.js | 25 + dist/js/context/mixins/JobContextMixin.d.ts | 11 + dist/js/context/mixins/JobContextMixin.js | 49 +- .../context/mixins/MaterialContextMixin.d.ts | 18 + .../js/context/mixins/MaterialContextMixin.js | 52 +- .../context/mixins/MaterialsContextMixin.d.ts | 10 + .../context/mixins/MaterialsContextMixin.js | 28 +- .../mixins/MaterialsSetContextMixin.d.ts | 14 + .../mixins/MaterialsSetContextMixin.js | 40 +- .../mixins/MethodDataContextMixin.d.ts | 21 + .../context/mixins/MethodDataContextMixin.js | 59 +- .../context/mixins/WorkflowContextMixin.d.ts | 15 + .../js/context/mixins/WorkflowContextMixin.js | 38 +- dist/js/context/providers.d.ts | 55 + dist/js/context/providers.js | 368 +- .../BoundaryConditionsFormDataProvider.d.ts | 29 + .../BoundaryConditionsFormDataProvider.js | 131 +- ...CollinearMagnetizationContextProvider.d.ts | 41 + .../CollinearMagnetizationContextProvider.js | 179 +- .../Hubbard/HubbardContextProvider.d.ts | 19 + .../Hubbard/HubbardContextProvider.js | 46 + .../Hubbard/HubbardContextProviderLegacy.d.ts | 27 + .../Hubbard/HubbardContextProviderLegacy.js | 60 + .../Hubbard/HubbardJContextProvider.d.ts | 20 + .../Hubbard/HubbardJContextProvider.js | 52 + .../Hubbard/HubbardUContextProvider.d.ts | 20 + .../Hubbard/HubbardUContextProvider.js | 50 + .../Hubbard/HubbardVContextProvider.d.ts | 20 + .../Hubbard/HubbardVContextProvider.js | 70 + .../providers/HubbardContextProviderLegacy.js | 68 - .../providers/HubbardJContextProvider.js | 67 - .../providers/HubbardUContextProvider.js | 70 - .../providers/HubbardVContextProvider.js | 92 - .../providers/IonDynamicsContextProvider.d.ts | 25 + .../providers/IonDynamicsContextProvider.js | 90 +- .../providers/MLSettingsContextProvider.d.ts | 26 + .../providers/MLSettingsContextProvider.js | 82 +- .../MLTrainTestSplitContextProvider.d.ts | 25 + .../MLTrainTestSplitContextProvider.js | 76 +- .../providers/NEBFormDataProvider.d.ts | 21 + .../context/providers/NEBFormDataProvider.js | 67 +- ...CollinearMagnetizationContextProvider.d.ts | 77 + ...onCollinearMagnetizationContextProvider.js | 338 +- .../PlanewaveCutoffsContextProvider.d.ts | 26 + .../PlanewaveCutoffsContextProvider.js | 100 +- .../PointsGrid/IGridFormDataManager.d.ts | 7 + .../PointsGrid/IGridFormDataManager.js | 14 + .../PointsGrid/KGridFormDataManager.d.ts | 6 + .../PointsGrid/KGridFormDataManager.js | 13 + .../PointsGridFormDataProvider.d.ts | 86 + .../PointsGrid/PointsGridFormDataProvider.js | 238 + .../PointsGrid/QGridFormDataManager.d.ts | 7 + .../PointsGrid/QGridFormDataManager.js | 14 + .../providers/PointsGridFormDataProvider.js | 263 - .../ExplicitKPath2PIBAFormDataManager.d.ts | 8 + .../ExplicitKPath2PIBAFormDataManager.js | 15 + .../ExplicitKPathFormDataManager.d.ts | 7 + .../ExplicitKPathFormDataManager.js | 14 + .../PointsPath/IPathFormDataManager.d.ts | 6 + .../PointsPath/IPathFormDataManager.js | 13 + .../PointsPath/KPathFormDataManager.d.ts | 6 + .../PointsPath/KPathFormDataManager.js | 13 + .../PointsPathFormDataProvider.d.ts | 27 + .../PointsPath/PointsPathFormDataProvider.js | 114 + .../PointsPath/QPathFormDataManager.d.ts | 6 + .../PointsPath/QPathFormDataManager.js | 13 + .../providers/PointsPathFormDataProvider.js | 147 - .../providers/base/ContextProvider.d.ts | 41 + .../context/providers/base/ContextProvider.js | 29 + .../base/JSONSchemaDataProvider.d.ts | 16 + .../providers/base/JSONSchemaDataProvider.js | 17 + .../base/JSONSchemaFormDataProvider.d.ts | 18 + .../base/JSONSchemaFormDataProvider.js | 32 + .../ExecutableContextProvider.js | 25 - .../espresso/QENEBContextProvider.d.ts | 24 + .../espresso/QENEBContextProvider.js | 108 +- .../espresso/QEPWXContextProvider.d.ts | 89 + .../espresso/QEPWXContextProvider.js | 249 +- .../NWChemTotalEnergyContextProvider.d.ts | 33 + .../NWChemTotalEnergyContextProvider.js | 130 +- .../vasp/VASPContextProvider.d.ts | 33 + .../vasp/VASPContextProvider.js | 114 +- .../vasp/VASPNEBContextProvider.d.ts | 28 + .../vasp/VASPNEBContextProvider.js | 99 +- dist/js/context/providers/settings.d.ts | 15 + dist/js/context/providers/settings.js | 60 +- dist/js/enums.d.ts | 69 + dist/js/enums.js | 120 +- .../generated/AssertionUnitSchemaMixin.d.ts | 5 + dist/js/generated/AssertionUnitSchemaMixin.js | 27 + .../generated/AssignmentUnitSchemaMixin.d.ts | 5 + .../js/generated/AssignmentUnitSchemaMixin.js | 33 + dist/js/generated/BaseUnitSchemaMixin.d.ts | 5 + dist/js/generated/BaseUnitSchemaMixin.js | 57 + .../generated/ConditionUnitSchemaMixin.d.ts | 5 + dist/js/generated/ConditionUnitSchemaMixin.js | 51 + .../ExecutionUnitInputSchemaMixin.d.ts | 5 + .../ExecutionUnitInputSchemaMixin.js | 27 + .../generated/ExecutionUnitSchemaMixin.d.ts | 5 + dist/js/generated/ExecutionUnitSchemaMixin.js | 45 + dist/js/generated/IOUnitSchemaMixin.d.ts | 5 + dist/js/generated/IOUnitSchemaMixin.js | 33 + dist/js/generated/MapUnitSchemaMixin.d.ts | 5 + dist/js/generated/MapUnitSchemaMixin.js | 27 + .../generated/ProcessingUnitSchemaMixin.d.ts | 5 + .../js/generated/ProcessingUnitSchemaMixin.js | 33 + dist/js/generated/ReduceUnitSchemaMixin.d.ts | 5 + dist/js/generated/ReduceUnitSchemaMixin.js | 27 + dist/js/generated/StatusSchemaMixin.d.ts | 5 + dist/js/generated/StatusSchemaMixin.js | 21 + dist/js/generated/SubworkflowSchemaMixin.d.ts | 5 + dist/js/generated/SubworkflowSchemaMixin.js | 45 + .../generated/SubworkflowUnitSchemaMixin.d.ts | 5 + .../generated/SubworkflowUnitSchemaMixin.js | 15 + dist/js/index.d.ts | 26 + dist/js/index.js | 215 +- dist/js/patch.js | 19 - dist/js/subworkflows/convergence.d.ts | 20 + dist/js/subworkflows/convergence.js | 352 +- dist/js/subworkflows/convergence/factory.d.ts | 6 + dist/js/subworkflows/convergence/factory.js | 47 +- .../convergence/non_uniform_kgrid.d.ts | 15 + .../convergence/non_uniform_kgrid.js | 54 +- .../subworkflows/convergence/parameter.d.ts | 42 + dist/js/subworkflows/convergence/parameter.js | 117 +- .../convergence/uniform_kgrid.d.ts | 11 + .../subworkflows/convergence/uniform_kgrid.js | 43 +- dist/js/subworkflows/create.d.ts | 49 + dist/js/subworkflows/create.js | 342 +- .../dynamic/espresso/getQpointIrrep.d.ts | 17 + .../dynamic/espresso/getQpointIrrep.js | 43 +- dist/js/subworkflows/dynamic/index.d.ts | 8 + dist/js/subworkflows/dynamic/index.js | 27 +- .../subworkflows/dynamic/surfaceEnergy.d.ts | 4 + dist/js/subworkflows/dynamic/surfaceEnergy.js | 119 +- dist/js/subworkflows/index.d.ts | 2 + dist/js/subworkflows/index.js | 24 +- dist/js/subworkflows/subworkflow.d.ts | 1204 +++++ dist/js/subworkflows/subworkflow.js | 549 +- dist/js/units/AssertionUnit.d.ts | 15 + dist/js/units/AssertionUnit.js | 22 + dist/js/units/AssignmentUnit.d.ts | 12 + dist/js/units/AssignmentUnit.js | 23 + dist/js/units/BaseUnit.d.ts | 37 + dist/js/units/BaseUnit.js | 75 + dist/js/units/ConditionUnit.d.ts | 12 + dist/js/units/ConditionUnit.js | 28 + dist/js/units/ExecutionUnit.d.ts | 51 + dist/js/units/ExecutionUnit.js | 116 + dist/js/units/IOUnit.d.ts | 11 + dist/js/units/IOUnit.js | 13 + dist/js/units/MapUnit.d.ts | 25 + dist/js/units/MapUnit.js | 28 + dist/js/units/ProcessingUnit.d.ts | 14 + dist/js/units/ProcessingUnit.js | 26 + dist/js/units/ReduceUnit.d.ts | 11 + dist/js/units/ReduceUnit.js | 13 + dist/js/units/SubworkflowUnit.d.ts | 11 + dist/js/units/SubworkflowUnit.js | 13 + dist/js/units/assertion.js | 37 - dist/js/units/assignment.js | 42 - dist/js/units/base.js | 91 - .../builders/AssertionUnitConfigBuilder.d.ts | 20 + .../builders/AssertionUnitConfigBuilder.js | 56 +- .../builders/AssignmentUnitConfigBuilder.d.ts | 23 + .../builders/AssignmentUnitConfigBuilder.js | 70 +- .../builders/ExecutionUnitConfigBuilder.d.ts | 39 + .../builders/ExecutionUnitConfigBuilder.js | 112 +- .../units/builders/IOUnitConfigBuilder.d.ts | 31 + dist/js/units/builders/IOUnitConfigBuilder.js | 98 +- dist/js/units/builders/UnitConfigBuilder.d.ts | 35 + dist/js/units/builders/UnitConfigBuilder.js | 139 +- dist/js/units/builders/index.d.ts | 12 + dist/js/units/builders/index.js | 30 +- dist/js/units/condition.js | 52 - dist/js/units/execution.js | 225 - dist/js/units/factory.d.ts | 8 + dist/js/units/factory.js | 78 +- dist/js/units/index.d.ts | 12 + dist/js/units/index.js | 105 +- dist/js/units/io.js | 148 - dist/js/units/map.js | 38 - dist/js/units/processing.js | 41 - dist/js/units/reduce.js | 24 - dist/js/units/subworkflow.js | 23 - dist/js/utils.d.ts | 28 + dist/js/utils.js | 105 +- dist/js/workflows/create.d.ts | 8 + dist/js/workflows/create.js | 393 +- dist/js/workflows/default.d.ts | 36 + dist/js/workflows/default.js | 78 +- dist/js/workflows/index.d.ts | 18 + dist/js/workflows/index.js | 147 +- dist/js/workflows/relaxation.d.ts | 10 + dist/js/workflows/relaxation.js | 68 +- dist/js/workflows/workflow.d.ts | 4555 +++++++++++++++++ dist/js/workflows/workflow.js | 614 +-- 207 files changed, 12262 insertions(+), 5331 deletions(-) create mode 100644 dist/js/ExecutionUnitInput.d.ts create mode 100644 dist/js/ExecutionUnitInput.js create mode 100644 dist/js/RuntimeItemsUILogicMixin.d.ts create mode 100644 dist/js/RuntimeItemsUILogicMixin.js delete mode 100644 dist/js/context/context.js create mode 100644 dist/js/context/mixins/ApplicationContextMixin.d.ts create mode 100644 dist/js/context/mixins/ContextAndRenderFieldsMixin.d.ts create mode 100644 dist/js/context/mixins/ContextAndRenderFieldsMixin.js create mode 100644 dist/js/context/mixins/ImportantSettingsProviderMixin.d.ts create mode 100644 dist/js/context/mixins/ImportantSettingsProviderMixin.js create mode 100644 dist/js/context/mixins/JobContextMixin.d.ts create mode 100644 dist/js/context/mixins/MaterialContextMixin.d.ts create mode 100644 dist/js/context/mixins/MaterialsContextMixin.d.ts create mode 100644 dist/js/context/mixins/MaterialsSetContextMixin.d.ts create mode 100644 dist/js/context/mixins/MethodDataContextMixin.d.ts create mode 100644 dist/js/context/mixins/WorkflowContextMixin.d.ts create mode 100644 dist/js/context/providers.d.ts create mode 100644 dist/js/context/providers/BoundaryConditionsFormDataProvider.d.ts create mode 100644 dist/js/context/providers/CollinearMagnetizationContextProvider.d.ts create mode 100644 dist/js/context/providers/Hubbard/HubbardContextProvider.d.ts create mode 100644 dist/js/context/providers/Hubbard/HubbardContextProvider.js create mode 100644 dist/js/context/providers/Hubbard/HubbardContextProviderLegacy.d.ts create mode 100644 dist/js/context/providers/Hubbard/HubbardContextProviderLegacy.js create mode 100644 dist/js/context/providers/Hubbard/HubbardJContextProvider.d.ts create mode 100644 dist/js/context/providers/Hubbard/HubbardJContextProvider.js create mode 100644 dist/js/context/providers/Hubbard/HubbardUContextProvider.d.ts create mode 100644 dist/js/context/providers/Hubbard/HubbardUContextProvider.js create mode 100644 dist/js/context/providers/Hubbard/HubbardVContextProvider.d.ts create mode 100644 dist/js/context/providers/Hubbard/HubbardVContextProvider.js delete mode 100644 dist/js/context/providers/HubbardContextProviderLegacy.js delete mode 100644 dist/js/context/providers/HubbardJContextProvider.js delete mode 100644 dist/js/context/providers/HubbardUContextProvider.js delete mode 100644 dist/js/context/providers/HubbardVContextProvider.js create mode 100644 dist/js/context/providers/IonDynamicsContextProvider.d.ts create mode 100644 dist/js/context/providers/MLSettingsContextProvider.d.ts create mode 100644 dist/js/context/providers/MLTrainTestSplitContextProvider.d.ts create mode 100644 dist/js/context/providers/NEBFormDataProvider.d.ts create mode 100644 dist/js/context/providers/NonCollinearMagnetizationContextProvider.d.ts create mode 100644 dist/js/context/providers/PlanewaveCutoffsContextProvider.d.ts create mode 100644 dist/js/context/providers/PointsGrid/IGridFormDataManager.d.ts create mode 100644 dist/js/context/providers/PointsGrid/IGridFormDataManager.js create mode 100644 dist/js/context/providers/PointsGrid/KGridFormDataManager.d.ts create mode 100644 dist/js/context/providers/PointsGrid/KGridFormDataManager.js create mode 100644 dist/js/context/providers/PointsGrid/PointsGridFormDataProvider.d.ts create mode 100644 dist/js/context/providers/PointsGrid/PointsGridFormDataProvider.js create mode 100644 dist/js/context/providers/PointsGrid/QGridFormDataManager.d.ts create mode 100644 dist/js/context/providers/PointsGrid/QGridFormDataManager.js delete mode 100644 dist/js/context/providers/PointsGridFormDataProvider.js create mode 100644 dist/js/context/providers/PointsPath/ExplicitKPath2PIBAFormDataManager.d.ts create mode 100644 dist/js/context/providers/PointsPath/ExplicitKPath2PIBAFormDataManager.js create mode 100644 dist/js/context/providers/PointsPath/ExplicitKPathFormDataManager.d.ts create mode 100644 dist/js/context/providers/PointsPath/ExplicitKPathFormDataManager.js create mode 100644 dist/js/context/providers/PointsPath/IPathFormDataManager.d.ts create mode 100644 dist/js/context/providers/PointsPath/IPathFormDataManager.js create mode 100644 dist/js/context/providers/PointsPath/KPathFormDataManager.d.ts create mode 100644 dist/js/context/providers/PointsPath/KPathFormDataManager.js create mode 100644 dist/js/context/providers/PointsPath/PointsPathFormDataProvider.d.ts create mode 100644 dist/js/context/providers/PointsPath/PointsPathFormDataProvider.js create mode 100644 dist/js/context/providers/PointsPath/QPathFormDataManager.d.ts create mode 100644 dist/js/context/providers/PointsPath/QPathFormDataManager.js delete mode 100644 dist/js/context/providers/PointsPathFormDataProvider.js create mode 100644 dist/js/context/providers/base/ContextProvider.d.ts create mode 100644 dist/js/context/providers/base/ContextProvider.js create mode 100644 dist/js/context/providers/base/JSONSchemaDataProvider.d.ts create mode 100644 dist/js/context/providers/base/JSONSchemaDataProvider.js create mode 100644 dist/js/context/providers/base/JSONSchemaFormDataProvider.d.ts create mode 100644 dist/js/context/providers/base/JSONSchemaFormDataProvider.js delete mode 100644 dist/js/context/providers/by_application/ExecutableContextProvider.js create mode 100644 dist/js/context/providers/by_application/espresso/QENEBContextProvider.d.ts create mode 100644 dist/js/context/providers/by_application/espresso/QEPWXContextProvider.d.ts create mode 100644 dist/js/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.d.ts create mode 100644 dist/js/context/providers/by_application/vasp/VASPContextProvider.d.ts create mode 100644 dist/js/context/providers/by_application/vasp/VASPNEBContextProvider.d.ts create mode 100644 dist/js/context/providers/settings.d.ts create mode 100644 dist/js/enums.d.ts create mode 100644 dist/js/generated/AssertionUnitSchemaMixin.d.ts create mode 100644 dist/js/generated/AssertionUnitSchemaMixin.js create mode 100644 dist/js/generated/AssignmentUnitSchemaMixin.d.ts create mode 100644 dist/js/generated/AssignmentUnitSchemaMixin.js create mode 100644 dist/js/generated/BaseUnitSchemaMixin.d.ts create mode 100644 dist/js/generated/BaseUnitSchemaMixin.js create mode 100644 dist/js/generated/ConditionUnitSchemaMixin.d.ts create mode 100644 dist/js/generated/ConditionUnitSchemaMixin.js create mode 100644 dist/js/generated/ExecutionUnitInputSchemaMixin.d.ts create mode 100644 dist/js/generated/ExecutionUnitInputSchemaMixin.js create mode 100644 dist/js/generated/ExecutionUnitSchemaMixin.d.ts create mode 100644 dist/js/generated/ExecutionUnitSchemaMixin.js create mode 100644 dist/js/generated/IOUnitSchemaMixin.d.ts create mode 100644 dist/js/generated/IOUnitSchemaMixin.js create mode 100644 dist/js/generated/MapUnitSchemaMixin.d.ts create mode 100644 dist/js/generated/MapUnitSchemaMixin.js create mode 100644 dist/js/generated/ProcessingUnitSchemaMixin.d.ts create mode 100644 dist/js/generated/ProcessingUnitSchemaMixin.js create mode 100644 dist/js/generated/ReduceUnitSchemaMixin.d.ts create mode 100644 dist/js/generated/ReduceUnitSchemaMixin.js create mode 100644 dist/js/generated/StatusSchemaMixin.d.ts create mode 100644 dist/js/generated/StatusSchemaMixin.js create mode 100644 dist/js/generated/SubworkflowSchemaMixin.d.ts create mode 100644 dist/js/generated/SubworkflowSchemaMixin.js create mode 100644 dist/js/generated/SubworkflowUnitSchemaMixin.d.ts create mode 100644 dist/js/generated/SubworkflowUnitSchemaMixin.js create mode 100644 dist/js/index.d.ts delete mode 100644 dist/js/patch.js create mode 100644 dist/js/subworkflows/convergence.d.ts create mode 100644 dist/js/subworkflows/convergence/factory.d.ts create mode 100644 dist/js/subworkflows/convergence/non_uniform_kgrid.d.ts create mode 100644 dist/js/subworkflows/convergence/parameter.d.ts create mode 100644 dist/js/subworkflows/convergence/uniform_kgrid.d.ts create mode 100644 dist/js/subworkflows/create.d.ts create mode 100644 dist/js/subworkflows/dynamic/espresso/getQpointIrrep.d.ts create mode 100644 dist/js/subworkflows/dynamic/index.d.ts create mode 100644 dist/js/subworkflows/dynamic/surfaceEnergy.d.ts create mode 100644 dist/js/subworkflows/index.d.ts create mode 100644 dist/js/subworkflows/subworkflow.d.ts create mode 100644 dist/js/units/AssertionUnit.d.ts create mode 100644 dist/js/units/AssertionUnit.js create mode 100644 dist/js/units/AssignmentUnit.d.ts create mode 100644 dist/js/units/AssignmentUnit.js create mode 100644 dist/js/units/BaseUnit.d.ts create mode 100644 dist/js/units/BaseUnit.js create mode 100644 dist/js/units/ConditionUnit.d.ts create mode 100644 dist/js/units/ConditionUnit.js create mode 100644 dist/js/units/ExecutionUnit.d.ts create mode 100644 dist/js/units/ExecutionUnit.js create mode 100644 dist/js/units/IOUnit.d.ts create mode 100644 dist/js/units/IOUnit.js create mode 100644 dist/js/units/MapUnit.d.ts create mode 100644 dist/js/units/MapUnit.js create mode 100644 dist/js/units/ProcessingUnit.d.ts create mode 100644 dist/js/units/ProcessingUnit.js create mode 100644 dist/js/units/ReduceUnit.d.ts create mode 100644 dist/js/units/ReduceUnit.js create mode 100644 dist/js/units/SubworkflowUnit.d.ts create mode 100644 dist/js/units/SubworkflowUnit.js delete mode 100644 dist/js/units/assertion.js delete mode 100644 dist/js/units/assignment.js delete mode 100644 dist/js/units/base.js create mode 100644 dist/js/units/builders/AssertionUnitConfigBuilder.d.ts create mode 100644 dist/js/units/builders/AssignmentUnitConfigBuilder.d.ts create mode 100644 dist/js/units/builders/ExecutionUnitConfigBuilder.d.ts create mode 100644 dist/js/units/builders/IOUnitConfigBuilder.d.ts create mode 100644 dist/js/units/builders/UnitConfigBuilder.d.ts create mode 100644 dist/js/units/builders/index.d.ts delete mode 100644 dist/js/units/condition.js delete mode 100644 dist/js/units/execution.js create mode 100644 dist/js/units/factory.d.ts create mode 100644 dist/js/units/index.d.ts delete mode 100644 dist/js/units/io.js delete mode 100644 dist/js/units/map.js delete mode 100644 dist/js/units/processing.js delete mode 100644 dist/js/units/reduce.js delete mode 100644 dist/js/units/subworkflow.js create mode 100644 dist/js/utils.d.ts create mode 100644 dist/js/workflows/create.d.ts create mode 100644 dist/js/workflows/default.d.ts create mode 100644 dist/js/workflows/index.d.ts create mode 100644 dist/js/workflows/relaxation.d.ts create mode 100644 dist/js/workflows/workflow.d.ts diff --git a/dist/js/ExecutionUnitInput.d.ts b/dist/js/ExecutionUnitInput.d.ts new file mode 100644 index 00000000..2f94e2ed --- /dev/null +++ b/dist/js/ExecutionUnitInput.d.ts @@ -0,0 +1,28 @@ +import { Template } from "@mat3ra/ade"; +import { 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 { TemplateSchema } from "@mat3ra/esse/dist/js/types"; +import type { ContextItem } from "./context/providers/base/ContextProvider"; +import type ContextProvider from "./context/providers/base/ContextProvider"; +import type { ExecutionUnitInputSchemaMixin } from "./generated/ExecutionUnitInputSchemaMixin"; +type Schema = ExecutionUnitInputSchemaMixin; +type Base = typeof InMemoryEntity & Constructor; +type ConstructorConfig = Schema | (Omit & { + template: Template; +}); +declare const ExecutionUnitInput_base: Base; +export default class ExecutionUnitInput extends ExecutionUnitInput_base implements Schema { + _json: Schema & AnyObject; + toJSON: () => Schema & AnyObject; + toJSONQuick: () => Schema & AnyObject; + static get jsonSchema(): import("json-schema").JSONSchema7 | undefined; + contextProvidersInstances: ContextProvider[]; + readonly templateInstance: Template; + static createFromTemplate(template: Template | TemplateSchema): ExecutionUnitInput; + constructor(config: ConstructorConfig); + setContext(context: ContextItem[]): this; + render(): this; + getFullContext(): import("./context/providers/base/ContextProvider").ExtendedContextItem[]; +} +export {}; diff --git a/dist/js/ExecutionUnitInput.js b/dist/js/ExecutionUnitInput.js new file mode 100644 index 00000000..f7c588cf --- /dev/null +++ b/dist/js/ExecutionUnitInput.js @@ -0,0 +1,58 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const ade_1 = require("@mat3ra/ade"); +const entity_1 = require("@mat3ra/code/dist/js/entity"); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const nunjucks_1 = __importDefault(require("nunjucks")); +const providers_1 = require("./context/providers"); +class ExecutionUnitInput extends entity_1.InMemoryEntity { + static get jsonSchema() { + return JSONSchemasInterface_1.default.getSchemaById("workflow/unit/input/-inputItem"); + } + static createFromTemplate(template) { + return new ExecutionUnitInput({ + template, + rendered: template.content, + isManuallyChanged: false, + }); + } + constructor(config) { + const { template } = config; + const templateInstance = template instanceof ade_1.Template ? template : new ade_1.Template(template); + super({ ...config, template: templateInstance.toJSON() }); + this.contextProvidersInstances = []; + this.templateInstance = templateInstance; + } + setContext(context) { + this.contextProvidersInstances = this.template.contextProviders.map(({ name }) => { + if (!providers_1.providers) { + throw new Error("Providers config not set"); + } + const ContextProvider = providers_1.providers[name]; + const contextItem = context.find((c) => c.name === name); + if (!contextItem) { + throw new Error(`Context item for provider ${name} not found`); + } + return new ContextProvider(contextItem); + }); + return this; + } + render() { + if (this.isManuallyChanged) { + return this; + } + const fullContext = this.getFullContext(); + const rendered = nunjucks_1.default.compile(this.template.content).render(fullContext); + this.rendered = rendered || this.template.content; + return this; + } + getFullContext() { + return this.contextProvidersInstances.map((contextProvider) => { + return contextProvider.getContextItem(); + }); + } +} +exports.default = ExecutionUnitInput; diff --git a/dist/js/RuntimeItemsUILogicMixin.d.ts b/dist/js/RuntimeItemsUILogicMixin.d.ts new file mode 100644 index 00000000..d511e79a --- /dev/null +++ b/dist/js/RuntimeItemsUILogicMixin.d.ts @@ -0,0 +1,27 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { RuntimeItems } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; +import type { NameResultSchema } from "@mat3ra/code/dist/js/utils/object"; +import type { RuntimeItemsSchema } from "@mat3ra/esse/dist/js/types"; +type ItemKey = "results" | "monitors" | "preProcessors" | "postProcessors"; +export type RuntimeItemsUILogic = { + setRuntimeItemsToDefaultValues(): void; + _initRuntimeItems(config?: Partial): void; + toggleRuntimeItem(key: ItemKey, data: NameResultSchema, isAdding: boolean): void; + toggleResult(data: NameResultSchema, isAdding: boolean): void; + toggleMonitor(data: NameResultSchema, isAdding: boolean): void; + togglePreProcessor(data: NameResultSchema, isAdding: boolean): void; + togglePostProcessor(data: NameResultSchema, isAdding: boolean): void; + getResultByName(name: string): NameResultSchema | undefined; + get resultNames(): string[]; + get monitorNames(): string[]; + get postProcessorNames(): string[]; + get preProcessorNames(): string[]; +}; +type Base = InMemoryEntity & RuntimeItems & { + defaultResults: NameResultSchema[]; + defaultMonitors: NameResultSchema[]; + defaultPreProcessors: NameResultSchema[]; + defaultPostProcessors: NameResultSchema[]; +}; +export declare function runtimeItemsUILogicMixin(item: T): void; +export {}; diff --git a/dist/js/RuntimeItemsUILogicMixin.js b/dist/js/RuntimeItemsUILogicMixin.js new file mode 100644 index 00000000..4572573a --- /dev/null +++ b/dist/js/RuntimeItemsUILogicMixin.js @@ -0,0 +1,56 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.runtimeItemsUILogicMixin = runtimeItemsUILogicMixin; +// @ts-expect-error +const propertiesMixn = { + setRuntimeItemsToDefaultValues() { + this.results = this.defaultResults; + this.monitors = this.defaultMonitors; + this.preProcessors = this.defaultPreProcessors; + this.postProcessors = this.defaultPostProcessors; + }, + _initRuntimeItems(config) { + this.results = (config === null || config === void 0 ? void 0 : config.results) || this.defaultResults; + this.monitors = (config === null || config === void 0 ? void 0 : config.monitors) || this.defaultMonitors; + this.preProcessors = (config === null || config === void 0 ? void 0 : config.preProcessors) || this.defaultPreProcessors; + this.postProcessors = (config === null || config === void 0 ? void 0 : config.postProcessors) || this.defaultPostProcessors; + }, + toggleRuntimeItem(key, data, isAdding) { + if (isAdding) { + this[key] = [...this[key], data]; + } + else { + this[key] = this[key].filter((x) => x.name !== data.name); + } + }, + toggleResult(data, isAdding) { + this.toggleRuntimeItem("results", data, isAdding); + }, + toggleMonitor(data, isAdding) { + this.toggleRuntimeItem("monitors", data, isAdding); + }, + togglePreProcessor(data, isAdding) { + this.toggleRuntimeItem("preProcessors", data, isAdding); + }, + togglePostProcessor(data, isAdding) { + this.toggleRuntimeItem("postProcessors", data, isAdding); + }, + get resultNames() { + return this.results.map((r) => r.name); + }, + get monitorNames() { + return this.monitors.map((r) => r === null || r === void 0 ? void 0 : r.name); + }, + get postProcessorNames() { + return this.postProcessors.map((r) => r.name); + }, + get preProcessorNames() { + return this.preProcessors.map((r) => r.name); + }, + getResultByName(name) { + return this.results.find((r) => r.name === name); + }, +}; +function runtimeItemsUILogicMixin(item) { + Object.defineProperties(item, Object.getOwnPropertyDescriptors(propertiesMixn)); +} diff --git a/dist/js/context/context.js b/dist/js/context/context.js deleted file mode 100644 index 2a690bbb..00000000 --- a/dist/js/context/context.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _BoundaryConditionsFormDataProvider = require("./providers/BoundaryConditionsFormDataProvider"); -var _QENEBContextProvider = _interopRequireDefault(require("./providers/by_application/espresso/QENEBContextProvider")); -var _QEPWXContextProvider = _interopRequireDefault(require("./providers/by_application/espresso/QEPWXContextProvider")); -var _NWChemTotalEnergyContextProvider = _interopRequireDefault(require("./providers/by_application/nwchem/NWChemTotalEnergyContextProvider")); -var _VASPContextProvider = _interopRequireDefault(require("./providers/by_application/vasp/VASPContextProvider")); -var _VASPNEBContextProvider = _interopRequireDefault(require("./providers/by_application/vasp/VASPNEBContextProvider")); -var _CollinearMagnetizationContextProvider = require("./providers/CollinearMagnetizationContextProvider"); -var _HubbardContextProviderLegacy = require("./providers/HubbardContextProviderLegacy"); -var _HubbardJContextProvider = require("./providers/HubbardJContextProvider"); -var _HubbardUContextProvider = require("./providers/HubbardUContextProvider"); -var _HubbardVContextProvider = require("./providers/HubbardVContextProvider"); -var _IonDynamicsContextProvider = require("./providers/IonDynamicsContextProvider"); -var _MLSettingsContextProvider = require("./providers/MLSettingsContextProvider"); -var _MLTrainTestSplitContextProvider = require("./providers/MLTrainTestSplitContextProvider"); -var _NEBFormDataProvider = require("./providers/NEBFormDataProvider"); -var _NonCollinearMagnetizationContextProvider = require("./providers/NonCollinearMagnetizationContextProvider"); -var _PlanewaveCutoffsContextProvider = require("./providers/PlanewaveCutoffsContextProvider"); -var _PointsGridFormDataProvider = require("./providers/PointsGridFormDataProvider"); -var _PointsPathFormDataProvider = require("./providers/PointsPathFormDataProvider"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = { - BoundaryConditionsFormDataProvider: _BoundaryConditionsFormDataProvider.BoundaryConditionsFormDataProvider, - MLSettingsContextProvider: _MLSettingsContextProvider.MLSettingsContextProvider, - MLTrainTestSplitContextProvider: _MLTrainTestSplitContextProvider.MLTrainTestSplitContextProvider, - NEBFormDataProvider: _NEBFormDataProvider.NEBFormDataProvider, - PlanewaveCutoffsContextProvider: _PlanewaveCutoffsContextProvider.PlanewaveCutoffsContextProvider, - PointsGridFormDataProvider: _PointsGridFormDataProvider.PointsGridFormDataProvider, - PointsPathFormDataProvider: _PointsPathFormDataProvider.PointsPathFormDataProvider, - ExplicitPointsPathFormDataProvider: _PointsPathFormDataProvider.ExplicitPointsPathFormDataProvider, - ExplicitPointsPath2PIBAFormDataProvider: _PointsPathFormDataProvider.ExplicitPointsPath2PIBAFormDataProvider, - HubbardJContextProvider: _HubbardJContextProvider.HubbardJContextProvider, - HubbardUContextProvider: _HubbardUContextProvider.HubbardUContextProvider, - HubbardVContextProvider: _HubbardVContextProvider.HubbardVContextProvider, - HubbardContextProviderLegacy: _HubbardContextProviderLegacy.HubbardContextProviderLegacy, - IonDynamicsContextProvider: _IonDynamicsContextProvider.IonDynamicsContextProvider, - CollinearMagnetizationContextProvider: _CollinearMagnetizationContextProvider.CollinearMagnetizationContextProvider, - NonCollinearMagnetizationContextProvider: _NonCollinearMagnetizationContextProvider.NonCollinearMagnetizationContextProvider, - VASPContextProvider: _VASPContextProvider.default, - VASPNEBContextProvider: _VASPNEBContextProvider.default, - QEPWXContextProvider: _QEPWXContextProvider.default, - QENEBContextProvider: _QENEBContextProvider.default, - NWChemTotalEnergyContextProvider: _NWChemTotalEnergyContextProvider.default -}; \ No newline at end of file diff --git a/dist/js/context/mixins/ApplicationContextMixin.d.ts b/dist/js/context/mixins/ApplicationContextMixin.d.ts new file mode 100644 index 00000000..cb6fba53 --- /dev/null +++ b/dist/js/context/mixins/ApplicationContextMixin.d.ts @@ -0,0 +1,10 @@ +import type { Application } from "@mat3ra/ade"; +import type ContextProvider from "../providers/base/ContextProvider"; +export type ApplicationContextMixin = { + readonly application: Application; + initApplicationContextMixin(externalContext: ApplicationExternalContext): void; +}; +export type ApplicationExternalContext = { + application?: Application; +}; +export declare function applicationContextMixin(item: ContextProvider): void; diff --git a/dist/js/context/mixins/ApplicationContextMixin.js b/dist/js/context/mixins/ApplicationContextMixin.js index 1ed185cb..b93cbee6 100644 --- a/dist/js/context/mixins/ApplicationContextMixin.js +++ b/dist/js/context/mixins/ApplicationContextMixin.js @@ -1,19 +1,15 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.applicationContextMixin = applicationContextMixin; -var _settings = require("../providers/settings"); +const settings_1 = require("../providers/settings"); function applicationContextMixin(item) { - const properties = { - _application: undefined, - initApplicationContextMixin() { - this._application = this.config.context && this.config.context.application || _settings.globalSettings.Application.createDefault(); - }, - get application() { - return this._application; - } - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} \ No newline at end of file + // @ts-expect-error + const properties = { + initApplicationContextMixin(externalContext) { + var _a; + this.application = + (_a = externalContext.application) !== null && _a !== void 0 ? _a : settings_1.globalSettings.Application.createDefault(); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/context/mixins/ContextAndRenderFieldsMixin.d.ts b/dist/js/context/mixins/ContextAndRenderFieldsMixin.d.ts new file mode 100644 index 00000000..5edb0465 --- /dev/null +++ b/dist/js/context/mixins/ContextAndRenderFieldsMixin.d.ts @@ -0,0 +1,17 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types"; +export type Context = AnyObject; +export type ContextMixin = { + context: Context; + renderingContext: Context; + getRenderingContext(): Context; + updateRenderingContext(ctx: Context): void; + getPersistentContext(): Context; + updatePersistentContext(ctx: Context): void; + getCombinedContext(): Context; +}; +type AbstractBase = { + render(ctx: Context): void; +}; +export declare function contextMixin(item: T): asserts item is T & ContextMixin; +export {}; diff --git a/dist/js/context/mixins/ContextAndRenderFieldsMixin.js b/dist/js/context/mixins/ContextAndRenderFieldsMixin.js new file mode 100644 index 00000000..7f0b0a7f --- /dev/null +++ b/dist/js/context/mixins/ContextAndRenderFieldsMixin.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.contextMixin = contextMixin; +function contextMixin(item) { + // @ts-expect-error + const properties = { + get context() { + return this.requiredProp("context"); + }, + set context(ctx) { + this.setProp("context", ctx); + }, + renderingContext: {}, + updateRenderingContext(ctx) { + this.context = { ...this.renderingContext, ...ctx }; + }, + getRenderingContext() { + return this.renderingContext; + }, + getPersistentContext() { + return this.context; + }, + updatePersistentContext(ctx) { + this.context = { ...ctx }; + }, + getCombinedContext() { + return { + ...this.getPersistentContext(), + ...this.getRenderingContext(), + }; + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/context/mixins/ImportantSettingsProviderMixin.d.ts b/dist/js/context/mixins/ImportantSettingsProviderMixin.d.ts new file mode 100644 index 00000000..6d9b33ac --- /dev/null +++ b/dist/js/context/mixins/ImportantSettingsProviderMixin.d.ts @@ -0,0 +1,17 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +export interface ContextProvider { + domain?: string; +} +export type ImportantSettingsProvider = { + important: object; + setImportant(key: string, value: unknown): void; + importantSettingsProviders: ContextProvider[]; + isImportantEdited: boolean | undefined; +}; +type AbstractBase = { + contextProviders: ContextProvider[]; +}; +export type ImportantSettingsProviderInMemoryEntityConstructor = Constructor; +export declare function importantSettingsProviderMixin(item: T): asserts item is T & ImportantSettingsProvider; +export {}; diff --git a/dist/js/context/mixins/ImportantSettingsProviderMixin.js b/dist/js/context/mixins/ImportantSettingsProviderMixin.js new file mode 100644 index 00000000..6be5ff2a --- /dev/null +++ b/dist/js/context/mixins/ImportantSettingsProviderMixin.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.importantSettingsProviderMixin = importantSettingsProviderMixin; +const clone_1 = require("@mat3ra/code/dist/js/utils/clone"); +function importantSettingsProviderMixin(item) { + // @ts-expect-error + const properties = { + get important() { + return (0, clone_1.deepClone)(this._json.important || {}); + }, + setImportant(key, value) { + this.setProp("important", { [key]: value }); + }, + get importantSettingsProviders() { + return this.contextProviders.filter((p) => p.domain === "important"); + }, + get isImportantEdited() { + return this.prop("important.isEdited"); + }, + set isImportantEdited(bool) { + this.setProp("important", Object.assign(this.important, { isEdited: bool })); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/context/mixins/JobContextMixin.d.ts b/dist/js/context/mixins/JobContextMixin.d.ts new file mode 100644 index 00000000..dd504945 --- /dev/null +++ b/dist/js/context/mixins/JobContextMixin.d.ts @@ -0,0 +1,11 @@ +import type { JobSchema } from "@mat3ra/esse/dist/js/types"; +import type ContextProvider from "../providers/base/ContextProvider"; +export type JobContextMixin = { + isEdited: boolean; + job: JobSchema; + initJobContextMixin(externalContext: JobExternalContext): void; +}; +export type JobExternalContext = { + job: JobSchema; +}; +export default function jobContextMixin(item: ContextProvider): void; diff --git a/dist/js/context/mixins/JobContextMixin.js b/dist/js/context/mixins/JobContextMixin.js index bd98b7d6..c19fa9a9 100644 --- a/dist/js/context/mixins/JobContextMixin.js +++ b/dist/js/context/mixins/JobContextMixin.js @@ -1,39 +1,14 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.jobContextMixin = jobContextMixin; -const defaultJob = { - workflow: { - subworkflows: [], - units: [] - }, - status: "pre-submission", - compute: { - queue: "D", - nodes: 1, - ppn: 1, - timeLimit: "3600" - }, - _project: { - _id: "" - } -}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = jobContextMixin; function jobContextMixin(item) { - const properties = { - isEdited: false, - _job: defaultJob, - get job() { - return this._job; - }, - initJobContextMixin() { - const { - config - } = this; - this._job = config.context && config.context.job || defaultJob; - this.isEdited = false; // we always get the `defaultData` (recalculated from scratch, not persistent) - } - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} \ No newline at end of file + // @ts-expect-error + const properties = { + isEdited: false, + initJobContextMixin(externalContext) { + this.job = externalContext.job; + this.isEdited = false; // we always get the `defaultData` (recalculated from scratch, not persistent) + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/context/mixins/MaterialContextMixin.d.ts b/dist/js/context/mixins/MaterialContextMixin.d.ts new file mode 100644 index 00000000..d22f2b79 --- /dev/null +++ b/dist/js/context/mixins/MaterialContextMixin.d.ts @@ -0,0 +1,18 @@ +import type { OrderedInMemoryEntityInSet } from "@mat3ra/code/dist/js/entity/set/ordered/OrderedInMemoryEntityInSetMixin"; +import { Material } from "@mat3ra/made/dist/js/material"; +import type ContextProvider from "../providers/base/ContextProvider"; +export type OrderedMaterial = OrderedInMemoryEntityInSet & Material; +export type MaterialContextMixin = { + readonly isMaterialCreatedDefault: boolean; + readonly isMaterialUpdated: boolean; + material: OrderedMaterial; + extraData?: { + materialHash: string; + }; + initMaterialContextMixin(externalContext: MaterialExternalContext): void; + updateMaterialHash(): void; +}; +export type MaterialExternalContext = { + material: OrderedMaterial; +}; +export default function materialContextMixin(item: ContextProvider): void; diff --git a/dist/js/context/mixins/MaterialContextMixin.js b/dist/js/context/mixins/MaterialContextMixin.js index 4cd2a74c..92901e8d 100644 --- a/dist/js/context/mixins/MaterialContextMixin.js +++ b/dist/js/context/mixins/MaterialContextMixin.js @@ -1,40 +1,16 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.materialContextMixin = materialContextMixin; -var _settings = require("../providers/settings"); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = materialContextMixin; function materialContextMixin(item) { - const properties = { - _material: undefined, - updateMaterialHash() { - if (this.isEditedIsSetToFalseOnMaterialUpdate) this.isEdited = false; - this.extraData = { - materialHash: this.material.hash - }; - }, - // Workaround: Material.createDefault() used to initiate workflow reducer and hence here too - // does not have an id. Here we catch when such material is used and avoid resetting isEdited - get isMaterialCreatedDefault() { - return !this.material.id; - }, - get isMaterialUpdated() { - return Boolean(this.extraData && this.extraData.materialHash !== this.material.hash); - }, - get material() { - if (!this._material) { - throw new Error("Material is not set"); - } - return this._material; - }, - initMaterialContextMixin() { - this._material = this.config.context && this.config.context.material; - if (!this._material) { - this._material = _settings.globalSettings.Material.createDefault(); - } - this.updateMaterialHash(); - } - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} \ No newline at end of file + // @ts-expect-error + const properties = { + updateMaterialHash() { + this.extraData = { materialHash: this.material.hash }; + }, + initMaterialContextMixin(externalContext) { + this.material = externalContext.material; + this.updateMaterialHash(); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/context/mixins/MaterialsContextMixin.d.ts b/dist/js/context/mixins/MaterialsContextMixin.d.ts new file mode 100644 index 00000000..b7b6b9d7 --- /dev/null +++ b/dist/js/context/mixins/MaterialsContextMixin.d.ts @@ -0,0 +1,10 @@ +import type ContextProvider from "../providers/base/ContextProvider"; +import type { OrderedMaterial } from "./MaterialContextMixin"; +export type MaterialsContextMixin = { + materials: OrderedMaterial[]; + initMaterialsContextMixin(externalContext: MaterialsExternalContext): void; +}; +export type MaterialsExternalContext = { + materials: OrderedMaterial[]; +}; +export default function materialsContextMixin(item: ContextProvider): void; diff --git a/dist/js/context/mixins/MaterialsContextMixin.js b/dist/js/context/mixins/MaterialsContextMixin.js index 7c57fb5e..cf9165c2 100644 --- a/dist/js/context/mixins/MaterialsContextMixin.js +++ b/dist/js/context/mixins/MaterialsContextMixin.js @@ -1,19 +1,13 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.materialsContextMixin = materialsContextMixin; -var _settings = require("../providers/settings"); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = materialsContextMixin; function materialsContextMixin(item) { - const properties = { - get materials() { - return this._materials; - }, - initMaterialsContextMixin() { - const materials = this.config.context?.materials; - this._materials = materials && materials.length ? materials : [_settings.globalSettings.Material.createDefault()]; - } - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} \ No newline at end of file + // @ts-expect-error + const properties = { + materials: [], + initMaterialsContextMixin(externalContext) { + this.materials = externalContext.materials; + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/context/mixins/MaterialsSetContextMixin.d.ts b/dist/js/context/mixins/MaterialsSetContextMixin.d.ts new file mode 100644 index 00000000..4845cba3 --- /dev/null +++ b/dist/js/context/mixins/MaterialsSetContextMixin.d.ts @@ -0,0 +1,14 @@ +import type { OrderedMaterial } from "./MaterialContextMixin"; +type MaterialsSet = { + _id: string; +}; +export type MaterialsSetContextMixin = { + materialsSet: MaterialsSet; + initMaterialsSetContextMixin(externalContext: MaterialsSetContextProvider): void; + sortMaterialsByIndexInSet(materials?: OrderedMaterial[]): OrderedMaterial[]; +}; +type MaterialsSetContextProvider = { + materialsSet: MaterialsSet; +}; +export default function materialsSetContextMixin(item: MaterialsSetContextProvider): void; +export {}; diff --git a/dist/js/context/mixins/MaterialsSetContextMixin.js b/dist/js/context/mixins/MaterialsSetContextMixin.js index 1df111ff..c9ce29f5 100644 --- a/dist/js/context/mixins/MaterialsSetContextMixin.js +++ b/dist/js/context/mixins/MaterialsSetContextMixin.js @@ -1,25 +1,19 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.materialsSetContextMixin = materialsSetContextMixin; -var _utils = require("@mat3ra/code/dist/js/entity/set/ordered/utils"); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = materialsSetContextMixin; +const utils_1 = require("@mat3ra/code/dist/js/entity/set/ordered/utils"); function materialsSetContextMixin(item) { - const properties = { - _materialsSet: undefined, - get materialsSet() { - return this._materialsSet; - }, - initMaterialsSetContextMixin() { - this._materialsSet = this.config.context?.materialsSet; - }, - sortMaterialsByIndexInSet(materials = []) { - // DO NOT SORT IN PLACE AS IT CHANGES THE ORDER IN `this.materials` AND HAS SIDE EFFECTS (MaterialViewer). - return materials.concat().sort((a, b) => { - return (0, _utils.compareEntitiesInOrderedSetForSorting)(a, b, this.materialsSet._id, false); - }); - } - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} \ No newline at end of file + // @ts-expect-error + const properties = { + initMaterialsSetContextMixin(externalContext) { + this.materialsSet = externalContext.materialsSet; + }, + sortMaterialsByIndexInSet(materials = []) { + // DO NOT SORT IN PLACE AS IT CHANGES THE ORDER IN `this.materials` AND HAS SIDE EFFECTS (MaterialViewer). + return materials.concat().sort((a, b) => { + return (0, utils_1.compareEntitiesInOrderedSetForSorting)(a, b, this.materialsSet._id, false); + }); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/context/mixins/MethodDataContextMixin.d.ts b/dist/js/context/mixins/MethodDataContextMixin.d.ts new file mode 100644 index 00000000..046bf8e7 --- /dev/null +++ b/dist/js/context/mixins/MethodDataContextMixin.d.ts @@ -0,0 +1,21 @@ +import type { BaseMethod } from "@mat3ra/esse/dist/js/types"; +import type { AtomicElementValue } from "@mat3ra/made/dist/js/basis/elements"; +import type ContextProvider from "../providers/base/ContextProvider"; +type MethodData = BaseMethod["data"] & { + pseudo?: { + element: AtomicElementValue; + filename?: string; + path?: string; + }[]; +}; +export type MethodDataContextMixin = { + methodData: MethodData; + isEdited: boolean; + initMethodDataContextMixin(externalContext: MethodDataExternalContext): void; +}; +export type MethodDataExternalContext = { + methodData?: MethodData; + isEdited?: boolean; +}; +export default function methodDataContextMixin(item: ContextProvider): void; +export {}; diff --git a/dist/js/context/mixins/MethodDataContextMixin.js b/dist/js/context/mixins/MethodDataContextMixin.js index f26c7e11..7ea27498 100644 --- a/dist/js/context/mixins/MethodDataContextMixin.js +++ b/dist/js/context/mixins/MethodDataContextMixin.js @@ -1,48 +1,15 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.methodDataContextMixin = methodDataContextMixin; -var _cryptoJs = _interopRequireDefault(require("crypto-js")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = methodDataContextMixin; function methodDataContextMixin(item) { - const properties = { - _methodData: undefined, - isEdited: false, - methodDataHash: undefined, - extraData: undefined, - initMethodDataContextMixin() { - this._methodData = this.config.context && this.config.context.methodData || {}; - this.isEdited = Boolean(this.config.isEdited); - }, - /* @summary Replace the logic in constructor with this in order to enable passing `methodDataHash` between - * subsequent initializations of the derived class. Not used at present and kept for the record. - */ - _initMethodDataHash() { - this.methodDataHash = _cryptoJs.default.MD5(JSON.stringify(this.methodData)).toString(); - this.extraData = { - methodDataHash: this.methodDataHash - }; - if (!this._methodData) { - this._methodData = {}; - this.isEdited = false; - // Commented out to reduce effect on performance. Uncomment for debugging purposes. - // TODO: remove on next refactoring or convert to log - // console.warn("MethodDataContextMixin: methodData is undefined or null"); - } else if (this.isMethodDataUpdated) { - this.isEdited = false; - } else { - // eslint-disable-next-line no-undef - this.isEdited = config.isEdited; - } - }, - get methodData() { - return this._methodData; - }, - get isMethodDataUpdated() { - return Boolean(this.extraData && this.extraData.methodDataHash !== this.methodDataHash); - } - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} \ No newline at end of file + // @ts-expect-error + const properties = { + methodData: {}, + isEdited: false, + initMethodDataContextMixin(externalContext) { + this.methodData = externalContext.methodData || {}; + this.isEdited = Boolean(externalContext === null || externalContext === void 0 ? void 0 : externalContext.isEdited); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/context/mixins/WorkflowContextMixin.d.ts b/dist/js/context/mixins/WorkflowContextMixin.d.ts new file mode 100644 index 00000000..196a4f24 --- /dev/null +++ b/dist/js/context/mixins/WorkflowContextMixin.d.ts @@ -0,0 +1,15 @@ +import type { WorkflowSchema } from "@mat3ra/esse/dist/js/types"; +import type ContextProvider from "../providers/base/ContextProvider"; +type Workflow = WorkflowSchema & { + hasRelaxation?: boolean; +}; +export type WorkflowContextMixin = { + isEdited: boolean; + workflow: Workflow; + initWorkflowContextMixin(externalContext: WorkflowExternalContext): void; +}; +export type WorkflowExternalContext = { + workflow: Workflow; +}; +export default function workflowContextMixin(item: ContextProvider): void; +export {}; diff --git a/dist/js/context/mixins/WorkflowContextMixin.js b/dist/js/context/mixins/WorkflowContextMixin.js index f65c5e88..d1fa0f25 100644 --- a/dist/js/context/mixins/WorkflowContextMixin.js +++ b/dist/js/context/mixins/WorkflowContextMixin.js @@ -1,28 +1,14 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.workflowContextMixin = workflowContextMixin; -const defaultWorkflow = { - subworkflows: [], - units: [], - hasRelaxation: false -}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = workflowContextMixin; function workflowContextMixin(item) { - const properties = { - isEdited: false, - _workflow: defaultWorkflow, - get workflow() { - return this._workflow; - }, - initWorkflowContextMixin() { - const { - config - } = this; // as WorkflowConfig; - this._workflow = config.context && config.context.workflow || defaultWorkflow; - this.isEdited = false; // we always get the `defaultData` (recalculated from scratch, not persistent) - } - }; - Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); -} \ No newline at end of file + // @ts-expect-error + const properties = { + isEdited: false, + initWorkflowContextMixin(externalContext) { + this.workflow = externalContext.workflow; + this.isEdited = false; + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/context/providers.d.ts b/dist/js/context/providers.d.ts new file mode 100644 index 00000000..82ea9df5 --- /dev/null +++ b/dist/js/context/providers.d.ts @@ -0,0 +1,55 @@ +import BoundaryConditionsFormDataProvider from "./providers/BoundaryConditionsFormDataProvider"; +import QENEBContextProvider from "./providers/by_application/espresso/QENEBContextProvider"; +import QEPWXContextProvider from "./providers/by_application/espresso/QEPWXContextProvider"; +import NWChemTotalEnergyContextProvider from "./providers/by_application/nwchem/NWChemTotalEnergyContextProvider"; +import VASPContextProvider from "./providers/by_application/vasp/VASPContextProvider"; +import VASPNEBContextProvider from "./providers/by_application/vasp/VASPNEBContextProvider"; +import CollinearMagnetizationContextProvider from "./providers/CollinearMagnetizationContextProvider"; +import HubbardContextProviderLegacy from "./providers/Hubbard/HubbardContextProviderLegacy"; +import HubbardJContextProvider from "./providers/Hubbard/HubbardJContextProvider"; +import HubbardUContextProvider from "./providers/Hubbard/HubbardUContextProvider"; +import HubbardVContextProvider from "./providers/Hubbard/HubbardVContextProvider"; +import IonDynamicsContextProvider from "./providers/IonDynamicsContextProvider"; +import MLSettingsContextProvider from "./providers/MLSettingsContextProvider"; +import MLTrainTestSplitContextProvider from "./providers/MLTrainTestSplitContextProvider"; +import NEBFormDataProvider from "./providers/NEBFormDataProvider"; +import NonCollinearMagnetizationContextProvider from "./providers/NonCollinearMagnetizationContextProvider"; +import PlanewaveCutoffsContextProvider from "./providers/PlanewaveCutoffsContextProvider"; +import IGridFormDataManager from "./providers/PointsGrid/IGridFormDataManager"; +import KGridFormDataManager from "./providers/PointsGrid/KGridFormDataManager"; +import QGridFormDataManager from "./providers/PointsGrid/QGridFormDataManager"; +import ExplicitKPath2PIBAFormDataManager from "./providers/PointsPath/ExplicitKPath2PIBAFormDataManager"; +import ExplicitKPathFormDataManager from "./providers/PointsPath/ExplicitKPathFormDataManager"; +import IPathFormDataManager from "./providers/PointsPath/IPathFormDataManager"; +import KPathFormDataManager from "./providers/PointsPath/KPathFormDataManager"; +import QPathFormDataManager from "./providers/PointsPath/QPathFormDataManager"; +/** ******************************** + * Method-based context providers * + ********************************* */ +export declare const newWodeProviders: { + PlanewaveCutoffDataManager: typeof PlanewaveCutoffsContextProvider; + KGridFormDataManager: typeof KGridFormDataManager; + QGridFormDataManager: typeof QGridFormDataManager; + IGridFormDataManager: typeof IGridFormDataManager; + QPathFormDataManager: typeof QPathFormDataManager; + IPathFormDataManager: typeof IPathFormDataManager; + KPathFormDataManager: typeof KPathFormDataManager; + ExplicitKPathFormDataManager: typeof ExplicitKPathFormDataManager; + ExplicitKPath2PIBAFormDataManager: typeof ExplicitKPath2PIBAFormDataManager; + HubbardJContextManager: typeof HubbardJContextProvider; + HubbardUContextManager: typeof HubbardUContextProvider; + HubbardVContextManager: typeof HubbardVContextProvider; + HubbardContextManagerLegacy: typeof HubbardContextProviderLegacy; + NEBFormDataManager: typeof NEBFormDataProvider; + BoundaryConditionsFormDataManager: typeof BoundaryConditionsFormDataProvider; + MLSettingsDataManager: typeof MLSettingsContextProvider; + MLTrainTestSplitDataManager: typeof MLTrainTestSplitContextProvider; + IonDynamicsContextProvider: typeof IonDynamicsContextProvider; + CollinearMagnetizationDataManager: typeof CollinearMagnetizationContextProvider; + NonCollinearMagnetizationDataManager: typeof NonCollinearMagnetizationContextProvider; + QEPWXInputDataManager: typeof QEPWXContextProvider; + QENEBInputDataManager: typeof QENEBContextProvider; + VASPInputDataManager: typeof VASPContextProvider; + VASPNEBInputDataManager: typeof VASPNEBContextProvider; + NWChemInputDataManager: typeof NWChemTotalEnergyContextProvider; +}; diff --git a/dist/js/context/providers.js b/dist/js/context/providers.js index e2a2e1ea..21b20dea 100644 --- a/dist/js/context/providers.js +++ b/dist/js/context/providers.js @@ -1,199 +1,179 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.wodeProviders = void 0; -var _context = _interopRequireDefault(require("./context")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const { - BoundaryConditionsFormDataProvider, - MLSettingsContextProvider, - MLTrainTestSplitContextProvider, - NEBFormDataProvider, - PlanewaveCutoffsContextProvider, - PointsGridFormDataProvider, - PointsPathFormDataProvider, - ExplicitPointsPathFormDataProvider, - ExplicitPointsPath2PIBAFormDataProvider, - HubbardJContextProvider, - HubbardUContextProvider, - HubbardVContextProvider, - HubbardContextProviderLegacy, - IonDynamicsContextProvider, - CollinearMagnetizationContextProvider, - NonCollinearMagnetizationContextProvider, - VASPContextProvider, - VASPNEBContextProvider, - QEPWXContextProvider, - QENEBContextProvider, - NWChemTotalEnergyContextProvider -} = _context.default; -const CONTEXT_DOMAINS = { - important: "important" // used to generate `ImportantSettings` form +// import type { ContextProviderNameEnum as ProviderName } from "@mat3ra/esse/dist/js/types"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; }; -const _makeImportant = config => Object.assign(config, { - domain: CONTEXT_DOMAINS.important -}); - +Object.defineProperty(exports, "__esModule", { value: true }); +exports.newWodeProviders = void 0; +// import type ContextProvider from "./providers/base/ContextProvider"; +// import type { ContextItem } from "./providers/base/ContextProvider"; +const BoundaryConditionsFormDataProvider_1 = __importDefault(require("./providers/BoundaryConditionsFormDataProvider")); +const QENEBContextProvider_1 = __importDefault(require("./providers/by_application/espresso/QENEBContextProvider")); +const QEPWXContextProvider_1 = __importDefault(require("./providers/by_application/espresso/QEPWXContextProvider")); +const NWChemTotalEnergyContextProvider_1 = __importDefault(require("./providers/by_application/nwchem/NWChemTotalEnergyContextProvider")); +const VASPContextProvider_1 = __importDefault(require("./providers/by_application/vasp/VASPContextProvider")); +const VASPNEBContextProvider_1 = __importDefault(require("./providers/by_application/vasp/VASPNEBContextProvider")); +const CollinearMagnetizationContextProvider_1 = __importDefault(require("./providers/CollinearMagnetizationContextProvider")); +const HubbardContextProviderLegacy_1 = __importDefault(require("./providers/Hubbard/HubbardContextProviderLegacy")); +const HubbardJContextProvider_1 = __importDefault(require("./providers/Hubbard/HubbardJContextProvider")); +const HubbardUContextProvider_1 = __importDefault(require("./providers/Hubbard/HubbardUContextProvider")); +const HubbardVContextProvider_1 = __importDefault(require("./providers/Hubbard/HubbardVContextProvider")); +const IonDynamicsContextProvider_1 = __importDefault(require("./providers/IonDynamicsContextProvider")); +const MLSettingsContextProvider_1 = __importDefault(require("./providers/MLSettingsContextProvider")); +const MLTrainTestSplitContextProvider_1 = __importDefault(require("./providers/MLTrainTestSplitContextProvider")); +const NEBFormDataProvider_1 = __importDefault(require("./providers/NEBFormDataProvider")); +const NonCollinearMagnetizationContextProvider_1 = __importDefault(require("./providers/NonCollinearMagnetizationContextProvider")); +const PlanewaveCutoffsContextProvider_1 = __importDefault(require("./providers/PlanewaveCutoffsContextProvider")); +const IGridFormDataManager_1 = __importDefault(require("./providers/PointsGrid/IGridFormDataManager")); +const KGridFormDataManager_1 = __importDefault(require("./providers/PointsGrid/KGridFormDataManager")); +const QGridFormDataManager_1 = __importDefault(require("./providers/PointsGrid/QGridFormDataManager")); +const ExplicitKPath2PIBAFormDataManager_1 = __importDefault(require("./providers/PointsPath/ExplicitKPath2PIBAFormDataManager")); +const ExplicitKPathFormDataManager_1 = __importDefault(require("./providers/PointsPath/ExplicitKPathFormDataManager")); +const IPathFormDataManager_1 = __importDefault(require("./providers/PointsPath/IPathFormDataManager")); +const KPathFormDataManager_1 = __importDefault(require("./providers/PointsPath/KPathFormDataManager")); +const QPathFormDataManager_1 = __importDefault(require("./providers/PointsPath/QPathFormDataManager")); +// const CONTEXT_DOMAINS = { +// important: "important", // used to generate `ImportantSettings` form +// }; +// export type ProvidersConfig = Record< +// ProviderName, +// new ( +// config: ContextItem, +// domain?: string, +// entityName?: "unit" | "subworkflow", +// ) => ContextProvider +// >; /** ******************************** * Method-based context providers * ********************************* */ - -const wodeProviders = exports.wodeProviders = { - // NOTE: subworkflow-level data manager. Will override the unit-level data with the same name via subworkflow context. - PlanewaveCutoffDataManager: { - providerCls: PlanewaveCutoffsContextProvider, - config: _makeImportant({ - name: "cutoffs", - entityName: "subworkflow" - }) - }, - KGridFormDataManager: { - providerCls: PointsGridFormDataProvider, - config: _makeImportant({ - name: "kgrid" - }) - }, - QGridFormDataManager: { - providerCls: PointsGridFormDataProvider, - config: _makeImportant({ - name: "qgrid", - divisor: 5 - }) // Using less points for Qgrid by default - }, - IGridFormDataManager: { - providerCls: PointsGridFormDataProvider, - config: _makeImportant({ - name: "igrid", - divisor: 0.2 - }) // Using more points for interpolated grid by default - }, - QPathFormDataManager: { - providerCls: PointsPathFormDataProvider, - config: _makeImportant({ - name: "qpath" - }) - }, - IPathFormDataManager: { - providerCls: PointsPathFormDataProvider, - config: _makeImportant({ - name: "ipath" - }) - }, - KPathFormDataManager: { - providerCls: PointsPathFormDataProvider, - config: _makeImportant({ - name: "kpath" - }) - }, - ExplicitKPathFormDataManager: { - providerCls: ExplicitPointsPathFormDataProvider, - config: _makeImportant({ - name: "explicitKPath" - }) - }, - ExplicitKPath2PIBAFormDataManager: { - providerCls: ExplicitPointsPath2PIBAFormDataProvider, - config: _makeImportant({ - name: "explicitKPath2PIBA" - }) - }, - HubbardJContextManager: { - providerCls: HubbardJContextProvider, - config: _makeImportant({ - name: "hubbard_j" - }) - }, - HubbardUContextManager: { - providerCls: HubbardUContextProvider, - config: _makeImportant({ - name: "hubbard_u" - }) - }, - HubbardVContextManager: { - providerCls: HubbardVContextProvider, - config: _makeImportant({ - name: "hubbard_v" - }) - }, - HubbardContextManagerLegacy: { - providerCls: HubbardContextProviderLegacy, - config: _makeImportant({ - name: "hubbard_legacy" - }) - }, - // NEBFormDataManager context is stored under the same key (`input`) as InputDataManager contexts. - NEBFormDataManager: { - providerCls: NEBFormDataProvider, - config: _makeImportant({ - name: "neb" - }) - }, - BoundaryConditionsFormDataManager: { - providerCls: BoundaryConditionsFormDataProvider, - config: _makeImportant({ - name: "boundaryConditions" - }) - }, - MLSettingsDataManager: { - providerCls: MLSettingsContextProvider, - config: _makeImportant({ - name: "mlSettings" - }) - }, - MLTrainTestSplitDataManager: { - providerCls: MLTrainTestSplitContextProvider, - config: _makeImportant({ - name: "mlTrainTestSplit" - }) - }, - IonDynamicsContextProvider: { - providerCls: IonDynamicsContextProvider, - config: _makeImportant({ - name: "dynamics" - }) - }, - CollinearMagnetizationDataManager: { - providerCls: CollinearMagnetizationContextProvider, - config: _makeImportant({ - name: "collinearMagnetization" - }) - }, - NonCollinearMagnetizationDataManager: { - providerCls: NonCollinearMagnetizationContextProvider, - config: _makeImportant({ - name: "nonCollinearMagnetization" - }) - }, - QEPWXInputDataManager: { - providerCls: QEPWXContextProvider, - config: { - name: "input" - } - }, - QENEBInputDataManager: { - providerCls: QENEBContextProvider, - config: { - name: "input" - } - }, - VASPInputDataManager: { - providerCls: VASPContextProvider, - config: { - name: "input" - } - }, - VASPNEBInputDataManager: { - providerCls: VASPNEBContextProvider, - config: { - name: "input" - } - }, - NWChemInputDataManager: { - providerCls: NWChemTotalEnergyContextProvider, - config: { - name: "input" - } - } -}; \ No newline at end of file +// export const wodeProviders = { +// // NOTE: subworkflow-level data manager. Will override the unit-level data with the same name via subworkflow context. +// PlanewaveCutoffDataManager: { +// providerCls: PlanewaveCutoffsContextProvider, +// config: _makeImportant({ name: "cutoffs", entityName: "subworkflow" }), +// }, +// KGridFormDataManager: { +// providerCls: PointsGridFormDataProvider, +// config: _makeImportant({ name: "kgrid" }), +// }, +// QGridFormDataManager: { +// providerCls: PointsGridFormDataProvider, +// config: _makeImportant({ name: "qgrid", divisor: 5 }), // Using less points for Qgrid by default +// }, +// IGridFormDataManager: { +// providerCls: PointsGridFormDataProvider, +// config: _makeImportant({ name: "igrid", divisor: 0.2 }), // Using more points for interpolated grid by default +// }, +// QPathFormDataManager: { +// providerCls: PointsPathFormDataProvider, +// config: _makeImportant({ name: "qpath" }), +// }, +// IPathFormDataManager: { +// providerCls: PointsPathFormDataProvider, +// config: _makeImportant({ name: "ipath" }), +// }, +// KPathFormDataManager: { +// providerCls: PointsPathFormDataProvider, +// config: _makeImportant({ name: "kpath" }), +// }, +// ExplicitKPathFormDataManager: { +// providerCls: ExplicitPointsPathFormDataProvider, +// config: _makeImportant({ name: "explicitKPath" }), +// }, +// ExplicitKPath2PIBAFormDataManager: { +// providerCls: ExplicitPointsPath2PIBAFormDataProvider, +// config: _makeImportant({ name: "explicitKPath2PIBA" }), +// }, +// HubbardJContextManager: { +// providerCls: HubbardJContextProvider, +// config: _makeImportant({ name: "hubbard_j" }), +// }, +// HubbardUContextManager: { +// providerCls: HubbardUContextProvider, +// config: _makeImportant({ name: "hubbard_u" }), +// }, +// HubbardVContextManager: { +// providerCls: HubbardVContextProvider, +// config: _makeImportant({ name: "hubbard_v" }), +// }, +// HubbardContextManagerLegacy: { +// providerCls: HubbardContextProviderLegacy, +// config: _makeImportant({ name: "hubbard_legacy" }), +// }, +// // NEBFormDataManager context is stored under the same key (`input`) as InputDataManager contexts. +// NEBFormDataManager: { +// providerCls: NEBFormDataProvider, +// config: _makeImportant({ name: "neb" }), +// }, +// BoundaryConditionsFormDataManager: { +// providerCls: BoundaryConditionsFormDataProvider, +// config: _makeImportant({ name: "boundaryConditions" }), +// }, +// MLSettingsDataManager: { +// providerCls: MLSettingsContextProvider, +// config: _makeImportant({ name: "mlSettings" }), +// }, +// MLTrainTestSplitDataManager: { +// providerCls: MLTrainTestSplitContextProvider, +// config: _makeImportant({ name: "mlTrainTestSplit" }), +// }, +// IonDynamicsContextProvider: { +// providerCls: IonDynamicsContextProvider, +// config: _makeImportant({ name: "dynamics" }), +// }, +// CollinearMagnetizationDataManager: { +// providerCls: CollinearMagnetizationContextProvider, +// config: _makeImportant({ name: "collinearMagnetization" }), +// }, +// NonCollinearMagnetizationDataManager: { +// providerCls: NonCollinearMagnetizationContextProvider, +// config: _makeImportant({ name: "nonCollinearMagnetization" }), +// }, +// QEPWXInputDataManager: { +// providerCls: QEPWXContextProvider, +// config: { name: "input" }, +// }, +// QENEBInputDataManager: { +// providerCls: QENEBContextProvider, +// config: { name: "input" }, +// }, +// VASPInputDataManager: { +// providerCls: VASPContextProvider, +// config: { name: "input" }, +// }, +// VASPNEBInputDataManager: { +// providerCls: VASPNEBContextProvider, +// config: { name: "input" }, +// }, +// NWChemInputDataManager: { +// providerCls: NWChemTotalEnergyContextProvider, +// config: { name: "input" }, +// }, +// }; +exports.newWodeProviders = { + PlanewaveCutoffDataManager: PlanewaveCutoffsContextProvider_1.default, + KGridFormDataManager: KGridFormDataManager_1.default, + QGridFormDataManager: QGridFormDataManager_1.default, + IGridFormDataManager: IGridFormDataManager_1.default, + QPathFormDataManager: QPathFormDataManager_1.default, + IPathFormDataManager: IPathFormDataManager_1.default, + KPathFormDataManager: KPathFormDataManager_1.default, + ExplicitKPathFormDataManager: ExplicitKPathFormDataManager_1.default, + ExplicitKPath2PIBAFormDataManager: ExplicitKPath2PIBAFormDataManager_1.default, + HubbardJContextManager: HubbardJContextProvider_1.default, + HubbardUContextManager: HubbardUContextProvider_1.default, + HubbardVContextManager: HubbardVContextProvider_1.default, + HubbardContextManagerLegacy: HubbardContextProviderLegacy_1.default, + NEBFormDataManager: NEBFormDataProvider_1.default, + BoundaryConditionsFormDataManager: BoundaryConditionsFormDataProvider_1.default, + MLSettingsDataManager: MLSettingsContextProvider_1.default, + MLTrainTestSplitDataManager: MLTrainTestSplitContextProvider_1.default, + IonDynamicsContextProvider: IonDynamicsContextProvider_1.default, + CollinearMagnetizationDataManager: CollinearMagnetizationContextProvider_1.default, + NonCollinearMagnetizationDataManager: NonCollinearMagnetizationContextProvider_1.default, + QEPWXInputDataManager: QEPWXContextProvider_1.default, + QENEBInputDataManager: QENEBContextProvider_1.default, + VASPInputDataManager: VASPContextProvider_1.default, + VASPNEBInputDataManager: VASPNEBContextProvider_1.default, + NWChemInputDataManager: NWChemTotalEnergyContextProvider_1.default, +}; diff --git a/dist/js/context/providers/BoundaryConditionsFormDataProvider.d.ts b/dist/js/context/providers/BoundaryConditionsFormDataProvider.d.ts new file mode 100644 index 00000000..61f6d123 --- /dev/null +++ b/dist/js/context/providers/BoundaryConditionsFormDataProvider.d.ts @@ -0,0 +1,29 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { BoundaryConditionsDataProviderSchema } from "@mat3ra/esse/dist/js/types"; +import { type MaterialContextMixin, type MaterialExternalContext } from "../mixins/MaterialContextMixin"; +import type { ContextItem, Domain } from "./base/ContextProvider"; +import JSONSchemaDataProvider, { type JinjaExternalContext } from "./base/JSONSchemaDataProvider"; +type Name = "boundaryConditions"; +type Data = BoundaryConditionsDataProviderSchema; +type ExternalContext = JinjaExternalContext & MaterialExternalContext; +type Base = typeof JSONSchemaDataProvider & Constructor; +declare const BoundaryConditionsFormDataProvider_base: Base; +export default class BoundaryConditionsFormDataProvider extends BoundaryConditionsFormDataProvider_base { + readonly name: Name; + readonly domain: Domain; + readonly humanName = "Boundary Conditions"; + readonly uiSchema: { + type: { + "ui:disabled": boolean; + }; + offset: { + "ui:disabled": boolean; + }; + electricField: {}; + targetFermiEnergy: {}; + }; + constructor(contextItem: ContextItem, externalContext: ExternalContext); + getDefaultData(): Data; + get jsonSchema(): import("json-schema").JSONSchema7 | undefined; +} +export {}; diff --git a/dist/js/context/providers/BoundaryConditionsFormDataProvider.js b/dist/js/context/providers/BoundaryConditionsFormDataProvider.js index 9a5fb25c..3dd1d4ca 100644 --- a/dist/js/context/providers/BoundaryConditionsFormDataProvider.js +++ b/dist/js/context/providers/BoundaryConditionsFormDataProvider.js @@ -1,84 +1,51 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.BoundaryConditionsFormDataProvider = void 0; -var _ade = require("@mat3ra/ade"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _made = require("@mat3ra/made"); -var _utils = require("@mat3ra/utils"); -var _MaterialContextMixin = require("../mixins/MaterialContextMixin"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class BoundaryConditionsFormDataProvider extends _ade.JSONSchemaFormDataProvider { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/boundary-conditions-data-provider"); - this.initMaterialContextMixin(); - } - get boundaryConditions() { - return this.material.metadata.boundaryConditions || {}; - } - - // eslint-disable-next-line class-methods-use-this - get defaultData() { - return { - type: this.boundaryConditions.type || "pbc", - offset: this.boundaryConditions.offset || 0, - electricField: 0, - targetFermiEnergy: 0 - }; - } - get jsonSchemaPatchConfig() { - const defaults = this.defaultData; - return { - type: { - default: defaults.type - }, - offset: { - default: defaults.offset - }, - electricField: { - default: defaults.electricField - }, - targetFermiEnergy: { - default: defaults.targetFermiEnergy - } - }; - } - - // TODO: MOVE to WA/wove instantiation - // eslint-disable-next-line class-methods-use-this - get uiSchema() { - return { - type: { - "ui:disabled": true - }, - offset: { - "ui:disabled": true - }, - electricField: {}, - targetFermiEnergy: {} - }; - } - - // eslint-disable-next-line class-methods-use-this - get humanName() { - return "Boundary Conditions"; - } - yieldDataForRendering() { - const data = _utils.Utils.clone.deepClone(this.yieldData()); - data.boundaryConditions.offset *= _made.Made.coefficients.ANGSTROM_TO_BOHR; - data.boundaryConditions.targetFermiEnergy *= _made.Made.coefficients.EV_TO_RY; - data.boundaryConditions.electricField *= _made.Made.coefficients.EV_A_TO_RY_BOHR; - return data; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const MaterialContextMixin_1 = __importDefault(require("../mixins/MaterialContextMixin")); +const JSONSchemaDataProvider_1 = __importDefault(require("./base/JSONSchemaDataProvider")); +const jsonSchemaId = "context-providers-directory/boundary-conditions-data-provider"; +class BoundaryConditionsFormDataProvider extends JSONSchemaDataProvider_1.default { + constructor(contextItem, externalContext) { + super(contextItem, externalContext); + this.name = "boundaryConditions"; + this.domain = "important"; + this.humanName = "Boundary Conditions"; + this.uiSchema = { + type: { "ui:disabled": true }, + offset: { "ui:disabled": true }, + electricField: {}, + targetFermiEnergy: {}, + }; + this.initMaterialContextMixin(externalContext); + } + getDefaultData() { + var _a, _b, _c, _d, _e, _f; + return { + type: ((_c = (_b = (_a = this.material) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.boundaryConditions) === null || _c === void 0 ? void 0 : _c.type) || "pbc", + offset: ((_f = (_e = (_d = this.material) === null || _d === void 0 ? void 0 : _d.metadata) === null || _e === void 0 ? void 0 : _e.boundaryConditions) === null || _f === void 0 ? void 0 : _f.offset) || 0, + electricField: 0, + targetFermiEnergy: 0, + }; + } + // yieldDataForRendering() { + // const data = Utils.clone.deepClone(this.getContextItem()); + // data.boundaryConditions.offset *= Made.coefficients.ANGSTROM_TO_BOHR; + // data.boundaryConditions.targetFermiEnergy *= Made.coefficients.EV_TO_RY; + // data.boundaryConditions.electricField *= Made.coefficients.EV_A_TO_RY_BOHR; + // return data; + // } + get jsonSchema() { + const defaults = this.getDefaultData(); + return JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + type: { default: defaults.type }, + offset: { default: defaults.offset }, + electricField: { default: defaults.electricField }, + targetFermiEnergy: { default: defaults.targetFermiEnergy }, + }); + } } -exports.BoundaryConditionsFormDataProvider = BoundaryConditionsFormDataProvider; -(0, _MaterialContextMixin.materialContextMixin)(BoundaryConditionsFormDataProvider.prototype); \ No newline at end of file +exports.default = BoundaryConditionsFormDataProvider; +(0, MaterialContextMixin_1.default)(BoundaryConditionsFormDataProvider.prototype); diff --git a/dist/js/context/providers/CollinearMagnetizationContextProvider.d.ts b/dist/js/context/providers/CollinearMagnetizationContextProvider.d.ts new file mode 100644 index 00000000..8d71423a --- /dev/null +++ b/dist/js/context/providers/CollinearMagnetizationContextProvider.d.ts @@ -0,0 +1,41 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { CollinearMagnetizationContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import { type MaterialContextMixin, type MaterialExternalContext } from "../mixins/MaterialContextMixin"; +import type { ContextItem, Domain } from "./base/ContextProvider"; +import JSONSchemaDataProvider, { type JinjaExternalContext } from "./base/JSONSchemaDataProvider"; +type Name = "collinearMagnetization"; +type Data = CollinearMagnetizationContextProviderSchema; +type ExternalContext = JinjaExternalContext & MaterialExternalContext; +type Base = typeof JSONSchemaDataProvider & Constructor; +declare const CollinearMagnetizationContextProvider_base: Base; +export default class CollinearMagnetizationContextProvider extends CollinearMagnetizationContextProvider_base { + readonly name: Name; + readonly domain: Domain; + readonly jsonSchema: JSONSchema7 | undefined; + private readonly isTotalMagnetization; + private readonly firstElement; + private readonly uniqueElementsWithLabels; + constructor(contextItem: ContextItem, externalContext: ExternalContext); + getDefaultData(): Data; + setData(data: Data): void; + get uiSchemaStyled(): { + startingMagnetization: { + items: { + atomicSpecies: { + "ui:classNames": string; + }; + value: { + "ui:classNames": string; + }; + }; + "ui:readonly": boolean; + }; + isTotalMagnetization: {}; + totalMagnetization: { + "ui:classNames": string; + "ui:readonly": boolean; + }; + }; +} +export {}; diff --git a/dist/js/context/providers/CollinearMagnetizationContextProvider.js b/dist/js/context/providers/CollinearMagnetizationContextProvider.js index e0c682e0..ec135ef6 100644 --- a/dist/js/context/providers/CollinearMagnetizationContextProvider.js +++ b/dist/js/context/providers/CollinearMagnetizationContextProvider.js @@ -1,96 +1,87 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.CollinearMagnetizationContextProvider = void 0; -var _ade = require("@mat3ra/ade"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _lodash = _interopRequireDefault(require("lodash")); -var _MaterialContextMixin = require("../mixins/MaterialContextMixin"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class CollinearMagnetizationContextProvider extends _ade.JSONSchemaFormDataProvider { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/collinear-magnetization-context-provider"); - _defineProperty(this, "indexOfElement", element => { - return this.uniqueElementsWithLabels.indexOf(element) + 1; - }); - _defineProperty(this, "transformData", data => { - const startingMagnetizationWithIndex = data.startingMagnetization.map(row => ({ - ...row, - index: this.indexOfElement(row.atomicSpecies) - })); - return { - ...data, - startingMagnetization: startingMagnetizationWithIndex - }; - }); - this.initMaterialContextMixin(); - this.firstElement = this.uniqueElementsWithLabels?.length > 0 ? this.uniqueElementsWithLabels[0] : ""; - this.isTotalMagnetization = _lodash.default.get(this.data, "isTotalMagnetization", false); - } - get uniqueElementsWithLabels() { - const elementsWithLabelsArray = this.material?.Basis?.elementsWithLabelsArray || []; - return [...new Set(elementsWithLabelsArray)]; - } - get defaultData() { - return { - startingMagnetization: [{ - index: 1, - atomicSpecies: this.firstElement, - value: 0.0 - }], - isTotalMagnetization: false, - totalMagnetization: 0.0 - }; - } - get jsonSchemaPatchConfig() { - return { - "properties.startingMagnetization": { - maxItems: this.uniqueElementsWithLabels.length - }, - "properties.startingMagnetization.items.properties.atomicSpecies": { - enum: this.uniqueElementsWithLabels, - default: this.firstElement - }, - "properties.startingMagnetization.items.properties.value": { - default: 0.0 - }, - "properties.isTotalMagnetization": { - default: false - }, - "properties.totalMagnetization": { - default: 0.0 - } - }; - } - get uiSchemaStyled() { - return { - startingMagnetization: { - items: { - atomicSpecies: { - "ui:classNames": "col-xs-3" - }, - value: { - "ui:classNames": "col-xs-6" - } - }, - "ui:readonly": this.isTotalMagnetization - }, - isTotalMagnetization: {}, - totalMagnetization: { - "ui:classNames": "col-xs-6", - "ui:readonly": !this.isTotalMagnetization - } - }; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const MaterialContextMixin_1 = __importDefault(require("../mixins/MaterialContextMixin")); +const JSONSchemaDataProvider_1 = __importDefault(require("./base/JSONSchemaDataProvider")); +const jsonSchemaId = "context-providers-directory/collinear-magnetization-context-provider"; +class CollinearMagnetizationContextProvider extends JSONSchemaDataProvider_1.default { + constructor(contextItem, externalContext) { + var _a, _b, _c, _d; + super(contextItem, externalContext); + this.name = "collinearMagnetization"; + this.domain = "important"; + this.initMaterialContextMixin(externalContext); + this.uniqueElementsWithLabels = [ + ...new Set(((_b = (_a = this.material) === null || _a === void 0 ? void 0 : _a.Basis) === null || _b === void 0 ? void 0 : _b.elementsWithLabelsArray) || []), + ]; + this.firstElement = + ((_c = this.uniqueElementsWithLabels) === null || _c === void 0 ? void 0 : _c.length) > 0 ? this.uniqueElementsWithLabels[0] : ""; + this.isTotalMagnetization = ((_d = this.data) === null || _d === void 0 ? void 0 : _d.isTotalMagnetization) || false; + this.jsonSchema = JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + "properties.startingMagnetization": { + maxItems: this.uniqueElementsWithLabels.length, + }, + "properties.startingMagnetization.items.properties.atomicSpecies": { + enum: this.uniqueElementsWithLabels, + default: this.firstElement, + }, + "properties.startingMagnetization.items.properties.value": { + default: 0.0, + }, + "properties.isTotalMagnetization": { + default: false, + }, + "properties.totalMagnetization": { + default: 0.0, + }, + }); + } + getDefaultData() { + return { + startingMagnetization: [ + { + index: 1, + atomicSpecies: this.firstElement, + value: 0.0, + }, + ], + isTotalMagnetization: false, + totalMagnetization: 0.0, + }; + } + setData(data) { + const startingMagnetization = data.startingMagnetization.map((row) => ({ + ...row, + index: this.uniqueElementsWithLabels.indexOf(row.atomicSpecies) + 1, + })); + super.setData({ + ...data, + startingMagnetization, + }); + } + get uiSchemaStyled() { + return { + startingMagnetization: { + items: { + atomicSpecies: { + "ui:classNames": "col-xs-3", + }, + value: { + "ui:classNames": "col-xs-6", + }, + }, + "ui:readonly": this.isTotalMagnetization, + }, + isTotalMagnetization: {}, + totalMagnetization: { + "ui:classNames": "col-xs-6", + "ui:readonly": !this.isTotalMagnetization, + }, + }; + } } -exports.CollinearMagnetizationContextProvider = CollinearMagnetizationContextProvider; -(0, _MaterialContextMixin.materialContextMixin)(CollinearMagnetizationContextProvider.prototype); \ No newline at end of file +exports.default = CollinearMagnetizationContextProvider; +(0, MaterialContextMixin_1.default)(CollinearMagnetizationContextProvider.prototype); diff --git a/dist/js/context/providers/Hubbard/HubbardContextProvider.d.ts b/dist/js/context/providers/Hubbard/HubbardContextProvider.d.ts new file mode 100644 index 00000000..a9bcbfc2 --- /dev/null +++ b/dist/js/context/providers/Hubbard/HubbardContextProvider.d.ts @@ -0,0 +1,19 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import { type MaterialContextMixin, type MaterialExternalContext } from "../../mixins/MaterialContextMixin"; +import type { ContextItem, Domain } from "../base/ContextProvider"; +import JSONSchemaDataProvider, { type JinjaExternalContext } from "../base/JSONSchemaDataProvider"; +type HubbardName = "hubbard_u" | "hubbard_j" | "hubbard_v" | "hubbard_legacy"; +export type HubbardExternalContext = JinjaExternalContext & MaterialExternalContext; +type Base = typeof JSONSchemaDataProvider & Constructor; +declare const HubbardContextProvider_base: Base; +export default abstract class HubbardContextProvider extends HubbardContextProvider_base { + abstract readonly name: N; + abstract getDefaultData(): D; + readonly domain: Domain; + protected readonly uniqueElementsWithLabels: string[]; + protected readonly firstElement: string; + protected readonly secondSpecies: string; + protected readonly orbitalList: string[]; + constructor(contextItem: ContextItem, externalContext: EC); +} +export {}; diff --git a/dist/js/context/providers/Hubbard/HubbardContextProvider.js b/dist/js/context/providers/Hubbard/HubbardContextProvider.js new file mode 100644 index 00000000..2cfd1a4a --- /dev/null +++ b/dist/js/context/providers/Hubbard/HubbardContextProvider.js @@ -0,0 +1,46 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const MaterialContextMixin_1 = __importDefault(require("../../mixins/MaterialContextMixin")); +const JSONSchemaDataProvider_1 = __importDefault(require("../base/JSONSchemaDataProvider")); +class HubbardContextProvider extends JSONSchemaDataProvider_1.default { + constructor(contextItem, externalContext) { + var _a, _b, _c; + super(contextItem, externalContext); + this.domain = "important"; + this.orbitalList = [ + "2p", + "3s", + "3p", + "3d", + "4s", + "4p", + "4d", + "4f", + "5s", + "5p", + "5d", + "5f", + "6s", + "6p", + "6d", + "7s", + "7p", + "7d", + ]; + this.initMaterialContextMixin(externalContext); + this.uniqueElementsWithLabels = [ + ...new Set(((_a = this.material.Basis) === null || _a === void 0 ? void 0 : _a.elementsWithLabelsArray) || []), + ]; + this.firstElement = + ((_b = this.uniqueElementsWithLabels) === null || _b === void 0 ? void 0 : _b.length) > 0 ? this.uniqueElementsWithLabels[0] : ""; + this.secondSpecies = + ((_c = this.uniqueElementsWithLabels) === null || _c === void 0 ? void 0 : _c.length) > 1 + ? this.uniqueElementsWithLabels[1] + : this.firstElement; + } +} +exports.default = HubbardContextProvider; +(0, MaterialContextMixin_1.default)(HubbardContextProvider.prototype); diff --git a/dist/js/context/providers/Hubbard/HubbardContextProviderLegacy.d.ts b/dist/js/context/providers/Hubbard/HubbardContextProviderLegacy.d.ts new file mode 100644 index 00000000..953b9c77 --- /dev/null +++ b/dist/js/context/providers/Hubbard/HubbardContextProviderLegacy.d.ts @@ -0,0 +1,27 @@ +import type { HubbardLegacyContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import type { ContextItem, Domain } from "../base/ContextProvider"; +import HubbardContextProvider, { type HubbardExternalContext } from "./HubbardContextProvider"; +type Name = "hubbard_legacy"; +type Data = HubbardLegacyContextProviderSchema; +export default class HubbardContextProviderLegacy extends HubbardContextProvider { + readonly name: Name; + readonly domain: Domain; + readonly jsonSchema: JSONSchema7 | undefined; + readonly uiSchemaStyled: { + "ui:options": { + addable: boolean; + orderable: boolean; + removable: boolean; + }; + items: { + atomicSpeciesIndex: { + "ui:readonly": boolean; + }; + }; + }; + constructor(contextItem: ContextItem, externalContext: HubbardExternalContext); + getDefaultData(): Data; + setData(data: Data): void; +} +export {}; diff --git a/dist/js/context/providers/Hubbard/HubbardContextProviderLegacy.js b/dist/js/context/providers/Hubbard/HubbardContextProviderLegacy.js new file mode 100644 index 00000000..cfb6db88 --- /dev/null +++ b/dist/js/context/providers/Hubbard/HubbardContextProviderLegacy.js @@ -0,0 +1,60 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const HubbardContextProvider_1 = __importDefault(require("./HubbardContextProvider")); +const defaultHubbardConfig = { + hubbardUValue: 1.0, +}; +const jsonSchemaId = "context-providers-directory/hubbard-legacy-context-provider"; +class HubbardContextProviderLegacy extends HubbardContextProvider_1.default { + constructor(contextItem, externalContext) { + super(contextItem, externalContext); + this.name = "hubbard_legacy"; + this.domain = "important"; + this.uiSchemaStyled = { + "ui:options": { + addable: true, + orderable: false, + removable: true, + }, + items: { + atomicSpeciesIndex: { "ui:readonly": true }, + }, + }; + this.jsonSchema = JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + "items.properties.atomicSpecies": { + enum: this.uniqueElementsWithLabels, + }, + "items.properties.hubbardUValue": { + default: defaultHubbardConfig.hubbardUValue, + }, + }); + } + getDefaultData() { + var _a; + return [ + { + ...defaultHubbardConfig, + atomicSpecies: this.firstElement, + atomicSpeciesIndex: ((_a = this.uniqueElementsWithLabels) === null || _a === void 0 ? void 0 : _a.length) > 0 ? 1 : undefined, + }, + ]; + } + setData(data) { + const hubbardUValues = data.map((row) => { + var _a; + const atomicSpeciesIndex = ((_a = this.uniqueElementsWithLabels) === null || _a === void 0 ? void 0 : _a.length) > 0 + ? this.uniqueElementsWithLabels.indexOf(row.atomicSpecies || "") + 1 + : undefined; + return { + ...row, + atomicSpeciesIndex, + }; + }); + super.setData(hubbardUValues); + } +} +exports.default = HubbardContextProviderLegacy; diff --git a/dist/js/context/providers/Hubbard/HubbardJContextProvider.d.ts b/dist/js/context/providers/Hubbard/HubbardJContextProvider.d.ts new file mode 100644 index 00000000..0334c3d9 --- /dev/null +++ b/dist/js/context/providers/Hubbard/HubbardJContextProvider.d.ts @@ -0,0 +1,20 @@ +import type { HubbardJContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import type { ContextItem } from "../base/ContextProvider"; +import HubbardContextProvider, { type HubbardExternalContext } from "./HubbardContextProvider"; +type Name = "hubbard_j"; +type Data = HubbardJContextProviderSchema; +export default class HubbardJContextProvider extends HubbardContextProvider { + readonly name: Name; + readonly uiSchemaStyled: { + "ui:options": { + addable: boolean; + orderable: boolean; + removable: boolean; + }; + }; + readonly jsonSchema: JSONSchema7 | undefined; + constructor(contextItem: ContextItem, externalContext: HubbardExternalContext); + getDefaultData(): Data; +} +export {}; diff --git a/dist/js/context/providers/Hubbard/HubbardJContextProvider.js b/dist/js/context/providers/Hubbard/HubbardJContextProvider.js new file mode 100644 index 00000000..928936df --- /dev/null +++ b/dist/js/context/providers/Hubbard/HubbardJContextProvider.js @@ -0,0 +1,52 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const HubbardContextProvider_1 = __importDefault(require("./HubbardContextProvider")); +const defaultHubbardConfig = { + paramType: "J", + atomicSpecies: "", + atomicOrbital: "2p", + value: 1.0, +}; +const jsonSchemaId = "context-providers-directory/hubbard-j-context-provider"; +class HubbardJContextProvider extends HubbardContextProvider_1.default { + constructor(contextItem, externalContext) { + super(contextItem, externalContext); + this.name = "hubbard_j"; + this.uiSchemaStyled = { + "ui:options": { + addable: true, + orderable: true, + removable: true, + }, + }; + this.jsonSchema = JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + "items.properties.paramType": { + default: defaultHubbardConfig.paramType, + }, + "items.properties.atomicSpecies": { + enum: this.uniqueElementsWithLabels, + default: this.firstElement, + }, + "items.properties.atomicOrbital": { + enum: this.orbitalList, + default: defaultHubbardConfig.atomicOrbital, + }, + "items.properties.value": { + default: defaultHubbardConfig.value, + }, + }); + } + getDefaultData() { + return [ + { + ...defaultHubbardConfig, + atomicSpecies: this.firstElement, + }, + ]; + } +} +exports.default = HubbardJContextProvider; diff --git a/dist/js/context/providers/Hubbard/HubbardUContextProvider.d.ts b/dist/js/context/providers/Hubbard/HubbardUContextProvider.d.ts new file mode 100644 index 00000000..de02ea73 --- /dev/null +++ b/dist/js/context/providers/Hubbard/HubbardUContextProvider.d.ts @@ -0,0 +1,20 @@ +import type { HubbardUContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import type { ContextItem } from "../base/ContextProvider"; +import HubbardContextProvider, { type HubbardExternalContext } from "./HubbardContextProvider"; +type Name = "hubbard_u"; +type Data = HubbardUContextProviderSchema; +export default class HubbardUContextProvider extends HubbardContextProvider { + readonly name: Name; + readonly uiSchemaStyled: { + "ui:options": { + addable: boolean; + orderable: boolean; + removable: boolean; + }; + }; + readonly jsonSchema: JSONSchema7 | undefined; + constructor(contextItem: ContextItem, externalContext: HubbardExternalContext); + getDefaultData(): Data; +} +export {}; diff --git a/dist/js/context/providers/Hubbard/HubbardUContextProvider.js b/dist/js/context/providers/Hubbard/HubbardUContextProvider.js new file mode 100644 index 00000000..e1ad1be0 --- /dev/null +++ b/dist/js/context/providers/Hubbard/HubbardUContextProvider.js @@ -0,0 +1,50 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const MaterialContextMixin_1 = __importDefault(require("../../mixins/MaterialContextMixin")); +const HubbardContextProvider_1 = __importDefault(require("./HubbardContextProvider")); +const defaultHubbardConfig = { + atomicSpecies: "", + atomicOrbital: "2p", + hubbardUValue: 1.0, +}; +const jsonSchemaId = "context-providers-directory/hubbard-u-context-provider"; +class HubbardUContextProvider extends HubbardContextProvider_1.default { + constructor(contextItem, externalContext) { + super(contextItem, externalContext); + this.name = "hubbard_u"; + this.uiSchemaStyled = { + "ui:options": { + addable: true, + orderable: false, + removable: true, + }, + }; + this.jsonSchema = JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + "items.properties.atomicSpecies": { + enum: this.uniqueElementsWithLabels, + default: this.firstElement, + }, + "items.properties.atomicOrbital": { + enum: this.orbitalList, + default: defaultHubbardConfig.atomicOrbital, + }, + "items.properties.hubbardUValue": { + default: defaultHubbardConfig.hubbardUValue, + }, + }); + } + getDefaultData() { + return [ + { + ...defaultHubbardConfig, + atomicSpecies: this.firstElement, + }, + ]; + } +} +exports.default = HubbardUContextProvider; +(0, MaterialContextMixin_1.default)(HubbardUContextProvider.prototype); diff --git a/dist/js/context/providers/Hubbard/HubbardVContextProvider.d.ts b/dist/js/context/providers/Hubbard/HubbardVContextProvider.d.ts new file mode 100644 index 00000000..0f28da97 --- /dev/null +++ b/dist/js/context/providers/Hubbard/HubbardVContextProvider.d.ts @@ -0,0 +1,20 @@ +import type { HubbardVContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import type { ContextItem } from "../base/ContextProvider"; +import HubbardContextProvider, { type HubbardExternalContext } from "./HubbardContextProvider"; +type Name = "hubbard_v"; +type Data = HubbardVContextProviderSchema; +export default class HubbardVContextProvider extends HubbardContextProvider { + readonly name: Name; + readonly uiSchemaStyled: { + "ui:options": { + addable: boolean; + orderable: boolean; + removable: boolean; + }; + }; + readonly jsonSchema: JSONSchema7 | undefined; + constructor(contextItem: ContextItem, externalContext: HubbardExternalContext); + getDefaultData(): Data; +} +export {}; diff --git a/dist/js/context/providers/Hubbard/HubbardVContextProvider.js b/dist/js/context/providers/Hubbard/HubbardVContextProvider.js new file mode 100644 index 00000000..c4adac75 --- /dev/null +++ b/dist/js/context/providers/Hubbard/HubbardVContextProvider.js @@ -0,0 +1,70 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const HubbardContextProvider_1 = __importDefault(require("./HubbardContextProvider")); +const defaultHubbardConfig = { + atomicSpecies: "", + atomicOrbital: "2p", + atomicSpecies2: "", + atomicOrbital2: "2p", + siteIndex: 1, + siteIndex2: 1, + hubbardVValue: 1.0, +}; +const jsonSchemaId = "context-providers-directory/hubbard-v-context-provider"; +class HubbardVContextProvider extends HubbardContextProvider_1.default { + constructor(contextItem, externalContext) { + var _a; + super(contextItem, externalContext); + this.name = "hubbard_v"; + this.uiSchemaStyled = { + "ui:options": { + addable: true, + orderable: true, + removable: true, + }, + }; + this.jsonSchema = JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + "items.properties.atomicSpecies": { + enum: this.uniqueElementsWithLabels, + default: this.firstElement, + }, + "items.properties.siteIndex": { + default: defaultHubbardConfig.siteIndex, + }, + "items.properties.atomicOrbital": { + enum: this.orbitalList, + default: defaultHubbardConfig.atomicOrbital, + }, + "items.properties.atomicSpecies2": { + enum: this.uniqueElementsWithLabels, + default: this.secondSpecies, + }, + "items.properties.siteIndex2": { + default: ((_a = this.uniqueElementsWithLabels) === null || _a === void 0 ? void 0 : _a.length) > 1 ? 2 : defaultHubbardConfig.siteIndex2, + }, + "items.properties.atomicOrbital2": { + enum: this.orbitalList, + default: defaultHubbardConfig.atomicOrbital, + }, + "items.properties.hubbardVValue": { + default: defaultHubbardConfig.hubbardVValue, + }, + }); + } + getDefaultData() { + var _a; + return [ + { + ...defaultHubbardConfig, + atomicSpecies: this.firstElement, + atomicSpecies2: this.secondSpecies, + siteIndex2: ((_a = this.uniqueElementsWithLabels) === null || _a === void 0 ? void 0 : _a.length) > 1 ? 2 : defaultHubbardConfig.siteIndex2, + }, + ]; + } +} +exports.default = HubbardVContextProvider; diff --git a/dist/js/context/providers/HubbardContextProviderLegacy.js b/dist/js/context/providers/HubbardContextProviderLegacy.js deleted file mode 100644 index 148a89d8..00000000 --- a/dist/js/context/providers/HubbardContextProviderLegacy.js +++ /dev/null @@ -1,68 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.HubbardContextProviderLegacy = void 0; -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _HubbardUContextProvider = require("./HubbardUContextProvider"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -const defaultHubbardConfig = { - hubbardUValue: 1.0 -}; -class HubbardContextProviderLegacy extends _HubbardUContextProvider.HubbardUContextProvider { - constructor(...args) { - super(...args); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/hubbard-legacy-context-provider"); - _defineProperty(this, "speciesIndexFromSpecies", species => { - return this.uniqueElementsWithLabels?.length > 0 ? this.uniqueElementsWithLabels.indexOf(species) + 1 : null; - }); - _defineProperty(this, "transformData", data => { - return data.map(row => ({ - ...row, - atomicSpeciesIndex: this.speciesIndexFromSpecies(row.atomicSpecies) - })); - }); - } - get defaultData() { - return [{ - ...defaultHubbardConfig, - atomicSpecies: this.firstElement, - atomicSpeciesIndex: this.uniqueElementsWithLabels?.length > 0 ? 1 : null - }]; - } - get jsonSchemaPatchConfig() { - return { - "items.properties.atomicSpecies": { - enum: this.uniqueElementsWithLabels - }, - "items.properties.hubbardUValue": { - default: defaultHubbardConfig.hubbardUValue - } - }; - } - get uiSchemaStyled() { - return { - "ui:options": { - addable: true, - orderable: false, - removable: true - }, - items: { - atomicSpecies: this.defaultFieldStyles, - atomicSpeciesIndex: { - ...this.defaultFieldStyles, - "ui:readonly": true - }, - hubbardUValue: this.defaultFieldStyles - } - }; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } -} -exports.HubbardContextProviderLegacy = HubbardContextProviderLegacy; \ No newline at end of file diff --git a/dist/js/context/providers/HubbardJContextProvider.js b/dist/js/context/providers/HubbardJContextProvider.js deleted file mode 100644 index 7a334ce6..00000000 --- a/dist/js/context/providers/HubbardJContextProvider.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.HubbardJContextProvider = void 0; -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _HubbardUContextProvider = require("./HubbardUContextProvider"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -const defaultHubbardConfig = { - paramType: "U", - atomicSpecies: "", - atomicOrbital: "2p", - value: 1.0 -}; -class HubbardJContextProvider extends _HubbardUContextProvider.HubbardUContextProvider { - constructor(...args) { - super(...args); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/hubbard-j-context-provider"); - } - get defaultData() { - return [{ - ...defaultHubbardConfig, - atomicSpecies: this.firstElement - }]; - } - get jsonSchemaPatchConfig() { - return { - "items.properties.paramType": { - default: defaultHubbardConfig.paramType - }, - "items.properties.atomicSpecies": { - enum: this.uniqueElementsWithLabels, - default: this.firstElement - }, - "items.properties.atomicOrbital": { - enum: this.orbitalList, - default: defaultHubbardConfig.atomicOrbital - }, - "items.properties.value": { - default: defaultHubbardConfig.value - } - }; - } - get uiSchemaStyled() { - return { - "ui:options": { - addable: true, - orderable: true, - removable: true - }, - items: { - paramType: this.defaultFieldStyles, - atomicSpecies: this.defaultFieldStyles, - atomicOrbital: this.defaultFieldStyles, - value: this.defaultFieldStyles - } - }; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } -} -exports.HubbardJContextProvider = HubbardJContextProvider; \ No newline at end of file diff --git a/dist/js/context/providers/HubbardUContextProvider.js b/dist/js/context/providers/HubbardUContextProvider.js deleted file mode 100644 index 719aca4b..00000000 --- a/dist/js/context/providers/HubbardUContextProvider.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.HubbardUContextProvider = void 0; -var _ade = require("@mat3ra/ade"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _MaterialContextMixin = require("../mixins/MaterialContextMixin"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -const defaultHubbardConfig = { - atomicSpecies: "", - atomicOrbital: "2p", - hubbardUValue: 1.0 -}; -class HubbardUContextProvider extends _ade.JSONSchemaFormDataProvider { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/hubbard-u-context-provider"); - this.initMaterialContextMixin(); - this.uniqueElements = this.material?.Basis?.uniqueElements || []; - this.orbitalList = ["2p", "3s", "3p", "3d", "4s", "4p", "4d", "4f", "5s", "5p", "5d", "5f", "6s", "6p", "6d", "7s", "7p", "7d"]; - const _elementsWithLabels = this.material?.Basis?.elementsWithLabelsArray || []; - this.uniqueElementsWithLabels = [...new Set(_elementsWithLabels)]; - this.firstElement = this.uniqueElementsWithLabels?.length > 0 ? this.uniqueElementsWithLabels[0] : ""; - } - get defaultData() { - return [{ - ...defaultHubbardConfig, - atomicSpecies: this.firstElement - }]; - } - get jsonSchemaPatchConfig() { - return { - "items.properties.atomicSpecies": { - enum: this.uniqueElementsWithLabels, - default: this.firstElement - }, - "items.properties.atomicOrbital": { - enum: this.orbitalList, - default: defaultHubbardConfig.atomicOrbital - }, - "items.properties.hubbardUValue": { - default: defaultHubbardConfig.hubbardUValue - } - }; - } - get uiSchemaStyled() { - return { - "ui:options": { - addable: true, - orderable: false, - removable: true - }, - items: { - atomicSpecies: this.defaultFieldStyles, - atomicOrbital: this.defaultFieldStyles, - hubbardUValue: this.defaultFieldStyles - } - }; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } -} -exports.HubbardUContextProvider = HubbardUContextProvider; -(0, _MaterialContextMixin.materialContextMixin)(HubbardUContextProvider.prototype); \ No newline at end of file diff --git a/dist/js/context/providers/HubbardVContextProvider.js b/dist/js/context/providers/HubbardVContextProvider.js deleted file mode 100644 index 81de9a0e..00000000 --- a/dist/js/context/providers/HubbardVContextProvider.js +++ /dev/null @@ -1,92 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.HubbardVContextProvider = void 0; -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _HubbardUContextProvider = require("./HubbardUContextProvider"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -const defaultHubbardConfig = { - atomicSpecies: "", - atomicOrbital: "2p", - atomicSpecies2: "", - atomicOrbital2: "2p", - siteIndex: 1, - siteIndex2: 1, - hubbardVValue: 1.0 -}; -class HubbardVContextProvider extends _HubbardUContextProvider.HubbardUContextProvider { - constructor(...args) { - super(...args); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/hubbard-v-context-provider"); - } - get defaultData() { - return [{ - ...defaultHubbardConfig, - atomicSpecies: this.firstSpecies, - atomicSpecies2: this.secondSpecies, - siteIndex2: this.uniqueElementsWithLabels?.length > 1 ? 2 : defaultHubbardConfig.siteIndex2 - }]; - } - get firstSpecies() { - return this.firstElement; - } - get secondSpecies() { - return this.uniqueElementsWithLabels?.length > 1 ? this.uniqueElementsWithLabels[1] : this.firstSpecies; - } - get jsonSchemaPatchConfig() { - return { - "items.properties.atomicSpecies": { - enum: this.uniqueElementsWithLabels, - default: this.firstSpecies - }, - "items.properties.siteIndex": { - default: defaultHubbardConfig.siteIndex - }, - "items.properties.atomicOrbital": { - enum: this.orbitalList, - default: defaultHubbardConfig.atomicOrbital - }, - "items.properties.atomicSpecies2": { - enum: this.uniqueElementsWithLabels, - default: this.secondSpecies - }, - "items.properties.siteIndex2": { - default: this.uniqueElementsWithLabels?.length > 1 ? 2 : defaultHubbardConfig.siteIndex2 - }, - "items.properties.atomicOrbital2": { - enum: this.orbitalList, - default: defaultHubbardConfig.atomicOrbital - }, - "items.properties.hubbardVValue": { - default: defaultHubbardConfig.hubbardVValue - } - }; - } - get uiSchemaStyled() { - return { - "ui:options": { - addable: true, - orderable: true, - removable: true - }, - items: { - atomicSpecies: this.defaultFieldStyles, - atomicOrbital: this.defaultFieldStyles, - atomicSpecies2: this.defaultFieldStyles, - atomicOrbital2: this.defaultFieldStyles, - siteIndex: this.defaultFieldStyles, - siteIndex2: this.defaultFieldStyles, - hubbardVValue: this.defaultFieldStyles - } - }; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } -} -exports.HubbardVContextProvider = HubbardVContextProvider; \ No newline at end of file diff --git a/dist/js/context/providers/IonDynamicsContextProvider.d.ts b/dist/js/context/providers/IonDynamicsContextProvider.d.ts new file mode 100644 index 00000000..8eca4e70 --- /dev/null +++ b/dist/js/context/providers/IonDynamicsContextProvider.d.ts @@ -0,0 +1,25 @@ +import type { IonDynamicsContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import type { ContextItem, Domain, ExternalContext } from "./base/ContextProvider"; +import JSONSchemaFormDataProvider from "./base/JSONSchemaFormDataProvider"; +type Data = IonDynamicsContextProviderSchema; +type Name = "dynamics"; +export default class IonDynamicsContextProvider extends JSONSchemaFormDataProvider { + readonly name: Name; + readonly domain: Domain; + readonly uiSchema: { + numberOfSteps: {}; + timeStep: {}; + electronMass: {}; + temperature: {}; + }; + readonly jsonSchema: JSONSchema7 | undefined; + constructor(contextItem: ContextItem, externalContext: ExternalContext); + getDefaultData(): { + numberOfSteps: number; + timeStep: number; + electronMass: number; + temperature: number; + }; +} +export {}; diff --git a/dist/js/context/providers/IonDynamicsContextProvider.js b/dist/js/context/providers/IonDynamicsContextProvider.js index e49adc55..cf5c4440 100644 --- a/dist/js/context/providers/IonDynamicsContextProvider.js +++ b/dist/js/context/providers/IonDynamicsContextProvider.js @@ -1,58 +1,38 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.IonDynamicsContextProvider = void 0; -var _ade = require("@mat3ra/ade"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -const defaultMDConfig = { - numberOfSteps: 100, - timeStep: 5.0, - electronMass: 100.0, - temperature: 300.0 +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; }; -class IonDynamicsContextProvider extends _ade.JSONSchemaFormDataProvider { - constructor(...args) { - super(...args); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/ion-dynamics-context-provider"); - } - // eslint-disable-next-line class-methods-use-this - get defaultData() { - return defaultMDConfig; - } - get jsonSchemaPatchConfig() { - return { - numberOfSteps: { - default: this.defaultData.numberOfSteps - }, - timeStep: { - default: this.defaultData.timeStep - }, - electronMass: { - default: this.defaultData.electronMass - }, - temperature: { - default: this.defaultData.temperature - } - }; - } - - // eslint-disable-next-line class-methods-use-this - get uiSchema() { - return { - numberOfSteps: {}, - timeStep: {}, - electronMass: {}, - temperature: {} - }; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const JSONSchemaFormDataProvider_1 = __importDefault(require("./base/JSONSchemaFormDataProvider")); +const jsonSchemaId = "context-providers-directory/ion-dynamics-context-provider"; +const defaultData = { + numberOfSteps: 100, + timeStep: 5.0, + electronMass: 100.0, + temperature: 300.0, +}; +class IonDynamicsContextProvider extends JSONSchemaFormDataProvider_1.default { + constructor(contextItem, externalContext) { + super(contextItem, externalContext); + this.name = "dynamics"; + this.domain = "important"; + this.uiSchema = { + numberOfSteps: {}, + timeStep: {}, + electronMass: {}, + temperature: {}, + }; + this.jsonSchema = JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + numberOfSteps: { default: defaultData.numberOfSteps }, + timeStep: { default: defaultData.timeStep }, + electronMass: { default: defaultData.electronMass }, + temperature: { default: defaultData.temperature }, + }); + } + // eslint-disable-next-line class-methods-use-this + getDefaultData() { + return defaultData; + } } -exports.IonDynamicsContextProvider = IonDynamicsContextProvider; \ No newline at end of file +exports.default = IonDynamicsContextProvider; diff --git a/dist/js/context/providers/MLSettingsContextProvider.d.ts b/dist/js/context/providers/MLSettingsContextProvider.d.ts new file mode 100644 index 00000000..73d2512c --- /dev/null +++ b/dist/js/context/providers/MLSettingsContextProvider.d.ts @@ -0,0 +1,26 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { MLSettingsContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import { type ApplicationContextMixin } from "../mixins/ApplicationContextMixin"; +import { type ContextItem, type Domain } from "./base/ContextProvider"; +import JSONSchemaDataProvider, { type JinjaExternalContext } from "./base/JSONSchemaDataProvider"; +type Name = "mlSettings"; +type Data = MLSettingsContextProviderSchema; +type ExternalContext = JinjaExternalContext & ApplicationContextMixin; +type Base = typeof JSONSchemaDataProvider & Constructor; +declare const MLSettingsContextProvider_base: Base; +export default class MLSettingsContextProvider extends MLSettingsContextProvider_base { + readonly name: Name; + readonly domain: Domain; + readonly jsonSchema: JSONSchema7 | undefined; + readonly uiSchema: { + target_column_name: {}; + problem_category: {}; + }; + constructor(contextItem: ContextItem, externalContext: ExternalContext); + getDefaultData(): { + target_column_name: string; + problem_category: "regression"; + }; +} +export {}; diff --git a/dist/js/context/providers/MLSettingsContextProvider.js b/dist/js/context/providers/MLSettingsContextProvider.js index ee833de5..e42f7717 100644 --- a/dist/js/context/providers/MLSettingsContextProvider.js +++ b/dist/js/context/providers/MLSettingsContextProvider.js @@ -1,51 +1,35 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.MLSettingsContextProvider = void 0; -var _ade = require("@mat3ra/ade"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _ApplicationContextMixin = require("../mixins/ApplicationContextMixin"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class MLSettingsContextProvider extends _ade.ContextProvider { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/ml-settings-context-provider"); - this.initApplicationContextMixin(); - } - - // eslint-disable-next-line class-methods-use-this - get uiSchema() { - return { - target_column_name: {}, - problem_category: {} - }; - } - - // eslint-disable-next-line class-methods-use-this - get defaultData() { - return { - target_column_name: "target", - problem_category: "regression" - }; - } - get jsonSchemaPatchConfig() { - return { - target_column_name: { - default: this.defaultData.target_column_name - }, - problem_category: { - default: this.defaultData.problem_category - } - }; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const ApplicationContextMixin_1 = require("../mixins/ApplicationContextMixin"); +const JSONSchemaDataProvider_1 = __importDefault(require("./base/JSONSchemaDataProvider")); +const jsonSchemaId = "context-providers-directory/ml-settings-context-provider"; +const defaultData = { + target_column_name: "target", + problem_category: "regression", +}; +class MLSettingsContextProvider extends JSONSchemaDataProvider_1.default { + constructor(contextItem, externalContext) { + super(contextItem, externalContext); + this.name = "mlSettings"; + this.domain = "important"; + this.uiSchema = { + target_column_name: {}, + problem_category: {}, + }; + this.initApplicationContextMixin(externalContext); + this.jsonSchema = JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + target_column_name: { default: defaultData.target_column_name }, + problem_category: { default: defaultData.problem_category }, + }); + } + // eslint-disable-next-line class-methods-use-this + getDefaultData() { + return defaultData; + } } -exports.MLSettingsContextProvider = MLSettingsContextProvider; -(0, _ApplicationContextMixin.applicationContextMixin)(MLSettingsContextProvider.prototype); \ No newline at end of file +exports.default = MLSettingsContextProvider; +(0, ApplicationContextMixin_1.applicationContextMixin)(MLSettingsContextProvider.prototype); diff --git a/dist/js/context/providers/MLTrainTestSplitContextProvider.d.ts b/dist/js/context/providers/MLTrainTestSplitContextProvider.d.ts new file mode 100644 index 00000000..69a3c3e6 --- /dev/null +++ b/dist/js/context/providers/MLTrainTestSplitContextProvider.d.ts @@ -0,0 +1,25 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { MLTrainTestSplitContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import { type ApplicationContextMixin } from "../mixins/ApplicationContextMixin"; +import { type ContextItem, type Domain } from "./base/ContextProvider"; +import JSONSchemaDataProvider, { type JinjaExternalContext } from "./base/JSONSchemaDataProvider"; +type Name = "mlTrainTestSplit"; +type Data = MLTrainTestSplitContextProviderSchema; +type ExternalContext = JinjaExternalContext & ApplicationContextMixin; +type Base = typeof JSONSchemaDataProvider & Constructor; +declare const MLTrainTestSplitContextProvider_base: Base; +export default class MLTrainTestSplitContextProvider extends MLTrainTestSplitContextProvider_base { + readonly name: Name; + readonly domain: Domain; + readonly jsonSchema: JSONSchema7 | undefined; + readonly uiSchema: { + target_column_name: {}; + problem_category: {}; + }; + constructor(contextItem: ContextItem, externalContext: ExternalContext); + getDefaultData(): { + fraction_held_as_test_set: number; + }; +} +export {}; diff --git a/dist/js/context/providers/MLTrainTestSplitContextProvider.js b/dist/js/context/providers/MLTrainTestSplitContextProvider.js index c9030d91..2e216c35 100644 --- a/dist/js/context/providers/MLTrainTestSplitContextProvider.js +++ b/dist/js/context/providers/MLTrainTestSplitContextProvider.js @@ -1,47 +1,33 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.MLTrainTestSplitContextProvider = void 0; -var _ade = require("@mat3ra/ade"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _ApplicationContextMixin = require("../mixins/ApplicationContextMixin"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class MLTrainTestSplitContextProvider extends _ade.ContextProvider { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/ml-train-test-split-context-provider"); - this.initApplicationContextMixin(); - } - - // eslint-disable-next-line class-methods-use-this - get uiSchema() { - return { - target_column_name: {}, - problem_category: {} - }; - } - - // eslint-disable-next-line class-methods-use-this - get defaultData() { - return { - fraction_held_as_test_set: 0.2 - }; - } - get jsonSchemaPatchConfig() { - return { - fraction_held_as_test_set: { - default: this.defaultData.fraction_held_as_test_set - } - }; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const ApplicationContextMixin_1 = require("../mixins/ApplicationContextMixin"); +const JSONSchemaDataProvider_1 = __importDefault(require("./base/JSONSchemaDataProvider")); +const jsonSchemaId = "context-providers-directory/ml-train-test-split-context-provider"; +const defaultData = { + fraction_held_as_test_set: 0.2, +}; +class MLTrainTestSplitContextProvider extends JSONSchemaDataProvider_1.default { + constructor(contextItem, externalContext) { + super(contextItem, externalContext); + this.name = "mlTrainTestSplit"; + this.domain = "important"; + this.uiSchema = { + target_column_name: {}, + problem_category: {}, + }; + this.initApplicationContextMixin(externalContext); + this.jsonSchema = JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + fraction_held_as_test_set: { default: defaultData.fraction_held_as_test_set }, + }); + } + // eslint-disable-next-line class-methods-use-this + getDefaultData() { + return defaultData; + } } -exports.MLTrainTestSplitContextProvider = MLTrainTestSplitContextProvider; -(0, _ApplicationContextMixin.applicationContextMixin)(MLTrainTestSplitContextProvider.prototype); \ No newline at end of file +exports.default = MLTrainTestSplitContextProvider; +(0, ApplicationContextMixin_1.applicationContextMixin)(MLTrainTestSplitContextProvider.prototype); diff --git a/dist/js/context/providers/NEBFormDataProvider.d.ts b/dist/js/context/providers/NEBFormDataProvider.d.ts new file mode 100644 index 00000000..8b45d298 --- /dev/null +++ b/dist/js/context/providers/NEBFormDataProvider.d.ts @@ -0,0 +1,21 @@ +import type { NEBDataProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import type { ContextItem, Domain } from "./base/ContextProvider"; +import type { JinjaExternalContext } from "./base/JSONSchemaDataProvider"; +import JSONSchemaFormDataProvider from "./base/JSONSchemaFormDataProvider"; +type Name = "neb"; +type Data = NEBDataProviderSchema; +type ExternalContext = JinjaExternalContext; +export default class NEBFormDataProvider extends JSONSchemaFormDataProvider { + readonly name: Name; + readonly domain: Domain; + readonly uiSchema: { + nImages: {}; + }; + readonly jsonSchema: JSONSchema7 | undefined; + constructor(contextItem: ContextItem, externalContext: ExternalContext); + getDefaultData(): { + nImages: number; + }; +} +export {}; diff --git a/dist/js/context/providers/NEBFormDataProvider.js b/dist/js/context/providers/NEBFormDataProvider.js index 13daac09..fb0572ae 100644 --- a/dist/js/context/providers/NEBFormDataProvider.js +++ b/dist/js/context/providers/NEBFormDataProvider.js @@ -1,42 +1,29 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.NEBFormDataProvider = void 0; -var _ade = require("@mat3ra/ade"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class NEBFormDataProvider extends _ade.JSONSchemaFormDataProvider { - constructor(...args) { - super(...args); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/neb-data-provider"); - } - // eslint-disable-next-line class-methods-use-this - get defaultData() { - return { - nImages: 1 - }; - } - get jsonSchemaPatchConfig() { - return { - nImages: { - default: this.defaultData.nImages - } - }; - } - - // eslint-disable-next-line class-methods-use-this - get uiSchema() { - return { - nImages: {} - }; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const JSONSchemaFormDataProvider_1 = __importDefault(require("./base/JSONSchemaFormDataProvider")); +const jsonSchemaId = "context-providers-directory/neb-data-provider"; +const defaultData = { + nImages: 1, +}; +class NEBFormDataProvider extends JSONSchemaFormDataProvider_1.default { + constructor(contextItem, externalContext) { + super(contextItem, externalContext); + this.name = "neb"; + this.domain = "important"; + this.uiSchema = { + nImages: {}, + }; + this.jsonSchema = JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + nImages: { default: defaultData.nImages }, + }); + } + // eslint-disable-next-line class-methods-use-this + getDefaultData() { + return defaultData; + } } -exports.NEBFormDataProvider = NEBFormDataProvider; \ No newline at end of file +exports.default = NEBFormDataProvider; diff --git a/dist/js/context/providers/NonCollinearMagnetizationContextProvider.d.ts b/dist/js/context/providers/NonCollinearMagnetizationContextProvider.d.ts new file mode 100644 index 00000000..d5df390b --- /dev/null +++ b/dist/js/context/providers/NonCollinearMagnetizationContextProvider.d.ts @@ -0,0 +1,77 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { NonCollinearMagnetizationContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import { type MaterialContextMixin, type MaterialExternalContext } from "../mixins/MaterialContextMixin"; +import type { ContextItem, Domain } from "./base/ContextProvider"; +import JSONSchemaDataProvider, { type JinjaExternalContext } from "./base/JSONSchemaDataProvider"; +type Name = "nonCollinearMagnetization"; +type Data = NonCollinearMagnetizationContextProviderSchema; +type ExternalContext = JinjaExternalContext & MaterialExternalContext; +type Base = typeof JSONSchemaDataProvider & Constructor; +declare const NonCollinearMagnetizationContextProvider_base: Base; +export default class NonCollinearMagnetizationContextProvider extends NonCollinearMagnetizationContextProvider_base { + readonly name: Name; + readonly domain: Domain; + readonly isStartingMagnetization: boolean; + readonly isConstrainedMagnetization: boolean; + readonly isExistingChargeDensity: boolean; + readonly isArbitrarySpinDirection: boolean; + readonly isFixedMagnetization: boolean; + readonly constrainedMagnetization: Data["constrainedMagnetization"]; + readonly jsonSchema: JSONSchema7 | undefined; + private readonly uniqueElementsWithLabels; + constructor(contextItem: ContextItem, externalContext: ExternalContext); + getDefaultData(): Data; + get uiSchemaStyled(): { + isExistingChargeDensity: {}; + lforcet: { + "ui:readonly": boolean; + "ui:widget": string; + "ui:options": { + inline: boolean; + }; + }; + isArbitrarySpinDirection: {}; + spinAngles: { + items: { + atomicSpecies: { + "ui:readonly": boolean; + }; + }; + "ui:readonly": boolean; + "ui:options": { + addable: boolean; + orderable: boolean; + removable: boolean; + }; + }; + isStartingMagnetization: {}; + startingMagnetization: { + items: { + atomicSpecies: { + "ui:readonly": boolean; + }; + value: { + "ui:classNames": string; + }; + }; + "ui:readonly": boolean; + "ui:options": { + addable: boolean; + orderable: boolean; + removable: boolean; + }; + }; + isConstrainedMagnetization: {}; + constrainedMagnetization: { + "ui:readonly": boolean; + }; + isFixedMagnetization: { + "ui:readonly": boolean; + }; + fixedMagnetization: { + "ui:readonly": boolean; + }; + }; +} +export {}; diff --git a/dist/js/context/providers/NonCollinearMagnetizationContextProvider.js b/dist/js/context/providers/NonCollinearMagnetizationContextProvider.js index abeb8c82..79c16f9d 100644 --- a/dist/js/context/providers/NonCollinearMagnetizationContextProvider.js +++ b/dist/js/context/providers/NonCollinearMagnetizationContextProvider.js @@ -1,187 +1,155 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.NonCollinearMagnetizationContextProvider = void 0; -var _ade = require("@mat3ra/ade"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _lodash = _interopRequireDefault(require("lodash")); -var _MaterialContextMixin = require("../mixins/MaterialContextMixin"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class NonCollinearMagnetizationContextProvider extends _ade.JSONSchemaFormDataProvider { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/non-collinear-magnetization-context-provider"); - this.initMaterialContextMixin(); - this.isStartingMagnetization = _lodash.default.get(this.data, "isStartingMagnetization", true); - this.isConstrainedMagnetization = _lodash.default.get(this.data, "isConstrainedMagnetization", false); - this.isExistingChargeDensity = _lodash.default.get(this.data, "isExistingChargeDensity", false); - this.isArbitrarySpinDirection = _lodash.default.get(this.data, "isArbitrarySpinDirection", false); - this.isFixedMagnetization = _lodash.default.get(this.data, "isFixedMagnetization", false); - this.constrainedMagnetization = _lodash.default.get(this.data, "constrainedMagnetization", {}); - } - get uniqueElementsWithLabels() { - const elementsWithLabelsArray = this.material?.Basis?.elementsWithLabelsArray || []; - return [...new Set(elementsWithLabelsArray)]; - } - get defaultData() { - const startingMagnetization = this.uniqueElementsWithLabels.map((element, index) => { - return { - index: index + 1, - atomicSpecies: element, - value: 0.0 - }; - }); - const spinAngles = this.uniqueElementsWithLabels.map((element, index) => { - return { - index: index + 1, - atomicSpecies: element, - angle1: 0.0, - angle2: 0.0 - }; - }); - return { - isExistingChargeDensity: false, - isStartingMagnetization: true, - isConstrainedMagnetization: false, - isArbitrarySpinAngle: false, - isFixedMagnetization: false, - lforcet: true, - spinAngles, - startingMagnetization, - constrainedMagnetization: { - lambda: 0.0, - constrainType: "atomic direction" - }, - fixedMagnetization: { - x: 0.0, - y: 0.0, - z: 0.0 - } - }; - } - get uiSchemaStyled() { - return { - isExistingChargeDensity: {}, - lforcet: { - "ui:readonly": !this.isExistingChargeDensity, - "ui:widget": "radio", - "ui:options": { - inline: true - } - }, - isArbitrarySpinDirection: {}, - spinAngles: { - items: { - atomicSpecies: { - ...this.defaultFieldStyles, - "ui:readonly": true - }, - angle1: this.defaultFieldStyles, - angle2: this.defaultFieldStyles - }, - "ui:readonly": !this.isArbitrarySpinDirection, - "ui:options": { - addable: false, - orderable: false, - removable: false - } - }, - isStartingMagnetization: {}, - startingMagnetization: { - items: { - atomicSpecies: { - ...this.defaultFieldStyles, - "ui:readonly": true - }, - value: { - "ui:classNames": "col-xs-6" - } - }, - "ui:readonly": !this.isStartingMagnetization, - "ui:options": { - addable: false, - orderable: false, - removable: false - } - }, - isConstrainedMagnetization: {}, - constrainedMagnetization: { - constrainType: this.defaultFieldStyles, - lambda: this.defaultFieldStyles, - "ui:readonly": !this.isConstrainedMagnetization - }, - isFixedMagnetization: { - "ui:readonly": !(this.isConstrainedMagnetization && this.constrainedMagnetization?.constrainType === "total") - }, - fixedMagnetization: { - x: this.defaultFieldStyles, - y: this.defaultFieldStyles, - z: this.defaultFieldStyles, - "ui:readonly": !(this.isFixedMagnetization && this.isConstrainedMagnetization && this.constrainedMagnetization?.constrainType === "total") - } - }; - } - get jsonSchemaPatchConfig() { - return { - isExistingChargeDensity: { - default: false - }, - isStartingMagnetization: { - default: true - }, - isArbitrarySpinAngle: { - default: false - }, - isConstrainedMagnetization: { - default: false - }, - isFixedMagnetization: { - default: true - }, - startingMagnetization: { - minItems: this.uniqueElementsWithLabels.length, - maxItems: this.uniqueElementsWithLabels.length - }, - "startingMagnetization.items.properties.value": { - default: 0.0, - minimum: -1.0, - maximum: 1.0 - }, - spinAngles: { - minItems: this.uniqueElementsWithLabels.length, - maxItems: this.uniqueElementsWithLabels.length - }, - "spinAngles.items.properties.angle1": { - default: 0.0 - }, - "spinAngles.items.properties.angle2": { - default: 0.0 - }, - "constrainedMagnetization.properties.constrainType": { - default: "atomic direction" - }, - "constrainedMagnetization.properties.lambda": { - default: 0.0 - }, - "fixedMagnetization.properties.x": { - default: 0.0 - }, - "fixedMagnetization.properties.y": { - default: 0.0 - }, - "fixedMagnetization.properties.z": { - default: 0.0 - } - }; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const MaterialContextMixin_1 = __importDefault(require("../mixins/MaterialContextMixin")); +const JSONSchemaDataProvider_1 = __importDefault(require("./base/JSONSchemaDataProvider")); +const jsonSchemaId = "context-providers-directory/non-collinear-magnetization-context-provider"; +class NonCollinearMagnetizationContextProvider extends JSONSchemaDataProvider_1.default { + constructor(contextItem, externalContext) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p; + super(contextItem, externalContext); + this.name = "nonCollinearMagnetization"; + this.domain = "important"; + this.initMaterialContextMixin(externalContext); + this.isStartingMagnetization = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.isStartingMagnetization) !== null && _b !== void 0 ? _b : true; + this.isConstrainedMagnetization = (_d = (_c = this.data) === null || _c === void 0 ? void 0 : _c.isConstrainedMagnetization) !== null && _d !== void 0 ? _d : false; + this.isExistingChargeDensity = (_f = (_e = this.data) === null || _e === void 0 ? void 0 : _e.isExistingChargeDensity) !== null && _f !== void 0 ? _f : false; + this.isArbitrarySpinDirection = (_h = (_g = this.data) === null || _g === void 0 ? void 0 : _g.isArbitrarySpinDirection) !== null && _h !== void 0 ? _h : false; + this.isFixedMagnetization = (_k = (_j = this.data) === null || _j === void 0 ? void 0 : _j.isFixedMagnetization) !== null && _k !== void 0 ? _k : false; + this.constrainedMagnetization = (_m = (_l = this.data) === null || _l === void 0 ? void 0 : _l.constrainedMagnetization) !== null && _m !== void 0 ? _m : { + lambda: 0.0, + constrainType: "atomic direction", + }; + this.uniqueElementsWithLabels = [ + ...new Set(((_p = (_o = this.material) === null || _o === void 0 ? void 0 : _o.Basis) === null || _p === void 0 ? void 0 : _p.elementsWithLabelsArray) || []), + ]; + this.jsonSchema = JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + isExistingChargeDensity: { default: false }, + isStartingMagnetization: { default: true }, + isArbitrarySpinAngle: { default: false }, + isConstrainedMagnetization: { default: false }, + isFixedMagnetization: { default: true }, + startingMagnetization: { + minItems: this.uniqueElementsWithLabels.length, + maxItems: this.uniqueElementsWithLabels.length, + }, + "startingMagnetization.items.properties.value": { + default: 0.0, + minimum: -1.0, + maximum: 1.0, + }, + spinAngles: { + minItems: this.uniqueElementsWithLabels.length, + maxItems: this.uniqueElementsWithLabels.length, + }, + "spinAngles.items.properties.angle1": { default: 0.0 }, + "spinAngles.items.properties.angle2": { default: 0.0 }, + "constrainedMagnetization.properties.constrainType": { + default: "atomic direction", + }, + "constrainedMagnetization.properties.lambda": { default: 0.0 }, + "fixedMagnetization.properties.x": { default: 0.0 }, + "fixedMagnetization.properties.y": { default: 0.0 }, + "fixedMagnetization.properties.z": { default: 0.0 }, + }); + } + getDefaultData() { + const startingMagnetization = this.uniqueElementsWithLabels.map((element, index) => { + return { + index: index + 1, + atomicSpecies: element, + value: 0.0, + }; + }); + const spinAngles = this.uniqueElementsWithLabels.map((element, index) => { + return { + index: index + 1, + atomicSpecies: element, + angle1: 0.0, + angle2: 0.0, + }; + }); + return { + isExistingChargeDensity: false, + isStartingMagnetization: true, + isConstrainedMagnetization: false, + isArbitrarySpinAngle: false, + isArbitrarySpinDirection: false, + isFixedMagnetization: false, + lforcet: true, + spinAngles, + startingMagnetization, + constrainedMagnetization: { + lambda: 0.0, + constrainType: "atomic direction", + }, + fixedMagnetization: { + x: 0.0, + y: 0.0, + z: 0.0, + }, + }; + } + get uiSchemaStyled() { + var _a, _b; + return { + isExistingChargeDensity: {}, + lforcet: { + "ui:readonly": !this.isExistingChargeDensity, + "ui:widget": "radio", + "ui:options": { + inline: true, + }, + }, + isArbitrarySpinDirection: {}, + spinAngles: { + items: { + atomicSpecies: { + "ui:readonly": true, + }, + }, + "ui:readonly": !this.isArbitrarySpinDirection, + "ui:options": { + addable: false, + orderable: false, + removable: false, + }, + }, + isStartingMagnetization: {}, + startingMagnetization: { + items: { + atomicSpecies: { + "ui:readonly": true, + }, + value: { + "ui:classNames": "col-xs-6", + }, + }, + "ui:readonly": !this.isStartingMagnetization, + "ui:options": { + addable: false, + orderable: false, + removable: false, + }, + }, + isConstrainedMagnetization: {}, + constrainedMagnetization: { + "ui:readonly": !this.isConstrainedMagnetization, + }, + isFixedMagnetization: { + "ui:readonly": !(this.isConstrainedMagnetization && + ((_a = this.constrainedMagnetization) === null || _a === void 0 ? void 0 : _a.constrainType) === "total"), + }, + fixedMagnetization: { + "ui:readonly": !(this.isFixedMagnetization && + this.isConstrainedMagnetization && + ((_b = this.constrainedMagnetization) === null || _b === void 0 ? void 0 : _b.constrainType) === "total"), + }, + }; + } } -exports.NonCollinearMagnetizationContextProvider = NonCollinearMagnetizationContextProvider; -(0, _MaterialContextMixin.materialContextMixin)(NonCollinearMagnetizationContextProvider.prototype); \ No newline at end of file +exports.default = NonCollinearMagnetizationContextProvider; +(0, MaterialContextMixin_1.default)(NonCollinearMagnetizationContextProvider.prototype); diff --git a/dist/js/context/providers/PlanewaveCutoffsContextProvider.d.ts b/dist/js/context/providers/PlanewaveCutoffsContextProvider.d.ts new file mode 100644 index 00000000..22b39a64 --- /dev/null +++ b/dist/js/context/providers/PlanewaveCutoffsContextProvider.d.ts @@ -0,0 +1,26 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { PlanewaveCutoffsContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import { type ApplicationContextMixin } from "../mixins/ApplicationContextMixin"; +import ContextProvider, { type ContextItem, type Domain, type EntityName, type ExternalContext } from "./base/ContextProvider"; +type Name = "cutoffs"; +type Data = PlanewaveCutoffsContextProviderSchema; +type PlanewaveExternalContext = ExternalContext & ApplicationContextMixin; +type Base = typeof ContextProvider & Constructor; +declare const PlanewaveCutoffsContextProvider_base: Base; +export default class PlanewaveCutoffsContextProvider extends PlanewaveCutoffsContextProvider_base { + readonly name: Name; + readonly domain: Domain; + readonly entityName: EntityName; + readonly jsonSchema: JSONSchema7 | undefined; + readonly uiSchema: { + wavefunction: {}; + density: {}; + }; + constructor(contextItem: ContextItem, externalContext: PlanewaveExternalContext); + getDefaultData(): { + wavefunction: number | undefined; + density: number | undefined; + }; +} +export {}; diff --git a/dist/js/context/providers/PlanewaveCutoffsContextProvider.js b/dist/js/context/providers/PlanewaveCutoffsContextProvider.js index 40121fdd..643cc145 100644 --- a/dist/js/context/providers/PlanewaveCutoffsContextProvider.js +++ b/dist/js/context/providers/PlanewaveCutoffsContextProvider.js @@ -1,67 +1,41 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.PlanewaveCutoffsContextProvider = void 0; -var _ade = require("@mat3ra/ade"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _ApplicationContextMixin = require("../mixins/ApplicationContextMixin"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const ApplicationContextMixin_1 = require("../mixins/ApplicationContextMixin"); +const ContextProvider_1 = __importDefault(require("./base/ContextProvider")); const cutoffConfig = { - vasp: {}, - // assuming default cutoffs for VASP - espresso: { - // assuming the default GBRV set of pseudopotentials is used - wavefunction: 40, - density: 200 - } + vasp: { wavefunction: undefined, density: undefined }, + espresso: { wavefunction: 40, density: 200 }, }; -class PlanewaveCutoffsContextProvider extends _ade.ContextProvider { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/planewave-cutoffs-context-provider"); - this.initApplicationContextMixin(); - } - - // eslint-disable-next-line class-methods-use-this - get uiSchema() { - return { - wavefunction: {}, - density: {} - }; - } - get defaultData() { - return { - wavefunction: this.defaultECUTWFC, - density: this.defaultECUTRHO - }; - } - get jsonSchemaPatchConfig() { - return { - wavefunction: { - default: this.defaultData.wavefunction - }, - density: { - default: this.defaultData.density - } - }; - } - get _cutoffConfigPerApplication() { - return cutoffConfig[this.application.name]; - } - get defaultECUTWFC() { - return this._cutoffConfigPerApplication.wavefunction || null; - } - get defaultECUTRHO() { - return this._cutoffConfigPerApplication.density || null; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } +const jsonSchemaId = "context-providers-directory/planewave-cutoffs-context-provider"; +class PlanewaveCutoffsContextProvider extends ContextProvider_1.default { + constructor(contextItem, externalContext) { + super(contextItem, externalContext); + this.name = "cutoffs"; + this.domain = "important"; + this.entityName = "subworkflow"; + this.uiSchema = { + wavefunction: {}, + density: {}, + }; + this.initApplicationContextMixin(externalContext); + const { wavefunction, density } = this.getDefaultData(); + this.jsonSchema = JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + wavefunction: { default: wavefunction }, + density: { default: density }, + }); + } + getDefaultData() { + // TODO-QUESTION: what if the application is not in the cutoffConfig? + const { wavefunction, density } = cutoffConfig[this.application.name] || {}; + return { + wavefunction, + density, + }; + } } -exports.PlanewaveCutoffsContextProvider = PlanewaveCutoffsContextProvider; -(0, _ApplicationContextMixin.applicationContextMixin)(PlanewaveCutoffsContextProvider.prototype); \ No newline at end of file +exports.default = PlanewaveCutoffsContextProvider; +(0, ApplicationContextMixin_1.applicationContextMixin)(PlanewaveCutoffsContextProvider.prototype); diff --git a/dist/js/context/providers/PointsGrid/IGridFormDataManager.d.ts b/dist/js/context/providers/PointsGrid/IGridFormDataManager.d.ts new file mode 100644 index 00000000..eceea505 --- /dev/null +++ b/dist/js/context/providers/PointsGrid/IGridFormDataManager.d.ts @@ -0,0 +1,7 @@ +import PointsGridFormDataProvider from "./PointsGridFormDataProvider"; +type Name = "igrid"; +export default class IGridFormDataManager extends PointsGridFormDataProvider { + readonly name: Name; + readonly divisor: number; +} +export {}; diff --git a/dist/js/context/providers/PointsGrid/IGridFormDataManager.js b/dist/js/context/providers/PointsGrid/IGridFormDataManager.js new file mode 100644 index 00000000..3d13f9aa --- /dev/null +++ b/dist/js/context/providers/PointsGrid/IGridFormDataManager.js @@ -0,0 +1,14 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const PointsGridFormDataProvider_1 = __importDefault(require("./PointsGridFormDataProvider")); +class IGridFormDataManager extends PointsGridFormDataProvider_1.default { + constructor() { + super(...arguments); + this.name = "igrid"; + this.divisor = 0.2; + } +} +exports.default = IGridFormDataManager; diff --git a/dist/js/context/providers/PointsGrid/KGridFormDataManager.d.ts b/dist/js/context/providers/PointsGrid/KGridFormDataManager.d.ts new file mode 100644 index 00000000..e23b1f43 --- /dev/null +++ b/dist/js/context/providers/PointsGrid/KGridFormDataManager.d.ts @@ -0,0 +1,6 @@ +import PointsGridFormDataProvider from "./PointsGridFormDataProvider"; +type Name = "kgrid"; +export default class KGridFormDataManager extends PointsGridFormDataProvider { + readonly name: Name; +} +export {}; diff --git a/dist/js/context/providers/PointsGrid/KGridFormDataManager.js b/dist/js/context/providers/PointsGrid/KGridFormDataManager.js new file mode 100644 index 00000000..991c2ee4 --- /dev/null +++ b/dist/js/context/providers/PointsGrid/KGridFormDataManager.js @@ -0,0 +1,13 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const PointsGridFormDataProvider_1 = __importDefault(require("./PointsGridFormDataProvider")); +class KGridFormDataManager extends PointsGridFormDataProvider_1.default { + constructor() { + super(...arguments); + this.name = "kgrid"; + } +} +exports.default = KGridFormDataManager; diff --git a/dist/js/context/providers/PointsGrid/PointsGridFormDataProvider.d.ts b/dist/js/context/providers/PointsGrid/PointsGridFormDataProvider.d.ts new file mode 100644 index 00000000..dc33023b --- /dev/null +++ b/dist/js/context/providers/PointsGrid/PointsGridFormDataProvider.d.ts @@ -0,0 +1,86 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { PointsGridDataProviderSchema, Vector3DSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import { type MaterialContextMixin, type MaterialExternalContext } from "../../mixins/MaterialContextMixin"; +import type { ContextItem, Domain } from "../base/ContextProvider"; +import type { JinjaExternalContext } from "../base/JSONSchemaDataProvider"; +import JSONSchemaFormDataProvider from "../base/JSONSchemaFormDataProvider"; +type Name = string; +type Data = PointsGridDataProviderSchema; +type EContext = JinjaExternalContext & MaterialExternalContext & { + divisor: number; +}; +type Base = typeof JSONSchemaFormDataProvider & Constructor; +declare const PointsGridFormDataProvider_base: Base; +export default abstract class PointsGridFormDataProvider extends PointsGridFormDataProvider_base { + abstract readonly name: N; + readonly domain: Domain; + dimensions: Vector3DSchema; + shifts: Vector3DSchema; + private reciprocalLattice; + private gridMetricType; + private gridMetricValue; + private preferGridMetric; + private defaultDimensions; + private reciprocalVectorRatios; + private defaultMetric; + readonly jsonSchema: JSONSchema7 | undefined; + constructor(contextItem: ContextItem, externalContext: EContext); + private initInstanceFields; + private getDefaultGridMetricValue; + getDefaultData(): PointsGridDataProviderSchema; + private get jsonSchemaPatchConfig(); + get uiSchema(): { + dimensions: { + "ui:options": { + addable: boolean; + orderable: boolean; + removable: boolean; + }; + items: { + "ui:disabled": boolean; + "ui:placeholder": string; + "ui:emptyValue": number; + "ui:label": boolean; + }; + }; + shifts: { + "ui:options": { + addable: boolean; + orderable: boolean; + removable: boolean; + }; + items: { + "ui:disabled": boolean; + "ui:placeholder": string; + "ui:emptyValue": number; + "ui:label": boolean; + }; + }; + gridMetricType: { + "ui:title": string; + }; + gridMetricValue: { + "ui:disabled": boolean; + "ui:emptyValue": number; + "ui:placeholder": string; + }; + preferGridMetric: { + "ui:emptyValue": boolean; + "ui:disabled": boolean; + }; + reciprocalVectorRatios: { + "ui:title": string; + "ui:orderable": boolean; + "ui:removable": boolean; + "ui:readonly": boolean; + items: { + "ui:label": boolean; + }; + }; + }; + private calculateDimensions; + private calculateGridMetric; + setData(data?: Data): void; +} +export {}; diff --git a/dist/js/context/providers/PointsGrid/PointsGridFormDataProvider.js b/dist/js/context/providers/PointsGrid/PointsGridFormDataProvider.js new file mode 100644 index 00000000..d5b44188 --- /dev/null +++ b/dist/js/context/providers/PointsGrid/PointsGridFormDataProvider.js @@ -0,0 +1,238 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const constants_1 = require("@mat3ra/code/dist/js/constants"); +const math_1 = require("@mat3ra/code/dist/js/math"); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const made_1 = require("@mat3ra/made"); +const lodash_1 = __importDefault(require("lodash")); +const MaterialContextMixin_1 = __importDefault(require("../../mixins/MaterialContextMixin")); +const JSONSchemaFormDataProvider_1 = __importDefault(require("../base/JSONSchemaFormDataProvider")); +const settings_1 = require("../settings"); +// Helper function to create vector schema with defaults +const vector = (defaultValue, isStringType = false) => { + const isArray = Array.isArray(defaultValue); + return { + type: "array", + items: { + type: isStringType ? "string" : "number", + ...(isArray ? {} : { default: defaultValue }), + }, + minItems: 3, + maxItems: 3, + ...(isArray ? { default: defaultValue } : {}), + }; +}; +const jsonSchemaId = "context-providers-directory/points-grid-data-provider"; +const defaultShift = 0; +const defaultShifts = [defaultShift, defaultShift, defaultShift]; +class PointsGridFormDataProvider extends JSONSchemaFormDataProvider_1.default { + constructor(contextItem, externalContext) { + super(contextItem, externalContext); + this.domain = "important"; + this.initMaterialContextMixin(externalContext); + this.initInstanceFields(); + const { jsonSchemaPatchConfig } = this; + this.jsonSchema = JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, jsonSchemaPatchConfig); + } + initInstanceFields() { + var _a, _b, _c, _d, _e, _f; + this.defaultMetric = { + type: "KPPRA", + value: this.getDefaultGridMetricValue("KPPRA"), + }; + this.shifts = ((_a = this.data) === null || _a === void 0 ? void 0 : _a.shifts) || [...defaultShifts]; + this.gridMetricType = ((_b = this.data) === null || _b === void 0 ? void 0 : _b.gridMetricType) || this.defaultMetric.type; + this.gridMetricValue = ((_c = this.data) === null || _c === void 0 ? void 0 : _c.gridMetricValue) || this.defaultMetric.value; + this.preferGridMetric = ((_d = this.data) === null || _d === void 0 ? void 0 : _d.preferGridMetric) || false; + this.reciprocalLattice = new made_1.Made.ReciprocalLattice((_e = this.material) === null || _e === void 0 ? void 0 : _e.lattice); + this.defaultDimensions = this.calculateDimensions({ + gridMetricType: this.defaultMetric.type, + gridMetricValue: this.defaultMetric.value, + }); + this.dimensions = ((_f = this.data) === null || _f === void 0 ? void 0 : _f.dimensions) || this.defaultDimensions; + this.reciprocalVectorRatios = this.reciprocalLattice.reciprocalVectorRatios.map((r) => Number(math_1.math.numberToPrecision(r, 3))); + } + getDefaultGridMetricValue(metric) { + var _a; + switch (metric) { + case "KPPRA": { + const divisor = ((_a = this.externalContext) === null || _a === void 0 ? void 0 : _a.divisor) || 1; + const { defaultKPPRA } = settings_1.globalSettings; + return Math.floor(defaultKPPRA / divisor); + } + case "spacing": + return 0.3; + default: + console.error("Metric type not recognized!"); + return 1; + } + } + getDefaultData() { + const defaultData = { + dimensions: this.defaultDimensions, + shifts: defaultShifts, + gridMetricType: this.defaultMetric.type, + gridMetricValue: this.defaultMetric.value, + preferGridMetric: false, + reciprocalVectorRatios: this.reciprocalVectorRatios, + }; + if (this.material) { + const { gridMetricType, gridMetricValue } = this; + // if `data` is present and material is updated, prioritize `data` when `preferGridMetric` is not set + return this.preferGridMetric + ? { + dimensions: this.calculateDimensions({ gridMetricType, gridMetricValue }), + shifts: defaultShifts, + gridMetricType, + gridMetricValue, + } + : this.data || defaultData; + } + return defaultData; + } + get jsonSchemaPatchConfig() { + var _a; + const metricDescription = { + KPPRA: `${this.name.toUpperCase()}PPRA (${this.name}pt per reciprocal atom)`, // KPPRA or QPPRA + spacing: "grid spacing", + }; + const gridMetricType = ((_a = this.data) === null || _a === void 0 ? void 0 : _a.gridMetricType) || this.defaultMetric.type; + return { + dimensions: vector(this.defaultDimensions, this.isUsingJinjaVariables), + shifts: vector(defaultShifts), + reciprocalVectorRatios: vector(this.reciprocalVectorRatios), + gridMetricType: { default: this.defaultMetric.type }, + description: `3D grid with shifts. Default min value for ${metricDescription[gridMetricType]} is ${this.getDefaultGridMetricValue(gridMetricType)}.`, + required: ["dimensions", "shifts"], + dependencies: { + gridMetricType: { + oneOf: [ + { + properties: { + gridMetricType: { enum: ["KPPRA"] }, + gridMetricValue: { + type: "integer", + minimum: 1, + title: "Value", + default: this.gridMetricValue, + }, + preferGridMetric: { + type: "boolean", + title: "prefer KPPRA", + default: this.preferGridMetric, + }, + }, + }, + { + properties: { + gridMetricType: { enum: ["spacing"] }, + gridMetricValue: { + type: "number", + minimum: 0, + title: "Value [1/Å]", + default: this.gridMetricValue, + }, + preferGridMetric: { + type: "boolean", + title: "prefer spacing", + default: this.preferGridMetric, + }, + }, + }, + ], + }, + }, + }; + } + get uiSchema() { + const arraySubStyle = (emptyValue = 0) => { + return { + "ui:options": { + addable: false, + orderable: false, + removable: false, + }, + items: { + "ui:disabled": this.preferGridMetric, + // TODO: extract the actual current values from context + "ui:placeholder": "1", + "ui:emptyValue": emptyValue, + "ui:label": false, + }, + }; + }; + return { + dimensions: arraySubStyle(1), + shifts: arraySubStyle(0), + gridMetricType: { + "ui:title": "Grid Metric", + }, + gridMetricValue: { + "ui:disabled": !this.preferGridMetric, + "ui:emptyValue": this.gridMetricValue, + "ui:placeholder": this.gridMetricValue.toString(), // make string to prevent prop type error + }, + preferGridMetric: { + "ui:emptyValue": true, + "ui:disabled": this.isUsingJinjaVariables, + }, + reciprocalVectorRatios: { + "ui:title": "reciprocal vector ratios", + "ui:orderable": false, + "ui:removable": false, + "ui:readonly": true, + items: { + "ui:label": false, + }, + }, + }; + } + calculateDimensions({ gridMetricType, gridMetricValue, }) { + switch (gridMetricType) { + case "KPPRA": { + const nAtoms = this.material ? this.material.Basis.nAtoms : 1; + return this.reciprocalLattice.getDimensionsFromPointsCount(gridMetricValue / nAtoms); + } + case "spacing": + return this.reciprocalLattice.getDimensionsFromSpacing(gridMetricValue, constants_1.Units.angstrom); + default: + return [1, 1, 1]; + } + } + calculateGridMetric({ gridMetricType, dimensions, }) { + switch (gridMetricType) { + case "KPPRA": { + const nAtoms = this.material ? this.material.Basis.nAtoms : 1; + return dimensions.reduce((a, b) => a * b) * nAtoms; + } + case "spacing": + return lodash_1.default.round(this.reciprocalLattice.getSpacingFromDimensions(dimensions, constants_1.Units.angstrom), 3); + default: + return 1; + } + } + setData(data) { + var _a; + const canTransform = ((data === null || data === void 0 ? void 0 : data.preferGridMetric) && (data === null || data === void 0 ? void 0 : data.gridMetricType) && (data === null || data === void 0 ? void 0 : data.gridMetricValue)) || + (!(data === null || data === void 0 ? void 0 : data.preferGridMetric) && ((_a = data === null || data === void 0 ? void 0 : data.dimensions) === null || _a === void 0 ? void 0 : _a.every((d) => typeof d === "number"))); + if (!data || !canTransform) { + return super.setData(data); + } + // dimensions are calculated from grid metric or vice versa + if (data.preferGridMetric) { + return super.setData({ + ...data, + dimensions: this.calculateDimensions(data), + }); + } + super.setData({ + ...data, + gridMetricValue: this.calculateGridMetric(data), + }); + } +} +exports.default = PointsGridFormDataProvider; +(0, MaterialContextMixin_1.default)(PointsGridFormDataProvider.prototype); diff --git a/dist/js/context/providers/PointsGrid/QGridFormDataManager.d.ts b/dist/js/context/providers/PointsGrid/QGridFormDataManager.d.ts new file mode 100644 index 00000000..da727057 --- /dev/null +++ b/dist/js/context/providers/PointsGrid/QGridFormDataManager.d.ts @@ -0,0 +1,7 @@ +import PointsGridFormDataProvider from "./PointsGridFormDataProvider"; +type Name = "qgrid"; +export default class QGridFormDataManager extends PointsGridFormDataProvider { + readonly name: Name; + readonly divisor: number; +} +export {}; diff --git a/dist/js/context/providers/PointsGrid/QGridFormDataManager.js b/dist/js/context/providers/PointsGrid/QGridFormDataManager.js new file mode 100644 index 00000000..6d38fe7d --- /dev/null +++ b/dist/js/context/providers/PointsGrid/QGridFormDataManager.js @@ -0,0 +1,14 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const PointsGridFormDataProvider_1 = __importDefault(require("./PointsGridFormDataProvider")); +class QGridFormDataManager extends PointsGridFormDataProvider_1.default { + constructor() { + super(...arguments); + this.name = "qgrid"; + this.divisor = 5; + } +} +exports.default = QGridFormDataManager; diff --git a/dist/js/context/providers/PointsGridFormDataProvider.js b/dist/js/context/providers/PointsGridFormDataProvider.js deleted file mode 100644 index 748bafca..00000000 --- a/dist/js/context/providers/PointsGridFormDataProvider.js +++ /dev/null @@ -1,263 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.PointsGridFormDataProvider = void 0; -var _ade = require("@mat3ra/ade"); -var _constants = require("@mat3ra/code/dist/js/constants"); -var _math = require("@mat3ra/code/dist/js/math"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _made = require("@mat3ra/made"); -var _lodash = _interopRequireDefault(require("lodash")); -var _MaterialContextMixin = require("../mixins/MaterialContextMixin"); -var _settings = require("./settings"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class PointsGridFormDataProvider extends _ade.JSONSchemaFormDataProvider { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/points-grid-data-provider"); - this.initMaterialContextMixin(); - this._divisor = config.divisor || 1; // KPPRA will be divided by this number - this.reciprocalLattice = new _made.Made.ReciprocalLattice(this.material.lattice); - this.dimensions = _lodash.default.get(this.data, "dimensions") || this._defaultDimensions; - this.shifts = _lodash.default.get(this.data, "shifts") || this._defaultShifts; - - // init class fields from data (as constructed from context in parent) - this.gridMetricType = _lodash.default.get(this.data, "gridMetricType") || "KPPRA"; - this.gridMetricValue = _lodash.default.get(this.data, "gridMetricValue") || this._getDefaultGridMetricValue("KPPRA"); - this.preferGridMetric = _lodash.default.get(this.data, "preferGridMetric", false); - this._metricDescription = { - KPPRA: `${this.name[0].toUpperCase()}PPRA (${this.name[0]}pt per reciprocal atom)`, - // KPPRA or QPPRA - spacing: "grid spacing" - }; - this.defaultClassNames = "col-xs-12 col-sm-6 col-md-3 col-lg-2"; - } - - // eslint-disable-next-line class-methods-use-this - getDefaultShift() { - return 0; - } - get _defaultDimensions() { - return this.calculateDimensions({ - gridMetricType: "KPPRA", - gridMetricValue: this._getDefaultGridMetricValue("KPPRA") - }); - } - get _defaultShifts() { - return Array(3).fill(this.getDefaultShift()); - } - _getDefaultGridMetricValue(metric) { - switch (metric) { - case "KPPRA": - return Math.floor(_settings.globalSettings.defaultKPPRA / this._divisor); - case "spacing": - return 0.3; - default: - console.error("Metric type not recognized!"); - return 1; - } - } - get _defaultData() { - return { - dimensions: this._defaultDimensions, - shifts: this._defaultShifts, - gridMetricType: "KPPRA", - gridMetricValue: this._getDefaultGridMetricValue("KPPRA"), - preferGridMetric: false, - reciprocalVectorRatios: this.reciprocalVectorRatios - }; - } - get _defaultDataWithMaterial() { - const { - gridMetricType, - gridMetricValue - } = this; - // if `data` is present and material is updated, prioritize `data` when `preferGridMetric` is not set - return this.preferGridMetric ? { - dimensions: this.calculateDimensions({ - gridMetricType, - gridMetricValue - }), - shifts: this._defaultShifts - } : this.data || this._defaultData; - } - get defaultData() { - return this.material ? this._defaultDataWithMaterial : this._defaultData; - } - get reciprocalVectorRatios() { - return this.reciprocalLattice.reciprocalVectorRatios.map(r => Number(_math.math.numberToPrecision(r, 3))); - } - get jsonSchemaPatchConfig() { - // Helper function to create vector schema with defaults - const vector_ = (defaultValue, isStringType = false) => { - const isArray = Array.isArray(defaultValue); - return { - type: "array", - items: { - type: isStringType ? "string" : "number", - ...(isArray ? {} : { - default: defaultValue - }) - }, - minItems: 3, - maxItems: 3, - ...(isArray ? { - default: defaultValue - } : {}) - }; - }; - return { - dimensions: vector_(this._defaultDimensions, this.isUsingJinjaVariables), - shifts: vector_(this.getDefaultShift()), - reciprocalVectorRatios: vector_(this.reciprocalVectorRatios), - gridMetricType: { - default: "KPPRA" - }, - description: `3D grid with shifts. Default min value for ${this._metricDescription[this.gridMetricType]} is ${this._getDefaultGridMetricValue(this.gridMetricType)}.`, - required: ["dimensions", "shifts"], - dependencies: { - gridMetricType: { - oneOf: [{ - properties: { - gridMetricType: { - enum: ["KPPRA"] - }, - gridMetricValue: { - type: "integer", - minimum: 1, - title: "Value", - default: this.gridMetricValue - }, - preferGridMetric: { - type: "boolean", - title: "prefer KPPRA", - default: this.preferGridMetric - } - } - }, { - properties: { - gridMetricType: { - enum: ["spacing"] - }, - gridMetricValue: { - type: "number", - minimum: 0, - title: "Value [1/Å]", - default: this.gridMetricValue - }, - preferGridMetric: { - type: "boolean", - title: "prefer spacing", - default: this.preferGridMetric - } - } - }] - } - } - }; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } - get uiSchema() { - const _arraySubStyle = (emptyValue = 0) => { - return { - "ui:options": { - addable: false, - orderable: false, - removable: false - }, - items: { - "ui:disabled": this.preferGridMetric, - // TODO: extract the actual current values from context - "ui:placeholder": "1", - "ui:emptyValue": emptyValue, - "ui:label": false - } - }; - }; - return { - dimensions: _arraySubStyle(1), - shifts: _arraySubStyle(0), - gridMetricType: { - "ui:title": "Grid Metric" - }, - gridMetricValue: { - "ui:disabled": !this.preferGridMetric, - "ui:emptyValue": this.gridMetricValue, - "ui:placeholder": this.gridMetricValue.toString() // make string to prevent prop type error - }, - preferGridMetric: { - "ui:emptyValue": true, - "ui:disabled": this.isUsingJinjaVariables - }, - reciprocalVectorRatios: { - "ui:title": "reciprocal vector ratios", - "ui:orderable": false, - "ui:removable": false, - "ui:readonly": true, - items: { - "ui:label": false - } - } - }; - } - _getDimensionsFromKPPRA(KPPRA) { - const nAtoms = this.material ? this.material.Basis.nAtoms : 1; - return this.reciprocalLattice.getDimensionsFromPointsCount(KPPRA / nAtoms); - } - _getKPPRAFromDimensions(dimensions) { - const nAtoms = this.material ? this.material.Basis.nAtoms : 1; - return dimensions.reduce((a, b) => a * b) * nAtoms; - } - static _canTransform(data) { - return data.preferGridMetric && data.gridMetricType && data.gridMetricValue || !data.preferGridMetric && data.dimensions.every(d => typeof d === "number"); - } - calculateDimensions({ - gridMetricType, - gridMetricValue, - units = _constants.units.angstrom - }) { - switch (gridMetricType) { - case "KPPRA": - return this._getDimensionsFromKPPRA(gridMetricValue); - case "spacing": - return this.reciprocalLattice.getDimensionsFromSpacing(gridMetricValue, units); - default: - return [1, 1, 1]; - } - } - calculateGridMetric({ - gridMetricType, - dimensions, - units = _constants.units.angstrom - }) { - switch (gridMetricType) { - case "KPPRA": - return this._getKPPRAFromDimensions(dimensions); - case "spacing": - return _lodash.default.round(this.reciprocalLattice.getSpacingFromDimensions(dimensions, units), 3); - default: - return 1; - } - } - transformData(data) { - if (!this.constructor._canTransform(data)) { - return data; - } - // dimensions are calculated from grid metric or vice versa - if (data.preferGridMetric) { - data.dimensions = this.calculateDimensions(data); - } else { - data.gridMetricValue = this.calculateGridMetric(data); - } - return data; - } -} -exports.PointsGridFormDataProvider = PointsGridFormDataProvider; -(0, _MaterialContextMixin.materialContextMixin)(PointsGridFormDataProvider.prototype); \ No newline at end of file diff --git a/dist/js/context/providers/PointsPath/ExplicitKPath2PIBAFormDataManager.d.ts b/dist/js/context/providers/PointsPath/ExplicitKPath2PIBAFormDataManager.d.ts new file mode 100644 index 00000000..9470d2cd --- /dev/null +++ b/dist/js/context/providers/PointsPath/ExplicitKPath2PIBAFormDataManager.d.ts @@ -0,0 +1,8 @@ +import PointsPathFormDataProvider from "./PointsPathFormDataProvider"; +type Name = "explicitKPath2PIBA"; +export default class ExplicitKPath2PIBAFormDataManager extends PointsPathFormDataProvider { + readonly name: Name; + readonly is2PIBA = true; + readonly useExplicitPath = true; +} +export {}; diff --git a/dist/js/context/providers/PointsPath/ExplicitKPath2PIBAFormDataManager.js b/dist/js/context/providers/PointsPath/ExplicitKPath2PIBAFormDataManager.js new file mode 100644 index 00000000..1c6653b3 --- /dev/null +++ b/dist/js/context/providers/PointsPath/ExplicitKPath2PIBAFormDataManager.js @@ -0,0 +1,15 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const PointsPathFormDataProvider_1 = __importDefault(require("./PointsPathFormDataProvider")); +class ExplicitKPath2PIBAFormDataManager extends PointsPathFormDataProvider_1.default { + constructor() { + super(...arguments); + this.name = "explicitKPath2PIBA"; + this.is2PIBA = true; + this.useExplicitPath = true; + } +} +exports.default = ExplicitKPath2PIBAFormDataManager; diff --git a/dist/js/context/providers/PointsPath/ExplicitKPathFormDataManager.d.ts b/dist/js/context/providers/PointsPath/ExplicitKPathFormDataManager.d.ts new file mode 100644 index 00000000..64c6a064 --- /dev/null +++ b/dist/js/context/providers/PointsPath/ExplicitKPathFormDataManager.d.ts @@ -0,0 +1,7 @@ +import PointsPathFormDataProvider from "./PointsPathFormDataProvider"; +type Name = "explicitKPath"; +export default class ExplicitKPathFormDataManager extends PointsPathFormDataProvider { + readonly name: Name; + readonly useExplicitPath = true; +} +export {}; diff --git a/dist/js/context/providers/PointsPath/ExplicitKPathFormDataManager.js b/dist/js/context/providers/PointsPath/ExplicitKPathFormDataManager.js new file mode 100644 index 00000000..76c930bd --- /dev/null +++ b/dist/js/context/providers/PointsPath/ExplicitKPathFormDataManager.js @@ -0,0 +1,14 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const PointsPathFormDataProvider_1 = __importDefault(require("./PointsPathFormDataProvider")); +class ExplicitKPathFormDataManager extends PointsPathFormDataProvider_1.default { + constructor() { + super(...arguments); + this.name = "explicitKPath"; + this.useExplicitPath = true; + } +} +exports.default = ExplicitKPathFormDataManager; diff --git a/dist/js/context/providers/PointsPath/IPathFormDataManager.d.ts b/dist/js/context/providers/PointsPath/IPathFormDataManager.d.ts new file mode 100644 index 00000000..e756e575 --- /dev/null +++ b/dist/js/context/providers/PointsPath/IPathFormDataManager.d.ts @@ -0,0 +1,6 @@ +import PointsPathFormDataProvider from "./PointsPathFormDataProvider"; +type Name = "ipath"; +export default class IPathFormDataManager extends PointsPathFormDataProvider { + readonly name: Name; +} +export {}; diff --git a/dist/js/context/providers/PointsPath/IPathFormDataManager.js b/dist/js/context/providers/PointsPath/IPathFormDataManager.js new file mode 100644 index 00000000..a1011782 --- /dev/null +++ b/dist/js/context/providers/PointsPath/IPathFormDataManager.js @@ -0,0 +1,13 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const PointsPathFormDataProvider_1 = __importDefault(require("./PointsPathFormDataProvider")); +class IPathFormDataManager extends PointsPathFormDataProvider_1.default { + constructor() { + super(...arguments); + this.name = "ipath"; + } +} +exports.default = IPathFormDataManager; diff --git a/dist/js/context/providers/PointsPath/KPathFormDataManager.d.ts b/dist/js/context/providers/PointsPath/KPathFormDataManager.d.ts new file mode 100644 index 00000000..cc3b49be --- /dev/null +++ b/dist/js/context/providers/PointsPath/KPathFormDataManager.d.ts @@ -0,0 +1,6 @@ +import PointsPathFormDataProvider from "./PointsPathFormDataProvider"; +type Name = "kpath"; +export default class KPathFormDataManager extends PointsPathFormDataProvider { + readonly name: Name; +} +export {}; diff --git a/dist/js/context/providers/PointsPath/KPathFormDataManager.js b/dist/js/context/providers/PointsPath/KPathFormDataManager.js new file mode 100644 index 00000000..fe70575f --- /dev/null +++ b/dist/js/context/providers/PointsPath/KPathFormDataManager.js @@ -0,0 +1,13 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const PointsPathFormDataProvider_1 = __importDefault(require("./PointsPathFormDataProvider")); +class KPathFormDataManager extends PointsPathFormDataProvider_1.default { + constructor() { + super(...arguments); + this.name = "kpath"; + } +} +exports.default = KPathFormDataManager; diff --git a/dist/js/context/providers/PointsPath/PointsPathFormDataProvider.d.ts b/dist/js/context/providers/PointsPath/PointsPathFormDataProvider.d.ts new file mode 100644 index 00000000..3c00fee8 --- /dev/null +++ b/dist/js/context/providers/PointsPath/PointsPathFormDataProvider.d.ts @@ -0,0 +1,27 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { PointsPathDataProviderSchema } from "@mat3ra/esse/dist/js/types"; +import { type ApplicationContextMixin } from "../../mixins/ApplicationContextMixin"; +import { type MaterialContextMixin, type MaterialExternalContext } from "../../mixins/MaterialContextMixin"; +import type { ContextItem, Domain } from "../base/ContextProvider"; +import JSONSchemaDataProvider, { type JinjaExternalContext } from "../base/JSONSchemaDataProvider"; +type Data = PointsPathDataProviderSchema; +type ExternalContext = JinjaExternalContext & MaterialExternalContext & ApplicationContextMixin; +type Base = typeof JSONSchemaDataProvider & Constructor & Constructor; +declare const MixinsContextProvider_base: Base; +declare abstract class MixinsContextProvider extends MixinsContextProvider_base { + constructor(contextItem: ContextItem, externalContext: ExternalContext); +} +declare abstract class PointsPathFormDataProvider extends MixinsContextProvider { + abstract name: N; + readonly domain: Domain; + private reciprocalLattice; + readonly useExplicitPath: boolean; + readonly is2PIBA: boolean; + constructor(config: ContextItem, externalContext: ExternalContext); + getDefaultData(): Data; + updateMaterialHash(): void; + get jsonSchema(): import("json-schema").JSONSchema7 | undefined; + setData(path: Data): void; + private convertToExplicitPath; +} +export default PointsPathFormDataProvider; diff --git a/dist/js/context/providers/PointsPath/PointsPathFormDataProvider.js b/dist/js/context/providers/PointsPath/PointsPathFormDataProvider.js new file mode 100644 index 00000000..c84169cd --- /dev/null +++ b/dist/js/context/providers/PointsPath/PointsPathFormDataProvider.js @@ -0,0 +1,114 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const math_1 = require("@mat3ra/code/dist/js/math"); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const made_1 = require("@mat3ra/made"); +const underscore_string_1 = __importDefault(require("underscore.string")); +const ApplicationContextMixin_1 = require("../../mixins/ApplicationContextMixin"); +const MaterialContextMixin_1 = __importDefault(require("../../mixins/MaterialContextMixin")); +const JSONSchemaDataProvider_1 = __importDefault(require("../base/JSONSchemaDataProvider")); +const defaultPoint = "Г"; +const defaultSteps = 10; +const jsonSchemaId = "context-providers-directory/points-path-data-provider"; +class MixinsContextProvider extends JSONSchemaDataProvider_1.default { + constructor(contextItem, externalContext) { + super(contextItem, externalContext); + this.initMaterialContextMixin(externalContext); + this.initApplicationContextMixin(externalContext); + } +} +(0, MaterialContextMixin_1.default)(MixinsContextProvider.prototype); +(0, ApplicationContextMixin_1.applicationContextMixin)(MixinsContextProvider.prototype); +class PointsPathFormDataProvider extends MixinsContextProvider { + constructor(config, externalContext) { + super(config, externalContext); + this.domain = "important"; + this.is2PIBA = false; + this.reciprocalLattice = new made_1.Made.ReciprocalLattice(this.material.lattice); + this.useExplicitPath = this.application.name === "vasp"; + } + getDefaultData() { + return this.reciprocalLattice.defaultKpointPath; + } + updateMaterialHash() { + var _a; + super.updateMaterialHash(); + // Workaround: Material.createDefault() used to initiate workflow reducer and hence here too + // does not have an id. Here we catch when such material is used and avoid resetting isEdited + const isMaterialCreatedDefault = !this.material.id; + const isMaterialUpdated = ((_a = this.extraData) === null || _a === void 0 ? void 0 : _a.materialHash) !== this.material.hash; + if (isMaterialUpdated || isMaterialCreatedDefault) { + this.isEdited = false; + } + } + get jsonSchema() { + return JSONSchemasInterface_1.default.getPatchedSchemaById(jsonSchemaId, { + "items.properties.point": { + default: defaultPoint, + enum: this.reciprocalLattice.symmetryPoints.map((x) => x.point), + }, + "items.properties.steps": { + default: defaultSteps, + }, + }); + } + setData(path) { + const rawData = path.map((pathItem) => { + const point = this.reciprocalLattice.symmetryPoints.find((sp) => { + return sp.point === pathItem.point; + }); + if (!point) { + throw new Error(`Point ${pathItem.point} not found in reciprocal lattice`); + } + return { ...pathItem, coordinates: point.coordinates }; + }); + const processedData = this.useExplicitPath ? this.convertToExplicitPath(rawData) : rawData; + const newData = processedData.map((p) => { + const coordinates = this.is2PIBA + ? this.reciprocalLattice.getCartesianCoordinates(p.coordinates) + : p.coordinates; + return { + ...p, + coordinates: coordinates.map((c) => +underscore_string_1.default.sprintf("%14.9f", c)), + }; + }); + super.setData(newData); + } + // Initially, path contains symmetry points with steps counts. + // This function explicitly calculates each point between symmetry points by step counts. + // eslint-disable-next-line class-methods-use-this + convertToExplicitPath(path) { + return path.reduce((acc, startPoint, index) => { + const nextPoint = path[index + 1]; + if (!nextPoint) { + return acc; + } + const middlePoints = math_1.math.calculateSegmentsBetweenPoints3D(startPoint.coordinates, nextPoint.coordinates, startPoint.steps); + const steps = 1; + // TODO-QUESTION: confirm that "point" property should be present after transformation; point was missing in original implementation + acc.push({ + steps, + coordinates: startPoint.coordinates, + point: startPoint.point, + }, ...middlePoints.map((coordinates) => ({ + steps, + coordinates, + // TODO-QUESTION: is this correct? + point: startPoint.point, + }))); + // nextPoint is the last point in the path + if (path.length - 2 === index) { + acc.push({ + steps, + coordinates: nextPoint.coordinates, + point: nextPoint.point, + }); + } + return acc; + }, []); + } +} +exports.default = PointsPathFormDataProvider; diff --git a/dist/js/context/providers/PointsPath/QPathFormDataManager.d.ts b/dist/js/context/providers/PointsPath/QPathFormDataManager.d.ts new file mode 100644 index 00000000..dcc2e11c --- /dev/null +++ b/dist/js/context/providers/PointsPath/QPathFormDataManager.d.ts @@ -0,0 +1,6 @@ +import PointsPathFormDataProvider from "./PointsPathFormDataProvider"; +type Name = "qpath"; +export default class QPathFormDataManager extends PointsPathFormDataProvider { + readonly name: Name; +} +export {}; diff --git a/dist/js/context/providers/PointsPath/QPathFormDataManager.js b/dist/js/context/providers/PointsPath/QPathFormDataManager.js new file mode 100644 index 00000000..bf0acf10 --- /dev/null +++ b/dist/js/context/providers/PointsPath/QPathFormDataManager.js @@ -0,0 +1,13 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const PointsPathFormDataProvider_1 = __importDefault(require("./PointsPathFormDataProvider")); +class QPathFormDataManager extends PointsPathFormDataProvider_1.default { + constructor() { + super(...arguments); + this.name = "qpath"; + } +} +exports.default = QPathFormDataManager; diff --git a/dist/js/context/providers/PointsPathFormDataProvider.js b/dist/js/context/providers/PointsPathFormDataProvider.js deleted file mode 100644 index cb2982ea..00000000 --- a/dist/js/context/providers/PointsPathFormDataProvider.js +++ /dev/null @@ -1,147 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.PointsPathFormDataProvider = exports.ExplicitPointsPathFormDataProvider = exports.ExplicitPointsPath2PIBAFormDataProvider = void 0; -var _ade = require("@mat3ra/ade"); -var _math = require("@mat3ra/code/dist/js/math"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _made = require("@mat3ra/made"); -var _underscore = _interopRequireDefault(require("underscore.string")); -var _ApplicationContextMixin = require("../mixins/ApplicationContextMixin"); -var _MaterialContextMixin = require("../mixins/MaterialContextMixin"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable max-classes-per-file */ /* eslint react/prop-types: 0 */ -const defaultPoint = "Г"; -const defaultSteps = 10; -class PointsPathFormDataProvider extends _ade.JSONSchemaFormDataProvider { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/points-path-data-provider"); - this.initMaterialContextMixin(); - this.initApplicationContextMixin(); - this.reciprocalLattice = new _made.Made.ReciprocalLattice(this.material.lattice); - this.symmetryPoints = this.symmetryPointsFromMaterial; - } - get isEditedIsSetToFalseOnMaterialUpdate() { - return this.isMaterialUpdated || this.isMaterialCreatedDefault; - } - get defaultData() { - return this.reciprocalLattice.defaultKpointPath; - } - get symmetryPointsFromMaterial() { - return this.reciprocalLattice.symmetryPoints; - } - get jsonSchemaPatchConfig() { - const points = [].concat(this.symmetryPoints).map(x => x.point); - return { - "items.properties.point": { - default: defaultPoint, - enum: points - }, - "items.properties.steps": { - default: defaultSteps - } - }; - } - get jsonSchema() { - return _JSONSchemasInterface.default.getPatchedSchemaById(this.jsonSchemaId, this.jsonSchemaPatchConfig); - } - - // eslint-disable-next-line class-methods-use-this - get uiSchema() { - return { - items: {} - }; - } - get uiSchemaStyled() { - return { - items: { - point: this.defaultFieldStyles, - steps: this.defaultFieldStyles - } - }; - } - - // eslint-disable-next-line class-methods-use-this - get templates() { - return {}; - } - getBrillouinZoneImageComponent(title) { - const hasRequiredFn = typeof this.material.getBrillouinZoneImageComponent === "function"; - if (!hasRequiredFn) { - console.log("PointsPathFormDataProvider: Material class has no function" + " 'getBrillouinZoneImageComponent'! Returning empty Object instead."); - return null; - } - return this.material.getBrillouinZoneImageComponent(title); - } - get useExplicitPath() { - return this.application.name === "vasp"; - } - - // override yieldData to avoid storing explicit path in saved context - yieldDataForRendering() { - return this.yieldData(this.useExplicitPath); - } - transformData(path = [], useExplicitPath = false) { - const rawData = path.map(p => { - const point = this.symmetryPoints.find(sp => sp.point === p.point); - return { - ...p, - coordinates: point.coordinates - }; - }); - const processedData = useExplicitPath ? this._convertToExplicitPath(rawData) : rawData; - // make coordinates into string and add formatting - return processedData.map(p => { - const coordinates = this.is2PIBA ? this.get2PIBACoordinates(p.coordinates) : p.coordinates; - p.coordinates = coordinates.map(c => _underscore.default.sprintf("%14.9f", c)); - return p; - }); - } - get2PIBACoordinates(point) { - return this.reciprocalLattice.getCartesianCoordinates(point); - } - - // Initially, path contains symmetry points with steps counts. - // This function explicitly calculates each point between symmetry points by step counts. - // eslint-disable-next-line class-methods-use-this - _convertToExplicitPath(path) { - const points = []; - for (let i = 0; i < path.length - 1; i++) { - const startPoint = path[i]; - const endPoint = path[i + 1]; - const middlePoints = _math.math.calculateSegmentsBetweenPoints3D(startPoint.coordinates, endPoint.coordinates, startPoint.steps); - points.push(startPoint.coordinates); - points.push(...middlePoints); - // Include endPoint into path for the last section, otherwise it will be included by next loop iteration - if (path.length - 2 === i) points.push(endPoint.coordinates); - } - return points.map(x => { - return { - coordinates: x, - steps: 1 - }; - }); - } -} -exports.PointsPathFormDataProvider = PointsPathFormDataProvider; -class ExplicitPointsPathFormDataProvider extends PointsPathFormDataProvider { - // eslint-disable-next-line class-methods-use-this - get useExplicitPath() { - return true; - } -} -exports.ExplicitPointsPathFormDataProvider = ExplicitPointsPathFormDataProvider; -class ExplicitPointsPath2PIBAFormDataProvider extends ExplicitPointsPathFormDataProvider { - // eslint-disable-next-line class-methods-use-this - get is2PIBA() { - return true; - } -} -exports.ExplicitPointsPath2PIBAFormDataProvider = ExplicitPointsPath2PIBAFormDataProvider; -(0, _MaterialContextMixin.materialContextMixin)(PointsPathFormDataProvider.prototype); -(0, _ApplicationContextMixin.applicationContextMixin)(PointsPathFormDataProvider.prototype); \ No newline at end of file diff --git a/dist/js/context/providers/base/ContextProvider.d.ts b/dist/js/context/providers/base/ContextProvider.d.ts new file mode 100644 index 00000000..219e43fb --- /dev/null +++ b/dist/js/context/providers/base/ContextProvider.d.ts @@ -0,0 +1,41 @@ +import { ContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +export interface ContextProviderInstance { + constructor: typeof ContextProvider; + config: ContextProviderSchema; +} +export type ContextProviderConfig = { + name: N; + data?: D; + extraData?: ED; + domain?: string; + entityName?: EntityName; + isEdited?: boolean; +}; +export type ContextItem = { + data?: D; + extraData?: ED; + isEdited?: boolean; +}; +export type ExtendedContextItem = ContextItem & { + name: N; + isEdited: boolean; +}; +export type Domain = "executable" | "important"; +export type EntityName = "unit" | "subworkflow"; +export type ExternalContext = object; +declare abstract class ContextProvider implements ContextProviderConfig { + abstract name: N; + abstract readonly domain: Domain; + abstract readonly entityName: EntityName; + protected abstract getDefaultData(): D; + data?: D; + readonly extraData?: ED; + readonly externalContext: EC; + isEdited: boolean; + constructor(contextItem: ContextItem, externalContext: EC); + setIsEdited(isEdited: boolean): void; + getData(): D; + setData(data?: D): void; + getContextItem(): ExtendedContextItem; +} +export default ContextProvider; diff --git a/dist/js/context/providers/base/ContextProvider.js b/dist/js/context/providers/base/ContextProvider.js new file mode 100644 index 00000000..0966fc2f --- /dev/null +++ b/dist/js/context/providers/base/ContextProvider.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const utils_1 = require("@mat3ra/utils"); +class ContextProvider { + constructor(contextItem, externalContext) { + this.externalContext = externalContext; + this.extraData = contextItem.extraData; + this.isEdited = contextItem.isEdited || false; + this.setData(contextItem.data); + } + setIsEdited(isEdited) { + this.isEdited = isEdited; + } + getData() { + return this.isEdited && this.data ? this.data : this.getDefaultData(); + } + setData(data) { + this.data = data ? utils_1.Utils.clone.deepClone(data) : undefined; + } + getContextItem() { + return { + name: this.name, + isEdited: this.isEdited, + data: this.getData(), + extraData: this.extraData, + }; + } +} +exports.default = ContextProvider; diff --git a/dist/js/context/providers/base/JSONSchemaDataProvider.d.ts b/dist/js/context/providers/base/JSONSchemaDataProvider.d.ts new file mode 100644 index 00000000..8e4d5c0a --- /dev/null +++ b/dist/js/context/providers/base/JSONSchemaDataProvider.d.ts @@ -0,0 +1,16 @@ +import type { JSONSchema } from "@mat3ra/esse/dist/js/esse/utils"; +import type { ContextItem, EntityName, ExternalContext } from "./ContextProvider"; +import ContextProvider from "./ContextProvider"; +export interface JinjaExternalContext extends ExternalContext { + isUsingJinjaVariables?: boolean; +} +/** + * @summary Provides jsonSchema only. + */ +declare abstract class JSONSchemaDataProvider extends ContextProvider { + abstract readonly jsonSchema: JSONSchema | undefined; + readonly entityName: EntityName; + isUsingJinjaVariables: boolean; + constructor(contextItem: ContextItem, externalContext: EC); +} +export default JSONSchemaDataProvider; diff --git a/dist/js/context/providers/base/JSONSchemaDataProvider.js b/dist/js/context/providers/base/JSONSchemaDataProvider.js new file mode 100644 index 00000000..9221e32e --- /dev/null +++ b/dist/js/context/providers/base/JSONSchemaDataProvider.js @@ -0,0 +1,17 @@ +"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")); +/** + * @summary Provides jsonSchema only. + */ +class JSONSchemaDataProvider extends ContextProvider_1.default { + constructor(contextItem, externalContext) { + super(contextItem, externalContext); + this.entityName = "unit"; + this.isUsingJinjaVariables = Boolean(externalContext === null || externalContext === void 0 ? void 0 : externalContext.isUsingJinjaVariables); + } +} +exports.default = JSONSchemaDataProvider; diff --git a/dist/js/context/providers/base/JSONSchemaFormDataProvider.d.ts b/dist/js/context/providers/base/JSONSchemaFormDataProvider.d.ts new file mode 100644 index 00000000..ab44f43a --- /dev/null +++ b/dist/js/context/providers/base/JSONSchemaFormDataProvider.d.ts @@ -0,0 +1,18 @@ +import type { UiSchema } from "react-jsonschema-form"; +import JSONSchemaDataProvider, { type JinjaExternalContext } 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: + * ``` + *
+ * ``` + */ +declare abstract class JSONSchemaFormDataProvider extends JSONSchemaDataProvider { + fields: object; + protected abstract uiSchema: UiSchema; + get uiSchemaStyled(): UiSchema; +} +export default JSONSchemaFormDataProvider; diff --git a/dist/js/context/providers/base/JSONSchemaFormDataProvider.js b/dist/js/context/providers/base/JSONSchemaFormDataProvider.js new file mode 100644 index 00000000..3c534c7a --- /dev/null +++ b/dist/js/context/providers/base/JSONSchemaFormDataProvider.js @@ -0,0 +1,32 @@ +"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: + * ``` + * + * ``` + */ +class JSONSchemaFormDataProvider extends JSONSchemaDataProvider_1.default { + constructor() { + super(...arguments); + this.fields = {}; + } + get uiSchemaStyled() { + return Object.fromEntries(Object.entries(this.uiSchema).map(([key, value]) => [ + key, + { + ...value, + classNames: `${value.classNames || ""}`, + }, + ])); + } +} +exports.default = JSONSchemaFormDataProvider; diff --git a/dist/js/context/providers/by_application/ExecutableContextProvider.js b/dist/js/context/providers/by_application/ExecutableContextProvider.js deleted file mode 100644 index 298b6092..00000000 --- a/dist/js/context/providers/by_application/ExecutableContextProvider.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _ade = require("@mat3ra/ade"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class ExecutableContextProvider extends _ade.ContextProvider { - constructor(config) { - super({ - ...config, - domain: "executable" - }); - _defineProperty(this, "jsonSchemaId", "context-provider"); - } - get jsonSchema() { - return _JSONSchemasInterface.default.getSchemaById(this.jsonSchemaId); - } -} -exports.default = ExecutableContextProvider; \ No newline at end of file diff --git a/dist/js/context/providers/by_application/espresso/QENEBContextProvider.d.ts b/dist/js/context/providers/by_application/espresso/QENEBContextProvider.d.ts new file mode 100644 index 00000000..ac0e54a0 --- /dev/null +++ b/dist/js/context/providers/by_application/espresso/QENEBContextProvider.d.ts @@ -0,0 +1,24 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { QENEBContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import { type JobContextMixin, type JobExternalContext } from "../../../mixins/JobContextMixin"; +import { type MaterialContextMixin, type MaterialExternalContext } from "../../../mixins/MaterialContextMixin"; +import { type MaterialsContextMixin, type MaterialsExternalContext } from "../../../mixins/MaterialsContextMixin"; +import { type MaterialsSetContextMixin } from "../../../mixins/MaterialsSetContextMixin"; +import { type MethodDataContextMixin, type MethodDataExternalContext } from "../../../mixins/MethodDataContextMixin"; +import { type WorkflowContextMixin, type WorkflowExternalContext } from "../../../mixins/WorkflowContextMixin"; +import type { ContextItem, Domain } from "../../base/ContextProvider"; +import JSONSchemaDataProvider, { type JinjaExternalContext } from "../../base/JSONSchemaDataProvider"; +type Name = "input"; +type Data = QENEBContextProviderSchema; +type ExternalContext = JinjaExternalContext & WorkflowExternalContext & JobExternalContext & MaterialsExternalContext & MethodDataExternalContext & MaterialsSetContextMixin & MaterialExternalContext; +type Base = typeof JSONSchemaDataProvider & Constructor & Constructor & Constructor & Constructor & Constructor & Constructor; +declare const QENEBContextProvider_base: Base; +export default class QENEBContextProvider extends QENEBContextProvider_base { + readonly name: Name; + readonly domain: Domain; + readonly jsonSchema: JSONSchema7 | undefined; + constructor(config: ContextItem, externalContext: ExternalContext); + getDefaultData(): Data; +} +export {}; diff --git a/dist/js/context/providers/by_application/espresso/QENEBContextProvider.js b/dist/js/context/providers/by_application/espresso/QENEBContextProvider.js index 54b1a032..2bc1f66d 100644 --- a/dist/js/context/providers/by_application/espresso/QENEBContextProvider.js +++ b/dist/js/context/providers/by_application/espresso/QENEBContextProvider.js @@ -1,61 +1,53 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _lodash = _interopRequireDefault(require("lodash")); -var _JobContextMixin = require("../../../mixins/JobContextMixin"); -var _MaterialContextMixin = require("../../../mixins/MaterialContextMixin"); -var _MaterialsContextMixin = require("../../../mixins/MaterialsContextMixin"); -var _MaterialsSetContextMixin = require("../../../mixins/MaterialsSetContextMixin"); -var _MethodDataContextMixin = require("../../../mixins/MethodDataContextMixin"); -var _WorkflowContextMixin = require("../../../mixins/WorkflowContextMixin"); -var _ExecutableContextProvider = _interopRequireDefault(require("../ExecutableContextProvider")); -var _QEPWXContextProvider = _interopRequireDefault(require("./QEPWXContextProvider")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class QENEBContextProvider extends _ExecutableContextProvider.default { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/by-application/qe-neb-context-provider"); - _defineProperty(this, "_material", undefined); - _defineProperty(this, "_materials", []); - _defineProperty(this, "_materialsSet", undefined); - this.initJobContextMixin(); - this.initMaterialsContextMixin(); - this.initMethodDataContextMixin(); - this.initWorkflowContextMixin(); - this.initMaterialContextMixin(); - this.initMaterialsSetContextMixin(); - } - getData() { - const sortedMaterials = this.sortMaterialsByIndexInSet(this.materials); - const PWXContexts = sortedMaterials.map(material => { - const context = { - ...this.config.context, - material - }; - const config = { - ...this.config, - context - }; - return new _QEPWXContextProvider.default(config).getData(); - }); - return { - ..._lodash.default.omit(PWXContexts[0], ["ATOMIC_POSITIONS", "ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS"]), - FIRST_IMAGE: PWXContexts[0].ATOMIC_POSITIONS, - LAST_IMAGE: PWXContexts[PWXContexts.length - 1].ATOMIC_POSITIONS, - INTERMEDIATE_IMAGES: PWXContexts.slice(1, PWXContexts.length - 1).map(data => data.ATOMIC_POSITIONS) - }; - } +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const JobContextMixin_1 = __importDefault(require("../../../mixins/JobContextMixin")); +const MaterialContextMixin_1 = __importDefault(require("../../../mixins/MaterialContextMixin")); +const MaterialsContextMixin_1 = __importDefault(require("../../../mixins/MaterialsContextMixin")); +const MaterialsSetContextMixin_1 = __importDefault(require("../../../mixins/MaterialsSetContextMixin")); +const MethodDataContextMixin_1 = __importDefault(require("../../../mixins/MethodDataContextMixin")); +const WorkflowContextMixin_1 = __importDefault(require("../../../mixins/WorkflowContextMixin")); +const JSONSchemaDataProvider_1 = __importDefault(require("../../base/JSONSchemaDataProvider")); +const QEPWXContextProvider_1 = __importDefault(require("./QEPWXContextProvider")); +const jsonSchemaId = "context-providers-directory/by-application/qe-neb-context-provider"; +function atomicPositionsToString(atomicPositions) { + return atomicPositions.map(({ X, x, y, z }) => `${X} ${x} ${y} ${z}`).join("\n"); +} +class QENEBContextProvider extends JSONSchemaDataProvider_1.default { + constructor(config, externalContext) { + super(config, externalContext); + this.name = "input"; + this.domain = "executable"; + this.initJobContextMixin(externalContext); + this.initMaterialsContextMixin(externalContext); + this.initMethodDataContextMixin(externalContext); + this.initWorkflowContextMixin(externalContext); + this.initMaterialContextMixin(externalContext); + this.initMaterialsSetContextMixin(externalContext); + this.jsonSchema = JSONSchemasInterface_1.default.getSchemaById(jsonSchemaId); + } + getDefaultData() { + const PWXContexts = this.sortMaterialsByIndexInSet(this.materials).map((material) => { + return new QEPWXContextProvider_1.default({}, { ...this.externalContext, material }).getData(); + }); + const { ATOMIC_POSITIONS, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS: _, ...rest } = PWXContexts[0]; + return { + ...rest, + FIRST_IMAGE: atomicPositionsToString(ATOMIC_POSITIONS), + LAST_IMAGE: atomicPositionsToString(PWXContexts[PWXContexts.length - 1].ATOMIC_POSITIONS), + INTERMEDIATE_IMAGES: PWXContexts.slice(1, PWXContexts.length - 1).map((data) => atomicPositionsToString(data.ATOMIC_POSITIONS)), + }; + } } exports.default = QENEBContextProvider; -(0, _MaterialContextMixin.materialContextMixin)(QENEBContextProvider.prototype); -(0, _MaterialsContextMixin.materialsContextMixin)(QENEBContextProvider.prototype); -(0, _MethodDataContextMixin.methodDataContextMixin)(QENEBContextProvider.prototype); -(0, _WorkflowContextMixin.workflowContextMixin)(QENEBContextProvider.prototype); -(0, _JobContextMixin.jobContextMixin)(QENEBContextProvider.prototype); -(0, _MaterialsSetContextMixin.materialsSetContextMixin)(QENEBContextProvider.prototype); \ No newline at end of file +(0, MaterialContextMixin_1.default)(QENEBContextProvider.prototype); +(0, MaterialsContextMixin_1.default)(QENEBContextProvider.prototype); +(0, MethodDataContextMixin_1.default)(QENEBContextProvider.prototype); +(0, WorkflowContextMixin_1.default)(QENEBContextProvider.prototype); +(0, JobContextMixin_1.default)(QENEBContextProvider.prototype); +(0, MaterialsSetContextMixin_1.default)(QENEBContextProvider.prototype); diff --git a/dist/js/context/providers/by_application/espresso/QEPWXContextProvider.d.ts b/dist/js/context/providers/by_application/espresso/QEPWXContextProvider.d.ts new file mode 100644 index 00000000..e38caab3 --- /dev/null +++ b/dist/js/context/providers/by_application/espresso/QEPWXContextProvider.d.ts @@ -0,0 +1,89 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { QEPwxContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import { type JobContextMixin, type JobExternalContext } from "../../../mixins/JobContextMixin"; +import { type MaterialContextMixin, type MaterialExternalContext } from "../../../mixins/MaterialContextMixin"; +import { type MaterialsContextMixin, type MaterialsExternalContext } from "../../../mixins/MaterialsContextMixin"; +import { type MethodDataContextMixin, type MethodDataExternalContext } from "../../../mixins/MethodDataContextMixin"; +import { type WorkflowContextMixin, type WorkflowExternalContext } from "../../../mixins/WorkflowContextMixin"; +import type { ContextItem, Domain } from "../../base/ContextProvider"; +import JSONSchemaDataProvider, { type JinjaExternalContext } from "../../base/JSONSchemaDataProvider"; +type Name = "input"; +type Data = QEPwxContextProviderSchema; +type ExternalContext = JinjaExternalContext & WorkflowExternalContext & MaterialExternalContext & JobExternalContext & MethodDataExternalContext & MaterialsExternalContext; +type Base = typeof JSONSchemaDataProvider & Constructor & Constructor & Constructor & Constructor & Constructor; +declare const QEPWXContextProvider_base: Base; +export default class QEPWXContextProvider extends QEPWXContextProvider_base { + readonly name: Name; + readonly domain: Domain; + readonly jsonSchema: JSONSchema7 | undefined; + constructor(config: ContextItem, externalContext: ExternalContext); + private buildQEPWXContext; + private getDataPerMaterial; + getDefaultData(): { + perMaterial?: undefined; + IBRAV: number; + RESTART_MODE: "from_scratch" | "restart"; + ATOMIC_SPECIES: { + X?: string; + Mass_X?: number; + PseudoPot_X?: string; + }[]; + ATOMIC_SPECIES_WITH_LABELS: { + X?: string; + Mass_X?: number; + PseudoPot_X?: string; + }[]; + NAT: number; + NTYP: number; + NTYP_WITH_LABELS: number; + ATOMIC_POSITIONS: { + X?: string; + x: number; + y: number; + z: number; + "if_pos(1)"?: number; + "if_pos(2)"?: number; + "if_pos(3)"?: number; + }[]; + ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS: string; + CELL_PARAMETERS: { + v1?: [number, number, number]; + v2?: [number, number, number]; + v3?: [number, number, number]; + }; + } | { + perMaterial: QEPwxContextProviderSchema[]; + IBRAV: number; + RESTART_MODE: "from_scratch" | "restart"; + ATOMIC_SPECIES: { + X?: string; + Mass_X?: number; + PseudoPot_X?: string; + }[]; + ATOMIC_SPECIES_WITH_LABELS: { + X?: string; + Mass_X?: number; + PseudoPot_X?: string; + }[]; + NAT: number; + NTYP: number; + NTYP_WITH_LABELS: number; + ATOMIC_POSITIONS: { + X?: string; + x: number; + y: number; + z: number; + "if_pos(1)"?: number; + "if_pos(2)"?: number; + "if_pos(3)"?: number; + }[]; + ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS: string; + CELL_PARAMETERS: { + v1?: [number, number, number]; + v2?: [number, number, number]; + v3?: [number, number, number]; + }; + }; +} +export {}; diff --git a/dist/js/context/providers/by_application/espresso/QEPWXContextProvider.js b/dist/js/context/providers/by_application/espresso/QEPWXContextProvider.js index 51ace97a..63ba251d 100644 --- a/dist/js/context/providers/by_application/espresso/QEPWXContextProvider.js +++ b/dist/js/context/providers/by_application/espresso/QEPWXContextProvider.js @@ -1,150 +1,105 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _periodicTable = require("@exabyte-io/periodic-table.js"); -var _path = _interopRequireDefault(require("path")); -var _underscore = _interopRequireDefault(require("underscore.string")); -var _JobContextMixin = require("../../../mixins/JobContextMixin"); -var _MaterialContextMixin = require("../../../mixins/MaterialContextMixin"); -var _MaterialsContextMixin = require("../../../mixins/MaterialsContextMixin"); -var _MethodDataContextMixin = require("../../../mixins/MethodDataContextMixin"); -var _WorkflowContextMixin = require("../../../mixins/WorkflowContextMixin"); -var _ExecutableContextProvider = _interopRequireDefault(require("../ExecutableContextProvider")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class QEPWXContextProvider extends _ExecutableContextProvider.default { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/by-application/qe-pwx-context-provider"); - _defineProperty(this, "_material", undefined); - _defineProperty(this, "_materials", []); - this.initMaterialsContextMixin(); - this.initMethodDataContextMixin(); - this.initWorkflowContextMixin(); - this.initJobContextMixin(); - this.initMaterialContextMixin(); - } - static atomSymbols(material) { - return material.Basis.uniqueElements; - } - static uniqueElementsWithLabels(material) { - // return unique items - return [...new Set(material.Basis.elementsWithLabelsArray)]; - } - - /** Returns the input text block for atomic positions WITH constraints. - */ - static atomicPositionsWithConstraints(material) { - return material.Basis.getAtomicPositionsWithConstraintsAsStrings().join("\n"); - } - - /** Returns the input text block for atomic positions - * Note: does NOT include constraints - */ - static atomicPositions(material) { - return material.Basis.atomicPositions.join("\n"); - } - static NAT(material) { - return material.Basis.atomicPositions.length; - } - static NTYP(material) { - return material.Basis.uniqueElements.length; - } - static NTYP_WITH_LABELS(material) { - return this.uniqueElementsWithLabels(material).length; - } - buildQEPWXContext(material) { - const IBRAV = 0; // use CELL_PARAMETERS to define Bravais lattice - - return { - IBRAV, - RESTART_MODE: this.RESTART_MODE, - ATOMIC_SPECIES: this.ATOMIC_SPECIES(material), - ATOMIC_SPECIES_WITH_LABELS: this.ATOMIC_SPECIES_WITH_LABELS(material), - NAT: QEPWXContextProvider.NAT(material), - NTYP: QEPWXContextProvider.NTYP(material), - NTYP_WITH_LABELS: QEPWXContextProvider.NTYP_WITH_LABELS(material), - ATOMIC_POSITIONS: QEPWXContextProvider.atomicPositionsWithConstraints(material), - ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS: QEPWXContextProvider.atomicPositions(material), - CELL_PARAMETERS: QEPWXContextProvider.CELL_PARAMETERS(material) - }; - } - getDataPerMaterial() { - if (!this.materials || this.materials.length <= 1) return {}; - return { - perMaterial: this.materials.map(material => this.buildQEPWXContext(material)) - }; - } - - /* - * @NOTE: Overriding getData makes this provider "stateless", ie. delivering data from scratch each time and not - * considering the content of `this.data`, and `this.isEdited` field(s). - */ - getData() { - // the below values are read from PlanewaveDataManager instead - // ECUTWFC = 40; - // ECUTRHO = 200; - - return { - ...this.buildQEPWXContext(this.material), - ...this.getDataPerMaterial() - }; - } - get RESTART_MODE() { - return this.job.parentJob || this.workflow.hasRelaxation ? "restart" : "from_scratch"; - } - getPseudoBySymbol(symbol) { - return (this.methodData.pseudo || []).find(p => p.element === symbol); - } - - /** Builds ATOMIC SPECIES block of pw.x input in the format - * X Mass_X PseudoPot_X - * where X is the atom label - * Mass_X is the mass of element X [amu] - * PseudoPot_X is the pseudopotential filename associated with element X - * - * Note: assumes this.methodData is defined - */ - ATOMIC_SPECIES(material) { - return QEPWXContextProvider.atomSymbols(material).map(symbol => { - const pseudo = this.getPseudoBySymbol(symbol); - return QEPWXContextProvider.symbolToAtomicSpecie(symbol, pseudo); - }).join("\n"); - } - ATOMIC_SPECIES_WITH_LABELS(material) { - return QEPWXContextProvider.uniqueElementsWithLabels(material).map(symbol => { - const symbolWithoutLabel = symbol.replace(/\d$/, ""); - const label = symbol.match(/\d$/g) ? symbol.match(/\d$/g)?.[0] : ""; - const pseudo = this.getPseudoBySymbol(symbolWithoutLabel); - return QEPWXContextProvider.elementAndPseudoToAtomicSpecieWithLabels(symbolWithoutLabel, pseudo, label); - }).join("\n"); - } - static CELL_PARAMETERS(material) { - return material.Lattice.vectorArrays.map(x => { - return x.map(y => { - return _underscore.default.sprintf("%14.9f", y).trim(); - }).join(" "); - }).join("\n"); - } - static symbolToAtomicSpecie(symbol, pseudo) { - const el = _periodicTable.PERIODIC_TABLE[symbol]; - const filename = pseudo?.filename || _path.default.basename(pseudo?.path || ""); - return _underscore.default.sprintf("%s %f %s", symbol, el.atomic_mass, filename) || ""; - } - static elementAndPseudoToAtomicSpecieWithLabels(symbol, pseudo, label = "") { - const el = _periodicTable.PERIODIC_TABLE[symbol]; - const filename = pseudo?.filename || _path.default.basename(pseudo?.path || ""); - return _underscore.default.sprintf("%s%s %f %s", symbol, label, el.atomic_mass, filename) || ""; - } +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const periodic_table_js_1 = require("@exabyte-io/periodic-table.js"); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const path_1 = __importDefault(require("path")); +const JobContextMixin_1 = __importDefault(require("../../../mixins/JobContextMixin")); +const MaterialContextMixin_1 = __importDefault(require("../../../mixins/MaterialContextMixin")); +const MaterialsContextMixin_1 = __importDefault(require("../../../mixins/MaterialsContextMixin")); +const MethodDataContextMixin_1 = __importDefault(require("../../../mixins/MethodDataContextMixin")); +const WorkflowContextMixin_1 = __importDefault(require("../../../mixins/WorkflowContextMixin")); +const JSONSchemaDataProvider_1 = __importDefault(require("../../base/JSONSchemaDataProvider")); +const jsonSchemaId = "context-providers-directory/by-application/qe-pwx-context-provider"; +class QEPWXContextProvider extends JSONSchemaDataProvider_1.default { + constructor(config, externalContext) { + super(config, externalContext); + this.name = "input"; + this.domain = "executable"; + this.initMaterialsContextMixin(externalContext); + this.initMethodDataContextMixin(externalContext); + this.initWorkflowContextMixin(externalContext); + this.initJobContextMixin(externalContext); + this.initMaterialContextMixin(externalContext); + this.jsonSchema = JSONSchemasInterface_1.default.getSchemaById(jsonSchemaId); + } + buildQEPWXContext(material) { + const { Basis: basis, Lattice: lattice } = material; + const { job, workflow } = this; + const ATOMIC_SPECIES = basis.uniqueElements.map((symbol) => { + var _a; + const pseudo = (((_a = this.methodData) === null || _a === void 0 ? void 0 : _a.pseudo) || []).find((p) => p.element === symbol); + return { + X: symbol, + Mass_X: periodic_table_js_1.PERIODIC_TABLE[symbol].atomic_mass, + PseudoPot_X: (pseudo === null || pseudo === void 0 ? void 0 : pseudo.filename) || path_1.default.basename((pseudo === null || pseudo === void 0 ? void 0 : pseudo.path) || ""), + }; + // return s.sprintf("%s %f %s", symbol, el.atomic_mass, filename) || ""; + }); // .join("\n"); + const uniqueElementsWithLabels = [...new Set(basis.elementsWithLabelsArray)]; + const ATOMIC_SPECIES_WITH_LABELS = uniqueElementsWithLabels.map((symbol) => { + var _a, _b; + const symbolWithoutLabel = symbol.replace(/\d$/, ""); + const label = symbol.match(/\d$/g) ? (_a = symbol.match(/\d$/g)) === null || _a === void 0 ? void 0 : _a[0] : ""; + const pseudo = (((_b = this.methodData) === null || _b === void 0 ? void 0 : _b.pseudo) || []).find((p) => p.element === symbolWithoutLabel); + return { + X: `${symbolWithoutLabel}${label}`, + Mass_X: periodic_table_js_1.PERIODIC_TABLE[symbol].atomic_mass, + PseudoPot_X: (pseudo === null || pseudo === void 0 ? void 0 : pseudo.filename) || path_1.default.basename((pseudo === null || pseudo === void 0 ? void 0 : pseudo.path) || ""), + }; + // return s.sprintf("%s%s %f %s", symbol, label, el.atomic_mass, filename) || ""; + }); // .join("\n"); + // Format numbers with 14 total width, 9 decimal places (equivalent to %14.9f) + // const formatNumber = (num: number) => { + // return Number(num.toFixed(9).padStart(14).trim()); + // }; + const CELL_PARAMETERS = { + v1: lattice.vectorArrays[0], + v2: lattice.vectorArrays[1], + v3: lattice.vectorArrays[2], + }; + // const ATOMIC_POSITIONS = basis.getAtomicPositionsWithConstraintsAsStrings().join("\n"); + const ATOMIC_POSITIONS = basis.elementsAndCoordinatesAndLabelsArray.map(([element, coordinate, label]) => { + return { + X: `${element}${label}`, + x: coordinate[0], + y: coordinate[1], + z: coordinate[2], + }; + }); + return { + IBRAV: 0, // use CELL_PARAMETERS to define Bravais lattice + RESTART_MODE: job.parent || workflow.hasRelaxation ? "restart" : "from_scratch", + ATOMIC_SPECIES, + ATOMIC_SPECIES_WITH_LABELS, + NAT: basis.atomicPositions.length, + NTYP: basis.uniqueElements.length, + NTYP_WITH_LABELS: uniqueElementsWithLabels.length, + ATOMIC_POSITIONS, + ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS: basis.atomicPositions.join("\n"), + CELL_PARAMETERS, + }; + } + getDataPerMaterial() { + if (!this.materials || this.materials.length <= 1) + return {}; + return { perMaterial: this.materials.map((material) => this.buildQEPWXContext(material)) }; + } + getDefaultData() { + // the below values are read from PlanewaveDataManager instead + // ECUTWFC = 40; + // ECUTRHO = 200; + return { + ...this.buildQEPWXContext(this.material), + ...this.getDataPerMaterial(), + }; + } } exports.default = QEPWXContextProvider; -(0, _MaterialContextMixin.materialContextMixin)(QEPWXContextProvider.prototype); -(0, _MaterialsContextMixin.materialsContextMixin)(QEPWXContextProvider.prototype); -(0, _MethodDataContextMixin.methodDataContextMixin)(QEPWXContextProvider.prototype); -(0, _WorkflowContextMixin.workflowContextMixin)(QEPWXContextProvider.prototype); -(0, _JobContextMixin.jobContextMixin)(QEPWXContextProvider.prototype); \ No newline at end of file +(0, MaterialContextMixin_1.default)(QEPWXContextProvider.prototype); +(0, MaterialsContextMixin_1.default)(QEPWXContextProvider.prototype); +(0, MethodDataContextMixin_1.default)(QEPWXContextProvider.prototype); +(0, WorkflowContextMixin_1.default)(QEPWXContextProvider.prototype); +(0, JobContextMixin_1.default)(QEPWXContextProvider.prototype); diff --git a/dist/js/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.d.ts b/dist/js/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.d.ts new file mode 100644 index 00000000..81ffabf4 --- /dev/null +++ b/dist/js/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.d.ts @@ -0,0 +1,33 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { NWChemTotalEnergyContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import { type JobContextMixin, type JobExternalContext } from "../../../mixins/JobContextMixin"; +import { type MaterialContextMixin, type MaterialExternalContext } from "../../../mixins/MaterialContextMixin"; +import { type MethodDataContextMixin, type MethodDataExternalContext } from "../../../mixins/MethodDataContextMixin"; +import { type WorkflowContextMixin, type WorkflowExternalContext } from "../../../mixins/WorkflowContextMixin"; +import type { ContextItem, Domain } from "../../base/ContextProvider"; +import JSONSchemaDataProvider, { type JinjaExternalContext } from "../../base/JSONSchemaDataProvider"; +type Name = "input"; +type Data = NWChemTotalEnergyContextProviderSchema; +type ExternalContext = JinjaExternalContext & WorkflowExternalContext & JobExternalContext & MethodDataExternalContext & MaterialExternalContext; +type Base = typeof JSONSchemaDataProvider & Constructor & Constructor & Constructor & Constructor; +declare const NWChemTotalEnergyContextProvider_base: Base; +export default class NWChemTotalEnergyContextProvider extends NWChemTotalEnergyContextProvider_base { + readonly name: Name; + readonly domain: Domain; + readonly jsonSchema: JSONSchema7 | undefined; + constructor(config: ContextItem, externalContext: ExternalContext); + getDefaultData(): { + CHARGE: number; + MULT: number; + BASIS: string; + NAT: number; + NTYP: number; + ATOMIC_POSITIONS: string; + ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS: string; + ATOMIC_SPECIES: string; + FUNCTIONAL: string; + CARTESIAN: boolean; + }; +} +export {}; diff --git a/dist/js/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.js b/dist/js/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.js index 1901250f..02b09dd3 100644 --- a/dist/js/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.js +++ b/dist/js/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.js @@ -1,85 +1,55 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _periodicTable = require("@exabyte-io/periodic-table.js"); -var _lodash = _interopRequireDefault(require("lodash")); -var _underscore = _interopRequireDefault(require("underscore")); -var _underscore2 = _interopRequireDefault(require("underscore.string")); -var _JobContextMixin = require("../../../mixins/JobContextMixin"); -var _MaterialContextMixin = require("../../../mixins/MaterialContextMixin"); -var _MethodDataContextMixin = require("../../../mixins/MethodDataContextMixin"); -var _WorkflowContextMixin = require("../../../mixins/WorkflowContextMixin"); -var _ExecutableContextProvider = _interopRequireDefault(require("../ExecutableContextProvider")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class NWChemTotalEnergyContextProvider extends _ExecutableContextProvider.default { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/by-application/nwchem-total-energy-context-provider"); - _defineProperty(this, "_material", undefined); - this.initMethodDataContextMixin(); - this.initWorkflowContextMixin(); - this.initJobContextMixin(); - this.initMaterialContextMixin(); - } - get atomicPositionsWithoutConstraints() { - return this.material.Basis.atomicPositions; - } - get atomicPositions() { - const basis = this.material.Basis; - basis.toCartesian(); - return basis.getAtomicPositionsWithConstraintsAsStrings(); - } - get atomSymbols() { - return this.material.Basis.uniqueElements; - } - get cartesianAtomicPositions() { - return this.material.Basis.toCartesian !== undefined; - } - get ATOMIC_SPECIES() { - return _underscore.default.map(this.atomSymbols, symbol => { - return NWChemTotalEnergyContextProvider.symbolToAtomicSpecies(symbol); - }).join("\n"); - } - - /* - * @NOTE: Overriding getData makes this provider "stateless", ie. delivering data from scratch each time and not - * considering the content of `this.data`, and `this.isEdited` field(s). - */ - getData() { +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const periodic_table_js_1 = require("@exabyte-io/periodic-table.js"); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const JobContextMixin_1 = __importDefault(require("../../../mixins/JobContextMixin")); +const MaterialContextMixin_1 = __importDefault(require("../../../mixins/MaterialContextMixin")); +const MethodDataContextMixin_1 = __importDefault(require("../../../mixins/MethodDataContextMixin")); +const WorkflowContextMixin_1 = __importDefault(require("../../../mixins/WorkflowContextMixin")); +const JSONSchemaDataProvider_1 = __importDefault(require("../../base/JSONSchemaDataProvider")); +const jsonSchemaId = "context-providers-directory/by-application/nwchem-total-energy-context-provider"; +class NWChemTotalEnergyContextProvider extends JSONSchemaDataProvider_1.default { + constructor(config, externalContext) { + super(config, externalContext); + this.name = "input"; + this.domain = "executable"; + this.initMethodDataContextMixin(externalContext); + this.initWorkflowContextMixin(externalContext); + this.initJobContextMixin(externalContext); + this.initMaterialContextMixin(externalContext); + this.jsonSchema = JSONSchemasInterface_1.default.getSchemaById(jsonSchemaId); + } /* - TODO: Create ability for user to define CHARGE, MULT, BASIS and FUNCTIONAL parameters. + * TODO: Create ability for user to define CHARGE, MULT, BASIS and FUNCTIONAL parameters. */ - const CHARGE = 0; - const MULT = 1; - const BASIS = "6-31G"; - const FUNCTIONAL = "B3LYP"; - return { - CHARGE, - MULT, - BASIS, - NAT: this.atomicPositions.length, - NTYP: this.atomSymbols.length, - ATOMIC_POSITIONS: this.atomicPositions.join("\n"), - ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS: this.atomicPositionsWithoutConstraints.join("\n"), - ATOMIC_SPECIES: this.ATOMIC_SPECIES, - FUNCTIONAL, - CARTESIAN: this.cartesianAtomicPositions - }; - } - static symbolToAtomicSpecies(symbol, pseudo) { - const el = _periodicTable.PERIODIC_TABLE[symbol]; - const filename = pseudo ? _lodash.default.get(pseudo, "filename", _underscore2.default.strRightBack(pseudo.path || "", "/")) : ""; - return el ? _underscore2.default.sprintf("%s %f %s", symbol, el.atomic_mass, filename) : undefined; - } + getDefaultData() { + const basis = this.material.Basis; + const NTYP = basis.uniqueElements.length; + const ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS = basis.atomicPositions.join("\n") || ""; + const ATOMIC_SPECIES = basis.uniqueElements + .map((symbol) => `${symbol} ${periodic_table_js_1.PERIODIC_TABLE[symbol].atomic_mass} `) + .join("\n"); + basis.toCartesian(); + const atomicPositions = basis.getAtomicPositionsWithConstraintsAsStrings(); + return { + CHARGE: 0, + MULT: 1, + BASIS: "6-31G", + NAT: atomicPositions.length, + NTYP, + ATOMIC_POSITIONS: atomicPositions.join("\n"), + ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS, + ATOMIC_SPECIES, + FUNCTIONAL: "B3LYP", + CARTESIAN: basis.toCartesian !== undefined, + }; + } } exports.default = NWChemTotalEnergyContextProvider; -(0, _MaterialContextMixin.materialContextMixin)(NWChemTotalEnergyContextProvider.prototype); -(0, _MethodDataContextMixin.methodDataContextMixin)(NWChemTotalEnergyContextProvider.prototype); -(0, _WorkflowContextMixin.workflowContextMixin)(NWChemTotalEnergyContextProvider.prototype); -(0, _JobContextMixin.jobContextMixin)(NWChemTotalEnergyContextProvider.prototype); \ No newline at end of file +(0, MaterialContextMixin_1.default)(NWChemTotalEnergyContextProvider.prototype); +(0, MethodDataContextMixin_1.default)(NWChemTotalEnergyContextProvider.prototype); +(0, WorkflowContextMixin_1.default)(NWChemTotalEnergyContextProvider.prototype); +(0, JobContextMixin_1.default)(NWChemTotalEnergyContextProvider.prototype); diff --git a/dist/js/context/providers/by_application/vasp/VASPContextProvider.d.ts b/dist/js/context/providers/by_application/vasp/VASPContextProvider.d.ts new file mode 100644 index 00000000..fd149acc --- /dev/null +++ b/dist/js/context/providers/by_application/vasp/VASPContextProvider.d.ts @@ -0,0 +1,33 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { VASPContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import { type JobContextMixin, type JobExternalContext } from "../../../mixins/JobContextMixin"; +import { type MaterialContextMixin, type MaterialExternalContext } from "../../../mixins/MaterialContextMixin"; +import { type MaterialsContextMixin } from "../../../mixins/MaterialsContextMixin"; +import { type MethodDataContextMixin, type MethodDataExternalContext } from "../../../mixins/MethodDataContextMixin"; +import { type WorkflowContextMixin, type WorkflowExternalContext } from "../../../mixins/WorkflowContextMixin"; +import type { ContextItem, Domain } from "../../base/ContextProvider"; +import JSONSchemaDataProvider, { type JinjaExternalContext } from "../../base/JSONSchemaDataProvider"; +type Name = "input"; +type Data = VASPContextProviderSchema; +type ExternalContext = JinjaExternalContext & WorkflowExternalContext & JobExternalContext & MaterialExternalContext & MethodDataExternalContext & MaterialsContextMixin; +type Base = typeof JSONSchemaDataProvider & Constructor & Constructor & Constructor & Constructor & Constructor; +declare const VASPContextProvider_base: Base; +export default class VASPContextProvider extends VASPContextProvider_base { + readonly name: Name; + readonly domain: Domain; + readonly jsonSchema: JSONSchema7 | undefined; + constructor(config: ContextItem, externalContext: ExternalContext); + private buildVASPContext; + private getDataPerMaterial; + getDefaultData(): { + perMaterial?: undefined; + POSCAR: string; + POSCAR_WITH_CONSTRAINTS: string; + } | { + perMaterial: VASPContextProviderSchema[]; + POSCAR: string; + POSCAR_WITH_CONSTRAINTS: string; + }; +} +export {}; diff --git a/dist/js/context/providers/by_application/vasp/VASPContextProvider.js b/dist/js/context/providers/by_application/vasp/VASPContextProvider.js index 13e7f6ac..3f3eff90 100644 --- a/dist/js/context/providers/by_application/vasp/VASPContextProvider.js +++ b/dist/js/context/providers/by_application/vasp/VASPContextProvider.js @@ -1,65 +1,55 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _JobContextMixin = require("../../../mixins/JobContextMixin"); -var _MaterialContextMixin = require("../../../mixins/MaterialContextMixin"); -var _MaterialsContextMixin = require("../../../mixins/MaterialsContextMixin"); -var _MethodDataContextMixin = require("../../../mixins/MethodDataContextMixin"); -var _WorkflowContextMixin = require("../../../mixins/WorkflowContextMixin"); -var _ExecutableContextProvider = _interopRequireDefault(require("../ExecutableContextProvider")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class VASPContextProvider extends _ExecutableContextProvider.default { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/by-application/vasp-context-provider"); - _defineProperty(this, "_material", undefined); - _defineProperty(this, "_materials", []); - this.initJobContextMixin(); - this.initMaterialsContextMixin(); - this.initMethodDataContextMixin(); - this.initWorkflowContextMixin(); - this.initMaterialContextMixin(); - } - - // eslint-disable-next-line class-methods-use-this - buildVASPContext(material) { - return { - // TODO: figure out whether we need two separate POSCARS, maybe one is enough - POSCAR: material.getAsPOSCAR(true, true), - POSCAR_WITH_CONSTRAINTS: material.getAsPOSCAR(true) - }; - } - getDataPerMaterial() { - if (!this.materials || this.materials.length <= 1) return {}; - return { - perMaterial: this.materials.map(material => this.buildVASPContext(material)) - }; - } - - /* - * @NOTE: Overriding getData makes this provider "stateless", ie. delivering data from scratch each time and not - * considering the content of `this.data`, and `this.isEdited` field(s). - */ - getData() { - // consider adjusting so that below values are read from PlanewaveDataManager - // ECUTWFC; - // ECUTRHO; - - return { - ...this.buildVASPContext(this.material), - ...this.getDataPerMaterial() - }; - } +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const JobContextMixin_1 = __importDefault(require("../../../mixins/JobContextMixin")); +const MaterialContextMixin_1 = __importDefault(require("../../../mixins/MaterialContextMixin")); +const MaterialsContextMixin_1 = __importDefault(require("../../../mixins/MaterialsContextMixin")); +const MethodDataContextMixin_1 = __importDefault(require("../../../mixins/MethodDataContextMixin")); +const WorkflowContextMixin_1 = __importDefault(require("../../../mixins/WorkflowContextMixin")); +const JSONSchemaDataProvider_1 = __importDefault(require("../../base/JSONSchemaDataProvider")); +const jsonSchemaId = "context-providers-directory/by-application/vasp-context-provider"; +class VASPContextProvider extends JSONSchemaDataProvider_1.default { + constructor(config, externalContext) { + super(config, externalContext); + this.name = "input"; + this.domain = "executable"; + this.initJobContextMixin(externalContext); + this.initMaterialsContextMixin(externalContext); + this.initMethodDataContextMixin(externalContext); + this.initWorkflowContextMixin(externalContext); + this.initMaterialContextMixin(externalContext); + this.jsonSchema = JSONSchemasInterface_1.default.getSchemaById(jsonSchemaId); + } + // eslint-disable-next-line class-methods-use-this + buildVASPContext(material) { + return { + // TODO: figure out whether we need two separate POSCARS, maybe one is enough + POSCAR: material.getAsPOSCAR(true, true), + POSCAR_WITH_CONSTRAINTS: material.getAsPOSCAR(true), + }; + } + getDataPerMaterial() { + if (!this.materials || this.materials.length <= 1) + return {}; + // TODO-QUESTION: perMaterial is not defined in the schema + return { perMaterial: this.materials.map((material) => this.buildVASPContext(material)) }; + } + getDefaultData() { + // consider adjusting so that below values are read from PlanewaveDataManager + // ECUTWFC; + // ECUTRHO; + return { + ...this.buildVASPContext(this.material), + ...this.getDataPerMaterial(), + }; + } } exports.default = VASPContextProvider; -(0, _MaterialContextMixin.materialContextMixin)(VASPContextProvider.prototype); -(0, _MaterialsContextMixin.materialsContextMixin)(VASPContextProvider.prototype); -(0, _MethodDataContextMixin.methodDataContextMixin)(VASPContextProvider.prototype); -(0, _WorkflowContextMixin.workflowContextMixin)(VASPContextProvider.prototype); -(0, _JobContextMixin.jobContextMixin)(VASPContextProvider.prototype); \ No newline at end of file +(0, MaterialContextMixin_1.default)(VASPContextProvider.prototype); +(0, MaterialsContextMixin_1.default)(VASPContextProvider.prototype); +(0, MethodDataContextMixin_1.default)(VASPContextProvider.prototype); +(0, WorkflowContextMixin_1.default)(VASPContextProvider.prototype); +(0, JobContextMixin_1.default)(VASPContextProvider.prototype); diff --git a/dist/js/context/providers/by_application/vasp/VASPNEBContextProvider.d.ts b/dist/js/context/providers/by_application/vasp/VASPNEBContextProvider.d.ts new file mode 100644 index 00000000..fa42d1e2 --- /dev/null +++ b/dist/js/context/providers/by_application/vasp/VASPNEBContextProvider.d.ts @@ -0,0 +1,28 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { VASPNEBContextProviderSchema } from "@mat3ra/esse/dist/js/types"; +import type { JSONSchema7 } from "json-schema"; +import { type JobContextMixin, type JobExternalContext } from "../../../mixins/JobContextMixin"; +import { type MaterialContextMixin, type MaterialExternalContext } from "../../../mixins/MaterialContextMixin"; +import { type MaterialsContextMixin } from "../../../mixins/MaterialsContextMixin"; +import { type MaterialsSetContextMixin } from "../../../mixins/MaterialsSetContextMixin"; +import { type MethodDataContextMixin, type MethodDataExternalContext } from "../../../mixins/MethodDataContextMixin"; +import { type WorkflowContextMixin, type WorkflowExternalContext } from "../../../mixins/WorkflowContextMixin"; +import type { ContextItem, Domain } from "../../base/ContextProvider"; +import JSONSchemaDataProvider, { type JinjaExternalContext } from "../../base/JSONSchemaDataProvider"; +type Name = "input"; +type Data = VASPNEBContextProviderSchema; +type ExternalContext = JinjaExternalContext & WorkflowExternalContext & JobExternalContext & MaterialExternalContext & MethodDataExternalContext & MaterialsContextMixin & MaterialsSetContextMixin; +type Base = typeof JSONSchemaDataProvider & Constructor & Constructor & Constructor & Constructor & Constructor & Constructor; +declare const VASPNEBContextProvider_base: Base; +export default class VASPNEBContextProvider extends VASPNEBContextProvider_base { + readonly name: Name; + readonly domain: Domain; + readonly jsonSchema: JSONSchema7 | undefined; + constructor(config: ContextItem, externalContext: ExternalContext); + getDefaultData(): { + FIRST_IMAGE: string; + LAST_IMAGE: string; + INTERMEDIATE_IMAGES: string[]; + }; +} +export {}; diff --git a/dist/js/context/providers/by_application/vasp/VASPNEBContextProvider.js b/dist/js/context/providers/by_application/vasp/VASPNEBContextProvider.js index 1a76328f..23e1e892 100644 --- a/dist/js/context/providers/by_application/vasp/VASPNEBContextProvider.js +++ b/dist/js/context/providers/by_application/vasp/VASPNEBContextProvider.js @@ -1,57 +1,48 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _JobContextMixin = require("../../../mixins/JobContextMixin"); -var _MaterialContextMixin = require("../../../mixins/MaterialContextMixin"); -var _MaterialsContextMixin = require("../../../mixins/MaterialsContextMixin"); -var _MaterialsSetContextMixin = require("../../../mixins/MaterialsSetContextMixin"); -var _MethodDataContextMixin = require("../../../mixins/MethodDataContextMixin"); -var _WorkflowContextMixin = require("../../../mixins/WorkflowContextMixin"); -var _ExecutableContextProvider = _interopRequireDefault(require("../ExecutableContextProvider")); -var _VASPContextProvider = _interopRequireDefault(require("./VASPContextProvider")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class VASPNEBContextProvider extends _ExecutableContextProvider.default { - constructor(config) { - super(config); - _defineProperty(this, "jsonSchemaId", "context-providers-directory/by-application/vasp-neb-context-provider"); - _defineProperty(this, "_materials", []); - this.initMaterialContextMixin(); - this.initMaterialsContextMixin(); - this.initMaterialsSetContextMixin(); - this.initMethodDataContextMixin(); - this.initWorkflowContextMixin(); - this.initJobContextMixin(); - } - getData() { - const sortedMaterials = this.sortMaterialsByIndexInSet(this.materials); - const VASPContexts = sortedMaterials.map(material => { - const context = { - ...this.config.context, - material - }; - const config = { - ...this.config, - context - }; - return new _VASPContextProvider.default(config).getData(); - }); - return { - FIRST_IMAGE: VASPContexts[0].POSCAR_WITH_CONSTRAINTS, - LAST_IMAGE: VASPContexts[VASPContexts.length - 1].POSCAR_WITH_CONSTRAINTS, - INTERMEDIATE_IMAGES: VASPContexts.slice(1, VASPContexts.length - 1).map(data => data.POSCAR_WITH_CONSTRAINTS) - }; - } +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const JobContextMixin_1 = __importDefault(require("../../../mixins/JobContextMixin")); +const MaterialContextMixin_1 = __importDefault(require("../../../mixins/MaterialContextMixin")); +const MaterialsContextMixin_1 = __importDefault(require("../../../mixins/MaterialsContextMixin")); +const MaterialsSetContextMixin_1 = __importDefault(require("../../../mixins/MaterialsSetContextMixin")); +const MethodDataContextMixin_1 = __importDefault(require("../../../mixins/MethodDataContextMixin")); +const WorkflowContextMixin_1 = __importDefault(require("../../../mixins/WorkflowContextMixin")); +const JSONSchemaDataProvider_1 = __importDefault(require("../../base/JSONSchemaDataProvider")); +const VASPContextProvider_1 = __importDefault(require("./VASPContextProvider")); +const jsonSchemaId = "context-providers-directory/by-application/vasp-neb-context-provider"; +class VASPNEBContextProvider extends JSONSchemaDataProvider_1.default { + constructor(config, externalContext) { + super(config, externalContext); + this.name = "input"; + this.domain = "executable"; + this.initMaterialContextMixin(externalContext); + this.initMaterialsContextMixin(externalContext); + this.initMaterialsSetContextMixin(externalContext); + this.initMethodDataContextMixin(externalContext); + this.initWorkflowContextMixin(externalContext); + this.initJobContextMixin(externalContext); + this.jsonSchema = JSONSchemasInterface_1.default.getSchemaById(jsonSchemaId); + } + getDefaultData() { + const VASPContexts = this.sortMaterialsByIndexInSet(this.materials).map((material) => { + return new VASPContextProvider_1.default({}, { ...this.externalContext, material }).getData(); + }); + return { + FIRST_IMAGE: VASPContexts[0].POSCAR_WITH_CONSTRAINTS, + LAST_IMAGE: VASPContexts[VASPContexts.length - 1].POSCAR_WITH_CONSTRAINTS, + INTERMEDIATE_IMAGES: VASPContexts.slice(1, VASPContexts.length - 1).map((data) => { + return data.POSCAR_WITH_CONSTRAINTS; + }), + }; + } } exports.default = VASPNEBContextProvider; -(0, _MaterialContextMixin.materialContextMixin)(VASPNEBContextProvider.prototype); -(0, _MaterialsContextMixin.materialsContextMixin)(VASPNEBContextProvider.prototype); -(0, _MaterialsSetContextMixin.materialsSetContextMixin)(VASPNEBContextProvider.prototype); -(0, _MethodDataContextMixin.methodDataContextMixin)(VASPNEBContextProvider.prototype); -(0, _WorkflowContextMixin.workflowContextMixin)(VASPNEBContextProvider.prototype); -(0, _JobContextMixin.jobContextMixin)(VASPNEBContextProvider.prototype); \ No newline at end of file +(0, MaterialContextMixin_1.default)(VASPNEBContextProvider.prototype); +(0, MaterialsContextMixin_1.default)(VASPNEBContextProvider.prototype); +(0, MaterialsSetContextMixin_1.default)(VASPNEBContextProvider.prototype); +(0, MethodDataContextMixin_1.default)(VASPNEBContextProvider.prototype); +(0, WorkflowContextMixin_1.default)(VASPNEBContextProvider.prototype); +(0, JobContextMixin_1.default)(VASPNEBContextProvider.prototype); diff --git a/dist/js/context/providers/settings.d.ts b/dist/js/context/providers/settings.d.ts new file mode 100644 index 00000000..a900c581 --- /dev/null +++ b/dist/js/context/providers/settings.d.ts @@ -0,0 +1,15 @@ +import { Application } from "@mat3ra/ade"; +import { Made } from "@mat3ra/made"; +declare class GlobalSettings { + "PointsGridFormDataProvider.defaultKPPRA": number; + Material: typeof import("@mat3ra/made").Material; + Application: typeof Application; + constructor(); + get defaultKPPRA(): number; + setApplication(application: typeof Application): void; + setMaterial(material: typeof Made.Material): void; + setDefaultKPPRA(kppra: number): void; + resetDefaults(): void; +} +export declare const globalSettings: GlobalSettings; +export {}; diff --git a/dist/js/context/providers/settings.js b/dist/js/context/providers/settings.js index bc4cd736..6ed19f81 100644 --- a/dist/js/context/providers/settings.js +++ b/dist/js/context/providers/settings.js @@ -1,37 +1,31 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.globalSettings = void 0; -var _ade = require("@mat3ra/ade"); -var _made = require("@mat3ra/made"); -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +const ade_1 = require("@mat3ra/ade"); +const made_1 = require("@mat3ra/made"); class GlobalSettings { - constructor() { - _defineProperty(this, "PointsGridFormDataProvider.defaultKPPRA", 5); - _defineProperty(this, "Material", _made.Made.Material); - _defineProperty(this, "Application", _ade.Application); - this.resetDefaults(); - } - get defaultKPPRA() { - return this["PointsGridFormDataProvider.defaultKPPRA"]; - } - setApplication(application) { - this.Application = application; - } - setMaterial(material) { - this.Material = material; - } - setDefaultKPPRA(kppra) { - this["PointsGridFormDataProvider.defaultKPPRA"] = kppra; - } - resetDefaults() { - this.Material = _made.Made.Material; - this.Application = _ade.Application; - this["PointsGridFormDataProvider.defaultKPPRA"] = 5; - } + constructor() { + this["PointsGridFormDataProvider.defaultKPPRA"] = 5; + this.Material = made_1.Made.Material; + this.Application = ade_1.Application; + this.resetDefaults(); + } + get defaultKPPRA() { + return this["PointsGridFormDataProvider.defaultKPPRA"]; + } + setApplication(application) { + this.Application = application; + } + setMaterial(material) { + this.Material = material; + } + setDefaultKPPRA(kppra) { + this["PointsGridFormDataProvider.defaultKPPRA"] = kppra; + } + resetDefaults() { + this.Material = made_1.Made.Material; + this.Application = ade_1.Application; + this["PointsGridFormDataProvider.defaultKPPRA"] = 5; + } } -const globalSettings = exports.globalSettings = new GlobalSettings(); \ No newline at end of file +exports.globalSettings = new GlobalSettings(); diff --git a/dist/js/enums.d.ts b/dist/js/enums.d.ts new file mode 100644 index 00000000..22ab6b5e --- /dev/null +++ b/dist/js/enums.d.ts @@ -0,0 +1,69 @@ +/** + * THIS ENUMS ARE SHARED WITH TESTS. + * DO NOT IMPORT ANYTHINGS IN THIS MODULE. + */ +export declare const IO_ID_COLUMN = "exabyteId"; +export declare const UNIT_TYPES: { + convergence: string; + exit: string; + execution: string; + map: string; + reduce: string; + assignment: string; + condition: string; + subworkflow: string; + processing: string; + io: string; + assertion: string; +}; +export declare enum UnitType { + convergence = "convergence", + exit = "exit", + execution = "execution", + map = "map", + reduce = "reduce", + assignment = "assignment", + condition = "condition", + subworkflow = "subworkflow", + processing = "processing", + io = "io", + assertion = "assertion" +} +export declare const UNIT_STATUSES: { + idle: string; + active: string; + finished: string; + error: string; + warning: string; +}; +export declare const UNIT_TAGS: { + hasConvergenceParam: string; + hasConvergenceResult: string; +}; +export declare const WORKFLOW_STATUSES: { + "up-to-date": string; + outdated: string; +}; +export declare const TAB_NAVIGATION_CONFIG: { + overview: { + itemName: string; + className: string; + href: string; + }; + importantSettings: { + itemName: string; + className: string; + href: string; + }; + detailedView: { + itemName: string; + className: string; + href: string; + }; + compute: { + itemName: string; + className: string; + href: string; + }; +}; +export declare const UNIT_NAME_INVALID_CHARS = "/"; diff --git a/dist/js/enums.js b/dist/js/enums.js index 8d50a8fd..1e91c562 100644 --- a/dist/js/enums.js +++ b/dist/js/enums.js @@ -1,65 +1,75 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.WORKFLOW_STATUSES = exports.UNIT_TYPES = exports.UNIT_TAGS = exports.UNIT_STATUSES = exports.UNIT_NAME_INVALID_CHARS = exports.TAB_NAVIGATION_CONFIG = exports.IO_ID_COLUMN = void 0; /** * THIS ENUMS ARE SHARED WITH TESTS. * DO NOT IMPORT ANYTHINGS IN THIS MODULE. */ - -const IO_ID_COLUMN = exports.IO_ID_COLUMN = "exabyteId"; -const UNIT_TYPES = exports.UNIT_TYPES = { - // not currently used - convergence: "convergence", - exit: "exit", - // actively used - execution: "execution", - map: "map", - reduce: "reduce", - assignment: "assignment", - condition: "condition", - subworkflow: "subworkflow", - processing: "processing", - io: "io", - assertion: "assertion" +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UNIT_NAME_INVALID_CHARS = exports.TAB_NAVIGATION_CONFIG = exports.WORKFLOW_STATUSES = exports.UNIT_TAGS = exports.UNIT_STATUSES = exports.UnitType = exports.UNIT_TYPES = exports.IO_ID_COLUMN = void 0; +exports.IO_ID_COLUMN = "exabyteId"; +exports.UNIT_TYPES = { + // not currently used + convergence: "convergence", + exit: "exit", + // actively used + execution: "execution", + map: "map", + reduce: "reduce", + assignment: "assignment", + condition: "condition", + subworkflow: "subworkflow", + processing: "processing", + io: "io", + assertion: "assertion", }; -const UNIT_STATUSES = exports.UNIT_STATUSES = { - idle: "idle", - active: "active", - finished: "finished", - error: "error", - warning: "warning" +var UnitType; +(function (UnitType) { + UnitType["convergence"] = "convergence"; + UnitType["exit"] = "exit"; + UnitType["execution"] = "execution"; + UnitType["map"] = "map"; + UnitType["reduce"] = "reduce"; + UnitType["assignment"] = "assignment"; + UnitType["condition"] = "condition"; + UnitType["subworkflow"] = "subworkflow"; + UnitType["processing"] = "processing"; + UnitType["io"] = "io"; + UnitType["assertion"] = "assertion"; +})(UnitType || (exports.UnitType = UnitType = {})); +exports.UNIT_STATUSES = { + idle: "idle", + active: "active", + finished: "finished", + error: "error", + warning: "warning", }; -const UNIT_TAGS = exports.UNIT_TAGS = { - hasConvergenceParam: "hasConvergenceParam", - hasConvergenceResult: "hasConvergenceResult" +exports.UNIT_TAGS = { + hasConvergenceParam: "hasConvergenceParam", + hasConvergenceResult: "hasConvergenceResult", }; -const WORKFLOW_STATUSES = exports.WORKFLOW_STATUSES = { - "up-to-date": "up-to-date", - outdated: "outdated" +exports.WORKFLOW_STATUSES = { + "up-to-date": "up-to-date", + outdated: "outdated", }; -const TAB_NAVIGATION_CONFIG = exports.TAB_NAVIGATION_CONFIG = { - overview: { - itemName: "Overview", - className: "", - href: "sw-overview" - }, - importantSettings: { - itemName: "Important settings", - className: "", - href: "sw-important-settings" - }, - detailedView: { - itemName: "Detailed view", - className: "", - href: "sw-detailed-view" - }, - compute: { - itemName: "Compute", - className: "", - href: "sw-compute" - } +exports.TAB_NAVIGATION_CONFIG = { + overview: { + itemName: "Overview", + className: "", + href: "sw-overview", + }, + importantSettings: { + itemName: "Important settings", + className: "", + href: "sw-important-settings", + }, + detailedView: { + itemName: "Detailed view", + className: "", + href: "sw-detailed-view", + }, + compute: { + itemName: "Compute", + className: "", + href: "sw-compute", + }, }; -const UNIT_NAME_INVALID_CHARS = exports.UNIT_NAME_INVALID_CHARS = "/"; \ No newline at end of file +exports.UNIT_NAME_INVALID_CHARS = "/"; diff --git a/dist/js/generated/AssertionUnitSchemaMixin.d.ts b/dist/js/generated/AssertionUnitSchemaMixin.d.ts new file mode 100644 index 00000000..156548b2 --- /dev/null +++ b/dist/js/generated/AssertionUnitSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { AssertionUnitMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type AssertionUnitSchemaMixin = AssertionUnitMixinSchema; +export type AssertionUnitInMemoryEntity = InMemoryEntity & AssertionUnitSchemaMixin; +export declare function assertionUnitSchemaMixin(item: InMemoryEntity): asserts item is T & AssertionUnitSchemaMixin; diff --git a/dist/js/generated/AssertionUnitSchemaMixin.js b/dist/js/generated/AssertionUnitSchemaMixin.js new file mode 100644 index 00000000..352ed128 --- /dev/null +++ b/dist/js/generated/AssertionUnitSchemaMixin.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.assertionUnitSchemaMixin = assertionUnitSchemaMixin; +function assertionUnitSchemaMixin(item) { + // @ts-expect-error + const properties = { + get type() { + return this.prop("type"); + }, + set type(value) { + this.setProp("type", value); + }, + get statement() { + return this.requiredProp("statement"); + }, + set statement(value) { + this.setProp("statement", value); + }, + get errorMessage() { + return this.prop("errorMessage"); + }, + set errorMessage(value) { + this.setProp("errorMessage", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/AssignmentUnitSchemaMixin.d.ts b/dist/js/generated/AssignmentUnitSchemaMixin.d.ts new file mode 100644 index 00000000..fecbc975 --- /dev/null +++ b/dist/js/generated/AssignmentUnitSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { AssignmentUnitMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type AssignmentUnitSchemaMixin = AssignmentUnitMixinSchema; +export type AssignmentUnitInMemoryEntity = InMemoryEntity & AssignmentUnitSchemaMixin; +export declare function assignmentUnitSchemaMixin(item: InMemoryEntity): asserts item is T & AssignmentUnitSchemaMixin; diff --git a/dist/js/generated/AssignmentUnitSchemaMixin.js b/dist/js/generated/AssignmentUnitSchemaMixin.js new file mode 100644 index 00000000..6c134292 --- /dev/null +++ b/dist/js/generated/AssignmentUnitSchemaMixin.js @@ -0,0 +1,33 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.assignmentUnitSchemaMixin = assignmentUnitSchemaMixin; +function assignmentUnitSchemaMixin(item) { + // @ts-expect-error + const properties = { + get type() { + return this.prop("type"); + }, + set type(value) { + this.setProp("type", value); + }, + get input() { + return this.prop("input"); + }, + set input(value) { + this.setProp("input", value); + }, + get operand() { + return this.requiredProp("operand"); + }, + set operand(value) { + this.setProp("operand", value); + }, + get value() { + return this.requiredProp("value"); + }, + set value(value) { + this.setProp("value", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/BaseUnitSchemaMixin.d.ts b/dist/js/generated/BaseUnitSchemaMixin.d.ts new file mode 100644 index 00000000..5f3469e4 --- /dev/null +++ b/dist/js/generated/BaseUnitSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { WorkflowBaseUnitMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type BaseUnitSchemaMixin = WorkflowBaseUnitMixinSchema; +export type BaseUnitInMemoryEntity = InMemoryEntity & BaseUnitSchemaMixin; +export declare function baseUnitSchemaMixin(item: InMemoryEntity): asserts item is T & BaseUnitSchemaMixin; diff --git a/dist/js/generated/BaseUnitSchemaMixin.js b/dist/js/generated/BaseUnitSchemaMixin.js new file mode 100644 index 00000000..40054c71 --- /dev/null +++ b/dist/js/generated/BaseUnitSchemaMixin.js @@ -0,0 +1,57 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.baseUnitSchemaMixin = baseUnitSchemaMixin; +function baseUnitSchemaMixin(item) { + // @ts-expect-error + const properties = { + get isDraft() { + return this.prop("isDraft"); + }, + set isDraft(value) { + this.setProp("isDraft", value); + }, + get type() { + return this.requiredProp("type"); + }, + set type(value) { + this.setProp("type", value); + }, + get name() { + return this.prop("name"); + }, + set name(value) { + this.setProp("name", value); + }, + get status() { + return this.prop("status"); + }, + set status(value) { + this.setProp("status", value); + }, + get head() { + return this.prop("head"); + }, + set head(value) { + this.setProp("head", value); + }, + get flowchartId() { + return this.requiredProp("flowchartId"); + }, + set flowchartId(value) { + this.setProp("flowchartId", value); + }, + get next() { + return this.prop("next"); + }, + set next(value) { + this.setProp("next", value); + }, + get enableRender() { + return this.prop("enableRender"); + }, + set enableRender(value) { + this.setProp("enableRender", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/ConditionUnitSchemaMixin.d.ts b/dist/js/generated/ConditionUnitSchemaMixin.d.ts new file mode 100644 index 00000000..6f655292 --- /dev/null +++ b/dist/js/generated/ConditionUnitSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { ConditionUnitMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type ConditionUnitSchemaMixin = ConditionUnitMixinSchema; +export type ConditionUnitInMemoryEntity = InMemoryEntity & ConditionUnitSchemaMixin; +export declare function conditionUnitSchemaMixin(item: InMemoryEntity): asserts item is T & ConditionUnitSchemaMixin; diff --git a/dist/js/generated/ConditionUnitSchemaMixin.js b/dist/js/generated/ConditionUnitSchemaMixin.js new file mode 100644 index 00000000..692ff5b6 --- /dev/null +++ b/dist/js/generated/ConditionUnitSchemaMixin.js @@ -0,0 +1,51 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.conditionUnitSchemaMixin = conditionUnitSchemaMixin; +function conditionUnitSchemaMixin(item) { + // @ts-expect-error + const properties = { + get type() { + return this.prop("type"); + }, + set type(value) { + this.setProp("type", value); + }, + get input() { + return this.requiredProp("input"); + }, + set input(value) { + this.setProp("input", value); + }, + get statement() { + return this.requiredProp("statement"); + }, + set statement(value) { + this.setProp("statement", value); + }, + get then() { + return this.requiredProp("then"); + }, + set then(value) { + this.setProp("then", value); + }, + get else() { + return this.requiredProp("else"); + }, + set else(value) { + this.setProp("else", value); + }, + get maxOccurrences() { + return this.requiredProp("maxOccurrences"); + }, + set maxOccurrences(value) { + this.setProp("maxOccurrences", value); + }, + get throwException() { + return this.prop("throwException"); + }, + set throwException(value) { + this.setProp("throwException", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/ExecutionUnitInputSchemaMixin.d.ts b/dist/js/generated/ExecutionUnitInputSchemaMixin.d.ts new file mode 100644 index 00000000..bedea4c8 --- /dev/null +++ b/dist/js/generated/ExecutionUnitInputSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { ExecutionUnitInputItemSchema } from "@mat3ra/esse/dist/js/types"; +export type ExecutionUnitInputSchemaMixin = ExecutionUnitInputItemSchema; +export type ExecutionUnitInputInMemoryEntity = InMemoryEntity & ExecutionUnitInputSchemaMixin; +export declare function executionUnitInputSchemaMixin(item: InMemoryEntity): asserts item is T & ExecutionUnitInputSchemaMixin; diff --git a/dist/js/generated/ExecutionUnitInputSchemaMixin.js b/dist/js/generated/ExecutionUnitInputSchemaMixin.js new file mode 100644 index 00000000..65eb6c96 --- /dev/null +++ b/dist/js/generated/ExecutionUnitInputSchemaMixin.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.executionUnitInputSchemaMixin = executionUnitInputSchemaMixin; +function executionUnitInputSchemaMixin(item) { + // @ts-expect-error + const properties = { + get template() { + return this.requiredProp("template"); + }, + set template(value) { + this.setProp("template", value); + }, + get rendered() { + return this.requiredProp("rendered"); + }, + set rendered(value) { + this.setProp("rendered", value); + }, + get isManuallyChanged() { + return this.requiredProp("isManuallyChanged"); + }, + set isManuallyChanged(value) { + this.setProp("isManuallyChanged", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/ExecutionUnitSchemaMixin.d.ts b/dist/js/generated/ExecutionUnitSchemaMixin.d.ts new file mode 100644 index 00000000..273866f7 --- /dev/null +++ b/dist/js/generated/ExecutionUnitSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { ExecutionUnitMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type ExecutionUnitSchemaMixin = ExecutionUnitMixinSchema; +export type ExecutionUnitInMemoryEntity = InMemoryEntity & ExecutionUnitSchemaMixin; +export declare function executionUnitSchemaMixin(item: InMemoryEntity): asserts item is T & ExecutionUnitSchemaMixin; diff --git a/dist/js/generated/ExecutionUnitSchemaMixin.js b/dist/js/generated/ExecutionUnitSchemaMixin.js new file mode 100644 index 00000000..89de9ce7 --- /dev/null +++ b/dist/js/generated/ExecutionUnitSchemaMixin.js @@ -0,0 +1,45 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.executionUnitSchemaMixin = executionUnitSchemaMixin; +function executionUnitSchemaMixin(item) { + // @ts-expect-error + const properties = { + get type() { + return this.prop("type"); + }, + set type(value) { + this.setProp("type", value); + }, + get application() { + return this.requiredProp("application"); + }, + set application(value) { + this.setProp("application", value); + }, + get executable() { + return this.prop("executable"); + }, + set executable(value) { + this.setProp("executable", value); + }, + get flavor() { + return this.prop("flavor"); + }, + set flavor(value) { + this.setProp("flavor", value); + }, + get input() { + return this.requiredProp("input"); + }, + set input(value) { + this.setProp("input", value); + }, + get context() { + return this.prop("context"); + }, + set context(value) { + this.setProp("context", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/IOUnitSchemaMixin.d.ts b/dist/js/generated/IOUnitSchemaMixin.d.ts new file mode 100644 index 00000000..2e02f8d8 --- /dev/null +++ b/dist/js/generated/IOUnitSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { DataIOUnitMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type IOUnitSchemaMixin = DataIOUnitMixinSchema; +export type IOUnitInMemoryEntity = InMemoryEntity & IOUnitSchemaMixin; +export declare function iOUnitSchemaMixin(item: InMemoryEntity): asserts item is T & IOUnitSchemaMixin; diff --git a/dist/js/generated/IOUnitSchemaMixin.js b/dist/js/generated/IOUnitSchemaMixin.js new file mode 100644 index 00000000..3443130d --- /dev/null +++ b/dist/js/generated/IOUnitSchemaMixin.js @@ -0,0 +1,33 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.iOUnitSchemaMixin = iOUnitSchemaMixin; +function iOUnitSchemaMixin(item) { + // @ts-expect-error + const properties = { + get type() { + return this.prop("type"); + }, + set type(value) { + this.setProp("type", value); + }, + get subtype() { + return this.requiredProp("subtype"); + }, + set subtype(value) { + this.setProp("subtype", value); + }, + get source() { + return this.requiredProp("source"); + }, + set source(value) { + this.setProp("source", value); + }, + get input() { + return this.requiredProp("input"); + }, + set input(value) { + this.setProp("input", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/MapUnitSchemaMixin.d.ts b/dist/js/generated/MapUnitSchemaMixin.d.ts new file mode 100644 index 00000000..1146f7a8 --- /dev/null +++ b/dist/js/generated/MapUnitSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { MapUnitMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type MapUnitSchemaMixin = MapUnitMixinSchema; +export type MapUnitInMemoryEntity = InMemoryEntity & MapUnitSchemaMixin; +export declare function mapUnitSchemaMixin(item: InMemoryEntity): asserts item is T & MapUnitSchemaMixin; diff --git a/dist/js/generated/MapUnitSchemaMixin.js b/dist/js/generated/MapUnitSchemaMixin.js new file mode 100644 index 00000000..8d35acf0 --- /dev/null +++ b/dist/js/generated/MapUnitSchemaMixin.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.mapUnitSchemaMixin = mapUnitSchemaMixin; +function mapUnitSchemaMixin(item) { + // @ts-expect-error + const properties = { + get type() { + return this.prop("type"); + }, + set type(value) { + this.setProp("type", value); + }, + get workflowId() { + return this.requiredProp("workflowId"); + }, + set workflowId(value) { + this.setProp("workflowId", value); + }, + get input() { + return this.requiredProp("input"); + }, + set input(value) { + this.setProp("input", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/ProcessingUnitSchemaMixin.d.ts b/dist/js/generated/ProcessingUnitSchemaMixin.d.ts new file mode 100644 index 00000000..eb59cea2 --- /dev/null +++ b/dist/js/generated/ProcessingUnitSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { ProcessingUnitMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type ProcessingUnitSchemaMixin = ProcessingUnitMixinSchema; +export type ProcessingUnitInMemoryEntity = InMemoryEntity & ProcessingUnitSchemaMixin; +export declare function processingUnitSchemaMixin(item: InMemoryEntity): asserts item is T & ProcessingUnitSchemaMixin; diff --git a/dist/js/generated/ProcessingUnitSchemaMixin.js b/dist/js/generated/ProcessingUnitSchemaMixin.js new file mode 100644 index 00000000..1d556e93 --- /dev/null +++ b/dist/js/generated/ProcessingUnitSchemaMixin.js @@ -0,0 +1,33 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.processingUnitSchemaMixin = processingUnitSchemaMixin; +function processingUnitSchemaMixin(item) { + // @ts-expect-error + const properties = { + get type() { + return this.prop("type"); + }, + set type(value) { + this.setProp("type", value); + }, + get operation() { + return this.requiredProp("operation"); + }, + set operation(value) { + this.setProp("operation", value); + }, + get operationType() { + return this.requiredProp("operationType"); + }, + set operationType(value) { + this.setProp("operationType", value); + }, + get inputData() { + return this.requiredProp("inputData"); + }, + set inputData(value) { + this.setProp("inputData", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/ReduceUnitSchemaMixin.d.ts b/dist/js/generated/ReduceUnitSchemaMixin.d.ts new file mode 100644 index 00000000..4dd96df4 --- /dev/null +++ b/dist/js/generated/ReduceUnitSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { ReduceUnitMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type ReduceUnitSchemaMixin = ReduceUnitMixinSchema; +export type ReduceUnitInMemoryEntity = InMemoryEntity & ReduceUnitSchemaMixin; +export declare function reduceUnitSchemaMixin(item: InMemoryEntity): asserts item is T & ReduceUnitSchemaMixin; diff --git a/dist/js/generated/ReduceUnitSchemaMixin.js b/dist/js/generated/ReduceUnitSchemaMixin.js new file mode 100644 index 00000000..06528dd0 --- /dev/null +++ b/dist/js/generated/ReduceUnitSchemaMixin.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.reduceUnitSchemaMixin = reduceUnitSchemaMixin; +function reduceUnitSchemaMixin(item) { + // @ts-expect-error + const properties = { + get type() { + return this.prop("type"); + }, + set type(value) { + this.setProp("type", value); + }, + get mapFlowchartId() { + return this.requiredProp("mapFlowchartId"); + }, + set mapFlowchartId(value) { + this.setProp("mapFlowchartId", value); + }, + get input() { + return this.requiredProp("input"); + }, + set input(value) { + this.setProp("input", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/StatusSchemaMixin.d.ts b/dist/js/generated/StatusSchemaMixin.d.ts new file mode 100644 index 00000000..2cd3b44c --- /dev/null +++ b/dist/js/generated/StatusSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { StatusSchema } from "@mat3ra/esse/dist/js/types"; +export type StatusSchemaMixin = StatusSchema; +export type StatusInMemoryEntity = InMemoryEntity & StatusSchemaMixin; +export declare function statusSchemaMixin(item: InMemoryEntity): asserts item is T & StatusSchemaMixin; diff --git a/dist/js/generated/StatusSchemaMixin.js b/dist/js/generated/StatusSchemaMixin.js new file mode 100644 index 00000000..86fcb4c3 --- /dev/null +++ b/dist/js/generated/StatusSchemaMixin.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.statusSchemaMixin = statusSchemaMixin; +function statusSchemaMixin(item) { + // @ts-expect-error + const properties = { + get status() { + return this.prop("status"); + }, + set status(value) { + this.setProp("status", value); + }, + get statusTrack() { + return this.prop("statusTrack"); + }, + set statusTrack(value) { + this.setProp("statusTrack", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/SubworkflowSchemaMixin.d.ts b/dist/js/generated/SubworkflowSchemaMixin.d.ts new file mode 100644 index 00000000..46349216 --- /dev/null +++ b/dist/js/generated/SubworkflowSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { SubworkflowMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type SubworkflowSchemaMixin = SubworkflowMixinSchema; +export type SubworkflowInMemoryEntity = InMemoryEntity & SubworkflowSchemaMixin; +export declare function subworkflowSchemaMixin(item: InMemoryEntity): asserts item is T & SubworkflowSchemaMixin; diff --git a/dist/js/generated/SubworkflowSchemaMixin.js b/dist/js/generated/SubworkflowSchemaMixin.js new file mode 100644 index 00000000..859e8d5f --- /dev/null +++ b/dist/js/generated/SubworkflowSchemaMixin.js @@ -0,0 +1,45 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.subworkflowSchemaMixin = subworkflowSchemaMixin; +function subworkflowSchemaMixin(item) { + // @ts-expect-error + const properties = { + get properties() { + return this.prop("properties"); + }, + set properties(value) { + this.setProp("properties", value); + }, + get compute() { + return this.prop("compute"); + }, + set compute(value) { + this.setProp("compute", value); + }, + get units() { + return this.requiredProp("units"); + }, + set units(value) { + this.setProp("units", value); + }, + get model() { + return this.requiredProp("model"); + }, + set model(value) { + this.setProp("model", value); + }, + get application() { + return this.requiredProp("application"); + }, + set application(value) { + this.setProp("application", value); + }, + get isDraft() { + return this.prop("isDraft"); + }, + set isDraft(value) { + this.setProp("isDraft", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/generated/SubworkflowUnitSchemaMixin.d.ts b/dist/js/generated/SubworkflowUnitSchemaMixin.d.ts new file mode 100644 index 00000000..fdca84fe --- /dev/null +++ b/dist/js/generated/SubworkflowUnitSchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { SubworkflowUnitMixinSchema } from "@mat3ra/esse/dist/js/types"; +export type SubworkflowUnitSchemaMixin = SubworkflowUnitMixinSchema; +export type SubworkflowUnitInMemoryEntity = InMemoryEntity & SubworkflowUnitSchemaMixin; +export declare function subworkflowUnitSchemaMixin(item: InMemoryEntity): asserts item is T & SubworkflowUnitSchemaMixin; diff --git a/dist/js/generated/SubworkflowUnitSchemaMixin.js b/dist/js/generated/SubworkflowUnitSchemaMixin.js new file mode 100644 index 00000000..3d7a8183 --- /dev/null +++ b/dist/js/generated/SubworkflowUnitSchemaMixin.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.subworkflowUnitSchemaMixin = subworkflowUnitSchemaMixin; +function subworkflowUnitSchemaMixin(item) { + // @ts-expect-error + const properties = { + get type() { + return this.prop("type"); + }, + set type(value) { + this.setProp("type", value); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/index.d.ts b/dist/js/index.d.ts new file mode 100644 index 00000000..e228fc47 --- /dev/null +++ b/dist/js/index.d.ts @@ -0,0 +1,26 @@ +import { Subworkflow } from "./subworkflows"; +import { Workflow } from "./workflows"; +import { createWorkflow } from "./workflows"; +import { createWorkflows } from "./workflows"; +import { createWorkflowConfigs } from "./workflows"; +import { createSubworkflowByName } from "./subworkflows"; +import { UnitFactory } from "./units/factory"; +import { builders } from "./units/builders"; +import { UNIT_TYPES } from "./enums"; +import { UNIT_STATUSES } from "./enums"; +import { TAB_NAVIGATION_CONFIG } from "./enums"; +import { UNIT_NAME_INVALID_CHARS } from "./enums"; +import { WORKFLOW_STATUSES } from "./enums"; +import { BaseUnit } from "./units"; +import { ExecutionUnit } from "./units"; +import { AssertionUnit } from "./units"; +import { AssignmentUnit } from "./units"; +import { ConditionUnit } from "./units"; +import { IOUnit } from "./units"; +import { MapUnit } from "./units"; +import { ProcessingUnit } from "./units"; +import { ReduceUnit } from "./units"; +import { SubworkflowUnit } from "./units"; +import { defaultMapConfig } from "./units/MapUnit"; +import { globalSettings } from "./context/providers/settings"; +export { Subworkflow, Workflow, createWorkflow, createWorkflows, createWorkflowConfigs, createSubworkflowByName, UnitFactory, builders, UNIT_TYPES, UNIT_STATUSES, TAB_NAVIGATION_CONFIG, UNIT_NAME_INVALID_CHARS, WORKFLOW_STATUSES, BaseUnit, ExecutionUnit, AssertionUnit, AssignmentUnit, ConditionUnit, IOUnit, MapUnit, ProcessingUnit, ReduceUnit, SubworkflowUnit, defaultMapConfig, wodeProviders, PointsPathFormDataProvider, globalSettings }; diff --git a/dist/js/index.js b/dist/js/index.js index 6afac8c3..466e746a 100644 --- a/dist/js/index.js +++ b/dist/js/index.js @@ -1,177 +1,40 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "AssertionUnit", { - enumerable: true, - get: function () { - return _units.AssertionUnit; - } -}); -Object.defineProperty(exports, "AssignmentUnit", { - enumerable: true, - get: function () { - return _units.AssignmentUnit; - } -}); -Object.defineProperty(exports, "BaseUnit", { - enumerable: true, - get: function () { - return _units.BaseUnit; - } -}); -Object.defineProperty(exports, "ConditionUnit", { - enumerable: true, - get: function () { - return _units.ConditionUnit; - } -}); -Object.defineProperty(exports, "ExecutionUnit", { - enumerable: true, - get: function () { - return _units.ExecutionUnit; - } -}); -Object.defineProperty(exports, "IOUnit", { - enumerable: true, - get: function () { - return _units.IOUnit; - } -}); -Object.defineProperty(exports, "MapUnit", { - enumerable: true, - get: function () { - return _units.MapUnit; - } -}); -Object.defineProperty(exports, "PointsPathFormDataProvider", { - enumerable: true, - get: function () { - return _PointsPathFormDataProvider.PointsPathFormDataProvider; - } -}); -Object.defineProperty(exports, "ProcessingUnit", { - enumerable: true, - get: function () { - return _units.ProcessingUnit; - } -}); -Object.defineProperty(exports, "ReduceUnit", { - enumerable: true, - get: function () { - return _units.ReduceUnit; - } -}); -Object.defineProperty(exports, "Subworkflow", { - enumerable: true, - get: function () { - return _subworkflows.Subworkflow; - } -}); -Object.defineProperty(exports, "SubworkflowUnit", { - enumerable: true, - get: function () { - return _units.SubworkflowUnit; - } -}); -Object.defineProperty(exports, "TAB_NAVIGATION_CONFIG", { - enumerable: true, - get: function () { - return _enums.TAB_NAVIGATION_CONFIG; - } -}); -Object.defineProperty(exports, "UNIT_NAME_INVALID_CHARS", { - enumerable: true, - get: function () { - return _enums.UNIT_NAME_INVALID_CHARS; - } -}); -Object.defineProperty(exports, "UNIT_STATUSES", { - enumerable: true, - get: function () { - return _enums.UNIT_STATUSES; - } -}); -Object.defineProperty(exports, "UNIT_TYPES", { - enumerable: true, - get: function () { - return _enums.UNIT_TYPES; - } -}); -Object.defineProperty(exports, "UnitFactory", { - enumerable: true, - get: function () { - return _factory.UnitFactory; - } -}); -Object.defineProperty(exports, "WORKFLOW_STATUSES", { - enumerable: true, - get: function () { - return _enums.WORKFLOW_STATUSES; - } -}); -Object.defineProperty(exports, "Workflow", { - enumerable: true, - get: function () { - return _workflows.Workflow; - } -}); -Object.defineProperty(exports, "builders", { - enumerable: true, - get: function () { - return _builders.builders; - } -}); -Object.defineProperty(exports, "createSubworkflowByName", { - enumerable: true, - get: function () { - return _subworkflows.createSubworkflowByName; - } -}); -Object.defineProperty(exports, "createWorkflow", { - enumerable: true, - get: function () { - return _workflows.createWorkflow; - } -}); -Object.defineProperty(exports, "createWorkflowConfigs", { - enumerable: true, - get: function () { - return _workflows.createWorkflowConfigs; - } -}); -Object.defineProperty(exports, "createWorkflows", { - enumerable: true, - get: function () { - return _workflows.createWorkflows; - } -}); -Object.defineProperty(exports, "defaultMapConfig", { - enumerable: true, - get: function () { - return _map.defaultMapConfig; - } -}); -Object.defineProperty(exports, "globalSettings", { - enumerable: true, - get: function () { - return _settings.globalSettings; - } -}); -Object.defineProperty(exports, "wodeProviders", { - enumerable: true, - get: function () { - return _providers.wodeProviders; - } -}); -var _providers = require("./context/providers"); -var _PointsPathFormDataProvider = require("./context/providers/PointsPathFormDataProvider"); -var _settings = require("./context/providers/settings"); -var _enums = require("./enums"); -var _subworkflows = require("./subworkflows"); -var _units = require("./units"); -var _builders = require("./units/builders"); -var _factory = require("./units/factory"); -var _map = require("./units/map"); -var _workflows = require("./workflows"); \ No newline at end of file +Object.defineProperty(exports, "__esModule", { value: true }); +exports.globalSettings = exports.PointsPathFormDataProvider = exports.wodeProviders = exports.defaultMapConfig = exports.SubworkflowUnit = exports.ReduceUnit = exports.ProcessingUnit = exports.MapUnit = exports.IOUnit = exports.ConditionUnit = exports.AssignmentUnit = exports.AssertionUnit = exports.ExecutionUnit = exports.BaseUnit = exports.WORKFLOW_STATUSES = exports.UNIT_NAME_INVALID_CHARS = exports.TAB_NAVIGATION_CONFIG = exports.UNIT_STATUSES = exports.UNIT_TYPES = exports.builders = exports.UnitFactory = exports.createSubworkflowByName = exports.createWorkflowConfigs = exports.createWorkflows = exports.createWorkflow = exports.Workflow = exports.Subworkflow = void 0; +const providers_1 = require("./context/providers"); +Object.defineProperty(exports, "wodeProviders", { enumerable: true, get: function () { return providers_1.wodeProviders; } }); +const PointsPathFormDataProvider_1 = require("./context/providers/PointsPath/PointsPathFormDataProvider"); +Object.defineProperty(exports, "PointsPathFormDataProvider", { enumerable: true, get: function () { return PointsPathFormDataProvider_1.PointsPathFormDataProvider; } }); +const settings_1 = require("./context/providers/settings"); +Object.defineProperty(exports, "globalSettings", { enumerable: true, get: function () { return settings_1.globalSettings; } }); +const enums_1 = require("./enums"); +Object.defineProperty(exports, "TAB_NAVIGATION_CONFIG", { enumerable: true, get: function () { return enums_1.TAB_NAVIGATION_CONFIG; } }); +Object.defineProperty(exports, "UNIT_NAME_INVALID_CHARS", { enumerable: true, get: function () { return enums_1.UNIT_NAME_INVALID_CHARS; } }); +Object.defineProperty(exports, "UNIT_STATUSES", { enumerable: true, get: function () { return enums_1.UNIT_STATUSES; } }); +Object.defineProperty(exports, "UNIT_TYPES", { enumerable: true, get: function () { return enums_1.UNIT_TYPES; } }); +Object.defineProperty(exports, "WORKFLOW_STATUSES", { enumerable: true, get: function () { return enums_1.WORKFLOW_STATUSES; } }); +const subworkflows_1 = require("./subworkflows"); +Object.defineProperty(exports, "createSubworkflowByName", { enumerable: true, get: function () { return subworkflows_1.createSubworkflowByName; } }); +Object.defineProperty(exports, "Subworkflow", { enumerable: true, get: function () { return subworkflows_1.Subworkflow; } }); +const units_1 = require("./units"); +Object.defineProperty(exports, "AssertionUnit", { enumerable: true, get: function () { return units_1.AssertionUnit; } }); +Object.defineProperty(exports, "AssignmentUnit", { enumerable: true, get: function () { return units_1.AssignmentUnit; } }); +Object.defineProperty(exports, "BaseUnit", { enumerable: true, get: function () { return units_1.BaseUnit; } }); +Object.defineProperty(exports, "ConditionUnit", { enumerable: true, get: function () { return units_1.ConditionUnit; } }); +Object.defineProperty(exports, "ExecutionUnit", { enumerable: true, get: function () { return units_1.ExecutionUnit; } }); +Object.defineProperty(exports, "IOUnit", { enumerable: true, get: function () { return units_1.IOUnit; } }); +Object.defineProperty(exports, "MapUnit", { enumerable: true, get: function () { return units_1.MapUnit; } }); +Object.defineProperty(exports, "ProcessingUnit", { enumerable: true, get: function () { return units_1.ProcessingUnit; } }); +Object.defineProperty(exports, "ReduceUnit", { enumerable: true, get: function () { return units_1.ReduceUnit; } }); +Object.defineProperty(exports, "SubworkflowUnit", { enumerable: true, get: function () { return units_1.SubworkflowUnit; } }); +const builders_1 = require("./units/builders"); +Object.defineProperty(exports, "builders", { enumerable: true, get: function () { return builders_1.builders; } }); +const factory_1 = require("./units/factory"); +Object.defineProperty(exports, "UnitFactory", { enumerable: true, get: function () { return factory_1.UnitFactory; } }); +const MapUnit_1 = require("./units/MapUnit"); +Object.defineProperty(exports, "defaultMapConfig", { enumerable: true, get: function () { return MapUnit_1.defaultMapConfig; } }); +const workflows_1 = require("./workflows"); +Object.defineProperty(exports, "createWorkflow", { enumerable: true, get: function () { return workflows_1.createWorkflow; } }); +Object.defineProperty(exports, "createWorkflowConfigs", { enumerable: true, get: function () { return workflows_1.createWorkflowConfigs; } }); +Object.defineProperty(exports, "createWorkflows", { enumerable: true, get: function () { return workflows_1.createWorkflows; } }); +Object.defineProperty(exports, "Workflow", { enumerable: true, get: function () { return workflows_1.Workflow; } }); diff --git a/dist/js/patch.js b/dist/js/patch.js deleted file mode 100644 index 86e4029c..00000000 --- a/dist/js/patch.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "Template", { - enumerable: true, - get: function () { - return _ade.Template; - } -}); -var _ade = require("@mat3ra/ade"); -var _providers = require("./context/providers"); -// We patch the static providerRegistry here so that -// Template has all context providers available -// to it when creating workflows. It is then re-exported -// from WoDe for use downstream. - -_ade.Template.setContextProvidersConfig(_providers.wodeProviders); \ No newline at end of file diff --git a/dist/js/subworkflows/convergence.d.ts b/dist/js/subworkflows/convergence.d.ts new file mode 100644 index 00000000..fced1616 --- /dev/null +++ b/dist/js/subworkflows/convergence.d.ts @@ -0,0 +1,20 @@ +export function ConvergenceMixin(superclass: any): { + new (): { + [x: string]: any; + get convergenceParam(): any; + get convergenceResult(): any; + convergenceSeries(scopeTrack: any): any; + addConvergence({ parameter, parameterInitial, parameterIncrement, result, resultInitial, condition, operator, tolerance, maxOccurrences, }: { + parameter: any; + parameterInitial: any; + parameterIncrement: any; + result: any; + resultInitial: any; + condition: any; + operator: any; + tolerance: any; + maxOccurrences: any; + }): void; + }; + [x: string]: any; +}; diff --git a/dist/js/subworkflows/convergence.js b/dist/js/subworkflows/convergence.js index 8309cca4..bb1d109d 100644 --- a/dist/js/subworkflows/convergence.js +++ b/dist/js/subworkflows/convergence.js @@ -1,189 +1,173 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); exports.ConvergenceMixin = void 0; -var _merge = _interopRequireDefault(require("lodash/merge")); -var _enums = require("../enums"); -var _factory = require("./convergence/factory"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const ConvergenceMixin = superclass => class extends superclass { - get convergenceParam() { - return this.findUnitWithTag("hasConvergenceParam")?.operand || undefined; - } - get convergenceResult() { - return this.findUnitWithTag("hasConvergenceResult")?.operand || undefined; - } - convergenceSeries(scopeTrack) { - if (!this.hasConvergence || !scopeTrack?.length) return []; - let lastResult; - const series = scopeTrack.map((scopeItem, i) => ({ - x: i, - param: scopeItem.scope?.global[this.convergenceParam], - y: scopeItem.scope?.global[this.convergenceResult] - })).filter(({ - y - }) => { - const isNewResult = y !== undefined && y !== lastResult; - lastResult = y; - return isNewResult; - }); - return series.map((item, i) => { - return { - x: i + 1, - param: item.param, - y: item.y - }; - }); - } - addConvergence({ - parameter, - parameterInitial, - parameterIncrement, - result, - resultInitial, - condition, - operator, - tolerance, - maxOccurrences - }) { - // RF: added TODO comments for future improvements - - const { - units - } = this; - // Find unit to converge: should contain passed result in its results list - // TODO: make user to select unit for convergence explicitly - const unitForConvergence = units.find(x => x.resultNames.find(name => name === result)); - if (!unitForConvergence) { - // eslint-disable-next-line no-undef - sAlert.error(`Subworkflow does not contain unit with '${result}' as extracted property.`); - throw new Error("There is no result to converge"); +const merge_1 = __importDefault(require("lodash/merge")); +const enums_1 = require("../enums"); +const factory_1 = require("./convergence/factory"); +const ConvergenceMixin = (superclass) => class extends superclass { + get convergenceParam() { + var _a; + return ((_a = this.findUnitWithTag("hasConvergenceParam")) === null || _a === void 0 ? void 0 : _a.operand) || undefined; + } + get convergenceResult() { + var _a; + return ((_a = this.findUnitWithTag("hasConvergenceResult")) === null || _a === void 0 ? void 0 : _a.operand) || undefined; + } + convergenceSeries(scopeTrack) { + if (!this.hasConvergence || !(scopeTrack === null || scopeTrack === void 0 ? void 0 : scopeTrack.length)) + return []; + let lastResult; + const series = scopeTrack + .map((scopeItem, i) => { + var _a, _b; + return ({ + x: i, + param: (_a = scopeItem.scope) === null || _a === void 0 ? void 0 : _a.global[this.convergenceParam], + y: (_b = scopeItem.scope) === null || _b === void 0 ? void 0 : _b.global[this.convergenceResult], + }); + }) + .filter(({ y }) => { + const isNewResult = y !== undefined && y !== lastResult; + lastResult = y; + return isNewResult; + }); + return series.map((item, i) => { + return { + x: i + 1, + param: item.param, + y: item.y, + }; + }); } - - // initialize parameter - const param = (0, _factory.createConvergenceParameter)({ - name: parameter, - initialValue: parameterInitial, - increment: parameterIncrement - }); - - // Replace kgrid to be ready for convergence - // TODO: kgrid should be abstracted and selected by user - const providers = unitForConvergence.importantSettingsProviders; - const gridProvider = providers.find(p => p.name === "kgrid" || p.name === "qgrid"); - let mergedContext = param.unitContext; - if (gridProvider) { - mergedContext = (0, _merge.default)(gridProvider.yieldData(), param.unitContext); - gridProvider.setData(mergedContext); - gridProvider.setIsEdited(true); + addConvergence({ parameter, parameterInitial, parameterIncrement, result, resultInitial, condition, operator, tolerance, maxOccurrences, }) { + // RF: added TODO comments for future improvements + const { units } = this; + // Find unit to converge: should contain passed result in its results list + // TODO: make user to select unit for convergence explicitly + const unitForConvergence = units.find((x) => x.resultNames.find((name) => name === result)); + if (!unitForConvergence) { + // eslint-disable-next-line no-undef + sAlert.error(`Subworkflow does not contain unit with '${result}' as extracted property.`); + throw new Error("There is no result to converge"); + } + // initialize parameter + const param = (0, factory_1.createConvergenceParameter)({ + name: parameter, + initialValue: parameterInitial, + increment: parameterIncrement, + }); + // Replace kgrid to be ready for convergence + // TODO: kgrid should be abstracted and selected by user + const providers = unitForConvergence.importantSettingsProviders; + const gridProvider = providers.find((p) => p.name === "kgrid" || p.name === "qgrid"); + let mergedContext = param.unitContext; + if (gridProvider) { + mergedContext = (0, merge_1.default)(gridProvider.yieldData(), param.unitContext); + gridProvider.setData(mergedContext); + gridProvider.setIsEdited(true); + } + unitForConvergence.updateContext(mergedContext); + const prevResult = "prev_result"; + const iteration = "iteration"; + // Assignment with result's initial value + const prevResultInit = this._UnitFactory.create({ + name: "init result", + type: enums_1.UNIT_TYPES.assignment, + head: true, + operand: prevResult, + value: resultInitial, + }); + // Assignment with initial value of convergence parameter + const paramInit = this._UnitFactory.create({ + name: "init parameter", + type: enums_1.UNIT_TYPES.assignment, + operand: param.name, + value: param.initialValue, + tags: [enums_1.UNIT_TAGS.hasConvergenceParam], + }); + // Assignment with initial value of iteration counter + const iterInit = this._UnitFactory.create({ + name: "init counter", + type: enums_1.UNIT_TYPES.assignment, + operand: iteration, + value: 1, + }); + // Assignment for storing iteration result: extracts 'result' from convergence unit scope + const storePrevResult = this._UnitFactory.create({ + name: "store result", + type: enums_1.UNIT_TYPES.assignment, + input: [ + { + scope: unitForConvergence.flowchartId, + name: result, + }, + ], + operand: prevResult, + value: result, + }); + // Assignment for convergence param increase + const nextStep = this._UnitFactory.create({ + name: "update parameter", + type: enums_1.UNIT_TYPES.assignment, + input: param.useVariablesFromUnitContext(unitForConvergence.flowchartId), + operand: param.name, + value: param.increment, + next: unitForConvergence.flowchartId, + }); + // Final step of convergence + const exit = this._UnitFactory.create({ + type: enums_1.UNIT_TYPES.assignment, + name: "exit", + input: [], + operand: param.name, + value: param.finalValue, + }); + // Final step of convergence + const storeResult = this._UnitFactory.create({ + name: "update result", + type: enums_1.UNIT_TYPES.assignment, + input: [ + { + scope: unitForConvergence.flowchartId, + name: result, + }, + ], + operand: result, + value: result, + tags: [enums_1.UNIT_TAGS.hasConvergenceResult], + }); + // Assign next iteration value + const nextIter = this._UnitFactory.create({ + name: "update counter", + type: enums_1.UNIT_TYPES.assignment, + input: [], + operand: iteration, + value: `${iteration} + 1`, + }); + // Convergence condition unit + const conditionUnit = this._UnitFactory.create({ + name: "check convergence", + type: enums_1.UNIT_TYPES.condition, + statement: `${condition} ${operator} ${tolerance}`, + then: exit.flowchartId, + else: storePrevResult.flowchartId, + maxOccurrences, + next: storePrevResult.flowchartId, + }); + this.addUnit(paramInit, 0); + this.addUnit(prevResultInit, 1); + this.addUnit(iterInit, 2); + this.addUnit(storeResult); + this.addUnit(conditionUnit); + this.addUnit(storePrevResult); + this.addUnit(nextIter); + this.addUnit(nextStep); + this.addUnit(exit); + // `addUnit` adjusts the `next` field, hence the below. + nextStep.next = unitForConvergence.flowchartId; } - unitForConvergence.updateContext(mergedContext); - const prevResult = "prev_result"; - const iteration = "iteration"; - - // Assignment with result's initial value - const prevResultInit = this._UnitFactory.create({ - name: "init result", - type: _enums.UNIT_TYPES.assignment, - head: true, - operand: prevResult, - value: resultInitial - }); - - // Assignment with initial value of convergence parameter - const paramInit = this._UnitFactory.create({ - name: "init parameter", - type: _enums.UNIT_TYPES.assignment, - operand: param.name, - value: param.initialValue, - tags: [_enums.UNIT_TAGS.hasConvergenceParam] - }); - - // Assignment with initial value of iteration counter - const iterInit = this._UnitFactory.create({ - name: "init counter", - type: _enums.UNIT_TYPES.assignment, - operand: iteration, - value: 1 - }); - - // Assignment for storing iteration result: extracts 'result' from convergence unit scope - const storePrevResult = this._UnitFactory.create({ - name: "store result", - type: _enums.UNIT_TYPES.assignment, - input: [{ - scope: unitForConvergence.flowchartId, - name: result - }], - operand: prevResult, - value: result - }); - - // Assignment for convergence param increase - const nextStep = this._UnitFactory.create({ - name: "update parameter", - type: _enums.UNIT_TYPES.assignment, - input: param.useVariablesFromUnitContext(unitForConvergence.flowchartId), - operand: param.name, - value: param.increment, - next: unitForConvergence.flowchartId - }); - - // Final step of convergence - const exit = this._UnitFactory.create({ - type: _enums.UNIT_TYPES.assignment, - name: "exit", - input: [], - operand: param.name, - value: param.finalValue - }); - - // Final step of convergence - const storeResult = this._UnitFactory.create({ - name: "update result", - type: _enums.UNIT_TYPES.assignment, - input: [{ - scope: unitForConvergence.flowchartId, - name: result - }], - operand: result, - value: result, - tags: [_enums.UNIT_TAGS.hasConvergenceResult] - }); - - // Assign next iteration value - const nextIter = this._UnitFactory.create({ - name: "update counter", - type: _enums.UNIT_TYPES.assignment, - input: [], - operand: iteration, - value: `${iteration} + 1` - }); - - // Convergence condition unit - const conditionUnit = this._UnitFactory.create({ - name: "check convergence", - type: _enums.UNIT_TYPES.condition, - statement: `${condition} ${operator} ${tolerance}`, - then: exit.flowchartId, - else: storePrevResult.flowchartId, - maxOccurrences, - next: storePrevResult.flowchartId - }); - this.addUnit(paramInit, 0); - this.addUnit(prevResultInit, 1); - this.addUnit(iterInit, 2); - this.addUnit(storeResult); - this.addUnit(conditionUnit); - this.addUnit(storePrevResult); - this.addUnit(nextIter); - this.addUnit(nextStep); - this.addUnit(exit); - - // `addUnit` adjusts the `next` field, hence the below. - nextStep.next = unitForConvergence.flowchartId; - } }; -exports.ConvergenceMixin = ConvergenceMixin; \ No newline at end of file +exports.ConvergenceMixin = ConvergenceMixin; diff --git a/dist/js/subworkflows/convergence/factory.d.ts b/dist/js/subworkflows/convergence/factory.d.ts new file mode 100644 index 00000000..067badb5 --- /dev/null +++ b/dist/js/subworkflows/convergence/factory.d.ts @@ -0,0 +1,6 @@ +export function createConvergenceParameter({ name, initialValue, increment }: { + name: any; + initialValue: any; + increment: any; +}): ConvergenceParameter; +import { ConvergenceParameter } from "./parameter"; diff --git a/dist/js/subworkflows/convergence/factory.js b/dist/js/subworkflows/convergence/factory.js index c405ebfe..c016fd8f 100644 --- a/dist/js/subworkflows/convergence/factory.js +++ b/dist/js/subworkflows/convergence/factory.js @@ -1,35 +1,16 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.createConvergenceParameter = createConvergenceParameter; -var _non_uniform_kgrid = require("./non_uniform_kgrid"); -var _parameter = require("./parameter"); -var _uniform_kgrid = require("./uniform_kgrid"); -function createConvergenceParameter({ - name, - initialValue, - increment -}) { - switch (name) { - case "N_k": - return new _uniform_kgrid.UniformKGridConvergence({ - name, - initialValue, - increment - }); - case "N_k_nonuniform": - return new _non_uniform_kgrid.NonUniformKGridConvergence({ - name, - initialValue, - increment - }); - default: - return new _parameter.ConvergenceParameter({ - name, - initialValue, - increment - }); - } -} \ No newline at end of file +const non_uniform_kgrid_1 = require("./non_uniform_kgrid"); +const parameter_1 = require("./parameter"); +const uniform_kgrid_1 = require("./uniform_kgrid"); +function createConvergenceParameter({ name, initialValue, increment }) { + switch (name) { + case "N_k": + return new uniform_kgrid_1.UniformKGridConvergence({ name, initialValue, increment }); + case "N_k_nonuniform": + return new non_uniform_kgrid_1.NonUniformKGridConvergence({ name, initialValue, increment }); + default: + return new parameter_1.ConvergenceParameter({ name, initialValue, increment }); + } +} diff --git a/dist/js/subworkflows/convergence/non_uniform_kgrid.d.ts b/dist/js/subworkflows/convergence/non_uniform_kgrid.d.ts new file mode 100644 index 00000000..780802f3 --- /dev/null +++ b/dist/js/subworkflows/convergence/non_uniform_kgrid.d.ts @@ -0,0 +1,15 @@ +export class NonUniformKGridConvergence extends ConvergenceParameter { + get unitContext(): { + kgrid: { + dimensions: string[]; + shifts: number[]; + }; + isKgridEdited: boolean; + isUsingJinjaVariables: boolean; + }; + useVariablesFromUnitContext(flowchartId: any): { + scope: any; + name: string; + }[]; +} +import { ConvergenceParameter } from "./parameter"; diff --git a/dist/js/subworkflows/convergence/non_uniform_kgrid.js b/dist/js/subworkflows/convergence/non_uniform_kgrid.js index 2daf659d..680a963f 100644 --- a/dist/js/subworkflows/convergence/non_uniform_kgrid.js +++ b/dist/js/subworkflows/convergence/non_uniform_kgrid.js @@ -1,31 +1,29 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.NonUniformKGridConvergence = void 0; -var _parameter = require("./parameter"); -class NonUniformKGridConvergence extends _parameter.ConvergenceParameter { - get increment() { - return `[${this.initialValue}[i] + math.floor(iteration * ${this._increment} * float(context['kgrid']['reciprocalVectorRatios'][i])) for i in range(3)]`; - } - get unitContext() { - return { - kgrid: { - dimensions: [`{{${this.name}[0]}}`, `{{${this.name}[1]}}`, `{{${this.name}[2]}}`], - shifts: [0, 0, 0] - }, - isKgridEdited: true, - isUsingJinjaVariables: true - }; - } - - // eslint-disable-next-line class-methods-use-this - useVariablesFromUnitContext(flowchartId) { - return [{ - scope: flowchartId, - name: "context" - }]; - } +const parameter_1 = require("./parameter"); +class NonUniformKGridConvergence extends parameter_1.ConvergenceParameter { + get increment() { + return `[${this.initialValue}[i] + math.floor(iteration * ${this._increment} * float(context['kgrid']['reciprocalVectorRatios'][i])) for i in range(3)]`; + } + get unitContext() { + return { + kgrid: { + dimensions: [`{{${this.name}[0]}}`, `{{${this.name}[1]}}`, `{{${this.name}[2]}}`], + shifts: [0, 0, 0], + }, + isKgridEdited: true, + isUsingJinjaVariables: true, + }; + } + // eslint-disable-next-line class-methods-use-this + useVariablesFromUnitContext(flowchartId) { + return [ + { + scope: flowchartId, + name: "context", + }, + ]; + } } -exports.NonUniformKGridConvergence = NonUniformKGridConvergence; \ No newline at end of file +exports.NonUniformKGridConvergence = NonUniformKGridConvergence; diff --git a/dist/js/subworkflows/convergence/parameter.d.ts b/dist/js/subworkflows/convergence/parameter.d.ts new file mode 100644 index 00000000..2cbff560 --- /dev/null +++ b/dist/js/subworkflows/convergence/parameter.d.ts @@ -0,0 +1,42 @@ +export class ConvergenceParameter { + constructor({ name, initialValue, increment }: { + name: any; + initialValue: any; + increment: any; + }); + name: any; + _initialValue: any; + _increment: any; + /** + * Getter for initial value as string. + * Note: this will be used in assignment unit. + * @return {string} + */ + get initialValue(): string; + /** + * @summary Defines how to increment the parameter. + * @return {string} - increment operation used in assignment unit + */ + get increment(): string; + /** + * Defines content for updating the unit context + * @return {Object} + */ + get unitContext(): Object; + /** + * Defines value once convergence is reached (for 'exit' unit). + * Note: This is used in assignment unit and most often the variable will be assigned to itself. + * @return {string} + */ + get finalValue(): string; + /** + * Create list of variables to fetch from a unit. + * Note: this is used for the `input` field for an assignment unit. + * @param {string} flowchartId - flowchartId of unit containing context variables + * @return {Object|{scope, name}} + */ + useVariablesFromUnitContext(flowchartId: string): Object | { + scope: any; + name: any; + }; +} diff --git a/dist/js/subworkflows/convergence/parameter.js b/dist/js/subworkflows/convergence/parameter.js index ea25215f..1bc2db91 100644 --- a/dist/js/subworkflows/convergence/parameter.js +++ b/dist/js/subworkflows/convergence/parameter.js @@ -1,70 +1,59 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); exports.ConvergenceParameter = void 0; -var _lodash = _interopRequireDefault(require("lodash")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /* eslint-disable class-methods-use-this */ - +const lodash_1 = __importDefault(require("lodash")); class ConvergenceParameter { - constructor({ - name, - initialValue, - increment - }) { - this.name = name; - this._initialValue = initialValue; - this._increment = increment; - } - - /** - * Getter for initial value as string. - * Note: this will be used in assignment unit. - * @return {string} - */ - get initialValue() { - if (!_lodash.default.isString(this._initialValue)) { - return JSON.stringify(this._initialValue); + constructor({ name, initialValue, increment }) { + this.name = name; + this._initialValue = initialValue; + this._increment = increment; + } + /** + * Getter for initial value as string. + * Note: this will be used in assignment unit. + * @return {string} + */ + get initialValue() { + if (!lodash_1.default.isString(this._initialValue)) { + return JSON.stringify(this._initialValue); + } + return this._initialValue; + } + /** + * @summary Defines how to increment the parameter. + * @return {string} - increment operation used in assignment unit + */ + get increment() { + return ""; // overwrite in derived class + } + /** + * Defines content for updating the unit context + * @return {Object} + */ + get unitContext() { + return {}; + } + /** + * Defines value once convergence is reached (for 'exit' unit). + * Note: This is used in assignment unit and most often the variable will be assigned to itself. + * @return {string} + */ + get finalValue() { + return `${this.name}`; + } + /** + * Create list of variables to fetch from a unit. + * Note: this is used for the `input` field for an assignment unit. + * @param {string} flowchartId - flowchartId of unit containing context variables + * @return {Object|{scope, name}} + */ + // eslint-disable-next-line class-methods-use-this, no-unused-vars + useVariablesFromUnitContext(flowchartId) { + return []; } - return this._initialValue; - } - - /** - * @summary Defines how to increment the parameter. - * @return {string} - increment operation used in assignment unit - */ - get increment() { - return ""; // overwrite in derived class - } - - /** - * Defines content for updating the unit context - * @return {Object} - */ - get unitContext() { - return {}; - } - - /** - * Defines value once convergence is reached (for 'exit' unit). - * Note: This is used in assignment unit and most often the variable will be assigned to itself. - * @return {string} - */ - get finalValue() { - return `${this.name}`; - } - - /** - * Create list of variables to fetch from a unit. - * Note: this is used for the `input` field for an assignment unit. - * @param {string} flowchartId - flowchartId of unit containing context variables - * @return {Object|{scope, name}} - */ - // eslint-disable-next-line class-methods-use-this, no-unused-vars - useVariablesFromUnitContext(flowchartId) { - return []; - } } -exports.ConvergenceParameter = ConvergenceParameter; \ No newline at end of file +exports.ConvergenceParameter = ConvergenceParameter; diff --git a/dist/js/subworkflows/convergence/uniform_kgrid.d.ts b/dist/js/subworkflows/convergence/uniform_kgrid.d.ts new file mode 100644 index 00000000..eb7d79ed --- /dev/null +++ b/dist/js/subworkflows/convergence/uniform_kgrid.d.ts @@ -0,0 +1,11 @@ +export class UniformKGridConvergence extends ConvergenceParameter { + get unitContext(): { + kgrid: { + dimensions: string[]; + shifts: number[]; + }; + isKgridEdited: boolean; + isUsingJinjaVariables: boolean; + }; +} +import { ConvergenceParameter } from "./parameter"; diff --git a/dist/js/subworkflows/convergence/uniform_kgrid.js b/dist/js/subworkflows/convergence/uniform_kgrid.js index ed061fd9..0cbf07b5 100644 --- a/dist/js/subworkflows/convergence/uniform_kgrid.js +++ b/dist/js/subworkflows/convergence/uniform_kgrid.js @@ -1,26 +1,23 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.UniformKGridConvergence = void 0; -var _parameter = require("./parameter"); -class UniformKGridConvergence extends _parameter.ConvergenceParameter { - get increment() { - return `${this.name} + ${this._increment}`; - } - get unitContext() { - return { - kgrid: { - dimensions: [`{{${this.name}}}`, `{{${this.name}}}`, `{{${this.name}}}`], - shifts: [0, 0, 0] - }, - isKgridEdited: true, - isUsingJinjaVariables: true - }; - } - get finalValue() { - return `${this.name} + 0`; - } +const parameter_1 = require("./parameter"); +class UniformKGridConvergence extends parameter_1.ConvergenceParameter { + get increment() { + return `${this.name} + ${this._increment}`; + } + get unitContext() { + return { + kgrid: { + dimensions: [`{{${this.name}}}`, `{{${this.name}}}`, `{{${this.name}}}`], + shifts: [0, 0, 0], + }, + isKgridEdited: true, + isUsingJinjaVariables: true, + }; + } + get finalValue() { + return `${this.name} + 0`; + } } -exports.UniformKGridConvergence = UniformKGridConvergence; \ No newline at end of file +exports.UniformKGridConvergence = UniformKGridConvergence; diff --git a/dist/js/subworkflows/create.d.ts b/dist/js/subworkflows/create.d.ts new file mode 100644 index 00000000..5d8a6901 --- /dev/null +++ b/dist/js/subworkflows/create.d.ts @@ -0,0 +1,49 @@ +/** + * @summary Create workflow unit from JSON configuration + * Supports applying functions to the builder prior to building via "functions" + * Supports applying attributes to the builder after building via "attributes" + * @param config {Object} unit config + * @param application {*} application + * @param unitBuilders {Object} workflow unit builders + * @param unitFactoryCls {*} workflow unit class factory + * @returns {*|{head: boolean, preProcessors: [], postProcessors: [], name: *, flowchartId: *, type: *, results: [], monitors: []}} + */ +export function createUnit({ config, application, unitBuilders, unitFactoryCls }: Object): any | { + head: boolean; + preProcessors: []; + postProcessors: []; + name: any; + flowchartId: any; + type: any; + results: []; + monitors: []; +}; +export function createSubworkflow({ subworkflowData, AppRegistry, modelFactoryCls, methodFactoryCls, subworkflowCls, unitFactoryCls, unitBuilders, }: { + subworkflowData: any; + AppRegistry?: typeof ApplicationRegistry | undefined; + modelFactoryCls?: typeof ModelFactory | undefined; + methodFactoryCls?: typeof MethodFactory | undefined; + subworkflowCls?: typeof Subworkflow | undefined; + unitFactoryCls?: typeof UnitFactory | undefined; + unitBuilders?: { + UnitConfigBuilder: typeof import("../units/builders/UnitConfigBuilder").UnitConfigBuilder; + AssignmentUnitConfigBuilder: typeof import("../units/builders/AssignmentUnitConfigBuilder").AssignmentUnitConfigBuilder; + AssertionUnitConfigBuilder: typeof import("../units/builders/AssertionUnitConfigBuilder").AssertionUnitConfigBuilder; + ExecutionUnitConfigBuilder: typeof import("../units/builders/ExecutionUnitConfigBuilder").ExecutionUnitConfigBuilder; + IOUnitConfigBuilder: typeof import("../units/builders/IOUnitConfigBuilder").IOUnitConfigBuilder; + } | undefined; +}): Subworkflow; +/** + * @summary Convenience wrapper around createSubworkflow to create by app name and swf name + * @param appName {String} application name + * @param swfName {String} subworkflow name (snake_case.yml) + * @param workflowSubworkflowMapByApplication {Object} object containing all workflow/subworkflow map by application + * @param swArgs {Object} classes for instantiation + * @returns {*} subworkflow object + */ +export function createSubworkflowByName({ appName, swfName, workflowSubworkflowMapByApplication, ...swArgs }: string): any; +import { ApplicationRegistry } from "@mat3ra/ade"; +import { ModelFactory } from "@mat3ra/mode"; +import { MethodFactory } from "@mat3ra/mode"; +import { Subworkflow } from "./subworkflow"; +import { UnitFactory } from "../units"; diff --git a/dist/js/subworkflows/create.js b/dist/js/subworkflows/create.js index d0301cc2..9ee915f1 100644 --- a/dist/js/subworkflows/create.js +++ b/dist/js/subworkflows/create.js @@ -1,52 +1,40 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createUnit = createUnit; exports.createSubworkflow = createSubworkflow; exports.createSubworkflowByName = createSubworkflowByName; -exports.createUnit = createUnit; -var _ade = require("@mat3ra/ade"); -var _mode = require("@mat3ra/mode"); -var _standata = require("@mat3ra/standata"); -var _lodash = _interopRequireDefault(require("lodash")); -var _units = require("../units"); -var _builders = require("../units/builders"); -var _utils = require("../utils"); -var _dynamic = require("./dynamic"); -var _subworkflow = require("./subworkflow"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +const ade_1 = require("@mat3ra/ade"); +const mode_1 = require("@mat3ra/mode"); +const standata_1 = require("@mat3ra/standata"); +const lodash_1 = __importDefault(require("lodash")); +const units_1 = require("../units"); +const builders_1 = require("../units/builders"); +const utils_1 = require("../utils"); +const dynamic_1 = require("./dynamic"); +const subworkflow_1 = require("./subworkflow"); // NOTE: DFTModel => DFTModelConfig, configs should have the same name as the model/method class + "Config" at the end function _getConfigFromModelOrMethodName(name, kind) { - const configs = kind === "Model" ? _mode.default_models : _mode.default_methods; - if (!configs[`${name}Config`]) { - // eslint-disable-next-line no-param-reassign - name = `Unknown${kind}`; - } - return configs[`${name}Config`]; + const configs = kind === "Model" ? mode_1.default_models : mode_1.default_methods; + if (!configs[`${name}Config`]) { + // eslint-disable-next-line no-param-reassign + name = `Unknown${kind}`; + } + return configs[`${name}Config`]; } - /** * @summary Create model from subworkflow data * @param config {Object} model config * @param modelFactoryCls {any} model factory to use * @returns {DFTModel|Model} */ -function createModel({ - config, - modelFactoryCls -}) { - const { - name, - config: modelConfig = {} - } = config; - const defaultConfig = _getConfigFromModelOrMethodName(name, "Model"); - return modelFactoryCls.create({ - ...defaultConfig, - ...modelConfig - }); +function createModel({ config, modelFactoryCls }) { + const { name, config: modelConfig = {} } = config; + const defaultConfig = _getConfigFromModelOrMethodName(name, "Model"); + return modelFactoryCls.create({ ...defaultConfig, ...modelConfig }); } - /** * @summary Create method from subworkflow data * @param config {Object} method configuration @@ -54,30 +42,20 @@ function createModel({ * @param applicationConfig {Object} application configuration * @returns {{method, setSearchText}} */ -function createMethod({ - config, - methodFactoryCls, - applicationConfig = {} -}) { - const { - name, - setSearchText = null, - config: methodConfig = {} - } = config; - const defaultConfig = _getConfigFromModelOrMethodName(name, "Method"); - const defaultConfigForApp = new _standata.ApplicationMethodStandata().getDefaultMethodConfigForApplication(applicationConfig); - const defaultConfigForAppSimple = defaultConfigForApp && defaultConfigForApp.units ? _mode.MethodConversionHandler.convertToSimple(defaultConfigForApp) : defaultConfigForApp; - const method = methodFactoryCls.create({ - ...defaultConfig, - ...defaultConfigForAppSimple, - ...methodConfig - }); - return { - method, - setSearchText - }; +function createMethod({ config, methodFactoryCls, applicationConfig = {} }) { + const { name, setSearchText = null, config: methodConfig = {} } = config; + const defaultConfig = _getConfigFromModelOrMethodName(name, "Method"); + const defaultConfigForApp = new standata_1.ApplicationMethodStandata().getDefaultMethodConfigForApplication(applicationConfig); + const defaultConfigForAppSimple = defaultConfigForApp && defaultConfigForApp.units + ? mode_1.MethodConversionHandler.convertToSimple(defaultConfigForApp) + : defaultConfigForApp; + const method = methodFactoryCls.create({ + ...defaultConfig, + ...defaultConfigForAppSimple, + ...methodConfig, + }); + return { method, setSearchText }; } - /** * @summary Create top-level objects used in subworkflow initialization * @param subworkflowData {Object} subworkflow data @@ -86,38 +64,22 @@ function createMethod({ * @param methodFactoryCls {any} method factory class * @returns {{application: *, method: *, model: (DFTModel|Model), setSearchText: String|null}} */ -function createTopLevel({ - subworkflowData, - modelFactoryCls, - methodFactoryCls, - AppRegistry -}) { - const { - application: appConfig, - model: modelConfig, - method: methodConfig - } = subworkflowData; - const application = AppRegistry.createApplication(appConfig); - const model = createModel({ - config: modelConfig, - modelFactoryCls - }); - const { - method, - setSearchText - } = createMethod({ - config: methodConfig, - methodFactoryCls, - applicationConfig: appConfig - }); - return { - application, - model, - method, - setSearchText - }; +function createTopLevel({ subworkflowData, modelFactoryCls, methodFactoryCls, AppRegistry }) { + const { application: appConfig, model: modelConfig, method: methodConfig } = subworkflowData; + const application = AppRegistry.createApplication(appConfig); + const model = createModel({ config: modelConfig, modelFactoryCls }); + const { method, setSearchText } = createMethod({ + config: methodConfig, + methodFactoryCls, + applicationConfig: appConfig, + }); + return { + application, + model, + method, + setSearchText, + }; } - /** * @summary Create workflow unit from JSON configuration * Supports applying functions to the builder prior to building via "functions" @@ -128,39 +90,17 @@ function createTopLevel({ * @param unitFactoryCls {*} workflow unit class factory * @returns {*|{head: boolean, preProcessors: [], postProcessors: [], name: *, flowchartId: *, type: *, results: [], monitors: []}} */ -function createUnit({ - config, - application, - unitBuilders, - unitFactoryCls -}) { - const { - type, - config: unitConfig - } = config; - if (type === "executionBuilder") { - const { - name, - execName, - flavorName, - flowchartId - } = unitConfig; - const builder = new unitBuilders.ExecutionUnitConfigBuilder(name, application, execName, flavorName, flowchartId); - - // config should contain "functions" and "attributes" - const cfg = (0, _utils.applyConfig)({ - obj: builder, - config, - callBuild: true - }); - return unitFactoryCls.create(cfg); - } - return unitFactoryCls.create({ - type, - ...unitConfig - }); +function createUnit({ config, application, unitBuilders, unitFactoryCls }) { + const { type, config: unitConfig } = config; + if (type === "executionBuilder") { + const { name, execName, flavorName, flowchartId } = unitConfig; + const builder = new unitBuilders.ExecutionUnitConfigBuilder(name, application, execName, flavorName, flowchartId); + // config should contain "functions" and "attributes" + const cfg = (0, utils_1.applyConfig)({ obj: builder, config, callBuild: true }); + return unitFactoryCls.create(cfg); + } + return unitFactoryCls.create({ type, ...unitConfig }); } - /** * @summary Dynamically create subworkflow units * @param dynamicSubworkflow {String} name of unit creation function @@ -170,96 +110,53 @@ function createUnit({ * @param application {*} application (optional) * @returns {*} */ -function createDynamicUnits({ - dynamicSubworkflow, - units, - unitBuilders, - unitFactoryCls, - application = null -}) { - const { - name, - subfolder - } = dynamicSubworkflow; - const func = subfolder && _lodash.default.get(_dynamic.dynamicSubworkflowsByApp, `${subfolder}.${name}`, () => {}); - switch (name) { - case "surfaceEnergy": - // eslint-disable-next-line no-case-declarations - const [scfUnit] = units; - return (0, _dynamic.getSurfaceEnergySubworkflowUnits)({ - scfUnit, - unitBuilders - }); - case "getQpointIrrep": - return func({ - unitBuilders, - unitFactoryCls, - application - }); - default: - throw new Error(`dynamicSubworkflow=${name} not recognized`); - } +function createDynamicUnits({ dynamicSubworkflow, units, unitBuilders, unitFactoryCls, application = null, }) { + const { name, subfolder } = dynamicSubworkflow; + const func = subfolder && lodash_1.default.get(dynamic_1.dynamicSubworkflowsByApp, `${subfolder}.${name}`, () => { }); + switch (name) { + case "surfaceEnergy": + // eslint-disable-next-line no-case-declarations + const [scfUnit] = units; + return (0, dynamic_1.getSurfaceEnergySubworkflowUnits)({ scfUnit, unitBuilders }); + case "getQpointIrrep": + return func({ unitBuilders, unitFactoryCls, application }); + default: + throw new Error(`dynamicSubworkflow=${name} not recognized`); + } } -function createSubworkflow({ - subworkflowData, - AppRegistry = _ade.ApplicationRegistry, - modelFactoryCls = _mode.ModelFactory, - methodFactoryCls = _mode.MethodFactory, - subworkflowCls = _subworkflow.Subworkflow, - unitFactoryCls = _units.UnitFactory, - unitBuilders = _builders.builders -}) { - const { - application, - model, - method, - setSearchText - } = createTopLevel({ - subworkflowData, - AppRegistry, - modelFactoryCls, - methodFactoryCls - }); - let units = []; - const { - name, - units: unitConfigs, - config = {}, - dynamicSubworkflow = null - } = subworkflowData; - unitConfigs.forEach(_config => { - units.push(createUnit({ - config: _config, - application, - unitBuilders, - unitFactoryCls - })); - }); - if (dynamicSubworkflow) { - units = createDynamicUnits({ - dynamicSubworkflow, - units, - unitBuilders, - unitFactoryCls, - application +function createSubworkflow({ subworkflowData, AppRegistry = ade_1.ApplicationRegistry, modelFactoryCls = mode_1.ModelFactory, methodFactoryCls = mode_1.MethodFactory, subworkflowCls = subworkflow_1.Subworkflow, unitFactoryCls = units_1.UnitFactory, unitBuilders = builders_1.builders, }) { + const { application, model, method, setSearchText } = createTopLevel({ + subworkflowData, + AppRegistry, + modelFactoryCls, + methodFactoryCls, + }); + let units = []; + const { name, units: unitConfigs, config = {}, dynamicSubworkflow = null } = subworkflowData; + unitConfigs.forEach((_config) => { + units.push(createUnit({ + config: _config, + application, + unitBuilders, + unitFactoryCls, + })); }); - } - let subworkflow = subworkflowCls.fromArguments(application, model, method, name, units, config); - const { - functions = {}, - attributes = {} - } = config; - subworkflow = (0, _utils.applyConfig)({ - obj: subworkflow, - config: { - functions, - attributes + if (dynamicSubworkflow) { + units = createDynamicUnits({ + dynamicSubworkflow, + units, + unitBuilders, + unitFactoryCls, + application, + }); } - }); - if (setSearchText) subworkflow.model.Method.setSearchText(setSearchText); - return subworkflow; + let subworkflow = subworkflowCls.fromArguments(application, model, method, name, units, config); + const { functions = {}, attributes = {} } = config; + subworkflow = (0, utils_1.applyConfig)({ obj: subworkflow, config: { functions, attributes } }); + if (setSearchText) + subworkflow.model.Method.setSearchText(setSearchText); + return subworkflow; } - /** * @summary Convenience wrapper around createSubworkflow to create by app name and swf name * @param appName {String} application name @@ -268,23 +165,12 @@ function createSubworkflow({ * @param swArgs {Object} classes for instantiation * @returns {*} subworkflow object */ -function createSubworkflowByName({ - appName, - swfName, - workflowSubworkflowMapByApplication, - ...swArgs -}) { - const { - subworkflows - } = workflowSubworkflowMapByApplication; - const { - [appName]: allSubworkflowData - } = subworkflows; - const { - [swfName]: subworkflowData - } = allSubworkflowData; - return createSubworkflow({ - subworkflowData, - ...swArgs - }); -} \ No newline at end of file +function createSubworkflowByName({ appName, swfName, workflowSubworkflowMapByApplication, ...swArgs }) { + const { subworkflows } = workflowSubworkflowMapByApplication; + const { [appName]: allSubworkflowData } = subworkflows; + const { [swfName]: subworkflowData } = allSubworkflowData; + return createSubworkflow({ + subworkflowData, + ...swArgs, + }); +} diff --git a/dist/js/subworkflows/dynamic/espresso/getQpointIrrep.d.ts b/dist/js/subworkflows/dynamic/espresso/getQpointIrrep.d.ts new file mode 100644 index 00000000..7c5bdc2f --- /dev/null +++ b/dist/js/subworkflows/dynamic/espresso/getQpointIrrep.d.ts @@ -0,0 +1,17 @@ +/** + * @summary Get QptIrr units used in phonon map calculations + * @param unitBuilders {Object} unit builders + * @param unitFactoryCls {*} unit factory class + * @param application {*} application instance + * @returns {[{head: boolean, preProcessors: [], postProcessors: [], name: *, flowchartId: *, type: *, results: [], monitors: []},*]} + */ +export function getQpointIrrep({ unitBuilders, unitFactoryCls, application }: Object): [{ + head: boolean; + preProcessors: []; + postProcessors: []; + name: any; + flowchartId: any; + type: any; + results: []; + monitors: []; +}, any]; diff --git a/dist/js/subworkflows/dynamic/espresso/getQpointIrrep.js b/dist/js/subworkflows/dynamic/espresso/getQpointIrrep.js index 25998531..fba0720b 100644 --- a/dist/js/subworkflows/dynamic/espresso/getQpointIrrep.js +++ b/dist/js/subworkflows/dynamic/espresso/getQpointIrrep.js @@ -1,10 +1,7 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.getQpointIrrep = getQpointIrrep; -var _enums = require("../../../enums"); +const enums_1 = require("../../../enums"); /** * @summary Get QptIrr units used in phonon map calculations * @param unitBuilders {Object} unit builders @@ -12,23 +9,19 @@ var _enums = require("../../../enums"); * @param application {*} application instance * @returns {[{head: boolean, preProcessors: [], postProcessors: [], name: *, flowchartId: *, type: *, results: [], monitors: []},*]} */ -function getQpointIrrep({ - unitBuilders, - unitFactoryCls, - application -}) { - const { - ExecutionUnitConfigBuilder - } = unitBuilders; - const pythonUnit = new ExecutionUnitConfigBuilder("python", application, "python", "espresso_xml_get_qpt_irr").build(); - const assignmentUnit = unitFactoryCls.create({ - type: _enums.UNIT_TYPES.assignment, - input: [{ - scope: pythonUnit.flowchartId, - name: "STDOUT" - }], - operand: "Q_POINTS", - value: "json.loads(STDOUT)" - }); - return [pythonUnit, assignmentUnit]; -} \ No newline at end of file +function getQpointIrrep({ unitBuilders, unitFactoryCls, application }) { + const { ExecutionUnitConfigBuilder } = unitBuilders; + const pythonUnit = new ExecutionUnitConfigBuilder("python", application, "python", "espresso_xml_get_qpt_irr").build(); + const assignmentUnit = unitFactoryCls.create({ + type: enums_1.UNIT_TYPES.assignment, + input: [ + { + scope: pythonUnit.flowchartId, + name: "STDOUT", + }, + ], + operand: "Q_POINTS", + value: "json.loads(STDOUT)", + }); + return [pythonUnit, assignmentUnit]; +} diff --git a/dist/js/subworkflows/dynamic/index.d.ts b/dist/js/subworkflows/dynamic/index.d.ts new file mode 100644 index 00000000..6192c868 --- /dev/null +++ b/dist/js/subworkflows/dynamic/index.d.ts @@ -0,0 +1,8 @@ +import { getSurfaceEnergySubworkflowUnits } from "./surfaceEnergy"; +export namespace dynamicSubworkflowsByApp { + namespace espresso { + export { getQpointIrrep }; + } +} +import { getQpointIrrep } from "./espresso/getQpointIrrep"; +export { getSurfaceEnergySubworkflowUnits }; diff --git a/dist/js/subworkflows/dynamic/index.js b/dist/js/subworkflows/dynamic/index.js index 003b4a23..bd706c58 100644 --- a/dist/js/subworkflows/dynamic/index.js +++ b/dist/js/subworkflows/dynamic/index.js @@ -1,19 +1,10 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.dynamicSubworkflowsByApp = void 0; -Object.defineProperty(exports, "getSurfaceEnergySubworkflowUnits", { - enumerable: true, - get: function () { - return _surfaceEnergy.getSurfaceEnergySubworkflowUnits; - } -}); -var _getQpointIrrep = require("./espresso/getQpointIrrep"); -var _surfaceEnergy = require("./surfaceEnergy"); -const dynamicSubworkflowsByApp = exports.dynamicSubworkflowsByApp = { - espresso: { - getQpointIrrep: _getQpointIrrep.getQpointIrrep - } -}; \ No newline at end of file +Object.defineProperty(exports, "__esModule", { value: true }); +exports.dynamicSubworkflowsByApp = exports.getSurfaceEnergySubworkflowUnits = void 0; +const getQpointIrrep_1 = require("./espresso/getQpointIrrep"); +const surfaceEnergy_1 = require("./surfaceEnergy"); +Object.defineProperty(exports, "getSurfaceEnergySubworkflowUnits", { enumerable: true, get: function () { return surfaceEnergy_1.getSurfaceEnergySubworkflowUnits; } }); +const dynamicSubworkflowsByApp = { + espresso: { getQpointIrrep: getQpointIrrep_1.getQpointIrrep }, +}; +exports.dynamicSubworkflowsByApp = dynamicSubworkflowsByApp; diff --git a/dist/js/subworkflows/dynamic/surfaceEnergy.d.ts b/dist/js/subworkflows/dynamic/surfaceEnergy.d.ts new file mode 100644 index 00000000..b2b79dcc --- /dev/null +++ b/dist/js/subworkflows/dynamic/surfaceEnergy.d.ts @@ -0,0 +1,4 @@ +export function getSurfaceEnergySubworkflowUnits({ scfUnit, unitBuilders }: { + scfUnit: any; + unitBuilders: any; +}): any[]; diff --git a/dist/js/subworkflows/dynamic/surfaceEnergy.js b/dist/js/subworkflows/dynamic/surfaceEnergy.js index 2873367a..60667d4e 100644 --- a/dist/js/subworkflows/dynamic/surfaceEnergy.js +++ b/dist/js/subworkflows/dynamic/surfaceEnergy.js @@ -1,67 +1,72 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.getSurfaceEnergySubworkflowUnits = getSurfaceEnergySubworkflowUnits; -var _utils = require("@mat3ra/utils"); +const utils_1 = require("@mat3ra/utils"); function getIOUnitEndpointOptions(query, projection = "{}") { - return { - params: { - query, - projection - } - }; + return { + params: { + query, + projection, + }, + }; } function getAssignmentUnitInput(unit, name) { - return [{ - name, - scope: unit.flowchartId - }]; + return [ + { + name, + scope: unit.flowchartId, + }, + ]; } -function getSurfaceEnergySubworkflowUnits({ - scfUnit, - unitBuilders -}) { - const { - IOUnitConfigBuilder, - AssignmentUnitConfigBuilder, - AssertionUnitConfigBuilder - } = unitBuilders; - let input, endpointOptions; - endpointOptions = getIOUnitEndpointOptions("{'_id': MATERIAL_ID}"); - const getSlabUnit = new IOUnitConfigBuilder("io-slab", "materials", endpointOptions).build(); - input = getAssignmentUnitInput(getSlabUnit, "DATA"); - const setSlabUnit = new AssignmentUnitConfigBuilder("slab", "SLAB", "DATA[0]", input).build(); - endpointOptions = getIOUnitEndpointOptions("{'_id': SLAB.metadata.bulkId}"); - const getBulkUnit = new IOUnitConfigBuilder("io-bulk", "materials", endpointOptions).build(); - const BULKValue = "DATA[0] if DATA else None"; - input = getAssignmentUnitInput(getBulkUnit, "DATA"); - const setBulkUnit = new AssignmentUnitConfigBuilder("bulk", "BULK", BULKValue, input).build(); - const assertBulkUnit = new AssertionUnitConfigBuilder("assert-bulk", "BULK != None", "Bulk material does not exist!").build(); - const query = _utils.Utils.str.removeNewLinesAndExtraSpaces(`{ +function getSurfaceEnergySubworkflowUnits({ scfUnit, unitBuilders }) { + const { IOUnitConfigBuilder, AssignmentUnitConfigBuilder, AssertionUnitConfigBuilder } = unitBuilders; + let input, endpointOptions; + endpointOptions = getIOUnitEndpointOptions("{'_id': MATERIAL_ID}"); + const getSlabUnit = new IOUnitConfigBuilder("io-slab", "materials", endpointOptions).build(); + input = getAssignmentUnitInput(getSlabUnit, "DATA"); + const setSlabUnit = new AssignmentUnitConfigBuilder("slab", "SLAB", "DATA[0]", input).build(); + endpointOptions = getIOUnitEndpointOptions("{'_id': SLAB.metadata.bulkId}"); + const getBulkUnit = new IOUnitConfigBuilder("io-bulk", "materials", endpointOptions).build(); + const BULKValue = "DATA[0] if DATA else None"; + input = getAssignmentUnitInput(getBulkUnit, "DATA"); + const setBulkUnit = new AssignmentUnitConfigBuilder("bulk", "BULK", BULKValue, input).build(); + const assertBulkUnit = new AssertionUnitConfigBuilder("assert-bulk", "BULK != None", "Bulk material does not exist!").build(); + const query = utils_1.Utils.str.removeNewLinesAndExtraSpaces(`{ 'exabyteId': BULK.exabyteId, 'data.name': 'total_energy', 'group': {'$regex': ''.join((SUBWORKFLOW.application.shortName, ':'))} }`); - // Do not confuse `sort` with `$sort`. `sort` is used in meteor collections and `$sort` is used in Mongo queries. - const projection = "{'sort': {'precision.value': -1}, 'limit': 1}"; - endpointOptions = getIOUnitEndpointOptions(query, projection); - const getEBulkUnit = new IOUnitConfigBuilder("io-e-bulk", "refined-properties", endpointOptions).build(); - input = getAssignmentUnitInput(getEBulkUnit, "DATA"); - const EBULKValue = "DATA[0].data.value if DATA else None"; - const setEBulkUnit = new AssignmentUnitConfigBuilder("e-bulk", "E_BULK", EBULKValue, input).build(); - const assertEBulkUnit = new AssertionUnitConfigBuilder("assert-e-bulk", "E_BULK != None", "E_BULK does not exist!").build(); - const AValue = "np.linalg.norm(np.cross(SLAB.lattice.vectors.a, SLAB.lattice.vectors.b))"; - const setSurfaceUnit = new AssignmentUnitConfigBuilder("surface", "A", AValue).build(); - const setNBulkUnit = new AssignmentUnitConfigBuilder("n-bulk", "N_BULK", "len(BULK.basis.elements)").build(); - const setNSlabUnit = new AssignmentUnitConfigBuilder("n-slab", "N_SLAB", "len(SLAB.basis.elements)").build(); - input = getAssignmentUnitInput(scfUnit, "total_energy"); - const setESlabUnit = new AssignmentUnitConfigBuilder("e-slab", "E_SLAB", "total_energy", input).build(); - const results = [{ - name: "surface_energy" - }]; - const SEValue = "1 / (2 * A) * (E_SLAB - E_BULK * (N_SLAB/N_BULK))"; - const surfaceEnergyUnit = new AssignmentUnitConfigBuilder("surface-energy", "SURFACE_ENERGY", SEValue, [], results).build(); - return [getSlabUnit, setSlabUnit, getBulkUnit, setBulkUnit, assertBulkUnit, getEBulkUnit, setEBulkUnit, assertEBulkUnit, setSurfaceUnit, setNBulkUnit, setNSlabUnit, scfUnit, setESlabUnit, surfaceEnergyUnit]; -} \ No newline at end of file + // Do not confuse `sort` with `$sort`. `sort` is used in meteor collections and `$sort` is used in Mongo queries. + const projection = "{'sort': {'precision.value': -1}, 'limit': 1}"; + endpointOptions = getIOUnitEndpointOptions(query, projection); + const getEBulkUnit = new IOUnitConfigBuilder("io-e-bulk", "refined-properties", endpointOptions).build(); + input = getAssignmentUnitInput(getEBulkUnit, "DATA"); + const EBULKValue = "DATA[0].data.value if DATA else None"; + const setEBulkUnit = new AssignmentUnitConfigBuilder("e-bulk", "E_BULK", EBULKValue, input).build(); + const assertEBulkUnit = new AssertionUnitConfigBuilder("assert-e-bulk", "E_BULK != None", "E_BULK does not exist!").build(); + const AValue = "np.linalg.norm(np.cross(SLAB.lattice.vectors.a, SLAB.lattice.vectors.b))"; + const setSurfaceUnit = new AssignmentUnitConfigBuilder("surface", "A", AValue).build(); + const setNBulkUnit = new AssignmentUnitConfigBuilder("n-bulk", "N_BULK", "len(BULK.basis.elements)").build(); + const setNSlabUnit = new AssignmentUnitConfigBuilder("n-slab", "N_SLAB", "len(SLAB.basis.elements)").build(); + input = getAssignmentUnitInput(scfUnit, "total_energy"); + const setESlabUnit = new AssignmentUnitConfigBuilder("e-slab", "E_SLAB", "total_energy", input).build(); + const results = [{ name: "surface_energy" }]; + const SEValue = "1 / (2 * A) * (E_SLAB - E_BULK * (N_SLAB/N_BULK))"; + const surfaceEnergyUnit = new AssignmentUnitConfigBuilder("surface-energy", "SURFACE_ENERGY", SEValue, [], results).build(); + return [ + getSlabUnit, + setSlabUnit, + getBulkUnit, + setBulkUnit, + assertBulkUnit, + getEBulkUnit, + setEBulkUnit, + assertEBulkUnit, + setSurfaceUnit, + setNBulkUnit, + setNSlabUnit, + scfUnit, + setESlabUnit, + surfaceEnergyUnit, + ]; +} diff --git a/dist/js/subworkflows/index.d.ts b/dist/js/subworkflows/index.d.ts new file mode 100644 index 00000000..48390ca0 --- /dev/null +++ b/dist/js/subworkflows/index.d.ts @@ -0,0 +1,2 @@ +export { Subworkflow } from "./subworkflow"; +export { createSubworkflowByName } from "./create"; diff --git a/dist/js/subworkflows/index.js b/dist/js/subworkflows/index.js index 0d571aa2..ac2896d6 100644 --- a/dist/js/subworkflows/index.js +++ b/dist/js/subworkflows/index.js @@ -1,19 +1,7 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "Subworkflow", { - enumerable: true, - get: function () { - return _subworkflow.Subworkflow; - } -}); -Object.defineProperty(exports, "createSubworkflowByName", { - enumerable: true, - get: function () { - return _create.createSubworkflowByName; - } -}); -var _subworkflow = require("./subworkflow"); -var _create = require("./create"); \ No newline at end of file +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createSubworkflowByName = exports.Subworkflow = void 0; +var subworkflow_1 = require("./subworkflow"); +Object.defineProperty(exports, "Subworkflow", { enumerable: true, get: function () { return subworkflow_1.Subworkflow; } }); +var create_1 = require("./create"); +Object.defineProperty(exports, "createSubworkflowByName", { enumerable: true, get: function () { return create_1.createSubworkflowByName; } }); diff --git a/dist/js/subworkflows/subworkflow.d.ts b/dist/js/subworkflows/subworkflow.d.ts new file mode 100644 index 00000000..0faa7740 --- /dev/null +++ b/dist/js/subworkflows/subworkflow.d.ts @@ -0,0 +1,1204 @@ +import { Application } from "@mat3ra/ade"; +import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import { type DefaultableInMemoryEntityConstructor } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; +import { type NamedInMemoryEntityConstructor } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { ApplicationSchema, BaseMethod, BaseModel } from "@mat3ra/esse/dist/js/types"; +import { type Method, Model, ModelFactory } from "@mat3ra/mode"; +import { type SubworkflowSchemaMixin } from "../generated/SubworkflowSchemaMixin"; +import { type BaseUnit, UnitFactory } from "../units"; +type Base = typeof InMemoryEntity & DefaultableInMemoryEntityConstructor & NamedInMemoryEntityConstructor & Constructor; +declare const Subworkflow_base: Base; +export declare class Subworkflow extends Subworkflow_base { + static usePredefinedIds: boolean; + private ModelFactory; + private UnitFactory; + private applicationInstance; + private modelInstance; + private unitsInstances; + constructor(config: SubworkflowSchemaMixin, _ModelFactory?: typeof ModelFactory, _UnitFactory?: typeof UnitFactory); + static generateSubworkflowId(name: string, application?: ApplicationSchema, model?: BaseModel, method?: BaseMethod): any; + static get defaultConfig(): { + _id: any; + name: string; + application: import("node_modules/@mat3ra/ade/dist/js/applicationMixin").DefaultApplicationConfig; + model: import("@mat3ra/mode/dist/js/types").ModelConfig; + properties: never[]; + units: never[]; + }; + getAsUnit(): BaseUnit; + static fromArguments(application: Application, model: Model, method: Method, name: string, units?: BaseUnit[], config?: {}, Cls?: typeof Subworkflow): Subworkflow; + setApplication(application: Application): void; + setModel(model: Model): void; + setUnits(units: BaseUnit[]): void; + toJSON(exclude?: string[]): { + compute?: { + queue: "D" | "OR" | "OF" | "OFplus" | "SR" | "SF" | "SFplus" | "GPOF" | "GP2OF" | "GP4OF" | "GPSF" | "GP2SF" | "GP4SF" | "OR4" | "OR8" | "OR16" | "SR4" | "SR8" | "SR16" | "GOF" | "G4OF" | "G8OF" | "GSF" | "G4SF" | "G8SF"; + nodes: number; + ppn: number; + timeLimit: string; + timeLimitType?: "per single attempt" | "compound"; + isRestartable?: boolean; + notify?: string; + email?: string; + maxCPU?: number; + arguments?: { + nimage?: number; + npools?: number; + nband?: number; + ntg?: number; + ndiag?: number; + }; + cluster?: { + fqdn?: string; + jid?: string; + }; + errors?: { + domain?: "rupy" | "alfred" | "celim" | "webapp"; + reason?: string; + message?: string; + traceback?: string; + }[]; + excludeFilesPattern?: string; + } | undefined; + model: Record; + units: import("@mat3ra/esse/dist/js/esse/types").AnyObject[]; + }; + get contextProviders(): any[]; + /** + * Extracts a reduced version of the entity config to be stored inside redux state. + * This is used to track changes to context, monitors, properties, etc. when multiple materials are in state. + */ + extractReducedExternalDependentConfig(): { + id: string; + context: any; + units: any[]; + }; + /** + * Applies the reduced config obtained from extractReducedExternalDependentConfig on the entity. + */ + applyReducedExternalDependentConfig(config: any): void; + get contextFromAssignmentUnits(): {}; + render(context?: {}): void; + /** + * TODO: reuse workflow function instead + */ + addUnit(unit: BaseUnit, index?: number): void; + removeUnit(flowchartId: string): void; + get properties(): any[]; + getUnit(flowchartId: string): { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "io"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + subtype: "input" | "output" | "dataFrame"; + source: "api" | "db" | "object_storage"; + input: ({ + type: "db_ids"; + ids: string[]; + } | { + type: "db_collection"; + collection: string; + draft: boolean; + } | { + type: "object_storage"; + objectData: { + CONTAINER?: string; + NAME?: string; + PROVIDER?: string; + REGION?: string; + SIZE?: number; + TIMESTAMP?: string; + }; + overwrite?: boolean; + pathname?: string; + basename?: string; + filetype?: string; + })[]; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "reduce"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + mapFlowchartId: string; + input: { + operation: string; + arguments: string[]; + }[]; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "condition"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + input: { + scope: string; + name: string; + }[]; + statement: string; + then: string; + else: string; + maxOccurrences: number; + throwException?: boolean; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "assertion"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + statement: string; + errorMessage?: string; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "execution"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + application: { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + shortName: string; + summary: string; + version: string; + build: string; + hasAdvancedComputeOptions?: boolean; + isLicensed?: boolean; + }; + executable?: { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + applicationId: string[]; + hasAdvancedComputeOptions?: boolean; + }; + flavor?: { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + executableId: string; + executableName?: string; + applicationName?: string; + input: { + templateId?: string; + templateName?: string; + name?: string; + }[]; + supportedApplicationVersions?: string[]; + }; + input: { + template: { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + applicationName: string; + applicationVersion?: string; + executableName: string; + contextProviders: { + name: string; + }[]; + content: string; + }; + rendered: string; + isManuallyChanged: boolean; + }[]; + context?: { + name: import("@mat3ra/esse/dist/js/types").ContextProviderNameEnum; + isEdited: boolean; + data: {}; + extraData?: {}; + }[]; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "assignment"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + scope?: string; + input?: { + scope: string; + name: string; + }[]; + operand: string; + value: string | boolean | number; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "processing"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + operation: string; + operationType: string; + inputData: { + [k: string]: unknown; + }; + } | undefined; + unitIndex(flowchartId: string): number; + replaceUnit(index: number, unit: BaseUnit): void; + get scopeVariables(): string[]; + get scalarResults(): string[]; + get isMultiMaterial(): boolean; + get isDraft(): boolean; + setIsDraft(bool: boolean): void; + get methodData(): any; + /** + * @summary Calculates hash of the subworkflow. Meaningful fields are units, app and model. + * units must be sorted topologically before hashing (already sorted). + */ + calculateHash(): string; + _calculateModelHash(): string; + findUnitById(id: string): { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "io"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + subtype: "input" | "output" | "dataFrame"; + source: "api" | "db" | "object_storage"; + input: ({ + type: "db_ids"; + ids: string[]; + } | { + type: "db_collection"; + collection: string; + draft: boolean; + } | { + type: "object_storage"; + objectData: { + CONTAINER?: string; + NAME?: string; + PROVIDER?: string; + REGION?: string; + SIZE?: number; + TIMESTAMP?: string; + }; + overwrite?: boolean; + pathname?: string; + basename?: string; + filetype?: string; + })[]; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "reduce"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + mapFlowchartId: string; + input: { + operation: string; + arguments: string[]; + }[]; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "condition"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + input: { + scope: string; + name: string; + }[]; + statement: string; + then: string; + else: string; + maxOccurrences: number; + throwException?: boolean; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "assertion"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + statement: string; + errorMessage?: string; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "execution"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + application: { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + shortName: string; + summary: string; + version: string; + build: string; + hasAdvancedComputeOptions?: boolean; + isLicensed?: boolean; + }; + executable?: { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + applicationId: string[]; + hasAdvancedComputeOptions?: boolean; + }; + flavor?: { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + executableId: string; + executableName?: string; + applicationName?: string; + input: { + templateId?: string; + templateName?: string; + name?: string; + }[]; + supportedApplicationVersions?: string[]; + }; + input: { + template: { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + applicationName: string; + applicationVersion?: string; + executableName: string; + contextProviders: { + name: string; + }[]; + content: string; + }; + rendered: string; + isManuallyChanged: boolean; + }[]; + context?: { + name: import("@mat3ra/esse/dist/js/types").ContextProviderNameEnum; + isEdited: boolean; + data: {}; + extraData?: {}; + }[]; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "assignment"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + scope?: string; + input?: { + scope: string; + name: string; + }[]; + operand: string; + value: string | boolean | number; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "processing"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + operation: string; + operationType: string; + inputData: { + [k: string]: unknown; + }; + } | undefined; + findUnitKeyById(id: string): string; + findUnitWithTag(tag: string): { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "io"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + subtype: "input" | "output" | "dataFrame"; + source: "api" | "db" | "object_storage"; + input: ({ + type: "db_ids"; + ids: string[]; + } | { + type: "db_collection"; + collection: string; + draft: boolean; + } | { + type: "object_storage"; + objectData: { + CONTAINER?: string; + NAME?: string; + PROVIDER?: string; + REGION?: string; + SIZE?: number; + TIMESTAMP?: string; + }; + overwrite?: boolean; + pathname?: string; + basename?: string; + filetype?: string; + })[]; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "reduce"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + mapFlowchartId: string; + input: { + operation: string; + arguments: string[]; + }[]; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "condition"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + input: { + scope: string; + name: string; + }[]; + statement: string; + then: string; + else: string; + maxOccurrences: number; + throwException?: boolean; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "assertion"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + statement: string; + errorMessage?: string; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "execution"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + application: { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + shortName: string; + summary: string; + version: string; + build: string; + hasAdvancedComputeOptions?: boolean; + isLicensed?: boolean; + }; + executable?: { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + applicationId: string[]; + hasAdvancedComputeOptions?: boolean; + }; + flavor?: { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + executableId: string; + executableName?: string; + applicationName?: string; + input: { + templateId?: string; + templateName?: string; + name?: string; + }[]; + supportedApplicationVersions?: string[]; + }; + input: { + template: { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + applicationName: string; + applicationVersion?: string; + executableName: string; + contextProviders: { + name: string; + }[]; + content: string; + }; + rendered: string; + isManuallyChanged: boolean; + }[]; + context?: { + name: import("@mat3ra/esse/dist/js/types").ContextProviderNameEnum; + isEdited: boolean; + data: {}; + extraData?: {}; + }[]; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "assignment"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + scope?: string; + input?: { + scope: string; + name: string; + }[]; + operand: string; + value: string | boolean | number; + } | { + _id?: string; + slug?: string; + systemName?: string; + schemaVersion?: string; + name: string; + isDefault?: boolean; + preProcessors: { + name: string; + }[]; + postProcessors: { + name: string; + }[]; + monitors: { + name: string; + }[]; + results: { + name: string; + }[]; + tags?: string[]; + status?: "idle" | "active" | "warning" | "error" | "finished"; + statusTrack?: { + trackedAt: number; + status: string; + repetition?: number; + }[]; + isDraft?: boolean; + type: "processing"; + head?: boolean; + flowchartId: string; + next?: string; + enableRender?: boolean; + operation: string; + operationType: string; + inputData: { + [k: string]: unknown; + }; + } | undefined; + get hasConvergence(): boolean; +} +export {}; diff --git a/dist/js/subworkflows/subworkflow.js b/dist/js/subworkflows/subworkflow.js index 0b09a122..418fbdf8 100644 --- a/dist/js/subworkflows/subworkflow.js +++ b/dist/js/subworkflows/subworkflow.js @@ -1,291 +1,266 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); exports.Subworkflow = void 0; -var _ade = require("@mat3ra/ade"); -var _entity = require("@mat3ra/code/dist/js/entity"); -var _mode = require("@mat3ra/mode"); -var _utils = require("@mat3ra/utils"); -var _lodash = _interopRequireDefault(require("lodash")); -var _mixwith = require("mixwith"); -var _underscore = _interopRequireDefault(require("underscore")); -var _enums = require("../enums"); -var _units = require("../units"); -var _utils2 = require("../utils"); -var _convergence = require("./convergence"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -/* eslint max-classes-per-file:0 */ - -class BaseSubworkflow extends (0, _mixwith.mix)(_entity.NamedDefaultableRepetitionImportantSettingsInMemoryEntity).with(_convergence.ConvergenceMixin, _entity.ContextAndRenderFieldsMixin) {} -class Subworkflow extends BaseSubworkflow { - constructor(config, _Application = _ade.Application, _ModelFactory = _mode.ModelFactory, _UnitFactory = _units.UnitFactory) { - super(config); - this._Application = _Application; - this._ModelFactory = _ModelFactory; - this._UnitFactory = _UnitFactory; - this.initialize(); - } - initialize() { - this._application = new this._Application(this.prop("application")); - this._model = this._ModelFactory.create({ - ...this.prop("model"), - application: this.prop("application") - }); - this._units = (0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)(this.prop("units", [])), this.id).map(cfg => this._UnitFactory.create(Object.assign(cfg, { - application: this.application.toJSON() - }))); - } - static generateSubworkflowId(name, application = null, model = null, method = null) { - const appName = application ? application.name || application : ""; - const modelInfo = model ? `${(model.toJSON?.() || model).type}-${(model.toJSON?.() || model).subtype || ""}` : ""; - const methodInfo = method ? `${(method.toJSON?.() || method).type}-${(method.toJSON?.() || method).subtype || ""}` : ""; - const seed = [`subworkflow-${name}`, appName, modelInfo, methodInfo].filter(p => p).join("-"); - if (this.usePredefinedIds) return _utils.Utils.uuid.getUUIDFromNamespace(seed); - return _utils.Utils.uuid.getUUID(); - } - static get defaultConfig() { - const defaultName = "New Subworkflow"; - return { - _id: this.generateSubworkflowId(defaultName), - name: defaultName, - application: _ade.Application.defaultConfig, - model: _mode.Model.defaultConfig, - properties: [], - units: [] - }; - } - - /* - * @returns {SubworkflowUnit} - */ - getAsUnit() { - return this._UnitFactory.create({ - type: _enums.UNIT_TYPES.subworkflow, - _id: this.id, - name: this.name - }); - } - - /* - * @summary Used to generate initial application tree, therefore omit setting application. - */ - static fromArguments(application, model, method, name, units = [], config = {}, Cls = Subworkflow) { - const nameForIdGeneration = config.attributes?.name || name; - const { - functions, - attributes, - ...cleanConfig - } = config; - - // Set the method on the model so it can be properly serialized - model.setMethod(method); - return new Cls({ - ...cleanConfig, - _id: Cls.generateSubworkflowId(nameForIdGeneration, application, model, method), - name, - application: application.toJSON(), - properties: _lodash.default.sortedUniq(_lodash.default.flatten(units.filter(x => x.resultNames).map(x => x.resultNames))), - model: { - ...model.toJSON(), - method: method.toJSON() - }, - units: units.map(unit => unit.toJSON ? unit.toJSON() : unit) - }); - } - get application() { - return this._application; - } - setApplication(application) { - // TODO: adjust the logic above to take into account whether units need re-rendering after version change etc. - // reset units if application name changes - const previousApplicationName = this.application.name; - this._application = application; - if (previousApplicationName !== application.name) { - // TODO: figure out how to set a default unit per new application instead of removing all - this.setUnits([]); - } else { - // propagate new application version to all units - this.units.filter(unit => typeof unit.setApplication === "function").forEach(unit => unit.setApplication(application, true)); - } - this.setProp("application", application.toJSON()); - // set model to the default one for the application selected - this.setModel(this._ModelFactory.createFromApplication({ - application: this.prop("application") - })); - } - get model() { - return this._model; - } - setModel(model) { - this._model = model; - } - get units() { - return this._units; - } - setUnits(units) { - this._units = units; - } - toJSON(exclude = []) { - return { - ...super.toJSON(exclude), - model: this.model.toJSON(), - units: this.units.map(x => x.toJSON()), - ...(this.compute ? { - compute: this.compute - } : {}) // {"compute": null } won't pass esse validation - }; - } - get contextProviders() { - const unitsWithContextProviders = this.units.filter(u => u.allContextProviders && u.allContextProviders.length); - const allContextProviders = _underscore.default.flatten(unitsWithContextProviders.map(u => u.allContextProviders)); - const subworkflowContextProviders = allContextProviders.filter(p => p.isSubworkflowContextProvider); - return _underscore.default.uniq(subworkflowContextProviders, p => p.name); - } - - /** - * Extracts a reduced version of the entity config to be stored inside redux state. - * This is used to track changes to context, monitors, properties, etc. when multiple materials are in state. - */ - extractReducedExternalDependentConfig() { - return { - id: this.id, - context: this.context || {}, - units: this.units.map(unit => unit.extractReducedExternalDependentConfig()) - }; - } - - /** - * Applies the reduced config obtained from extractReducedExternalDependentConfig on the entity. - */ - applyReducedExternalDependentConfig(config) { - this.context = config.context || {}; - this.units.forEach(unit => { - const unitConfig = (config.units || []).find(c => c.id === unit.flowchartId); - unit.applyReducedExternalDependentConfig(unitConfig || {}); - }); - } - get contextFromAssignmentUnits() { - const ctx = {}; - this.units.filter(u => u.type === _enums.UNIT_TYPES.assignment).forEach(u => { - ctx[u.operand] = u.value; - }); - return ctx; - } - render(context = {}) { - const ctx = { - ...context, - application: this.application, - methodData: this.model.Method.data, - model: this.model.toJSON(), - // context below is assembled from context providers and passed to units to override theirs - ...this.context, - subworkflowContext: this.contextFromAssignmentUnits - }; - this.units.forEach(u => u.render(ctx)); - } - - /** - * TODO: reuse workflow function instead - * @param unit {Unit} - * @param head {Boolean} - * @param index {Number} - */ - addUnit(unit, index = -1) { - const { - units - } = this; - if (units.length === 0) { - unit.head = true; - this.setUnits([unit]); - } else { - if (index >= 0) units.splice(index, 0, unit);else units.push(unit); - this.setUnits((0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)(units))); - } - } - removeUnit(flowchartId) { - const previousUnit = this.units.find(x => x.next === flowchartId); - if (previousUnit) previousUnit.unsetProp("next"); - // TODO: remove the setNextLinks and setUnitsHead and handle the logic via flowchart designer - this.setUnits((0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)(this.units.filter(x => x.flowchartId !== flowchartId)))); - } - get properties() { - return _lodash.default.flatten(this.units.map(x => x.resultNames)); - } - getUnit(flowchartId) { - return this.units.find(x => x.flowchartId === flowchartId); - } - unitIndex(flowchartId) { - return _lodash.default.findIndex(this.units, unit => { - return unit.flowchartId === flowchartId; - }); - } - replaceUnit(index, unit) { - this.units[index] = unit; - this.setUnits((0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)(this.units))); - } - - // eslint-disable-next-line class-methods-use-this - get scopeVariables() { - return ["N_k", "N_k_nonuniform"]; - } - - // eslint-disable-next-line class-methods-use-this - get scalarResults() { - return ["total_energy", "pressure"]; - } - get isMultiMaterial() { - return this.prop("isMultiMaterial", false); - } - get isDraft() { - return this.prop("isDraft", false); - } - setIsDraft(bool) { - return this.setProp("isDraft", bool); - } - get methodData() { - return this.model.Method.data; - } - - /** - * @summary Calculates hash of the subworkflow. Meaningful fields are units, app and model. - * units must be sorted topologically before hashing (already sorted). - */ - calculateHash() { - const config = this.toJSON(); - const meaningfulFields = { - application: _utils.Utils.specific.removeTimestampableKeysFromConfig(config.application), - model: this._calculateModelHash(), - units: _underscore.default.map(this.units, u => u.calculateHash()).join() - }; - return _utils.Utils.hash.calculateHashFromObject(meaningfulFields); - } - _calculateModelHash() { - const { - model - } = this.toJSON(); - // ignore empty data object - if (this.model.Method.omitInHashCalculation) delete model.method.data; - return _utils.Utils.hash.calculateHashFromObject(model); - } - findUnitById(id) { - // TODO: come back and refactor after converting flowchartId to id - return this.units.find(u => u.flowchartId === id); - } - findUnitKeyById(id) { - const index = this.units.findIndex(u => u.flowchartId === id); - return `units.${index}`; - } - findUnitWithTag(tag) { - return this.units.find(unit => unit.tags.includes(tag)); - } - get hasConvergence() { - return !!this.convergenceParam && !!this.convergenceResult && !!this.convergenceSeries; - } +const ade_1 = require("@mat3ra/ade"); +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 mode_1 = require("@mat3ra/mode"); +const utils_1 = require("@mat3ra/utils"); +const lodash_1 = __importDefault(require("lodash")); +const underscore_1 = __importDefault(require("underscore")); +const enums_1 = require("../enums"); +const SubworkflowSchemaMixin_1 = require("../generated/SubworkflowSchemaMixin"); +const units_1 = require("../units"); +const utils_2 = require("../utils"); +class Subworkflow extends entity_1.InMemoryEntity { + constructor(config, _ModelFactory = mode_1.ModelFactory, _UnitFactory = units_1.UnitFactory) { + super(config); + this.ModelFactory = _ModelFactory; + this.UnitFactory = _UnitFactory; + this.applicationInstance = new ade_1.Application(this.application); + this.modelInstance = this.ModelFactory.create({ + ...this.model, + application: this.application, + }); + this.unitsInstances = (0, utils_2.setNextLinks)((0, utils_2.setUnitsHead)(this.units || []).map((cfg) => { + return this.UnitFactory.create({ ...cfg, application: this.application }); + })); + } + static generateSubworkflowId(name, application, model, method) { + const appName = (application === null || application === void 0 ? void 0 : application.name) || ""; + const modelInfo = model ? `${model.type}-${model.subtype || ""}` : ""; + const methodInfo = method ? `${method.type}-${method.subtype || ""}` : ""; + const seed = [`subworkflow-${name}`, appName, modelInfo, methodInfo] + .filter((p) => p) + .join("-"); + return this.usePredefinedIds ? utils_1.Utils.uuid.getUUIDFromNamespace(seed) : utils_1.Utils.uuid.getUUID(); + } + static get defaultConfig() { + const defaultName = "New Subworkflow"; + return { + _id: this.generateSubworkflowId(defaultName), + name: defaultName, + application: ade_1.Application.defaultConfig, + model: mode_1.Model.defaultConfig, + properties: [], + units: [], + }; + } + /* + * @returns {SubworkflowUnit} + */ + getAsUnit() { + return this.UnitFactory.create({ + type: enums_1.UnitType.subworkflow, + _id: this.id, + name: this.name, + }); + } + /* + * @summary Used to generate initial application tree, therefore omit setting application. + */ + static fromArguments(application, model, method, name, units = [], config = {}, Cls = Subworkflow) { + var _a; + const nameForIdGeneration = ((_a = config.attributes) === null || _a === void 0 ? void 0 : _a.name) || name; + const { functions, attributes, ...cleanConfig } = config; + // Set the method on the model so it can be properly serialized + model.setMethod(method); + return new Cls({ + ...cleanConfig, + _id: Cls.generateSubworkflowId(nameForIdGeneration, application, model, method), + name, + application: application.toJSON(), + properties: lodash_1.default.sortedUniq(lodash_1.default.flatten(units.filter((x) => x.resultNames).map((x) => x.resultNames))), + model: { + ...model.toJSON(), + method: method.toJSON(), + }, + units: units.map((unit) => (unit.toJSON ? unit.toJSON() : unit)), + }); + } + setApplication(application) { + // TODO: adjust the logic above to take into account whether units need re-rendering after version change etc. + // reset units if application name changes + const previousApplicationName = this.application.name; + this.applicationInstance = application; + if (previousApplicationName !== application.name) { + // TODO: figure out how to set a default unit per new application instead of removing all + this.setUnits([]); + } + else { + // propagate new application version to all units + this.units + .filter((unit) => typeof unit.setApplication === "function") + .forEach((unit) => unit.setApplication(this.applicationInstance, true)); + } + this.application = application.toJSON(); + // set model to the default one for the application selected + this.setModel(this.ModelFactory.createFromApplication({ + application: this.application, + })); + } + setModel(model) { + this.modelInstance = model; + } + setUnits(units) { + this.unitsInstances = units; + } + toJSON(exclude = []) { + return { + ...super.toJSON(exclude), + model: this.modelInstance.toJSON(), + units: this.unitsInstances.map((x) => x.toJSON()), + ...(this.compute ? { compute: this.compute } : {}), // {"compute": null } won't pass esse validation + }; + } + get contextProviders() { + const unitsWithContextProviders = this.units.filter((u) => u.allContextProviders && u.allContextProviders.length); + const allContextProviders = underscore_1.default.flatten(unitsWithContextProviders.map((u) => u.allContextProviders)); + const subworkflowContextProviders = allContextProviders.filter((p) => p.entityName === "subworkflow"); + return underscore_1.default.uniq(subworkflowContextProviders, (p) => p.name); + } + /** + * Extracts a reduced version of the entity config to be stored inside redux state. + * This is used to track changes to context, monitors, properties, etc. when multiple materials are in state. + */ + extractReducedExternalDependentConfig() { + return { + id: this.id, + context: this.context || {}, + units: this.units.map((unit) => unit.extractReducedExternalDependentConfig()), + }; + } + /** + * Applies the reduced config obtained from extractReducedExternalDependentConfig on the entity. + */ + applyReducedExternalDependentConfig(config) { + this.context = config.context || {}; + this.units.forEach((unit) => { + const unitConfig = (config.units || []).find((c) => c.id === unit.flowchartId); + unit.applyReducedExternalDependentConfig(unitConfig || {}); + }); + } + get contextFromAssignmentUnits() { + const ctx = {}; + this.units + .filter((u) => u.type === enums_1.UNIT_TYPES.assignment) + .forEach((u) => { + ctx[u.operand] = u.value; + }); + return ctx; + } + render(context = {}) { + const ctx = { + ...context, + application: this.application, + methodData: this.model.Method.data, + model: this.model.toJSON(), + // context below is assembled from context providers and passed to units to override theirs + ...this.context, + subworkflowContext: this.contextFromAssignmentUnits, + }; + this.units.forEach((u) => u.render(ctx)); + } + /** + * TODO: reuse workflow function instead + */ + addUnit(unit, index = -1) { + const { units } = this; + if (units.length === 0) { + unit.head = true; + this.setUnits([unit]); + } + else { + if (index >= 0) + units.splice(index, 0, unit); + else + units.push(unit); + this.setUnits((0, utils_2.setNextLinks)((0, utils_2.setUnitsHead)(units))); + } + } + removeUnit(flowchartId) { + const previousUnit = this.units.find((x) => x.next === flowchartId); + if (previousUnit) + previousUnit.unsetProp("next"); + // TODO: remove the setNextLinks and setUnitsHead and handle the logic via flowchart designer + this.setUnits((0, utils_2.setNextLinks)((0, utils_2.setUnitsHead)(this.units.filter((x) => x.flowchartId !== flowchartId)))); + } + get properties() { + return lodash_1.default.flatten(this.units.map((x) => x.resultNames)); + } + getUnit(flowchartId) { + return this.units.find((x) => x.flowchartId === flowchartId); + } + unitIndex(flowchartId) { + return lodash_1.default.findIndex(this.units, (unit) => { + return unit.flowchartId === flowchartId; + }); + } + replaceUnit(index, unit) { + this.units[index] = unit; + this.setUnits((0, utils_2.setNextLinks)((0, utils_2.setUnitsHead)(this.units))); + } + // eslint-disable-next-line class-methods-use-this + get scopeVariables() { + return ["N_k", "N_k_nonuniform"]; + } + // eslint-disable-next-line class-methods-use-this + get scalarResults() { + return ["total_energy", "pressure"]; + } + get isMultiMaterial() { + return this.prop("isMultiMaterial", false); + } + get isDraft() { + return this.prop("isDraft", false); + } + setIsDraft(bool) { + return this.setProp("isDraft", bool); + } + get methodData() { + return this.model.Method.data; + } + /** + * @summary Calculates hash of the subworkflow. Meaningful fields are units, app and model. + * units must be sorted topologically before hashing (already sorted). + */ + calculateHash() { + const config = this.toJSON(); + const meaningfulFields = { + application: utils_1.Utils.specific.removeTimestampableKeysFromConfig(config.application), + model: this._calculateModelHash(), + units: underscore_1.default.map(this.units, (u) => u.calculateHash()).join(), + }; + return utils_1.Utils.hash.calculateHashFromObject(meaningfulFields); + } + _calculateModelHash() { + const { model } = this.toJSON(); + // ignore empty data object + if (this.model.Method.omitInHashCalculation) + delete model.method.data; + return utils_1.Utils.hash.calculateHashFromObject(model); + } + findUnitById(id) { + // TODO: come back and refactor after converting flowchartId to id + return this.units.find((u) => u.flowchartId === id); + } + findUnitKeyById(id) { + const index = this.units.findIndex((u) => u.flowchartId === id); + return `units.${index}`; + } + findUnitWithTag(tag) { + return this.units.find((unit) => unit.tags.includes(tag)); + } + get hasConvergence() { + return !!this.convergenceParam && !!this.convergenceResult && !!this.convergenceSeries; + } } exports.Subworkflow = Subworkflow; -_defineProperty(Subworkflow, "usePredefinedIds", false); \ No newline at end of file +Subworkflow.usePredefinedIds = false; +(0, NamedEntityMixin_1.namedEntityMixin)(Subworkflow.prototype); +(0, DefaultableMixin_1.defaultableEntityMixin)(Subworkflow); +(0, SubworkflowSchemaMixin_1.subworkflowSchemaMixin)(Subworkflow.prototype); diff --git a/dist/js/units/AssertionUnit.d.ts b/dist/js/units/AssertionUnit.d.ts new file mode 100644 index 00000000..50b4fd43 --- /dev/null +++ b/dist/js/units/AssertionUnit.d.ts @@ -0,0 +1,15 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { AssertionUnitSchema } from "@mat3ra/esse/dist/js/types"; +import { type AssertionUnitSchemaMixin } from "../generated/AssertionUnitSchemaMixin"; +import { BaseUnit } from "./BaseUnit"; +type Schema = AssertionUnitSchema; +type Base = typeof BaseUnit & Constructor; +declare const AssertionUnit_base: Base; +export declare class AssertionUnit extends AssertionUnit_base implements Schema { + constructor(config: Partial); + getHashObject(): { + statement: string; + errorMessage: string | undefined; + }; +} +export {}; diff --git a/dist/js/units/AssertionUnit.js b/dist/js/units/AssertionUnit.js new file mode 100644 index 00000000..1516fefb --- /dev/null +++ b/dist/js/units/AssertionUnit.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AssertionUnit = void 0; +const enums_1 = require("../enums"); +const AssertionUnitSchemaMixin_1 = require("../generated/AssertionUnitSchemaMixin"); +const BaseUnit_1 = require("./BaseUnit"); +class AssertionUnit extends BaseUnit_1.BaseUnit { + constructor(config) { + super({ + name: enums_1.UnitType.assertion, + type: enums_1.UnitType.assertion, + statement: "true", + errorMessage: "assertion failed", + ...config, + }); + } + getHashObject() { + return { statement: this.statement, errorMessage: this.errorMessage }; + } +} +exports.AssertionUnit = AssertionUnit; +(0, AssertionUnitSchemaMixin_1.assertionUnitSchemaMixin)(AssertionUnit.prototype); diff --git a/dist/js/units/AssignmentUnit.d.ts b/dist/js/units/AssignmentUnit.d.ts new file mode 100644 index 00000000..122ab4c2 --- /dev/null +++ b/dist/js/units/AssignmentUnit.d.ts @@ -0,0 +1,12 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { AssignmentUnitSchema } from "@mat3ra/esse/dist/js/types"; +import { type AssignmentUnitSchemaMixin } from "../generated/AssignmentUnitSchemaMixin"; +import { BaseUnit } from "./BaseUnit"; +type Schema = AssignmentUnitSchema; +type Base = typeof BaseUnit & Constructor; +declare const AssignmentUnit_base: Base; +export declare class AssignmentUnit extends AssignmentUnit_base implements Schema { + constructor(config: Partial); + getHashObject(): object; +} +export {}; diff --git a/dist/js/units/AssignmentUnit.js b/dist/js/units/AssignmentUnit.js new file mode 100644 index 00000000..560af1ba --- /dev/null +++ b/dist/js/units/AssignmentUnit.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AssignmentUnit = void 0; +const enums_1 = require("../enums"); +const AssignmentUnitSchemaMixin_1 = require("../generated/AssignmentUnitSchemaMixin"); +const BaseUnit_1 = require("./BaseUnit"); +class AssignmentUnit extends BaseUnit_1.BaseUnit { + constructor(config) { + super({ + name: enums_1.UnitType.assignment, + type: enums_1.UnitType.assignment, + operand: "X", + value: "1", + input: [], + ...config, + }); + } + getHashObject() { + return { input: this.input, operand: this.operand, value: this.value }; + } +} +exports.AssignmentUnit = AssignmentUnit; +(0, AssignmentUnitSchemaMixin_1.assignmentUnitSchemaMixin)(AssignmentUnit.prototype); diff --git a/dist/js/units/BaseUnit.d.ts b/dist/js/units/BaseUnit.d.ts new file mode 100644 index 00000000..a0e1ed5b --- /dev/null +++ b/dist/js/units/BaseUnit.d.ts @@ -0,0 +1,37 @@ +import { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import { type Defaultable } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"; +import { HashedEntity } from "@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin"; +import { HasRepetition } from "@mat3ra/code/dist/js/entity/mixins/HasRepetitionMixin"; +import { type NamedEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"; +import { type RuntimeItems } from "@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"; +import { Taggable } from "@mat3ra/code/dist/js/entity/mixins/TaggableMixin"; +import type { NameResultSchema } from "@mat3ra/code/dist/js/utils/object"; +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { StatusSchema, WorkflowBaseUnitSchema } from "@mat3ra/esse/dist/js/types"; +import { type BaseUnitSchemaMixin } from "../generated/BaseUnitSchemaMixin"; +import { type StatusSchemaMixin } from "../generated/StatusSchemaMixin"; +import { type RuntimeItemsUILogic } from "../RuntimeItemsUILogicMixin"; +type Base = typeof InMemoryEntity & Constructor & Constructor & Constructor & Constructor & Constructor & Constructor & Constructor & Constructor & Constructor; +type Schema = WorkflowBaseUnitSchema; +declare const BaseUnit_base: Base; +export declare class BaseUnit extends BaseUnit_base implements Schema { + static usePredefinedIds: boolean; + static generateFlowChartId(name: string): any; + defaultResults: NameResultSchema[]; + defaultMonitors: NameResultSchema[]; + defaultPostProcessors: NameResultSchema[]; + defaultPreProcessors: NameResultSchema[]; + allowedResults: NameResultSchema[]; + allowedMonitors: NameResultSchema[]; + allowedPostProcessors: NameResultSchema[]; + constructor(config: Partial & Pick); + get lastStatusUpdate(): { + trackedAt: number; + status: string; + repetition?: number; + }; + getHashObject(): object; + isInStatus(status: StatusSchema["status"]): boolean; + clone(extraContext: object): this; +} +export {}; diff --git a/dist/js/units/BaseUnit.js b/dist/js/units/BaseUnit.js new file mode 100644 index 00000000..822f5494 --- /dev/null +++ b/dist/js/units/BaseUnit.js @@ -0,0 +1,75 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BaseUnit = void 0; +/* eslint-disable class-methods-use-this */ +const entity_1 = require("@mat3ra/code/dist/js/entity"); +const DefaultableMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/DefaultableMixin"); +const HashedEntityMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin"); +const HasRepetitionMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/HasRepetitionMixin"); +const NamedEntityMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin"); +const RuntimeItemsMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/RuntimeItemsMixin"); +const TaggableMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/TaggableMixin"); +const utils_1 = require("@mat3ra/utils"); +const enums_1 = require("../enums"); +const BaseUnitSchemaMixin_1 = require("../generated/BaseUnitSchemaMixin"); +const StatusSchemaMixin_1 = require("../generated/StatusSchemaMixin"); +const RuntimeItemsUILogicMixin_1 = require("../RuntimeItemsUILogicMixin"); +// eslint-disable-next-line prettier/prettier +class BaseUnit extends entity_1.InMemoryEntity { + static generateFlowChartId(name) { + if (this.usePredefinedIds) { + return utils_1.Utils.uuid.getUUIDFromNamespace(`flowchart-${name}`); + } + return utils_1.Utils.uuid.getUUID(); + } + constructor(config) { + super({ + results: [], + monitors: [], + preProcessors: [], + postProcessors: [], + ...config, + status: config.status || enums_1.UNIT_STATUSES.idle, + statusTrack: config.statusTrack || [], + flowchartId: config.flowchartId || BaseUnit.generateFlowChartId(config.name), + tags: config.tags || [], + }); + this.defaultResults = []; + this.defaultMonitors = []; + this.defaultPostProcessors = []; + this.defaultPreProcessors = []; + this.allowedResults = []; + this.allowedMonitors = []; + this.allowedPostProcessors = []; + this._initRuntimeItems(config); + } + get lastStatusUpdate() { + const statusTrack = (this.statusTrack || []).filter((s) => (s.repetition || 0) === this.repetition); + const sortedStatusTrack = statusTrack.sort((a, b) => a.trackedAt - b.trackedAt); // lodash.sortBy(statusTrack, (x) => x.trackedAt); + return sortedStatusTrack[sortedStatusTrack.length - 1]; + } + getHashObject() { + return { ...this.hashObjectFromRuntimeItems, type: this.type }; + } + isInStatus(status) { + return this.status === status; + } + clone(extraContext) { + const flowchartIDOverrideConfigAsExtraContext = { + flowchartId: BaseUnit.generateFlowChartId(this.name), + ...extraContext, + }; + return super.clone(flowchartIDOverrideConfigAsExtraContext); + } +} +exports.BaseUnit = BaseUnit; +BaseUnit.usePredefinedIds = false; +(0, TaggableMixin_1.taggableMixin)(BaseUnit.prototype); +(0, HashedEntityMixin_1.hashedEntityMixin)(BaseUnit.prototype); +(0, HasRepetitionMixin_1.hasRepetitionMixin)(BaseUnit.prototype); +(0, RuntimeItemsMixin_1.runtimeItemsMixin)(BaseUnit.prototype); +(0, RuntimeItemsUILogicMixin_1.runtimeItemsUILogicMixin)(BaseUnit.prototype); +(0, BaseUnitSchemaMixin_1.baseUnitSchemaMixin)(BaseUnit.prototype); +(0, StatusSchemaMixin_1.statusSchemaMixin)(BaseUnit.prototype); +(0, NamedEntityMixin_1.namedEntityMixin)(BaseUnit.prototype); +(0, DefaultableMixin_1.defaultableEntityMixin)(BaseUnit); diff --git a/dist/js/units/ConditionUnit.d.ts b/dist/js/units/ConditionUnit.d.ts new file mode 100644 index 00000000..bccbca4c --- /dev/null +++ b/dist/js/units/ConditionUnit.d.ts @@ -0,0 +1,12 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { ConditionUnitSchema } from "@mat3ra/esse/dist/js/types"; +import { type ConditionUnitSchemaMixin } from "../generated/ConditionUnitSchemaMixin"; +import { BaseUnit } from "./BaseUnit"; +type Schema = ConditionUnitSchema; +type Base = typeof BaseUnit & Constructor; +declare const ConditionUnit_base: Base; +export declare class ConditionUnit extends ConditionUnit_base implements Schema { + constructor(config: Partial); + getHashObject(): object; +} +export {}; diff --git a/dist/js/units/ConditionUnit.js b/dist/js/units/ConditionUnit.js new file mode 100644 index 00000000..dda98e43 --- /dev/null +++ b/dist/js/units/ConditionUnit.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ConditionUnit = void 0; +const enums_1 = require("../enums"); +const ConditionUnitSchemaMixin_1 = require("../generated/ConditionUnitSchemaMixin"); +const BaseUnit_1 = require("./BaseUnit"); +class ConditionUnit extends BaseUnit_1.BaseUnit { + constructor(config) { + super({ + name: enums_1.UnitType.condition, + type: enums_1.UnitType.condition, + input: [], + results: [], + preProcessors: [], + postProcessors: [], + then: undefined, + else: undefined, + statement: "true", + maxOccurrences: 100, + ...config, + }); + } + getHashObject() { + return { statement: this.statement, maxOccurrences: this.maxOccurrences }; + } +} +exports.ConditionUnit = ConditionUnit; +(0, ConditionUnitSchemaMixin_1.conditionUnitSchemaMixin)(ConditionUnit.prototype); diff --git a/dist/js/units/ExecutionUnit.d.ts b/dist/js/units/ExecutionUnit.d.ts new file mode 100644 index 00000000..e7e21145 --- /dev/null +++ b/dist/js/units/ExecutionUnit.d.ts @@ -0,0 +1,51 @@ +import { Application, Executable, Flavor } from "@mat3ra/ade"; +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types"; +import type { ExecutableSchema, ExecutionUnitSchemaBase, FlavorSchema } from "@mat3ra/esse/dist/js/types"; +import { type ImportantSettingsProvider } from "../context/mixins/ImportantSettingsProviderMixin"; +import type { ContextItem } from "../context/providers/base/ContextProvider"; +import ExecutionUnitInput from "../ExecutionUnitInput"; +import { type ExecutionUnitSchemaMixin } from "../generated/ExecutionUnitSchemaMixin"; +import { BaseUnit } from "./BaseUnit"; +type Schema = ExecutionUnitSchemaBase; +type Base = typeof BaseUnit & Constructor & Constructor; +interface SetApplicationProps { + application: Application; + executable?: Executable | ExecutableSchema; + flavor?: Flavor | FlavorSchema; +} +interface SetExecutableProps { + executable?: Executable | ExecutableSchema; + flavor?: Flavor | FlavorSchema; +} +export type ExecutionUnitSchema = Schema; +declare const ExecutionUnit_base: Base; +export declare class ExecutionUnit extends ExecutionUnit_base implements Schema { + applicationInstance: Application; + executableInstance: Executable; + flavorInstance: Flavor; + inputInstances: ExecutionUnitInput[]; + renderingContext: ContextItem[]; + constructor(config: Schema); + setApplication({ application, executable, flavor }: SetApplicationProps): void; + setExecutable({ executable, flavor }: SetExecutableProps): void; + setFlavor(flavor?: Flavor | FlavorSchema): void; + setDefaultInput(): void; + get allContextProviders(): import("../context/providers/base/ContextProvider").default[]; + get contextProviders(): import("../context/providers/base/ContextProvider").default[]; + /** Update rendering context and persistent context + * Note: this function is sometimes being called without passing a context! + */ + render(context?: AnyObject): void; + /** + * @summary Calculates hash on unit-specific fields. + * The meaningful fields of processing unit are operation, flavor and input at the moment. + */ + getHashObject(): { + application: {}; + executable: {}; + flavor: {} | undefined; + input: string; + }; +} +export {}; diff --git a/dist/js/units/ExecutionUnit.js b/dist/js/units/ExecutionUnit.js new file mode 100644 index 00000000..dfe92ff8 --- /dev/null +++ b/dist/js/units/ExecutionUnit.js @@ -0,0 +1,116 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ExecutionUnit = void 0; +const ade_1 = require("@mat3ra/ade"); +const utils_1 = require("@mat3ra/utils"); +const ContextAndRenderFieldsMixin_1 = require("../context/mixins/ContextAndRenderFieldsMixin"); +const ImportantSettingsProviderMixin_1 = require("../context/mixins/ImportantSettingsProviderMixin"); +const ExecutionUnitInput_1 = __importDefault(require("../ExecutionUnitInput")); +const ExecutionUnitSchemaMixin_1 = require("../generated/ExecutionUnitSchemaMixin"); +const BaseUnit_1 = require("./BaseUnit"); +class ExecutionUnit extends BaseUnit_1.BaseUnit { + constructor(config) { + var _a; + super(config); + this.inputInstances = []; + this.renderingContext = []; + const { application, executable, flavor } = config; + const applicationInstance = ade_1.ApplicationRegistry.createApplication(application); + const executableInstance = ade_1.ApplicationRegistry.getExecutableByConfig(application.name, executable); + const flavorInstance = ade_1.ApplicationRegistry.getFlavorByConfig(executableInstance, flavor); + if (!flavorInstance) { + throw new Error("Flavor is not set"); + } + this.setApplication({ + application: applicationInstance, + executable: executableInstance, + flavor: flavorInstance, + }); + this.name = this.name || ((_a = this.flavor) === null || _a === void 0 ? void 0 : _a.name) || ""; + } + setApplication({ application, executable, flavor }) { + this.applicationInstance = application; + this.setProp("application", application.toJSON()); + this.setExecutable({ executable, flavor }); + } + setExecutable({ executable, flavor }) { + const defaultExecutable = ade_1.ApplicationRegistry.getExecutableByName(this.application.name); + const instance = executable instanceof ade_1.Executable + ? executable + : new ade_1.Executable(executable !== null && executable !== void 0 ? executable : defaultExecutable.toJSON()); + this.allowedResults = instance.results; + this.allowedMonitors = instance.monitors; + this.allowedPostProcessors = instance.postProcessors; + this.setProp("executable", instance.toJSON()); + this.setFlavor(flavor); + } + setFlavor(flavor) { + const defaultFlavor = ade_1.ApplicationRegistry.getFlavorByConfig(this.executableInstance); + const instance = flavor instanceof ade_1.Flavor ? flavor : new ade_1.Flavor(flavor !== null && flavor !== void 0 ? flavor : defaultFlavor === null || defaultFlavor === void 0 ? void 0 : defaultFlavor.toJSON()); + if (!instance) { + throw new Error("Flavor is not found for executable"); + } + this.flavorInstance = instance; + this.defaultMonitors = instance.monitors; + this.defaultResults = instance.results; + this.defaultPostProcessors = instance.postProcessors; + this.setProp("flavor", instance.toJSON()); + this.setRuntimeItemsToDefaultValues(); + this.setDefaultInput(); + } + setDefaultInput() { + const inputs = ade_1.ApplicationRegistry.getInput(this.flavorInstance); + this.inputInstances = inputs.map(ExecutionUnitInput_1.default.createFromTemplate); + } + get allContextProviders() { + return this.inputInstances.map((input) => input.contextProvidersInstances).flat(); + } + get contextProviders() { + return this.allContextProviders.filter((p) => p.entityName === "unit"); + } + /** Update rendering context and persistent context + * Note: this function is sometimes being called without passing a context! + */ + render(context = {}) { + this.renderingContext = { ...this.renderingContext, ...context }; + const newInput = []; + const newPersistentContext = []; + const newRenderingContext = []; + this.inputInstances.forEach((input) => { + input.setContext(this.renderingContext); + input.render(); + const inputJSON = input.toJSON(); + const context = input.getFullContext(); + newInput.push(inputJSON); + newRenderingContext.push(...context); + newPersistentContext.push(...context.filter((c) => c.isEdited)); + }); + this.input = newInput; + this.renderingContext = newRenderingContext; + this.context = newPersistentContext; + } + /** + * @summary Calculates hash on unit-specific fields. + * The meaningful fields of processing unit are operation, flavor and input at the moment. + */ + getHashObject() { + return { + ...super.getHashObject(), + application: utils_1.Utils.specific.removeTimestampableKeysFromConfig(this.applicationInstance.toJSON()), + executable: utils_1.Utils.specific.removeTimestampableKeysFromConfig(this.executableInstance.toJSON()), + flavor: this.flavorInstance + ? utils_1.Utils.specific.removeTimestampableKeysFromConfig(this.flavorInstance.toJSON()) + : undefined, + input: utils_1.Utils.hash.calculateHashFromObject(this.input.map((i) => { + return utils_1.Utils.str.removeEmptyLinesFromString(utils_1.Utils.str.removeCommentsFromSourceCode(i.template.content)); + })), + }; + } +} +exports.ExecutionUnit = ExecutionUnit; +(0, ExecutionUnitSchemaMixin_1.executionUnitSchemaMixin)(ExecutionUnit.prototype); +(0, ContextAndRenderFieldsMixin_1.contextMixin)(ExecutionUnit.prototype); +(0, ImportantSettingsProviderMixin_1.importantSettingsProviderMixin)(ExecutionUnit.prototype); diff --git a/dist/js/units/IOUnit.d.ts b/dist/js/units/IOUnit.d.ts new file mode 100644 index 00000000..65fb01bf --- /dev/null +++ b/dist/js/units/IOUnit.d.ts @@ -0,0 +1,11 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { DataIOUnitSchema } from "@mat3ra/esse/dist/js/types"; +import { type IOUnitSchemaMixin } from "../generated/IOUnitSchemaMixin"; +import { BaseUnit } from "./BaseUnit"; +type Schema = DataIOUnitSchema; +type Base = typeof BaseUnit & Constructor; +declare const IOUnit_base: Base; +export declare class IOUnit extends IOUnit_base implements Schema { + constructor(config: Partial); +} +export {}; diff --git a/dist/js/units/IOUnit.js b/dist/js/units/IOUnit.js new file mode 100644 index 00000000..350ae782 --- /dev/null +++ b/dist/js/units/IOUnit.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IOUnit = void 0; +const enums_1 = require("../enums"); +const IOUnitSchemaMixin_1 = require("../generated/IOUnitSchemaMixin"); +const BaseUnit_1 = require("./BaseUnit"); +class IOUnit extends BaseUnit_1.BaseUnit { + constructor(config) { + super({ name: enums_1.UnitType.io, subtype: "input", ...config, type: enums_1.UnitType.io }); + } +} +exports.IOUnit = IOUnit; +(0, IOUnitSchemaMixin_1.iOUnitSchemaMixin)(IOUnit.prototype); diff --git a/dist/js/units/MapUnit.d.ts b/dist/js/units/MapUnit.d.ts new file mode 100644 index 00000000..b2f91acf --- /dev/null +++ b/dist/js/units/MapUnit.d.ts @@ -0,0 +1,25 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { MapUnitSchema } from "@mat3ra/esse/dist/js/types"; +import { UnitType } from "../enums"; +import { type MapUnitSchemaMixin } from "../generated/MapUnitSchemaMixin"; +import { BaseUnit } from "./BaseUnit"; +type Schema = MapUnitSchema; +export declare const defaultMapConfig: { + name: string; + type: UnitType.map; + workflowId: string; + input: { + target: string; + scope: string; + name: string; + values: never[]; + useValues: boolean; + }; +}; +type Base = typeof BaseUnit & Constructor; +declare const MapUnit_base: Base; +export declare class MapUnit extends MapUnit_base implements Schema { + constructor(config: Partial); + setWorkflowId(id: string): void; +} +export {}; diff --git a/dist/js/units/MapUnit.js b/dist/js/units/MapUnit.js new file mode 100644 index 00000000..a412f06f --- /dev/null +++ b/dist/js/units/MapUnit.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MapUnit = exports.defaultMapConfig = void 0; +const enums_1 = require("../enums"); +const MapUnitSchemaMixin_1 = require("../generated/MapUnitSchemaMixin"); +const BaseUnit_1 = require("./BaseUnit"); +exports.defaultMapConfig = { + name: enums_1.UnitType.map, + type: enums_1.UnitType.map, + workflowId: "", + input: { + target: "MAP_DATA", + scope: "global", + name: "", + values: [], + useValues: false, + }, +}; +class MapUnit extends BaseUnit_1.BaseUnit { + constructor(config) { + super({ ...exports.defaultMapConfig, ...config }); + } + setWorkflowId(id) { + this.setProp("workflowId", id); + } +} +exports.MapUnit = MapUnit; +(0, MapUnitSchemaMixin_1.mapUnitSchemaMixin)(MapUnit.prototype); diff --git a/dist/js/units/ProcessingUnit.d.ts b/dist/js/units/ProcessingUnit.d.ts new file mode 100644 index 00000000..05d1c5db --- /dev/null +++ b/dist/js/units/ProcessingUnit.d.ts @@ -0,0 +1,14 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { ProcessingUnitSchema } from "@mat3ra/esse/dist/js/types"; +import { type ProcessingUnitSchemaMixin } from "../generated/ProcessingUnitSchemaMixin"; +import { BaseUnit } from "./BaseUnit"; +type Schema = ProcessingUnitSchema; +type Base = typeof BaseUnit & Constructor; +declare const ProcessingUnit_base: Base; +export declare class ProcessingUnit extends ProcessingUnit_base implements Schema { + constructor(config: Partial); + setOperation(op: ProcessingUnitSchema["operation"]): void; + setOperationType(type: ProcessingUnitSchema["operationType"]): void; + setInput(input: ProcessingUnitSchema["inputData"]): void; +} +export {}; diff --git a/dist/js/units/ProcessingUnit.js b/dist/js/units/ProcessingUnit.js new file mode 100644 index 00000000..c861e349 --- /dev/null +++ b/dist/js/units/ProcessingUnit.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ProcessingUnit = void 0; +const enums_1 = require("../enums"); +const ProcessingUnitSchemaMixin_1 = require("../generated/ProcessingUnitSchemaMixin"); +const BaseUnit_1 = require("./BaseUnit"); +class ProcessingUnit extends BaseUnit_1.BaseUnit { + constructor(config) { + super({ + name: enums_1.UnitType.processing, + type: enums_1.UnitType.processing, + ...config, + }); + } + setOperation(op) { + this.setProp("operation", op); + } + setOperationType(type) { + this.setProp("operationType", type); + } + setInput(input) { + this.setProp("inputData", input); + } +} +exports.ProcessingUnit = ProcessingUnit; +(0, ProcessingUnitSchemaMixin_1.processingUnitSchemaMixin)(ProcessingUnit.prototype); diff --git a/dist/js/units/ReduceUnit.d.ts b/dist/js/units/ReduceUnit.d.ts new file mode 100644 index 00000000..6ff8fd18 --- /dev/null +++ b/dist/js/units/ReduceUnit.d.ts @@ -0,0 +1,11 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { ReduceUnitSchema } from "@mat3ra/esse/dist/js/types"; +import { type ReduceUnitSchemaMixin } from "../generated/ReduceUnitSchemaMixin"; +import { BaseUnit } from "./BaseUnit"; +type Schema = ReduceUnitSchema; +type Base = typeof BaseUnit & Constructor; +declare const ReduceUnit_base: Base; +export declare class ReduceUnit extends ReduceUnit_base implements Schema { + constructor(unitName: string, mapUnit: string, input: ReduceUnitSchema["input"]); +} +export {}; diff --git a/dist/js/units/ReduceUnit.js b/dist/js/units/ReduceUnit.js new file mode 100644 index 00000000..e1a4bf82 --- /dev/null +++ b/dist/js/units/ReduceUnit.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ReduceUnit = void 0; +const enums_1 = require("../enums"); +const ReduceUnitSchemaMixin_1 = require("../generated/ReduceUnitSchemaMixin"); +const BaseUnit_1 = require("./BaseUnit"); +class ReduceUnit extends BaseUnit_1.BaseUnit { + constructor(unitName, mapUnit, input) { + super({ type: enums_1.UnitType.reduce, name: unitName, mapFlowchartId: mapUnit, input }); + } +} +exports.ReduceUnit = ReduceUnit; +(0, ReduceUnitSchemaMixin_1.reduceUnitSchemaMixin)(ReduceUnit.prototype); diff --git a/dist/js/units/SubworkflowUnit.d.ts b/dist/js/units/SubworkflowUnit.d.ts new file mode 100644 index 00000000..6514b002 --- /dev/null +++ b/dist/js/units/SubworkflowUnit.d.ts @@ -0,0 +1,11 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { SubworkflowUnitSchema } from "@mat3ra/esse/dist/js/types"; +import { type SubworkflowUnitSchemaMixin } from "../generated/SubworkflowUnitSchemaMixin"; +import { BaseUnit } from "./BaseUnit"; +type Schema = SubworkflowUnitSchema; +type Base = typeof BaseUnit & Constructor; +declare const SubworkflowUnit_base: Base; +export declare class SubworkflowUnit extends SubworkflowUnit_base implements Schema { + constructor(config: Partial); +} +export {}; diff --git a/dist/js/units/SubworkflowUnit.js b/dist/js/units/SubworkflowUnit.js new file mode 100644 index 00000000..fadfe201 --- /dev/null +++ b/dist/js/units/SubworkflowUnit.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SubworkflowUnit = void 0; +const enums_1 = require("../enums"); +const SubworkflowUnitSchemaMixin_1 = require("../generated/SubworkflowUnitSchemaMixin"); +const BaseUnit_1 = require("./BaseUnit"); +class SubworkflowUnit extends BaseUnit_1.BaseUnit { + constructor(config) { + super({ name: "New Subworkflow", ...config, type: enums_1.UnitType.subworkflow }); + } +} +exports.SubworkflowUnit = SubworkflowUnit; +(0, SubworkflowUnitSchemaMixin_1.subworkflowUnitSchemaMixin)(SubworkflowUnit.prototype); diff --git a/dist/js/units/assertion.js b/dist/js/units/assertion.js deleted file mode 100644 index 21895761..00000000 --- a/dist/js/units/assertion.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.AssertionUnit = void 0; -var _enums = require("../enums"); -var _base = require("./base"); -class AssertionUnit extends _base.BaseUnit { - constructor(config) { - super({ - ...AssertionUnit.getAssertionConfig(), - ...config - }); - } - static getAssertionConfig() { - return { - name: _enums.UNIT_TYPES.assertion, - type: _enums.UNIT_TYPES.assertion, - statement: "true", - errorMessage: "assertion failed" - }; - } - get statement() { - return this.prop("statement"); - } - get errorMessage() { - return this.prop("errorMessage"); - } - getHashObject() { - return { - statement: this.statement, - errorMessage: this.errorMessage - }; - } -} -exports.AssertionUnit = AssertionUnit; \ No newline at end of file diff --git a/dist/js/units/assignment.js b/dist/js/units/assignment.js deleted file mode 100644 index daecf8d0..00000000 --- a/dist/js/units/assignment.js +++ /dev/null @@ -1,42 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.AssignmentUnit = void 0; -var _enums = require("../enums"); -var _base = require("./base"); -class AssignmentUnit extends _base.BaseUnit { - constructor(config) { - super({ - ...AssignmentUnit.getAssignmentConfig(), - ...config - }); - } - static getAssignmentConfig() { - return { - name: _enums.UNIT_TYPES.assignment, - type: _enums.UNIT_TYPES.assignment, - operand: "X", - value: "1", - input: [] - }; - } - get operand() { - return this.prop("operand"); - } - get value() { - return this.prop("value"); - } - get input() { - return this.prop("input"); - } - getHashObject() { - return { - input: this.input, - operand: this.operand, - value: this.value - }; - } -} -exports.AssignmentUnit = AssignmentUnit; \ No newline at end of file diff --git a/dist/js/units/base.js b/dist/js/units/base.js deleted file mode 100644 index 0f768073..00000000 --- a/dist/js/units/base.js +++ /dev/null @@ -1,91 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.BaseUnit = void 0; -var _entity = require("@mat3ra/code/dist/js/entity"); -var _TaggableMixin = require("@mat3ra/code/dist/js/entity/mixins/TaggableMixin"); -var _utils = require("@mat3ra/utils"); -var _lodash = _interopRequireDefault(require("lodash")); -var _enums = require("../enums"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -// eslint-disable-next-line max-len -class BaseUnit extends _entity.NamedDefaultableRepetitionRuntimeItemsImportantSettingsContextAndRenderHashedInMemoryEntity { - constructor(config) { - const flowchartId = config.flowchartId || BaseUnit.generateFlowChartId.call(new.target, config.name); - super({ - ...config, - status: config.status || _enums.UNIT_STATUSES.idle, - statusTrack: config.statusTrack || [], - flowchartId, - tags: config.tags || [] - }); - } - static generateFlowChartId(...args) { - args[0] = `flowchart-${args[0]}`; - if (this.usePredefinedIds) return _utils.Utils.uuid.getUUIDFromNamespace(...args); - return _utils.Utils.uuid.getUUID(); - } - get flowchartId() { - return this.prop("flowchartId"); - } - get head() { - return this.prop("head", false); - } - set head(bool) { - this.setProp("head", bool); - } - get next() { - return this.prop("next"); - } - set next(flowchartId) { - this.setProp("next", flowchartId); - } - get status() { - return _lodash.default.get(this.lastStatusUpdate, "status") || _enums.UNIT_STATUSES.idle; - } - set status(s) { - this.setProp("status", s); - } - get lastStatusUpdate() { - const statusTrack = this.prop("statusTrack", []).filter(s => (s.repetition || 0) === this.repetition); - const sortedStatusTrack = _lodash.default.sortBy(statusTrack || [], x => x.trackedAt); - return sortedStatusTrack[sortedStatusTrack.length - 1]; - } - get type() { - return this.prop("type"); - } - get isDraft() { - return this.prop("isDraft", false); - } - getHashObject() { - return { - ...this.hashObjectFromRuntimeItems, - type: this.type - }; - } - - /** - * Checks whether a unit is currently in a given status (e.g. idle, active, etc). The full list can be found - * in the UNIT_STATUSES variable in enums.js. - * @param status (String) name of the status to check - * @returns Boolean - */ - isInStatus(status) { - return this.status === status; - } - clone(extraContext) { - const flowchartIDOverrideConfigAsExtraContext = { - flowchartId: this.constructor.generateFlowChartId(), - ...extraContext - }; - return super.clone(flowchartIDOverrideConfigAsExtraContext); - } -} -exports.BaseUnit = BaseUnit; -_defineProperty(BaseUnit, "usePredefinedIds", false); -(0, _TaggableMixin.taggableMixin)(BaseUnit.prototype); \ No newline at end of file diff --git a/dist/js/units/builders/AssertionUnitConfigBuilder.d.ts b/dist/js/units/builders/AssertionUnitConfigBuilder.d.ts new file mode 100644 index 00000000..85878114 --- /dev/null +++ b/dist/js/units/builders/AssertionUnitConfigBuilder.d.ts @@ -0,0 +1,20 @@ +export class AssertionUnitConfigBuilder extends UnitConfigBuilder { + constructor(name: any, statement: any, errorMessage: any); + _statement: any; + _errorMessage: any; + statement(str: any): this; + errorMessage(str: any): this; + build(): { + statement: any; + errorMessage: any; + type: any; + name: any; + head: boolean; + results: any[]; + monitors: any[]; + flowchartId: any; + preProcessors: any[]; + postProcessors: any[]; + }; +} +import { UnitConfigBuilder } from "./UnitConfigBuilder"; diff --git a/dist/js/units/builders/AssertionUnitConfigBuilder.js b/dist/js/units/builders/AssertionUnitConfigBuilder.js index b2964aba..3bf740fd 100644 --- a/dist/js/units/builders/AssertionUnitConfigBuilder.js +++ b/dist/js/units/builders/AssertionUnitConfigBuilder.js @@ -1,34 +1,28 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.AssertionUnitConfigBuilder = void 0; -var _enums = require("../../enums"); -var _UnitConfigBuilder = require("./UnitConfigBuilder"); -class AssertionUnitConfigBuilder extends _UnitConfigBuilder.UnitConfigBuilder { - constructor(name, statement, errorMessage) { - super({ - name, - type: _enums.UNIT_TYPES.assertion - }); - this._statement = statement; - this._errorMessage = errorMessage; - } - statement(str) { - this._statement = str; - return this; - } - errorMessage(str) { - this._errorMessage = str; - return this; - } - build() { - return { - ...super.build(), - statement: this._statement, - errorMessage: this._errorMessage - }; - } +const enums_1 = require("../../enums"); +const UnitConfigBuilder_1 = require("./UnitConfigBuilder"); +class AssertionUnitConfigBuilder extends UnitConfigBuilder_1.UnitConfigBuilder { + constructor(name, statement, errorMessage) { + super({ name, type: enums_1.UNIT_TYPES.assertion }); + this._statement = statement; + this._errorMessage = errorMessage; + } + statement(str) { + this._statement = str; + return this; + } + errorMessage(str) { + this._errorMessage = str; + return this; + } + build() { + return { + ...super.build(), + statement: this._statement, + errorMessage: this._errorMessage, + }; + } } -exports.AssertionUnitConfigBuilder = AssertionUnitConfigBuilder; \ No newline at end of file +exports.AssertionUnitConfigBuilder = AssertionUnitConfigBuilder; diff --git a/dist/js/units/builders/AssignmentUnitConfigBuilder.d.ts b/dist/js/units/builders/AssignmentUnitConfigBuilder.d.ts new file mode 100644 index 00000000..a1d509eb --- /dev/null +++ b/dist/js/units/builders/AssignmentUnitConfigBuilder.d.ts @@ -0,0 +1,23 @@ +export class AssignmentUnitConfigBuilder extends UnitConfigBuilder { + constructor(name: any, variableName: any, variableValue: any, input?: any[], results?: any[]); + _variableName: any; + _variableValue: any; + _input: any[]; + input(arr: any): this; + variableName(str: any): this; + variableValue(str: any): this; + build(): { + input: any[]; + operand: any; + value: any; + type: any; + name: any; + head: boolean; + results: any[]; + monitors: any[]; + flowchartId: any; + preProcessors: any[]; + postProcessors: any[]; + }; +} +import { UnitConfigBuilder } from "./UnitConfigBuilder"; diff --git a/dist/js/units/builders/AssignmentUnitConfigBuilder.js b/dist/js/units/builders/AssignmentUnitConfigBuilder.js index a118de7b..e7991665 100644 --- a/dist/js/units/builders/AssignmentUnitConfigBuilder.js +++ b/dist/js/units/builders/AssignmentUnitConfigBuilder.js @@ -1,41 +1,35 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.AssignmentUnitConfigBuilder = void 0; -var _enums = require("../../enums"); -var _UnitConfigBuilder = require("./UnitConfigBuilder"); -class AssignmentUnitConfigBuilder extends _UnitConfigBuilder.UnitConfigBuilder { - constructor(name, variableName, variableValue, input = [], results = []) { - super({ - name, - type: _enums.UNIT_TYPES.assignment - }); - this._variableName = variableName; - this._variableValue = variableValue; - this._input = input; - this._results = results; - } - input(arr) { - this._input = arr; - return this; - } - variableName(str) { - this._variableName = str; - return this; - } - variableValue(str) { - this._variableValue = str; - return this; - } - build() { - return { - ...super.build(), - input: this._input, - operand: this._variableName, - value: this._variableValue - }; - } +const enums_1 = require("../../enums"); +const UnitConfigBuilder_1 = require("./UnitConfigBuilder"); +class AssignmentUnitConfigBuilder extends UnitConfigBuilder_1.UnitConfigBuilder { + constructor(name, variableName, variableValue, input = [], results = []) { + super({ name, type: enums_1.UNIT_TYPES.assignment }); + this._variableName = variableName; + this._variableValue = variableValue; + this._input = input; + this._results = results; + } + input(arr) { + this._input = arr; + return this; + } + variableName(str) { + this._variableName = str; + return this; + } + variableValue(str) { + this._variableValue = str; + return this; + } + build() { + return { + ...super.build(), + input: this._input, + operand: this._variableName, + value: this._variableValue, + }; + } } -exports.AssignmentUnitConfigBuilder = AssignmentUnitConfigBuilder; \ No newline at end of file +exports.AssignmentUnitConfigBuilder = AssignmentUnitConfigBuilder; diff --git a/dist/js/units/builders/ExecutionUnitConfigBuilder.d.ts b/dist/js/units/builders/ExecutionUnitConfigBuilder.d.ts new file mode 100644 index 00000000..65d7e310 --- /dev/null +++ b/dist/js/units/builders/ExecutionUnitConfigBuilder.d.ts @@ -0,0 +1,39 @@ +export class ExecutionUnitConfigBuilder extends UnitConfigBuilder { + constructor(name: any, application: any, execName: any, flavorName: any, flowchartId: any); + _results: any; + _monitors: any; + _preProcessors: any; + _postProcessors: any; + initialize(application: any, execName: any, flavorName: any): void; + application: any; + executable: any; + flavor: any; + build(): { + application: any; + executable: any; + flavor: any; + type: any; + name: any; + head: boolean; + results: any[]; + monitors: any[]; + flowchartId: any; + preProcessors: any[]; + postProcessors: any[]; + }; + /** + * Creates an executable instance. This method is intended to be overridden in subclasses. + * @param {Application} application - The application object + * @param {string} execName - The name of the executable + * @returns {Executable} The created executable instance + */ + _createExecutable(application: Application, execName: string): Executable; + /** + * Creates a flavor instance. This method is intended to be overridden in subclasses. + * @param {Executable} executable - The executable object + * @param {string} flavorName - The name of the flavor + * @returns {Flavor} The created flavor instance + */ + _createFlavor(executable: Executable, flavorName: string): Flavor; +} +import { UnitConfigBuilder } from "./UnitConfigBuilder"; diff --git a/dist/js/units/builders/ExecutionUnitConfigBuilder.js b/dist/js/units/builders/ExecutionUnitConfigBuilder.js index 4fe730a9..44915b5e 100644 --- a/dist/js/units/builders/ExecutionUnitConfigBuilder.js +++ b/dist/js/units/builders/ExecutionUnitConfigBuilder.js @@ -1,66 +1,56 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.ExecutionUnitConfigBuilder = void 0; -var _ade = require("@mat3ra/ade"); -var _enums = require("../../enums"); -var _UnitConfigBuilder = require("./UnitConfigBuilder"); /* eslint-disable class-methods-use-this */ - -class ExecutionUnitConfigBuilder extends _UnitConfigBuilder.UnitConfigBuilder { - constructor(name, application, execName, flavorName, flowchartId) { - super({ - name, - type: _enums.UNIT_TYPES.execution, - flowchartId - }); - try { - this.initialize(application, execName, flavorName); - } catch (e) { - console.error(`Can't initialize executable/flavor: ${execName}/${flavorName}`); - throw e; +const ade_1 = require("@mat3ra/ade"); +const enums_1 = require("../../enums"); +const UnitConfigBuilder_1 = require("./UnitConfigBuilder"); +class ExecutionUnitConfigBuilder extends UnitConfigBuilder_1.UnitConfigBuilder { + constructor(name, application, execName, flavorName, flowchartId) { + super({ name, type: enums_1.UNIT_TYPES.execution, flowchartId }); + try { + this.initialize(application, execName, flavorName); + } + catch (e) { + console.error(`Can't initialize executable/flavor: ${execName}/${flavorName}`); + throw e; + } + // initialize runtimeItems + this._results = this.flavor.results; + this._monitors = this.flavor.monitors; + this._preProcessors = this.flavor.preProcessors; + this._postProcessors = this.flavor.postProcessors; + } + initialize(application, execName, flavorName) { + this.application = application; + this.executable = this._createExecutable(this.application, execName); + this.flavor = this._createFlavor(this.executable, flavorName); + } + build() { + return { + ...super.build(), + application: this.application.toJSON(), + executable: this.executable.toJSON(), + flavor: this.flavor.toJSON(), + }; + } + /** + * Creates an executable instance. This method is intended to be overridden in subclasses. + * @param {Application} application - The application object + * @param {string} execName - The name of the executable + * @returns {Executable} The created executable instance + */ + _createExecutable(application, execName) { + return ade_1.ApplicationRegistry.getExecutableByName(application.name, execName); + } + /** + * Creates a flavor instance. This method is intended to be overridden in subclasses. + * @param {Executable} executable - The executable object + * @param {string} flavorName - The name of the flavor + * @returns {Flavor} The created flavor instance + */ + _createFlavor(executable, flavorName) { + return ade_1.ApplicationRegistry.getFlavorByName(executable, flavorName); } - - // initialize runtimeItems - this._results = this.flavor.results; - this._monitors = this.flavor.monitors; - this._preProcessors = this.flavor.preProcessors; - this._postProcessors = this.flavor.postProcessors; - } - initialize(application, execName, flavorName) { - this.application = application; - this.executable = this._createExecutable(this.application, execName); - this.flavor = this._createFlavor(this.executable, flavorName); - } - build() { - return { - ...super.build(), - application: this.application.toJSON(), - executable: this.executable.toJSON(), - flavor: this.flavor.toJSON() - }; - } - - /** - * Creates an executable instance. This method is intended to be overridden in subclasses. - * @param {Application} application - The application object - * @param {string} execName - The name of the executable - * @returns {Executable} The created executable instance - */ - _createExecutable(application, execName) { - return _ade.ApplicationRegistry.getExecutableByName(application.name, execName); - } - - /** - * Creates a flavor instance. This method is intended to be overridden in subclasses. - * @param {Executable} executable - The executable object - * @param {string} flavorName - The name of the flavor - * @returns {Flavor} The created flavor instance - */ - _createFlavor(executable, flavorName) { - return _ade.ApplicationRegistry.getFlavorByName(executable, flavorName); - } } -exports.ExecutionUnitConfigBuilder = ExecutionUnitConfigBuilder; \ No newline at end of file +exports.ExecutionUnitConfigBuilder = ExecutionUnitConfigBuilder; diff --git a/dist/js/units/builders/IOUnitConfigBuilder.d.ts b/dist/js/units/builders/IOUnitConfigBuilder.d.ts new file mode 100644 index 00000000..d560f789 --- /dev/null +++ b/dist/js/units/builders/IOUnitConfigBuilder.d.ts @@ -0,0 +1,31 @@ +export class IOUnitConfigBuilder extends UnitConfigBuilder { + constructor(name: any, endpointName: any, endpointOptions: any); + _endpointName: any; + _endpointOptions: any; + _variableName: string; + _subtype: string; + _source: string; + endpointName(str: any): this; + endpointOptions(options: any): this; + variableName(str: any): this; + subtype(str: any): this; + source(str: any): this; + build(): { + subtype: string; + source: string; + input: { + endpoint: any; + endpoint_options: any; + name: string; + }[]; + type: any; + name: any; + head: boolean; + results: any[]; + monitors: any[]; + flowchartId: any; + preProcessors: any[]; + postProcessors: any[]; + }; +} +import { UnitConfigBuilder } from "./UnitConfigBuilder"; diff --git a/dist/js/units/builders/IOUnitConfigBuilder.js b/dist/js/units/builders/IOUnitConfigBuilder.js index ea5ca879..53990f63 100644 --- a/dist/js/units/builders/IOUnitConfigBuilder.js +++ b/dist/js/units/builders/IOUnitConfigBuilder.js @@ -1,54 +1,50 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.IOUnitConfigBuilder = void 0; -var _enums = require("../../enums"); -var _UnitConfigBuilder = require("./UnitConfigBuilder"); -class IOUnitConfigBuilder extends _UnitConfigBuilder.UnitConfigBuilder { - constructor(name, endpointName, endpointOptions) { - super({ - name, - type: _enums.UNIT_TYPES.io - }); - this._endpointName = endpointName; - this._endpointOptions = endpointOptions; - this._variableName = "DATA"; - this._subtype = "input"; - this._source = "api"; - } - endpointName(str) { - this._endpointName = str; - return this; - } - endpointOptions(options) { - this._endpointOptions = options; - return this; - } - variableName(str) { - this._variableName = str; - return this; - } - subtype(str) { - this._subtype = str; - return this; - } - source(str) { - this._source = str; - return this; - } - build() { - return { - ...super.build(), - subtype: this._subtype, - source: this._source, - input: [{ - endpoint: this._endpointName, - endpoint_options: this._endpointOptions, - name: this._variableName - }] - }; - } +const enums_1 = require("../../enums"); +const UnitConfigBuilder_1 = require("./UnitConfigBuilder"); +class IOUnitConfigBuilder extends UnitConfigBuilder_1.UnitConfigBuilder { + constructor(name, endpointName, endpointOptions) { + super({ name, type: enums_1.UNIT_TYPES.io }); + this._endpointName = endpointName; + this._endpointOptions = endpointOptions; + this._variableName = "DATA"; + this._subtype = "input"; + this._source = "api"; + } + endpointName(str) { + this._endpointName = str; + return this; + } + endpointOptions(options) { + this._endpointOptions = options; + return this; + } + variableName(str) { + this._variableName = str; + return this; + } + subtype(str) { + this._subtype = str; + return this; + } + source(str) { + this._source = str; + return this; + } + build() { + return { + ...super.build(), + subtype: this._subtype, + source: this._source, + input: [ + { + endpoint: this._endpointName, + endpoint_options: this._endpointOptions, + name: this._variableName, + }, + ], + }; + } } -exports.IOUnitConfigBuilder = IOUnitConfigBuilder; \ No newline at end of file +exports.IOUnitConfigBuilder = IOUnitConfigBuilder; diff --git a/dist/js/units/builders/UnitConfigBuilder.d.ts b/dist/js/units/builders/UnitConfigBuilder.d.ts new file mode 100644 index 00000000..6d3ef83c --- /dev/null +++ b/dist/js/units/builders/UnitConfigBuilder.d.ts @@ -0,0 +1,35 @@ +export class UnitConfigBuilder { + static usePredefinedIds: boolean; + static generateFlowChartId(...args: any[]): any; + static _stringArrayToNamedObject(array: any): any; + constructor({ name, type, flowchartId }: { + name: any; + type: any; + flowchartId: any; + }); + type: any; + _name: any; + _head: boolean; + _results: any[]; + _monitors: any[]; + _preProcessors: any[]; + _postProcessors: any[]; + _flowchartId: any; + name(str: any): this; + head(bool: any): this; + flowchartId(flowchartId: any): this; + addPreProcessors(preProcessorNames: any): this; + addPostProcessors(postProcessorNames: any): this; + addResults(resultNames: any): this; + addMonitors(monitorNames: any): this; + build(): { + type: any; + name: any; + head: boolean; + results: any[]; + monitors: any[]; + flowchartId: any; + preProcessors: any[]; + postProcessors: any[]; + }; +} diff --git a/dist/js/units/builders/UnitConfigBuilder.js b/dist/js/units/builders/UnitConfigBuilder.js index 617e3545..bbe2a9a0 100644 --- a/dist/js/units/builders/UnitConfigBuilder.js +++ b/dist/js/units/builders/UnitConfigBuilder.js @@ -1,79 +1,70 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); exports.UnitConfigBuilder = void 0; -var _utils = require("@mat3ra/utils"); -var _underscore = _interopRequireDefault(require("underscore")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +const utils_1 = require("@mat3ra/utils"); +const underscore_1 = __importDefault(require("underscore")); class UnitConfigBuilder { - constructor({ - name, - type, - flowchartId - }) { - this.type = type; - this._name = name; - this._head = false; - this._results = []; - this._monitors = []; - this._preProcessors = []; - this._postProcessors = []; - this._flowchartId = flowchartId || this.constructor.generateFlowChartId(name); - } - name(str) { - this._name = str; - return this; - } - head(bool) { - this._head = bool; - return this; - } - static generateFlowChartId(...args) { - if (this.usePredefinedIds) return _utils.Utils.uuid.getUUIDFromNamespace(...args); - return _utils.Utils.uuid.getUUID(); - } - flowchartId(flowchartId) { - this._flowchartId = flowchartId; - return this; - } - static _stringArrayToNamedObject(array) { - return array.map(name => _underscore.default.isString(name) ? { - name - } : name); - } - addPreProcessors(preProcessorNames) { - this._preProcessors = _underscore.default.union(this.constructor._stringArrayToNamedObject(preProcessorNames), this._preProcessors); - return this; - } - addPostProcessors(postProcessorNames) { - this._postProcessors = _underscore.default.union(this.constructor._stringArrayToNamedObject(postProcessorNames), this._postProcessors); - return this; - } - addResults(resultNames) { - this._results = _underscore.default.union(this.constructor._stringArrayToNamedObject(resultNames), this._results); - return this; - } - addMonitors(monitorNames) { - this._monitors = _underscore.default.union(this.constructor._stringArrayToNamedObject(monitorNames), this._monitors); - return this; - } - build() { - return { - type: this.type, - name: this._name, - head: this._head, - results: this._results, - monitors: this._monitors, - flowchartId: this._flowchartId, - preProcessors: this._preProcessors, - postProcessors: this._postProcessors - }; - } + constructor({ name, type, flowchartId }) { + this.type = type; + this._name = name; + this._head = false; + this._results = []; + this._monitors = []; + this._preProcessors = []; + this._postProcessors = []; + this._flowchartId = flowchartId || this.constructor.generateFlowChartId(name); + } + name(str) { + this._name = str; + return this; + } + head(bool) { + this._head = bool; + return this; + } + static generateFlowChartId(...args) { + if (this.usePredefinedIds) + return utils_1.Utils.uuid.getUUIDFromNamespace(...args); + return utils_1.Utils.uuid.getUUID(); + } + flowchartId(flowchartId) { + this._flowchartId = flowchartId; + return this; + } + static _stringArrayToNamedObject(array) { + return array.map((name) => (underscore_1.default.isString(name) ? { name } : name)); + } + addPreProcessors(preProcessorNames) { + this._preProcessors = underscore_1.default.union(this.constructor._stringArrayToNamedObject(preProcessorNames), this._preProcessors); + return this; + } + addPostProcessors(postProcessorNames) { + this._postProcessors = underscore_1.default.union(this.constructor._stringArrayToNamedObject(postProcessorNames), this._postProcessors); + return this; + } + addResults(resultNames) { + this._results = underscore_1.default.union(this.constructor._stringArrayToNamedObject(resultNames), this._results); + return this; + } + addMonitors(monitorNames) { + this._monitors = underscore_1.default.union(this.constructor._stringArrayToNamedObject(monitorNames), this._monitors); + return this; + } + build() { + return { + type: this.type, + name: this._name, + head: this._head, + results: this._results, + monitors: this._monitors, + flowchartId: this._flowchartId, + preProcessors: this._preProcessors, + postProcessors: this._postProcessors, + }; + } } exports.UnitConfigBuilder = UnitConfigBuilder; -_defineProperty(UnitConfigBuilder, "usePredefinedIds", false); \ No newline at end of file +UnitConfigBuilder.usePredefinedIds = false; diff --git a/dist/js/units/builders/index.d.ts b/dist/js/units/builders/index.d.ts new file mode 100644 index 00000000..2271d086 --- /dev/null +++ b/dist/js/units/builders/index.d.ts @@ -0,0 +1,12 @@ +export namespace builders { + export { UnitConfigBuilder }; + export { AssignmentUnitConfigBuilder }; + export { AssertionUnitConfigBuilder }; + export { ExecutionUnitConfigBuilder }; + export { IOUnitConfigBuilder }; +} +import { UnitConfigBuilder } from "./UnitConfigBuilder"; +import { AssignmentUnitConfigBuilder } from "./AssignmentUnitConfigBuilder"; +import { AssertionUnitConfigBuilder } from "./AssertionUnitConfigBuilder"; +import { ExecutionUnitConfigBuilder } from "./ExecutionUnitConfigBuilder"; +import { IOUnitConfigBuilder } from "./IOUnitConfigBuilder"; diff --git a/dist/js/units/builders/index.js b/dist/js/units/builders/index.js index a4cdde4b..bd53bfa5 100644 --- a/dist/js/units/builders/index.js +++ b/dist/js/units/builders/index.js @@ -1,18 +1,16 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.builders = void 0; -var _AssertionUnitConfigBuilder = require("./AssertionUnitConfigBuilder"); -var _AssignmentUnitConfigBuilder = require("./AssignmentUnitConfigBuilder"); -var _ExecutionUnitConfigBuilder = require("./ExecutionUnitConfigBuilder"); -var _IOUnitConfigBuilder = require("./IOUnitConfigBuilder"); -var _UnitConfigBuilder = require("./UnitConfigBuilder"); -const builders = exports.builders = { - UnitConfigBuilder: _UnitConfigBuilder.UnitConfigBuilder, - AssignmentUnitConfigBuilder: _AssignmentUnitConfigBuilder.AssignmentUnitConfigBuilder, - AssertionUnitConfigBuilder: _AssertionUnitConfigBuilder.AssertionUnitConfigBuilder, - ExecutionUnitConfigBuilder: _ExecutionUnitConfigBuilder.ExecutionUnitConfigBuilder, - IOUnitConfigBuilder: _IOUnitConfigBuilder.IOUnitConfigBuilder -}; \ No newline at end of file +const AssertionUnitConfigBuilder_1 = require("./AssertionUnitConfigBuilder"); +const AssignmentUnitConfigBuilder_1 = require("./AssignmentUnitConfigBuilder"); +const ExecutionUnitConfigBuilder_1 = require("./ExecutionUnitConfigBuilder"); +const IOUnitConfigBuilder_1 = require("./IOUnitConfigBuilder"); +const UnitConfigBuilder_1 = require("./UnitConfigBuilder"); +const builders = { + UnitConfigBuilder: UnitConfigBuilder_1.UnitConfigBuilder, + AssignmentUnitConfigBuilder: AssignmentUnitConfigBuilder_1.AssignmentUnitConfigBuilder, + AssertionUnitConfigBuilder: AssertionUnitConfigBuilder_1.AssertionUnitConfigBuilder, + ExecutionUnitConfigBuilder: ExecutionUnitConfigBuilder_1.ExecutionUnitConfigBuilder, + IOUnitConfigBuilder: IOUnitConfigBuilder_1.IOUnitConfigBuilder, +}; +exports.builders = builders; diff --git a/dist/js/units/condition.js b/dist/js/units/condition.js deleted file mode 100644 index f9169ee0..00000000 --- a/dist/js/units/condition.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ConditionUnit = void 0; -var _enums = require("../enums"); -var _base = require("./base"); -class ConditionUnit extends _base.BaseUnit { - constructor(config) { - super({ - ...ConditionUnit.getConditionConfig(), - ...config - }); - } - static getConditionConfig() { - return { - name: _enums.UNIT_TYPES.condition, - type: _enums.UNIT_TYPES.condition, - input: [], - results: [], - preProcessors: [], - postProcessors: [], - then: undefined, - else: undefined, - statement: "true", - maxOccurrences: 100 - }; - } - get input() { - return this.prop("input"); - } - get then() { - return this.prop("then"); - } - get else() { - return this.prop("else"); - } - get statement() { - return this.prop("statement"); - } - get maxOccurrences() { - return this.prop("maxOccurrences"); - } - getHashObject() { - return { - statement: this.statement, - maxOccurrences: this.maxOccurrences - }; - } -} -exports.ConditionUnit = ConditionUnit; \ No newline at end of file diff --git a/dist/js/units/execution.js b/dist/js/units/execution.js deleted file mode 100644 index 1bb62af4..00000000 --- a/dist/js/units/execution.js +++ /dev/null @@ -1,225 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ExecutionUnit = void 0; -var _ade = require("@mat3ra/ade"); -var _utils = require("@mat3ra/utils"); -var _underscore = _interopRequireDefault(require("underscore")); -var _base = require("./base"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -class ExecutionUnit extends _base.BaseUnit { - /** - * @override this method to provide entities from other sources - */ - _initApplication(config) { - this._application = _ade.ApplicationRegistry.createApplication(config.application); - this._executable = _ade.ApplicationRegistry.getExecutableByConfig(this._application.name, config.executable); - this._flavor = _ade.ApplicationRegistry.getFlavorByConfig(this._executable, config.flavor); - this._templates = this._flavor ? this._flavor.inputAsTemplates : []; - } - - /** - * @override this method to provide default executable from other source - */ - _getDefaultExecutable() { - return _ade.ApplicationRegistry.getExecutableByName(this.application.name); - } - - /** - * @override this method to provide default flavor from other source - */ - _getDefaultFlavor() { - return _ade.ApplicationRegistry.getFlavorByName(this.executable.name); - } - - /** - * @override this method to provide custom templates - */ - _getTemplatesFromInput() { - return this.getInput().map(i => new _ade.Template(i)); - } - - /** - * @override this method to provide custom input from other sources - */ - _getInput() { - return this.input || _ade.ApplicationRegistry.getInputAsRenderedTemplates(this.flavor, this.getCombinedContext()) || []; - } - - /** - * @override this method to provide custom input as templates - */ - _getInputAsTemplates() { - return _ade.ApplicationRegistry.getInputAsTemplates(this.flavor); - } - _initRuntimeItems(keys, config) { - this._initApplication(config); - super._initRuntimeItems(keys); - } - - /* - * @summary expects an array with elements containing field [{content: "..."}] - */ - get hashFromArrayInputContent() { - const objectForHashing = this._getInput().map(i => { - return _utils.Utils.str.removeEmptyLinesFromString(_utils.Utils.str.removeCommentsFromSourceCode(i.content)); - }); - return _utils.Utils.hash.calculateHashFromObject(objectForHashing); - } - get name() { - return this.prop("name", this.flavor.name); - } - get application() { - return this._application; - } - get executable() { - return this._executable; - } - get flavor() { - return this._flavor; - } - get templates() { - return this._templates; - } - setApplication(application, omitSettingExecutable = false) { - this._application = application; - this.setProp("application", application.toJSON()); - if (!omitSettingExecutable) { - this.setExecutable(this._getDefaultExecutable()); - } - } - setExecutable(executable) { - this._executable = executable; - this.setProp("executable", executable.toJSON()); - this.setFlavor(this._getDefaultFlavor()); - } - setFlavor(flavor) { - this._flavor = flavor; - this.setRuntimeItemsToDefaultValues(); - this.setProp("flavor", flavor.toJSON()); - this.setTemplates(this._getInputAsTemplates()); - } - setTemplates(templates) { - this._templates = templates; - this.render(this.context, true); - } - setInput(input) { - this.setProp("input", input); - } - get defaultResults() { - return this.flavor.results; - } - get defaultMonitors() { - return this.flavor.monitors; - } - get defaultPostProcessors() { - return this.flavor.postProcessors; - } - get allowedResults() { - return this.executable.results; - } - get allowedMonitors() { - return this.executable.monitors; - } - get allowedPostProcessors() { - return this.executable.postProcessors; - } - get allContextProviders() { - const list = []; - // pass context below to keep UI changes - this.templates.forEach(i => list.push(...i.getContextProvidersAsClassInstances(this.getCombinedContext()))); - return list; - } - get contextProviders() { - return this.allContextProviders.filter(p => p.isUnitContextProvider); - } - get input() { - return this.prop("input"); - } - get renderingContext() { - return this._renderingContext || {}; - } - set renderingContext(ctx) { - this._renderingContext = ctx; - } - - // context to persist in toJSON - get storedContext() { - return _underscore.default.omit(this.context, ...this.constructor.omitKeys); - } - - // context to show to users with some extra keys omitted - get visibleRenderingContext() { - return _underscore.default.omit(this.renderingContext, ...this.constructor.omitKeys); - } - static getSubworkflowContext(context) { - const { - subworkflowContext - } = context; - return subworkflowContext ? { - subworkflowContext - } : {}; - } - - /** Update rendering context and persistent context - * Note: this function is sometimes being called without passing a context! - * @param context - * @param fromTemplates - */ - render(context, fromTemplates = false) { - const newInput = []; - const newPersistentContext = {}; - const newRenderingContext = {}; - const renderingContext = { - ...this.context, - ...context - }; - this.updateContext(renderingContext); // update in-memory context to properly render templates from input below - (fromTemplates ? this.templates : this._getTemplatesFromInput()).forEach(t => { - newInput.push(t.getRenderedJSON(renderingContext)); - Object.assign(newRenderingContext, t.getDataFromProvidersForRenderingContext(renderingContext), ExecutionUnit.getSubworkflowContext(renderingContext)); - Object.assign(newPersistentContext, t.getDataFromProvidersForPersistentContext(renderingContext), ExecutionUnit.getSubworkflowContext(renderingContext)); - }); - this.setInput(newInput); - this.renderingContext = newRenderingContext; - this.updatePersistentContext(newPersistentContext); - } - - /** - * @summary Calculates hash on unit-specific fields. - * The meaningful fields of processing unit are operation, flavor and input at the moment. - */ - getHashObject() { - return { - ...super.getHashObject(), - application: _utils.Utils.specific.removeTimestampableKeysFromConfig(this.application.toJSON()), - executable: _utils.Utils.specific.removeTimestampableKeysFromConfig(this.executable.toJSON()), - flavor: _utils.Utils.specific.removeTimestampableKeysFromConfig(this.flavor.toJSON()), - input: this.hashFromArrayInputContent - }; - } - toJSON() { - const json = this.clean({ - ...super.toJSON(), - executable: this.executable.toJSON(), - flavor: this.flavor.toJSON(), - input: this._getInput(), - // keys below are not propagated to the parent class on initialization of a new unit unless explicitly given - name: this.name - // TODO: figure out the problem with storing context below - // context: this.storedContext, - }); - - // Remove results from executable - if (json.executable?.results) delete json.executable.results; - return json; - } -} -exports.ExecutionUnit = ExecutionUnit; -// keys to be omitted during toJSON -_defineProperty(ExecutionUnit, "omitKeys", ["job", "workflow", "material", "materials", "model", "methodData", "hasRelaxation"]); \ No newline at end of file diff --git a/dist/js/units/factory.d.ts b/dist/js/units/factory.d.ts new file mode 100644 index 00000000..4c24e16f --- /dev/null +++ b/dist/js/units/factory.d.ts @@ -0,0 +1,8 @@ +import type { AssertionUnitSchema, AssignmentUnitSchema, ConditionUnitSchema, DataIOUnitSchema, MapUnitSchema, ProcessingUnitSchema, SubworkflowUnitSchema } from "@mat3ra/esse/dist/js/types"; +import { BaseUnit } from "./BaseUnit"; +import { type ExecutionUnitSchema } from "./ExecutionUnit"; +type UnitConfig = ExecutionUnitSchema | AssignmentUnitSchema | ConditionUnitSchema | DataIOUnitSchema | ProcessingUnitSchema | MapUnitSchema | SubworkflowUnitSchema | AssertionUnitSchema; +export declare class UnitFactory { + static create(config: UnitConfig): BaseUnit; +} +export {}; diff --git a/dist/js/units/factory.js b/dist/js/units/factory.js index d92df052..5f395545 100644 --- a/dist/js/units/factory.js +++ b/dist/js/units/factory.js @@ -1,53 +1,37 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.UnitFactory = void 0; -var _enums = require("../enums"); -var _assertion = require("./assertion"); -var _assignment = require("./assignment"); -var _base = require("./base"); -var _condition = require("./condition"); -var _execution = require("./execution"); -var _io = require("./io"); -var _map = require("./map"); -var _processing = require("./processing"); -var _subworkflow = require("./subworkflow"); -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +const enums_1 = require("../enums"); +const AssertionUnit_1 = require("./AssertionUnit"); +const AssignmentUnit_1 = require("./AssignmentUnit"); +const ConditionUnit_1 = require("./ConditionUnit"); +const ExecutionUnit_1 = require("./ExecutionUnit"); +const IOUnit_1 = require("./IOUnit"); +const MapUnit_1 = require("./MapUnit"); +const ProcessingUnit_1 = require("./ProcessingUnit"); +const SubworkflowUnit_1 = require("./SubworkflowUnit"); class UnitFactory { - static create(config) { - switch (config.type) { - case _enums.UNIT_TYPES.execution: - return new this.ExecutionUnit(config); - case _enums.UNIT_TYPES.assignment: - return new this.AssignmentUnit(config); - case _enums.UNIT_TYPES.condition: - return new this.ConditionUnit(config); - case _enums.UNIT_TYPES.io: - return new this.IOUnit(config); - case _enums.UNIT_TYPES.processing: - return new this.ProcessingUnit(config); - case _enums.UNIT_TYPES.map: - return new this.MapUnit(config); - case _enums.UNIT_TYPES.subworkflow: - return new this.SubworkflowUnit(config); - case _enums.UNIT_TYPES.assertion: - return new this.AssertionUnit(config); - default: - return new this.BaseUnit(config); + static create(config) { + switch (config.type) { + case enums_1.UnitType.execution: + return new ExecutionUnit_1.ExecutionUnit(config); + case enums_1.UnitType.assignment: + return new AssignmentUnit_1.AssignmentUnit(config); + case enums_1.UnitType.condition: + return new ConditionUnit_1.ConditionUnit(config); + case enums_1.UnitType.io: + return new IOUnit_1.IOUnit(config); + case enums_1.UnitType.processing: + return new ProcessingUnit_1.ProcessingUnit(config); + case enums_1.UnitType.map: + return new MapUnit_1.MapUnit(config); + case enums_1.UnitType.subworkflow: + return new SubworkflowUnit_1.SubworkflowUnit(config); + case enums_1.UnitType.assertion: + return new AssertionUnit_1.AssertionUnit(config); + default: + throw new Error(`Unknown unit type: ${config.type}`); + } } - } } exports.UnitFactory = UnitFactory; -_defineProperty(UnitFactory, "AssertionUnit", _assertion.AssertionUnit); -_defineProperty(UnitFactory, "AssignmentUnit", _assignment.AssignmentUnit); -_defineProperty(UnitFactory, "BaseUnit", _base.BaseUnit); -_defineProperty(UnitFactory, "ConditionUnit", _condition.ConditionUnit); -_defineProperty(UnitFactory, "ExecutionUnit", _execution.ExecutionUnit); -_defineProperty(UnitFactory, "IOUnit", _io.IOUnit); -_defineProperty(UnitFactory, "MapUnit", _map.MapUnit); -_defineProperty(UnitFactory, "ProcessingUnit", _processing.ProcessingUnit); -_defineProperty(UnitFactory, "SubworkflowUnit", _subworkflow.SubworkflowUnit); \ No newline at end of file diff --git a/dist/js/units/index.d.ts b/dist/js/units/index.d.ts new file mode 100644 index 00000000..08eb9db7 --- /dev/null +++ b/dist/js/units/index.d.ts @@ -0,0 +1,12 @@ +import { AssertionUnit } from "./AssertionUnit"; +import { AssignmentUnit } from "./AssignmentUnit"; +import { BaseUnit } from "./BaseUnit"; +import { ConditionUnit } from "./ConditionUnit"; +import { ExecutionUnit } from "./ExecutionUnit"; +import { UnitFactory } from "./factory"; +import { IOUnit } from "./IOUnit"; +import { MapUnit } from "./MapUnit"; +import { ProcessingUnit } from "./ProcessingUnit"; +import { ReduceUnit } from "./ReduceUnit"; +import { SubworkflowUnit } from "./SubworkflowUnit"; +export { BaseUnit, AssertionUnit, AssignmentUnit, ConditionUnit, ExecutionUnit, IOUnit, MapUnit, ProcessingUnit, ReduceUnit, SubworkflowUnit, UnitFactory, }; diff --git a/dist/js/units/index.js b/dist/js/units/index.js index 88c98a3f..0be195c9 100644 --- a/dist/js/units/index.js +++ b/dist/js/units/index.js @@ -1,82 +1,25 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "AssertionUnit", { - enumerable: true, - get: function () { - return _assertion.AssertionUnit; - } -}); -Object.defineProperty(exports, "AssignmentUnit", { - enumerable: true, - get: function () { - return _assignment.AssignmentUnit; - } -}); -Object.defineProperty(exports, "BaseUnit", { - enumerable: true, - get: function () { - return _base.BaseUnit; - } -}); -Object.defineProperty(exports, "ConditionUnit", { - enumerable: true, - get: function () { - return _condition.ConditionUnit; - } -}); -Object.defineProperty(exports, "ExecutionUnit", { - enumerable: true, - get: function () { - return _execution.ExecutionUnit; - } -}); -Object.defineProperty(exports, "IOUnit", { - enumerable: true, - get: function () { - return _io.IOUnit; - } -}); -Object.defineProperty(exports, "MapUnit", { - enumerable: true, - get: function () { - return _map.MapUnit; - } -}); -Object.defineProperty(exports, "ProcessingUnit", { - enumerable: true, - get: function () { - return _processing.ProcessingUnit; - } -}); -Object.defineProperty(exports, "ReduceUnit", { - enumerable: true, - get: function () { - return _reduce.ReduceUnit; - } -}); -Object.defineProperty(exports, "SubworkflowUnit", { - enumerable: true, - get: function () { - return _subworkflow.SubworkflowUnit; - } -}); -Object.defineProperty(exports, "UnitFactory", { - enumerable: true, - get: function () { - return _factory.UnitFactory; - } -}); -var _assertion = require("./assertion"); -var _assignment = require("./assignment"); -var _base = require("./base"); -var _condition = require("./condition"); -var _execution = require("./execution"); -var _factory = require("./factory"); -var _io = require("./io"); -var _map = require("./map"); -var _processing = require("./processing"); -var _reduce = require("./reduce"); -var _subworkflow = require("./subworkflow"); \ No newline at end of file +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UnitFactory = exports.SubworkflowUnit = exports.ReduceUnit = exports.ProcessingUnit = exports.MapUnit = exports.IOUnit = exports.ExecutionUnit = exports.ConditionUnit = exports.AssignmentUnit = exports.AssertionUnit = exports.BaseUnit = void 0; +const AssertionUnit_1 = require("./AssertionUnit"); +Object.defineProperty(exports, "AssertionUnit", { enumerable: true, get: function () { return AssertionUnit_1.AssertionUnit; } }); +const AssignmentUnit_1 = require("./AssignmentUnit"); +Object.defineProperty(exports, "AssignmentUnit", { enumerable: true, get: function () { return AssignmentUnit_1.AssignmentUnit; } }); +const BaseUnit_1 = require("./BaseUnit"); +Object.defineProperty(exports, "BaseUnit", { enumerable: true, get: function () { return BaseUnit_1.BaseUnit; } }); +const ConditionUnit_1 = require("./ConditionUnit"); +Object.defineProperty(exports, "ConditionUnit", { enumerable: true, get: function () { return ConditionUnit_1.ConditionUnit; } }); +const ExecutionUnit_1 = require("./ExecutionUnit"); +Object.defineProperty(exports, "ExecutionUnit", { enumerable: true, get: function () { return ExecutionUnit_1.ExecutionUnit; } }); +const factory_1 = require("./factory"); +Object.defineProperty(exports, "UnitFactory", { enumerable: true, get: function () { return factory_1.UnitFactory; } }); +const IOUnit_1 = require("./IOUnit"); +Object.defineProperty(exports, "IOUnit", { enumerable: true, get: function () { return IOUnit_1.IOUnit; } }); +const MapUnit_1 = require("./MapUnit"); +Object.defineProperty(exports, "MapUnit", { enumerable: true, get: function () { return MapUnit_1.MapUnit; } }); +const ProcessingUnit_1 = require("./ProcessingUnit"); +Object.defineProperty(exports, "ProcessingUnit", { enumerable: true, get: function () { return ProcessingUnit_1.ProcessingUnit; } }); +const ReduceUnit_1 = require("./ReduceUnit"); +Object.defineProperty(exports, "ReduceUnit", { enumerable: true, get: function () { return ReduceUnit_1.ReduceUnit; } }); +const SubworkflowUnit_1 = require("./SubworkflowUnit"); +Object.defineProperty(exports, "SubworkflowUnit", { enumerable: true, get: function () { return SubworkflowUnit_1.SubworkflowUnit; } }); diff --git a/dist/js/units/io.js b/dist/js/units/io.js deleted file mode 100644 index 89223cbb..00000000 --- a/dist/js/units/io.js +++ /dev/null @@ -1,148 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.IOUnit = void 0; -var _lodash = _interopRequireDefault(require("lodash")); -var _enums = require("../enums"); -var _base = require("./base"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -class IOUnit extends _base.BaseUnit { - /** - * IO Unit Builder for Object Storage sources. - * - * @param {Object} config - config object with other parameters: - * @param {String} config.name - the name of the unit this builder is creating - * @param {String} config.subtype - "input", "output", or "dataframe" - * @param {Object} config.input - input containing information on the file to download - * @param {Boolean} config.enableRender - Whether to use Jinja templating at runtime - */ - constructor(config) { - super({ - ...IOUnit.getIOConfig(), - ...config - }); - this.initialize(config); - } - static getIOConfig() { - return { - name: _enums.UNIT_TYPES.io, - type: _enums.UNIT_TYPES.io, - subtype: "input" - }; - } - initialize(config) { - this._materials = []; - this._defaultTargets = ["band_gaps:direct", "band_gaps:indirect"]; - this._features = _lodash.default.get(config, "input.0.endpoint_options.data.features", []); - this._targets = _lodash.default.get(config, "input.0.endpoint_options.data.targets", this._defaultTargets); - this._ids = _lodash.default.get(config, "input.0.endpoint_options.data.ids", []); - this._jobId = null; - } - get materials() { - return this._materials || []; - } - get defaultTargets() { - return this._defaultTargets; - } - get features() { - return this._features; - } - get featuresWithoutId() { - return this.features.filter(x => x !== _enums.IO_ID_COLUMN); - } - get availableFeatures() { - const { - materials - } = this; - return _lodash.default.uniq(_lodash.default.flatten(materials.map(x => _lodash.default.keys(x.propertiesDict()))).concat(this.features)); - } - get availableFeaturesWithoutId() { - return this.availableFeatures.filter(feature => feature !== _enums.IO_ID_COLUMN); - } - get targets() { - return this._targets; - } - - /** - * @summary Checks whether selected features contain only IO_ID_COLUMN ('exabyteId'). - * Used to identify that no features are selected yet (features set always contains ID_COLUMN) - */ - get onlyIdFeatureSelected() { - return _lodash.default.isEmpty(_lodash.default.without(this.features, _enums.IO_ID_COLUMN)); - } - - /** - * @summary Returns object with targets as key and arrays of appropriate values. - * E.g. {'band_gap:indirect': [0.1, 0.3], 'pressure': [100, undefined]} - */ - get valuesByTarget() { - const values = this.dataGridValues; - const result = {}; - this.targets.forEach(target => { - result[target] = values.map(v => v[target]); - }); - return result; - } - get dataFrameConfig() { - return { - subtype: "dataFrame", - source: "api", - input: [{ - endpoint: "dataframe", - endpoint_options: { - method: "POST", - data: { - targets: this._targets, - features: this._features, - ids: this._ids, - jobId: this._jobId - }, - headers: {}, - params: {} - } - }] - }; - } - get isDataFrame() { - return this.prop("subtype") === "dataFrame"; - } - setMaterials(materials) { - this._materials = materials; - this._ids = materials.map(m => m.exabyteId); - } - addFeature(feature) { - // only add if not already present - if (this._features.indexOf(feature) === -1) this._features.push(feature); - } - removeFeature(feature) { - if (this.featuresWithoutId.length === 1) { - throw new Error("At least one feature is required"); - } - this._features = this._features.filter(x => feature !== x && x !== _enums.IO_ID_COLUMN); - } - addTarget(target) { - if (this._targets.indexOf(target) === -1) this._targets.push(target); - } - removeTarget(target) { - if (this._targets.length === 1) { - throw new Error("At least one target is required"); - } - this._targets = this._targets.filter(x => target !== x); - } - hasFeature(feature) { - return this._features.indexOf(feature) > -1; - } - hasTarget(target) { - return this._targets.indexOf(target) > -1; - } - toJSON() { - const config = this.isDataFrame ? this.dataFrameConfig : {}; - return this.clean({ - ...super.toJSON(), - ...config - }); - } -} -exports.IOUnit = IOUnit; \ No newline at end of file diff --git a/dist/js/units/map.js b/dist/js/units/map.js deleted file mode 100644 index 9f491c7a..00000000 --- a/dist/js/units/map.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.defaultMapConfig = exports.MapUnit = void 0; -var _enums = require("../enums"); -var _base = require("./base"); -const defaultMapConfig = exports.defaultMapConfig = { - name: _enums.UNIT_TYPES.map, - type: _enums.UNIT_TYPES.map, - workflowId: "", - input: { - target: "MAP_DATA", - scope: "global", - name: "", - values: [], - useValues: false - } -}; -class MapUnit extends _base.BaseUnit { - constructor(config) { - super({ - ...defaultMapConfig, - ...config - }); - } - get input() { - return this.prop("input"); - } - get workflowId() { - return this.prop("workflowId"); - } - setWorkflowId(id) { - this.setProp("workflowId", id); - } -} -exports.MapUnit = MapUnit; \ No newline at end of file diff --git a/dist/js/units/processing.js b/dist/js/units/processing.js deleted file mode 100644 index 82baf0c8..00000000 --- a/dist/js/units/processing.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ProcessingUnit = void 0; -var _enums = require("../enums"); -var _base = require("./base"); -class ProcessingUnit extends _base.BaseUnit { - constructor(config) { - super({ - ...ProcessingUnit.getProcessingConfig(), - ...config - }); - } - static getProcessingConfig() { - return { - name: _enums.UNIT_TYPES.processing, - type: _enums.UNIT_TYPES.processing - }; - } - setOperation(op) { - this.setProp("operation", op); - } - setOperationType(type) { - this.setProp("operationType", type); - } - setInput(input) { - this.setProp("input", input); - } - get operation() { - return this.prop("operation"); - } - get operationType() { - return this.prop("operationType"); - } - get input() { - return this.prop("input"); - } -} -exports.ProcessingUnit = ProcessingUnit; \ No newline at end of file diff --git a/dist/js/units/reduce.js b/dist/js/units/reduce.js deleted file mode 100644 index 5174ac5b..00000000 --- a/dist/js/units/reduce.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ReduceUnit = void 0; -var _enums = require("../enums"); -var _base = require("./base"); -class ReduceUnit extends _base.BaseUnit { - constructor(unitName, mapUnit, input) { - super({ - ...ReduceUnit.getReduceConfig(unitName, mapUnit, input) - }); - } - static getReduceConfig(unitName, mapUnit, input) { - return { - type: _enums.UNIT_TYPES.reduce, - name: unitName, - mapFlowchartId: mapUnit, - input - }; - } -} -exports.ReduceUnit = ReduceUnit; \ No newline at end of file diff --git a/dist/js/units/subworkflow.js b/dist/js/units/subworkflow.js deleted file mode 100644 index 8f6f0672..00000000 --- a/dist/js/units/subworkflow.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.SubworkflowUnit = void 0; -var _enums = require("../enums"); -var _base = require("./base"); -class SubworkflowUnit extends _base.BaseUnit { - constructor(config) { - super({ - ...SubworkflowUnit.getSubworkflowConfig(), - ...config - }); - } - static getSubworkflowConfig() { - return { - name: "New Subworkflow", - type: _enums.UNIT_TYPES.subworkflow - }; - } -} -exports.SubworkflowUnit = SubworkflowUnit; \ No newline at end of file diff --git a/dist/js/utils.d.ts b/dist/js/utils.d.ts new file mode 100644 index 00000000..cf6bc75e --- /dev/null +++ b/dist/js/utils.d.ts @@ -0,0 +1,28 @@ +/** + * @summary set the head of an array of units + * @param units + * @returns {Unit[]} + */ +export function setUnitsHead(units: any): Unit[]; +/** + * @summary Re-establishes the linked `next => flowchartId` logic in an array of units + * @params units {Unit[]} + * @returns units {Unit[]} + */ +export function setNextLinks(units: any): any; +/** + * @summary Apply configuration data to an object + * @param obj {*} object / class containing methods or attributes to be set + * @param config { functions: {}, attributes: {} } functions to call and attributes to set + * @param callBuild {boolean} if true; call build between applying functions and attributes + * @returns {*} updated object + */ +export function applyConfig({ obj, config, callBuild }: any): any; +/** + * @summary Safely extract unit object from subworkflow data + * @param subworkflowData {Object} subworkflow data + * @param index {number} index of subworkflow unit + * @param type {string} type of subworkflow unit + * @returns {Object|null} subworkflow unit object (not a unit class instance!) + */ +export function findUnit({ subworkflowData, index, type }: Object): Object | null; diff --git a/dist/js/utils.js b/dist/js/utils.js index a4093b8f..697fff99 100644 --- a/dist/js/utils.js +++ b/dist/js/utils.js @@ -1,27 +1,25 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.setUnitsHead = setUnitsHead; +exports.setNextLinks = setNextLinks; exports.applyConfig = applyConfig; exports.findUnit = findUnit; -exports.setNextLinks = setNextLinks; -exports.setUnitsHead = setUnitsHead; -var _lodash = _interopRequireDefault(require("lodash")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +const lodash_1 = __importDefault(require("lodash")); /** * @summary set the head of an array of units * @param units * @returns {Unit[]} */ function setUnitsHead(units) { - if (units.length > 0) { - units[0].head = true; - _lodash.default.tail(units).map(x => x.head = false); - } - return units; + if (units.length > 0) { + units[0].head = true; + lodash_1.default.tail(units).map((x) => (x.head = false)); + } + return units; } - // TODO: fix setNextLinks on unit removal and convergence logic. /** * @summary Re-establishes the linked `next => flowchartId` logic in an array of units @@ -29,20 +27,21 @@ function setUnitsHead(units) { * @returns units {Unit[]} */ function setNextLinks(units) { - const flowchartIds = units.map(u => u.flowchartId); - for (let i = 0; i < units.length - 1; i++) { - if (!units[i].next) { - // newly added units don't have next set yet => set it - units[i].next = units[i + 1].flowchartId; - if (i > 0) units[i - 1].next = units[i].flowchartId; - } else if (!flowchartIds.includes(units[i].next)) { - // newly removed units may create broken next links => fix it - units[i].next = units[i + 1].flowchartId; + const flowchartIds = units.map((u) => u.flowchartId); + for (let i = 0; i < units.length - 1; i++) { + if (!units[i].next) { + // newly added units don't have next set yet => set it + units[i].next = units[i + 1].flowchartId; + if (i > 0) + units[i - 1].next = units[i].flowchartId; + } + else if (!flowchartIds.includes(units[i].next)) { + // newly removed units may create broken next links => fix it + units[i].next = units[i + 1].flowchartId; + } } - } - return units; + return units; } - /** * @summary Apply configuration data to an object * @param obj {*} object / class containing methods or attributes to be set @@ -50,30 +49,25 @@ function setNextLinks(units) { * @param callBuild {boolean} if true; call build between applying functions and attributes * @returns {*} updated object */ -function applyConfig({ - obj, - config = {}, - callBuild = false -}) { - const { - functions = {}, - attributes = {} - } = config; - // eslint-disable-next-line no-restricted-syntax - for (const [func, args] of Object.entries(functions)) { - // eslint-disable-next-line no-nested-ternary - if (obj[func]) { - if (args) obj[func](args);else obj[func](); +function applyConfig({ obj, config = {}, callBuild = false }) { + const { functions = {}, attributes = {} } = config; + // eslint-disable-next-line no-restricted-syntax + for (const [func, args] of Object.entries(functions)) { + // eslint-disable-next-line no-nested-ternary + if (obj[func]) { + if (args) + obj[func](args); + else + obj[func](); + } + } + const modified = callBuild ? obj.build() : obj; + // eslint-disable-next-line no-restricted-syntax + for (const [key, values] of Object.entries(attributes)) { + modified[key] = values; } - } - const modified = callBuild ? obj.build() : obj; - // eslint-disable-next-line no-restricted-syntax - for (const [key, values] of Object.entries(attributes)) { - modified[key] = values; - } - return modified; + return modified; } - /** * @summary Safely extract unit object from subworkflow data * @param subworkflowData {Object} subworkflow data @@ -81,12 +75,9 @@ function applyConfig({ * @param type {string} type of subworkflow unit * @returns {Object|null} subworkflow unit object (not a unit class instance!) */ -function findUnit({ - subworkflowData, - index, - type -}) { - const unit = subworkflowData.units[index]; - if (unit.type !== type) throw new Error("findUnit() error: unit type does not match!"); - return unit; -} \ No newline at end of file +function findUnit({ subworkflowData, index, type }) { + const unit = subworkflowData.units[index]; + if (unit.type !== type) + throw new Error("findUnit() error: unit type does not match!"); + return unit; +} diff --git a/dist/js/workflows/create.d.ts b/dist/js/workflows/create.d.ts new file mode 100644 index 00000000..546e92ce --- /dev/null +++ b/dist/js/workflows/create.d.ts @@ -0,0 +1,8 @@ +export function createWorkflow({ appName, workflowData, workflowSubworkflowMapByApplication, workflowCls, ...swArgs }: { + [x: string]: any; + appName: any; + workflowData: any; + workflowSubworkflowMapByApplication: any; + workflowCls?: typeof Workflow | undefined; +}): any[]; +import { Workflow } from "./workflow"; diff --git a/dist/js/workflows/create.js b/dist/js/workflows/create.js index a185b941..25224744 100644 --- a/dist/js/workflows/create.js +++ b/dist/js/workflows/create.js @@ -1,71 +1,41 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.createWorkflow = createWorkflow; -var _create = require("../subworkflows/create"); -var _units = require("../units"); -var _map = require("../units/map"); -var _utils = require("../utils"); -var _workflow = require("./workflow"); +const create_1 = require("../subworkflows/create"); +const units_1 = require("../units"); +const map_1 = require("../units/map"); +const utils_1 = require("../utils"); +const workflow_1 = require("./workflow"); /** * @summary Helper for creating Map units for complex workflows * @param config {Object} map unit configuration * @param unitFactoryCls {*} class factory for map unit * @returns {*} map unit */ -function createMapUnit({ - config, - unitFactoryCls = _units.UnitFactory -}) { - let { - input: defaultInput - } = _map.defaultMapConfig; - if (config.input) { - defaultInput = { - ...defaultInput, - ...config.input - }; - } - const unit = unitFactoryCls.create({ - ..._map.defaultMapConfig, - input: defaultInput - }); - return unit; +function createMapUnit({ config, unitFactoryCls = units_1.UnitFactory }) { + let { input: defaultInput } = map_1.defaultMapConfig; + if (config.input) { + defaultInput = { ...defaultInput, ...config.input }; + } + const unit = unitFactoryCls.create({ ...map_1.defaultMapConfig, input: defaultInput }); + return unit; } - /** * @summary Update subworkflow units with patch configuration defined in the workflow config * @param subworkflowData {Object} subworkflow data * @param unitConfigs {Array} array of patch configs for subworkflow units * @returns subworkflowData {Object} subworkflowData with patches applied to units */ -function updateUnitConfigs({ - subworkflowData, - unitConfigs -}) { - unitConfigs.forEach(config => { - const { - index, - type, - config: unitConfig - } = config; // unitConfig should contain 'attributes' key - const unit = (0, _utils.findUnit)({ - subworkflowData, - index, - type - }); - console.log(` patching ${type} unit ${index} of subworkflow ${subworkflowData.name}`); - unit.config = (0, _utils.applyConfig)({ - obj: unit.config, - config: unitConfig +function updateUnitConfigs({ subworkflowData, unitConfigs }) { + unitConfigs.forEach((config) => { + const { index, type, config: unitConfig } = config; // unitConfig should contain 'attributes' key + const unit = (0, utils_1.findUnit)({ subworkflowData, index, type }); + console.log(` patching ${type} unit ${index} of subworkflow ${subworkflowData.name}`); + unit.config = (0, utils_1.applyConfig)({ obj: unit.config, config: unitConfig }); + return null; }); - return null; - }); - return subworkflowData; + return subworkflowData; } - /** * @summary Use subworkflow.createSubworkflow to create a Subworkflow unit * @param appName {String} application name @@ -74,40 +44,19 @@ function updateUnitConfigs({ * @param swArgs {*} subworkflow classes * @returns {*} subworkflow object */ -function createSubworkflowUnit({ - appName, - unitData, - workflowData, - ...swArgs -}) { - const { - name: unitName, - unitConfigs, - config - } = unitData; - const { - subworkflows - } = workflowData; - const { - [appName]: dataByApp - } = subworkflows; - let { - [unitName]: subworkflowData - } = dataByApp; - subworkflowData.config = { - ...subworkflowData.config, - ...config - }; - if (unitConfigs) subworkflowData = updateUnitConfigs({ - subworkflowData, - unitConfigs - }); - return (0, _create.createSubworkflow)({ - subworkflowData, - ...swArgs - }); +function createSubworkflowUnit({ appName, unitData, workflowData, ...swArgs }) { + const { name: unitName, unitConfigs, config } = unitData; + const { subworkflows } = workflowData; + const { [appName]: dataByApp } = subworkflows; + let { [unitName]: subworkflowData } = dataByApp; + subworkflowData.config = { ...subworkflowData.config, ...config }; + if (unitConfigs) + subworkflowData = updateUnitConfigs({ subworkflowData, unitConfigs }); + return (0, create_1.createSubworkflow)({ + subworkflowData, + ...swArgs, + }); } - /** * @summary Create the first workflow object specified in a workflow configuration * @param workflow {*|null} the workflow (if already initialized, no-op) @@ -116,27 +65,22 @@ function createSubworkflowUnit({ * @param workflowCls {*} workflow class * @returns {Workflow|*} workflow object */ -function createWorkflowHead({ - workflow, - unit, - type, - workflowCls -}) { - if (workflow) return workflow; - let wf; - switch (type) { - case "workflow": - wf = unit; - break; - case "subworkflow": - wf = workflowCls.fromSubworkflow(unit); - break; - default: - throw new Error(`workflow type=${type} not understood.`); - } - return wf; +function createWorkflowHead({ workflow, unit, type, workflowCls }) { + if (workflow) + return workflow; + let wf; + switch (type) { + case "workflow": + wf = unit; + break; + case "subworkflow": + wf = workflowCls.fromSubworkflow(unit); + break; + default: + throw new Error(`workflow type=${type} not understood.`); + } + return wf; } - /** * @summary Combine workflow units together * @param workflow {*} the workflow object @@ -146,40 +90,28 @@ function createWorkflowHead({ * @param unitFactoryCls {*} unit factory class for e.g. map units * @returns {*} modified workflow */ -function composeWorkflow({ - workflow, - unit, - config, - type, - unitFactoryCls -}) { - /* eslint-disable no-case-declarations */ - switch (type) { - case "workflow": - const { - mapUnit: isMapUnit, - ...mapUnitConfig - } = config; - if (isMapUnit) { - const mapUnit = createMapUnit({ - config: mapUnitConfig, - unitFactoryCls - }); - workflow.addMapUnit(mapUnit, unit); - } else { - console.log("adding workflows directly to workflows is not supported."); - } - break; - case "subworkflow": - workflow.addSubworkflow(unit); - break; - default: - throw new Error(`workflow type=${type} not understood.`); - } - /* eslint-enable no-case-declarations */ - return workflow; +function composeWorkflow({ workflow, unit, config, type, unitFactoryCls }) { + /* eslint-disable no-case-declarations */ + switch (type) { + case "workflow": + const { mapUnit: isMapUnit, ...mapUnitConfig } = config; + if (isMapUnit) { + const mapUnit = createMapUnit({ config: mapUnitConfig, unitFactoryCls }); + workflow.addMapUnit(mapUnit, unit); + } + else { + console.log("adding workflows directly to workflows is not supported."); + } + break; + case "subworkflow": + workflow.addSubworkflow(unit); + break; + default: + throw new Error(`workflow type=${type} not understood.`); + } + /* eslint-enable no-case-declarations */ + return workflow; } - /** * @summary Convert a flattened array of workflow units to a properly constructed workflow * @param wfUnits {Array} array of workflow units @@ -187,42 +119,31 @@ function composeWorkflow({ * @param unitFactoryCls {*} unit factory class * @returns {*} constructed workflow */ -function createFromWorkflowUnits({ - wfUnits, - workflowCls, - unitFactoryCls -}) { - let workflow, unit, config, type; - wfUnits.map(wfUnit => { - ({ - unit, - config, - type - } = wfUnit); - if (!workflow) { - workflow = createWorkflowHead({ - workflow, - unit, - type, - workflowCls - }); - } else { - workflow = composeWorkflow({ - workflow, - unit, - config, - type, - unitFactoryCls - }); - } - return null; - }); - return (0, _utils.applyConfig)({ - obj: workflow, - config - }); +function createFromWorkflowUnits({ wfUnits, workflowCls, unitFactoryCls }) { + let workflow, unit, config, type; + wfUnits.map((wfUnit) => { + ({ unit, config, type } = wfUnit); + if (!workflow) { + workflow = createWorkflowHead({ + workflow, + unit, + type, + workflowCls, + }); + } + else { + workflow = composeWorkflow({ + workflow, + unit, + config, + type, + unitFactoryCls, + }); + } + return null; + }); + return (0, utils_1.applyConfig)({ obj: workflow, config }); } - /** * @summary Creates a flattened array of workflow units from nested workflow/subworkflow * configuration data comprising a simple or complex workflow @@ -231,82 +152,56 @@ function createFromWorkflowUnits({ * @param swArgs * @returns {*[]} */ -function createWorkflowUnits({ - appName, - workflowData, - workflowSubworkflowMapByApplication, - workflowCls, - ...swArgs -}) { - const wfUnits = []; - const { - units - } = workflowData; - let unit, config; - units.map(unitData => { - const { - type - } = unitData; - switch (type) { - case "workflow": - ({ - config - } = unitData); - unit = createWorkflowUnits({ - appName, - workflowData: unitData, - workflowSubworkflowMapByApplication, - workflowCls, - ...swArgs - }); - break; - case "subworkflow": - ({ - config - } = workflowData); - unit = createSubworkflowUnit({ - appName, - unitData, - workflowData: workflowSubworkflowMapByApplication, - ...swArgs - }); - break; - default: - break; - } - wfUnits.push({ - config, - unit, - type +function createWorkflowUnits({ appName, workflowData, workflowSubworkflowMapByApplication, workflowCls, ...swArgs }) { + const wfUnits = []; + const { units } = workflowData; + let unit, config; + units.map((unitData) => { + const { type } = unitData; + switch (type) { + case "workflow": + ({ config } = unitData); + unit = createWorkflowUnits({ + appName, + workflowData: unitData, + workflowSubworkflowMapByApplication, + workflowCls, + ...swArgs, + }); + break; + case "subworkflow": + ({ config } = workflowData); + unit = createSubworkflowUnit({ + appName, + unitData, + workflowData: workflowSubworkflowMapByApplication, + ...swArgs, + }); + break; + default: + break; + } + wfUnits.push({ config, unit, type }); + return null; + }); + return createFromWorkflowUnits({ + wfUnits, + workflowCls, + subworkflowCls: swArgs.subworkflowCls, + unitFactoryCls: swArgs.unitFactoryCls, + }); +} +function createWorkflow({ appName, workflowData, workflowSubworkflowMapByApplication, workflowCls = workflow_1.Workflow, ...swArgs }) { + const { name } = workflowData; + console.log(`wode: creating ${appName} workflow ${name}`); + const wf = createWorkflowUnits({ + appName, + workflowData, + workflowSubworkflowMapByApplication, + workflowCls, + ...swArgs, }); - return null; - }); - return createFromWorkflowUnits({ - wfUnits, - workflowCls, - subworkflowCls: swArgs.subworkflowCls, - unitFactoryCls: swArgs.unitFactoryCls - }); + wf.setName(name); + wf.applicationName = appName; + return wf; } -function createWorkflow({ - appName, - workflowData, - workflowSubworkflowMapByApplication, - workflowCls = _workflow.Workflow, - ...swArgs -}) { - const { - name - } = workflowData; - console.log(`wode: creating ${appName} workflow ${name}`); - const wf = createWorkflowUnits({ - appName, - workflowData, - workflowSubworkflowMapByApplication, - workflowCls, - ...swArgs - }); - wf.setName(name); - wf.applicationName = appName; - return wf; -} \ No newline at end of file diff --git a/dist/js/workflows/default.d.ts b/dist/js/workflows/default.d.ts new file mode 100644 index 00000000..1a74f6f7 --- /dev/null +++ b/dist/js/workflows/default.d.ts @@ -0,0 +1,36 @@ +declare namespace _default { + let name: string; + let properties: never[]; + let subworkflows: { + _id: string; + application: { + name: string; + summary: string; + version: string; + }; + model: { + method: { + subtype: string; + type: string; + }; + subtype: string; + type: string; + }; + name: string; + properties: never[]; + units: never[]; + }[]; + let workflows: never[]; + let units: { + _id: string; + flowchartId: string; + head: boolean; + monitors: never[]; + postProcessors: never[]; + preProcessors: never[]; + results: never[]; + type: string; + name: string; + }[]; +} +export default _default; diff --git a/dist/js/workflows/default.js b/dist/js/workflows/default.js index 98fdef36..ed743f2a 100644 --- a/dist/js/workflows/default.js +++ b/dist/js/workflows/default.js @@ -1,41 +1,41 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _default = exports.default = { - name: "New Workflow", - properties: [], - subworkflows: [{ - _id: "c6e9dbbee8929de01f4e76ee", - application: { - name: "espresso", - summary: "Quantum Espresso", - version: "6.3" - }, - model: { - method: { - subtype: "us", - type: "pseudopotential" - }, - subtype: "gga", - type: "dft" - }, - name: "New Subworkflow", +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = { + name: "New Workflow", properties: [], - units: [] - }], - workflows: [], - units: [{ - _id: "c6e9dbbee8929de01f4e76ee", - flowchartId: "da2c090ede4dc2fa6e66647f", - head: true, - monitors: [], - postProcessors: [], - preProcessors: [], - results: [], - type: "subworkflow", - name: "New Subworkflow" - }] -}; \ No newline at end of file + subworkflows: [ + { + _id: "c6e9dbbee8929de01f4e76ee", + application: { + name: "espresso", + summary: "Quantum Espresso", + version: "6.3", + }, + model: { + method: { + subtype: "us", + type: "pseudopotential", + }, + subtype: "gga", + type: "dft", + }, + name: "New Subworkflow", + properties: [], + units: [], + }, + ], + workflows: [], + units: [ + { + _id: "c6e9dbbee8929de01f4e76ee", + flowchartId: "da2c090ede4dc2fa6e66647f", + head: true, + monitors: [], + postProcessors: [], + preProcessors: [], + results: [], + type: "subworkflow", + name: "New Subworkflow", + }, + ], +}; diff --git a/dist/js/workflows/index.d.ts b/dist/js/workflows/index.d.ts new file mode 100644 index 00000000..f84e75a6 --- /dev/null +++ b/dist/js/workflows/index.d.ts @@ -0,0 +1,18 @@ +import { Workflow } from "./workflow"; +export function createWorkflows({ appName, workflowCls, workflowSubworkflowMapByApplication, ...swArgs }: { + [x: string]: any; + appName?: null | undefined; + workflowCls?: typeof Workflow | undefined; + workflowSubworkflowMapByApplication: any; +}): any[]; +/** + * @summary Create workflow configurations for all applications + * @param applications {Array} array of application names + * @param workflowCls {*} workflow class to instantiate + * @param workflowSubworkflowMapByApplication {Object} object containing all workflow/subworkflow map by application + * @param swArgs {Object} other classes for instantiation + * @returns {Array} array of workflow configurations + */ +export function createWorkflowConfigs({ applications, workflowCls, workflowSubworkflowMapByApplication, ...swArgs }: Array): Array; +import { createWorkflow } from "./create"; +export { Workflow, createWorkflow }; diff --git a/dist/js/workflows/index.js b/dist/js/workflows/index.js index c4a3d795..64462631 100644 --- a/dist/js/workflows/index.js +++ b/dist/js/workflows/index.js @@ -1,35 +1,23 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "Workflow", { - enumerable: true, - get: function () { - return _workflow.Workflow; - } -}); -Object.defineProperty(exports, "createWorkflow", { - enumerable: true, - get: function () { - return _create.createWorkflow; - } -}); -exports.createWorkflowConfigs = createWorkflowConfigs; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createWorkflow = exports.Workflow = void 0; exports.createWorkflows = createWorkflows; -var _ade = require("@mat3ra/ade"); -var _JSONSchemasInterface = _interopRequireDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); -var _schemas = _interopRequireDefault(require("@mat3ra/esse/dist/js/schemas.json")); -var _patch = require("../patch"); -var _create = require("./create"); -var _workflow = require("./workflow"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +exports.createWorkflowConfigs = createWorkflowConfigs; +const ade_1 = require("@mat3ra/ade"); +const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface")); +const schemas_json_1 = __importDefault(require("@mat3ra/esse/dist/js/schemas.json")); // Import Template here to apply context provider patch // eslint-disable-next-line no-unused-vars - +const patch_1 = require("../patch"); +const create_1 = require("./create"); +Object.defineProperty(exports, "createWorkflow", { enumerable: true, get: function () { return create_1.createWorkflow; } }); +const workflow_1 = require("./workflow"); +Object.defineProperty(exports, "Workflow", { enumerable: true, get: function () { return workflow_1.Workflow; } }); // Running this to set schemas for validation, removing the redundant data from application-flavors tree: `flavors` -_JSONSchemasInterface.default.setSchemas(_schemas.default); - +JSONSchemasInterface_1.default.setSchemas(schemas_json_1.default); /* Workflow construction follows these rules: 1. Workflow is constructed as a collection of subworkflows defined in JSON @@ -38,47 +26,37 @@ _JSONSchemasInterface.default.setSchemas(_schemas.default); 4. map units are added along with their workflows according to data in "units" 5. top-level subworkflows are added directly in the order also specified by "units" */ -function createWorkflows({ - appName = null, - workflowCls = _workflow.Workflow, - workflowSubworkflowMapByApplication, - ...swArgs -}) { - let apps = appName !== null ? [appName] : _ade.allApplications; - const allApplicationsFromWorkflowData = Object.keys(workflowSubworkflowMapByApplication.workflows); - // output warning if allApplications and allApplicationsFromWorkflowData do not match - if (appName === null) { - if (apps && apps.sort().join(",") !== allApplicationsFromWorkflowData.sort().join(",")) { - // eslint-disable-next-line no-console - console.warn(`Warning: allApplications and allApplicationsFromWorkflowData do not match: +function createWorkflows({ appName = null, workflowCls = workflow_1.Workflow, workflowSubworkflowMapByApplication, ...swArgs }) { + let apps = appName !== null ? [appName] : ade_1.allApplications; + const allApplicationsFromWorkflowData = Object.keys(workflowSubworkflowMapByApplication.workflows); + // output warning if allApplications and allApplicationsFromWorkflowData do not match + if (appName === null) { + if (apps && apps.sort().join(",") !== allApplicationsFromWorkflowData.sort().join(",")) { + // eslint-disable-next-line no-console + console.warn(`Warning: allApplications and allApplicationsFromWorkflowData do not match: ${apps.sort().join(",")} !== ${allApplicationsFromWorkflowData.sort().join(",")}`); - console.warn("Using allApplicationsFromWorkflowData"); + console.warn("Using allApplicationsFromWorkflowData"); + } + apps = allApplicationsFromWorkflowData; } - apps = allApplicationsFromWorkflowData; - } - const wfs = []; - const { - workflows - } = workflowSubworkflowMapByApplication; - apps.map(name => { - const { - [name]: dataByApp - } = workflows; - Object.values(dataByApp).map(workflowDataForApp => { - wfs.push((0, _create.createWorkflow)({ - appName: name, - workflowData: workflowDataForApp, - workflowSubworkflowMapByApplication, - workflowCls, - ...swArgs - })); - return null; + const wfs = []; + const { workflows } = workflowSubworkflowMapByApplication; + apps.map((name) => { + const { [name]: dataByApp } = workflows; + Object.values(dataByApp).map((workflowDataForApp) => { + wfs.push((0, create_1.createWorkflow)({ + appName: name, + workflowData: workflowDataForApp, + workflowSubworkflowMapByApplication, + workflowCls, + ...swArgs, + })); + return null; + }); + return null; }); - return null; - }); - return wfs; + return wfs; } - /** * @summary Create workflow configurations for all applications * @param applications {Array} array of application names @@ -87,27 +65,22 @@ function createWorkflows({ * @param swArgs {Object} other classes for instantiation * @returns {Array} array of workflow configurations */ -function createWorkflowConfigs({ - applications, - workflowCls = _workflow.Workflow, - workflowSubworkflowMapByApplication, - ...swArgs -}) { - const configs = []; - applications.forEach(app => { - const workflows = createWorkflows({ - appName: app, - workflowCls, - workflowSubworkflowMapByApplication, - ...swArgs +function createWorkflowConfigs({ applications, workflowCls = workflow_1.Workflow, workflowSubworkflowMapByApplication, ...swArgs }) { + const configs = []; + applications.forEach((app) => { + const workflows = createWorkflows({ + appName: app, + workflowCls, + workflowSubworkflowMapByApplication, + ...swArgs, + }); + workflows.forEach((wf) => { + configs.push({ + application: app, + name: wf.prop("name"), + config: wf.toJSON(), + }); + }); }); - workflows.forEach(wf => { - configs.push({ - application: app, - name: wf.prop("name"), - config: wf.toJSON() - }); - }); - }); - return configs; -} \ No newline at end of file + return configs; +} diff --git a/dist/js/workflows/relaxation.d.ts b/dist/js/workflows/relaxation.d.ts new file mode 100644 index 00000000..060471fc --- /dev/null +++ b/dist/js/workflows/relaxation.d.ts @@ -0,0 +1,10 @@ +export function RelaxationLogicMixin(superclass: any): { + new (): { + [x: string]: any; + get relaxationSubworkflow(): any; + isRelaxationSubworkflow(subworkflow: any): boolean; + get hasRelaxation(): any; + toggleRelaxation(): void; + }; + [x: string]: any; +}; diff --git a/dist/js/workflows/relaxation.js b/dist/js/workflows/relaxation.js index 82f218db..13214f2f 100644 --- a/dist/js/workflows/relaxation.js +++ b/dist/js/workflows/relaxation.js @@ -1,38 +1,38 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +Object.defineProperty(exports, "__esModule", { value: true }); exports.RelaxationLogicMixin = void 0; -var _standata = require("@mat3ra/standata"); -const RelaxationLogicMixin = superclass => class extends superclass { - get relaxationSubworkflow() { - const appName = this.subworkflows[0]?.application?.name; - if (!appName) return undefined; - const subworkflowStandata = new _standata.SubworkflowStandata(); - const relaxationSubworkflow = subworkflowStandata.getRelaxationSubworkflowByApplication(appName); - if (!relaxationSubworkflow) return undefined; - return new this._Subworkflow(relaxationSubworkflow); - } - isRelaxationSubworkflow(subworkflow) { - const { - relaxationSubworkflow - } = this; - return relaxationSubworkflow?.systemName !== undefined && relaxationSubworkflow.systemName === subworkflow.systemName; - } - get hasRelaxation() { - return this.subworkflows.some(subworkflow => this.isRelaxationSubworkflow(subworkflow)); - } - toggleRelaxation() { - if (this.hasRelaxation) { - const relaxSubworkflow = this.subworkflows.find(sw => this.isRelaxationSubworkflow(sw)); - this.removeSubworkflow(relaxSubworkflow.id); - } else { - const vcRelax = this.relaxationSubworkflow; - if (vcRelax) { - this.addSubworkflow(vcRelax, true); - } +const standata_1 = require("@mat3ra/standata"); +const RelaxationLogicMixin = (superclass) => class extends superclass { + get relaxationSubworkflow() { + var _a, _b; + const appName = (_b = (_a = this.subworkflows[0]) === null || _a === void 0 ? void 0 : _a.application) === null || _b === void 0 ? void 0 : _b.name; + if (!appName) + return undefined; + const subworkflowStandata = new standata_1.SubworkflowStandata(); + const relaxationSubworkflow = subworkflowStandata.getRelaxationSubworkflowByApplication(appName); + if (!relaxationSubworkflow) + return undefined; + return new this._Subworkflow(relaxationSubworkflow); + } + isRelaxationSubworkflow(subworkflow) { + const { relaxationSubworkflow } = this; + return ((relaxationSubworkflow === null || relaxationSubworkflow === void 0 ? void 0 : relaxationSubworkflow.systemName) !== undefined && + relaxationSubworkflow.systemName === subworkflow.systemName); + } + get hasRelaxation() { + return this.subworkflows.some((subworkflow) => this.isRelaxationSubworkflow(subworkflow)); + } + toggleRelaxation() { + if (this.hasRelaxation) { + const relaxSubworkflow = this.subworkflows.find((sw) => this.isRelaxationSubworkflow(sw)); + this.removeSubworkflow(relaxSubworkflow.id); + } + else { + const vcRelax = this.relaxationSubworkflow; + if (vcRelax) { + this.addSubworkflow(vcRelax, true); + } + } } - } }; -exports.RelaxationLogicMixin = RelaxationLogicMixin; \ No newline at end of file +exports.RelaxationLogicMixin = RelaxationLogicMixin; diff --git a/dist/js/workflows/workflow.d.ts b/dist/js/workflows/workflow.d.ts new file mode 100644 index 00000000..59c86476 --- /dev/null +++ b/dist/js/workflows/workflow.d.ts @@ -0,0 +1,4555 @@ +export class Workflow extends BaseWorkflow { + static getDefaultComputeConfig: any; + static jsonSchema: { + $id: string; + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + subworkflows: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + properties: { + description: string; + type: string; + items: { + description: string; + type: string; + }; + }; + compute: { + $schema: string; + title: string; + description: string; + type: string; + required: string[]; + properties: { + queue: { + description: string; + type: string; + enum: string[]; + }; + nodes: { + description: string; + type: string; + }; + ppn: { + description: string; + type: string; + }; + timeLimit: { + description: string; + type: string; + }; + timeLimitType: { + description: string; + type: string; + default: string; + enum: string[]; + }; + isRestartable: { + description: string; + type: string; + default: boolean; + }; + notify: { + description: string; + type: string; + }; + email: { + description: string; + type: string; + }; + maxCPU: { + description: string; + type: string; + }; + arguments: { + description: string; + default: {}; + $schema: string; + title: string; + type: string; + additionalProperties: boolean; + properties: { + nimage: { + description: string; + type: string; + default: number; + minimum: number; + maximum: number; + }; + npools: { + description: string; + type: string; + default: number; + minimum: number; + maximum: number; + }; + nband: { + description: string; + type: string; + default: number; + minimum: number; + maximum: number; + }; + ntg: { + description: string; + type: string; + default: number; + minimum: number; + maximum: number; + }; + ndiag: { + description: string; + type: string; + default: number; + minimum: number; + maximum: number; + }; + }; + }; + cluster: { + description: string; + type: string; + properties: { + fqdn: { + description: string; + type: string; + }; + jid: { + description: string; + type: string; + }; + }; + }; + errors: { + description: string; + type: string; + items: { + type: string; + properties: { + domain: { + description: string; + type: string; + enum: string[]; + }; + reason: { + description: string; + type: string; + }; + message: { + description: string; + type: string; + }; + traceback: { + description: string; + type: string; + }; + }; + }; + }; + excludeFilesPattern: { + description: string; + type: string; + }; + }; + }; + units: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + oneOf: ({ + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + subtype: { + enum: string[]; + }; + source: { + enum: string[]; + }; + input: { + type: string; + items: { + oneOf: ({ + $schema: string; + title: string; + type: string; + properties: { + type: { + const: string; + }; + ids: { + description: string; + type: string; + items: { + type: string; + }; + }; + collection?: undefined; + draft?: undefined; + objectData?: undefined; + overwrite?: undefined; + pathname?: undefined; + basename?: undefined; + filetype?: undefined; + }; + required: string[]; + } | { + $schema: string; + title: string; + type: string; + properties: { + type: { + const: string; + }; + collection: { + description: string; + type: string; + }; + draft: { + description: string; + type: string; + }; + ids?: undefined; + objectData?: undefined; + overwrite?: undefined; + pathname?: undefined; + basename?: undefined; + filetype?: undefined; + }; + required: string[]; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + type: { + const: string; + }; + objectData: { + $schema: string; + title: string; + type: string; + properties: { + CONTAINER: { + description: string; + type: string; + }; + NAME: { + description: string; + type: string; + }; + PROVIDER: { + description: string; + type: string; + }; + REGION: { + description: string; + type: string; + }; + SIZE: { + description: string; + type: string; + }; + TIMESTAMP: { + description: string; + type: string; + }; + }; + }; + overwrite: { + description: string; + type: string; + }; + pathname: { + description: string; + type: string; + }; + basename: { + description: string; + type: string; + $comment: string; + }; + filetype: { + description: string; + type: string; + }; + ids?: undefined; + collection?: undefined; + draft?: undefined; + }; + })[]; + discriminator: { + propertyName: string; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + $schema?: undefined; + title?: undefined; + }; + description?: undefined; + }; + mapFlowchartId?: undefined; + statement?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + errorMessage?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + mapFlowchartId: { + description: string; + type: string; + }; + input: { + description: string; + type: string; + items: { + type: string; + required: string[]; + properties: { + operation: { + description: string; + type: string; + }; + arguments: { + description: string; + type: string; + items: { + type: string; + }; + }; + scope?: undefined; + name?: undefined; + template?: undefined; + rendered?: undefined; + isManuallyChanged?: undefined; + }; + oneOf?: undefined; + discriminator?: undefined; + $schema?: undefined; + title?: undefined; + }; + }; + subtype?: undefined; + source?: undefined; + statement?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + errorMessage?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + input: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + scope: { + description: string; + type: string; + }; + name: { + description: string; + type: string; + }; + operation?: undefined; + arguments?: undefined; + template?: undefined; + rendered?: undefined; + isManuallyChanged?: undefined; + }; + oneOf?: undefined; + discriminator?: undefined; + }; + }; + statement: { + description: string; + type: string; + }; + then: { + description: string; + type: string; + }; + else: { + description: string; + type: string; + }; + maxOccurrences: { + description: string; + type: string; + }; + throwException: { + description: string; + type: string; + }; + subtype?: undefined; + source?: undefined; + mapFlowchartId?: undefined; + errorMessage?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + statement: { + type: string; + description: string; + }; + errorMessage: { + type: string; + description: string; + }; + subtype?: undefined; + source?: undefined; + input?: undefined; + mapFlowchartId?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + application: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + shortName: { + description: string; + type: string; + }; + summary: { + description: string; + type: string; + }; + version: { + description: string; + type: string; + }; + build: { + description: string; + type: string; + }; + hasAdvancedComputeOptions: { + description: string; + type: string; + }; + isLicensed: { + description: string; + type: string; + }; + }; + }; + executable: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + applicationId: { + description: string; + type: string; + items: { + type: string; + }; + }; + hasAdvancedComputeOptions: { + description: string; + type: string; + }; + }; + }; + flavor: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + executableId: { + description: string; + type: string; + }; + executableName: { + description: string; + type: string; + }; + applicationName: { + description: string; + type: string; + }; + input: { + title: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + additionalProperties: boolean; + properties: { + templateId: { + type: string; + }; + templateName: { + type: string; + }; + name: { + description: string; + type: string; + }; + }; + }; + }; + supportedApplicationVersions: { + description: string; + type: string; + items: { + type: string; + }; + }; + }; + }; + input: { + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + template: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + applicationName: { + type: string; + }; + applicationVersion: { + type: string; + }; + executableName: { + type: string; + }; + contextProviders: { + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + content: { + description: string; + type: string; + }; + }; + }; + rendered: { + description: string; + type: string; + }; + isManuallyChanged: { + type: string; + default: boolean; + }; + operation?: undefined; + arguments?: undefined; + scope?: undefined; + name?: undefined; + }; + oneOf?: undefined; + discriminator?: undefined; + }; + description?: undefined; + }; + context: { + type: string; + items: { + type: string; + required: string[]; + properties: { + name: { + type: string; + tsType: string; + }; + isEdited: { + type: string; + }; + data: { + type: string; + }; + extraData: { + type: string; + }; + }; + }; + }; + subtype?: undefined; + source?: undefined; + mapFlowchartId?: undefined; + statement?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + errorMessage?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + scope: { + type: string; + }; + input: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + scope: { + description: string; + type: string; + }; + name: { + description: string; + type: string; + }; + operation?: undefined; + arguments?: undefined; + template?: undefined; + rendered?: undefined; + isManuallyChanged?: undefined; + }; + oneOf?: undefined; + discriminator?: undefined; + }; + }; + operand: { + description: string; + type: string; + }; + value: { + description: string; + oneOf: { + type: string; + }[]; + }; + subtype?: undefined; + source?: undefined; + mapFlowchartId?: undefined; + statement?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + errorMessage?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + operation: { + description: string; + type: string; + }; + operationType: { + description: string; + type: string; + }; + inputData: { + description: string; + }; + subtype?: undefined; + source?: undefined; + input?: undefined; + mapFlowchartId?: undefined; + statement?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + errorMessage?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + }; + })[]; + discriminator: { + propertyName: string; + }; + required: string[]; + }; + }; + model: { + $schema: string; + title: string; + type: string; + required: string[]; + additionalProperties: boolean; + properties: { + type: { + description: string; + type: string; + }; + subtype: { + description: string; + type: string; + }; + method: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + type: { + description: string; + type: string; + }; + subtype: { + description: string; + type: string; + }; + precision: { + description: string; + type: string; + }; + data: { + description: string; + type: string; + }; + }; + }; + }; + }; + application: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + shortName: { + description: string; + type: string; + }; + summary: { + description: string; + type: string; + }; + version: { + description: string; + type: string; + }; + build: { + description: string; + type: string; + }; + hasAdvancedComputeOptions: { + description: string; + type: string; + }; + isLicensed: { + description: string; + type: string; + }; + }; + }; + isDraft: { + description: string; + type: string; + default: boolean; + }; + }; + }; + }; + units: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + oneOf: ({ + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + subtype: { + enum: string[]; + }; + source: { + enum: string[]; + }; + input: { + type: string; + items: { + oneOf: ({ + $schema: string; + title: string; + type: string; + properties: { + type: { + const: string; + }; + ids: { + description: string; + type: string; + items: { + type: string; + }; + }; + collection?: undefined; + draft?: undefined; + objectData?: undefined; + overwrite?: undefined; + pathname?: undefined; + basename?: undefined; + filetype?: undefined; + }; + required: string[]; + } | { + $schema: string; + title: string; + type: string; + properties: { + type: { + const: string; + }; + collection: { + description: string; + type: string; + }; + draft: { + description: string; + type: string; + }; + ids?: undefined; + objectData?: undefined; + overwrite?: undefined; + pathname?: undefined; + basename?: undefined; + filetype?: undefined; + }; + required: string[]; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + type: { + const: string; + }; + objectData: { + $schema: string; + title: string; + type: string; + properties: { + CONTAINER: { + description: string; + type: string; + }; + NAME: { + description: string; + type: string; + }; + PROVIDER: { + description: string; + type: string; + }; + REGION: { + description: string; + type: string; + }; + SIZE: { + description: string; + type: string; + }; + TIMESTAMP: { + description: string; + type: string; + }; + }; + }; + overwrite: { + description: string; + type: string; + }; + pathname: { + description: string; + type: string; + }; + basename: { + description: string; + type: string; + $comment: string; + }; + filetype: { + description: string; + type: string; + }; + ids?: undefined; + collection?: undefined; + draft?: undefined; + }; + })[]; + discriminator: { + propertyName: string; + }; + type?: undefined; + required?: undefined; + properties?: undefined; + $schema?: undefined; + title?: undefined; + }; + description?: undefined; + required?: undefined; + properties?: undefined; + }; + mapFlowchartId?: undefined; + statement?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + errorMessage?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + workflowId?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + mapFlowchartId: { + description: string; + type: string; + }; + input: { + description: string; + type: string; + items: { + type: string; + required: string[]; + properties: { + operation: { + description: string; + type: string; + }; + arguments: { + description: string; + type: string; + items: { + type: string; + }; + }; + scope?: undefined; + name?: undefined; + template?: undefined; + rendered?: undefined; + isManuallyChanged?: undefined; + }; + oneOf?: undefined; + discriminator?: undefined; + $schema?: undefined; + title?: undefined; + }; + required?: undefined; + properties?: undefined; + }; + subtype?: undefined; + source?: undefined; + statement?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + errorMessage?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + workflowId?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + input: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + scope: { + description: string; + type: string; + }; + name: { + description: string; + type: string; + }; + operation?: undefined; + arguments?: undefined; + template?: undefined; + rendered?: undefined; + isManuallyChanged?: undefined; + }; + oneOf?: undefined; + discriminator?: undefined; + }; + required?: undefined; + properties?: undefined; + }; + statement: { + description: string; + type: string; + }; + then: { + description: string; + type: string; + }; + else: { + description: string; + type: string; + }; + maxOccurrences: { + description: string; + type: string; + }; + throwException: { + description: string; + type: string; + }; + subtype?: undefined; + source?: undefined; + mapFlowchartId?: undefined; + errorMessage?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + workflowId?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + statement: { + type: string; + description: string; + }; + errorMessage: { + type: string; + description: string; + }; + subtype?: undefined; + source?: undefined; + input?: undefined; + mapFlowchartId?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + workflowId?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + application: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + shortName: { + description: string; + type: string; + }; + summary: { + description: string; + type: string; + }; + version: { + description: string; + type: string; + }; + build: { + description: string; + type: string; + }; + hasAdvancedComputeOptions: { + description: string; + type: string; + }; + isLicensed: { + description: string; + type: string; + }; + }; + }; + executable: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + applicationId: { + description: string; + type: string; + items: { + type: string; + }; + }; + hasAdvancedComputeOptions: { + description: string; + type: string; + }; + }; + }; + flavor: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + executableId: { + description: string; + type: string; + }; + executableName: { + description: string; + type: string; + }; + applicationName: { + description: string; + type: string; + }; + input: { + title: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + additionalProperties: boolean; + properties: { + templateId: { + type: string; + }; + templateName: { + type: string; + }; + name: { + description: string; + type: string; + }; + }; + }; + }; + supportedApplicationVersions: { + description: string; + type: string; + items: { + type: string; + }; + }; + }; + }; + input: { + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + template: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + applicationName: { + type: string; + }; + applicationVersion: { + type: string; + }; + executableName: { + type: string; + }; + contextProviders: { + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + content: { + description: string; + type: string; + }; + }; + }; + rendered: { + description: string; + type: string; + }; + isManuallyChanged: { + type: string; + default: boolean; + }; + operation?: undefined; + arguments?: undefined; + scope?: undefined; + name?: undefined; + }; + oneOf?: undefined; + discriminator?: undefined; + }; + description?: undefined; + required?: undefined; + properties?: undefined; + }; + context: { + type: string; + items: { + type: string; + required: string[]; + properties: { + name: { + type: string; + tsType: string; + }; + isEdited: { + type: string; + }; + data: { + type: string; + }; + extraData: { + type: string; + }; + }; + }; + }; + subtype?: undefined; + source?: undefined; + mapFlowchartId?: undefined; + statement?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + errorMessage?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + workflowId?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + scope: { + type: string; + }; + input: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + scope: { + description: string; + type: string; + }; + name: { + description: string; + type: string; + }; + operation?: undefined; + arguments?: undefined; + template?: undefined; + rendered?: undefined; + isManuallyChanged?: undefined; + }; + oneOf?: undefined; + discriminator?: undefined; + }; + required?: undefined; + properties?: undefined; + }; + operand: { + description: string; + type: string; + }; + value: { + description: string; + oneOf: { + type: string; + }[]; + }; + subtype?: undefined; + source?: undefined; + mapFlowchartId?: undefined; + statement?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + errorMessage?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + workflowId?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + operation: { + description: string; + type: string; + }; + operationType: { + description: string; + type: string; + }; + inputData: { + description: string; + }; + subtype?: undefined; + source?: undefined; + input?: undefined; + mapFlowchartId?: undefined; + statement?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + errorMessage?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + workflowId?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + workflowId: { + description: string; + type: string; + }; + input: { + description: string; + type: string; + required: string[]; + properties: { + target: { + description: string; + type: string; + }; + scope: { + description: string; + type: string; + }; + name: { + description: string; + type: string; + }; + values: { + description: string; + type: string; + items: { + oneOf: { + type: string; + }[]; + }; + }; + useValues: { + type: string; + }; + }; + items?: undefined; + }; + subtype?: undefined; + source?: undefined; + mapFlowchartId?: undefined; + statement?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + errorMessage?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + }; + } | { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + preProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + postProcessors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + monitors: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + results: { + description: string; + type: string; + items: { + $schema: string; + title: string; + type: string; + required: string[]; + properties: { + name: { + description: string; + type: string; + }; + }; + }; + }; + tags: { + description: string; + type: string; + items: { + type: string; + }; + }; + status: { + type: string; + description: string; + enum: string[]; + }; + statusTrack: { + type: string; + items: { + type: string; + required: string[]; + properties: { + trackedAt: { + type: string; + }; + status: { + type: string; + }; + repetition: { + type: string; + }; + }; + }; + }; + isDraft: { + type: string; + }; + type: { + description: string; + type: string; + const: string; + }; + head: { + description: string; + type: string; + }; + flowchartId: { + description: string; + type: string; + }; + next: { + description: string; + type: string; + }; + enableRender: { + description: string; + type: string; + }; + subtype?: undefined; + source?: undefined; + input?: undefined; + mapFlowchartId?: undefined; + statement?: undefined; + then?: undefined; + else?: undefined; + maxOccurrences?: undefined; + throwException?: undefined; + errorMessage?: undefined; + application?: undefined; + executable?: undefined; + flavor?: undefined; + context?: undefined; + scope?: undefined; + operand?: undefined; + value?: undefined; + operation?: undefined; + operationType?: undefined; + inputData?: undefined; + workflowId?: undefined; + }; + })[]; + discriminator: { + propertyName: string; + }; + required: string[]; + }; + }; + properties: { + description: string; + type: string; + items: { + description: string; + oneOf: { + type: string; + }[]; + }; + }; + isUsingDataset: { + description: string; + type: string; + }; + workflows: { + description: string; + type: string; + items: { + type: string; + }; + }; + _id: { + description: string; + type: string; + }; + slug: { + description: string; + type: string; + }; + systemName: { + type: string; + }; + schemaVersion: { + description: string; + type: string; + default: string; + }; + name: { + description: string; + type: string; + }; + isDefault: { + description: string; + type: string; + default: boolean; + }; + metadata: { + type: string; + }; + }; + }; + static usePredefinedIds: boolean; + static get defaultConfig(): { + name: string; + properties: never[]; + subworkflows: { + _id: string; + application: { + name: string; + summary: string; + version: string; + }; + model: { + method: { + subtype: string; + type: string; + }; + subtype: string; + type: string; + }; + name: string; + properties: never[]; + units: never[]; + }[]; + workflows: never[]; + units: { + _id: string; + flowchartId: string; + head: boolean; + monitors: never[]; + postProcessors: never[]; + preProcessors: never[]; + results: never[]; + type: string; + name: string; + }[]; + }; + static generateWorkflowId(name: any, properties?: null, subworkflows?: null, applicationName?: null): any; + static fromSubworkflow(subworkflow: any, ClsConstructor?: typeof Workflow): Workflow; + static fromSubworkflows(name: any, ClsConstructor?: typeof Workflow, ...subworkflows: any[]): Workflow; + constructor(config: any, _Subworkflow?: typeof Subworkflow, _UnitFactory?: typeof UnitFactory, _Workflow?: typeof Workflow, _MapUnit?: typeof MapUnit); + _Subworkflow: typeof Subworkflow; + _UnitFactory: typeof UnitFactory; + _Workflow: typeof Workflow; + _MapUnit: typeof MapUnit; + initialize(): void; + _subworkflows: any; + _units: any; + _workflows: any; + /** + * @summary Adds subworkflow to current workflow. + * @param subworkflow {Subworkflow} + * @param head {Boolean} + */ + addSubworkflow(subworkflow: Subworkflow, head?: boolean, index?: number): void; + removeSubworkflow(id: any): void; + subworkflowId(index: any): any; + replaceSubworkflowAtIndex(index: any, newSubworkflow: any): void; + get units(): any; + setUnits(arr: any): void; + get usedApplications(): any[]; + get usedApplicationNames(): any[]; + get usedApplicationVersions(): any[]; + get usedApplicationNamesWithVersions(): string[]; + get usedModels(): any[]; + get humanReadableUsedModels(): any[]; + toJSON(exclude?: any[]): lodash.Omit; + get isDefault(): any; + set isMultiMaterial(value: any); + get isMultiMaterial(): any; + set isUsingDataset(value: boolean); + get isUsingDataset(): boolean; + get properties(): any[]; + get humanReadableProperties(): string[]; + get systemName(): string; + get defaultDescription(): string; + get exabyteId(): any; + get hash(): any; + get isOutdated(): any; + get history(): any; + setMethodData(methodData: any): void; + /** + * @param unit {Unit} + * @param head {Boolean} + * @param index {Number} + */ + addUnit(unit: Unit, head?: boolean, index?: number): void; + removeUnit(flowchartId: any): void; + /** + * @return Subworkflow[] + */ + get subworkflows(): any; + get workflows(): any; + addUnitType(type: any, head?: boolean, index?: number): void; + addMapUnit(mapUnit: any, mapWorkflow: any): void; + findSubworkflowById(id: any): any; + get allSubworkflows(): any[]; + /** + * @summary Calculates hash of the workflow. Meaningful fields are units and subworkflows. + * units and subworkflows must be sorted topologically before hashing (already sorted). + */ + calculateHash(): string; +} +declare class BaseWorkflow { +} +import { Subworkflow } from "../subworkflows/subworkflow"; +import { UnitFactory } from "../units/factory"; +import { MapUnit } from "../units"; +import lodash from "lodash"; +export {}; diff --git a/dist/js/workflows/workflow.js b/dist/js/workflows/workflow.js index be63ce13..0f6706d0 100644 --- a/dist/js/workflows/workflow.js +++ b/dist/js/workflows/workflow.js @@ -1,310 +1,314 @@ "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); exports.Workflow = void 0; -var _entity = require("@mat3ra/code/dist/js/entity"); -var _workflow = _interopRequireDefault(require("@mat3ra/esse/dist/js/schema/workflow.json")); -var _ide = require("@mat3ra/ide"); -var _mode = require("@mat3ra/mode"); -var _utils = require("@mat3ra/utils"); -var _lodash = _interopRequireDefault(require("lodash")); -var _mixwith = require("mixwith"); -var _underscore = _interopRequireDefault(require("underscore")); -var _underscore2 = _interopRequireDefault(require("underscore.string")); -var _enums = require("../enums"); -var _subworkflow = require("../subworkflows/subworkflow"); -var _units = require("../units"); -var _factory = require("../units/factory"); -var _utils2 = require("../utils"); -var _default = _interopRequireDefault(require("./default")); -var _relaxation = require("./relaxation"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable max-classes-per-file */ -const { - MODEL_NAMES -} = _mode.tree; -class BaseWorkflow extends (0, _mixwith.mix)(_entity.NamedDefaultableRepetitionContextAndRenderInMemoryEntity).with(_ide.ComputedEntityMixin, _relaxation.RelaxationLogicMixin) {} +/* eslint-disable max-classes-per-file */ +const entity_1 = require("@mat3ra/code/dist/js/entity"); +const workflow_json_1 = __importDefault(require("@mat3ra/esse/dist/js/schema/workflow.json")); +const ide_1 = require("@mat3ra/ide"); +const mode_1 = require("@mat3ra/mode"); +const utils_1 = require("@mat3ra/utils"); +const lodash_1 = __importDefault(require("lodash")); +const mixwith_1 = require("mixwith"); +const underscore_1 = __importDefault(require("underscore")); +const underscore_string_1 = __importDefault(require("underscore.string")); +const enums_1 = require("../enums"); +const subworkflow_1 = require("../subworkflows/subworkflow"); +const units_1 = require("../units"); +const factory_1 = require("../units/factory"); +const utils_2 = require("../utils"); +const default_1 = __importDefault(require("./default")); +const relaxation_1 = require("./relaxation"); +const { MODEL_NAMES } = mode_1.tree; +class BaseWorkflow extends (0, mixwith_1.mix)(entity_1.NamedDefaultableRepetitionContextAndRenderInMemoryEntity).with(ide_1.ComputedEntityMixin, relaxation_1.RelaxationLogicMixin) { +} class Workflow extends BaseWorkflow { - constructor(config, _Subworkflow = _subworkflow.Subworkflow, _UnitFactory = _factory.UnitFactory, _Workflow = Workflow, _MapUnit = _units.MapUnit) { - if (!config._id) { - config._id = Workflow.generateWorkflowId(config.name, config.properties, config.subworkflows, config.applicationName); - } - super(config); - this._Subworkflow = _Subworkflow; - this._UnitFactory = _UnitFactory; - this._Workflow = _Workflow; - this._MapUnit = _MapUnit; - if (!config.skipInitialize) this.initialize(); - } - initialize() { - const me = this; - this._subworkflows = this.prop("subworkflows").map(x => new me._Subworkflow(x)); - this._units = this.prop("units").map(unit => me._UnitFactory.create(unit)); - this._json.workflows = this._json.workflows || []; - this._workflows = this.prop("workflows").map(x => new me._Workflow(x)); - } - static get defaultConfig() { - return _default.default; - } - static generateWorkflowId(name, properties = null, subworkflows = null, applicationName = null) { - const propsInfo = properties?.length ? properties.sort().join(",") : ""; - const swInfo = subworkflows?.length ? subworkflows.map(sw => sw.name || "unknown").join(",") : ""; - const seed = [`workflow-${name}`, applicationName, propsInfo, swInfo].filter(p => p).join("-"); - if (this.usePredefinedIds) return _utils.Utils.uuid.getUUIDFromNamespace(seed); - return _utils.Utils.uuid.getUUID(); - } - static fromSubworkflow(subworkflow, ClsConstructor = Workflow) { - const config = { - name: subworkflow.name, - subworkflows: [subworkflow.toJSON()], - units: (0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)([subworkflow.getAsUnit().toJSON()])), - properties: subworkflow.properties, - applicationName: subworkflow.application.name - }; - return new ClsConstructor(config); - } - static fromSubworkflows(name, ClsConstructor = Workflow, ...subworkflows) { - return new ClsConstructor(name, subworkflows, subworkflows.map(sw => sw.getAsUnit())); - } - - /** - * @summary Adds subworkflow to current workflow. - * @param subworkflow {Subworkflow} - * @param head {Boolean} - */ - addSubworkflow(subworkflow, head = false, index = -1) { - const subworkflowUnit = subworkflow.getAsUnit(); - if (head) { - this.subworkflows.unshift(subworkflow); - this.addUnit(subworkflowUnit, head, index); - } else { - this.subworkflows.push(subworkflow); - this.addUnit(subworkflowUnit, head, index); - } - } - removeSubworkflow(id) { - const subworkflowUnit = this.units.find(u => u.id === id); - if (subworkflowUnit) this.removeUnit(subworkflowUnit.flowchartId); - } - subworkflowId(index) { - const sw = this.prop(`subworkflows[${index}]`); - return sw ? sw._id : null; - } - replaceSubworkflowAtIndex(index, newSubworkflow) { - this._subworkflows[index] = newSubworkflow; - this.setUnits((0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)(this._units))); - } - get units() { - return this._units; - } - setUnits(arr) { - this._units = arr; - } - - // returns a list of `app` Classes - get usedApplications() { - const swApplications = this.subworkflows.map(sw => sw.application); - const wfApplications = _lodash.default.flatten(this.workflows.map(w => w.usedApplications)); - return _lodash.default.uniqBy(swApplications.concat(wfApplications), a => a.name); - } - - // return application names - get usedApplicationNames() { - return this.usedApplications.map(a => a.name); - } - get usedApplicationVersions() { - return this.usedApplications.map(a => a.version); - } - get usedApplicationNamesWithVersions() { - return this.usedApplications.map(a => `${a.name} ${a.version}`); - } - get usedModels() { - return _lodash.default.uniq(this.subworkflows.map(sw => sw.model.type)); - } - get humanReadableUsedModels() { - return this.usedModels.filter(m => m !== "unknown").map(m => MODEL_NAMES[m]); - } - toJSON(exclude = []) { - return _lodash.default.omit({ - ...super.toJSON(), - units: this._units.map(x => x.toJSON()), - subworkflows: this._subworkflows.map(x => x.toJSON()), - workflows: this.workflows.map(x => x.toJSON()), - ...(this.compute ? { - compute: this.compute - } : {}) // {"compute": null } won't pass esse validation - }, exclude); - } - get isDefault() { - return this.prop("isDefault", false); - } - get isMultiMaterial() { - const fromSubworkflows = this.subworkflows.some(sw => sw.isMultiMaterial); - return this.prop("isMultiMaterial") || fromSubworkflows; - } - set isMultiMaterial(value) { - this.setProp("isMultiMaterial", value); - } - set isUsingDataset(value) { - this.setProp("isUsingDataset", value); - } - get isUsingDataset() { - return !!this.prop("isUsingDataset", false); - } - get properties() { - return _lodash.default.uniq(_lodash.default.flatten(this._subworkflows.map(x => x.properties))); - } - get humanReadableProperties() { - return this.properties.map(name => _underscore2.default.humanize(name)); - } - get systemName() { - return _underscore2.default.slugify(`${this.usedApplicationNames.join(":")}-${this.name.toLowerCase()}`); - } - get defaultDescription() { - return `${this.usedModels.join(", ").toUpperCase()} workflow using ${this.usedApplicationNames.join(", ")}.`; - } - get exabyteId() { - return this.prop("exabyteId"); - } - get hash() { - return this.prop("hash", ""); - } - get isOutdated() { - return this.prop("isOutdated", false); - } - get history() { - return this.prop("history", []); - } - setMethodData(methodData) { - this.subworkflows.forEach(sw => { - const method = methodData.getMethodBySubworkflow(sw); - if (method) sw.model.setMethod(method); - }); - this.workflows.forEach(wf => { - wf.subworkflows.forEach(sw => { - const method = methodData.getMethodBySubworkflow(sw); - if (method) sw.model.setMethod(method); - }); - }); - } - - /** - * @param unit {Unit} - * @param head {Boolean} - * @param index {Number} - */ - addUnit(unit, head = false, index = -1) { - const { - units - } = this; - if (units.length === 0) { - unit.head = true; - this.setUnits([unit]); - } else { - if (head) { - units.unshift(unit); - } else if (index >= 0) { - units.splice(index, 0, unit); - } else { - units.push(unit); - } - this.setUnits((0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)(units))); - } - } - removeUnit(flowchartId) { - if (this.units.length < 2) return; - const unit = this.units.find(x => x.flowchartId === flowchartId); - const previousUnit = this.units.find(x => x.next === unit.flowchartId); - if (previousUnit) { - delete previousUnit.next; - } - this._subworkflows = this._subworkflows.filter(x => x.id !== unit.id); - this._units = (0, _utils2.setNextLinks)((0, _utils2.setUnitsHead)(this._units.filter(x => x.flowchartId !== flowchartId))); - } - - /** - * @return Subworkflow[] - */ - get subworkflows() { - return this._subworkflows; - } - get workflows() { - return this._workflows; - } - - /* - * @param type {String|Object} Unit type, map or subworkflow - * @param head {Boolean} - * @param index {Number} Index at which the unit will be added. -1 by default (ignored). - */ - addUnitType(type, head = false, index = -1) { - switch (type) { - case _enums.UNIT_TYPES.map: - // eslint-disable-next-line no-case-declarations - const workflowConfig = _default.default; - // eslint-disable-next-line no-case-declarations - const mapUnit = new this._MapUnit(); - workflowConfig._id = this._Workflow.generateWorkflowId(workflowConfig.name, workflowConfig.properties, workflowConfig.subworkflows, this.applicationName); - this.prop("workflows").push(workflowConfig); - this._workflows = this.prop("workflows").map(x => new this._Workflow(x)); - mapUnit.setWorkflowId(workflowConfig._id); - this.addUnit(mapUnit, head, index); - break; - case _enums.UNIT_TYPES.subworkflow: - this.addSubworkflow(this._Subworkflow.createDefault(), head, index); - break; - default: - console.log(`unit_type=${type} unrecognized, skipping.`); - } - } - addMapUnit(mapUnit, mapWorkflow) { - const mapWorkflowConfig = mapWorkflow.toJSON(); - if (!mapWorkflowConfig._id) { - mapWorkflowConfig._id = this._Workflow.generateWorkflowId(mapWorkflowConfig.name, mapWorkflowConfig.properties, mapWorkflowConfig.subworkflows, mapWorkflow.applicationName || this.applicationName); - } - mapUnit.setWorkflowId(mapWorkflowConfig._id); - this.addUnit(mapUnit); - this._json.workflows.push(mapWorkflowConfig); - const me = this; - this._workflows = this.prop("workflows").map(x => new me._Workflow(x)); - } - findSubworkflowById(id) { - if (!id) return; - const workflows = this.workflows || []; - const subworkflows = this.subworkflows || []; - const subworkflow = subworkflows.find(sw => sw.id === id); - if (subworkflow) return subworkflow; - const workflow = workflows.find(w => w.findSubworkflowById(id)); - if (workflow) return workflow.findSubworkflowById(id); - console.warn("attempted to find a non-existing subworkflow"); - } - get allSubworkflows() { - const subworkflowsList = []; - this.subworkflows.forEach(sw => subworkflowsList.push(sw)); - this.workflows.forEach(workflow => { - return Array.prototype.push.apply(subworkflowsList, workflow.allSubworkflows); - }); - return subworkflowsList; - } - - /** - * @summary Calculates hash of the workflow. Meaningful fields are units and subworkflows. - * units and subworkflows must be sorted topologically before hashing (already sorted). - */ - calculateHash() { - const meaningfulFields = { - units: _underscore.default.map(this.units, u => u.calculateHash()).join(), - subworkflows: _underscore.default.map(this.subworkflows, sw => sw.calculateHash()).join(), - workflows: _underscore.default.map(this.workflows, w => w.calculateHash()).join() - }; - return _utils.Utils.hash.calculateHashFromObject(meaningfulFields); - } + constructor(config, _Subworkflow = subworkflow_1.Subworkflow, _UnitFactory = factory_1.UnitFactory, _Workflow = Workflow, _MapUnit = units_1.MapUnit) { + if (!config._id) { + config._id = Workflow.generateWorkflowId(config.name, config.properties, config.subworkflows, config.applicationName); + } + super(config); + this._Subworkflow = _Subworkflow; + this._UnitFactory = _UnitFactory; + this._Workflow = _Workflow; + this._MapUnit = _MapUnit; + if (!config.skipInitialize) + this.initialize(); + } + initialize() { + const me = this; + this._subworkflows = this.prop("subworkflows").map((x) => new me._Subworkflow(x)); + this._units = this.prop("units").map((unit) => me._UnitFactory.create(unit)); + this._json.workflows = this._json.workflows || []; + this._workflows = this.prop("workflows").map((x) => new me._Workflow(x)); + } + static get defaultConfig() { + return default_1.default; + } + static generateWorkflowId(name, properties = null, subworkflows = null, applicationName = null) { + const propsInfo = (properties === null || properties === void 0 ? void 0 : properties.length) ? properties.sort().join(",") : ""; + const swInfo = (subworkflows === null || subworkflows === void 0 ? void 0 : subworkflows.length) + ? subworkflows.map((sw) => sw.name || "unknown").join(",") + : ""; + const seed = [`workflow-${name}`, applicationName, propsInfo, swInfo] + .filter((p) => p) + .join("-"); + if (this.usePredefinedIds) + return utils_1.Utils.uuid.getUUIDFromNamespace(seed); + return utils_1.Utils.uuid.getUUID(); + } + static fromSubworkflow(subworkflow, ClsConstructor = Workflow) { + const config = { + name: subworkflow.name, + subworkflows: [subworkflow.toJSON()], + units: (0, utils_2.setNextLinks)((0, utils_2.setUnitsHead)([subworkflow.getAsUnit().toJSON()])), + properties: subworkflow.properties, + applicationName: subworkflow.application.name, + }; + return new ClsConstructor(config); + } + static fromSubworkflows(name, ClsConstructor = Workflow, ...subworkflows) { + return new ClsConstructor(name, subworkflows, subworkflows.map((sw) => sw.getAsUnit())); + } + /** + * @summary Adds subworkflow to current workflow. + * @param subworkflow {Subworkflow} + * @param head {Boolean} + */ + addSubworkflow(subworkflow, head = false, index = -1) { + const subworkflowUnit = subworkflow.getAsUnit(); + if (head) { + this.subworkflows.unshift(subworkflow); + this.addUnit(subworkflowUnit, head, index); + } + else { + this.subworkflows.push(subworkflow); + this.addUnit(subworkflowUnit, head, index); + } + } + removeSubworkflow(id) { + const subworkflowUnit = this.units.find((u) => u.id === id); + if (subworkflowUnit) + this.removeUnit(subworkflowUnit.flowchartId); + } + subworkflowId(index) { + const sw = this.prop(`subworkflows[${index}]`); + return sw ? sw._id : null; + } + replaceSubworkflowAtIndex(index, newSubworkflow) { + this._subworkflows[index] = newSubworkflow; + this.setUnits((0, utils_2.setNextLinks)((0, utils_2.setUnitsHead)(this._units))); + } + get units() { + return this._units; + } + setUnits(arr) { + this._units = arr; + } + // returns a list of `app` Classes + get usedApplications() { + const swApplications = this.subworkflows.map((sw) => sw.application); + const wfApplications = lodash_1.default.flatten(this.workflows.map((w) => w.usedApplications)); + return lodash_1.default.uniqBy(swApplications.concat(wfApplications), (a) => a.name); + } + // return application names + get usedApplicationNames() { + return this.usedApplications.map((a) => a.name); + } + get usedApplicationVersions() { + return this.usedApplications.map((a) => a.version); + } + get usedApplicationNamesWithVersions() { + return this.usedApplications.map((a) => `${a.name} ${a.version}`); + } + get usedModels() { + return lodash_1.default.uniq(this.subworkflows.map((sw) => sw.model.type)); + } + get humanReadableUsedModels() { + return this.usedModels.filter((m) => m !== "unknown").map((m) => MODEL_NAMES[m]); + } + toJSON(exclude = []) { + return lodash_1.default.omit({ + ...super.toJSON(), + units: this._units.map((x) => x.toJSON()), + subworkflows: this._subworkflows.map((x) => x.toJSON()), + workflows: this.workflows.map((x) => x.toJSON()), + ...(this.compute ? { compute: this.compute } : {}), // {"compute": null } won't pass esse validation + }, exclude); + } + get isDefault() { + return this.prop("isDefault", false); + } + get isMultiMaterial() { + const fromSubworkflows = this.subworkflows.some((sw) => sw.isMultiMaterial); + return this.prop("isMultiMaterial") || fromSubworkflows; + } + set isMultiMaterial(value) { + this.setProp("isMultiMaterial", value); + } + set isUsingDataset(value) { + this.setProp("isUsingDataset", value); + } + get isUsingDataset() { + return !!this.prop("isUsingDataset", false); + } + get properties() { + return lodash_1.default.uniq(lodash_1.default.flatten(this._subworkflows.map((x) => x.properties))); + } + get humanReadableProperties() { + return this.properties.map((name) => underscore_string_1.default.humanize(name)); + } + get systemName() { + return underscore_string_1.default.slugify(`${this.usedApplicationNames.join(":")}-${this.name.toLowerCase()}`); + } + get defaultDescription() { + return `${this.usedModels + .join(", ") + .toUpperCase()} workflow using ${this.usedApplicationNames.join(", ")}.`; + } + get exabyteId() { + return this.prop("exabyteId"); + } + get hash() { + return this.prop("hash", ""); + } + get isOutdated() { + return this.prop("isOutdated", false); + } + get history() { + return this.prop("history", []); + } + setMethodData(methodData) { + this.subworkflows.forEach((sw) => { + const method = methodData.getMethodBySubworkflow(sw); + if (method) + sw.model.setMethod(method); + }); + this.workflows.forEach((wf) => { + wf.subworkflows.forEach((sw) => { + const method = methodData.getMethodBySubworkflow(sw); + if (method) + sw.model.setMethod(method); + }); + }); + } + /** + * @param unit {Unit} + * @param head {Boolean} + * @param index {Number} + */ + addUnit(unit, head = false, index = -1) { + const { units } = this; + if (units.length === 0) { + unit.head = true; + this.setUnits([unit]); + } + else { + if (head) { + units.unshift(unit); + } + else if (index >= 0) { + units.splice(index, 0, unit); + } + else { + units.push(unit); + } + this.setUnits((0, utils_2.setNextLinks)((0, utils_2.setUnitsHead)(units))); + } + } + removeUnit(flowchartId) { + if (this.units.length < 2) + return; + const unit = this.units.find((x) => x.flowchartId === flowchartId); + const previousUnit = this.units.find((x) => x.next === unit.flowchartId); + if (previousUnit) { + delete previousUnit.next; + } + this._subworkflows = this._subworkflows.filter((x) => x.id !== unit.id); + this._units = (0, utils_2.setNextLinks)((0, utils_2.setUnitsHead)(this._units.filter((x) => x.flowchartId !== flowchartId))); + } + /** + * @return Subworkflow[] + */ + get subworkflows() { + return this._subworkflows; + } + get workflows() { + return this._workflows; + } + /* + * @param type {String|Object} Unit type, map or subworkflow + * @param head {Boolean} + * @param index {Number} Index at which the unit will be added. -1 by default (ignored). + */ + addUnitType(type, head = false, index = -1) { + switch (type) { + case enums_1.UNIT_TYPES.map: + // eslint-disable-next-line no-case-declarations + const workflowConfig = default_1.default; + // eslint-disable-next-line no-case-declarations + const mapUnit = new this._MapUnit(); + workflowConfig._id = this._Workflow.generateWorkflowId(workflowConfig.name, workflowConfig.properties, workflowConfig.subworkflows, this.applicationName); + this.prop("workflows").push(workflowConfig); + this._workflows = this.prop("workflows").map((x) => new this._Workflow(x)); + mapUnit.setWorkflowId(workflowConfig._id); + this.addUnit(mapUnit, head, index); + break; + case enums_1.UNIT_TYPES.subworkflow: + this.addSubworkflow(this._Subworkflow.createDefault(), head, index); + break; + default: + console.log(`unit_type=${type} unrecognized, skipping.`); + } + } + addMapUnit(mapUnit, mapWorkflow) { + const mapWorkflowConfig = mapWorkflow.toJSON(); + if (!mapWorkflowConfig._id) { + mapWorkflowConfig._id = this._Workflow.generateWorkflowId(mapWorkflowConfig.name, mapWorkflowConfig.properties, mapWorkflowConfig.subworkflows, mapWorkflow.applicationName || this.applicationName); + } + mapUnit.setWorkflowId(mapWorkflowConfig._id); + this.addUnit(mapUnit); + this._json.workflows.push(mapWorkflowConfig); + const me = this; + this._workflows = this.prop("workflows").map((x) => new me._Workflow(x)); + } + findSubworkflowById(id) { + if (!id) + return; + const workflows = this.workflows || []; + const subworkflows = this.subworkflows || []; + const subworkflow = subworkflows.find((sw) => sw.id === id); + if (subworkflow) + return subworkflow; + const workflow = workflows.find((w) => w.findSubworkflowById(id)); + if (workflow) + return workflow.findSubworkflowById(id); + console.warn("attempted to find a non-existing subworkflow"); + } + get allSubworkflows() { + const subworkflowsList = []; + this.subworkflows.forEach((sw) => subworkflowsList.push(sw)); + this.workflows.forEach((workflow) => { + return Array.prototype.push.apply(subworkflowsList, workflow.allSubworkflows); + }); + return subworkflowsList; + } + /** + * @summary Calculates hash of the workflow. Meaningful fields are units and subworkflows. + * units and subworkflows must be sorted topologically before hashing (already sorted). + */ + calculateHash() { + const meaningfulFields = { + units: underscore_1.default.map(this.units, (u) => u.calculateHash()).join(), + subworkflows: underscore_1.default.map(this.subworkflows, (sw) => sw.calculateHash()).join(), + workflows: underscore_1.default.map(this.workflows, (w) => w.calculateHash()).join(), + }; + return utils_1.Utils.hash.calculateHashFromObject(meaningfulFields); + } } exports.Workflow = Workflow; -_defineProperty(Workflow, "getDefaultComputeConfig", _ide.getDefaultComputeConfig); -_defineProperty(Workflow, "jsonSchema", _workflow.default); -_defineProperty(Workflow, "usePredefinedIds", false); \ No newline at end of file +Workflow.getDefaultComputeConfig = ide_1.getDefaultComputeConfig; +Workflow.jsonSchema = workflow_json_1.default; +Workflow.usePredefinedIds = false;