@periskope/types 0.6.145 → 0.6.147

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/rules.types.ts CHANGED
@@ -1,70 +1,26 @@
1
1
  import { Merge, OverrideProperties } from 'type-fest';
2
2
  import { Tables } from './supabase.types';
3
+ import {
4
+ ChatRuleInfoType,
5
+ MessageRuleInfoType,
6
+ ReactionRuleInfoType,
7
+ SenderRuleInfoType,
8
+ TicketRuleInfoType,
9
+ } from './types';
3
10
 
4
11
  export type AppendTypes<T extends object, O extends string> = {
5
12
  [K in keyof T & string as `${K}${O}${keyof T[K] & string}`]: T[K][keyof T[K]];
6
13
  };
7
14
 
8
- export type TicketVariablesType = Merge<
9
- Pick<
10
- Tables<'tbl_chat_tickets'>,
11
- | 'assigned_by'
12
- | 'assignee'
13
- | 'status'
14
- | 'subject'
15
- | 'is_deleted'
16
- | 'priority'
17
- | 'raised_by'
18
- | 'due_date'
19
- | 'ticket_id'
20
- >,
21
- {
22
- labels: string[];
23
- }
24
- >;
15
+ export type TicketVariablesType = TicketRuleInfoType['ticket'];
25
16
 
26
- export type MessageVariablesType = Pick<
27
- Tables<'tbl_chat_messages'>,
28
- | 'body'
29
- | 'sender_phone'
30
- | 'timestamp'
31
- | 'flag_status'
32
- | 'has_quoted_msg'
33
- | 'media'
34
- | 'performed_by'
35
- | 'message_id'
36
- | 'chat_id'
37
- >;
17
+ export type MessageVariablesType = MessageRuleInfoType['message'];
38
18
 
39
- export type SenderVariablesType = Merge<
40
- Pick<
41
- Tables<'tbl_contacts'>,
42
- | 'is_business'
43
- | 'is_enterprise'
44
- | 'is_internal'
45
- | 'contact_name'
46
- | 'contact_id'
47
- >,
48
- {
49
- labels: string[];
50
- }
51
- >;
19
+ export type SenderVariablesType = SenderRuleInfoType;
52
20
 
53
- export type ReactionVariablesType = Pick<
54
- Tables<'tbl_chat_reactions'>,
55
- 'reaction' | 'sender_id' | 'reaction_id' | 'message_id' | 'chat_id'
56
- >;
21
+ export type ReactionVariablesType = ReactionRuleInfoType['reaction'];
57
22
 
58
- export type ChatVariablesType = Merge<
59
- Pick<
60
- Tables<'view_chats'>,
61
- 'assigned_to' | 'chat_name' | 'org_phone' | 'chat_type' | 'chat_id'
62
- >,
63
- {
64
- members: string[];
65
- labels: string[];
66
- }
67
- >;
23
+ export type ChatVariablesType = ChatRuleInfoType;
68
24
 
69
25
  export type MessageRulesInfoType = Merge<
70
26
  AppendTypes<
@@ -107,7 +63,6 @@ export type ReactionRulesInfoType = Merge<
107
63
  reaction: ReactionVariablesType;
108
64
  message: MessageVariablesType;
109
65
  sender: SenderVariablesType;
110
- ticket: TicketVariablesType;
111
66
  chat: ChatVariablesType;
112
67
  },
113
68
  '.'
@@ -115,7 +70,7 @@ export type ReactionRulesInfoType = Merge<
115
70
  {
116
71
  rule: Tables<'tbl_automation_rules'>[];
117
72
  id: 'reaction.reaction_id';
118
- type: `reaction.${'created' | 'updated'}`;
73
+ type: `reaction.added`;
119
74
  org_id: string;
120
75
  }
121
76
  >;
@@ -124,8 +79,6 @@ export type ChatRulesInfoType = Merge<
124
79
  AppendTypes<
125
80
  {
126
81
  chat: ChatVariablesType;
127
- message: MessageVariablesType;
128
- sender: SenderVariablesType;
129
82
  },
130
83
  '.'
131
84
  >,
@@ -232,7 +185,7 @@ export const FilterNameMap: Record<
232
185
 
233
186
  export type VariableNameValueType = {
234
187
  text: string;
235
- type: 'string' | 'date' | 'boolean' | 'dropdown';
188
+ type: 'string' | 'time' | 'boolean' | 'dropdown' | 'day-time' | 'number';
236
189
  value?:
237
190
  | string
238
191
  | {
@@ -243,6 +196,7 @@ export type VariableNameValueType = {
243
196
  | null;
244
197
  filters: Filter['condition'][];
245
198
  hidden?: boolean;
199
+ placeholder?: string;
246
200
  };
247
201
 
248
202
  export const MessageVariableNameMap: Record<
@@ -253,21 +207,24 @@ export const MessageVariableNameMap: Record<
253
207
  text: 'Message Body',
254
208
  type: 'string',
255
209
  filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
210
+ placeholder: 'e.g. Test message',
256
211
  },
257
212
  'message.sender_phone': {
258
213
  text: 'Message Sender Phone',
259
214
  type: 'string',
260
215
  filters: ['EQ', 'NEQ'],
216
+ placeholder: 'e.g. 919876543210@c.us',
261
217
  },
262
218
  'message.timestamp': {
263
219
  text: 'Message Timestamp',
264
- type: 'date',
220
+ type: 'day-time',
265
221
  filters: ['LT', 'LTE', 'GT', 'GTE', 'IS'],
266
222
  },
267
223
  'message.flag_status': {
268
224
  text: 'Message Flag Status',
269
225
  filters: ['IS'],
270
226
  type: 'boolean',
227
+
271
228
  },
272
229
  'message.has_quoted_msg': {
273
230
  text: 'Quoted Message',
@@ -285,18 +242,59 @@ export const MessageVariableNameMap: Record<
285
242
  value: 'org.members',
286
243
  filters: ['EQ', 'NEQ'],
287
244
  },
288
- "message.chat_id":{
245
+ 'message.chat_id': {
289
246
  text: 'Chat ID',
290
247
  type: 'string',
291
248
  filters: ['EQ', 'NEQ'],
292
- hidden: true
249
+ hidden: true,
293
250
  },
294
- "message.message_id":{
251
+ 'message.message_id': {
295
252
  text: 'Message ID',
296
253
  type: 'string',
297
254
  filters: ['EQ', 'NEQ'],
298
- hidden: true
299
- }
255
+ hidden: true,
256
+ },
257
+ 'message.org_phone': {
258
+ text: 'Org Phone',
259
+ type: 'string',
260
+ filters: ['EQ', 'NEQ'],
261
+ hidden: true,
262
+ },
263
+ 'message.org_id': {
264
+ text: 'Org ID',
265
+ type: 'string',
266
+ filters: ['EQ', 'NEQ'],
267
+ hidden: true,
268
+ },
269
+ 'message.message_type': {
270
+ text: 'Message Type',
271
+ type: 'dropdown',
272
+ value: [
273
+ { id: 'text', value: 'text', label: 'Text' },
274
+ { id: 'image', value: 'image', label: 'Image' },
275
+ { id: 'video', value: 'video', label: 'Video' },
276
+ { id: 'audio', value: 'audio', label: 'Audio' },
277
+ { id: 'document', value: 'document', label: 'Document' },
278
+ ],
279
+ filters: ['EQ', 'NEQ'],
280
+ },
281
+ 'message.author': {
282
+ text: 'Message Author',
283
+ type: 'string',
284
+ filters: ['EQ', 'NEQ'],
285
+ hidden: true,
286
+ },
287
+ 'message.ack': {
288
+ text: 'Message acknowledment status',
289
+ type: 'dropdown',
290
+ value: [
291
+ { id: '0', value: '0', label: '0' },
292
+ { id: '1', value: '1', label: '1' },
293
+ { id: '2', value: '2', label: '2' },
294
+ { id: '3', value: '3', label: '3' },
295
+ ],
296
+ filters: ['EQ'],
297
+ },
300
298
  };
301
299
 
302
300
  export const SenderVariableNameMap: Record<
@@ -304,13 +302,11 @@ export const SenderVariableNameMap: Record<
304
302
  VariableNameValueType
305
303
  > = {
306
304
  'sender.is_business': {
307
- // remove
308
305
  text: 'Sender is business',
309
306
  type: 'boolean',
310
307
  filters: ['IS'],
311
308
  },
312
309
  'sender.is_enterprise': {
313
- // remove
314
310
  text: 'Sender is enterprise',
315
311
  type: 'boolean',
316
312
  filters: ['IS'],
@@ -324,11 +320,13 @@ export const SenderVariableNameMap: Record<
324
320
  text: 'Sender Name',
325
321
  type: 'string',
326
322
  filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
323
+ placeholder: 'e.g. John Doe',
327
324
  },
328
325
  'sender.contact_id': {
329
326
  text: 'Sender Contact Phone',
330
327
  type: 'string',
331
328
  filters: ['EQ', 'NEQ'],
329
+ placeholder: 'e.g. 919876543210@c.us'
332
330
  },
333
331
  'sender.labels': {
334
332
  text: 'Sender Labels',
@@ -336,6 +334,46 @@ export const SenderVariableNameMap: Record<
336
334
  value: 'org.labels',
337
335
  filters: ['EQ', 'NEQ'],
338
336
  },
337
+ 'sender.org_id': {
338
+ text: 'Org ID',
339
+ type: 'string',
340
+ filters: ['EQ', 'NEQ'],
341
+ hidden: true,
342
+ },
343
+ 'sender.is_super_admin': {
344
+ text: 'Sender is super admin',
345
+ type: 'dropdown',
346
+ filters: ['EQ', 'NEQ'],
347
+ value: [
348
+ {
349
+ id: 'true',
350
+ value: 'true',
351
+ label: 'True',
352
+ },
353
+ {
354
+ id: 'false',
355
+ value: 'false',
356
+ label: 'False',
357
+ },
358
+ ],
359
+ },
360
+ 'sender.is_admin': {
361
+ text: 'Sender is admin',
362
+ type: 'dropdown',
363
+ filters: ['EQ', 'NEQ'],
364
+ value: [
365
+ {
366
+ id: 'true',
367
+ value: 'true',
368
+ label: 'True',
369
+ },
370
+ {
371
+ id: 'false',
372
+ value: 'false',
373
+ label: 'False',
374
+ },
375
+ ],
376
+ },
339
377
  };
340
378
 
341
379
  export const ChatVariableNameMap: Record<
@@ -352,10 +390,12 @@ export const ChatVariableNameMap: Record<
352
390
  text: 'Chat Name',
353
391
  type: 'string',
354
392
  filters: ['EQ', 'NEQ'],
393
+ placeholder: 'e.g. Support Chat',
355
394
  },
356
395
  'chat.org_phone': {
357
396
  text: 'Chat Org Phone',
358
- type: 'string',
397
+ type: 'dropdown',
398
+ value: 'org.org_phones',
359
399
  filters: ['EQ', 'NEQ'],
360
400
  },
361
401
  'chat.chat_type': {
@@ -370,7 +410,8 @@ export const ChatVariableNameMap: Record<
370
410
  'chat.members': {
371
411
  text: 'Chat Members',
372
412
  type: 'string',
373
- filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
413
+ filters: ['CONTAINS', 'NCONTAINS'],
414
+ placeholder: 'e.g. 919876543210'
374
415
  },
375
416
  'chat.labels': {
376
417
  text: 'Chat Labels',
@@ -378,11 +419,144 @@ export const ChatVariableNameMap: Record<
378
419
  value: 'org.labels',
379
420
  filters: ['CONTAINS', 'NCONTAINS'],
380
421
  },
381
- "chat.chat_id": {
422
+ 'chat.chat_id': {
382
423
  text: 'Chat ID',
383
424
  type: 'string',
384
425
  filters: ['EQ', 'NEQ'],
385
- }
426
+ placeholder: 'e.g. 12027747916749@c.us'
427
+ },
428
+ 'chat.chat_org_phones': {
429
+ text: 'Chat Org Phones',
430
+ type: 'dropdown',
431
+ filters: ['CONTAINS', 'NCONTAINS'],
432
+ hidden: true,
433
+ },
434
+ 'chat.org_id': {
435
+ text: 'Org ID',
436
+ type: 'string',
437
+ filters: [],
438
+ hidden: true,
439
+ },
440
+ 'chat.messages_admins_only': {
441
+ text: 'Chat Messages Admins Only',
442
+ type: 'boolean',
443
+ filters: ['EQ', 'NEQ'],
444
+ value: [
445
+ {
446
+ id: 'true',
447
+ value: 'true',
448
+ label: 'True',
449
+ },
450
+ {
451
+ id: 'false',
452
+ value: 'false',
453
+ label: 'False',
454
+ },
455
+ ],
456
+ },
457
+ 'chat.is_muted': {
458
+ text: 'Chat is muted',
459
+ type: 'boolean',
460
+ filters: ['EQ', 'NEQ'],
461
+ value: [
462
+ {
463
+ id: 'true',
464
+ value: 'true',
465
+ label: 'True',
466
+ },
467
+ {
468
+ id: 'false',
469
+ value: 'false',
470
+ label: 'False',
471
+ },
472
+ ],
473
+ },
474
+ 'chat.is_exited': {
475
+ text: 'Chat is exited',
476
+ type: 'boolean',
477
+ filters: ['EQ', 'NEQ'],
478
+ value: [
479
+ {
480
+ id: 'true',
481
+ value: 'true',
482
+ label: 'True',
483
+ },
484
+ {
485
+ id: 'false',
486
+ value: 'false',
487
+ label: 'False',
488
+ },
489
+ ],
490
+ },
491
+ // 'chat.is_archived': {
492
+ // text: 'Chat is archived',
493
+ // type: 'boolean',
494
+ // filters: ['EQ', 'NEQ'],
495
+ // value: [
496
+ // {
497
+ // id: 'true',
498
+ // value: 'true',
499
+ // label: 'True',
500
+ // },
501
+ // {
502
+ // id: 'false',
503
+ // value: 'false',
504
+ // label: 'False',
505
+ // },
506
+ // ],
507
+ // },
508
+ 'chat.info_admins_only': {
509
+ text: 'Chat Info Admins Only',
510
+ type: 'boolean',
511
+ filters: ['EQ', 'NEQ'],
512
+ value: [
513
+ {
514
+ id: 'true',
515
+ value: 'true',
516
+ label: 'True',
517
+ },
518
+ {
519
+ id: 'false',
520
+ value: 'false',
521
+ label: 'False',
522
+ },
523
+ ],
524
+ },
525
+ 'chat.has_flagged_messages': {
526
+ text: 'Chat has flagged messages',
527
+ type: 'boolean',
528
+ filters: ['EQ', 'NEQ'],
529
+ value: [
530
+ {
531
+ id: 'true',
532
+ value: 'true',
533
+ label: 'True',
534
+ },
535
+ {
536
+ id: 'false',
537
+ value: 'false',
538
+ label: 'False',
539
+ },
540
+ ],
541
+ },
542
+ 'chat.group_description': {
543
+ text: 'Group Description',
544
+ type: 'string',
545
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
546
+ placeholder: 'e.g. Group description',
547
+ },
548
+ 'chat.custom_properties': {
549
+ text: 'Chat Custom Properties',
550
+ type: 'dropdown',
551
+ value: 'org.custom_properties',
552
+ filters: ['EQ', 'NEQ'],
553
+ hidden: true,
554
+ },
555
+ 'chat.created_at': {
556
+ text: 'Chat Created At',
557
+ type: 'day-time',
558
+ filters: ['LT', 'LTE', 'GT', 'GTE', 'IS'],
559
+ },
386
560
  };
387
561
 
388
562
  export const TicketVariableNameMap: Record<
@@ -393,6 +567,7 @@ export const TicketVariableNameMap: Record<
393
567
  text: 'Ticket Subject',
394
568
  type: 'string',
395
569
  filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
570
+ placeholder: 'e.g. Test ticket',
396
571
  },
397
572
  'ticket.status': {
398
573
  text: 'Ticket Status',
@@ -420,7 +595,7 @@ export const TicketVariableNameMap: Record<
420
595
  text: 'Ticket Assignee',
421
596
  type: 'dropdown',
422
597
  value: 'org.members',
423
- filters: ['EQ', 'NEQ'],
598
+ filters: ['EQ', 'NEQ', "KNOWN", "NKNOWN"],
424
599
  },
425
600
  'ticket.labels': {
426
601
  text: 'Ticket Labels',
@@ -441,21 +616,39 @@ export const TicketVariableNameMap: Record<
441
616
  },
442
617
  'ticket.due_date': {
443
618
  text: 'Ticket Due Date',
444
- type: 'date',
445
- filters: ['LT', 'LTE', 'GT', 'GTE'],
619
+ type: 'string',
620
+ filters: ['KNOWN', 'NKNOWN'],
621
+ },
622
+ 'ticket.ticket_id': {
623
+ text: 'Ticket ID',
624
+ type: 'string',
625
+ filters: ['EQ', 'NEQ'],
626
+ hidden: true,
627
+ },
628
+ 'ticket.org_id': {
629
+ text: 'Org ID',
630
+ type: 'string',
631
+ filters: ['EQ', 'NEQ'],
632
+ hidden: true,
446
633
  },
447
- 'ticket.assigned_by': {
448
- text: 'Ticket assignee',
634
+ 'ticket.custom_properties': {
635
+ text: 'Ticket Custom Properties',
449
636
  type: 'dropdown',
450
- value: 'org.members',
637
+ value: 'org.custom_properties',
451
638
  filters: ['EQ', 'NEQ'],
639
+ hidden: true,
452
640
  },
453
- "ticket.ticket_id": {
454
- text: 'Ticket ID',
641
+ 'ticket.created_at': {
642
+ text: 'Ticket Created At',
643
+ type: 'day-time',
644
+ filters: ['LT', 'LTE', 'GT', 'GTE'],
645
+ },
646
+ 'ticket.chat_id': {
647
+ text: 'Chat ID',
455
648
  type: 'string',
456
649
  filters: ['EQ', 'NEQ'],
457
- hidden: true
458
- }
650
+ hidden: true,
651
+ },
459
652
  };
460
653
 
461
654
  export const ReactionVariableNameMap: Record<
@@ -466,30 +659,32 @@ export const ReactionVariableNameMap: Record<
466
659
  text: 'Reaction',
467
660
  type: 'string',
468
661
  filters: ['EQ', 'NEQ'],
662
+ placeholder: 'e.g. 👍',
469
663
  },
470
664
  'reaction.sender_id': {
471
665
  text: 'Reaction Sender Phone',
472
666
  type: 'string',
473
667
  filters: ['EQ', 'NEQ'],
668
+ placeholder: 'e.g. 919876543210@c.us'
474
669
  },
475
670
  'reaction.message_id': {
476
671
  text: 'Reaction Message ID',
477
672
  type: 'string',
478
673
  filters: ['EQ', 'NEQ'],
479
- hidden: true
674
+ hidden: true,
480
675
  },
481
- "reaction.chat_id": {
676
+ 'reaction.chat_id': {
482
677
  text: 'Chat ID',
483
678
  type: 'string',
484
679
  filters: ['EQ', 'NEQ'],
485
- hidden: true
680
+ hidden: true,
486
681
  },
487
- "reaction.reaction_id": {
682
+ 'reaction.reaction_id': {
488
683
  text: 'Reaction ID',
489
684
  type: 'string',
490
685
  filters: ['EQ', 'NEQ'],
491
- hidden: true
492
- }
686
+ hidden: true,
687
+ },
493
688
  };
494
689
 
495
690
  export enum FilterConditionMap {
@@ -638,7 +833,7 @@ export type ReplyToMessageAction = {
638
833
  type: 'image' | 'video' | 'audio' | 'document';
639
834
  name: string;
640
835
  };
641
- };
836
+ };
642
837
  };
643
838
 
644
839
  export type UpdateCustomPropertyAction = {
@@ -766,7 +961,14 @@ export const ActionNameMap: Record<
766
961
  string,
767
962
  {
768
963
  id: string;
769
- type: 'text' | 'dropdown' | 'editor' | 'date' | 'file' | 'textarea' | 'dynamic';
964
+ type:
965
+ | 'text'
966
+ | 'dropdown'
967
+ | 'editor'
968
+ | 'date'
969
+ | 'file'
970
+ | 'textarea'
971
+ | 'dynamic';
770
972
  value:
771
973
  | 'ticket.labels'
772
974
  | 'org.members'
@@ -814,6 +1016,7 @@ export const ActionNameMap: Record<
814
1016
  'ticket.created',
815
1017
  'reaction.added',
816
1018
  'message.flagged',
1019
+ 'chat.label.updated'
817
1020
  ],
818
1021
  },
819
1022
  reply_to_message: {
@@ -862,6 +1065,7 @@ export const ActionNameMap: Record<
862
1065
  'ticket.created',
863
1066
  'reaction.added',
864
1067
  'message.flagged',
1068
+ 'chat.label.updated'
865
1069
  ],
866
1070
  },
867
1071
  create_ticket: {
@@ -899,7 +1103,6 @@ export const ActionNameMap: Record<
899
1103
  validTriggers: [
900
1104
  'message.created',
901
1105
  'message.updated',
902
- 'chat.created',
903
1106
  'reaction.added',
904
1107
  'message.flagged',
905
1108
  ],
@@ -925,8 +1128,8 @@ export const ActionNameMap: Record<
925
1128
  title: 'Assign Ticket',
926
1129
  description: 'Assign a ticket',
927
1130
  inputs: {
928
- assignee: {
929
- id: 'assignee',
1131
+ email: {
1132
+ id: 'email',
930
1133
  type: 'dropdown',
931
1134
  value: 'org.members',
932
1135
  label: 'Assignee',
@@ -968,6 +1171,7 @@ export const ActionNameMap: Record<
968
1171
  'ticket.updated',
969
1172
  'ticket.created',
970
1173
  'reaction.added',
1174
+ 'chat.label.updated'
971
1175
  ],
972
1176
  },
973
1177
  add_ticket_label: {
@@ -1005,20 +1209,20 @@ export const ActionNameMap: Record<
1005
1209
  placeholder: 'Select property',
1006
1210
  },
1007
1211
  value: {
1008
- id: 'value',
1212
+ id: 'property_id',
1009
1213
  type: 'dynamic',
1010
1214
  label: 'Value',
1011
1215
  placeholder: 'Enter value',
1012
1216
  value: 'custom_property_values',
1013
1217
  },
1014
- }
1218
+ },
1015
1219
  },
1016
1220
  assign_chat: {
1017
1221
  title: 'Assign Chat',
1018
1222
  description: 'Assign a chat',
1019
1223
  inputs: {
1020
- assignee: {
1021
- id: 'assignee',
1224
+ email: {
1225
+ id: 'email',
1022
1226
  type: 'dropdown',
1023
1227
  value: 'org.members',
1024
1228
  label: 'Assignee',
@@ -1032,6 +1236,7 @@ export const ActionNameMap: Record<
1032
1236
  'ticket.updated',
1033
1237
  'ticket.created',
1034
1238
  'reaction.added',
1239
+ 'chat.label.updated'
1035
1240
  ],
1036
1241
  },
1037
1242
  forward_message: {
@@ -1045,13 +1250,13 @@ export const ActionNameMap: Record<
1045
1250
  label: 'Chat',
1046
1251
  placeholder: 'Select chat',
1047
1252
  },
1048
- prefix: {
1049
- id: 'prefix',
1050
- type: 'editor',
1051
- label: 'Prefix',
1052
- placeholder: 'Enter prefix',
1053
- value: null,
1054
- },
1253
+ // prefix: {
1254
+ // id: 'prefix',
1255
+ // type: 'editor',
1256
+ // label: 'Prefix',
1257
+ // placeholder: 'Enter prefix',
1258
+ // value: null,
1259
+ // },
1055
1260
  },
1056
1261
  validTriggers: [
1057
1262
  'message.created',
@@ -1097,6 +1302,7 @@ export const ActionNameMap: Record<
1097
1302
  'ticket.created',
1098
1303
  'reaction.added',
1099
1304
  'message.flagged',
1305
+ 'chat.label.updated'
1100
1306
  ],
1101
1307
  },
1102
1308
  };