@followupus/common 0.7.0 → 0.7.3

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.
@@ -11,6 +11,11 @@ export declare const DELTA_ACTION: {
11
11
  UPDATE: string;
12
12
  CREATE: string;
13
13
  };
14
+ export declare const ROOT_SCHEMA_NAME: {
15
+ USERS: string;
16
+ BOARDS: string;
17
+ SPACES: string;
18
+ };
14
19
  export interface DeltaObject {
15
20
  id: number;
16
21
  action: keyof typeof DELTA_ACTION;
@@ -20,7 +25,7 @@ export interface DeltaObject {
20
25
  createdAt: string;
21
26
  data?: object;
22
27
  rootId: string;
23
- rootType: keyof typeof DELTA_SCHEMA_NAME;
28
+ rootType: keyof typeof ROOT_SCHEMA_NAME;
24
29
  }
25
30
  export interface DeltaMessages {
26
31
  cmd: string;
@@ -11,3 +11,8 @@ export const DELTA_ACTION = {
11
11
  UPDATE: "U",
12
12
  CREATE: "C",
13
13
  };
14
+ export const ROOT_SCHEMA_NAME = {
15
+ USERS: "USERS",
16
+ BOARDS: "BOARDS",
17
+ SPACES: "SPACES",
18
+ };
@@ -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;
@@ -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((c) => {
151
- const validHeader = headers.find((h) => h.columnId === c.columnId);
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((v) => !!v || v === 0)?.length &&
181
+ (!!c.value?.filter(v => !!v || v === 0)?.length &&
167
182
  (!isDropdown ||
168
- c.value.some((v) => validHeader.dropdowns?.find((d) => d.key === v)))));
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((val) => val === itemVal));
207
+ !!condition.value.find(val => val === itemVal));
193
208
  case "stringArray":
194
209
  return ((condition.blank && !itemVal?.length) ||
195
- condition.value.some((val) => Array.isArray(itemVal) && itemVal?.includes(val)));
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((val) => _.isEqual(val, itemVal)));
213
+ !!condition.value.find(val => _.isEqual(val, itemVal)));
199
214
  case "objectArray":
200
215
  return ((condition.blank && !itemVal?.length) ||
201
- condition.value.some((val) => Array.isArray(itemVal) &&
202
- itemVal.find((existVal) => _.isEqual(val, existVal))));
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((dateGroup) => dateGroup === groupKey);
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((val) => val.includes(checkVal))
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((g) => {
316
- g.items = g.items?.filter((item) => {
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((h) => h.columnId === condition.columnId);
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;
@@ -14,7 +14,8 @@ const descriptor = {
14
14
  },
15
15
  phone: {
16
16
  type: "string", //+1 (408) 888-8888
17
- pattern: /^(\+?1)?\(?[2-9]\d{2}\)?\s?\d{3}-?\d{4}$/,
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@followupus/common",
3
- "version": "0.7.0",
3
+ "version": "0.7.3",
4
4
  "description": "followup common utils npm package with TypeScript and VSCode",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",