@wisemen/nestjs-custom-fields 4.2.0 → 5.0.0
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/README.md +70 -0
- package/dist/custom-field-choice.d.ts +1 -1
- package/dist/custom-field-definition.d.ts +6 -6
- package/dist/custom-field-rules.d.ts +4 -2
- package/dist/custom-field-type-contract.d.ts +3 -1
- package/dist/custom-field-type-contract.js +1 -1
- package/dist/custom-field-type-contract.js.map +1 -1
- package/dist/custom-field-types/boolean/boolean.definition-validation.d.ts +1 -1
- package/dist/custom-field-types/boolean/boolean.dto.d.ts +1 -1
- package/dist/custom-field-types/boolean/boolean.rules.d.ts +2 -2
- package/dist/custom-field-types/boolean/boolean.value.d.ts +2 -2
- package/dist/custom-field-types/boolean/index.d.ts +6 -6
- package/dist/custom-field-types/boolean/index.js +6 -6
- package/dist/custom-field-types/boolean/index.js.map +1 -1
- package/dist/custom-field-types/date/date.custom-field-value.validator.d.ts +1 -1
- package/dist/custom-field-types/date/date.definition-validation.d.ts +1 -1
- package/dist/custom-field-types/date/date.dto.d.ts +1 -1
- package/dist/custom-field-types/date/date.rules.d.ts +2 -2
- package/dist/custom-field-types/date/date.value.d.ts +2 -2
- package/dist/custom-field-types/date/index.d.ts +6 -6
- package/dist/custom-field-types/date/index.js +6 -6
- package/dist/custom-field-types/date/index.js.map +1 -1
- package/dist/custom-field-types/index.d.ts +11 -10
- package/dist/custom-field-types/index.js +11 -10
- package/dist/custom-field-types/index.js.map +1 -1
- package/dist/custom-field-types/monetary/index.d.ts +6 -6
- package/dist/custom-field-types/monetary/index.js +6 -6
- package/dist/custom-field-types/monetary/index.js.map +1 -1
- package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.d.ts +2 -2
- package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.js.map +1 -1
- package/dist/custom-field-types/monetary/monetary.definition-validation.d.ts +1 -1
- package/dist/custom-field-types/monetary/monetary.dto.d.ts +2 -2
- package/dist/custom-field-types/monetary/monetary.dto.js.map +1 -1
- package/dist/custom-field-types/monetary/monetary.rules.d.ts +2 -2
- package/dist/custom-field-types/monetary/monetary.value.d.ts +2 -2
- package/dist/custom-field-types/multi-select/index.d.ts +6 -6
- package/dist/custom-field-types/multi-select/index.js +6 -6
- package/dist/custom-field-types/multi-select/index.js.map +1 -1
- package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.d.ts +1 -1
- package/dist/custom-field-types/multi-select/multi-select.definition-validation.d.ts +1 -1
- package/dist/custom-field-types/multi-select/multi-select.dto.d.ts +1 -1
- package/dist/custom-field-types/multi-select/multi-select.rules.d.ts +2 -2
- package/dist/custom-field-types/multi-select/multi-select.value.d.ts +2 -2
- package/dist/custom-field-types/number/index.d.ts +6 -6
- package/dist/custom-field-types/number/index.js +6 -6
- package/dist/custom-field-types/number/index.js.map +1 -1
- package/dist/custom-field-types/number/number.custom-field-value.validator.d.ts +1 -1
- package/dist/custom-field-types/number/number.definition-validation.d.ts +1 -1
- package/dist/custom-field-types/number/number.dto.d.ts +1 -1
- package/dist/custom-field-types/number/number.rules.d.ts +2 -2
- package/dist/custom-field-types/number/number.value.d.ts +2 -2
- package/dist/custom-field-types/progress/index.d.ts +7 -0
- package/dist/custom-field-types/progress/index.js +8 -0
- package/dist/custom-field-types/progress/index.js.map +1 -0
- package/dist/custom-field-types/progress/progress.color.d.ts +25 -0
- package/dist/custom-field-types/progress/progress.color.js +27 -0
- package/dist/custom-field-types/progress/progress.color.js.map +1 -0
- package/dist/custom-field-types/progress/progress.contract.d.ts +20 -0
- package/dist/custom-field-types/progress/progress.contract.js +2 -0
- package/dist/custom-field-types/progress/progress.contract.js.map +1 -0
- package/dist/custom-field-types/progress/progress.custom-field-definition.factory.unit.test.d.ts +1 -0
- package/dist/custom-field-types/progress/progress.custom-field-definition.factory.unit.test.js +67 -0
- package/dist/custom-field-types/progress/progress.custom-field-definition.factory.unit.test.js.map +1 -0
- package/dist/custom-field-types/progress/progress.custom-field-value.validator.d.ts +6 -0
- package/dist/custom-field-types/progress/progress.custom-field-value.validator.js +34 -0
- package/dist/custom-field-types/progress/progress.custom-field-value.validator.js.map +1 -0
- package/dist/custom-field-types/progress/progress.custom-field-value.validator.unit.test.d.ts +1 -0
- package/dist/custom-field-types/progress/progress.custom-field-value.validator.unit.test.js +91 -0
- package/dist/custom-field-types/progress/progress.custom-field-value.validator.unit.test.js.map +1 -0
- package/dist/custom-field-types/progress/progress.definition-validation.d.ts +7 -0
- package/dist/custom-field-types/progress/progress.definition-validation.js +44 -0
- package/dist/custom-field-types/progress/progress.definition-validation.js.map +1 -0
- package/dist/custom-field-types/progress/progress.dto.d.ts +22 -0
- package/dist/custom-field-types/progress/progress.dto.js +94 -0
- package/dist/custom-field-types/progress/progress.dto.js.map +1 -0
- package/dist/custom-field-types/progress/progress.rules.d.ts +5 -0
- package/dist/custom-field-types/progress/progress.rules.js +2 -0
- package/dist/custom-field-types/progress/progress.rules.js.map +1 -0
- package/dist/custom-field-types/progress/progress.value.d.ts +5 -0
- package/dist/custom-field-types/progress/progress.value.js +2 -0
- package/dist/custom-field-types/progress/progress.value.js.map +1 -0
- package/dist/custom-field-types/reference/index.d.ts +7 -7
- package/dist/custom-field-types/reference/index.js +7 -7
- package/dist/custom-field-types/reference/index.js.map +1 -1
- package/dist/custom-field-types/reference/reference.contract.d.ts +1 -1
- package/dist/custom-field-types/reference/reference.custom-field-definition.factory.unit.test.js +1 -1
- package/dist/custom-field-types/reference/reference.custom-field-definition.factory.unit.test.js.map +1 -1
- package/dist/custom-field-types/reference/reference.custom-field-value.validator.d.ts +1 -1
- package/dist/custom-field-types/reference/reference.custom-field-value.validator.js +1 -1
- package/dist/custom-field-types/reference/reference.custom-field-value.validator.js.map +1 -1
- package/dist/custom-field-types/reference/reference.custom-field-value.validator.unit.test.js +1 -1
- package/dist/custom-field-types/reference/reference.custom-field-value.validator.unit.test.js.map +1 -1
- package/dist/custom-field-types/reference/reference.definition-validation.d.ts +1 -1
- package/dist/custom-field-types/reference/reference.definition-validation.js +1 -1
- package/dist/custom-field-types/reference/reference.definition-validation.js.map +1 -1
- package/dist/custom-field-types/reference/reference.dto.d.ts +1 -1
- package/dist/custom-field-types/reference/reference.rules.d.ts +2 -2
- package/dist/custom-field-types/reference/reference.value.d.ts +2 -2
- package/dist/custom-field-types/single-select/index.d.ts +6 -6
- package/dist/custom-field-types/single-select/index.js +6 -6
- package/dist/custom-field-types/single-select/index.js.map +1 -1
- package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.d.ts +1 -1
- package/dist/custom-field-types/single-select/single-select.definition-validation.d.ts +1 -1
- package/dist/custom-field-types/single-select/single-select.dto.d.ts +1 -1
- package/dist/custom-field-types/single-select/single-select.rules.d.ts +2 -2
- package/dist/custom-field-types/single-select/single-select.value.d.ts +2 -2
- package/dist/custom-field-types/text/index.d.ts +6 -6
- package/dist/custom-field-types/text/index.js +6 -6
- package/dist/custom-field-types/text/index.js.map +1 -1
- package/dist/custom-field-types/text/text.custom-field-definition.factory.unit.test.js.map +1 -1
- package/dist/custom-field-types/text/text.custom-field-value.validator.d.ts +1 -1
- package/dist/custom-field-types/text/text.definition-validation.d.ts +1 -1
- package/dist/custom-field-types/text/text.definition-validation.js +3 -3
- package/dist/custom-field-types/text/text.definition-validation.js.map +1 -1
- package/dist/custom-field-types/text/text.dto.d.ts +1 -1
- package/dist/custom-field-types/text/text.dto.js.map +1 -1
- package/dist/custom-field-types/text/text.rules.d.ts +2 -2
- package/dist/custom-field-types/text/text.value.d.ts +2 -2
- package/dist/custom-field-types/text-array/index.d.ts +6 -6
- package/dist/custom-field-types/text-array/index.js +6 -6
- package/dist/custom-field-types/text-array/index.js.map +1 -1
- package/dist/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.js.map +1 -1
- package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.d.ts +1 -1
- package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.js.map +1 -1
- package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.js.map +1 -1
- package/dist/custom-field-types/text-array/text-array.definition-validation.d.ts +1 -1
- package/dist/custom-field-types/text-array/text-array.definition-validation.js +3 -3
- package/dist/custom-field-types/text-array/text-array.definition-validation.js.map +1 -1
- package/dist/custom-field-types/text-array/text-array.dto.d.ts +1 -1
- package/dist/custom-field-types/text-array/text-array.dto.js.map +1 -1
- package/dist/custom-field-types/text-array/text-array.rules.d.ts +2 -2
- package/dist/custom-field-types/text-array/text-array.value.d.ts +2 -2
- package/dist/custom-field-types/timestamp/index.d.ts +6 -6
- package/dist/custom-field-types/timestamp/index.js +6 -6
- package/dist/custom-field-types/timestamp/index.js.map +1 -1
- package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.js.map +1 -1
- package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.d.ts +1 -1
- package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.js.map +1 -1
- package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.unit.test.js.map +1 -1
- package/dist/custom-field-types/timestamp/timestamp.definition-validation.d.ts +1 -1
- package/dist/custom-field-types/timestamp/timestamp.definition-validation.js +3 -3
- package/dist/custom-field-types/timestamp/timestamp.definition-validation.js.map +1 -1
- package/dist/custom-field-types/timestamp/timestamp.dto.d.ts +1 -1
- package/dist/custom-field-types/timestamp/timestamp.dto.js.map +1 -1
- package/dist/custom-field-types/timestamp/timestamp.rules.d.ts +2 -2
- package/dist/custom-field-types/timestamp/timestamp.value.d.ts +2 -2
- package/dist/custom-field-value.d.ts +3 -3
- package/dist/dto/base-custom-field-value.dto.d.ts +3 -3
- package/dist/dto/base-custom-field-value.dto.js.map +1 -1
- package/dist/dto/custom-field-value.dto.d.ts +8 -5
- package/dist/dto/custom-field-value.dto.js +7 -3
- package/dist/dto/custom-field-value.dto.js.map +1 -1
- package/dist/dto/custom-field-value.dto.unit.test.js +43 -1
- package/dist/dto/custom-field-value.dto.unit.test.js.map +1 -1
- package/dist/enum/custom-field-type.enum.d.ts +4 -3
- package/dist/enum/custom-field-type.enum.js +1 -0
- package/dist/enum/custom-field-type.enum.js.map +1 -1
- package/dist/factory/custom-field-definition.factory.d.ts +5 -5
- package/dist/factory/custom-field-definition.factory.js +6 -1
- package/dist/factory/custom-field-definition.factory.js.map +1 -1
- package/dist/factory/custom-field-value.factory.d.ts +1 -1
- package/dist/index.d.ts +23 -21
- package/dist/index.js +20 -19
- package/dist/index.js.map +1 -1
- package/dist/repositories/custom-field-definitions.repository.integration.test.js +1 -1
- package/dist/repositories/custom-field-definitions.repository.integration.test.js.map +1 -1
- package/dist/repositories/index.d.ts +2 -2
- package/dist/repositories/index.js +2 -2
- package/dist/repositories/index.js.map +1 -1
- package/dist/responses/custom-field-definition.response.d.ts +2 -2
- package/dist/responses/custom-field-definition.response.js +4 -3
- package/dist/responses/custom-field-definition.response.js.map +1 -1
- package/dist/tests/test-setup.d.ts +1 -1
- package/dist/tests/test-setup.js +1 -1
- package/dist/tests/test-setup.js.map +1 -1
- package/dist/typeorm/custom-field-choice.column.js +2 -2
- package/dist/typeorm/custom-field-choice.column.js.map +1 -1
- package/dist/typeorm/custom-field-definition.entity.d.ts +6 -6
- package/dist/typeorm/custom-field-definition.entity.js +5 -5
- package/dist/typeorm/custom-field-definition.entity.js.map +1 -1
- package/dist/typeorm/custom-field-value.column.d.ts +2 -2
- package/dist/typeorm/custom-field-value.column.js +4 -2
- package/dist/typeorm/custom-field-value.column.js.map +1 -1
- package/dist/validators/custom-field-value.validator.d.ts +2 -2
- package/dist/validators/custom-field-value.validator.js +5 -1
- package/dist/validators/custom-field-value.validator.js.map +1 -1
- package/dist/validators/custom-field-value.validator.unit.test.js.map +1 -1
- package/package.json +8 -8
- package/skills/getting-started/SKILL.md +70 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CustomFieldDefinitionFieldsByType } from '#src/custom-field-definition.js';
|
|
2
|
-
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
2
|
+
import type { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
3
|
type NumberCustomFieldDefinition = CustomFieldDefinitionFieldsByType<CustomFieldType.NUMBER>;
|
|
4
4
|
export declare function validateNumberCustomFieldValue(definition: NumberCustomFieldDefinition, value: number): void;
|
|
5
5
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ResolvedCustomFieldDefinitionFields } from '#src/custom-field-definition.js';
|
|
2
|
-
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
2
|
+
import type { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
3
|
type NumberCustomFieldDefinition = Extract<ResolvedCustomFieldDefinitionFields, {
|
|
4
4
|
type: CustomFieldType.NUMBER;
|
|
5
5
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseCustomFieldValueDto } from '#src/dto/base-custom-field-value.dto.js';
|
|
2
2
|
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
|
-
import { NumberCustomFieldValue } from '#src/custom-field-types/number/number.value.js';
|
|
3
|
+
import type { NumberCustomFieldValue } from '#src/custom-field-types/number/number.value.js';
|
|
4
4
|
export declare class NumberCustomFieldValueDto extends BaseCustomFieldValueDto {
|
|
5
5
|
type: CustomFieldType.NUMBER;
|
|
6
6
|
value: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
2
|
-
import type { NumberCustomFieldTypeContract } from '
|
|
1
|
+
import type { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
2
|
+
import type { NumberCustomFieldTypeContract } from '#src/custom-field-types/number/number.contract.js';
|
|
3
3
|
export type NumberCustomFieldRules = {
|
|
4
4
|
type: CustomFieldType.NUMBER;
|
|
5
5
|
} & NumberCustomFieldTypeContract['rules'];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseCustomFieldValue } from '#src/custom-field-value.js';
|
|
2
|
-
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
|
-
import type { NumberCustomFieldTypeContract } from '
|
|
2
|
+
import type { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
|
+
import type { NumberCustomFieldTypeContract } from '#src/custom-field-types/number/number.contract.js';
|
|
4
4
|
export type NumberCustomFieldValue = BaseCustomFieldValue<CustomFieldType.NUMBER, NumberCustomFieldTypeContract['value']>;
|
|
5
5
|
export type NumberCustomFieldColumnValue = BaseCustomFieldValue<CustomFieldType.NUMBER, NumberCustomFieldTypeContract['columnValue']>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from '#src/custom-field-types/progress/progress.color.js';
|
|
2
|
+
export * from '#src/custom-field-types/progress/progress.contract.js';
|
|
3
|
+
export * from '#src/custom-field-types/progress/progress.definition-validation.js';
|
|
4
|
+
export * from '#src/custom-field-types/progress/progress.dto.js';
|
|
5
|
+
export * from '#src/custom-field-types/progress/progress.rules.js';
|
|
6
|
+
export * from '#src/custom-field-types/progress/progress.custom-field-value.validator.js';
|
|
7
|
+
export * from '#src/custom-field-types/progress/progress.value.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from '#src/custom-field-types/progress/progress.color.js';
|
|
2
|
+
export * from '#src/custom-field-types/progress/progress.contract.js';
|
|
3
|
+
export * from '#src/custom-field-types/progress/progress.definition-validation.js';
|
|
4
|
+
export * from '#src/custom-field-types/progress/progress.dto.js';
|
|
5
|
+
export * from '#src/custom-field-types/progress/progress.rules.js';
|
|
6
|
+
export * from '#src/custom-field-types/progress/progress.custom-field-value.validator.js';
|
|
7
|
+
export * from '#src/custom-field-types/progress/progress.value.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/custom-field-types/progress/index.ts"],"names":[],"mappings":"AAAA,cAAc,oDAAoD,CAAA;AAClE,cAAc,uDAAuD,CAAA;AACrE,cAAc,oEAAoE,CAAA;AAClF,cAAc,kDAAkD,CAAA;AAChE,cAAc,oDAAoD,CAAA;AAClE,cAAc,2EAA2E,CAAA;AACzF,cAAc,oDAAoD,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare enum ProgressCustomFieldColor {
|
|
2
|
+
MOSS = "moss",
|
|
3
|
+
GREEN_LIGHT = "green-light",
|
|
4
|
+
GREEN = "green",
|
|
5
|
+
TEAL = "teal",
|
|
6
|
+
CYAN = "cyan",
|
|
7
|
+
BLUE_LIGHT = "blue-light",
|
|
8
|
+
BLUE = "blue",
|
|
9
|
+
BLUE_DARK = "blue-dark",
|
|
10
|
+
INDIGO = "indigo",
|
|
11
|
+
VIOLET = "violet",
|
|
12
|
+
PURPLE = "purple",
|
|
13
|
+
FUCHSIA = "fuchsia",
|
|
14
|
+
PINK = "pink",
|
|
15
|
+
ROSE = "rose",
|
|
16
|
+
ORANGE_DARK = "orange-dark",
|
|
17
|
+
ORANGE = "orange",
|
|
18
|
+
YELLOW = "yellow",
|
|
19
|
+
ERROR = "error",
|
|
20
|
+
WARNING = "warning",
|
|
21
|
+
SUCCESS = "success",
|
|
22
|
+
INFO = "info",
|
|
23
|
+
BRAND = "brand",
|
|
24
|
+
NEUTRAL = "neutral"
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export var ProgressCustomFieldColor;
|
|
2
|
+
(function (ProgressCustomFieldColor) {
|
|
3
|
+
ProgressCustomFieldColor["MOSS"] = "moss";
|
|
4
|
+
ProgressCustomFieldColor["GREEN_LIGHT"] = "green-light";
|
|
5
|
+
ProgressCustomFieldColor["GREEN"] = "green";
|
|
6
|
+
ProgressCustomFieldColor["TEAL"] = "teal";
|
|
7
|
+
ProgressCustomFieldColor["CYAN"] = "cyan";
|
|
8
|
+
ProgressCustomFieldColor["BLUE_LIGHT"] = "blue-light";
|
|
9
|
+
ProgressCustomFieldColor["BLUE"] = "blue";
|
|
10
|
+
ProgressCustomFieldColor["BLUE_DARK"] = "blue-dark";
|
|
11
|
+
ProgressCustomFieldColor["INDIGO"] = "indigo";
|
|
12
|
+
ProgressCustomFieldColor["VIOLET"] = "violet";
|
|
13
|
+
ProgressCustomFieldColor["PURPLE"] = "purple";
|
|
14
|
+
ProgressCustomFieldColor["FUCHSIA"] = "fuchsia";
|
|
15
|
+
ProgressCustomFieldColor["PINK"] = "pink";
|
|
16
|
+
ProgressCustomFieldColor["ROSE"] = "rose";
|
|
17
|
+
ProgressCustomFieldColor["ORANGE_DARK"] = "orange-dark";
|
|
18
|
+
ProgressCustomFieldColor["ORANGE"] = "orange";
|
|
19
|
+
ProgressCustomFieldColor["YELLOW"] = "yellow";
|
|
20
|
+
ProgressCustomFieldColor["ERROR"] = "error";
|
|
21
|
+
ProgressCustomFieldColor["WARNING"] = "warning";
|
|
22
|
+
ProgressCustomFieldColor["SUCCESS"] = "success";
|
|
23
|
+
ProgressCustomFieldColor["INFO"] = "info";
|
|
24
|
+
ProgressCustomFieldColor["BRAND"] = "brand";
|
|
25
|
+
ProgressCustomFieldColor["NEUTRAL"] = "neutral";
|
|
26
|
+
})(ProgressCustomFieldColor || (ProgressCustomFieldColor = {}));
|
|
27
|
+
//# sourceMappingURL=progress.color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.color.js","sourceRoot":"","sources":["../../../lib/custom-field-types/progress/progress.color.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,wBAwBX;AAxBD,WAAY,wBAAwB;IAClC,yCAAa,CAAA;IACb,uDAA2B,CAAA;IAC3B,2CAAe,CAAA;IACf,yCAAa,CAAA;IACb,yCAAa,CAAA;IACb,qDAAyB,CAAA;IACzB,yCAAa,CAAA;IACb,mDAAuB,CAAA;IACvB,6CAAiB,CAAA;IACjB,6CAAiB,CAAA;IACjB,6CAAiB,CAAA;IACjB,+CAAmB,CAAA;IACnB,yCAAa,CAAA;IACb,yCAAa,CAAA;IACb,uDAA2B,CAAA;IAC3B,6CAAiB,CAAA;IACjB,6CAAiB,CAAA;IACjB,2CAAe,CAAA;IACf,+CAAmB,CAAA;IACnB,+CAAmB,CAAA;IACnB,yCAAa,CAAA;IACb,2CAAe,CAAA;IACf,+CAAmB,CAAA;AACrB,CAAC,EAxBW,wBAAwB,KAAxB,wBAAwB,QAwBnC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DefineContract } from '#src/custom-field-type-contract.js';
|
|
2
|
+
import type { ProgressCustomFieldColor } from '#src/custom-field-types/progress/progress.color.js';
|
|
3
|
+
export interface ProgressCustomFieldSegment {
|
|
4
|
+
key: string;
|
|
5
|
+
amount: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ProgressCustomFieldData {
|
|
8
|
+
total?: number;
|
|
9
|
+
segments: ProgressCustomFieldSegment[];
|
|
10
|
+
}
|
|
11
|
+
export type ProgressCustomFieldTypeContract = DefineContract<{
|
|
12
|
+
value: ProgressCustomFieldData;
|
|
13
|
+
columnValue: ProgressCustomFieldData;
|
|
14
|
+
rules: {
|
|
15
|
+
icon?: string;
|
|
16
|
+
colors: Record<string, ProgressCustomFieldColor>;
|
|
17
|
+
};
|
|
18
|
+
rulesMode: 'required';
|
|
19
|
+
choicesMode: 'required';
|
|
20
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.contract.js","sourceRoot":"","sources":["../../../lib/custom-field-types/progress/progress.contract.ts"],"names":[],"mappings":""}
|
package/dist/custom-field-types/progress/progress.custom-field-definition.factory.unit.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/custom-field-types/progress/progress.custom-field-definition.factory.unit.test.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import { expect } from 'expect';
|
|
3
|
+
import { LocalizedString } from '@wisemen/localized-string';
|
|
4
|
+
import { CustomFieldDefinitionError } from '#src/errors/custom-field-definition.error.js';
|
|
5
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
6
|
+
import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
|
|
7
|
+
import { ProgressCustomFieldColor } from '#src/custom-field-types/progress/progress.color.js';
|
|
8
|
+
const choices = [
|
|
9
|
+
{ value: 'completed', order: 1, label: new LocalizedString([{ locale: 'en', value: 'Completed' }]) },
|
|
10
|
+
{ value: 'in_progress', order: 2, label: new LocalizedString([{ locale: 'en', value: 'In progress' }]) }
|
|
11
|
+
];
|
|
12
|
+
const rules = {
|
|
13
|
+
icon: 'tasks',
|
|
14
|
+
colors: {
|
|
15
|
+
completed: ProgressCustomFieldColor.SUCCESS,
|
|
16
|
+
in_progress: ProgressCustomFieldColor.WARNING
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function progressDefinition(overrides = {}) {
|
|
20
|
+
return customFieldDefinition(CustomFieldType.PROGRESS, {
|
|
21
|
+
tenantUuid: null,
|
|
22
|
+
entityType: 'project',
|
|
23
|
+
key: 'tasks',
|
|
24
|
+
label: new LocalizedString([{ locale: 'en', value: 'Tasks' }]),
|
|
25
|
+
description: null,
|
|
26
|
+
isRequired: false,
|
|
27
|
+
choices: overrides.choices ?? choices,
|
|
28
|
+
rules: overrides.rules ?? rules
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
describe('progress customFieldDefinition', () => {
|
|
32
|
+
it('creates a progress custom field definition', () => {
|
|
33
|
+
const definition = progressDefinition();
|
|
34
|
+
expect(definition.type).toBe(CustomFieldType.PROGRESS);
|
|
35
|
+
expect(definition.choices).toEqual(choices);
|
|
36
|
+
expect(definition.rules).toEqual({ type: CustomFieldType.PROGRESS, ...rules });
|
|
37
|
+
});
|
|
38
|
+
it('creates a progress custom field definition without an icon', () => {
|
|
39
|
+
const definition = progressDefinition({ rules: { colors: rules.colors } });
|
|
40
|
+
expect(definition.rules).toEqual({ type: CustomFieldType.PROGRESS, colors: rules.colors });
|
|
41
|
+
});
|
|
42
|
+
it('rejects a progress field without choices', () => {
|
|
43
|
+
expect(() => progressDefinition({ choices: [], rules: { icon: 'tasks', colors: {} } }))
|
|
44
|
+
.toThrow(new CustomFieldDefinitionError('Progress custom field must define at least one choice'));
|
|
45
|
+
});
|
|
46
|
+
it('rejects a progress field with duplicate choice values', () => {
|
|
47
|
+
expect(() => progressDefinition({ choices: [choices[0], { ...choices[1], value: 'completed' }] }))
|
|
48
|
+
.toThrow(new CustomFieldDefinitionError('Custom field choice value must be unique'));
|
|
49
|
+
});
|
|
50
|
+
it('rejects a progress field with an empty icon', () => {
|
|
51
|
+
expect(() => progressDefinition({ rules: { ...rules, icon: ' ' } }))
|
|
52
|
+
.toThrow(new CustomFieldDefinitionError('Progress custom field icon can not be empty'));
|
|
53
|
+
});
|
|
54
|
+
it('rejects a progress field without a color for every choice', () => {
|
|
55
|
+
expect(() => progressDefinition({ rules: { ...rules, colors: { completed: ProgressCustomFieldColor.SUCCESS } } }))
|
|
56
|
+
.toThrow(new CustomFieldDefinitionError('Progress custom field must define a color for every choice'));
|
|
57
|
+
});
|
|
58
|
+
it('rejects a progress field with a color for an unknown choice', () => {
|
|
59
|
+
expect(() => progressDefinition({ rules: { ...rules, colors: { ...rules.colors, blocked: ProgressCustomFieldColor.ERROR } } }))
|
|
60
|
+
.toThrow(new CustomFieldDefinitionError('Progress custom field colors can only be defined for choices'));
|
|
61
|
+
});
|
|
62
|
+
it('rejects a progress field with an unsupported color', () => {
|
|
63
|
+
expect(() => progressDefinition({ rules: { ...rules, colors: { ...rules.colors, completed: 'lime' } } }))
|
|
64
|
+
.toThrow(new CustomFieldDefinitionError('Progress custom field color must be a supported color'));
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=progress.custom-field-definition.factory.unit.test.js.map
|
package/dist/custom-field-types/progress/progress.custom-field-definition.factory.unit.test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.custom-field-definition.factory.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/progress/progress.custom-field-definition.factory.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAA;AAI7F,MAAM,OAAO,GAAwB;IACnC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE;IACpG,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC,EAAE;CACzG,CAAA;AAED,MAAM,KAAK,GAA6C;IACtD,IAAI,EAAE,OAAO;IACb,MAAM,EAAE;QACN,SAAS,EAAE,wBAAwB,CAAC,OAAO;QAC3C,WAAW,EAAE,wBAAwB,CAAC,OAAO;KAC9C;CACF,CAAA;AAED,SAAS,kBAAkB,CACzB,YAAiG,EAAE;IAEnG,OAAO,qBAAqB,CAAC,eAAe,CAAC,QAAQ,EAAE;QACrD,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,SAAS;QACrB,GAAG,EAAE,OAAO;QACZ,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE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K,EAAE,EAAE,EAAE,CAAC,CAAC;aAC5H,OAAO,CAAC,IAAI,0BAA0B,CAAC,8DAA8D,CAAC,CAAC,CAAA;IAC5G,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,MAAkC,EAAE,EAAE,EAAE,CAAC,CAAC;aAClI,OAAO,CAAC,IAAI,0BAA0B,CAAC,uDAAuD,CAAC,CAAC,CAAA;IACrG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CustomFieldDefinitionFieldsByType } from '#src/custom-field-definition.js';
|
|
2
|
+
import type { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
|
+
import type { ProgressCustomFieldData } from '#src/custom-field-types/progress/progress.contract.js';
|
|
4
|
+
type ProgressCustomFieldDefinition = CustomFieldDefinitionFieldsByType<CustomFieldType.PROGRESS>;
|
|
5
|
+
export declare function validateProgressCustomFieldValue(definition: ProgressCustomFieldDefinition, value: ProgressCustomFieldData): void;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
|
|
2
|
+
export function validateProgressCustomFieldValue(definition, value) {
|
|
3
|
+
if (definition.choices === null) {
|
|
4
|
+
throw new CustomFieldValueValidationError('Progress custom field definition must define choices');
|
|
5
|
+
}
|
|
6
|
+
const seenKeys = new Set();
|
|
7
|
+
let sum = 0;
|
|
8
|
+
for (const segment of value.segments) {
|
|
9
|
+
if (!definition.choices.some(choice => choice.value === segment.key)) {
|
|
10
|
+
throw new CustomFieldValueValidationError('Progress custom field value keys must be defined choices');
|
|
11
|
+
}
|
|
12
|
+
if (seenKeys.has(segment.key)) {
|
|
13
|
+
throw new CustomFieldValueValidationError('Progress custom field value can not contain duplicate keys');
|
|
14
|
+
}
|
|
15
|
+
if (!Number.isFinite(segment.amount)) {
|
|
16
|
+
throw new CustomFieldValueValidationError('Progress custom field value amount must be a finite number');
|
|
17
|
+
}
|
|
18
|
+
if (segment.amount < 0) {
|
|
19
|
+
throw new CustomFieldValueValidationError('Progress custom field value amount can not be negative');
|
|
20
|
+
}
|
|
21
|
+
seenKeys.add(segment.key);
|
|
22
|
+
sum += segment.amount;
|
|
23
|
+
}
|
|
24
|
+
if (value.total === undefined) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!Number.isFinite(value.total) || value.total <= 0) {
|
|
28
|
+
throw new CustomFieldValueValidationError('Progress custom field value total must be a finite number greater than zero');
|
|
29
|
+
}
|
|
30
|
+
if (sum > value.total) {
|
|
31
|
+
throw new CustomFieldValueValidationError('Progress custom field value amounts can not exceed the total');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=progress.custom-field-value.validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.custom-field-value.validator.js","sourceRoot":"","sources":["../../../lib/custom-field-types/progress/progress.custom-field-value.validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AAMxG,MAAM,UAAU,gCAAgC,CAC9C,UAAyC,EACzC,KAA8B;IAE9B,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,+BAA+B,CAAC,sDAAsD,CAAC,CAAA;IACnG,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAA;IAClC,IAAI,GAAG,GAAG,CAAC,CAAA;IAEX,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,+BAA+B,CAAC,0DAA0D,CAAC,CAAA;QACvG,CAAC;QAED,IAAI,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,+BAA+B,CAAC,4DAA4D,CAAC,CAAA;QACzG,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,+BAA+B,CAAC,4DAA4D,CAAC,CAAA;QACzG,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,+BAA+B,CAAC,wDAAwD,CAAC,CAAA;QACrG,CAAC;QAED,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACzB,GAAG,IAAI,OAAO,CAAC,MAAM,CAAA;IACvB,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAM;IACR,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,+BAA+B,CAAC,6EAA6E,CAAC,CAAA;IAC1H,CAAC;IAED,IAAI,GAAG,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;QACtB,MAAM,IAAI,+BAA+B,CAAC,8DAA8D,CAAC,CAAA;IAC3G,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import { expect } from 'expect';
|
|
3
|
+
import { LocalizedString } from '@wisemen/localized-string';
|
|
4
|
+
import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
|
|
5
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
6
|
+
import { validateCustomFieldValue } from '#src/validators/custom-field-value.validator.js';
|
|
7
|
+
import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
|
|
8
|
+
import { ProgressCustomFieldColor } from '#src/custom-field-types/progress/progress.color.js';
|
|
9
|
+
const definition = customFieldDefinition(CustomFieldType.PROGRESS, {
|
|
10
|
+
tenantUuid: null,
|
|
11
|
+
entityType: 'project',
|
|
12
|
+
key: 'tasks',
|
|
13
|
+
label: new LocalizedString([{ locale: 'en', value: 'Tasks' }]),
|
|
14
|
+
description: null,
|
|
15
|
+
isRequired: false,
|
|
16
|
+
choices: [
|
|
17
|
+
{ value: 'completed', order: 1, label: new LocalizedString([{ locale: 'en', value: 'Completed' }]) },
|
|
18
|
+
{ value: 'in_progress', order: 2, label: new LocalizedString([{ locale: 'en', value: 'In progress' }]) }
|
|
19
|
+
],
|
|
20
|
+
rules: {
|
|
21
|
+
icon: 'tasks',
|
|
22
|
+
colors: {
|
|
23
|
+
completed: ProgressCustomFieldColor.SUCCESS,
|
|
24
|
+
in_progress: ProgressCustomFieldColor.WARNING
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
function validate(value) {
|
|
29
|
+
validateCustomFieldValue(definition, {
|
|
30
|
+
definitionUuid: definition.uuid,
|
|
31
|
+
type: CustomFieldType.PROGRESS,
|
|
32
|
+
value
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
describe('progress validateCustomFieldValue', () => {
|
|
36
|
+
it('accepts amounts for defined choices', () => {
|
|
37
|
+
expect(() => validate({
|
|
38
|
+
segments: [
|
|
39
|
+
{ key: 'completed', amount: 2 },
|
|
40
|
+
{ key: 'in_progress', amount: 3 }
|
|
41
|
+
]
|
|
42
|
+
})).not.toThrow();
|
|
43
|
+
});
|
|
44
|
+
it('accepts a decimal amount', () => {
|
|
45
|
+
expect(() => validate({ segments: [{ key: 'completed', amount: 0.42 }] })).not.toThrow();
|
|
46
|
+
});
|
|
47
|
+
it('accepts an empty value', () => {
|
|
48
|
+
expect(() => validate({ segments: [] })).not.toThrow();
|
|
49
|
+
});
|
|
50
|
+
it('rejects a key that is not a defined choice', () => {
|
|
51
|
+
expect(() => validate({ segments: [{ key: 'blocked', amount: 1 }] }))
|
|
52
|
+
.toThrow(new CustomFieldValueValidationError('Progress custom field value keys must be defined choices'));
|
|
53
|
+
});
|
|
54
|
+
it('rejects duplicate keys', () => {
|
|
55
|
+
expect(() => validate({
|
|
56
|
+
segments: [
|
|
57
|
+
{ key: 'completed', amount: 1 },
|
|
58
|
+
{ key: 'completed', amount: 2 }
|
|
59
|
+
]
|
|
60
|
+
})).toThrow(new CustomFieldValueValidationError('Progress custom field value can not contain duplicate keys'));
|
|
61
|
+
});
|
|
62
|
+
it('rejects a negative amount', () => {
|
|
63
|
+
expect(() => validate({ segments: [{ key: 'completed', amount: -1 }] }))
|
|
64
|
+
.toThrow(new CustomFieldValueValidationError('Progress custom field value amount can not be negative'));
|
|
65
|
+
});
|
|
66
|
+
it('rejects a non-finite amount', () => {
|
|
67
|
+
expect(() => validate({ segments: [{ key: 'completed', amount: Number.POSITIVE_INFINITY }] }))
|
|
68
|
+
.toThrow(new CustomFieldValueValidationError('Progress custom field value amount must be a finite number'));
|
|
69
|
+
});
|
|
70
|
+
it('accepts amounts below the total', () => {
|
|
71
|
+
expect(() => validate({ total: 100, segments: [{ key: 'completed', amount: 20 }] })).not.toThrow();
|
|
72
|
+
});
|
|
73
|
+
it('rejects amounts that exceed the total', () => {
|
|
74
|
+
expect(() => validate({
|
|
75
|
+
total: 4,
|
|
76
|
+
segments: [
|
|
77
|
+
{ key: 'completed', amount: 2 },
|
|
78
|
+
{ key: 'in_progress', amount: 3 }
|
|
79
|
+
]
|
|
80
|
+
})).toThrow(new CustomFieldValueValidationError('Progress custom field value amounts can not exceed the total'));
|
|
81
|
+
});
|
|
82
|
+
it('rejects a total of zero', () => {
|
|
83
|
+
expect(() => validate({ total: 0, segments: [] }))
|
|
84
|
+
.toThrow(new CustomFieldValueValidationError('Progress custom field value total must be a finite number greater than zero'));
|
|
85
|
+
});
|
|
86
|
+
it('rejects a non-finite total', () => {
|
|
87
|
+
expect(() => validate({ total: Number.POSITIVE_INFINITY, segments: [] }))
|
|
88
|
+
.toThrow(new CustomFieldValueValidationError('Progress custom field value total must be a finite number greater than zero'));
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=progress.custom-field-value.validator.unit.test.js.map
|
package/dist/custom-field-types/progress/progress.custom-field-value.validator.unit.test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.custom-field-value.validator.unit.test.js","sourceRoot":"","sources":["../../../lib/custom-field-types/progress/progress.custom-field-value.validator.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,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAC1F,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AACxG,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAA;AAG7F,MAAM,UAAU,GAAG,qBAAqB,CAAC,eAAe,CAAC,QAAQ,EAAE;IACjE,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,SAAS;IACrB,GAAG,EAAE,OAAO;IACZ,KAAK,EAAE,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,IAA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+B,CAAC,6EAA6E,CAAC,CAAC,CAAA;IAChI,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,iBAAiB,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;aACtE,OAAO,CAAC,IAAI,+BAA+B,CAAC,6EAA6E,CAAC,CAAC,CAAA;IAChI,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResolvedCustomFieldDefinitionFields } from '#src/custom-field-definition.js';
|
|
2
|
+
import type { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
|
+
type ProgressCustomFieldDefinition = Extract<ResolvedCustomFieldDefinitionFields, {
|
|
4
|
+
type: CustomFieldType.PROGRESS;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function validateProgressCustomFieldDefinition(definition: ProgressCustomFieldDefinition): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CustomFieldDefinitionError } from '#src/errors/custom-field-definition.error.js';
|
|
2
|
+
import { ProgressCustomFieldColor } from '#src/custom-field-types/progress/progress.color.js';
|
|
3
|
+
export function validateProgressCustomFieldDefinition(definition) {
|
|
4
|
+
validateProgressChoices(definition.choices);
|
|
5
|
+
const rules = definition.rules;
|
|
6
|
+
if (rules === null) {
|
|
7
|
+
throw new CustomFieldDefinitionError('Progress custom field rules are required');
|
|
8
|
+
}
|
|
9
|
+
if (rules.icon !== undefined && rules.icon.trim() === '') {
|
|
10
|
+
throw new CustomFieldDefinitionError('Progress custom field icon can not be empty');
|
|
11
|
+
}
|
|
12
|
+
const choiceValues = new Set(definition.choices.map(choice => choice.value));
|
|
13
|
+
for (const [key, color] of Object.entries(rules.colors)) {
|
|
14
|
+
if (!choiceValues.has(key)) {
|
|
15
|
+
throw new CustomFieldDefinitionError('Progress custom field colors can only be defined for choices');
|
|
16
|
+
}
|
|
17
|
+
if (!Object.values(ProgressCustomFieldColor).includes(color)) {
|
|
18
|
+
throw new CustomFieldDefinitionError('Progress custom field color must be a supported color');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (const choice of definition.choices) {
|
|
22
|
+
if (rules.colors[choice.value] === undefined) {
|
|
23
|
+
throw new CustomFieldDefinitionError('Progress custom field must define a color for every choice');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function validateProgressChoices(choices) {
|
|
28
|
+
if (choices.length === 0) {
|
|
29
|
+
throw new CustomFieldDefinitionError('Progress custom field must define at least one choice');
|
|
30
|
+
}
|
|
31
|
+
const choiceValues = new Set();
|
|
32
|
+
const choiceOrders = new Set();
|
|
33
|
+
for (const choice of choices) {
|
|
34
|
+
if (choiceValues.has(choice.value)) {
|
|
35
|
+
throw new CustomFieldDefinitionError('Custom field choice value must be unique');
|
|
36
|
+
}
|
|
37
|
+
if (choiceOrders.has(choice.order)) {
|
|
38
|
+
throw new CustomFieldDefinitionError('Custom field choice order must be unique');
|
|
39
|
+
}
|
|
40
|
+
choiceValues.add(choice.value);
|
|
41
|
+
choiceOrders.add(choice.order);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=progress.definition-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.definition-validation.js","sourceRoot":"","sources":["../../../lib/custom-field-types/progress/progress.definition-validation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AAEzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAA;AAI7F,MAAM,UAAU,qCAAqC,CAAC,UAAyC;IAC7F,uBAAuB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAE3C,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAA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ED,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAA;IACtC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAA;IAEtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,0BAA0B,CAAC,0CAA0C,CAAC,CAAA;QAClF,CAAC;QAED,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,0BAA0B,CAAC,0CAA0C,CAAC,CAAA;QAClF,CAAC;QAED,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC9B,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 type { ProgressCustomFieldData, ProgressCustomFieldSegment } from '#src/custom-field-types/progress/progress.contract.js';
|
|
4
|
+
import type { ProgressCustomFieldValue } from '#src/custom-field-types/progress/progress.value.js';
|
|
5
|
+
export declare class ProgressCustomFieldSegmentDto {
|
|
6
|
+
key: string;
|
|
7
|
+
amount: number;
|
|
8
|
+
parse(): ProgressCustomFieldSegment;
|
|
9
|
+
static from(segment: ProgressCustomFieldSegment): ProgressCustomFieldSegmentDto;
|
|
10
|
+
}
|
|
11
|
+
export declare class ProgressCustomFieldDataDto {
|
|
12
|
+
total?: number;
|
|
13
|
+
segments: ProgressCustomFieldSegmentDto[];
|
|
14
|
+
parse(): ProgressCustomFieldData;
|
|
15
|
+
static from(data: ProgressCustomFieldData): ProgressCustomFieldDataDto;
|
|
16
|
+
}
|
|
17
|
+
export declare class ProgressCustomFieldValueDto extends BaseCustomFieldValueDto {
|
|
18
|
+
type: CustomFieldType.PROGRESS;
|
|
19
|
+
value: ProgressCustomFieldDataDto;
|
|
20
|
+
parse(): ProgressCustomFieldValue;
|
|
21
|
+
static from(customFieldValue: ProgressCustomFieldValue): ProgressCustomFieldValueDto;
|
|
22
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
11
|
+
import { Type } from 'class-transformer';
|
|
12
|
+
import { IsArray, IsEnum, IsNotEmpty, IsNumber, IsObject, IsOptional, IsPositive, IsString, Min, ValidateNested } from 'class-validator';
|
|
13
|
+
import { BaseCustomFieldValueDto, createCustomFieldValueDto } from '#src/dto/base-custom-field-value.dto.js';
|
|
14
|
+
import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
15
|
+
export class ProgressCustomFieldSegmentDto {
|
|
16
|
+
key;
|
|
17
|
+
amount;
|
|
18
|
+
parse() {
|
|
19
|
+
return {
|
|
20
|
+
key: this.key,
|
|
21
|
+
amount: this.amount
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
static from(segment) {
|
|
25
|
+
const dto = new ProgressCustomFieldSegmentDto();
|
|
26
|
+
dto.key = segment.key;
|
|
27
|
+
dto.amount = segment.amount;
|
|
28
|
+
return dto;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
__decorate([
|
|
32
|
+
ApiProperty({ type: String }),
|
|
33
|
+
IsString(),
|
|
34
|
+
IsNotEmpty(),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], ProgressCustomFieldSegmentDto.prototype, "key", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
ApiProperty({ type: Number, minimum: 0 }),
|
|
39
|
+
IsNumber({ allowNaN: false, allowInfinity: false }),
|
|
40
|
+
Min(0),
|
|
41
|
+
__metadata("design:type", Number)
|
|
42
|
+
], ProgressCustomFieldSegmentDto.prototype, "amount", void 0);
|
|
43
|
+
export class ProgressCustomFieldDataDto {
|
|
44
|
+
total;
|
|
45
|
+
segments;
|
|
46
|
+
parse() {
|
|
47
|
+
return {
|
|
48
|
+
total: this.total,
|
|
49
|
+
segments: this.segments.map(segment => segment.parse())
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static from(data) {
|
|
53
|
+
const dto = new ProgressCustomFieldDataDto();
|
|
54
|
+
dto.total = data.total;
|
|
55
|
+
dto.segments = data.segments.map(segment => ProgressCustomFieldSegmentDto.from(segment));
|
|
56
|
+
return dto;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
__decorate([
|
|
60
|
+
ApiProperty({ type: Number, required: false, exclusiveMinimum: true, minimum: 0 }),
|
|
61
|
+
IsOptional(),
|
|
62
|
+
IsNumber({ allowNaN: false, allowInfinity: false }),
|
|
63
|
+
IsPositive(),
|
|
64
|
+
__metadata("design:type", Number)
|
|
65
|
+
], ProgressCustomFieldDataDto.prototype, "total", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
ApiProperty({ type: ProgressCustomFieldSegmentDto, isArray: true }),
|
|
68
|
+
IsArray(),
|
|
69
|
+
ValidateNested({ each: true }),
|
|
70
|
+
Type(() => ProgressCustomFieldSegmentDto),
|
|
71
|
+
__metadata("design:type", Array)
|
|
72
|
+
], ProgressCustomFieldDataDto.prototype, "segments", void 0);
|
|
73
|
+
export class ProgressCustomFieldValueDto extends BaseCustomFieldValueDto {
|
|
74
|
+
value;
|
|
75
|
+
parse() {
|
|
76
|
+
return this.toCustomFieldValue(CustomFieldType.PROGRESS, this.value.parse());
|
|
77
|
+
}
|
|
78
|
+
static from(customFieldValue) {
|
|
79
|
+
return createCustomFieldValueDto(new ProgressCustomFieldValueDto(), CustomFieldType.PROGRESS, customFieldValue.definitionUuid, ProgressCustomFieldDataDto.from(customFieldValue.value));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
__decorate([
|
|
83
|
+
ApiProperty({ enum: [CustomFieldType.PROGRESS] }),
|
|
84
|
+
IsEnum([CustomFieldType.PROGRESS]),
|
|
85
|
+
__metadata("design:type", String)
|
|
86
|
+
], ProgressCustomFieldValueDto.prototype, "type", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
ApiProperty({ type: ProgressCustomFieldDataDto }),
|
|
89
|
+
IsObject(),
|
|
90
|
+
ValidateNested(),
|
|
91
|
+
Type(() => ProgressCustomFieldDataDto),
|
|
92
|
+
__metadata("design:type", ProgressCustomFieldDataDto)
|
|
93
|
+
], ProgressCustomFieldValueDto.prototype, "value", void 0);
|
|
94
|
+
//# sourceMappingURL=progress.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.dto.js","sourceRoot":"","sources":["../../../lib/custom-field-types/progress/progress.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,E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AAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;;yDACG;AAMtC;IAJC,WAAW,CAAC,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAAC;IACjD,QAAQ,EAAE;IACV,cAAc,EAAE;IAChB,IAAI,CAAC,GAAG,EAAE,CAAC,0BAA0B,CAAC;8BAChC,0BAA0B;0DAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
2
|
+
import type { ProgressCustomFieldTypeContract } from '#src/custom-field-types/progress/progress.contract.js';
|
|
3
|
+
export type ProgressCustomFieldRules = {
|
|
4
|
+
type: CustomFieldType.PROGRESS;
|
|
5
|
+
} & ProgressCustomFieldTypeContract['rules'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.rules.js","sourceRoot":"","sources":["../../../lib/custom-field-types/progress/progress.rules.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BaseCustomFieldValue } from '#src/custom-field-value.js';
|
|
2
|
+
import type { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
|
|
3
|
+
import type { ProgressCustomFieldTypeContract } from '#src/custom-field-types/progress/progress.contract.js';
|
|
4
|
+
export type ProgressCustomFieldValue = BaseCustomFieldValue<CustomFieldType.PROGRESS, ProgressCustomFieldTypeContract['value']>;
|
|
5
|
+
export type ProgressCustomFieldColumnValue = BaseCustomFieldValue<CustomFieldType.PROGRESS, ProgressCustomFieldTypeContract['columnValue']>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.value.js","sourceRoot":"","sources":["../../../lib/custom-field-types/progress/progress.value.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from '
|
|
3
|
-
export * from '
|
|
4
|
-
export * from '
|
|
5
|
-
export * from '
|
|
6
|
-
export * from '
|
|
7
|
-
export * from '
|
|
1
|
+
export * from '#src/custom-field-types/reference/reference.contract.js';
|
|
2
|
+
export * from '#src/custom-field-types/reference/reference.definition-validation.js';
|
|
3
|
+
export * from '#src/custom-field-types/reference/reference.dto.js';
|
|
4
|
+
export * from '#src/custom-field-types/reference/reference.format.js';
|
|
5
|
+
export * from '#src/custom-field-types/reference/reference.rules.js';
|
|
6
|
+
export * from '#src/custom-field-types/reference/reference.custom-field-value.validator.js';
|
|
7
|
+
export * from '#src/custom-field-types/reference/reference.value.js';
|