Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.12.1. #35

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.12.1

This version normalizes translations.

## 0.12.0

This version introduces the localization feature. Now you can localize the editor to any language you want.
Expand Down
4 changes: 2 additions & 2 deletions demos/webpack-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"sequential-workflow-model": "^0.2.0",
"sequential-workflow-designer": "^0.21.1",
"sequential-workflow-machine": "^0.4.0",
"sequential-workflow-editor-model": "^0.12.0",
"sequential-workflow-editor": "^0.12.0"
"sequential-workflow-editor-model": "^0.12.1",
"sequential-workflow-editor": "^0.12.1"
},
"devDependencies": {
"ts-loader": "^9.4.2",
Expand Down
24 changes: 12 additions & 12 deletions docs/I18N-KEYS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ This document lists all the I18N keys used in the Sequential Workflow Editor.
"anyVariables.noVariablesSelected": "No variables selected",
"anyVariables.variableIsLost": "Variable :name is lost",
"boolean.false": "False",
"boolean.invalidType": "The value must be a boolean.",
"boolean.invalidType": "The value must be a boolean",
"boolean.true": "True",
"branches.empty": "No branches defined.",
"branches.invalidLength": "Invalid number of branches.",
"branches.missingBranch": "Missing branch: :name.",
"branches.mustBeObject": "The value must be object.",
"choice.notSupportedValue": "Value is not supported.",
"branches.empty": "No branches defined",
"branches.invalidLength": "Invalid number of branches",
"branches.missingBranch": "Missing branch: :name",
"branches.mustBeObject": "The value must be object",
"choice.notSupportedValue": "Value is not supported",
"generatedString.differentValue": "Generator returns different value than the current value",
"nullableAnyVariable.invalidVariableType": "The variable :name has invalid type",
"nullableAnyVariable.select": "- Select -",
Expand All @@ -29,12 +29,12 @@ This document lists all the I18N keys used in the Sequential Workflow Editor.
"nullableVariableDefinition.expectedType": "Variable type must be :type",
"nullableVariableDefinition.variableIsDuplicated": "Variable name is already used",
"nullableVariableDefinition.variableIsRequired": "The variable is required",
"number.valueMustBeNumber": "The value must be a number.",
"number.valueTooHigh": "The value must be at most :max.",
"number.valueTooLow": "The value must be at least :min.",
"string.valueDoesNotMatchPattern": "The value does not match the required pattern.",
"string.valueMustBeString": "The value must be a string.",
"string.valueTooShort": "The value must be at least :min characters long.",
"number.valueMustBeNumber": "The value must be a number",
"number.valueTooHigh": "The value must be at most :max",
"number.valueTooLow": "The value must be at least :min",
"string.valueDoesNotMatchPattern": "The value does not match the required pattern",
"string.valueMustBeString": "The value must be a string",
"string.valueTooShort": "The value must be at least :min characters long",
"stringDictionary.addItem": "Add item",
"stringDictionary.delete": "Delete",
"stringDictionary.duplicatedKey": "Key name is duplicated",
Expand Down
6 changes: 3 additions & 3 deletions editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sequential-workflow-editor",
"version": "0.12.0",
"version": "0.12.1",
"type": "module",
"main": "./lib/esm/index.js",
"types": "./lib/index.d.ts",
Expand Down Expand Up @@ -46,11 +46,11 @@
"prettier:fix": "prettier --write ./src ./css"
},
"dependencies": {
"sequential-workflow-editor-model": "^0.12.0",
"sequential-workflow-editor-model": "^0.12.1",
"sequential-workflow-model": "^0.2.0"
},
"peerDependencies": {
"sequential-workflow-editor-model": "^0.12.0",
"sequential-workflow-editor-model": "^0.12.1",
"sequential-workflow-model": "^0.2.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion model/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sequential-workflow-editor-model",
"version": "0.12.0",
"version": "0.12.1",
"homepage": "https://nocode-js.com/",
"author": {
"name": "NoCode JS",
Expand Down
6 changes: 3 additions & 3 deletions model/src/validator/definition-validator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('DefinitionValidator', () => {

expect(error?.stepId).toEqual(null);
expect(error?.propertyPath.toString()).toEqual('properties/velocity');
expect(error?.error.$).toEqual('The value must be at least 0.');
expect(error?.error.$).toEqual('The value must be at least 0');
});

it('returns error when step has invalid delta value', () => {
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('DefinitionValidator', () => {

expect(error?.stepId).toEqual('0xFFFFFF');
expect(error?.propertyPath.toString()).toEqual('properties/delta');
expect(error?.error.$).toEqual('The value must be at most 0.');
expect(error?.error.$).toEqual('The value must be at most 0');
});

it('returns error when step has invalid name', () => {
Expand All @@ -112,7 +112,7 @@ describe('DefinitionValidator', () => {

expect(error?.stepId).toEqual('0xAAAAAA');
expect(error?.propertyPath.toString()).toEqual('name');
expect(error?.error.$).toEqual('The value must be at least 1 characters long.');
expect(error?.error.$).toEqual('The value must be at least 1 characters long');
});

it('returns null when definition is valid', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ describe('booleanValueModelValidator', () => {
it('returns "The value must be a boolean" if value is not a boolean', () => {
const context = createValueContextStub<BooleanValueModel>('this is not a boolean', {});
const error = booleanValueModelValidator(context);
expect(error?.$).toBe('The value must be a boolean.');
expect(error?.$).toBe('The value must be a boolean');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BooleanValueModel } from './boolean-value-model';
export function booleanValueModelValidator(context: ValueContext<BooleanValueModel>): ValidationResult {
const value = context.getValue();
if (typeof value !== 'boolean') {
return createValidationSingleError(context.i18n('boolean.invalidType', 'The value must be a boolean.'));
return createValidationSingleError(context.i18n('boolean.invalidType', 'The value must be a boolean'));
}
return null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('branchesValueModelValidator', () => {
}
);
const error = branchesValueModelValidator(context);
expect(error?.$).toBe('No branches defined.');
expect(error?.$).toBe('No branches defined');
});

it('returns "Missing branch" if branch is missing', () => {
Expand All @@ -29,7 +29,7 @@ describe('branchesValueModelValidator', () => {
}
);
const error = branchesValueModelValidator(context);
expect(error?.$).toBe('Missing branch: false.');
expect(error?.$).toBe('Missing branch: false');
});

it('returns "Invalid number of branches" if there is more branches', () => {
Expand All @@ -47,7 +47,7 @@ describe('branchesValueModelValidator', () => {
}
);
const error = branchesValueModelValidator(context);
expect(error?.$).toBe('Invalid number of branches.');
expect(error?.$).toBe('Invalid number of branches');
});

it('returns "The value must be object" if there is not any branch', () => {
Expand All @@ -58,7 +58,7 @@ describe('branchesValueModelValidator', () => {
}
});
const error = branchesValueModelValidator(context);
expect(error?.$).toBe('The value must be object.');
expect(error?.$).toBe('The value must be object');
});

it('returns null if there is valid branches', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ export function branchesValueModelValidator<TBranches extends Branches>(
const branches = context.getValue();

if (typeof branches !== 'object') {
return createValidationSingleError(context.i18n('branches.mustBeObject', 'The value must be object.'));
return createValidationSingleError(context.i18n('branches.mustBeObject', 'The value must be object'));
}
const branchNames = Object.keys(branches);
if (branchNames.length === 0) {
return createValidationSingleError(context.i18n('branches.empty', 'No branches defined.'));
return createValidationSingleError(context.i18n('branches.empty', 'No branches defined'));
}
if (!configuration.dynamic) {
const configurationBranchNames = Object.keys(configuration.branches);
if (branchNames.length !== configurationBranchNames.length) {
return createValidationSingleError(context.i18n('branches.invalidLength', 'Invalid number of branches.'));
return createValidationSingleError(context.i18n('branches.invalidLength', 'Invalid number of branches'));
}
const missingBranchName = configurationBranchNames.find(branchName => !branchNames.includes(branchName));
if (missingBranchName) {
return createValidationSingleError(
context.i18n('branches.missingBranch', 'Missing branch: :name.', { name: missingBranchName })
context.i18n('branches.missingBranch', 'Missing branch: :name', { name: missingBranchName })
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions model/src/value-models/choice/choice-value-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function createChoiceValueModel<TValue extends string>(
getDefaultValue() {
if (configuration.defaultValue) {
if (!configuration.choices.includes(configuration.defaultValue)) {
throw new Error(`Default value "${configuration.defaultValue}" does not match any of the choices.`);
throw new Error(`Default value "${configuration.defaultValue}" does not match any of the choices`);
}
return configuration.defaultValue;
}
Expand All @@ -37,7 +37,7 @@ export function createChoiceValueModel<TValue extends string>(
validate(context: ValueContext<ChoiceValueModel<TValue>>): ValidationResult {
const value = context.getValue();
if (!configuration.choices.includes(value)) {
return createValidationSingleError(context.i18n('choice.notSupportedValue', 'Value is not supported.'));
return createValidationSingleError(context.i18n('choice.notSupportedValue', 'Value is not supported'));
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ describe('numberValueModelValidator', () => {
it('returns error when value is not a number', () => {
const context1 = createValueContextStub<NumberValueModel>(NaN, {});
const error1 = numberValueModelValidator(context1);
expect(error1?.$).toBe('The value must be a number.');
expect(error1?.$).toBe('The value must be a number');

const context2 = createValueContextStub<NumberValueModel>('10', {});
const error2 = numberValueModelValidator(context2);
expect(error2?.$).toBe('The value must be a number.');
expect(error2?.$).toBe('The value must be a number');
});

it('returns error when value is too small', () => {
Expand All @@ -21,7 +21,7 @@ describe('numberValueModelValidator', () => {

const context = createValueContextStub<NumberValueModel>(5, configuration);
const error = numberValueModelValidator(context);
expect(error?.$).toBe('The value must be at least 10.');
expect(error?.$).toBe('The value must be at least 10');
});

it('returns error when value is too big', () => {
Expand All @@ -31,7 +31,7 @@ describe('numberValueModelValidator', () => {

const context = createValueContextStub<NumberValueModel>(15, configuration);
const error = numberValueModelValidator(context);
expect(error?.$).toBe('The value must be at most 10.');
expect(error?.$).toBe('The value must be at most 10');
});

it('returns null when value is correct', () => {
Expand Down
6 changes: 3 additions & 3 deletions model/src/value-models/number/number-value-model-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ export function numberValueModelValidator(context: ValueContext<NumberValueModel
const configuration = context.model.configuration;

if (isNaN(value) || typeof value !== 'number') {
return createValidationSingleError(context.i18n('number.valueMustBeNumber', 'The value must be a number.'));
return createValidationSingleError(context.i18n('number.valueMustBeNumber', 'The value must be a number'));
}
if (configuration.min !== undefined && value < configuration.min) {
return createValidationSingleError(
context.i18n('number.valueTooLow', 'The value must be at least :min.', {
context.i18n('number.valueTooLow', 'The value must be at least :min', {
min: String(configuration.min)
})
);
}
if (configuration.max !== undefined && value > configuration.max) {
return createValidationSingleError(
context.i18n('number.valueTooHigh', 'The value must be at most :max.', {
context.i18n('number.valueTooHigh', 'The value must be at most :max', {
max: String(configuration.max)
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('stringValueModelValidator', () => {

const context1 = createValueContextStub<StringValueModel>('', configuration);
const error1 = stringValueModelValidator(context1);
expect(error1?.$).toBe('The value must be at least 2 characters long.');
expect(error1?.$).toBe('The value must be at least 2 characters long');

const context2 = createValueContextStub<StringValueModel>('fo', configuration);
const error2 = stringValueModelValidator(context2);
Expand All @@ -21,7 +21,7 @@ describe('stringValueModelValidator', () => {
it('returns error when value is not string', () => {
const context1 = createValueContextStub<StringValueModel>(0x123, {});
const error1 = stringValueModelValidator(context1);
expect(error1?.$).toBe('The value must be a string.');
expect(error1?.$).toBe('The value must be a string');
});

it('returns correct response when pattern is set', () => {
Expand All @@ -31,7 +31,7 @@ describe('stringValueModelValidator', () => {

const context1 = createValueContextStub<StringValueModel>('1', configuration);
const error1 = stringValueModelValidator(context1);
expect(error1?.$).toBe('The value does not match the required pattern.');
expect(error1?.$).toBe('The value does not match the required pattern');

const context2 = createValueContextStub<StringValueModel>('a', configuration);
const error2 = stringValueModelValidator(context2);
Expand Down
6 changes: 3 additions & 3 deletions model/src/value-models/string/string-value-model-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ export function stringValueModelValidator(context: ValueContext<StringValueModel
const configuration = context.model.configuration;

if (typeof value !== 'string') {
return createValidationSingleError(context.i18n('string.valueMustBeString', 'The value must be a string.'));
return createValidationSingleError(context.i18n('string.valueMustBeString', 'The value must be a string'));
}
if (configuration.minLength !== undefined && value.length < configuration.minLength) {
return createValidationSingleError(
context.i18n('string.valueTooShort', 'The value must be at least :min characters long.', {
context.i18n('string.valueTooShort', 'The value must be at least :min characters long', {
min: String(configuration.minLength)
})
);
}
if (configuration.pattern && !configuration.pattern.test(value)) {
return createValidationSingleError(
context.i18n('string.valueDoesNotMatchPattern', 'The value does not match the required pattern.')
context.i18n('string.valueDoesNotMatchPattern', 'The value does not match the required pattern')
);
}
return null;
Expand Down
Loading