@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
package/LICENSE.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# PolyForm Strict License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/strict/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose, other than distributing the software or making changes or new works based on the software.
|
|
12
|
+
|
|
13
|
+
## Patent License
|
|
14
|
+
|
|
15
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
16
|
+
|
|
17
|
+
## Noncommercial Purposes
|
|
18
|
+
|
|
19
|
+
Any noncommercial purpose is a permitted purpose.
|
|
20
|
+
|
|
21
|
+
## Personal Uses
|
|
22
|
+
|
|
23
|
+
Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
|
|
24
|
+
|
|
25
|
+
## Noncommercial Organizations
|
|
26
|
+
|
|
27
|
+
Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
|
|
28
|
+
|
|
29
|
+
## Fair Use
|
|
30
|
+
|
|
31
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
32
|
+
|
|
33
|
+
## No Other Rights
|
|
34
|
+
|
|
35
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
36
|
+
|
|
37
|
+
## Patent Defense
|
|
38
|
+
|
|
39
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
40
|
+
|
|
41
|
+
## Violations
|
|
42
|
+
|
|
43
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
44
|
+
|
|
45
|
+
## No Liability
|
|
46
|
+
|
|
47
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
48
|
+
|
|
49
|
+
## Definitions
|
|
50
|
+
|
|
51
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
52
|
+
|
|
53
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
54
|
+
|
|
55
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
56
|
+
|
|
57
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
58
|
+
|
|
59
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# @wisemen/nestjs-custom-fields
|
|
2
|
+
|
|
3
|
+
Custom field definitions and values for NestJS applications with TypeORM
|
|
4
|
+
persistence, DTO support, and runtime validation.
|
|
5
|
+
|
|
6
|
+
Custom field definitions are developer-managed. This package does not target
|
|
7
|
+
end-user managed custom field creation.
|
|
8
|
+
|
|
9
|
+
It is intended that custom field definitions are read-only for users.
|
|
10
|
+
Creating, updating, and deleting definitions is handled manually by developers
|
|
11
|
+
through migrations or `playground.ts` scripts.
|
|
12
|
+
|
|
13
|
+
Definition uniqueness is scoped by `entityType`. For non-tenant definitions,
|
|
14
|
+
`key` must be unique per `entityType`. For tenant-scoped definitions,
|
|
15
|
+
`key + tenantUuid` must be unique per `entityType`.
|
|
16
|
+
|
|
17
|
+
## Step 1: Register The Exported Entity And Create The Table
|
|
18
|
+
|
|
19
|
+
This package already exports the effective `CustomFieldDefinition` TypeORM
|
|
20
|
+
entity. Add it to your datasource entities yourself so TypeORM knows about the
|
|
21
|
+
table metadata. After that, generate and run a migration so the table and the
|
|
22
|
+
exported entity's partial unique indexes are created in your database.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { DataSource } from 'typeorm'
|
|
26
|
+
import { CustomFieldDefinition } from '@wisemen/nestjs-custom-fields'
|
|
27
|
+
|
|
28
|
+
const datasource = new DataSource({
|
|
29
|
+
entities: ['dist/src/**/*.entity.js', CustomFieldDefinition]
|
|
30
|
+
})
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Step 2: Define Definitions And Insert Them In The Database
|
|
34
|
+
|
|
35
|
+
Create a definition with `customFieldDefinition(...)`, then insert it yourself.
|
|
36
|
+
The package does not discover definitions automatically. At the moment this is
|
|
37
|
+
mainly done through a migration or through `playground.ts`.
|
|
38
|
+
|
|
39
|
+
For persisted definitions, `tenantUuid` is part of the definition shape and
|
|
40
|
+
should be `null` for non-tenant definitions or a tenant UUID for tenant-scoped
|
|
41
|
+
definitions. This is different from repository lookups, where `tenantUuid` is
|
|
42
|
+
optional and can simply be omitted.
|
|
43
|
+
|
|
44
|
+
`key` uniqueness is enforced per `entityType`. Use a unique `key` for global
|
|
45
|
+
definitions, and a unique `key + tenantUuid` combination for tenant-specific
|
|
46
|
+
definitions.
|
|
47
|
+
|
|
48
|
+
It is recommended to define your `entityType` values in an enum instead of
|
|
49
|
+
repeating string literals across your application.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import type { INestApplicationContext } from '@nestjs/common'
|
|
53
|
+
import { NestFactory } from '@nestjs/core'
|
|
54
|
+
import { JobContainer } from '@wisemen/app-container/fastify'
|
|
55
|
+
import { LocalizedString } from '@wisemen/localized-string'
|
|
56
|
+
import { DataSource } from 'typeorm'
|
|
57
|
+
import {
|
|
58
|
+
CustomFieldDefinition,
|
|
59
|
+
CustomFieldType,
|
|
60
|
+
customFieldDefinition
|
|
61
|
+
} from '@wisemen/nestjs-custom-fields'
|
|
62
|
+
|
|
63
|
+
enum CustomFieldEntityType {
|
|
64
|
+
TICKET = 'ticket'
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class Playground extends JobContainer {
|
|
68
|
+
async bootstrap(): Promise<INestApplicationContext> {
|
|
69
|
+
return await NestFactory.createApplicationContext(PlayGroundModule)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async execute(app: INestApplicationContext): Promise<void> {
|
|
73
|
+
const priorityField = customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
|
|
74
|
+
tenantUuid: null,
|
|
75
|
+
entityType: CustomFieldEntityType.TICKET,
|
|
76
|
+
key: 'priority',
|
|
77
|
+
label: new LocalizedString([{ locale: 'en', value: 'Priority' }]),
|
|
78
|
+
description: null,
|
|
79
|
+
isRequired: true,
|
|
80
|
+
choices: [
|
|
81
|
+
{
|
|
82
|
+
value: 'low',
|
|
83
|
+
order: 1,
|
|
84
|
+
label: new LocalizedString([{ locale: 'en', value: 'Low' }])
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
value: 'high',
|
|
88
|
+
order: 2,
|
|
89
|
+
label: new LocalizedString([{ locale: 'en', value: 'High' }])
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
await app.get(DataSource).manager.insert(CustomFieldDefinition, priorityField)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Step 3: Store Values On The Entity With The Custom Column
|
|
100
|
+
|
|
101
|
+
Resolved custom field values live on your own entity. Use
|
|
102
|
+
`@CustomFieldValueColumn()` for the persisted values column.
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { Entity, PrimaryGeneratedColumn } from 'typeorm'
|
|
106
|
+
import {
|
|
107
|
+
CustomFieldValueColumn,
|
|
108
|
+
type CustomFieldValue
|
|
109
|
+
} 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
|
+
Calling `parse()` on a DTO turns the transport-friendly input into the domain
|
|
128
|
+
custom field value shape, including richer value objects when needed. For
|
|
129
|
+
example, a `MonetaryDto` is parsed into the package's monetary value object
|
|
130
|
+
instead of staying a plain JSON structure.
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import { ApiProperty } from '@nestjs/swagger'
|
|
134
|
+
import {
|
|
135
|
+
CustomFieldValueApiExtraModels,
|
|
136
|
+
CustomFieldValueDto,
|
|
137
|
+
CustomFieldValueDtoApiProperty,
|
|
138
|
+
IsCustomFields
|
|
139
|
+
} from '@wisemen/nestjs-custom-fields'
|
|
140
|
+
|
|
141
|
+
@CustomFieldValueApiExtraModels()
|
|
142
|
+
export class UpdateTicketCommand {
|
|
143
|
+
@CustomFieldValueDtoApiProperty({ isArray: true })
|
|
144
|
+
@IsCustomFields()
|
|
145
|
+
customFields: CustomFieldValueDto[]
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@CustomFieldValueApiExtraModels()
|
|
149
|
+
export class TicketResponseDto {
|
|
150
|
+
@ApiProperty({ type: String, format: 'uuid' })
|
|
151
|
+
uuid: string
|
|
152
|
+
|
|
153
|
+
@CustomFieldValueDtoApiProperty({ isArray: true })
|
|
154
|
+
customFields: CustomFieldValueDto[]
|
|
155
|
+
|
|
156
|
+
constructor(ticket: Ticket) {
|
|
157
|
+
this.uuid = ticket.uuid
|
|
158
|
+
this.customFields = ticket.customFields?.map(value => CustomFieldValueDto.from(value)) ?? []
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
`@IsCustomFields()` already applies array validation, nested DTO validation,
|
|
164
|
+
and uniqueness on `definitionUuid`.
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import {
|
|
168
|
+
CustomFieldType,
|
|
169
|
+
MonetaryCustomFieldValueDto
|
|
170
|
+
} from '@wisemen/nestjs-custom-fields'
|
|
171
|
+
|
|
172
|
+
const dto = new MonetaryCustomFieldValueDto()
|
|
173
|
+
dto.definitionUuid = definitionUuid
|
|
174
|
+
dto.value = {
|
|
175
|
+
amount: '12.50',
|
|
176
|
+
currency: 'EUR',
|
|
177
|
+
precision: 2
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const parsed = dto.parse()
|
|
181
|
+
|
|
182
|
+
// parsed is now a domain custom field value object:
|
|
183
|
+
// {
|
|
184
|
+
// definitionUuid,
|
|
185
|
+
// type: CustomFieldType.MONETARY,
|
|
186
|
+
// value: dto.value.parse()
|
|
187
|
+
// }
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Step 5: Retrieve Definitions For Validation
|
|
191
|
+
|
|
192
|
+
When you process submitted values, retrieve the matching definitions through
|
|
193
|
+
`CustomFieldDefinitionsRepository` and validate against them with
|
|
194
|
+
`validateCustomFieldValues(...)`. If you also want to return definitions from
|
|
195
|
+
an API, map the same repository results with `CustomFieldDefinitionResponse`.
|
|
196
|
+
To inject the repository, register `CustomFieldDefinitionRepositoryModule` in
|
|
197
|
+
the Nest module that owns your use case or controller.
|
|
198
|
+
|
|
199
|
+
`validateCustomFieldValues(...)` throws `CustomFieldValueValidationError` when
|
|
200
|
+
the submitted values do not match the definitions. In controllers, document
|
|
201
|
+
that error according to the `@wisemen/api-error` package pattern by registering
|
|
202
|
+
it with `@ApiErrorResponse(...)`.
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
import { Module } from '@nestjs/common'
|
|
206
|
+
import { CustomFieldDefinitionRepositoryModule } from '@wisemen/nestjs-custom-fields'
|
|
207
|
+
|
|
208
|
+
@Module({
|
|
209
|
+
imports: [CustomFieldDefinitionRepositoryModule],
|
|
210
|
+
providers: [UpdateTicketCustomFieldsUseCase]
|
|
211
|
+
})
|
|
212
|
+
export class UpdateTicketModule {}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
On repository lookups, `tenantUuid` is optional. Omit it to work with
|
|
216
|
+
non-tenant definitions, or set it to retrieve tenant-specific definitions in a
|
|
217
|
+
multi-tenant setup.
|
|
218
|
+
|
|
219
|
+
After DTO parsing, validate the resolved values against the definitions that
|
|
220
|
+
apply for that entity and tenant. This is the runtime check that enforces the
|
|
221
|
+
definition rules.
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import { Injectable } from '@nestjs/common'
|
|
225
|
+
import {
|
|
226
|
+
CustomFieldDefinitionResponse,
|
|
227
|
+
CustomFieldDefinitionsRepository,
|
|
228
|
+
validateCustomFieldValues
|
|
229
|
+
} from '@wisemen/nestjs-custom-fields'
|
|
230
|
+
|
|
231
|
+
enum CustomFieldEntityType {
|
|
232
|
+
TICKET = 'ticket'
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@Injectable()
|
|
236
|
+
export class UpdateTicketCustomFieldsUseCase {
|
|
237
|
+
constructor(
|
|
238
|
+
private readonly repository: CustomFieldDefinitionsRepository
|
|
239
|
+
) {}
|
|
240
|
+
|
|
241
|
+
async execute(command: UpdateTicketCommand): Promise<void> {
|
|
242
|
+
const definitions = await this.repository.findDefinitions({
|
|
243
|
+
entityType: CustomFieldEntityType.TICKET
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
const values = command.customFields.map(value => value.parse())
|
|
247
|
+
|
|
248
|
+
validateCustomFieldValues(definitions, values)
|
|
249
|
+
|
|
250
|
+
// Persist the validated values here.
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
If you want to return definitions from a read endpoint, use
|
|
256
|
+
`CustomFieldDefinitionResponse` to map the repository results into the response
|
|
257
|
+
shape:
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
async function findTicketDefinitions(
|
|
261
|
+
repository: CustomFieldDefinitionsRepository
|
|
262
|
+
): Promise<CustomFieldDefinitionResponse[]> {
|
|
263
|
+
const definitions = await repository.findDefinitions({
|
|
264
|
+
entityType: CustomFieldEntityType.TICKET
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
return definitions.map(definition => new CustomFieldDefinitionResponse(definition))
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
import { ApiErrorResponse } from '@wisemen/api-error'
|
|
273
|
+
import { CustomFieldValueValidationError } from '@wisemen/nestjs-custom-fields'
|
|
274
|
+
|
|
275
|
+
@ApiErrorResponse(CustomFieldValueValidationError)
|
|
276
|
+
async update(...): Promise<void> {
|
|
277
|
+
// controller logic
|
|
278
|
+
}
|
|
279
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-field-choice.js","sourceRoot":"","sources":["../lib/custom-field-choice.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CustomFieldChoice } from '#src/custom-field-choice.js';
|
|
2
|
+
import { CustomFieldDefinitionUuid } from '#src/custom-field-definition.uuid.js';
|
|
3
|
+
import { CustomFieldRules, CustomFieldRulesByType } from '#src/custom-field-rules.js';
|
|
4
|
+
import { CustomFieldChoicesModeByType, CustomFieldRulesModeByType } from '#src/custom-field-type-contract.js';
|
|
5
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
6
|
+
import { LocalizedString } from '@wisemen/localized-string';
|
|
7
|
+
export interface CustomFieldDefinitionData {
|
|
8
|
+
uuid: CustomFieldDefinitionUuid;
|
|
9
|
+
tenantUuid: string | null;
|
|
10
|
+
entityType: string;
|
|
11
|
+
key: string;
|
|
12
|
+
label: LocalizedString;
|
|
13
|
+
description: LocalizedString | null;
|
|
14
|
+
type: CustomFieldType;
|
|
15
|
+
isRequired: boolean;
|
|
16
|
+
choices: CustomFieldChoice[] | null;
|
|
17
|
+
rules: CustomFieldRules | null;
|
|
18
|
+
}
|
|
19
|
+
type BaseCustomFieldDefinitionFields<T extends CustomFieldType> = Omit<CustomFieldDefinitionData, 'type' | 'choices' | 'rules'> & {
|
|
20
|
+
type: T;
|
|
21
|
+
};
|
|
22
|
+
type CustomFieldDefinitionChoicesField<T extends CustomFieldType> = CustomFieldChoicesModeByType<T> extends 'required' ? {
|
|
23
|
+
choices: CustomFieldChoice[];
|
|
24
|
+
} : {
|
|
25
|
+
choices: null;
|
|
26
|
+
};
|
|
27
|
+
type CustomFieldDefinitionRulesField<T extends CustomFieldType> = CustomFieldRulesModeByType<T> extends 'required' ? {
|
|
28
|
+
rules: CustomFieldRulesByType<T>;
|
|
29
|
+
} : CustomFieldRulesModeByType<T> extends 'optional' ? {
|
|
30
|
+
rules: CustomFieldRulesByType<T> | null;
|
|
31
|
+
} : {
|
|
32
|
+
rules: null;
|
|
33
|
+
};
|
|
34
|
+
export type CustomFieldDefinitionFieldsByType<T extends CustomFieldType> = BaseCustomFieldDefinitionFields<T> & CustomFieldDefinitionChoicesField<T> & CustomFieldDefinitionRulesField<T>;
|
|
35
|
+
export type ResolvedCustomFieldDefinitionFields = {
|
|
36
|
+
[T in CustomFieldType]: CustomFieldDefinitionFieldsByType<T>;
|
|
37
|
+
}[CustomFieldType];
|
|
38
|
+
export type CustomFieldDefinitionFieldsMap = {
|
|
39
|
+
[T in CustomFieldType]: CustomFieldDefinitionFieldsByType<T>;
|
|
40
|
+
};
|
|
41
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-field-definition.js","sourceRoot":"","sources":["../lib/custom-field-definition.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type Uuid<Brand extends string> = string & {
|
|
2
|
+
readonly __brand: 'uuid';
|
|
3
|
+
} & {
|
|
4
|
+
readonly __uuid: Brand;
|
|
5
|
+
};
|
|
6
|
+
export declare function generateUuid<Brand extends Uuid<string> | null>(): Exclude<Brand, null>;
|
|
7
|
+
export type CustomFieldDefinitionUuid = Uuid<'CustomFieldDefinition'>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-field-definition.uuid.js","sourceRoot":"","sources":["../lib/custom-field-definition.uuid.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,YAAY;IAC1B,OAAO,MAAM,CAAC,UAAU,EAA0B,CAAA;AACpD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CustomFieldType } from './enum/custom-field-type.enum.js';
|
|
2
|
+
import type { CustomFieldRuleConfigByType } from './custom-field-type-contract.js';
|
|
3
|
+
import type { BooleanCustomFieldRules as BooleanCustomFieldRulesModel } from '#src/custom-field-types/boolean/boolean.rules.js';
|
|
4
|
+
import type { DateCustomFieldRules as DateCustomFieldRulesModel } from '#src/custom-field-types/date/date.rules.js';
|
|
5
|
+
import type { MonetaryCustomFieldRules as MonetaryCustomFieldRulesModel } from '#src/custom-field-types/monetary/monetary.rules.js';
|
|
6
|
+
import type { MultiSelectCustomFieldRules as MultiSelectCustomFieldRulesModel } from '#src/custom-field-types/multi-select/multi-select.rules.js';
|
|
7
|
+
import type { NumberCustomFieldRules as NumberCustomFieldRulesModel } from '#src/custom-field-types/number/number.rules.js';
|
|
8
|
+
import type { SelectCustomFieldRules as SelectCustomFieldRulesModel } from '#src/custom-field-types/single-select/single-select.rules.js';
|
|
9
|
+
import type { TextArrayCustomFieldRules as TextArrayCustomFieldRulesModel } from '#src/custom-field-types/text-array/text-array.rules.js';
|
|
10
|
+
import type { TextCustomFieldRules as TextCustomFieldRulesModel } from '#src/custom-field-types/text/text.rules.js';
|
|
11
|
+
import type { TimestampCustomFieldRules as TimestampCustomFieldRulesModel } from '#src/custom-field-types/timestamp/timestamp.rules.js';
|
|
12
|
+
type CustomFieldRulesFor<T extends CustomFieldType> = {
|
|
13
|
+
type: T;
|
|
14
|
+
} & CustomFieldRuleConfigByType<T>;
|
|
15
|
+
export type TextCustomFieldRules = TextCustomFieldRulesModel;
|
|
16
|
+
export type TextArrayCustomFieldRules = TextArrayCustomFieldRulesModel;
|
|
17
|
+
export type NumberCustomFieldRules = NumberCustomFieldRulesModel;
|
|
18
|
+
export type BooleanCustomFieldRules = BooleanCustomFieldRulesModel;
|
|
19
|
+
export type DateCustomFieldRules = DateCustomFieldRulesModel;
|
|
20
|
+
export type TimestampCustomFieldRules = TimestampCustomFieldRulesModel;
|
|
21
|
+
export type SelectCustomFieldRules = SelectCustomFieldRulesModel;
|
|
22
|
+
export type MultiSelectCustomFieldRules = MultiSelectCustomFieldRulesModel;
|
|
23
|
+
export type MonetaryCustomFieldRules = MonetaryCustomFieldRulesModel;
|
|
24
|
+
export type CustomFieldRulesByType<T extends CustomFieldType> = CustomFieldRulesFor<T>;
|
|
25
|
+
export type CustomFieldRules = {
|
|
26
|
+
[T in CustomFieldType]: CustomFieldRulesByType<T>;
|
|
27
|
+
}[CustomFieldType];
|
|
28
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-field-rules.js","sourceRoot":"","sources":["../lib/custom-field-rules.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { BooleanCustomFieldTypeContract } from '#src/custom-field-types/boolean/boolean.contract.js';
|
|
2
|
+
import type { DateCustomFieldTypeContract } from '#src/custom-field-types/date/date.contract.js';
|
|
3
|
+
import type { MonetaryCustomFieldTypeContract } from '#src/custom-field-types/monetary/monetary.contract.js';
|
|
4
|
+
import type { MultiSelectCustomFieldTypeContract } from '#src/custom-field-types/multi-select/multi-select.contract.js';
|
|
5
|
+
import type { NumberCustomFieldTypeContract } from '#src/custom-field-types/number/number.contract.js';
|
|
6
|
+
import type { SingleSelectCustomFieldTypeContract } from '#src/custom-field-types/single-select/single-select.contract.js';
|
|
7
|
+
import type { TextArrayCustomFieldTypeContract } from '#src/custom-field-types/text-array/text-array.contract.js';
|
|
8
|
+
import type { TextCustomFieldTypeContract } from '#src/custom-field-types/text/text.contract.js';
|
|
9
|
+
import type { TimestampCustomFieldTypeContract } from '#src/custom-field-types/timestamp/timestamp.contract.js';
|
|
10
|
+
import { CustomFieldType } from './enum/custom-field-type.enum.js';
|
|
11
|
+
type Satisfies<T extends U, U> = T;
|
|
12
|
+
export type CustomFieldRulesMode = 'required' | 'optional' | 'none';
|
|
13
|
+
export type CustomFieldChoicesMode = 'required' | 'none';
|
|
14
|
+
export interface CustomFieldTypeContractBase {
|
|
15
|
+
value: unknown;
|
|
16
|
+
columnValue: unknown;
|
|
17
|
+
rules: unknown;
|
|
18
|
+
rulesMode: CustomFieldRulesMode;
|
|
19
|
+
choicesMode: CustomFieldChoicesMode;
|
|
20
|
+
}
|
|
21
|
+
export type DefineContract<T extends CustomFieldTypeContractBase & Record<Exclude<keyof T, keyof CustomFieldTypeContractBase>, never>> = T;
|
|
22
|
+
export type CustomFieldTypeContract = Satisfies<{
|
|
23
|
+
[CustomFieldType.TEXT]: TextCustomFieldTypeContract;
|
|
24
|
+
[CustomFieldType.TEXT_ARRAY]: TextArrayCustomFieldTypeContract;
|
|
25
|
+
[CustomFieldType.NUMBER]: NumberCustomFieldTypeContract;
|
|
26
|
+
[CustomFieldType.BOOLEAN]: BooleanCustomFieldTypeContract;
|
|
27
|
+
[CustomFieldType.TIMESTAMP]: TimestampCustomFieldTypeContract;
|
|
28
|
+
[CustomFieldType.DATE]: DateCustomFieldTypeContract;
|
|
29
|
+
[CustomFieldType.SINGLE_SELECT]: SingleSelectCustomFieldTypeContract;
|
|
30
|
+
[CustomFieldType.MULTI_SELECT]: MultiSelectCustomFieldTypeContract;
|
|
31
|
+
[CustomFieldType.MONETARY]: MonetaryCustomFieldTypeContract;
|
|
32
|
+
}, Record<CustomFieldType, CustomFieldTypeContractBase>>;
|
|
33
|
+
export type CustomFieldDomainValueByType<T extends CustomFieldType> = CustomFieldTypeContract[T]['value'];
|
|
34
|
+
export type CustomFieldColumnValueByType<T extends CustomFieldType> = CustomFieldTypeContract[T]['columnValue'];
|
|
35
|
+
export type CustomFieldRuleConfigByType<T extends CustomFieldType> = CustomFieldTypeContract[T]['rules'];
|
|
36
|
+
export type CustomFieldRulesModeByType<T extends CustomFieldType> = CustomFieldTypeContract[T]['rulesMode'];
|
|
37
|
+
export type CustomFieldChoicesModeByType<T extends CustomFieldType> = CustomFieldTypeContract[T]['choicesMode'];
|
|
38
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-field-type-contract.js","sourceRoot":"","sources":["../lib/custom-field-type-contract.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.contract.js","sourceRoot":"","sources":["../../../lib/custom-field-types/boolean/boolean.contract.ts"],"names":[],"mappings":""}
|
package/dist/custom-field-types/boolean/boolean.custom-field-definition.factory.unit.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import { expect } from 'expect';
|
|
3
|
+
import { LocalizedString } from '@wisemen/localized-string';
|
|
4
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
5
|
+
import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
|
|
6
|
+
describe('boolean customFieldDefinition', () => {
|
|
7
|
+
it('creates a boolean custom field definition', () => {
|
|
8
|
+
const definition = customFieldDefinition(CustomFieldType.BOOLEAN, {
|
|
9
|
+
tenantUuid: null,
|
|
10
|
+
entityType: 'invoice',
|
|
11
|
+
key: 'approved',
|
|
12
|
+
label: new LocalizedString([{ locale: 'en', value: 'Approved' }]),
|
|
13
|
+
description: null,
|
|
14
|
+
isRequired: false
|
|
15
|
+
});
|
|
16
|
+
expect(definition.type).toBe(CustomFieldType.BOOLEAN);
|
|
17
|
+
expect(definition.choices).toBeNull();
|
|
18
|
+
expect(definition.rules).toBeNull();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=boolean.custom-field-definition.factory.unit.test.js.map
|
package/dist/custom-field-types/boolean/boolean.custom-field-definition.factory.unit.test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.custom-field-definition.factory.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/boolean/boolean.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,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AAEvF,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,OAAO,EAAE;YAChE,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,UAAU;YACf,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;YACjE,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAA;QAEF,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;QACrD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAA;QACrC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function validateBooleanCustomFieldValue(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.custom-field-value.validator.js","sourceRoot":"","sources":["../../../lib/custom-field-types/boolean/boolean.custom-field-value.validator.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,+BAA+B,KAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { expect } from 'expect';
|
|
7
|
+
describe('boolean validateCustomFieldValue', () => {
|
|
8
|
+
it('accepts a boolean custom field value', () => {
|
|
9
|
+
const definition = customFieldDefinition(CustomFieldType.BOOLEAN, {
|
|
10
|
+
tenantUuid: null,
|
|
11
|
+
entityType: 'invoice',
|
|
12
|
+
key: 'approved',
|
|
13
|
+
label: new LocalizedString([{ locale: 'en', value: 'Approved' }]),
|
|
14
|
+
description: null,
|
|
15
|
+
isRequired: false
|
|
16
|
+
});
|
|
17
|
+
expect(() => validateCustomFieldValue(definition, {
|
|
18
|
+
definitionUuid: definition.uuid,
|
|
19
|
+
type: CustomFieldType.BOOLEAN,
|
|
20
|
+
value: true
|
|
21
|
+
})).not.toThrow();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=boolean.custom-field-value.validator.unit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.custom-field-value.validator.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/boolean/boolean.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,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,OAAO,EAAE;YAChE,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS;YACrB,GAAG,EAAE,UAAU;YACf,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;YACjE,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAA;QAEF,MAAM,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,UAAU,EAAE;YAChD,cAAc,EAAE,UAAU,CAAC,IAAI;YAC/B,IAAI,EAAE,eAAe,CAAC,OAAO;YAC7B,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;IACnB,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 BooleanCustomFieldDefinition = Extract<ResolvedCustomFieldDefinitionFields, {
|
|
4
|
+
type: CustomFieldType.BOOLEAN;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function validateBooleanCustomFieldDefinition(definition: BooleanCustomFieldDefinition): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CustomFieldDefinitionError } from '#src/errors/custom-field-definition.error.js';
|
|
2
|
+
export function validateBooleanCustomFieldDefinition(definition) {
|
|
3
|
+
if (definition.choices !== null) {
|
|
4
|
+
throw new CustomFieldDefinitionError('Only select custom fields can define choices');
|
|
5
|
+
}
|
|
6
|
+
if (definition.rules !== null) {
|
|
7
|
+
throw new CustomFieldDefinitionError('Boolean custom field can not define rules');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=boolean.definition-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.definition-validation.js","sourceRoot":"","sources":["../../../lib/custom-field-types/boolean/boolean.definition-validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AAKzF,MAAM,UAAU,oCAAoC,CAAC,UAAwC;IAC3F,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,0BAA0B,CAAC,8CAA8C,CAAC,CAAA;IACtF,CAAC;IAED,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAC9B,MAAM,IAAI,0BAA0B,CAAC,2CAA2C,CAAC,CAAA;IACnF,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 { BooleanCustomFieldValue } from '#src/custom-field-types/boolean/boolean.value.js';
|
|
4
|
+
export declare class BooleanCustomFieldValueDto extends BaseCustomFieldValueDto {
|
|
5
|
+
type: CustomFieldType.BOOLEAN;
|
|
6
|
+
value: boolean;
|
|
7
|
+
parse(): BooleanCustomFieldValue;
|
|
8
|
+
static from(customFieldValue: BooleanCustomFieldValue): BooleanCustomFieldValueDto;
|
|
9
|
+
}
|