Skip to content

Commit e0b309f

Browse files
authored
0.14.6. (#51)
1 parent 53c9d33 commit e0b309f

12 files changed

+82
-22
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## O.14.6
2+
3+
Added comments to describe the `BranchedStepModelBuilder`, `SequentialStepModelBuilder` and `RootModelBuilder` classes.
4+
15
## O.14.5
26

37
Added comments to describe the `EditorProvider` class.

demos/webpack-app/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"sequential-workflow-model": "^0.2.0",
1919
"sequential-workflow-designer": "^0.21.2",
2020
"sequential-workflow-machine": "^0.4.0",
21-
"sequential-workflow-editor-model": "^0.14.5",
22-
"sequential-workflow-editor": "^0.14.5"
21+
"sequential-workflow-editor-model": "^0.14.6",
22+
"sequential-workflow-editor": "^0.14.6"
2323
},
2424
"devDependencies": {
2525
"ts-loader": "^9.4.2",

editor/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sequential-workflow-editor",
3-
"version": "0.14.5",
3+
"version": "0.14.6",
44
"type": "module",
55
"main": "./lib/esm/index.js",
66
"types": "./lib/index.d.ts",
@@ -46,11 +46,11 @@
4646
"prettier:fix": "prettier --write ./src ./css"
4747
},
4848
"dependencies": {
49-
"sequential-workflow-editor-model": "^0.14.5",
49+
"sequential-workflow-editor-model": "^0.14.6",
5050
"sequential-workflow-model": "^0.2.0"
5151
},
5252
"peerDependencies": {
53-
"sequential-workflow-editor-model": "^0.14.5",
53+
"sequential-workflow-editor-model": "^0.14.6",
5454
"sequential-workflow-model": "^0.2.0"
5555
},
5656
"devDependencies": {

model/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sequential-workflow-editor-model",
3-
"version": "0.14.5",
3+
"version": "0.14.6",
44
"homepage": "https://nocode-js.com/",
55
"author": {
66
"name": "NoCode JS",

model/src/builders/branched-step-model-builder.ts

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ const branchesPath = Path.create('branches');
99
export class BranchedStepModelBuilder<TStep extends BranchedStep> extends StepModelBuilder<TStep> {
1010
private readonly branchesBuilder = new PropertyModelBuilder<Branches>(branchesPath, this.circularDependencyDetector);
1111

12+
/**
13+
* @returns the builder for the branches property.
14+
* @example `builder.branches().value(createBranchesValueModel(...));`
15+
*/
1216
public branches(): PropertyModelBuilder<Branches, TStep['properties']> {
1317
return this.branchesBuilder;
1418
}

model/src/builders/root-model-builder.ts

+9
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,22 @@ export class RootModelBuilder<TProperties extends Properties> {
1212
private readonly propertyBuilders: PropertyModelBuilder[] = [];
1313
private readonly sequenceBuilder = new PropertyModelBuilder<Sequence, TProperties>(sequencePath, this.circularDependencyDetector);
1414

15+
/**
16+
* @param propertyName Name of the property.
17+
* @returns The builder for the property.
18+
* @example `builder.property('foo').value(createStringValueModel({ defaultValue: 'Some value' })).label('Foo');`
19+
*/
1520
public property<Key extends keyof TProperties>(propertyName: Key): PropertyModelBuilder<TProperties[Key], TProperties> {
1621
const path = Path.create(['properties', String(propertyName)]);
1722
const builder = new PropertyModelBuilder<TProperties[Key], TProperties>(path, this.circularDependencyDetector);
1823
this.propertyBuilders.push(builder);
1924
return builder;
2025
}
2126

27+
/**
28+
* @returns the builder for the sequence property.
29+
* @example `builder.sequence().value(createSequenceValueModel(...));`
30+
*/
2231
public sequence(): PropertyModelBuilder<Sequence> {
2332
return this.sequenceBuilder;
2433
}

model/src/builders/sequential-step-model-builder.ts

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export class SequentialStepModelBuilder<TStep extends SequentialStep> extends St
1313
this.circularDependencyDetector
1414
);
1515

16+
/**
17+
* @returns the builder for the sequence property.
18+
* @example `builder.sequence().value(createSequenceValueModel(...));`
19+
*/
1620
public sequence(): PropertyModelBuilder<Sequence> {
1721
return this.sequenceBuilder;
1822
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export interface ChoiceValueModelConfiguration<TValue extends string = string> {
2+
/**
3+
* Label. If not provided, the label is generated from the property name.
4+
*/
5+
label?: string;
6+
/**
7+
* Supported choices.
8+
*/
9+
choices: TValue[];
10+
/**
11+
* Default value.
12+
*/
13+
defaultValue?: TValue;
14+
/**
15+
* Custom editor ID.
16+
*/
17+
editorId?: string;
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { createValueContextStub } from '../../test-tools/value-context-stub';
2+
import { ChoiceValueModel } from './choice-value-model';
3+
import { ChoiceValueModelConfiguration } from './choice-value-model-configuration';
4+
import { choiceValueModelValidator } from './choice-value-model-validator';
5+
6+
describe('choiceValueModelValidator', () => {
7+
it('returns correct response', () => {
8+
const configuration: ChoiceValueModelConfiguration = {
9+
choices: ['x', 'y']
10+
};
11+
12+
const context1 = createValueContextStub<ChoiceValueModel>('z', configuration);
13+
const error1 = choiceValueModelValidator(context1);
14+
expect(error1?.$).toBe('Value is not supported');
15+
16+
const context2 = createValueContextStub<ChoiceValueModel>('x', configuration);
17+
const error2 = choiceValueModelValidator(context2);
18+
expect(error2).toBe(null);
19+
});
20+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { ValueContext } from '../../context';
2+
import { createValidationSingleError, ValidationResult } from '../../model';
3+
import { ChoiceValueModel } from './choice-value-model';
4+
5+
export function choiceValueModelValidator(context: ValueContext<ChoiceValueModel>): ValidationResult {
6+
const value = context.getValue();
7+
const configuration = context.model.configuration;
8+
if (!configuration.choices.includes(value)) {
9+
return createValidationSingleError(context.i18n('choice.notSupportedValue', 'Value is not supported'));
10+
}
11+
return null;
12+
}

model/src/value-models/choice/choice-value-model.ts

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
import { ValueModel, ValidationResult, createValidationSingleError, ValueModelFactory } from '../../model';
1+
import { ValueModel, ValueModelFactory } from '../../model';
22
import { Path } from '../../core/path';
3-
import { ValueContext } from '../../context';
4-
5-
export interface ChoiceValueModelConfiguration<TValue extends string = string> {
6-
label?: string;
7-
choices: TValue[];
8-
defaultValue?: TValue;
9-
editorId?: string;
10-
}
3+
import { ChoiceValueModelConfiguration } from './choice-value-model-configuration';
4+
import { choiceValueModelValidator } from './choice-value-model-validator';
115

126
export type ChoiceValueModel<TValue extends string = string> = ValueModel<TValue, ChoiceValueModelConfiguration<TValue>>;
137

@@ -37,13 +31,7 @@ export function createChoiceValueModel<TValue extends string>(
3731
return configuration.choices[0];
3832
},
3933
getVariableDefinitions: () => null,
40-
validate(context: ValueContext<ChoiceValueModel<TValue>>): ValidationResult {
41-
const value = context.getValue();
42-
if (!configuration.choices.includes(value)) {
43-
return createValidationSingleError(context.i18n('choice.notSupportedValue', 'Value is not supported'));
44-
}
45-
return null;
46-
}
34+
validate: choiceValueModelValidator
4735
})
4836
};
4937
}
+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export * from './choice-value-model-configuration';
12
export * from './choice-value-model';

0 commit comments

Comments
 (0)