@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,30 @@
|
|
|
1
|
+
import { CustomFieldDefinitionError } from '#src/errors/custom-field-definition.error.js';
|
|
2
|
+
export function validateTextCustomFieldDefinition(definition) {
|
|
3
|
+
if (definition.choices !== null) {
|
|
4
|
+
throw new CustomFieldDefinitionError('Only select custom fields can define choices');
|
|
5
|
+
}
|
|
6
|
+
const rules = definition.rules;
|
|
7
|
+
if (rules === null) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (rules.minLength !== undefined && rules.minLength < 0) {
|
|
11
|
+
throw new CustomFieldDefinitionError('Text custom field minLength can not be negative');
|
|
12
|
+
}
|
|
13
|
+
if (rules.maxLength !== undefined && rules.maxLength < 0) {
|
|
14
|
+
throw new CustomFieldDefinitionError('Text custom field maxLength can not be negative');
|
|
15
|
+
}
|
|
16
|
+
if (rules.minLength !== undefined
|
|
17
|
+
&& rules.maxLength !== undefined
|
|
18
|
+
&& rules.minLength > rules.maxLength) {
|
|
19
|
+
throw new CustomFieldDefinitionError('Text custom field minLength can not be greater than maxLength');
|
|
20
|
+
}
|
|
21
|
+
if (rules.regex !== undefined) {
|
|
22
|
+
try {
|
|
23
|
+
new RegExp(rules.regex);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new CustomFieldDefinitionError('Text custom field regex must be a valid regular expression');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=text.definition-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.definition-validation.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/text.definition-validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AAKzF,MAAM,UAAU,iCAAiC,CAAC,UAAqC;IACrF,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,0BAA0B,CAAC,8CAA8C,CAAC,CAAA;IACtF,CAAC;IAED,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,SAAS,GAAG,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,0BAA0B,CAAC,iDAAiD,CAAC,CAAA;IACzF,CAAC;IAED,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,0BAA0B,CAAC,iDAAiD,CAAC,CAAA;IACzF,CAAC;IAED,IACE,KAAK,CAAC,SAAS,KAAK,SAAS;WAC1B,KAAK,CAAC,SAAS,KAAK,SAAS;WAC7B,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EACpC,CAAC;QACD,MAAM,IAAI,0BAA0B,CAAC,+DAA+D,CAAC,CAAA;IACvG,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,0BAA0B,CAAC,4DAA4D,CAAC,CAAA;QACpG,CAAC;IACH,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 { TextCustomFieldValue } from '#src/custom-field-types/text/text.value.js';
|
|
4
|
+
export declare class TextCustomFieldValueDto extends BaseCustomFieldValueDto {
|
|
5
|
+
type: CustomFieldType.TEXT;
|
|
6
|
+
value: string;
|
|
7
|
+
parse(): TextCustomFieldValue;
|
|
8
|
+
static from(customFieldValue: TextCustomFieldValue): TextCustomFieldValueDto;
|
|
9
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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, 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 TextCustomFieldValueDto extends BaseCustomFieldValueDto {
|
|
15
|
+
value;
|
|
16
|
+
parse() {
|
|
17
|
+
return this.toCustomFieldValue(CustomFieldType.TEXT, this.value);
|
|
18
|
+
}
|
|
19
|
+
static from(customFieldValue) {
|
|
20
|
+
return createCustomFieldValueDto(new TextCustomFieldValueDto(), CustomFieldType.TEXT, customFieldValue.definitionUuid, customFieldValue.value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
__decorate([
|
|
24
|
+
ApiProperty({ enum: [CustomFieldType.TEXT] }),
|
|
25
|
+
IsEnum([CustomFieldType.TEXT]),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], TextCustomFieldValueDto.prototype, "type", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
ApiProperty({ type: String }),
|
|
30
|
+
IsString(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], TextCustomFieldValueDto.prototype, "value", void 0);
|
|
33
|
+
//# sourceMappingURL=text.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.dto.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/text.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAA;AAC5G,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAGrE,MAAM,OAAO,uBAAwB,SAAQ,uBAAuB;IAOlE,KAAK,CAAQ;IAEb,KAAK;QACH,OAAO,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IAClE,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,gBAAsC;QAChD,OAAO,yBAAyB,CAAC,IAAI,uBAAuB,EAAE,EAAE,eAAe,CAAC,IAAI,EAAE,gBAAgB,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAA;IAChJ,CAAC;CACF;AAbS;IAFP,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;IAC7C,MAAM,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;;qDACG;AAIlC;IAFC,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,EAAE;;sDACE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.rules.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/text.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 { TextCustomFieldTypeContract } from './text.contract.js';
|
|
4
|
+
export type TextCustomFieldValue = BaseCustomFieldValue<CustomFieldType.TEXT, TextCustomFieldTypeContract['value']>;
|
|
5
|
+
export type TextCustomFieldColumnValue = BaseCustomFieldValue<CustomFieldType.TEXT, TextCustomFieldTypeContract['columnValue']>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.value.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text/text.value.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './text-array.contract.js';
|
|
2
|
+
export * from './text-array.definition-validation.js';
|
|
3
|
+
export * from './text-array.dto.js';
|
|
4
|
+
export * from './text-array.rules.js';
|
|
5
|
+
export * from './text-array.custom-field-value.validator.js';
|
|
6
|
+
export * from './text-array.value.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './text-array.contract.js';
|
|
2
|
+
export * from './text-array.definition-validation.js';
|
|
3
|
+
export * from './text-array.dto.js';
|
|
4
|
+
export * from './text-array.rules.js';
|
|
5
|
+
export * from './text-array.custom-field-value.validator.js';
|
|
6
|
+
export * from './text-array.value.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text-array/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,uCAAuC,CAAA;AACrD,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,8CAA8C,CAAA;AAC5D,cAAc,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DefineContract } from '#src/custom-field-type-contract.js';
|
|
2
|
+
export type TextArrayCustomFieldTypeContract = DefineContract<{
|
|
3
|
+
value: string[];
|
|
4
|
+
columnValue: string[];
|
|
5
|
+
rules: {
|
|
6
|
+
minItems?: number;
|
|
7
|
+
maxItems?: number;
|
|
8
|
+
};
|
|
9
|
+
rulesMode: 'optional';
|
|
10
|
+
choicesMode: 'none';
|
|
11
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-array.contract.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text-array/text-array.contract.ts"],"names":[],"mappings":""}
|
package/dist/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
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('text array customFieldDefinition', () => {
|
|
8
|
+
it('creates a text array custom field definition', () => {
|
|
9
|
+
const definition = customFieldDefinition(CustomFieldType.TEXT_ARRAY, {
|
|
10
|
+
tenantUuid: null,
|
|
11
|
+
entityType: 'invoice',
|
|
12
|
+
key: 'tags',
|
|
13
|
+
label: new LocalizedString([{ locale: 'en', value: 'Tags' }]),
|
|
14
|
+
description: null,
|
|
15
|
+
isRequired: false,
|
|
16
|
+
rules: {
|
|
17
|
+
minItems: 1,
|
|
18
|
+
maxItems: 3
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
expect(definition.type).toBe(CustomFieldType.TEXT_ARRAY);
|
|
22
|
+
expect(definition.tenantUuid).toBeNull();
|
|
23
|
+
expect(definition.choices).toBeNull();
|
|
24
|
+
expect(definition.rules).toEqual({
|
|
25
|
+
type: CustomFieldType.TEXT_ARRAY,
|
|
26
|
+
minItems: 1,
|
|
27
|
+
maxItems: 3
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
it('rejects a text array field whose minItems exceeds maxItems', () => {
|
|
31
|
+
expect(() => customFieldDefinition(CustomFieldType.TEXT_ARRAY, {
|
|
32
|
+
tenantUuid: null,
|
|
33
|
+
entityType: 'invoice',
|
|
34
|
+
key: 'tags',
|
|
35
|
+
label: new LocalizedString([{ locale: 'en', value: 'Tags' }]),
|
|
36
|
+
description: null,
|
|
37
|
+
isRequired: false,
|
|
38
|
+
rules: {
|
|
39
|
+
minItems: 3,
|
|
40
|
+
maxItems: 2
|
|
41
|
+
}
|
|
42
|
+
})).toThrow(new CustomFieldDefinitionError('Text array custom field minItems can not be greater than maxItems'));
|
|
43
|
+
});
|
|
44
|
+
it('rejects a text array field whose minItems is negative', () => {
|
|
45
|
+
expect(() => customFieldDefinition(CustomFieldType.TEXT_ARRAY, {
|
|
46
|
+
tenantUuid: null,
|
|
47
|
+
entityType: 'invoice',
|
|
48
|
+
key: 'tags',
|
|
49
|
+
label: new LocalizedString([{ locale: 'en', value: 'Tags' }]),
|
|
50
|
+
description: null,
|
|
51
|
+
isRequired: false,
|
|
52
|
+
rules: {
|
|
53
|
+
minItems: -1
|
|
54
|
+
}
|
|
55
|
+
})).toThrow(new CustomFieldDefinitionError('Text array custom field minItems can not be negative'));
|
|
56
|
+
});
|
|
57
|
+
it('rejects a text array field whose maxItems is negative', () => {
|
|
58
|
+
expect(() => customFieldDefinition(CustomFieldType.TEXT_ARRAY, {
|
|
59
|
+
tenantUuid: null,
|
|
60
|
+
entityType: 'invoice',
|
|
61
|
+
key: 'tags',
|
|
62
|
+
label: new LocalizedString([{ locale: 'en', value: 'Tags' }]),
|
|
63
|
+
description: null,
|
|
64
|
+
isRequired: false,
|
|
65
|
+
rules: {
|
|
66
|
+
maxItems: -1
|
|
67
|
+
}
|
|
68
|
+
})).toThrow(new CustomFieldDefinitionError('Text array custom field maxItems can not be negative'));
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=text-array.custom-field-definition.factory.unit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-array.custom-field-definition.factory.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.ts"],"names":[],"mappings":"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"}
|
|
@@ -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 TextArrayCustomFieldDefinition = CustomFieldDefinitionFieldsByType<CustomFieldType.TEXT_ARRAY>;
|
|
4
|
+
export declare function validateTextArrayCustomFieldValue(definition: TextArrayCustomFieldDefinition, value: string[]): void;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
|
|
2
|
+
export function validateTextArrayCustomFieldValue(definition, value) {
|
|
3
|
+
const rules = definition.rules;
|
|
4
|
+
if (rules === null) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
if (rules.minItems !== undefined && value.length < rules.minItems) {
|
|
8
|
+
throw new CustomFieldValueValidationError('Text array custom field value can not contain fewer than minItems');
|
|
9
|
+
}
|
|
10
|
+
if (rules.maxItems !== undefined && value.length > rules.maxItems) {
|
|
11
|
+
throw new CustomFieldValueValidationError('Text array custom field value can not contain more than maxItems');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=text-array.custom-field-value.validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-array.custom-field-value.validator.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text-array/text-array.custom-field-value.validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AAKxG,MAAM,UAAU,iCAAiC,CAC/C,UAA0C,EAC1C,KAAe;IAEf,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAA;IAE9B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAM;IACR,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAClE,MAAM,IAAI,+BAA+B,CAAC,mEAAmE,CAAC,CAAA;IAChH,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAClE,MAAM,IAAI,+BAA+B,CAAC,kEAAkE,CAAC,CAAA;IAC/G,CAAC;AACH,CAAC"}
|
package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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 array validateCustomFieldValue', () => {
|
|
9
|
+
it('rejects a text array custom field value with fewer than minItems', () => {
|
|
10
|
+
const definition = customFieldDefinition(CustomFieldType.TEXT_ARRAY, {
|
|
11
|
+
tenantUuid: null,
|
|
12
|
+
entityType: 'invoice',
|
|
13
|
+
key: 'tags',
|
|
14
|
+
label: new LocalizedString([{ locale: 'en', value: 'Tags' }]),
|
|
15
|
+
description: null,
|
|
16
|
+
isRequired: false,
|
|
17
|
+
rules: {
|
|
18
|
+
minItems: 2
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
expect(() => validateCustomFieldValue(definition, {
|
|
22
|
+
definitionUuid: definition.uuid,
|
|
23
|
+
type: CustomFieldType.TEXT_ARRAY,
|
|
24
|
+
value: ['only-one']
|
|
25
|
+
})).toThrow(new CustomFieldValueValidationError('Text array custom field value can not contain fewer than minItems'));
|
|
26
|
+
});
|
|
27
|
+
it('rejects a text array custom field value with more than maxItems', () => {
|
|
28
|
+
const definition = customFieldDefinition(CustomFieldType.TEXT_ARRAY, {
|
|
29
|
+
tenantUuid: null,
|
|
30
|
+
entityType: 'invoice',
|
|
31
|
+
key: 'tags',
|
|
32
|
+
label: new LocalizedString([{ locale: 'en', value: 'Tags' }]),
|
|
33
|
+
description: null,
|
|
34
|
+
isRequired: false,
|
|
35
|
+
rules: {
|
|
36
|
+
maxItems: 1
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
expect(() => validateCustomFieldValue(definition, {
|
|
40
|
+
definitionUuid: definition.uuid,
|
|
41
|
+
type: CustomFieldType.TEXT_ARRAY,
|
|
42
|
+
value: ['first', 'second']
|
|
43
|
+
})).toThrow(new CustomFieldValueValidationError('Text array custom field value can not contain more than maxItems'));
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=text-array.custom-field-value.validator.unit.test.js.map
|
package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-array.custom-field-value.validator.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text-array/text-array.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,qCAAqC,EAAE,GAAG,EAAE;IACnD,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC1E,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,UAAU,EAAE;YACnE,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,MAAM;YACX,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YAC7D,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE;gBACL,QAAQ,EAAE,CAAC;aACZ;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,UAAU;YAChC,KAAK,EAAE,CAAC,UAAU,CAAC;SACpB,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,+BAA+B,CAAC,mEAAmE,CAAC,CAAC,CAAA;IACvH,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,UAAU,EAAE;YACnE,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,MAAM;YACX,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YAC7D,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE;gBACL,QAAQ,EAAE,CAAC;aACZ;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,UAAU;YAChC,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;SAC3B,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,+BAA+B,CAAC,kEAAkE,CAAC,CAAC,CAAA;IACtH,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 TextArrayCustomFieldDefinition = Extract<ResolvedCustomFieldDefinitionFields, {
|
|
4
|
+
type: CustomFieldType.TEXT_ARRAY;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function validateTextArrayCustomFieldDefinition(definition: TextArrayCustomFieldDefinition): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CustomFieldDefinitionError } from '#src/errors/custom-field-definition.error.js';
|
|
2
|
+
export function validateTextArrayCustomFieldDefinition(definition) {
|
|
3
|
+
if (definition.choices !== null) {
|
|
4
|
+
throw new CustomFieldDefinitionError('Only select custom fields can define choices');
|
|
5
|
+
}
|
|
6
|
+
const rules = definition.rules;
|
|
7
|
+
if (rules === null) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (rules.minItems !== undefined && rules.minItems < 0) {
|
|
11
|
+
throw new CustomFieldDefinitionError('Text array custom field minItems can not be negative');
|
|
12
|
+
}
|
|
13
|
+
if (rules.maxItems !== undefined && rules.maxItems < 0) {
|
|
14
|
+
throw new CustomFieldDefinitionError('Text array custom field maxItems can not be negative');
|
|
15
|
+
}
|
|
16
|
+
if (rules.minItems !== undefined
|
|
17
|
+
&& rules.maxItems !== undefined
|
|
18
|
+
&& rules.minItems > rules.maxItems) {
|
|
19
|
+
throw new CustomFieldDefinitionError('Text array custom field minItems can not be greater than maxItems');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=text-array.definition-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-array.definition-validation.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text-array/text-array.definition-validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AAKzF,MAAM,UAAU,sCAAsC,CAAC,UAA0C;IAC/F,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,0BAA0B,CAAC,8CAA8C,CAAC,CAAA;IACtF,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAA;IAE9B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAM;IACR,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,0BAA0B,CAAC,sDAAsD,CAAC,CAAA;IAC9F,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,0BAA0B,CAAC,sDAAsD,CAAC,CAAA;IAC9F,CAAC;IAED,IACE,KAAK,CAAC,QAAQ,KAAK,SAAS;WACzB,KAAK,CAAC,QAAQ,KAAK,SAAS;WAC5B,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAClC,CAAC;QACD,MAAM,IAAI,0BAA0B,CAAC,mEAAmE,CAAC,CAAA;IAC3G,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 { TextArrayCustomFieldValue } from '#src/custom-field-types/text-array/text-array.value.js';
|
|
4
|
+
export declare class TextArrayCustomFieldValueDto extends BaseCustomFieldValueDto {
|
|
5
|
+
type: CustomFieldType.TEXT_ARRAY;
|
|
6
|
+
value: string[];
|
|
7
|
+
parse(): TextArrayCustomFieldValue;
|
|
8
|
+
static from(customFieldValue: TextArrayCustomFieldValue): TextArrayCustomFieldValueDto;
|
|
9
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { ArrayUnique, IsArray, 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 TextArrayCustomFieldValueDto extends BaseCustomFieldValueDto {
|
|
15
|
+
value;
|
|
16
|
+
parse() {
|
|
17
|
+
return this.toCustomFieldValue(CustomFieldType.TEXT_ARRAY, this.value);
|
|
18
|
+
}
|
|
19
|
+
static from(customFieldValue) {
|
|
20
|
+
return createCustomFieldValueDto(new TextArrayCustomFieldValueDto(), CustomFieldType.TEXT_ARRAY, customFieldValue.definitionUuid, customFieldValue.value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
__decorate([
|
|
24
|
+
ApiProperty({ enum: [CustomFieldType.TEXT_ARRAY] }),
|
|
25
|
+
IsEnum([CustomFieldType.TEXT_ARRAY]),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], TextArrayCustomFieldValueDto.prototype, "type", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
ApiProperty({ type: String, isArray: true }),
|
|
30
|
+
IsString({ each: true }),
|
|
31
|
+
IsNotEmpty({ each: true }),
|
|
32
|
+
IsArray(),
|
|
33
|
+
ArrayUnique(),
|
|
34
|
+
__metadata("design:type", Array)
|
|
35
|
+
], TextArrayCustomFieldValueDto.prototype, "value", void 0);
|
|
36
|
+
//# sourceMappingURL=text-array.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-array.dto.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text-array/text-array.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACpF,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAA;AAC5G,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAGrE,MAAM,OAAO,4BAA6B,SAAQ,uBAAuB;IAUvE,KAAK,CAAU;IAEf,KAAK;QACH,OAAO,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IACxE,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,gBAA2C;QACrD,OAAO,yBAAyB,CAAC,IAAI,4BAA4B,EAAE,EAAE,eAAe,CAAC,UAAU,EAAE,gBAAgB,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAA;IAC3J,CAAC;CACF;AAhBS;IAFP,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;IACnD,MAAM,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;;0DACG;AAOxC;IALC,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC5C,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC1B,OAAO,EAAE;IACT,WAAW,EAAE;;2DACC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
2
|
+
import type { TextArrayCustomFieldTypeContract } from './text-array.contract.js';
|
|
3
|
+
export type TextArrayCustomFieldRules = {
|
|
4
|
+
type: CustomFieldType.TEXT_ARRAY;
|
|
5
|
+
} & TextArrayCustomFieldTypeContract['rules'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-array.rules.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text-array/text-array.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 { TextArrayCustomFieldTypeContract } from './text-array.contract.js';
|
|
4
|
+
export type TextArrayCustomFieldValue = BaseCustomFieldValue<CustomFieldType.TEXT_ARRAY, TextArrayCustomFieldTypeContract['value']>;
|
|
5
|
+
export type TextArrayCustomFieldColumnValue = BaseCustomFieldValue<CustomFieldType.TEXT_ARRAY, TextArrayCustomFieldTypeContract['columnValue']>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-array.value.js","sourceRoot":"","sources":["../../../lib/custom-field-types/text-array/text-array.value.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './timestamp.contract.js';
|
|
2
|
+
export * from './timestamp.definition-validation.js';
|
|
3
|
+
export * from './timestamp.dto.js';
|
|
4
|
+
export * from './timestamp.rules.js';
|
|
5
|
+
export * from './timestamp.custom-field-value.validator.js';
|
|
6
|
+
export * from './timestamp.value.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './timestamp.contract.js';
|
|
2
|
+
export * from './timestamp.definition-validation.js';
|
|
3
|
+
export * from './timestamp.dto.js';
|
|
4
|
+
export * from './timestamp.rules.js';
|
|
5
|
+
export * from './timestamp.custom-field-value.validator.js';
|
|
6
|
+
export * from './timestamp.value.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/custom-field-types/timestamp/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,sCAAsC,CAAA;AACpD,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,6CAA6C,CAAA;AAC3D,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Timestamp } from '@wisemen/datewise';
|
|
2
|
+
import type { DefineContract } from '#src/custom-field-type-contract.js';
|
|
3
|
+
export type TimestampCustomFieldTypeContract = DefineContract<{
|
|
4
|
+
value: Timestamp;
|
|
5
|
+
columnValue: string;
|
|
6
|
+
rules: {
|
|
7
|
+
minDate?: string;
|
|
8
|
+
maxDate?: string;
|
|
9
|
+
};
|
|
10
|
+
rulesMode: 'optional';
|
|
11
|
+
choicesMode: 'none';
|
|
12
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamp.contract.js","sourceRoot":"","sources":["../../../lib/custom-field-types/timestamp/timestamp.contract.ts"],"names":[],"mappings":""}
|
package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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('timestamp customFieldDefinition', () => {
|
|
8
|
+
it('creates a timestamp custom field definition', () => {
|
|
9
|
+
const definition = customFieldDefinition(CustomFieldType.TIMESTAMP, {
|
|
10
|
+
tenantUuid: null,
|
|
11
|
+
entityType: 'invoice',
|
|
12
|
+
key: 'sent_at',
|
|
13
|
+
label: new LocalizedString([{ locale: 'en', value: 'Sent at' }]),
|
|
14
|
+
description: null,
|
|
15
|
+
isRequired: false,
|
|
16
|
+
rules: {
|
|
17
|
+
minDate: '2026-01-01T00:00:00.000Z',
|
|
18
|
+
maxDate: '2026-12-31T23:59:59.999Z'
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
expect(definition.type).toBe(CustomFieldType.TIMESTAMP);
|
|
22
|
+
expect(definition.choices).toBeNull();
|
|
23
|
+
expect(definition.rules).toEqual({
|
|
24
|
+
type: CustomFieldType.TIMESTAMP,
|
|
25
|
+
minDate: '2026-01-01T00:00:00.000Z',
|
|
26
|
+
maxDate: '2026-12-31T23:59:59.999Z'
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
it('rejects a timestamp field with an invalid maxDate', () => {
|
|
30
|
+
expect(() => customFieldDefinition(CustomFieldType.TIMESTAMP, {
|
|
31
|
+
tenantUuid: null,
|
|
32
|
+
entityType: 'invoice',
|
|
33
|
+
key: 'sent_at',
|
|
34
|
+
label: new LocalizedString([{ locale: 'en', value: 'Sent at' }]),
|
|
35
|
+
description: null,
|
|
36
|
+
isRequired: false,
|
|
37
|
+
rules: {
|
|
38
|
+
maxDate: 'invalid-date'
|
|
39
|
+
}
|
|
40
|
+
})).toThrow(new CustomFieldDefinitionError('Date custom field maxDate must be a valid date'));
|
|
41
|
+
});
|
|
42
|
+
it('rejects a timestamp field whose minDate omits a timezone', () => {
|
|
43
|
+
expect(() => customFieldDefinition(CustomFieldType.TIMESTAMP, {
|
|
44
|
+
tenantUuid: null,
|
|
45
|
+
entityType: 'invoice',
|
|
46
|
+
key: 'sent_at',
|
|
47
|
+
label: new LocalizedString([{ locale: 'en', value: 'Sent at' }]),
|
|
48
|
+
description: null,
|
|
49
|
+
isRequired: false,
|
|
50
|
+
rules: {
|
|
51
|
+
minDate: '2026-01-01T09:00:00'
|
|
52
|
+
}
|
|
53
|
+
})).toThrow(new CustomFieldDefinitionError('Date custom field minDate must be a valid date'));
|
|
54
|
+
});
|
|
55
|
+
it('rejects a timestamp field whose minDate is after maxDate', () => {
|
|
56
|
+
expect(() => customFieldDefinition(CustomFieldType.TIMESTAMP, {
|
|
57
|
+
tenantUuid: null,
|
|
58
|
+
entityType: 'invoice',
|
|
59
|
+
key: 'sent_at',
|
|
60
|
+
label: new LocalizedString([{ locale: 'en', value: 'Sent at' }]),
|
|
61
|
+
description: null,
|
|
62
|
+
isRequired: false,
|
|
63
|
+
rules: {
|
|
64
|
+
minDate: '2026-12-31T23:59:59.999Z',
|
|
65
|
+
maxDate: '2026-01-01T00:00:00.000Z'
|
|
66
|
+
}
|
|
67
|
+
})).toThrow(new CustomFieldDefinitionError('Date custom field minDate can not be after maxDate'));
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=timestamp.custom-field-definition.factory.unit.test.js.map
|
package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamp.custom-field-definition.factory.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/timestamp/timestamp.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,iCAAiC,EAAE,GAAG,EAAE;IAC/C,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,SAAS,EAAE;YAClE,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,SAAS;YACd,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAChE,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE;gBACL,OAAO,EAAE,0BAA0B;gBACnC,OAAO,EAAE,0BAA0B;aACpC;SACF,CAAC,CAAA;QAEF,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;QACvD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAA;QACrC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;YAC/B,IAAI,EAAE,eAAe,CAAC,SAAS;YAC/B,OAAO,EAAE,0BAA0B;YACnC,OAAO,EAAE,0BAA0B;SACpC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,eAAe,CAAC,SAAS,EAAE;YAC5D,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,SAAS;YACd,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAChE,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE;gBACL,OAAO,EAAE,cAAc;aACxB;SACF,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,0BAA0B,CAAC,gDAAgD,CAAC,CAAC,CAAA;IAC/F,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,eAAe,CAAC,SAAS,EAAE;YAC5D,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,SAAS;YACd,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAChE,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE;gBACL,OAAO,EAAE,qBAAqB;aAC/B;SACF,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,0BAA0B,CAAC,gDAAgD,CAAC,CAAC,CAAA;IAC/F,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,eAAe,CAAC,SAAS,EAAE;YAC5D,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,SAAS;YACd,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAChE,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE;gBACL,OAAO,EAAE,0BAA0B;gBACnC,OAAO,EAAE,0BAA0B;aACpC;SACF,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,0BAA0B,CAAC,oDAAoD,CAAC,CAAC,CAAA;IACnG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Timestamp } from '@wisemen/datewise';
|
|
2
|
+
import type { CustomFieldDefinitionFieldsByType } from '#src/custom-field-definition.js';
|
|
3
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
4
|
+
type TimestampCustomFieldDefinition = CustomFieldDefinitionFieldsByType<CustomFieldType.TIMESTAMP>;
|
|
5
|
+
export declare function validateTimestampCustomFieldValue(definition: TimestampCustomFieldDefinition, value: Timestamp): void;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
|
|
2
|
+
export function validateTimestampCustomFieldValue(definition, value) {
|
|
3
|
+
const rules = definition.rules;
|
|
4
|
+
if (rules === null) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
if (rules.minDate !== undefined && value.isBefore(rules.minDate)) {
|
|
8
|
+
throw new CustomFieldValueValidationError('Timestamp custom field value can not be before minDate');
|
|
9
|
+
}
|
|
10
|
+
if (rules.maxDate !== undefined && value.isAfter(rules.maxDate)) {
|
|
11
|
+
throw new CustomFieldValueValidationError('Timestamp custom field value can not be after maxDate');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=timestamp.custom-field-value.validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamp.custom-field-value.validator.js","sourceRoot":"","sources":["../../../lib/custom-field-types/timestamp/timestamp.custom-field-value.validator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AAKxG,MAAM,UAAU,iCAAiC,CAC/C,UAA0C,EAC1C,KAAgB;IAEhB,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAA;IAE9B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAM;IACR,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,+BAA+B,CAAC,wDAAwD,CAAC,CAAA;IACrG,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,+BAA+B,CAAC,uDAAuD,CAAC,CAAA;IACpG,CAAC;AACH,CAAC"}
|
package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.unit.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|