sequential-workflow-editor-model
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -114,2 +114,3 @@ class ModelActivator { | ||
id: anyVariablesValueModelId, | ||
label: 'Variables', | ||
path, | ||
@@ -145,2 +146,3 @@ configuration, | ||
id: branchesValueModelId, | ||
label: 'Branches', | ||
path, | ||
@@ -173,2 +175,3 @@ configuration, | ||
id: choiceValueModelId, | ||
label: 'Choice', | ||
path, | ||
@@ -198,3 +201,3 @@ configuration, | ||
function dynamicValueModel(configuration) { | ||
if (configuration.choices.length < 1) { | ||
if (configuration.models.length < 1) { | ||
throw new Error('Dynamic value model must have at least one choice'); | ||
@@ -204,10 +207,11 @@ } | ||
const valuePath = path.add('value'); | ||
const childModels = configuration.choices.map(modelFactory => modelFactory(valuePath)); | ||
const subModels = configuration.models.map(modelFactory => modelFactory(valuePath)); | ||
return { | ||
id: dynamicValueModelId, | ||
label: 'Dynamic value', | ||
path, | ||
configuration, | ||
childModels, | ||
subModels, | ||
getDefaultValue(activator) { | ||
const model = childModels[0]; | ||
const model = subModels[0]; | ||
return { | ||
@@ -221,3 +225,3 @@ modelId: model.id, | ||
const value = context.getValue(); | ||
const model = childModels.find(m => m.id === value.modelId); | ||
const model = subModels.find(m => m.id === value.modelId); | ||
if (!model) { | ||
@@ -237,2 +241,3 @@ throw new Error(`Cannot find model id: ${value.modelId}`); | ||
id: nullableVariableValueModelId, | ||
label: 'Variable', | ||
path, | ||
@@ -277,2 +282,3 @@ configuration, | ||
id: nullableVariableDefinitionValueModelId, | ||
label: 'Variable definition', | ||
path, | ||
@@ -316,2 +322,3 @@ configuration, | ||
id: numberValueModelId, | ||
label: 'Number', | ||
path, | ||
@@ -349,2 +356,3 @@ configuration, | ||
id: sequenceValueModelId, | ||
label: 'Sequence', | ||
path, | ||
@@ -377,2 +385,3 @@ configuration, | ||
id: stringValueModelId, | ||
label: 'String', | ||
path, | ||
@@ -392,2 +401,3 @@ configuration, | ||
id: variableDefinitionsValueModelId, | ||
label: 'Variable definitions', | ||
path, | ||
@@ -394,0 +404,0 @@ configuration, |
@@ -142,5 +142,6 @@ import { Step, Definition, DefinitionWalker, PropertyValue, Properties, Sequence, ComponentType, BranchedStep, Branches, SequentialStep } from 'sequential-workflow-model'; | ||
id: ValueModelId; | ||
label: string; | ||
path: Path; | ||
configuration: TConfiguration; | ||
childModels?: ValueModel[]; | ||
subModels?: ValueModel[]; | ||
getDefaultValue(activator: ModelActivator): TValue; | ||
@@ -272,6 +273,6 @@ getVariableDefinitions(context: ValueModelContext<ValueModel<TValue, TConfiguration>>): VariableDefinition[] | null; | ||
interface DynamicValueModelConfiguration<TChoices extends ValueModelFactory[]> { | ||
choices: TChoices; | ||
interface DynamicValueModelConfiguration<TSubModels extends ValueModelFactory[]> { | ||
models: TSubModels; | ||
} | ||
type DynamicValueModel<TModels extends ValueModelFactory[] = ValueModelFactory[]> = ValueModel<Dynamic<TValueOf<TModels>>, DynamicValueModelConfiguration<ValueModelFactory[]>>; | ||
type DynamicValueModel<TSubModels extends ValueModelFactory[] = ValueModelFactory[]> = ValueModel<Dynamic<TValueOf<TSubModels>>, DynamicValueModelConfiguration<ValueModelFactory[]>>; | ||
type ReturnTypeOfModelFactory<TValueModelFactory> = TValueModelFactory extends ValueModelFactory<infer U>[] ? ReturnType<U['getDefaultValue']> : never; | ||
@@ -278,0 +279,0 @@ type TValueOf<TValueModelFactory extends ValueModelFactory[]> = ReturnTypeOfModelFactory<TValueModelFactory>; |
{ | ||
"name": "sequential-workflow-editor-model", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://nocode-js.com/", | ||
@@ -73,2 +73,2 @@ "author": { | ||
] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
122200
2029