@wisemen/nestjs-custom-fields 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +59 -0
- package/README.md +279 -0
- package/dist/custom-field-choice.d.ts +6 -0
- package/dist/custom-field-choice.js +2 -0
- package/dist/custom-field-choice.js.map +1 -0
- package/dist/custom-field-definition.d.ts +41 -0
- package/dist/custom-field-definition.js +2 -0
- package/dist/custom-field-definition.js.map +1 -0
- package/dist/custom-field-definition.uuid.d.ts +7 -0
- package/dist/custom-field-definition.uuid.js +4 -0
- package/dist/custom-field-definition.uuid.js.map +1 -0
- package/dist/custom-field-rules.d.ts +28 -0
- package/dist/custom-field-rules.js +2 -0
- package/dist/custom-field-rules.js.map +1 -0
- package/dist/custom-field-type-contract.d.ts +38 -0
- package/dist/custom-field-type-contract.js +2 -0
- package/dist/custom-field-type-contract.js.map +1 -0
- package/dist/custom-field-types/boolean/boolean.contract.d.ts +8 -0
- package/dist/custom-field-types/boolean/boolean.contract.js +2 -0
- package/dist/custom-field-types/boolean/boolean.contract.js.map +1 -0
- package/dist/custom-field-types/boolean/boolean.custom-field-definition.factory.unit.test.d.ts +1 -0
- package/dist/custom-field-types/boolean/boolean.custom-field-definition.factory.unit.test.js +21 -0
- package/dist/custom-field-types/boolean/boolean.custom-field-definition.factory.unit.test.js.map +1 -0
- package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.d.ts +1 -0
- package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.js +2 -0
- package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.js.map +1 -0
- package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.unit.test.d.ts +1 -0
- package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.unit.test.js +24 -0
- package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.unit.test.js.map +1 -0
- package/dist/custom-field-types/boolean/boolean.definition-validation.d.ts +7 -0
- package/dist/custom-field-types/boolean/boolean.definition-validation.js +10 -0
- package/dist/custom-field-types/boolean/boolean.definition-validation.js.map +1 -0
- package/dist/custom-field-types/boolean/boolean.dto.d.ts +9 -0
- package/dist/custom-field-types/boolean/boolean.dto.js +33 -0
- package/dist/custom-field-types/boolean/boolean.dto.js.map +1 -0
- package/dist/custom-field-types/boolean/boolean.rules.d.ts +5 -0
- package/dist/custom-field-types/boolean/boolean.rules.js +2 -0
- package/dist/custom-field-types/boolean/boolean.rules.js.map +1 -0
- package/dist/custom-field-types/boolean/boolean.value.d.ts +5 -0
- package/dist/custom-field-types/boolean/boolean.value.js +2 -0
- package/dist/custom-field-types/boolean/boolean.value.js.map +1 -0
- package/dist/custom-field-types/boolean/index.d.ts +6 -0
- package/dist/custom-field-types/boolean/index.js +7 -0
- package/dist/custom-field-types/boolean/index.js.map +1 -0
- package/dist/custom-field-types/date/date.contract.d.ts +12 -0
- package/dist/custom-field-types/date/date.contract.js +2 -0
- package/dist/custom-field-types/date/date.contract.js.map +1 -0
- package/dist/custom-field-types/date/date.custom-field-definition.factory.unit.test.d.ts +1 -0
- package/dist/custom-field-types/date/date.custom-field-definition.factory.unit.test.js +70 -0
- package/dist/custom-field-types/date/date.custom-field-definition.factory.unit.test.js.map +1 -0
- package/dist/custom-field-types/date/date.custom-field-value.validator.d.ts +6 -0
- package/dist/custom-field-types/date/date.custom-field-value.validator.js +14 -0
- package/dist/custom-field-types/date/date.custom-field-value.validator.js.map +1 -0
- package/dist/custom-field-types/date/date.custom-field-value.validator.unit.test.d.ts +1 -0
- package/dist/custom-field-types/date/date.custom-field-value.validator.unit.test.js +47 -0
- package/dist/custom-field-types/date/date.custom-field-value.validator.unit.test.js.map +1 -0
- package/dist/custom-field-types/date/date.definition-validation.d.ts +7 -0
- package/dist/custom-field-types/date/date.definition-validation.js +35 -0
- package/dist/custom-field-types/date/date.definition-validation.js.map +1 -0
- package/dist/custom-field-types/date/date.dto.d.ts +9 -0
- package/dist/custom-field-types/date/date.dto.js +34 -0
- package/dist/custom-field-types/date/date.dto.js.map +1 -0
- package/dist/custom-field-types/date/date.rules.d.ts +5 -0
- package/dist/custom-field-types/date/date.rules.js +2 -0
- package/dist/custom-field-types/date/date.rules.js.map +1 -0
- package/dist/custom-field-types/date/date.value.d.ts +5 -0
- package/dist/custom-field-types/date/date.value.js +2 -0
- package/dist/custom-field-types/date/date.value.js.map +1 -0
- package/dist/custom-field-types/date/index.d.ts +6 -0
- package/dist/custom-field-types/date/index.js +7 -0
- package/dist/custom-field-types/date/index.js.map +1 -0
- package/dist/custom-field-types/index.d.ts +9 -0
- package/dist/custom-field-types/index.js +10 -0
- package/dist/custom-field-types/index.js.map +1 -0
- package/dist/custom-field-types/monetary/index.d.ts +6 -0
- package/dist/custom-field-types/monetary/index.js +7 -0
- package/dist/custom-field-types/monetary/index.js.map +1 -0
- package/dist/custom-field-types/monetary/monetary.contract.d.ts +14 -0
- package/dist/custom-field-types/monetary/monetary.contract.js +2 -0
- package/dist/custom-field-types/monetary/monetary.contract.js.map +1 -0
- package/dist/custom-field-types/monetary/monetary.custom-field-definition.factory.unit.test.d.ts +1 -0
- package/dist/custom-field-types/monetary/monetary.custom-field-definition.factory.unit.test.js +98 -0
- package/dist/custom-field-types/monetary/monetary.custom-field-definition.factory.unit.test.js.map +1 -0
- package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.d.ts +6 -0
- package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.js +27 -0
- package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.js.map +1 -0
- package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.unit.test.d.ts +1 -0
- package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.unit.test.js +130 -0
- package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.unit.test.js.map +1 -0
- package/dist/custom-field-types/monetary/monetary.definition-validation.d.ts +7 -0
- package/dist/custom-field-types/monetary/monetary.definition-validation.js +25 -0
- package/dist/custom-field-types/monetary/monetary.definition-validation.js.map +1 -0
- package/dist/custom-field-types/monetary/monetary.dto.d.ts +10 -0
- package/dist/custom-field-types/monetary/monetary.dto.js +34 -0
- package/dist/custom-field-types/monetary/monetary.dto.js.map +1 -0
- package/dist/custom-field-types/monetary/monetary.rules.d.ts +5 -0
- package/dist/custom-field-types/monetary/monetary.rules.js +2 -0
- package/dist/custom-field-types/monetary/monetary.rules.js.map +1 -0
- package/dist/custom-field-types/monetary/monetary.value.d.ts +5 -0
- package/dist/custom-field-types/monetary/monetary.value.js +2 -0
- package/dist/custom-field-types/monetary/monetary.value.js.map +1 -0
- package/dist/custom-field-types/multi-select/index.d.ts +6 -0
- package/dist/custom-field-types/multi-select/index.js +7 -0
- package/dist/custom-field-types/multi-select/index.js.map +1 -0
- package/dist/custom-field-types/multi-select/multi-select.contract.d.ts +11 -0
- package/dist/custom-field-types/multi-select/multi-select.contract.js +2 -0
- package/dist/custom-field-types/multi-select/multi-select.contract.js.map +1 -0
- package/dist/custom-field-types/multi-select/multi-select.custom-field-definition.factory.unit.test.d.ts +1 -0
- package/dist/custom-field-types/multi-select/multi-select.custom-field-definition.factory.unit.test.js +169 -0
- package/dist/custom-field-types/multi-select/multi-select.custom-field-definition.factory.unit.test.js.map +1 -0
- package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.d.ts +5 -0
- package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.js +25 -0
- package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.js.map +1 -0
- package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.unit.test.d.ts +1 -0
- package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.unit.test.js +122 -0
- package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.unit.test.js.map +1 -0
- package/dist/custom-field-types/multi-select/multi-select.definition-validation.d.ts +7 -0
- package/dist/custom-field-types/multi-select/multi-select.definition-validation.js +45 -0
- package/dist/custom-field-types/multi-select/multi-select.definition-validation.js.map +1 -0
- package/dist/custom-field-types/multi-select/multi-select.dto.d.ts +9 -0
- package/dist/custom-field-types/multi-select/multi-select.dto.js +36 -0
- package/dist/custom-field-types/multi-select/multi-select.dto.js.map +1 -0
- package/dist/custom-field-types/multi-select/multi-select.rules.d.ts +5 -0
- package/dist/custom-field-types/multi-select/multi-select.rules.js +2 -0
- package/dist/custom-field-types/multi-select/multi-select.rules.js.map +1 -0
- package/dist/custom-field-types/multi-select/multi-select.value.d.ts +5 -0
- package/dist/custom-field-types/multi-select/multi-select.value.js +2 -0
- package/dist/custom-field-types/multi-select/multi-select.value.js.map +1 -0
- package/dist/custom-field-types/number/index.d.ts +6 -0
- package/dist/custom-field-types/number/index.js +7 -0
- package/dist/custom-field-types/number/index.js.map +1 -0
- package/dist/custom-field-types/number/number.contract.d.ts +11 -0
- package/dist/custom-field-types/number/number.contract.js +2 -0
- package/dist/custom-field-types/number/number.contract.js.map +1 -0
- package/dist/custom-field-types/number/number.custom-field-definition.factory.unit.test.d.ts +1 -0
- package/dist/custom-field-types/number/number.custom-field-definition.factory.unit.test.js +44 -0
- package/dist/custom-field-types/number/number.custom-field-definition.factory.unit.test.js.map +1 -0
- package/dist/custom-field-types/number/number.custom-field-value.validator.d.ts +5 -0
- package/dist/custom-field-types/number/number.custom-field-value.validator.js +14 -0
- package/dist/custom-field-types/number/number.custom-field-value.validator.js.map +1 -0
- package/dist/custom-field-types/number/number.custom-field-value.validator.unit.test.d.ts +1 -0
- package/dist/custom-field-types/number/number.custom-field-value.validator.unit.test.js +46 -0
- package/dist/custom-field-types/number/number.custom-field-value.validator.unit.test.js.map +1 -0
- package/dist/custom-field-types/number/number.definition-validation.d.ts +7 -0
- package/dist/custom-field-types/number/number.definition-validation.js +16 -0
- package/dist/custom-field-types/number/number.definition-validation.js.map +1 -0
- package/dist/custom-field-types/number/number.dto.d.ts +9 -0
- package/dist/custom-field-types/number/number.dto.js +33 -0
- package/dist/custom-field-types/number/number.dto.js.map +1 -0
- package/dist/custom-field-types/number/number.rules.d.ts +5 -0
- package/dist/custom-field-types/number/number.rules.js +2 -0
- package/dist/custom-field-types/number/number.rules.js.map +1 -0
- package/dist/custom-field-types/number/number.value.d.ts +5 -0
- package/dist/custom-field-types/number/number.value.js +2 -0
- package/dist/custom-field-types/number/number.value.js.map +1 -0
- package/dist/custom-field-types/single-select/index.d.ts +6 -0
- package/dist/custom-field-types/single-select/index.js +7 -0
- package/dist/custom-field-types/single-select/index.js.map +1 -0
- package/dist/custom-field-types/single-select/single-select.contract.d.ts +8 -0
- package/dist/custom-field-types/single-select/single-select.contract.js +2 -0
- package/dist/custom-field-types/single-select/single-select.contract.js.map +1 -0
- package/dist/custom-field-types/single-select/single-select.custom-field-definition.factory.unit.test.d.ts +1 -0
- package/dist/custom-field-types/single-select/single-select.custom-field-definition.factory.unit.test.js +100 -0
- package/dist/custom-field-types/single-select/single-select.custom-field-definition.factory.unit.test.js.map +1 -0
- package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.d.ts +5 -0
- package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.js +10 -0
- package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.js.map +1 -0
- package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.unit.test.d.ts +1 -0
- package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.unit.test.js +57 -0
- package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.unit.test.js.map +1 -0
- package/dist/custom-field-types/single-select/single-select.definition-validation.d.ts +7 -0
- package/dist/custom-field-types/single-select/single-select.definition-validation.js +25 -0
- package/dist/custom-field-types/single-select/single-select.definition-validation.js.map +1 -0
- package/dist/custom-field-types/single-select/single-select.dto.d.ts +9 -0
- package/dist/custom-field-types/single-select/single-select.dto.js +34 -0
- package/dist/custom-field-types/single-select/single-select.dto.js.map +1 -0
- package/dist/custom-field-types/single-select/single-select.rules.d.ts +5 -0
- package/dist/custom-field-types/single-select/single-select.rules.js +2 -0
- package/dist/custom-field-types/single-select/single-select.rules.js.map +1 -0
- package/dist/custom-field-types/single-select/single-select.value.d.ts +5 -0
- package/dist/custom-field-types/single-select/single-select.value.js +2 -0
- package/dist/custom-field-types/single-select/single-select.value.js.map +1 -0
- package/dist/custom-field-types/text/index.d.ts +6 -0
- package/dist/custom-field-types/text/index.js +7 -0
- package/dist/custom-field-types/text/index.js.map +1 -0
- package/dist/custom-field-types/text/text.contract.d.ts +12 -0
- package/dist/custom-field-types/text/text.contract.js +2 -0
- package/dist/custom-field-types/text/text.contract.js.map +1 -0
- package/dist/custom-field-types/text/text.custom-field-definition.factory.unit.test.d.ts +1 -0
- package/dist/custom-field-types/text/text.custom-field-definition.factory.unit.test.js +128 -0
- package/dist/custom-field-types/text/text.custom-field-definition.factory.unit.test.js.map +1 -0
- package/dist/custom-field-types/text/text.custom-field-value.validator.d.ts +5 -0
- package/dist/custom-field-types/text/text.custom-field-value.validator.js +17 -0
- package/dist/custom-field-types/text/text.custom-field-value.validator.js.map +1 -0
- package/dist/custom-field-types/text/text.custom-field-value.validator.unit.test.d.ts +1 -0
- package/dist/custom-field-types/text/text.custom-field-value.validator.unit.test.js +64 -0
- package/dist/custom-field-types/text/text.custom-field-value.validator.unit.test.js.map +1 -0
- package/dist/custom-field-types/text/text.definition-validation.d.ts +7 -0
- package/dist/custom-field-types/text/text.definition-validation.js +30 -0
- package/dist/custom-field-types/text/text.definition-validation.js.map +1 -0
- package/dist/custom-field-types/text/text.dto.d.ts +9 -0
- package/dist/custom-field-types/text/text.dto.js +33 -0
- package/dist/custom-field-types/text/text.dto.js.map +1 -0
- package/dist/custom-field-types/text/text.rules.d.ts +5 -0
- package/dist/custom-field-types/text/text.rules.js +2 -0
- package/dist/custom-field-types/text/text.rules.js.map +1 -0
- package/dist/custom-field-types/text/text.value.d.ts +5 -0
- package/dist/custom-field-types/text/text.value.js +2 -0
- package/dist/custom-field-types/text/text.value.js.map +1 -0
- package/dist/custom-field-types/text-array/index.d.ts +6 -0
- package/dist/custom-field-types/text-array/index.js +7 -0
- package/dist/custom-field-types/text-array/index.js.map +1 -0
- package/dist/custom-field-types/text-array/text-array.contract.d.ts +11 -0
- package/dist/custom-field-types/text-array/text-array.contract.js +2 -0
- package/dist/custom-field-types/text-array/text-array.contract.js.map +1 -0
- package/dist/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.d.ts +1 -0
- package/dist/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.js +71 -0
- package/dist/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.js.map +1 -0
- package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.d.ts +5 -0
- package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.js +14 -0
- package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.js.map +1 -0
- package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.d.ts +1 -0
- package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.js +46 -0
- package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.js.map +1 -0
- package/dist/custom-field-types/text-array/text-array.definition-validation.d.ts +7 -0
- package/dist/custom-field-types/text-array/text-array.definition-validation.js +22 -0
- package/dist/custom-field-types/text-array/text-array.definition-validation.js.map +1 -0
- package/dist/custom-field-types/text-array/text-array.dto.d.ts +9 -0
- package/dist/custom-field-types/text-array/text-array.dto.js +36 -0
- package/dist/custom-field-types/text-array/text-array.dto.js.map +1 -0
- package/dist/custom-field-types/text-array/text-array.rules.d.ts +5 -0
- package/dist/custom-field-types/text-array/text-array.rules.js +2 -0
- package/dist/custom-field-types/text-array/text-array.rules.js.map +1 -0
- package/dist/custom-field-types/text-array/text-array.value.d.ts +5 -0
- package/dist/custom-field-types/text-array/text-array.value.js +2 -0
- package/dist/custom-field-types/text-array/text-array.value.js.map +1 -0
- package/dist/custom-field-types/timestamp/index.d.ts +6 -0
- package/dist/custom-field-types/timestamp/index.js +7 -0
- package/dist/custom-field-types/timestamp/index.js.map +1 -0
- package/dist/custom-field-types/timestamp/timestamp.contract.d.ts +12 -0
- package/dist/custom-field-types/timestamp/timestamp.contract.js +2 -0
- package/dist/custom-field-types/timestamp/timestamp.contract.js.map +1 -0
- package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.d.ts +1 -0
- package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.js +70 -0
- package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.js.map +1 -0
- package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.d.ts +6 -0
- package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.js +14 -0
- package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.js.map +1 -0
- package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.unit.test.d.ts +1 -0
- package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.unit.test.js +47 -0
- package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.unit.test.js.map +1 -0
- package/dist/custom-field-types/timestamp/timestamp.definition-validation.d.ts +7 -0
- package/dist/custom-field-types/timestamp/timestamp.definition-validation.js +38 -0
- package/dist/custom-field-types/timestamp/timestamp.definition-validation.js.map +1 -0
- package/dist/custom-field-types/timestamp/timestamp.dto.d.ts +9 -0
- package/dist/custom-field-types/timestamp/timestamp.dto.js +35 -0
- package/dist/custom-field-types/timestamp/timestamp.dto.js.map +1 -0
- package/dist/custom-field-types/timestamp/timestamp.rules.d.ts +5 -0
- package/dist/custom-field-types/timestamp/timestamp.rules.js +2 -0
- package/dist/custom-field-types/timestamp/timestamp.rules.js.map +1 -0
- package/dist/custom-field-types/timestamp/timestamp.value.d.ts +5 -0
- package/dist/custom-field-types/timestamp/timestamp.value.js +2 -0
- package/dist/custom-field-types/timestamp/timestamp.value.js.map +1 -0
- package/dist/custom-field-value.d.ts +17 -0
- package/dist/custom-field-value.js +2 -0
- package/dist/custom-field-value.js.map +1 -0
- package/dist/decorators/is-custom-fields.decorator.d.ts +1 -0
- package/dist/decorators/is-custom-fields.decorator.js +14 -0
- package/dist/decorators/is-custom-fields.decorator.js.map +1 -0
- package/dist/dto/base-custom-field-value.dto.d.ts +15 -0
- package/dist/dto/base-custom-field-value.dto.js +33 -0
- package/dist/dto/base-custom-field-value.dto.js.map +1 -0
- package/dist/dto/custom-field-value.dto.d.ts +46 -0
- package/dist/dto/custom-field-value.dto.js +72 -0
- package/dist/dto/custom-field-value.dto.js.map +1 -0
- package/dist/dto/custom-field-value.dto.unit.test.d.ts +1 -0
- package/dist/dto/custom-field-value.dto.unit.test.js +74 -0
- package/dist/dto/custom-field-value.dto.unit.test.js.map +1 -0
- package/dist/enum/custom-field-type.enum.d.ts +15 -0
- package/dist/enum/custom-field-type.enum.js +28 -0
- package/dist/enum/custom-field-type.enum.js.map +1 -0
- package/dist/errors/custom-field-definition.error.d.ts +2 -0
- package/dist/errors/custom-field-definition.error.js +3 -0
- package/dist/errors/custom-field-definition.error.js.map +1 -0
- package/dist/exhaustive-check.d.ts +1 -0
- package/dist/exhaustive-check.js +4 -0
- package/dist/exhaustive-check.js.map +1 -0
- package/dist/factory/custom-field-definition.factory.d.ts +41 -0
- package/dist/factory/custom-field-definition.factory.js +125 -0
- package/dist/factory/custom-field-definition.factory.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/repositories/custom-field-definition.repository.module.d.ts +2 -0
- package/dist/repositories/custom-field-definition.repository.module.js +27 -0
- package/dist/repositories/custom-field-definition.repository.module.js.map +1 -0
- package/dist/repositories/custom-field-definitions.repository.d.ts +11 -0
- package/dist/repositories/custom-field-definitions.repository.integration.test.d.ts +1 -0
- package/dist/repositories/custom-field-definitions.repository.integration.test.js +174 -0
- package/dist/repositories/custom-field-definitions.repository.integration.test.js.map +1 -0
- package/dist/repositories/custom-field-definitions.repository.js +40 -0
- package/dist/repositories/custom-field-definitions.repository.js.map +1 -0
- package/dist/repositories/index.d.ts +2 -0
- package/dist/repositories/index.js +3 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/responses/custom-field-definition.response.d.ts +26 -0
- package/dist/responses/custom-field-definition.response.js +99 -0
- package/dist/responses/custom-field-definition.response.js.map +1 -0
- package/dist/responses/custom-field-definition.response.unit.test.d.ts +1 -0
- package/dist/responses/custom-field-definition.response.unit.test.js +96 -0
- package/dist/responses/custom-field-definition.response.unit.test.js.map +1 -0
- package/dist/tests/sql/datasource.d.ts +2 -0
- package/dist/tests/sql/datasource.js +17 -0
- package/dist/tests/sql/datasource.js.map +1 -0
- package/dist/tests/test-setup.d.ts +8 -0
- package/dist/tests/test-setup.js +46 -0
- package/dist/tests/test-setup.js.map +1 -0
- package/dist/typeorm/custom-field-choice.column.d.ts +2 -0
- package/dist/typeorm/custom-field-choice.column.js +49 -0
- package/dist/typeorm/custom-field-choice.column.js.map +1 -0
- package/dist/typeorm/custom-field-definition.entity.d.ts +20 -0
- package/dist/typeorm/custom-field-definition.entity.js +82 -0
- package/dist/typeorm/custom-field-definition.entity.js.map +1 -0
- package/dist/typeorm/custom-field-value.column.d.ts +2 -0
- package/dist/typeorm/custom-field-value.column.js +102 -0
- package/dist/typeorm/custom-field-value.column.js.map +1 -0
- package/dist/validators/custom-field-value-validation.error.d.ts +6 -0
- package/dist/validators/custom-field-value-validation.error.js +22 -0
- package/dist/validators/custom-field-value-validation.error.js.map +1 -0
- package/dist/validators/custom-field-value.validator.d.ts +4 -0
- package/dist/validators/custom-field-value.validator.js +81 -0
- package/dist/validators/custom-field-value.validator.js.map +1 -0
- package/dist/validators/custom-field-value.validator.unit.test.d.ts +1 -0
- package/dist/validators/custom-field-value.validator.unit.test.js +166 -0
- package/dist/validators/custom-field-value.validator.unit.test.js.map +1 -0
- package/package.json +56 -3
- package/skills/getting-started/SKILL.md +263 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import { expect } from 'expect';
|
|
3
|
+
import { LocalizedString } from '@wisemen/localized-string';
|
|
4
|
+
import { CustomFieldDefinitionError } from '#src/errors/custom-field-definition.error.js';
|
|
5
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
6
|
+
import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
|
|
7
|
+
describe('single select customFieldDefinition', () => {
|
|
8
|
+
it('creates a single select custom field definition', () => {
|
|
9
|
+
const definition = customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
|
|
10
|
+
tenantUuid: null,
|
|
11
|
+
entityType: 'invoice',
|
|
12
|
+
key: 'status',
|
|
13
|
+
label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
|
|
14
|
+
description: null,
|
|
15
|
+
isRequired: true,
|
|
16
|
+
choices: [
|
|
17
|
+
{
|
|
18
|
+
value: 'first',
|
|
19
|
+
label: new LocalizedString([{ locale: 'en', value: 'First' }]),
|
|
20
|
+
order: 1
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
value: 'second',
|
|
24
|
+
label: new LocalizedString([{ locale: 'en', value: 'Second' }]),
|
|
25
|
+
order: 2
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
expect(definition.type).toBe(CustomFieldType.SINGLE_SELECT);
|
|
30
|
+
expect(definition.choices).toEqual([
|
|
31
|
+
{
|
|
32
|
+
value: 'first',
|
|
33
|
+
label: new LocalizedString([{ locale: 'en', value: 'First' }]),
|
|
34
|
+
order: 1
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
value: 'second',
|
|
38
|
+
label: new LocalizedString([{ locale: 'en', value: 'Second' }]),
|
|
39
|
+
order: 2
|
|
40
|
+
}
|
|
41
|
+
]);
|
|
42
|
+
expect(definition.rules).toBeNull();
|
|
43
|
+
});
|
|
44
|
+
it('rejects a single select field without choices', () => {
|
|
45
|
+
expect(() => customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
|
|
46
|
+
tenantUuid: null,
|
|
47
|
+
entityType: 'invoice',
|
|
48
|
+
key: 'status',
|
|
49
|
+
label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
|
|
50
|
+
description: null,
|
|
51
|
+
isRequired: false,
|
|
52
|
+
choices: []
|
|
53
|
+
})).toThrow(new CustomFieldDefinitionError('Select custom field must define at least one choice'));
|
|
54
|
+
});
|
|
55
|
+
it('rejects a select field with duplicate choice values', () => {
|
|
56
|
+
expect(() => customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
|
|
57
|
+
tenantUuid: null,
|
|
58
|
+
entityType: 'invoice',
|
|
59
|
+
key: 'status',
|
|
60
|
+
label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
|
|
61
|
+
description: null,
|
|
62
|
+
isRequired: false,
|
|
63
|
+
choices: [
|
|
64
|
+
{
|
|
65
|
+
value: 'first',
|
|
66
|
+
label: new LocalizedString([{ locale: 'en', value: 'First' }]),
|
|
67
|
+
order: 1
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
value: 'first',
|
|
71
|
+
label: new LocalizedString([{ locale: 'en', value: 'Duplicate first' }]),
|
|
72
|
+
order: 2
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
})).toThrow(new CustomFieldDefinitionError('Custom field choice value must be unique'));
|
|
76
|
+
});
|
|
77
|
+
it('rejects a select field with duplicate choice orders', () => {
|
|
78
|
+
expect(() => customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
|
|
79
|
+
tenantUuid: null,
|
|
80
|
+
entityType: 'invoice',
|
|
81
|
+
key: 'status',
|
|
82
|
+
label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
|
|
83
|
+
description: null,
|
|
84
|
+
isRequired: false,
|
|
85
|
+
choices: [
|
|
86
|
+
{
|
|
87
|
+
value: 'first',
|
|
88
|
+
label: new LocalizedString([{ locale: 'en', value: 'First' }]),
|
|
89
|
+
order: 1
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
value: 'second',
|
|
93
|
+
label: new LocalizedString([{ locale: 'en', value: 'Second' }]),
|
|
94
|
+
order: 1
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
})).toThrow(new CustomFieldDefinitionError('Custom field choice order must be unique'));
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=single-select.custom-field-definition.factory.unit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single-select.custom-field-definition.factory.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.custom-field-definition.factory.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AAEvF,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACnD,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,aAAa,EAAE;YACtE,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,QAAQ;YACb,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC/D,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,OAAO;oBACd,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;oBAC9D,KAAK,EAAE,CAAC;iBACT;gBACD;oBACE,KAAK,EAAE,QAAQ;oBACf,KAAK,EAAE,IA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IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;oBAC9D,KAAK,EAAE,CAAC;iBACT;gBACD;oBACE,KAAK,EAAE,QAAQ;oBACf,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;oBAC/D,KAAK,EAAE,CAAC;iBACT;aACF;SACF,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,0BAA0B,CAAC,0CAA0C,CAAC,CAAC,CAAA;IACzF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CustomFieldDefinitionFieldsByType } from '#src/custom-field-definition.js';
|
|
2
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
|
+
type SingleSelectCustomFieldDefinition = CustomFieldDefinitionFieldsByType<CustomFieldType.SINGLE_SELECT>;
|
|
4
|
+
export declare function validateSingleSelectCustomFieldValue(definition: SingleSelectCustomFieldDefinition, value: string): void;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
|
|
2
|
+
export function validateSingleSelectCustomFieldValue(definition, value) {
|
|
3
|
+
if (definition.choices === null) {
|
|
4
|
+
throw new CustomFieldValueValidationError('Select custom field definition must define choices');
|
|
5
|
+
}
|
|
6
|
+
if (!definition.choices.some(choice => choice.value === value)) {
|
|
7
|
+
throw new CustomFieldValueValidationError('Single select custom field value must be one of the defined choices');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=single-select.custom-field-value.validator.js.map
|
package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single-select.custom-field-value.validator.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.custom-field-value.validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AAKxG,MAAM,UAAU,oCAAoC,CAClD,UAA6C,EAC7C,KAAa;IAEb,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,+BAA+B,CAAC,oDAAoD,CAAC,CAAA;IACjG,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,EAAE,CAAC;QAC/D,MAAM,IAAI,+BAA+B,CAAC,qEAAqE,CAAC,CAAA;IAClH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import { LocalizedString } from '@wisemen/localized-string';
|
|
3
|
+
import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
|
|
4
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
5
|
+
import { validateCustomFieldValue } from '#src/validators/custom-field-value.validator.js';
|
|
6
|
+
import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
|
|
7
|
+
import { expect } from 'expect';
|
|
8
|
+
describe('single select validateCustomFieldValue', () => {
|
|
9
|
+
it('rejects a single select custom field value outside the defined choices', () => {
|
|
10
|
+
const definition = customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
|
|
11
|
+
tenantUuid: null,
|
|
12
|
+
entityType: 'invoice',
|
|
13
|
+
key: 'status',
|
|
14
|
+
label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
|
|
15
|
+
description: null,
|
|
16
|
+
isRequired: false,
|
|
17
|
+
choices: [
|
|
18
|
+
{
|
|
19
|
+
value: 'draft',
|
|
20
|
+
label: new LocalizedString([{ locale: 'en', value: 'Draft' }]),
|
|
21
|
+
order: 1
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
expect(() => validateCustomFieldValue(definition, {
|
|
26
|
+
definitionUuid: definition.uuid,
|
|
27
|
+
type: CustomFieldType.SINGLE_SELECT,
|
|
28
|
+
value: 'sent'
|
|
29
|
+
})).toThrow(new CustomFieldValueValidationError('Single select custom field value must be one of the defined choices'));
|
|
30
|
+
});
|
|
31
|
+
it('rejects a single select custom field definition without choices', () => {
|
|
32
|
+
const definition = {
|
|
33
|
+
...customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
|
|
34
|
+
tenantUuid: null,
|
|
35
|
+
entityType: 'invoice',
|
|
36
|
+
key: 'status',
|
|
37
|
+
label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
|
|
38
|
+
description: null,
|
|
39
|
+
isRequired: false,
|
|
40
|
+
choices: [
|
|
41
|
+
{
|
|
42
|
+
value: 'draft',
|
|
43
|
+
label: new LocalizedString([{ locale: 'en', value: 'Draft' }]),
|
|
44
|
+
order: 1
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}),
|
|
48
|
+
choices: null
|
|
49
|
+
};
|
|
50
|
+
expect(() => validateCustomFieldValue(definition, {
|
|
51
|
+
definitionUuid: definition.uuid,
|
|
52
|
+
type: CustomFieldType.SINGLE_SELECT,
|
|
53
|
+
value: 'draft'
|
|
54
|
+
})).toThrow(new CustomFieldValueValidationError('Select custom field definition must define choices'));
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=single-select.custom-field-value.validator.unit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single-select.custom-field-value.validator.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.custom-field-value.validator.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CA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,UAAU,GAA8B;YAC5C,GAAG,qBAAqB,CAAC,eAAe,CAAC,aAAa,EAAE;gBACtD,UAAU,EAAE,IAAI;gBAChB,UAAU,EAAE,SAAS;gBACrB,GAAG,EAAE,QAAQ;gBACb,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;gBAC/D,WAAW,EAAE,IAAI;gBACjB,UAAU,EAAE,KAAK;gBACjB,OAAO,EAAE;oBACP;wBACE,KAAK,EAAE,OAAO;wBACd,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;wBAC9D,KAAK,EAAE,CAAC;qBACT;iBACF;aACF,CAAC;YACF,OAAO,EAAE,IAAI;SACd,CAAA;QAED,MAAM,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,UAAU,EAAE;YAChD,cAAc,EAAE,UAAU,CAAC,IAAI;YAC/B,IAAI,EAAE,eAAe,CAAC,aAAa;YACnC,KAAK,EAAE,OAAO;SACf,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,+BAA+B,CAAC,oDAAoD,CAAC,CAAC,CAAA;IACxG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResolvedCustomFieldDefinitionFields } from '#src/custom-field-definition.js';
|
|
2
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
|
+
type SingleSelectCustomFieldDefinition = Extract<ResolvedCustomFieldDefinitionFields, {
|
|
4
|
+
type: CustomFieldType.SINGLE_SELECT;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function validateSingleSelectCustomFieldDefinition(definition: SingleSelectCustomFieldDefinition): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CustomFieldDefinitionError } from '#src/errors/custom-field-definition.error.js';
|
|
2
|
+
export function validateSingleSelectCustomFieldDefinition(definition) {
|
|
3
|
+
if (definition.rules !== null) {
|
|
4
|
+
throw new CustomFieldDefinitionError('Single select custom field can not define rules');
|
|
5
|
+
}
|
|
6
|
+
validateSelectChoices(definition.choices);
|
|
7
|
+
}
|
|
8
|
+
function validateSelectChoices(choices) {
|
|
9
|
+
if (choices.length === 0) {
|
|
10
|
+
throw new CustomFieldDefinitionError('Select custom field must define at least one choice');
|
|
11
|
+
}
|
|
12
|
+
const choiceValues = new Set();
|
|
13
|
+
const choiceOrders = new Set();
|
|
14
|
+
for (const choice of choices) {
|
|
15
|
+
if (choiceValues.has(choice.value)) {
|
|
16
|
+
throw new CustomFieldDefinitionError('Custom field choice value must be unique');
|
|
17
|
+
}
|
|
18
|
+
if (choiceOrders.has(choice.order)) {
|
|
19
|
+
throw new CustomFieldDefinitionError('Custom field choice order must be unique');
|
|
20
|
+
}
|
|
21
|
+
choiceValues.add(choice.value);
|
|
22
|
+
choiceOrders.add(choice.order);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=single-select.definition-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single-select.definition-validation.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.definition-validation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AAKzF,MAAM,UAAU,yCAAyC,CAAC,UAA6C;IACrG,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAC9B,MAAM,IAAI,0BAA0B,CAAC,iDAAiD,CAAC,CAAA;IACzF,CAAC;IAED,qBAAqB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;AAC3C,CAAC;AAED,SAAS,qBAAqB,CAAC,OAA4B;IACzD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,0BAA0B,CAAC,qDAAqD,CAAC,CAAA;IAC7F,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAA;IACtC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAA;IAEtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,0BAA0B,CAAC,0CAA0C,CAAC,CAAA;QAClF,CAAC;QAED,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,0BAA0B,CAAC,0CAA0C,CAAC,CAAA;QAClF,CAAC;QAED,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC9B,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCustomFieldValueDto } from '#src/dto/base-custom-field-value.dto.js';
|
|
2
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
|
+
import { SingleSelectCustomFieldValue } from '#src/custom-field-types/single-select/single-select.value.js';
|
|
4
|
+
export declare class SingleSelectCustomFieldValueDto extends BaseCustomFieldValueDto {
|
|
5
|
+
type: CustomFieldType.SINGLE_SELECT;
|
|
6
|
+
value: string;
|
|
7
|
+
parse(): SingleSelectCustomFieldValue;
|
|
8
|
+
static from(customFieldValue: SingleSelectCustomFieldValue): SingleSelectCustomFieldValueDto;
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
11
|
+
import { IsEnum, IsNotEmpty, IsString } from 'class-validator';
|
|
12
|
+
import { BaseCustomFieldValueDto, createCustomFieldValueDto } from '#src/dto/base-custom-field-value.dto.js';
|
|
13
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
14
|
+
export class SingleSelectCustomFieldValueDto extends BaseCustomFieldValueDto {
|
|
15
|
+
value;
|
|
16
|
+
parse() {
|
|
17
|
+
return this.toCustomFieldValue(CustomFieldType.SINGLE_SELECT, this.value);
|
|
18
|
+
}
|
|
19
|
+
static from(customFieldValue) {
|
|
20
|
+
return createCustomFieldValueDto(new SingleSelectCustomFieldValueDto(), CustomFieldType.SINGLE_SELECT, customFieldValue.definitionUuid, customFieldValue.value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
__decorate([
|
|
24
|
+
ApiProperty({ enum: [CustomFieldType.SINGLE_SELECT] }),
|
|
25
|
+
IsEnum([CustomFieldType.SINGLE_SELECT]),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], SingleSelectCustomFieldValueDto.prototype, "type", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
ApiProperty({ type: String }),
|
|
30
|
+
IsString(),
|
|
31
|
+
IsNotEmpty(),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], SingleSelectCustomFieldValueDto.prototype, "value", void 0);
|
|
34
|
+
//# sourceMappingURL=single-select.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single-select.dto.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAA;AAC5G,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAGrE,MAAM,OAAO,+BAAgC,SAAQ,uBAAuB;IAQ1E,KAAK,CAAQ;IAEb,KAAK;QACH,OAAO,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IAC3E,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,gBAA8C;QACxD,OAAO,yBAAyB,CAAC,IAAI,+BAA+B,EAAE,EAAE,eAAe,CAAC,aAAa,EAAE,gBAAgB,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACjK,CAAC;CACF;AAdS;IAFP,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE,CAAC;IACtD,MAAM,CAAC,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;;6DACG;AAK3C;IAHC,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,EAAE;IACV,UAAU,EAAE;;8DACA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
2
|
+
import type { SingleSelectCustomFieldTypeContract } from './single-select.contract.js';
|
|
3
|
+
export type SelectCustomFieldRules = {
|
|
4
|
+
type: CustomFieldType.SINGLE_SELECT;
|
|
5
|
+
} & SingleSelectCustomFieldTypeContract['rules'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single-select.rules.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.rules.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BaseCustomFieldValue } from '#src/custom-field-value.js';
|
|
2
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
|
+
import type { SingleSelectCustomFieldTypeContract } from './single-select.contract.js';
|
|
4
|
+
export type SingleSelectCustomFieldValue = BaseCustomFieldValue<CustomFieldType.SINGLE_SELECT, SingleSelectCustomFieldTypeContract['value']>;
|
|
5
|
+
export type SingleSelectCustomFieldColumnValue = BaseCustomFieldValue<CustomFieldType.SINGLE_SELECT, SingleSelectCustomFieldTypeContract['columnValue']>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single-select.value.js","sourceRoot":"","sources":["../../../lib/custom-field-types/single-select/single-select.value.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './text.contract.js';
|
|
2
|
+
export * from './text.definition-validation.js';
|
|
3
|
+
export * from './text.dto.js';
|
|
4
|
+
export * from './text.rules.js';
|
|
5
|
+
export * from './text.custom-field-value.validator.js';
|
|
6
|
+
export * from './text.value.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wCAAwC,CAAA;AACtD,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DefineContract } from '#src/custom-field-type-contract.js';
|
|
2
|
+
export type TextCustomFieldTypeContract = DefineContract<{
|
|
3
|
+
value: string;
|
|
4
|
+
columnValue: string;
|
|
5
|
+
rules: {
|
|
6
|
+
minLength?: number;
|
|
7
|
+
maxLength?: number;
|
|
8
|
+
regex?: string;
|
|
9
|
+
};
|
|
10
|
+
rulesMode: 'optional';
|
|
11
|
+
choicesMode: 'none';
|
|
12
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.contract.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/text.contract.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import { expect } from 'expect';
|
|
3
|
+
import { LocalizedString } from '@wisemen/localized-string';
|
|
4
|
+
import { CustomFieldDefinitionError } from '#src/errors/custom-field-definition.error.js';
|
|
5
|
+
import { generateUuid } from '#src/custom-field-definition.uuid.js';
|
|
6
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
7
|
+
import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
|
|
8
|
+
describe('text customFieldDefinition', () => {
|
|
9
|
+
it('creates a text custom field definition', () => {
|
|
10
|
+
const tenantUuid = generateUuid();
|
|
11
|
+
const definition = customFieldDefinition(CustomFieldType.TEXT, {
|
|
12
|
+
tenantUuid,
|
|
13
|
+
entityType: 'invoice',
|
|
14
|
+
key: 'notes',
|
|
15
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
16
|
+
description: new LocalizedString([{ locale: 'en', value: 'Invoice notes' }]),
|
|
17
|
+
isRequired: true,
|
|
18
|
+
rules: {
|
|
19
|
+
minLength: 2,
|
|
20
|
+
maxLength: 50,
|
|
21
|
+
regex: '^[a-zA-Z ]+$'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
expect(definition.type).toBe(CustomFieldType.TEXT);
|
|
25
|
+
expect(definition.tenantUuid).toBe(tenantUuid);
|
|
26
|
+
expect(definition.choices).toBeNull();
|
|
27
|
+
expect(definition.rules).toEqual({
|
|
28
|
+
type: CustomFieldType.TEXT,
|
|
29
|
+
minLength: 2,
|
|
30
|
+
maxLength: 50,
|
|
31
|
+
regex: '^[a-zA-Z ]+$'
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
it('rejects a custom field whose entityType is empty', () => {
|
|
35
|
+
expect(() => customFieldDefinition(CustomFieldType.TEXT, {
|
|
36
|
+
tenantUuid: null,
|
|
37
|
+
entityType: ' ',
|
|
38
|
+
key: 'notes',
|
|
39
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
40
|
+
description: null,
|
|
41
|
+
isRequired: false
|
|
42
|
+
})).toThrow(new CustomFieldDefinitionError('Custom field entityType can not be empty'));
|
|
43
|
+
});
|
|
44
|
+
it('rejects a custom field whose key is empty', () => {
|
|
45
|
+
expect(() => customFieldDefinition(CustomFieldType.TEXT, {
|
|
46
|
+
tenantUuid: null,
|
|
47
|
+
entityType: 'invoice',
|
|
48
|
+
key: ' ',
|
|
49
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
50
|
+
description: null,
|
|
51
|
+
isRequired: false
|
|
52
|
+
})).toThrow(new CustomFieldDefinitionError('Custom field key can not be empty'));
|
|
53
|
+
});
|
|
54
|
+
it('rejects a custom field whose label has no translations', () => {
|
|
55
|
+
expect(() => customFieldDefinition(CustomFieldType.TEXT, {
|
|
56
|
+
tenantUuid: null,
|
|
57
|
+
entityType: 'invoice',
|
|
58
|
+
key: 'notes',
|
|
59
|
+
label: new LocalizedString([]),
|
|
60
|
+
description: null,
|
|
61
|
+
isRequired: false
|
|
62
|
+
})).toThrow(new CustomFieldDefinitionError('Custom field label must contain at least one translation'));
|
|
63
|
+
});
|
|
64
|
+
it('rejects a custom field whose description has no translations', () => {
|
|
65
|
+
expect(() => customFieldDefinition(CustomFieldType.TEXT, {
|
|
66
|
+
tenantUuid: null,
|
|
67
|
+
entityType: 'invoice',
|
|
68
|
+
key: 'notes',
|
|
69
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
70
|
+
description: new LocalizedString([]),
|
|
71
|
+
isRequired: false
|
|
72
|
+
})).toThrow(new CustomFieldDefinitionError('Custom field description must contain at least one translation'));
|
|
73
|
+
});
|
|
74
|
+
it('rejects a text field whose minLength is negative', () => {
|
|
75
|
+
expect(() => customFieldDefinition(CustomFieldType.TEXT, {
|
|
76
|
+
tenantUuid: null,
|
|
77
|
+
entityType: 'invoice',
|
|
78
|
+
key: 'notes',
|
|
79
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
80
|
+
description: null,
|
|
81
|
+
isRequired: false,
|
|
82
|
+
rules: {
|
|
83
|
+
minLength: -1
|
|
84
|
+
}
|
|
85
|
+
})).toThrow(new CustomFieldDefinitionError('Text custom field minLength can not be negative'));
|
|
86
|
+
});
|
|
87
|
+
it('rejects a text field whose maxLength is negative', () => {
|
|
88
|
+
expect(() => customFieldDefinition(CustomFieldType.TEXT, {
|
|
89
|
+
tenantUuid: null,
|
|
90
|
+
entityType: 'invoice',
|
|
91
|
+
key: 'notes',
|
|
92
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
93
|
+
description: null,
|
|
94
|
+
isRequired: false,
|
|
95
|
+
rules: {
|
|
96
|
+
maxLength: -1
|
|
97
|
+
}
|
|
98
|
+
})).toThrow(new CustomFieldDefinitionError('Text custom field maxLength can not be negative'));
|
|
99
|
+
});
|
|
100
|
+
it('rejects a text field whose minLength exceeds maxLength', () => {
|
|
101
|
+
expect(() => customFieldDefinition(CustomFieldType.TEXT, {
|
|
102
|
+
tenantUuid: null,
|
|
103
|
+
entityType: 'invoice',
|
|
104
|
+
key: 'notes',
|
|
105
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
106
|
+
description: null,
|
|
107
|
+
isRequired: false,
|
|
108
|
+
rules: {
|
|
109
|
+
minLength: 10,
|
|
110
|
+
maxLength: 5
|
|
111
|
+
}
|
|
112
|
+
})).toThrow(new CustomFieldDefinitionError('Text custom field minLength can not be greater than maxLength'));
|
|
113
|
+
});
|
|
114
|
+
it('rejects a text field whose regex is invalid', () => {
|
|
115
|
+
expect(() => customFieldDefinition(CustomFieldType.TEXT, {
|
|
116
|
+
tenantUuid: null,
|
|
117
|
+
entityType: 'invoice',
|
|
118
|
+
key: 'notes',
|
|
119
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
120
|
+
description: null,
|
|
121
|
+
isRequired: false,
|
|
122
|
+
rules: {
|
|
123
|
+
regex: '['
|
|
124
|
+
}
|
|
125
|
+
})).toThrow(new CustomFieldDefinitionError('Text custom field regex must be a valid regular expression'));
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=text.custom-field-definition.factory.unit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.custom-field-definition.factory.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/text.custom-field-definition.factory.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AACzF,OAAO,EAA6B,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AAEvF,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,UAAU,GAAG,YAAY,EAA6B,CAAA;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AAC,CAAC,CAAA;IAChG,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAChE,MAAM,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,eAAe,CAAC,IAAI,EAAE;YACvD,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,OAAO;YACZ,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;YAC9D,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE;gBACL,SAAS,EAAE,EAAE;gBACb,SAAS,EAAE,CAAC;aACb;SACF,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,0BAA0B,CAAC,+DAA+D,CAAC,CAAC,CAAA;IAC9G,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,eAAe,CAAC,IAAI,EAAE;YACvD,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,OAAO;YACZ,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;YAC9D,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE;gBACL,KAAK,EAAE,GAAG;aACX;SACF,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,0BAA0B,CAAC,4DAA4D,CAAC,CAAC,CAAA;IAC3G,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CustomFieldDefinitionFieldsByType } from '#src/custom-field-definition.js';
|
|
2
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
|
+
type TextCustomFieldDefinition = CustomFieldDefinitionFieldsByType<CustomFieldType.TEXT>;
|
|
4
|
+
export declare function validateTextCustomFieldValue(definition: TextCustomFieldDefinition, value: string): void;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
|
|
2
|
+
export function validateTextCustomFieldValue(definition, value) {
|
|
3
|
+
const rules = definition.rules;
|
|
4
|
+
if (rules === null) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
if (rules.minLength !== undefined && value.length < rules.minLength) {
|
|
8
|
+
throw new CustomFieldValueValidationError('Text custom field value can not be shorter than minLength');
|
|
9
|
+
}
|
|
10
|
+
if (rules.maxLength !== undefined && value.length > rules.maxLength) {
|
|
11
|
+
throw new CustomFieldValueValidationError('Text custom field value can not be longer than maxLength');
|
|
12
|
+
}
|
|
13
|
+
if (rules.regex !== undefined && !new RegExp(rules.regex).test(value)) {
|
|
14
|
+
throw new CustomFieldValueValidationError('Text custom field value must match the configured regex');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=text.custom-field-value.validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.custom-field-value.validator.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/text.custom-field-value.validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AAKxG,MAAM,UAAU,4BAA4B,CAC1C,UAAqC,EACrC,KAAa;IAEb,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAA;IAE9B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAM;IACR,CAAC;IAED,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACpE,MAAM,IAAI,+BAA+B,CAAC,2DAA2D,CAAC,CAAA;IACxG,CAAC;IAED,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACpE,MAAM,IAAI,+BAA+B,CAAC,0DAA0D,CAAC,CAAA;IACvG,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,+BAA+B,CAAC,yDAAyD,CAAC,CAAA;IACtG,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import { LocalizedString } from '@wisemen/localized-string';
|
|
3
|
+
import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
|
|
4
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
5
|
+
import { validateCustomFieldValue } from '#src/validators/custom-field-value.validator.js';
|
|
6
|
+
import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
|
|
7
|
+
import { expect } from 'expect';
|
|
8
|
+
describe('text validateCustomFieldValue', () => {
|
|
9
|
+
it('rejects a text custom field value shorter than minLength', () => {
|
|
10
|
+
const definition = customFieldDefinition(CustomFieldType.TEXT, {
|
|
11
|
+
tenantUuid: null,
|
|
12
|
+
entityType: 'invoice',
|
|
13
|
+
key: 'notes',
|
|
14
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
15
|
+
description: null,
|
|
16
|
+
isRequired: false,
|
|
17
|
+
rules: {
|
|
18
|
+
minLength: 3
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
expect(() => validateCustomFieldValue(definition, {
|
|
22
|
+
definitionUuid: definition.uuid,
|
|
23
|
+
type: CustomFieldType.TEXT,
|
|
24
|
+
value: 'no'
|
|
25
|
+
})).toThrow(new CustomFieldValueValidationError('Text custom field value can not be shorter than minLength'));
|
|
26
|
+
});
|
|
27
|
+
it('rejects a text custom field value longer than maxLength', () => {
|
|
28
|
+
const definition = customFieldDefinition(CustomFieldType.TEXT, {
|
|
29
|
+
tenantUuid: null,
|
|
30
|
+
entityType: 'invoice',
|
|
31
|
+
key: 'notes',
|
|
32
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
33
|
+
description: null,
|
|
34
|
+
isRequired: false,
|
|
35
|
+
rules: {
|
|
36
|
+
maxLength: 2
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
expect(() => validateCustomFieldValue(definition, {
|
|
40
|
+
definitionUuid: definition.uuid,
|
|
41
|
+
type: CustomFieldType.TEXT,
|
|
42
|
+
value: 'long'
|
|
43
|
+
})).toThrow(new CustomFieldValueValidationError('Text custom field value can not be longer than maxLength'));
|
|
44
|
+
});
|
|
45
|
+
it('rejects a text custom field value that does not match the regex', () => {
|
|
46
|
+
const definition = customFieldDefinition(CustomFieldType.TEXT, {
|
|
47
|
+
tenantUuid: null,
|
|
48
|
+
entityType: 'invoice',
|
|
49
|
+
key: 'notes',
|
|
50
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
51
|
+
description: null,
|
|
52
|
+
isRequired: false,
|
|
53
|
+
rules: {
|
|
54
|
+
regex: '^[A-Z]+$'
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
expect(() => validateCustomFieldValue(definition, {
|
|
58
|
+
definitionUuid: definition.uuid,
|
|
59
|
+
type: CustomFieldType.TEXT,
|
|
60
|
+
value: 'lowercase'
|
|
61
|
+
})).toThrow(new CustomFieldValueValidationError('Text custom field value must match the configured regex'));
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=text.custom-field-value.validator.unit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.custom-field-value.validator.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/text.custom-field-value.validator.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAC1F,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AACxG,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,IAAI,EAAE;YAC7D,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,OAAO;YACZ,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;YAC9D,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE;gBACL,SAAS,EAAE,CAAC;aACb;SACF,CAAC,CAAA;QAEF,MAAM,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,UAAU,EAAE;YAChD,cAAc,EAAE,UAAU,CAAC,IAAI;YAC/B,IAAI,EAAE,eAAe,CAAC,IAAI;YAC1B,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,+BAA+B,CAAC,2DAA2D,CAAC,CAAC,CAAA;IAC/G,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE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,+BAA+B,CAAC,yDAAyD,CAAC,CAAC,CAAA;IAC7G,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResolvedCustomFieldDefinitionFields } from '#src/custom-field-definition.js';
|
|
2
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
|
+
type TextCustomFieldDefinition = Extract<ResolvedCustomFieldDefinitionFields, {
|
|
4
|
+
type: CustomFieldType.TEXT;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function validateTextCustomFieldDefinition(definition: TextCustomFieldDefinition): void;
|
|
7
|
+
export {};
|