@followupus/common 0.7.0 → 0.7.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/dist/shared/shared.d.ts +4 -0
- package/dist/shared/shared.js +29 -14
- package/dist/utils/validator.js +2 -1
- package/package.json +1 -1
package/dist/shared/shared.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const COLUMN_TYPES: {
|
|
|
17
17
|
TIMELINE: string;
|
|
18
18
|
PHONE: string;
|
|
19
19
|
CURRENCY: string;
|
|
20
|
+
TIME_TRACKING: string;
|
|
20
21
|
};
|
|
21
22
|
export declare const OP_TYPES: {
|
|
22
23
|
CONTAINS: string;
|
|
@@ -35,6 +36,9 @@ export declare const OP_TYPES: {
|
|
|
35
36
|
export declare const COLUMN_OP_TYPES: {
|
|
36
37
|
[x: string]: string[];
|
|
37
38
|
};
|
|
39
|
+
export declare const AUTOMATION_OP_TYPES: {
|
|
40
|
+
[x: string]: string[];
|
|
41
|
+
};
|
|
38
42
|
export declare const DATE_GROUPS: {
|
|
39
43
|
OVERDUE: string;
|
|
40
44
|
TODAY: string;
|
package/dist/shared/shared.js
CHANGED
|
@@ -18,6 +18,7 @@ export const COLUMN_TYPES = {
|
|
|
18
18
|
TIMELINE: "timeline",
|
|
19
19
|
PHONE: "phone",
|
|
20
20
|
CURRENCY: "currency",
|
|
21
|
+
TIME_TRACKING: "time_tracking",
|
|
21
22
|
};
|
|
22
23
|
export const OP_TYPES = {
|
|
23
24
|
CONTAINS: "like",
|
|
@@ -81,6 +82,20 @@ export const COLUMN_OP_TYPES = {
|
|
|
81
82
|
OP_TYPES.NOT_EMPTY,
|
|
82
83
|
],
|
|
83
84
|
};
|
|
85
|
+
export const AUTOMATION_OP_TYPES = {
|
|
86
|
+
...COLUMN_OP_TYPES,
|
|
87
|
+
[COLUMN_TYPES.TEXT]: [OP_TYPES.CONTAINS, OP_TYPES.NOT_CONTAINS],
|
|
88
|
+
[COLUMN_TYPES.DATE]: [
|
|
89
|
+
OP_TYPES.EQUAL,
|
|
90
|
+
OP_TYPES.NOT_EQUAL,
|
|
91
|
+
OP_TYPES.GREATER,
|
|
92
|
+
OP_TYPES.GREATER_EQUAL,
|
|
93
|
+
OP_TYPES.LESS,
|
|
94
|
+
OP_TYPES.LESS_EQUAL,
|
|
95
|
+
OP_TYPES.EMPTY,
|
|
96
|
+
OP_TYPES.NOT_EMPTY,
|
|
97
|
+
],
|
|
98
|
+
};
|
|
84
99
|
export const DATE_GROUPS = {
|
|
85
100
|
OVERDUE: "overdue",
|
|
86
101
|
TODAY: "today",
|
|
@@ -147,8 +162,8 @@ export const getValidConditions = (filter, headers) => {
|
|
|
147
162
|
return [];
|
|
148
163
|
}
|
|
149
164
|
// for dropdown, if set the option is in filter condition, and user delete the option. should ignore it or make the option can't be deleted
|
|
150
|
-
return filter.criteria.filter(
|
|
151
|
-
const validHeader = headers.find(
|
|
165
|
+
return filter.criteria.filter(c => {
|
|
166
|
+
const validHeader = headers.find(h => h.columnId === c.columnId);
|
|
152
167
|
if (!validHeader)
|
|
153
168
|
return false;
|
|
154
169
|
const validOperate = COLUMN_OP_TYPES[validHeader.type].includes(c.op);
|
|
@@ -163,9 +178,9 @@ export const getValidConditions = (filter, headers) => {
|
|
|
163
178
|
case OP_TYPES.IS:
|
|
164
179
|
case OP_TYPES.IS_NOT:
|
|
165
180
|
return (c.blank ||
|
|
166
|
-
(!!c.value?.filter(
|
|
181
|
+
(!!c.value?.filter(v => !!v || v === 0)?.length &&
|
|
167
182
|
(!isDropdown ||
|
|
168
|
-
c.value.some(
|
|
183
|
+
c.value.some(v => validHeader.dropdowns?.find(d => d.key === v)))));
|
|
169
184
|
case OP_TYPES.EMPTY:
|
|
170
185
|
case OP_TYPES.NOT_EMPTY:
|
|
171
186
|
return true;
|
|
@@ -189,17 +204,17 @@ const isInConditionValues = (itemVal, valueType, condition) => {
|
|
|
189
204
|
case "number":
|
|
190
205
|
case "string":
|
|
191
206
|
return ((condition.blank && !itemVal) ||
|
|
192
|
-
!!condition.value.find(
|
|
207
|
+
!!condition.value.find(val => val === itemVal));
|
|
193
208
|
case "stringArray":
|
|
194
209
|
return ((condition.blank && !itemVal?.length) ||
|
|
195
|
-
condition.value.some(
|
|
210
|
+
condition.value.some(val => Array.isArray(itemVal) && itemVal?.includes(val)));
|
|
196
211
|
case "object":
|
|
197
212
|
return ((condition.blank && !itemVal) ||
|
|
198
|
-
!!condition.value.find(
|
|
213
|
+
!!condition.value.find(val => _.isEqual(val, itemVal)));
|
|
199
214
|
case "objectArray":
|
|
200
215
|
return ((condition.blank && !itemVal?.length) ||
|
|
201
|
-
condition.value.some(
|
|
202
|
-
itemVal.find(
|
|
216
|
+
condition.value.some(val => Array.isArray(itemVal) &&
|
|
217
|
+
itemVal.find(existVal => _.isEqual(val, existVal))));
|
|
203
218
|
default:
|
|
204
219
|
break;
|
|
205
220
|
}
|
|
@@ -211,7 +226,7 @@ const isDateInConditionValues = (itemVal, condition) => {
|
|
|
211
226
|
const groupKey = getDateGroupKey(itemVal);
|
|
212
227
|
if (!groupKey)
|
|
213
228
|
return !!condition.blank;
|
|
214
|
-
return !!condition.value?.find(
|
|
229
|
+
return !!condition.value?.find(dateGroup => dateGroup === groupKey);
|
|
215
230
|
};
|
|
216
231
|
const isEmpty = (itemVal, valueType) => {
|
|
217
232
|
switch (valueType) {
|
|
@@ -242,7 +257,7 @@ const isContains = (itemVal, valueType, condition) => {
|
|
|
242
257
|
return !!itemVal && itemVal.includes(checkVal);
|
|
243
258
|
case "stringArray":
|
|
244
259
|
return itemVal?.length
|
|
245
|
-
? itemVal.some(
|
|
260
|
+
? itemVal.some(val => val.includes(checkVal))
|
|
246
261
|
: false;
|
|
247
262
|
default:
|
|
248
263
|
break;
|
|
@@ -312,11 +327,11 @@ export const filterItemsByConditions = (groups, filter, headers) => {
|
|
|
312
327
|
if (!validConditions?.length) {
|
|
313
328
|
return groups;
|
|
314
329
|
}
|
|
315
|
-
groups.forEach(
|
|
316
|
-
g.items = g.items?.filter(
|
|
330
|
+
groups.forEach(g => {
|
|
331
|
+
g.items = g.items?.filter(item => {
|
|
317
332
|
let match = false;
|
|
318
333
|
for (const condition of validConditions) {
|
|
319
|
-
const header = headers?.find(
|
|
334
|
+
const header = headers?.find(h => h.columnId === condition.columnId);
|
|
320
335
|
const valueType = getColumnValueType(header?.type ?? "");
|
|
321
336
|
const itemVal = item.data?.[condition.columnId]?.value;
|
|
322
337
|
const isDate = header?.type === COLUMN_TYPES.DATE;
|
package/dist/utils/validator.js
CHANGED
|
@@ -14,7 +14,8 @@ const descriptor = {
|
|
|
14
14
|
},
|
|
15
15
|
phone: {
|
|
16
16
|
type: "string", //+1 (408) 888-8888
|
|
17
|
-
pattern: /^(
|
|
17
|
+
pattern: /^(\+?\d+)?\(?\d?\)?\s?\d?-?\d+$/, // temp for all countries
|
|
18
|
+
// pattern: /^(\+?1)?\(?[2-9]\d{2}\)?\s?\d{3}-?\d{4}$/,
|
|
18
19
|
},
|
|
19
20
|
};
|
|
20
21
|
const validator = new Schema(descriptor);
|