@wisemen/nestjs-custom-fields 0.0.0 → 0.0.2
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,166 @@
|
|
|
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, validateCustomFieldValues } from '#src/validators/custom-field-value.validator.js';
|
|
6
|
+
import { generateUuid } from '#src/custom-field-definition.uuid.js';
|
|
7
|
+
import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
|
|
8
|
+
import { expect } from 'expect';
|
|
9
|
+
describe('validateCustomFieldValues', () => {
|
|
10
|
+
it('accepts valid custom field values', () => {
|
|
11
|
+
const textDefinition = customFieldDefinition(CustomFieldType.TEXT, {
|
|
12
|
+
tenantUuid: null,
|
|
13
|
+
entityType: 'invoice',
|
|
14
|
+
key: 'notes',
|
|
15
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
16
|
+
description: null,
|
|
17
|
+
isRequired: true,
|
|
18
|
+
rules: {
|
|
19
|
+
minLength: 2
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const singleSelectDefinition = customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
|
|
23
|
+
tenantUuid: null,
|
|
24
|
+
entityType: 'invoice',
|
|
25
|
+
key: 'status',
|
|
26
|
+
label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
|
|
27
|
+
description: null,
|
|
28
|
+
isRequired: false,
|
|
29
|
+
choices: [
|
|
30
|
+
{
|
|
31
|
+
value: 'draft',
|
|
32
|
+
label: new LocalizedString([{ locale: 'en', value: 'Draft' }]),
|
|
33
|
+
order: 1
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
expect(() => validateCustomFieldValues([textDefinition, singleSelectDefinition], [
|
|
38
|
+
{
|
|
39
|
+
definitionUuid: textDefinition.uuid,
|
|
40
|
+
type: CustomFieldType.TEXT,
|
|
41
|
+
value: 'ok'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
definitionUuid: singleSelectDefinition.uuid,
|
|
45
|
+
type: CustomFieldType.SINGLE_SELECT,
|
|
46
|
+
value: 'draft'
|
|
47
|
+
}
|
|
48
|
+
])).not.toThrow();
|
|
49
|
+
});
|
|
50
|
+
it('rejects duplicate custom field definitions', () => {
|
|
51
|
+
const textDefinition = customFieldDefinition(CustomFieldType.TEXT, {
|
|
52
|
+
tenantUuid: null,
|
|
53
|
+
entityType: 'invoice',
|
|
54
|
+
key: 'notes',
|
|
55
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
56
|
+
description: null,
|
|
57
|
+
isRequired: false
|
|
58
|
+
});
|
|
59
|
+
expect(() => validateCustomFieldValues([textDefinition, textDefinition], [])).toThrow(new CustomFieldValueValidationError(`Duplicate custom field definition ${textDefinition.uuid}`));
|
|
60
|
+
});
|
|
61
|
+
it('rejects a value whose definition was not provided', () => {
|
|
62
|
+
const textDefinition = customFieldDefinition(CustomFieldType.TEXT, {
|
|
63
|
+
tenantUuid: null,
|
|
64
|
+
entityType: 'invoice',
|
|
65
|
+
key: 'notes',
|
|
66
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
67
|
+
description: null,
|
|
68
|
+
isRequired: false
|
|
69
|
+
});
|
|
70
|
+
const missingDefinitionUuid = generateUuid();
|
|
71
|
+
expect(() => validateCustomFieldValues([textDefinition], [
|
|
72
|
+
{
|
|
73
|
+
definitionUuid: missingDefinitionUuid,
|
|
74
|
+
type: CustomFieldType.TEXT,
|
|
75
|
+
value: 'hello'
|
|
76
|
+
}
|
|
77
|
+
])).toThrow(new CustomFieldValueValidationError(`Custom field definition ${missingDefinitionUuid} was not found`));
|
|
78
|
+
});
|
|
79
|
+
it('rejects duplicate values for the same definition', () => {
|
|
80
|
+
const textDefinition = customFieldDefinition(CustomFieldType.TEXT, {
|
|
81
|
+
tenantUuid: null,
|
|
82
|
+
entityType: 'invoice',
|
|
83
|
+
key: 'notes',
|
|
84
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
85
|
+
description: null,
|
|
86
|
+
isRequired: false
|
|
87
|
+
});
|
|
88
|
+
expect(() => validateCustomFieldValues([textDefinition], [
|
|
89
|
+
{
|
|
90
|
+
definitionUuid: textDefinition.uuid,
|
|
91
|
+
type: CustomFieldType.TEXT,
|
|
92
|
+
value: 'first'
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
definitionUuid: textDefinition.uuid,
|
|
96
|
+
type: CustomFieldType.TEXT,
|
|
97
|
+
value: 'second'
|
|
98
|
+
}
|
|
99
|
+
])).toThrow(new CustomFieldValueValidationError(`Custom field value for definition ${textDefinition.uuid} can only be provided once`));
|
|
100
|
+
});
|
|
101
|
+
it('rejects when a required custom field is missing', () => {
|
|
102
|
+
const textDefinition = customFieldDefinition(CustomFieldType.TEXT, {
|
|
103
|
+
tenantUuid: null,
|
|
104
|
+
entityType: 'invoice',
|
|
105
|
+
key: 'notes',
|
|
106
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
107
|
+
description: null,
|
|
108
|
+
isRequired: true
|
|
109
|
+
});
|
|
110
|
+
expect(() => validateCustomFieldValues([textDefinition], [])).toThrow(new CustomFieldValueValidationError(`Custom field definition ${textDefinition.uuid} is required`));
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
describe('validateCustomFieldValue', () => {
|
|
114
|
+
it('rejects when definitionUuid does not match the definition', () => {
|
|
115
|
+
const definition = 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
|
+
});
|
|
123
|
+
expect(() => validateCustomFieldValue(definition, {
|
|
124
|
+
definitionUuid: generateUuid(),
|
|
125
|
+
type: CustomFieldType.TEXT,
|
|
126
|
+
value: 'hello'
|
|
127
|
+
})).toThrow(new CustomFieldValueValidationError('Custom field value definitionUuid must match the definition uuid'));
|
|
128
|
+
});
|
|
129
|
+
it('rejects when value type does not match the definition type', () => {
|
|
130
|
+
const definition = customFieldDefinition(CustomFieldType.TEXT, {
|
|
131
|
+
tenantUuid: null,
|
|
132
|
+
entityType: 'invoice',
|
|
133
|
+
key: 'notes',
|
|
134
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
135
|
+
description: null,
|
|
136
|
+
isRequired: false
|
|
137
|
+
});
|
|
138
|
+
expect(() => validateCustomFieldValue(definition, {
|
|
139
|
+
definitionUuid: definition.uuid,
|
|
140
|
+
type: CustomFieldType.NUMBER,
|
|
141
|
+
value: 1
|
|
142
|
+
})).toThrow(new CustomFieldValueValidationError('Custom field value type must match the definition type'));
|
|
143
|
+
});
|
|
144
|
+
it('rejects when the rules type does not match the definition type', () => {
|
|
145
|
+
const definition = {
|
|
146
|
+
...customFieldDefinition(CustomFieldType.TEXT, {
|
|
147
|
+
tenantUuid: null,
|
|
148
|
+
entityType: 'invoice',
|
|
149
|
+
key: 'notes',
|
|
150
|
+
label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
|
|
151
|
+
description: null,
|
|
152
|
+
isRequired: false
|
|
153
|
+
}),
|
|
154
|
+
rules: {
|
|
155
|
+
type: CustomFieldType.NUMBER,
|
|
156
|
+
min: 1
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
expect(() => validateCustomFieldValue(definition, {
|
|
160
|
+
definitionUuid: definition.uuid,
|
|
161
|
+
type: CustomFieldType.TEXT,
|
|
162
|
+
value: 'hello'
|
|
163
|
+
})).toThrow(new CustomFieldValueValidationError('Custom field rules must match the definition type'));
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
//# sourceMappingURL=custom-field-value.validator.unit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-field-value.validator.unit.test.js","sourceRoot":"","sources":["../../lib/validators/custom-field-value.validator.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAA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AAwB,CAAC,UAAU,EAAE;YAChD,cAAc,EAAE,UAAU,CAAC,IAAI;YAC/B,IAAI,EAAE,eAAe,CAAC,IAAI;YAC1B,KAAK,EAAE,OAAO;SACf,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,+BAA+B,CAAC,mDAAmD,CAAC,CAAC,CAAA;IACvG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wisemen/nestjs-custom-fields",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"imports": {
|
|
11
|
+
"#src/*": "./dist/*"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/",
|
|
18
|
+
"skills/"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@wisemen/datewise": "^1.0.14",
|
|
22
|
+
"@wisemen/localized-string": "^0.1.1",
|
|
23
|
+
"@wisemen/monetary": "^0.5.2",
|
|
24
|
+
"@wisemen/api-error": "^1.0.0",
|
|
25
|
+
"@wisemen/validators": "^0.0.25",
|
|
26
|
+
"@wisemen/nestjs-typeorm": "^1.2.0"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@nestjs/common": "^11.1.19",
|
|
30
|
+
"@nestjs/core": "^11.1.19",
|
|
31
|
+
"@nestjs/swagger": "^11.4.2",
|
|
32
|
+
"@opentelemetry/api": "^1.9.1",
|
|
33
|
+
"class-transformer": "^0.5.1",
|
|
34
|
+
"class-validator": "^0.15.1",
|
|
35
|
+
"typeorm": "^1.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "25.3.0",
|
|
39
|
+
"eslint": "10.2.1",
|
|
40
|
+
"expect": "30.4.1",
|
|
41
|
+
"oxlint": "1.59.0",
|
|
42
|
+
"oxlint-tsgolint": "0.20.0",
|
|
43
|
+
"typescript": "^5.9.3",
|
|
44
|
+
"@wisemen/eslint-config-nestjs": "1.1.1"
|
|
45
|
+
},
|
|
5
46
|
"author": "Wisemen",
|
|
47
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
48
|
"repository": {
|
|
7
49
|
"type": "git",
|
|
8
50
|
"url": "https://github.com/wisemen-digital/wisemen-core",
|
|
9
51
|
"directory": "packages/api/nestjs-custom-fields"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"lint:oxlint": "oxlint --type-aware lib",
|
|
55
|
+
"lint:eslint": "eslint lib",
|
|
56
|
+
"lint": "pnpm run lint:oxlint && pnpm run lint:eslint",
|
|
57
|
+
"clean": "rm -rf ./dist",
|
|
58
|
+
"build": "tsc",
|
|
59
|
+
"pretest": "pnpm build",
|
|
60
|
+
"test": "node --test ./dist/**/*.test.js",
|
|
61
|
+
"prerelease": "npm run build",
|
|
62
|
+
"release": "pnpx release-it"
|
|
10
63
|
}
|
|
11
|
-
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nestjs-custom-fields
|
|
3
|
+
description: Use when working with the @wisemen/nestjs-custom-fields package — developer-defined custom fields in NestJS with TypeORM persistence and runtime validation. Covers registering the CustomFieldDefinition entity, authoring definitions with customFieldDefinition(), storing resolved values via @CustomFieldValueColumn(), exposing them through CustomFieldValueDto / @IsCustomFields(), and validating submissions with CustomFieldDefinitionsRepository + validateCustomFieldValues(). Use this whenever a task involves custom field definitions, CustomFieldValue columns, custom-field DTOs, or tenant-scoped field definitions, even if the package is not named explicitly.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @wisemen/nestjs-custom-fields - Getting Started
|
|
7
|
+
|
|
8
|
+
This package manages developer-defined custom field definitions and values. It
|
|
9
|
+
does not target end-user managed custom field creation, does not ship
|
|
10
|
+
migrations, and does not auto-discover definitions.
|
|
11
|
+
|
|
12
|
+
It is intended that custom field definitions are read-only for users.
|
|
13
|
+
Creating, updating, and deleting definitions is handled manually by developers
|
|
14
|
+
through migrations or `playground.ts` scripts.
|
|
15
|
+
|
|
16
|
+
Definition uniqueness is scoped by `entityType`. For non-tenant definitions,
|
|
17
|
+
`key` must be unique per `entityType`. For tenant-scoped definitions,
|
|
18
|
+
`key + tenantUuid` must be unique per `entityType`.
|
|
19
|
+
|
|
20
|
+
## Step 1: Register The Exported Entity And Create The Table
|
|
21
|
+
|
|
22
|
+
This package already exports the effective `CustomFieldDefinition` TypeORM
|
|
23
|
+
entity. Add it to your datasource entities yourself so TypeORM knows about the
|
|
24
|
+
table metadata. After that, generate and run a migration so the table and the
|
|
25
|
+
exported entity's partial unique indexes are created in your database.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { DataSource } from 'typeorm'
|
|
29
|
+
import { CustomFieldDefinition } from '@wisemen/nestjs-custom-fields'
|
|
30
|
+
|
|
31
|
+
const datasource = new DataSource({
|
|
32
|
+
entities: ['dist/src/**/*.entity.js', CustomFieldDefinition]
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Step 2: Define Definitions And Insert Them In The Database
|
|
37
|
+
|
|
38
|
+
Create a definition with `customFieldDefinition(...)`, then insert it yourself.
|
|
39
|
+
The package does not discover definitions automatically. At the moment this is
|
|
40
|
+
mainly done through a migration or through `playground.ts`.
|
|
41
|
+
|
|
42
|
+
For persisted definitions, `tenantUuid` is part of the definition shape and
|
|
43
|
+
should be `null` for non-tenant definitions or a tenant UUID for tenant-scoped
|
|
44
|
+
definitions. This is different from repository lookups, where `tenantUuid` is
|
|
45
|
+
optional and can simply be omitted.
|
|
46
|
+
|
|
47
|
+
`key` uniqueness is enforced per `entityType`. Use a unique `key` for global
|
|
48
|
+
definitions, and a unique `key + tenantUuid` combination for tenant-specific
|
|
49
|
+
definitions.
|
|
50
|
+
|
|
51
|
+
It is recommended to define your `entityType` values in an enum instead of
|
|
52
|
+
repeating string literals across your application.
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import type { INestApplicationContext } from '@nestjs/common'
|
|
56
|
+
import { NestFactory } from '@nestjs/core'
|
|
57
|
+
import { JobContainer } from '@wisemen/app-container/fastify'
|
|
58
|
+
import { LocalizedString } from '@wisemen/localized-string'
|
|
59
|
+
import { DataSource } from 'typeorm'
|
|
60
|
+
import {
|
|
61
|
+
CustomFieldDefinition,
|
|
62
|
+
CustomFieldType,
|
|
63
|
+
customFieldDefinition
|
|
64
|
+
} from '@wisemen/nestjs-custom-fields'
|
|
65
|
+
|
|
66
|
+
enum CustomFieldEntityType {
|
|
67
|
+
TICKET = 'ticket'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export class Playground extends JobContainer {
|
|
71
|
+
async bootstrap(): Promise<INestApplicationContext> {
|
|
72
|
+
return await NestFactory.createApplicationContext(PlayGroundModule)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async execute(app: INestApplicationContext): Promise<void> {
|
|
76
|
+
const priorityField = customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
|
|
77
|
+
tenantUuid: null,
|
|
78
|
+
entityType: CustomFieldEntityType.TICKET,
|
|
79
|
+
key: 'priority',
|
|
80
|
+
label: new LocalizedString([{ locale: 'en', value: 'Priority' }]),
|
|
81
|
+
description: null,
|
|
82
|
+
isRequired: true,
|
|
83
|
+
choices: [
|
|
84
|
+
{
|
|
85
|
+
value: 'low',
|
|
86
|
+
order: 1,
|
|
87
|
+
label: new LocalizedString([{ locale: 'en', value: 'Low' }])
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
value: 'high',
|
|
91
|
+
order: 2,
|
|
92
|
+
label: new LocalizedString([{ locale: 'en', value: 'High' }])
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
await app.get(DataSource).manager.insert(CustomFieldDefinition, priorityField)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Step 3: Store Values On The Entity With The Custom Column
|
|
103
|
+
|
|
104
|
+
Resolved custom field values live on your own entity. Use
|
|
105
|
+
`@CustomFieldValueColumn()` for the persisted values column.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
import { Entity, PrimaryGeneratedColumn } from 'typeorm'
|
|
109
|
+
import { CustomFieldValueColumn, type CustomFieldValue } from '@wisemen/nestjs-custom-fields'
|
|
110
|
+
|
|
111
|
+
@Entity()
|
|
112
|
+
export class Ticket {
|
|
113
|
+
@PrimaryGeneratedColumn('uuid')
|
|
114
|
+
uuid: string
|
|
115
|
+
|
|
116
|
+
@CustomFieldValueColumn({ nullable: true })
|
|
117
|
+
customFields: CustomFieldValue[] | null
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Step 4: Receive And Show Values With DTOs
|
|
122
|
+
|
|
123
|
+
Requests and responses use the DTO layer from this package. For incoming
|
|
124
|
+
payloads, use `CustomFieldValueDto` with `@IsCustomFields()`. For outgoing
|
|
125
|
+
payloads, map stored values back with `CustomFieldValueDto.from(...)`.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
// update-ticket.command.ts
|
|
129
|
+
import { ApiProperty } from '@nestjs/swagger'
|
|
130
|
+
import {
|
|
131
|
+
CustomFieldValueApiExtraModels,
|
|
132
|
+
CustomFieldValueDto,
|
|
133
|
+
CustomFieldValueDtoApiProperty,
|
|
134
|
+
IsCustomFields
|
|
135
|
+
} from '@wisemen/nestjs-custom-fields'
|
|
136
|
+
|
|
137
|
+
@CustomFieldValueApiExtraModels()
|
|
138
|
+
export class UpdateTicketCommand {
|
|
139
|
+
@CustomFieldValueDtoApiProperty({ isArray: true })
|
|
140
|
+
@IsCustomFields()
|
|
141
|
+
customFields: CustomFieldValueDto[]
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// view-ticket.response.ts
|
|
145
|
+
@CustomFieldValueApiExtraModels()
|
|
146
|
+
export class ViewTicketResponse {
|
|
147
|
+
@ApiProperty({ type: String, format: 'uuid' })
|
|
148
|
+
uuid: string
|
|
149
|
+
|
|
150
|
+
@CustomFieldValueDtoApiProperty({ isArray: true })
|
|
151
|
+
customFields: CustomFieldValueDto[]
|
|
152
|
+
|
|
153
|
+
constructor(ticket: Ticket) {
|
|
154
|
+
this.uuid = ticket.uuid
|
|
155
|
+
this.customFields = ticket.customFields?.map((value) => CustomFieldValueDto.from(value)) ?? []
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Calling `parse()` on a DTO turns the transport-friendly input into the domain
|
|
161
|
+
custom field value shape, including richer value objects when needed. For
|
|
162
|
+
example, a `MonetaryDto` is parsed into the package's monetary value object
|
|
163
|
+
instead of staying a plain JSON structure.
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
import {
|
|
167
|
+
CustomFieldType,
|
|
168
|
+
MonetaryCustomFieldValueDto
|
|
169
|
+
} from '@wisemen/nestjs-custom-fields'
|
|
170
|
+
|
|
171
|
+
const dto = new MonetaryCustomFieldValueDto()
|
|
172
|
+
dto.definitionUuid = definitionUuid
|
|
173
|
+
dto.value = {
|
|
174
|
+
amount: '12.50',
|
|
175
|
+
currency: 'EUR',
|
|
176
|
+
precision: 2
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const parsed = dto.parse()
|
|
180
|
+
|
|
181
|
+
// parsed is now a domain custom field value object:
|
|
182
|
+
// {
|
|
183
|
+
// definitionUuid,
|
|
184
|
+
// type: CustomFieldType.MONETARY,
|
|
185
|
+
// value: dto.value.parse()
|
|
186
|
+
// }
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Step 5: Retrieve Definitions For Validation
|
|
190
|
+
|
|
191
|
+
When you process submitted values, retrieve the matching definitions through
|
|
192
|
+
`CustomFieldDefinitionsRepository` and validate against them with
|
|
193
|
+
`validateCustomFieldValues(...)`. If you also want to return definitions from
|
|
194
|
+
an API, map the same repository results with `CustomFieldDefinitionResponse`.
|
|
195
|
+
To inject the repository, register `CustomFieldDefinitionRepositoryModule` in
|
|
196
|
+
the Nest module that owns your use case or controller.
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
import { Module } from '@nestjs/common'
|
|
200
|
+
import { CustomFieldDefinitionRepositoryModule } from '@wisemen/nestjs-custom-fields'
|
|
201
|
+
|
|
202
|
+
@Module({
|
|
203
|
+
imports: [CustomFieldDefinitionRepositoryModule],
|
|
204
|
+
providers: [UpdateTicketUseCase]
|
|
205
|
+
})
|
|
206
|
+
export class UpdateTicketModule {}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
`validateCustomFieldValues(...)` throws `CustomFieldValueValidationError` when
|
|
210
|
+
the submitted values do not match the definitions. In controllers, document
|
|
211
|
+
that error according to the `@wisemen/api-error` package pattern by registering
|
|
212
|
+
it with `@ApiErrorResponse(...)`.
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
import { ApiErrorResponse } from '@wisemen/api-error'
|
|
216
|
+
import { CustomFieldValueValidationError } from '@wisemen/nestjs-custom-fields'
|
|
217
|
+
|
|
218
|
+
@ApiErrorResponse(CustomFieldValueValidationError)
|
|
219
|
+
async update(...): Promise<void> {
|
|
220
|
+
// controller logic
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
On repository lookups, `tenantUuid` is optional. Omit it to work with
|
|
224
|
+
non-tenant definitions, or set it to retrieve tenant-specific definitions in a
|
|
225
|
+
multi-tenant setup.
|
|
226
|
+
|
|
227
|
+
After DTO parsing, validate the resolved values against the definitions that
|
|
228
|
+
apply for that entity and tenant. This is the runtime check that enforces the
|
|
229
|
+
definition rules.
|
|
230
|
+
|
|
231
|
+
The runtime order matters: call `.parse()` on the DTOs first, then run
|
|
232
|
+
`validateCustomFieldValues(...)` against the definitions for that
|
|
233
|
+
`entityType` and tenant scope.
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
import { Injectable } from '@nestjs/common'
|
|
237
|
+
import {
|
|
238
|
+
CustomFieldDefinitionResponse,
|
|
239
|
+
CustomFieldDefinitionsRepository,
|
|
240
|
+
validateCustomFieldValues
|
|
241
|
+
} from '@wisemen/nestjs-custom-fields'
|
|
242
|
+
|
|
243
|
+
enum CustomFieldEntityType {
|
|
244
|
+
TICKET = 'ticket'
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@Injectable()
|
|
248
|
+
export class UpdateTicketUseCase {
|
|
249
|
+
constructor(
|
|
250
|
+
private readonly repository: CustomFieldDefinitionsRepository
|
|
251
|
+
) {}
|
|
252
|
+
|
|
253
|
+
async execute(command: UpdateTicketCommand): Promise<void> {
|
|
254
|
+
const values = command.customFields.map((value) => value.parse())
|
|
255
|
+
const definitions = await this.repository.findDefinitions({
|
|
256
|
+
entityType: CustomFieldEntityType.TICKET
|
|
257
|
+
})
|
|
258
|
+
validateCustomFieldValues(definitions, values)
|
|
259
|
+
|
|
260
|
+
// Remaining use-case logic
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
```
|