From 2195e07add8843b06cc013b062a516d14b32f9c5 Mon Sep 17 00:00:00 2001 From: b4rtaz Date: Thu, 6 Jun 2024 22:19:10 +0200 Subject: [PATCH 1/2] 0.12.1. --- CHANGELOG.md | 4 ++++ demos/webpack-app/package.json | 4 ++-- editor/package.json | 6 +++--- model/package.json | 2 +- .../value-models/boolean/boolean-value-model-validator.ts | 2 +- .../branches/branches-value-model-validator.ts | 8 ++++---- model/src/value-models/choice/choice-value-model.ts | 4 ++-- .../value-models/number/number-value-model-validator.ts | 6 +++--- .../value-models/string/string-value-model-validator.ts | 6 +++--- 9 files changed, 23 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bab1b5..6948ffe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/demos/webpack-app/package.json b/demos/webpack-app/package.json index 9e92ecd..b654890 100644 --- a/demos/webpack-app/package.json +++ b/demos/webpack-app/package.json @@ -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", diff --git a/editor/package.json b/editor/package.json index 13996c2..c146616 100644 --- a/editor/package.json +++ b/editor/package.json @@ -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", @@ -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": { diff --git a/model/package.json b/model/package.json index a2cbdda..4445cd2 100644 --- a/model/package.json +++ b/model/package.json @@ -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", diff --git a/model/src/value-models/boolean/boolean-value-model-validator.ts b/model/src/value-models/boolean/boolean-value-model-validator.ts index 8ce3cdc..5d198ed 100644 --- a/model/src/value-models/boolean/boolean-value-model-validator.ts +++ b/model/src/value-models/boolean/boolean-value-model-validator.ts @@ -5,7 +5,7 @@ import { BooleanValueModel } from './boolean-value-model'; export function booleanValueModelValidator(context: ValueContext): 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; } diff --git a/model/src/value-models/branches/branches-value-model-validator.ts b/model/src/value-models/branches/branches-value-model-validator.ts index aeef989..4149139 100644 --- a/model/src/value-models/branches/branches-value-model-validator.ts +++ b/model/src/value-models/branches/branches-value-model-validator.ts @@ -10,21 +10,21 @@ export function branchesValueModelValidator( 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 }) ); } } diff --git a/model/src/value-models/choice/choice-value-model.ts b/model/src/value-models/choice/choice-value-model.ts index ba73f36..5d41f2b 100644 --- a/model/src/value-models/choice/choice-value-model.ts +++ b/model/src/value-models/choice/choice-value-model.ts @@ -27,7 +27,7 @@ export function createChoiceValueModel( 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; } @@ -37,7 +37,7 @@ export function createChoiceValueModel( validate(context: ValueContext>): 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; } diff --git a/model/src/value-models/number/number-value-model-validator.ts b/model/src/value-models/number/number-value-model-validator.ts index 89e1ae2..a5f3a0b 100644 --- a/model/src/value-models/number/number-value-model-validator.ts +++ b/model/src/value-models/number/number-value-model-validator.ts @@ -7,18 +7,18 @@ export function numberValueModelValidator(context: ValueContext 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) }) ); diff --git a/model/src/value-models/string/string-value-model-validator.ts b/model/src/value-models/string/string-value-model-validator.ts index 56acb0e..232d0d9 100644 --- a/model/src/value-models/string/string-value-model-validator.ts +++ b/model/src/value-models/string/string-value-model-validator.ts @@ -7,18 +7,18 @@ export function stringValueModelValidator(context: ValueContext Date: Thu, 6 Jun 2024 22:24:40 +0200 Subject: [PATCH 2/2] fix: tests. --- docs/I18N-KEYS.md | 24 +++++++++---------- .../validator/definition-validator.spec.ts | 6 ++--- .../boolean-value-model-validator.spec.ts | 2 +- .../branches-value-model-validator.spec.ts | 8 +++---- .../number-value-model-validator.spec.ts | 8 +++---- .../string-value-model-validator.spec.ts | 6 ++--- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/docs/I18N-KEYS.md b/docs/I18N-KEYS.md index 1ce22ac..809a4c2 100644 --- a/docs/I18N-KEYS.md +++ b/docs/I18N-KEYS.md @@ -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 -", @@ -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", diff --git a/model/src/validator/definition-validator.spec.ts b/model/src/validator/definition-validator.spec.ts index c9d31fd..9e7123c 100644 --- a/model/src/validator/definition-validator.spec.ts +++ b/model/src/validator/definition-validator.spec.ts @@ -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', () => { @@ -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', () => { @@ -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', () => { diff --git a/model/src/value-models/boolean/boolean-value-model-validator.spec.ts b/model/src/value-models/boolean/boolean-value-model-validator.spec.ts index 76e5744..5998cf9 100644 --- a/model/src/value-models/boolean/boolean-value-model-validator.spec.ts +++ b/model/src/value-models/boolean/boolean-value-model-validator.spec.ts @@ -12,6 +12,6 @@ describe('booleanValueModelValidator', () => { it('returns "The value must be a boolean" if value is not a boolean', () => { const context = createValueContextStub('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'); }); }); diff --git a/model/src/value-models/branches/branches-value-model-validator.spec.ts b/model/src/value-models/branches/branches-value-model-validator.spec.ts index fbe4997..e640b60 100644 --- a/model/src/value-models/branches/branches-value-model-validator.spec.ts +++ b/model/src/value-models/branches/branches-value-model-validator.spec.ts @@ -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', () => { @@ -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', () => { @@ -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', () => { @@ -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', () => { diff --git a/model/src/value-models/number/number-value-model-validator.spec.ts b/model/src/value-models/number/number-value-model-validator.spec.ts index 43b8377..5de3e1d 100644 --- a/model/src/value-models/number/number-value-model-validator.spec.ts +++ b/model/src/value-models/number/number-value-model-validator.spec.ts @@ -7,11 +7,11 @@ describe('numberValueModelValidator', () => { it('returns error when value is not a number', () => { const context1 = createValueContextStub(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('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', () => { @@ -21,7 +21,7 @@ describe('numberValueModelValidator', () => { const context = createValueContextStub(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', () => { @@ -31,7 +31,7 @@ describe('numberValueModelValidator', () => { const context = createValueContextStub(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', () => { diff --git a/model/src/value-models/string/string-value-model-validator.spec.ts b/model/src/value-models/string/string-value-model-validator.spec.ts index 55300dd..43a8dfa 100644 --- a/model/src/value-models/string/string-value-model-validator.spec.ts +++ b/model/src/value-models/string/string-value-model-validator.spec.ts @@ -11,7 +11,7 @@ describe('stringValueModelValidator', () => { const context1 = createValueContextStub('', 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('fo', configuration); const error2 = stringValueModelValidator(context2); @@ -21,7 +21,7 @@ describe('stringValueModelValidator', () => { it('returns error when value is not string', () => { const context1 = createValueContextStub(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', () => { @@ -31,7 +31,7 @@ describe('stringValueModelValidator', () => { const context1 = createValueContextStub('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('a', configuration); const error2 = stringValueModelValidator(context2);