@aneuhold/core-ts-db-lib 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/documents/common/ApiKey.d.ts +2 -0
- package/lib/documents/common/ApiKey.d.ts.map +1 -1
- package/lib/documents/common/ApiKey.js +2 -0
- package/lib/documents/common/ApiKey.js.map +1 -1
- package/lib/documents/common/ApiKey.ts +2 -0
- package/lib/documents/common/User.d.ts +8 -0
- package/lib/documents/common/User.d.ts.map +1 -1
- package/lib/documents/common/User.js +8 -0
- package/lib/documents/common/User.js.map +1 -1
- package/lib/documents/common/User.ts +8 -0
- package/lib/documents/dashboard/Task.d.ts +3 -0
- package/lib/documents/dashboard/Task.d.ts.map +1 -1
- package/lib/documents/dashboard/Task.js +3 -0
- package/lib/documents/dashboard/Task.js.map +1 -1
- package/lib/documents/dashboard/Task.ts +3 -0
- package/lib/embedded-types/dashboard/task/FilterSettings.d.ts +12 -0
- package/lib/embedded-types/dashboard/task/FilterSettings.d.ts.map +1 -1
- package/lib/embedded-types/dashboard/task/FilterSettings.js +12 -0
- package/lib/embedded-types/dashboard/task/FilterSettings.js.map +1 -1
- package/lib/embedded-types/dashboard/task/FilterSettings.ts +12 -0
- package/lib/embedded-types/dashboard/task/RecurrenceInfo.d.ts +6 -0
- package/lib/embedded-types/dashboard/task/RecurrenceInfo.d.ts.map +1 -1
- package/lib/embedded-types/dashboard/task/RecurrenceInfo.js +7 -1
- package/lib/embedded-types/dashboard/task/RecurrenceInfo.js.map +1 -1
- package/lib/embedded-types/dashboard/task/RecurrenceInfo.ts +11 -2
- package/lib/embedded-types/dashboard/task/SortSettings.d.ts +18 -0
- package/lib/embedded-types/dashboard/task/SortSettings.d.ts.map +1 -1
- package/lib/embedded-types/dashboard/task/SortSettings.js +12 -0
- package/lib/embedded-types/dashboard/task/SortSettings.js.map +1 -1
- package/lib/embedded-types/dashboard/task/SortSettings.ts +18 -0
- package/lib/schemas/type-guards/commonTypeGuards.d.ts +30 -0
- package/lib/schemas/type-guards/commonTypeGuards.d.ts.map +1 -1
- package/lib/schemas/type-guards/commonTypeGuards.js +30 -0
- package/lib/schemas/type-guards/commonTypeGuards.js.map +1 -1
- package/lib/schemas/type-guards/commonTypeGuards.ts +30 -0
- package/lib/schemas/validators/ValidateUtil.d.ts +75 -0
- package/lib/schemas/validators/ValidateUtil.d.ts.map +1 -1
- package/lib/schemas/validators/ValidateUtil.js +75 -0
- package/lib/schemas/validators/ValidateUtil.js.map +1 -1
- package/lib/schemas/validators/ValidateUtil.ts +75 -0
- package/lib/services/dashboard/Task/TaskFilterService.d.ts +10 -4
- package/lib/services/dashboard/Task/TaskFilterService.d.ts.map +1 -1
- package/lib/services/dashboard/Task/TaskFilterService.js +10 -4
- package/lib/services/dashboard/Task/TaskFilterService.js.map +1 -1
- package/lib/services/dashboard/Task/TaskFilterService.ts +10 -4
- package/lib/services/dashboard/Task/TaskRecurrenceService.d.ts +14 -2
- package/lib/services/dashboard/Task/TaskRecurrenceService.d.ts.map +1 -1
- package/lib/services/dashboard/Task/TaskRecurrenceService.js +14 -2
- package/lib/services/dashboard/Task/TaskRecurrenceService.js.map +1 -1
- package/lib/services/dashboard/Task/TaskRecurrenceService.ts +18 -3
- package/lib/services/dashboard/Task/TaskService.d.ts +33 -4
- package/lib/services/dashboard/Task/TaskService.d.ts.map +1 -1
- package/lib/services/dashboard/Task/TaskService.js +33 -4
- package/lib/services/dashboard/Task/TaskService.js.map +1 -1
- package/lib/services/dashboard/Task/TaskService.spec.ts +31 -0
- package/lib/services/dashboard/Task/TaskService.ts +33 -4
- package/lib/services/dashboard/Task/TaskSortService.d.ts +44 -0
- package/lib/services/dashboard/Task/TaskSortService.d.ts.map +1 -1
- package/lib/services/dashboard/Task/TaskSortService.js +44 -0
- package/lib/services/dashboard/Task/TaskSortService.js.map +1 -1
- package/lib/services/dashboard/Task/TaskSortService.ts +47 -3
- package/package.json +2 -2
|
@@ -18,15 +18,70 @@ export default class Validate {
|
|
|
18
18
|
private errorsArray;
|
|
19
19
|
parentObject: IndexableObject;
|
|
20
20
|
constructor(parentObject: object, errorsArray: string[]);
|
|
21
|
+
/**
|
|
22
|
+
* Validates if the field is an optional string.
|
|
23
|
+
*
|
|
24
|
+
* @param fieldName - The name of the field to validate.
|
|
25
|
+
*/
|
|
21
26
|
optionalString(fieldName: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Validates if the field is an optional number.
|
|
29
|
+
*
|
|
30
|
+
* @param fieldName - The name of the field to validate.
|
|
31
|
+
*/
|
|
22
32
|
optionalNumber(fieldName: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Validates if the field is an optional boolean.
|
|
35
|
+
*
|
|
36
|
+
* @param fieldName - The name of the field to validate.
|
|
37
|
+
*/
|
|
23
38
|
optionalBoolean(fieldName: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Validates if the field is an optional array.
|
|
41
|
+
*
|
|
42
|
+
* @param fieldName - The name of the field to validate.
|
|
43
|
+
*/
|
|
24
44
|
optionalArray(fieldName: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Validates if the field is an optional object.
|
|
47
|
+
*
|
|
48
|
+
* @param fieldName - The name of the field to validate.
|
|
49
|
+
*/
|
|
25
50
|
optionalObject(fieldName: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Validates if the field is a string.
|
|
53
|
+
*
|
|
54
|
+
* @param fieldName - The name of the field to validate.
|
|
55
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
56
|
+
*/
|
|
26
57
|
string(fieldName: string, defaultValue: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Validates if the field is an object.
|
|
60
|
+
*
|
|
61
|
+
* @param fieldName - The name of the field to validate.
|
|
62
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
63
|
+
*/
|
|
27
64
|
object(fieldName: string, defaultValue: object): void;
|
|
65
|
+
/**
|
|
66
|
+
* Validates if the field is a number.
|
|
67
|
+
*
|
|
68
|
+
* @param fieldName - The name of the field to validate.
|
|
69
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
70
|
+
*/
|
|
28
71
|
number(fieldName: string, defaultValue: number): void;
|
|
72
|
+
/**
|
|
73
|
+
* Validates if the field is a boolean.
|
|
74
|
+
*
|
|
75
|
+
* @param fieldName - The name of the field to validate.
|
|
76
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
77
|
+
*/
|
|
29
78
|
boolean(fieldName: string, defaultValue: boolean): void;
|
|
79
|
+
/**
|
|
80
|
+
* Validates if the field is an array.
|
|
81
|
+
*
|
|
82
|
+
* @param fieldName - The name of the field to validate.
|
|
83
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
84
|
+
*/
|
|
30
85
|
array(fieldName: string, defaultValue: unknown[]): void;
|
|
31
86
|
/**
|
|
32
87
|
* Checks if the provided field path is valid. In other words, if the
|
|
@@ -37,10 +92,30 @@ export default class Validate {
|
|
|
37
92
|
* The idea is that if the field path is invalid, then this class will
|
|
38
93
|
* not report an error, because it is assumed that the parent of the field
|
|
39
94
|
* path will report the error.
|
|
95
|
+
*
|
|
96
|
+
* @param fieldName - The name of the field to check.
|
|
97
|
+
* @returns boolean - True if the field path is valid, false otherwise.
|
|
40
98
|
*/
|
|
41
99
|
private fieldPathIsValid;
|
|
100
|
+
/**
|
|
101
|
+
* Updates the field with the provided default value.
|
|
102
|
+
*
|
|
103
|
+
* @param fieldName - The name of the field to update.
|
|
104
|
+
* @param defaultValue - The default value to set.
|
|
105
|
+
*/
|
|
42
106
|
private updateField;
|
|
107
|
+
/**
|
|
108
|
+
* Retrieves the value of the field.
|
|
109
|
+
*
|
|
110
|
+
* @param fieldName - The name of the field to retrieve.
|
|
111
|
+
* @returns unknown - The value of the field.
|
|
112
|
+
*/
|
|
43
113
|
private getField;
|
|
114
|
+
/**
|
|
115
|
+
* Deletes the field from the parent object.
|
|
116
|
+
*
|
|
117
|
+
* @param fieldName - The name of the field to delete.
|
|
118
|
+
*/
|
|
44
119
|
private deleteField;
|
|
45
120
|
}
|
|
46
121
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidateUtil.d.ts","sourceRoot":"./src/","sources":["schemas/validators/ValidateUtil.ts"],"names":[],"mappings":"AAQA,KAAK,eAAe,GAAG;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,QAAQ;IAKzB,OAAO,CAAC,WAAW;IAJrB,YAAY,EAAE,eAAe,CAAC;gBAG5B,YAAY,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EAAE;IAK/B,cAAc,CAAC,SAAS,EAAE,MAAM;IAUhC,cAAc,CAAC,SAAS,EAAE,MAAM;IAUhC,eAAe,CAAC,SAAS,EAAE,MAAM;IAUjC,aAAa,CAAC,SAAS,EAAE,MAAM;IAU/B,cAAc,CAAC,SAAS,EAAE,MAAM;IAUhC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAU9C,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAW9C,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAU9C,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO;IAUhD,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE;IAUhD
|
|
1
|
+
{"version":3,"file":"ValidateUtil.d.ts","sourceRoot":"./src/","sources":["schemas/validators/ValidateUtil.ts"],"names":[],"mappings":"AAQA,KAAK,eAAe,GAAG;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,QAAQ;IAKzB,OAAO,CAAC,WAAW;IAJrB,YAAY,EAAE,eAAe,CAAC;gBAG5B,YAAY,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EAAE;IAK/B;;;;OAIG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM;IAUhC;;;;OAIG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM;IAUhC;;;;OAIG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM;IAUjC;;;;OAIG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM;IAU/B;;;;OAIG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM;IAUhC;;;;;OAKG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAU9C;;;;;OAKG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAW9C;;;;;OAKG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAU9C;;;;;OAKG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO;IAUhD;;;;;OAKG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE;IAUhD;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,gBAAgB;IAexB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAYnB;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;IAShB;;;;OAIG;IACH,OAAO,CAAC,WAAW;CAYpB"}
|
|
@@ -19,6 +19,11 @@ export default class Validate {
|
|
|
19
19
|
this.errorsArray = errorsArray;
|
|
20
20
|
this.parentObject = parentObject;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Validates if the field is an optional string.
|
|
24
|
+
*
|
|
25
|
+
* @param fieldName - The name of the field to validate.
|
|
26
|
+
*/
|
|
22
27
|
optionalString(fieldName) {
|
|
23
28
|
if (this.fieldPathIsValid(fieldName) &&
|
|
24
29
|
!isOptionalString(this.getField(fieldName))) {
|
|
@@ -26,6 +31,11 @@ export default class Validate {
|
|
|
26
31
|
this.deleteField(fieldName);
|
|
27
32
|
}
|
|
28
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Validates if the field is an optional number.
|
|
36
|
+
*
|
|
37
|
+
* @param fieldName - The name of the field to validate.
|
|
38
|
+
*/
|
|
29
39
|
optionalNumber(fieldName) {
|
|
30
40
|
if (this.fieldPathIsValid(fieldName) &&
|
|
31
41
|
!isOptionalNumber(this.getField(fieldName))) {
|
|
@@ -33,6 +43,11 @@ export default class Validate {
|
|
|
33
43
|
this.deleteField(fieldName);
|
|
34
44
|
}
|
|
35
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Validates if the field is an optional boolean.
|
|
48
|
+
*
|
|
49
|
+
* @param fieldName - The name of the field to validate.
|
|
50
|
+
*/
|
|
36
51
|
optionalBoolean(fieldName) {
|
|
37
52
|
if (this.fieldPathIsValid(fieldName) &&
|
|
38
53
|
!isOptionalBoolean(this.getField(fieldName))) {
|
|
@@ -40,6 +55,11 @@ export default class Validate {
|
|
|
40
55
|
this.deleteField(fieldName);
|
|
41
56
|
}
|
|
42
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Validates if the field is an optional array.
|
|
60
|
+
*
|
|
61
|
+
* @param fieldName - The name of the field to validate.
|
|
62
|
+
*/
|
|
43
63
|
optionalArray(fieldName) {
|
|
44
64
|
if (this.fieldPathIsValid(fieldName) &&
|
|
45
65
|
!isOptionalArray(this.getField(fieldName))) {
|
|
@@ -47,6 +67,11 @@ export default class Validate {
|
|
|
47
67
|
this.deleteField(fieldName);
|
|
48
68
|
}
|
|
49
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Validates if the field is an optional object.
|
|
72
|
+
*
|
|
73
|
+
* @param fieldName - The name of the field to validate.
|
|
74
|
+
*/
|
|
50
75
|
optionalObject(fieldName) {
|
|
51
76
|
if (this.fieldPathIsValid(fieldName) &&
|
|
52
77
|
!isOptionalObject(this.getField(fieldName))) {
|
|
@@ -54,6 +79,12 @@ export default class Validate {
|
|
|
54
79
|
this.deleteField(fieldName);
|
|
55
80
|
}
|
|
56
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Validates if the field is a string.
|
|
84
|
+
*
|
|
85
|
+
* @param fieldName - The name of the field to validate.
|
|
86
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
87
|
+
*/
|
|
57
88
|
string(fieldName, defaultValue) {
|
|
58
89
|
if (this.fieldPathIsValid(fieldName) &&
|
|
59
90
|
typeof this.getField(fieldName) !== 'string') {
|
|
@@ -61,6 +92,12 @@ export default class Validate {
|
|
|
61
92
|
this.updateField(fieldName, defaultValue);
|
|
62
93
|
}
|
|
63
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Validates if the field is an object.
|
|
97
|
+
*
|
|
98
|
+
* @param fieldName - The name of the field to validate.
|
|
99
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
100
|
+
*/
|
|
64
101
|
object(fieldName, defaultValue) {
|
|
65
102
|
if (this.fieldPathIsValid(fieldName) &&
|
|
66
103
|
(Array.isArray(this.getField(fieldName)) ||
|
|
@@ -69,6 +106,12 @@ export default class Validate {
|
|
|
69
106
|
this.updateField(fieldName, defaultValue);
|
|
70
107
|
}
|
|
71
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Validates if the field is a number.
|
|
111
|
+
*
|
|
112
|
+
* @param fieldName - The name of the field to validate.
|
|
113
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
114
|
+
*/
|
|
72
115
|
number(fieldName, defaultValue) {
|
|
73
116
|
if (this.fieldPathIsValid(fieldName) &&
|
|
74
117
|
typeof this.getField(fieldName) !== 'number') {
|
|
@@ -76,6 +119,12 @@ export default class Validate {
|
|
|
76
119
|
this.updateField(fieldName, defaultValue);
|
|
77
120
|
}
|
|
78
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Validates if the field is a boolean.
|
|
124
|
+
*
|
|
125
|
+
* @param fieldName - The name of the field to validate.
|
|
126
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
127
|
+
*/
|
|
79
128
|
boolean(fieldName, defaultValue) {
|
|
80
129
|
if (this.fieldPathIsValid(fieldName) &&
|
|
81
130
|
typeof this.getField(fieldName) !== 'boolean') {
|
|
@@ -83,6 +132,12 @@ export default class Validate {
|
|
|
83
132
|
this.updateField(fieldName, defaultValue);
|
|
84
133
|
}
|
|
85
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Validates if the field is an array.
|
|
137
|
+
*
|
|
138
|
+
* @param fieldName - The name of the field to validate.
|
|
139
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
140
|
+
*/
|
|
86
141
|
array(fieldName, defaultValue) {
|
|
87
142
|
if (this.fieldPathIsValid(fieldName) &&
|
|
88
143
|
!Array.isArray(this.getField(fieldName))) {
|
|
@@ -99,6 +154,9 @@ export default class Validate {
|
|
|
99
154
|
* The idea is that if the field path is invalid, then this class will
|
|
100
155
|
* not report an error, because it is assumed that the parent of the field
|
|
101
156
|
* path will report the error.
|
|
157
|
+
*
|
|
158
|
+
* @param fieldName - The name of the field to check.
|
|
159
|
+
* @returns boolean - True if the field path is valid, false otherwise.
|
|
102
160
|
*/
|
|
103
161
|
fieldPathIsValid(fieldName) {
|
|
104
162
|
const fieldPath = fieldName.split('.');
|
|
@@ -114,6 +172,12 @@ export default class Validate {
|
|
|
114
172
|
}
|
|
115
173
|
return true;
|
|
116
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Updates the field with the provided default value.
|
|
177
|
+
*
|
|
178
|
+
* @param fieldName - The name of the field to update.
|
|
179
|
+
* @param defaultValue - The default value to set.
|
|
180
|
+
*/
|
|
117
181
|
updateField(fieldName, defaultValue) {
|
|
118
182
|
const fieldPath = fieldName.split('.');
|
|
119
183
|
let currentObject = this.parentObject;
|
|
@@ -126,6 +190,12 @@ export default class Validate {
|
|
|
126
190
|
}
|
|
127
191
|
});
|
|
128
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Retrieves the value of the field.
|
|
195
|
+
*
|
|
196
|
+
* @param fieldName - The name of the field to retrieve.
|
|
197
|
+
* @returns unknown - The value of the field.
|
|
198
|
+
*/
|
|
129
199
|
getField(fieldName) {
|
|
130
200
|
const fieldPath = fieldName.split('.');
|
|
131
201
|
let currentObject = this.parentObject;
|
|
@@ -134,6 +204,11 @@ export default class Validate {
|
|
|
134
204
|
});
|
|
135
205
|
return currentObject;
|
|
136
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Deletes the field from the parent object.
|
|
209
|
+
*
|
|
210
|
+
* @param fieldName - The name of the field to delete.
|
|
211
|
+
*/
|
|
137
212
|
deleteField(fieldName) {
|
|
138
213
|
const fieldPath = fieldName.split('.');
|
|
139
214
|
let currentObject = this.parentObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidateUtil.js","sourceRoot":"./src/","sources":["schemas/validators/ValidateUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAI5C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,QAAQ;IAKjB;IAJV,YAAY,CAAkB;IAE9B,YACE,YAAoB,EACZ,WAAqB;QAArB,gBAAW,GAAX,WAAW,CAAU;QAE7B,IAAI,CAAC,YAAY,GAAG,YAA+B,CAAC;IACtD,CAAC;IAED,cAAc,CAAC,SAAiB;QAC9B,IACE,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC;YAChC,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAC3C,CAAC;YACD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,SAAS,gCAAgC,CAAC,CAAC;YACpE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,cAAc,CAAC,SAAiB;QAC9B,IACE,IAAI,CAAC,gBAAgB,CAAC,SA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
|
35
|
+
* Validates if the field is an optional string.
|
|
36
|
+
*
|
|
37
|
+
* @param fieldName - The name of the field to validate.
|
|
38
|
+
*/
|
|
34
39
|
optionalString(fieldName: string) {
|
|
35
40
|
if (
|
|
36
41
|
this.fieldPathIsValid(fieldName) &&
|
|
@@ -41,6 +46,11 @@ export default class Validate {
|
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Validates if the field is an optional number.
|
|
51
|
+
*
|
|
52
|
+
* @param fieldName - The name of the field to validate.
|
|
53
|
+
*/
|
|
44
54
|
optionalNumber(fieldName: string) {
|
|
45
55
|
if (
|
|
46
56
|
this.fieldPathIsValid(fieldName) &&
|
|
@@ -51,6 +61,11 @@ export default class Validate {
|
|
|
51
61
|
}
|
|
52
62
|
}
|
|
53
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Validates if the field is an optional boolean.
|
|
66
|
+
*
|
|
67
|
+
* @param fieldName - The name of the field to validate.
|
|
68
|
+
*/
|
|
54
69
|
optionalBoolean(fieldName: string) {
|
|
55
70
|
if (
|
|
56
71
|
this.fieldPathIsValid(fieldName) &&
|
|
@@ -61,6 +76,11 @@ export default class Validate {
|
|
|
61
76
|
}
|
|
62
77
|
}
|
|
63
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Validates if the field is an optional array.
|
|
81
|
+
*
|
|
82
|
+
* @param fieldName - The name of the field to validate.
|
|
83
|
+
*/
|
|
64
84
|
optionalArray(fieldName: string) {
|
|
65
85
|
if (
|
|
66
86
|
this.fieldPathIsValid(fieldName) &&
|
|
@@ -71,6 +91,11 @@ export default class Validate {
|
|
|
71
91
|
}
|
|
72
92
|
}
|
|
73
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Validates if the field is an optional object.
|
|
96
|
+
*
|
|
97
|
+
* @param fieldName - The name of the field to validate.
|
|
98
|
+
*/
|
|
74
99
|
optionalObject(fieldName: string) {
|
|
75
100
|
if (
|
|
76
101
|
this.fieldPathIsValid(fieldName) &&
|
|
@@ -81,6 +106,12 @@ export default class Validate {
|
|
|
81
106
|
}
|
|
82
107
|
}
|
|
83
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Validates if the field is a string.
|
|
111
|
+
*
|
|
112
|
+
* @param fieldName - The name of the field to validate.
|
|
113
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
114
|
+
*/
|
|
84
115
|
string(fieldName: string, defaultValue: string) {
|
|
85
116
|
if (
|
|
86
117
|
this.fieldPathIsValid(fieldName) &&
|
|
@@ -91,6 +122,12 @@ export default class Validate {
|
|
|
91
122
|
}
|
|
92
123
|
}
|
|
93
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Validates if the field is an object.
|
|
127
|
+
*
|
|
128
|
+
* @param fieldName - The name of the field to validate.
|
|
129
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
130
|
+
*/
|
|
94
131
|
object(fieldName: string, defaultValue: object) {
|
|
95
132
|
if (
|
|
96
133
|
this.fieldPathIsValid(fieldName) &&
|
|
@@ -102,6 +139,12 @@ export default class Validate {
|
|
|
102
139
|
}
|
|
103
140
|
}
|
|
104
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Validates if the field is a number.
|
|
144
|
+
*
|
|
145
|
+
* @param fieldName - The name of the field to validate.
|
|
146
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
147
|
+
*/
|
|
105
148
|
number(fieldName: string, defaultValue: number) {
|
|
106
149
|
if (
|
|
107
150
|
this.fieldPathIsValid(fieldName) &&
|
|
@@ -112,6 +155,12 @@ export default class Validate {
|
|
|
112
155
|
}
|
|
113
156
|
}
|
|
114
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Validates if the field is a boolean.
|
|
160
|
+
*
|
|
161
|
+
* @param fieldName - The name of the field to validate.
|
|
162
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
163
|
+
*/
|
|
115
164
|
boolean(fieldName: string, defaultValue: boolean) {
|
|
116
165
|
if (
|
|
117
166
|
this.fieldPathIsValid(fieldName) &&
|
|
@@ -122,6 +171,12 @@ export default class Validate {
|
|
|
122
171
|
}
|
|
123
172
|
}
|
|
124
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Validates if the field is an array.
|
|
176
|
+
*
|
|
177
|
+
* @param fieldName - The name of the field to validate.
|
|
178
|
+
* @param defaultValue - The default value to set if validation fails.
|
|
179
|
+
*/
|
|
125
180
|
array(fieldName: string, defaultValue: unknown[]) {
|
|
126
181
|
if (
|
|
127
182
|
this.fieldPathIsValid(fieldName) &&
|
|
@@ -141,6 +196,9 @@ export default class Validate {
|
|
|
141
196
|
* The idea is that if the field path is invalid, then this class will
|
|
142
197
|
* not report an error, because it is assumed that the parent of the field
|
|
143
198
|
* path will report the error.
|
|
199
|
+
*
|
|
200
|
+
* @param fieldName - The name of the field to check.
|
|
201
|
+
* @returns boolean - True if the field path is valid, false otherwise.
|
|
144
202
|
*/
|
|
145
203
|
private fieldPathIsValid(fieldName: string): boolean {
|
|
146
204
|
const fieldPath = fieldName.split('.');
|
|
@@ -157,6 +215,12 @@ export default class Validate {
|
|
|
157
215
|
return true;
|
|
158
216
|
}
|
|
159
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Updates the field with the provided default value.
|
|
220
|
+
*
|
|
221
|
+
* @param fieldName - The name of the field to update.
|
|
222
|
+
* @param defaultValue - The default value to set.
|
|
223
|
+
*/
|
|
160
224
|
private updateField(fieldName: string, defaultValue: unknown) {
|
|
161
225
|
const fieldPath = fieldName.split('.');
|
|
162
226
|
let currentObject = this.parentObject;
|
|
@@ -169,6 +233,12 @@ export default class Validate {
|
|
|
169
233
|
});
|
|
170
234
|
}
|
|
171
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Retrieves the value of the field.
|
|
238
|
+
*
|
|
239
|
+
* @param fieldName - The name of the field to retrieve.
|
|
240
|
+
* @returns unknown - The value of the field.
|
|
241
|
+
*/
|
|
172
242
|
private getField(fieldName: string): unknown {
|
|
173
243
|
const fieldPath = fieldName.split('.');
|
|
174
244
|
let currentObject = this.parentObject;
|
|
@@ -178,6 +248,11 @@ export default class Validate {
|
|
|
178
248
|
return currentObject;
|
|
179
249
|
}
|
|
180
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Deletes the field from the parent object.
|
|
253
|
+
*
|
|
254
|
+
* @param fieldName - The name of the field to delete.
|
|
255
|
+
*/
|
|
181
256
|
private deleteField(fieldName: string) {
|
|
182
257
|
const fieldPath = fieldName.split('.');
|
|
183
258
|
let currentObject = this.parentObject;
|
|
@@ -13,7 +13,7 @@ export type DashboardTaskFilterResult = {
|
|
|
13
13
|
removedIds: string[];
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
* A service responsible for filtering
|
|
16
|
+
* A service responsible for filtering tasks based on provided settings.
|
|
17
17
|
*/
|
|
18
18
|
export default class DashboardTaskFilterService {
|
|
19
19
|
/**
|
|
@@ -23,10 +23,16 @@ export default class DashboardTaskFilterService {
|
|
|
23
23
|
* cases, then the less common or more heavy cases later on to increase
|
|
24
24
|
* performance.
|
|
25
25
|
*
|
|
26
|
-
* @param taskMap
|
|
26
|
+
* @param taskMap - The map of tasks to use for filtering. This is used so that
|
|
27
27
|
* the task map doesn't need to be generated multiple times.
|
|
28
|
-
* @param
|
|
29
|
-
*
|
|
28
|
+
* @param taskIds - The IDs of the tasks to be filtered.
|
|
29
|
+
* @param settings - The filter settings to apply.
|
|
30
|
+
* @param category - The category to filter tasks by.
|
|
31
|
+
* @param parentTaskId - (Optional) Determines if the current list is for a parent task
|
|
32
|
+
* or not.
|
|
33
|
+
* @returns An object containing the IDs of the tasks that satisfy the filter settings
|
|
34
|
+
* (`resultIds`) and the IDs of the tasks that were filtered but still apply to the same
|
|
35
|
+
* category (`removedIds`).
|
|
30
36
|
*/
|
|
31
37
|
static filter(taskMap: DashboardTaskMap, taskIds: string[], settings: DashboardTaskListFilterSettings, category: string, parentTaskId?: string): DashboardTaskFilterResult;
|
|
32
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskFilterService.d.ts","sourceRoot":"./src/","sources":["services/dashboard/Task/TaskFilterService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,+BAA+B,EAAE,MAAM,0DAA0D,CAAC;AAE3G,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;;;;OAIG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,0BAA0B;IAC7C
|
|
1
|
+
{"version":3,"file":"TaskFilterService.d.ts","sourceRoot":"./src/","sources":["services/dashboard/Task/TaskFilterService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,+BAA+B,EAAE,MAAM,0DAA0D,CAAC;AAE3G,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;;;;OAIG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,0BAA0B;IAC7C;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,MAAM,CACX,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,EAAE,+BAA+B,EACzC,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,MAAM,GACpB,yBAAyB;CAkE7B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A service responsible for filtering
|
|
2
|
+
* A service responsible for filtering tasks based on provided settings.
|
|
3
3
|
*/
|
|
4
4
|
export default class DashboardTaskFilterService {
|
|
5
5
|
/**
|
|
@@ -9,10 +9,16 @@ export default class DashboardTaskFilterService {
|
|
|
9
9
|
* cases, then the less common or more heavy cases later on to increase
|
|
10
10
|
* performance.
|
|
11
11
|
*
|
|
12
|
-
* @param taskMap
|
|
12
|
+
* @param taskMap - The map of tasks to use for filtering. This is used so that
|
|
13
13
|
* the task map doesn't need to be generated multiple times.
|
|
14
|
-
* @param
|
|
15
|
-
*
|
|
14
|
+
* @param taskIds - The IDs of the tasks to be filtered.
|
|
15
|
+
* @param settings - The filter settings to apply.
|
|
16
|
+
* @param category - The category to filter tasks by.
|
|
17
|
+
* @param parentTaskId - (Optional) Determines if the current list is for a parent task
|
|
18
|
+
* or not.
|
|
19
|
+
* @returns An object containing the IDs of the tasks that satisfy the filter settings
|
|
20
|
+
* (`resultIds`) and the IDs of the tasks that were filtered but still apply to the same
|
|
21
|
+
* category (`removedIds`).
|
|
16
22
|
*/
|
|
17
23
|
static filter(taskMap, taskIds, settings, category, parentTaskId) {
|
|
18
24
|
// The filtered IDs that apply to the category, and aren't grandchildren
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskFilterService.js","sourceRoot":"./src/","sources":["services/dashboard/Task/TaskFilterService.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,0BAA0B;IAC7C
|
|
1
|
+
{"version":3,"file":"TaskFilterService.js","sourceRoot":"./src/","sources":["services/dashboard/Task/TaskFilterService.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,0BAA0B;IAC7C;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,MAAM,CACX,OAAyB,EACzB,OAAiB,EACjB,QAAyC,EACzC,QAAgB,EAChB,YAAqB;QAErB,wEAAwE;QACxE,SAAS;QACT,MAAM,UAAU,GAAa,EAAE,CAAC;QAChC,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;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C,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;wBACnD,OAAO,IAAI,CAAC;oBACd,CAAC;oBACD,OAAO,KAAK,CAAC;gBACf,CAAC,CAAC,CAAC;gBACH,IAAI,UAAU,EAAE,CAAC;oBACf,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBACxB,OAAO,KAAK,CAAC;gBACf,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,OAAO;YACL,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -15,7 +15,7 @@ export type DashboardTaskFilterResult = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* A service responsible for filtering
|
|
18
|
+
* A service responsible for filtering tasks based on provided settings.
|
|
19
19
|
*/
|
|
20
20
|
export default class DashboardTaskFilterService {
|
|
21
21
|
/**
|
|
@@ -25,10 +25,16 @@ export default class DashboardTaskFilterService {
|
|
|
25
25
|
* cases, then the less common or more heavy cases later on to increase
|
|
26
26
|
* performance.
|
|
27
27
|
*
|
|
28
|
-
* @param taskMap
|
|
28
|
+
* @param taskMap - The map of tasks to use for filtering. This is used so that
|
|
29
29
|
* the task map doesn't need to be generated multiple times.
|
|
30
|
-
* @param
|
|
31
|
-
*
|
|
30
|
+
* @param taskIds - The IDs of the tasks to be filtered.
|
|
31
|
+
* @param settings - The filter settings to apply.
|
|
32
|
+
* @param category - The category to filter tasks by.
|
|
33
|
+
* @param parentTaskId - (Optional) Determines if the current list is for a parent task
|
|
34
|
+
* or not.
|
|
35
|
+
* @returns An object containing the IDs of the tasks that satisfy the filter settings
|
|
36
|
+
* (`resultIds`) and the IDs of the tasks that were filtered but still apply to the same
|
|
37
|
+
* category (`removedIds`).
|
|
32
38
|
*/
|
|
33
39
|
static filter(
|
|
34
40
|
taskMap: DashboardTaskMap,
|
|
@@ -2,8 +2,11 @@ import DashboardTask from '../../../documents/dashboard/Task.js';
|
|
|
2
2
|
import { RecurrenceFrequency } from '../../../embedded-types/dashboard/task/RecurrenceInfo.js';
|
|
3
3
|
export default class DashboardTaskRecurrenceService {
|
|
4
4
|
/**
|
|
5
|
-
* Gets the next frequency date from the provided basis date.
|
|
6
|
-
*
|
|
5
|
+
* Gets the next frequency date from the provided basis date.
|
|
6
|
+
*
|
|
7
|
+
* @param basisDate - The date from which to calculate the next frequency date.
|
|
8
|
+
* @param frequency - The recurrence frequency details.
|
|
9
|
+
* @returns The next frequency date or null if the frequency is in an invalid state.
|
|
7
10
|
*/
|
|
8
11
|
static getNextFrequencyDate(basisDate: Date, frequency: RecurrenceFrequency): Date | null;
|
|
9
12
|
/**
|
|
@@ -14,8 +17,17 @@ export default class DashboardTaskRecurrenceService {
|
|
|
14
17
|
*
|
|
15
18
|
* Makes no changes if the state of the task is invalid for recurrence or
|
|
16
19
|
* there isn't recurrence info.
|
|
20
|
+
*
|
|
21
|
+
* @param task - The task whose dates need to be updated.
|
|
17
22
|
*/
|
|
18
23
|
static updateDatesForRecurrence(task: DashboardTask): void;
|
|
24
|
+
/**
|
|
25
|
+
* Calculates the difference in time between the basis date and the next frequency date.
|
|
26
|
+
*
|
|
27
|
+
* @param basisDate - The date from which to calculate the difference.
|
|
28
|
+
* @param frequency - The recurrence frequency details.
|
|
29
|
+
* @returns The difference in time in milliseconds.
|
|
30
|
+
*/
|
|
19
31
|
private static getDiffForDateUpdate;
|
|
20
32
|
}
|
|
21
33
|
//# sourceMappingURL=TaskRecurrenceService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskRecurrenceService.d.ts","sourceRoot":"./src/","sources":["services/dashboard/Task/TaskRecurrenceService.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAEL,mBAAmB,EAEpB,MAAM,0DAA0D,CAAC;AAElE,MAAM,CAAC,OAAO,OAAO,8BAA8B;IACjD
|
|
1
|
+
{"version":3,"file":"TaskRecurrenceService.d.ts","sourceRoot":"./src/","sources":["services/dashboard/Task/TaskRecurrenceService.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAEL,mBAAmB,EAEpB,MAAM,0DAA0D,CAAC;AAElE,MAAM,CAAC,OAAO,OAAO,8BAA8B;IACjD;;;;;;OAMG;IACH,MAAM,CAAC,oBAAoB,CACzB,SAAS,EAAE,IAAI,EACf,SAAS,EAAE,mBAAmB,GAC7B,IAAI,GAAG,IAAI;IAsEd;;;;;;;;;;OAUG;IACH,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAkE1D;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;CAapC"}
|
|
@@ -2,8 +2,11 @@ import { DateService } from '@aneuhold/core-ts-lib';
|
|
|
2
2
|
import { RecurrenceBasis, RecurrenceFrequencyType } from '../../../embedded-types/dashboard/task/RecurrenceInfo.js';
|
|
3
3
|
export default class DashboardTaskRecurrenceService {
|
|
4
4
|
/**
|
|
5
|
-
* Gets the next frequency date from the provided basis date.
|
|
6
|
-
*
|
|
5
|
+
* Gets the next frequency date from the provided basis date.
|
|
6
|
+
*
|
|
7
|
+
* @param basisDate - The date from which to calculate the next frequency date.
|
|
8
|
+
* @param frequency - The recurrence frequency details.
|
|
9
|
+
* @returns The next frequency date or null if the frequency is in an invalid state.
|
|
7
10
|
*/
|
|
8
11
|
static getNextFrequencyDate(basisDate, frequency) {
|
|
9
12
|
// Last day of month
|
|
@@ -72,6 +75,8 @@ export default class DashboardTaskRecurrenceService {
|
|
|
72
75
|
*
|
|
73
76
|
* Makes no changes if the state of the task is invalid for recurrence or
|
|
74
77
|
* there isn't recurrence info.
|
|
78
|
+
*
|
|
79
|
+
* @param task - The task whose dates need to be updated.
|
|
75
80
|
*/
|
|
76
81
|
static updateDatesForRecurrence(task) {
|
|
77
82
|
// Initial basic validation
|
|
@@ -122,6 +127,13 @@ export default class DashboardTaskRecurrenceService {
|
|
|
122
127
|
task.dueDate = new Date(task.dueDate.getTime() + diff);
|
|
123
128
|
}
|
|
124
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Calculates the difference in time between the basis date and the next frequency date.
|
|
132
|
+
*
|
|
133
|
+
* @param basisDate - The date from which to calculate the difference.
|
|
134
|
+
* @param frequency - The recurrence frequency details.
|
|
135
|
+
* @returns The difference in time in milliseconds.
|
|
136
|
+
*/
|
|
125
137
|
static getDiffForDateUpdate(basisDate, frequency) {
|
|
126
138
|
if (!basisDate) {
|
|
127
139
|
return 0;
|