@periskope/types 0.6.13-7.3 → 0.6.13-7.5

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.
@@ -3,15 +3,15 @@ import { Tables } from './supabase.types';
3
3
  export type AppendTypes<T extends object, O extends string> = {
4
4
  [K in keyof T & string as `${K}${O}${keyof T[K] & string}`]: T[K][keyof T[K]];
5
5
  };
6
- export type TicketVariablesType = Merge<Pick<Tables<'tbl_chat_tickets'>, 'assigned_by' | 'assignee' | 'status' | 'subject' | 'is_deleted' | 'priority' | 'raised_by' | 'due_date'>, {
6
+ export type TicketVariablesType = Merge<Pick<Tables<'tbl_chat_tickets'>, 'assigned_by' | 'assignee' | 'status' | 'subject' | 'is_deleted' | 'priority' | 'raised_by' | 'due_date' | 'ticket_id'>, {
7
7
  labels: string[];
8
8
  }>;
9
- export type MessageVariablesType = Pick<Tables<'tbl_chat_messages'>, 'body' | 'sender_phone' | 'timestamp' | 'flag_status' | 'has_quoted_msg' | 'media' | 'performed_by'>;
9
+ export type MessageVariablesType = Pick<Tables<'tbl_chat_messages'>, 'body' | 'sender_phone' | 'timestamp' | 'flag_status' | 'has_quoted_msg' | 'media' | 'performed_by' | 'message_id' | 'chat_id'>;
10
10
  export type SenderVariablesType = Merge<Pick<Tables<'tbl_contacts'>, 'is_business' | 'is_enterprise' | 'is_internal' | 'contact_name' | 'contact_id'>, {
11
11
  labels: string[];
12
12
  }>;
13
13
  export type ReactionVariablesType = Pick<Tables<'tbl_chat_reactions'>, 'reaction' | 'sender_id'>;
14
- export type ChatVariablesType = Merge<Pick<Tables<'view_chats'>, 'assigned_to' | 'chat_name' | 'org_phone' | 'chat_type'>, {
14
+ export type ChatVariablesType = Merge<Pick<Tables<'view_chats'>, 'assigned_to' | 'chat_name' | 'org_phone' | 'chat_type' | 'chat_id'>, {
15
15
  members: string[];
16
16
  labels: string[];
17
17
  }>;
@@ -82,6 +82,7 @@ export type VariableNameValueType = {
82
82
  label: string;
83
83
  }[] | null;
84
84
  filters: Filter['condition'][];
85
+ hidden?: boolean;
85
86
  };
86
87
  export declare const MessageVariableNameMap: Record<keyof AppendTypes<{
87
88
  message: MessageVariablesType;
@@ -121,6 +122,7 @@ export interface Conditions {
121
122
  condition: 'allOf' | 'anyOf' | 'noneOf';
122
123
  variables: string[];
123
124
  delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
125
+ org_phones: string[];
124
126
  }
125
127
  export type SendMessageAction = {
126
128
  id: string;
@@ -218,16 +220,32 @@ export type SendEmailAction = {
218
220
  body: string;
219
221
  };
220
222
  };
221
- export type Action = SendMessageAction | NotifyHttpAction | CreateTicketAction | FlagMessageAction | AssignTicketAction | CloseTicketAction | AddChatLabelAction | AddTicketLabelAction | AssignChatAction | ForwardMessageAction | SendEmailAction;
223
+ export type ReplyToMessage = {
224
+ id: string;
225
+ type: 'reply_to_message';
226
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
227
+ metadata: {
228
+ message: string;
229
+ media?: {
230
+ url: string;
231
+ type: 'image' | 'video' | 'audio' | 'document';
232
+ name: string;
233
+ };
234
+ };
235
+ };
236
+ export type Action = SendMessageAction | NotifyHttpAction | CreateTicketAction | FlagMessageAction | AssignTicketAction | CloseTicketAction | AddChatLabelAction | AddTicketLabelAction | AssignChatAction | ForwardMessageAction | SendEmailAction | ReplyToMessage;
222
237
  export declare const isSendMessageAction: (action: Action) => action is SendMessageAction;
223
238
  export type Rule = OverrideProperties<Tables<'tbl_automation_rules'>, {
224
239
  actions: Action[];
225
240
  conditions: Conditions;
226
- trigger: 'message.created' | 'message.updated' | 'chat.created' | 'ticket.updated' | 'ticket.created' | 'reaction.created' | 'reaction.updated';
241
+ trigger: 'message.created' | 'message.updated' | 'chat.created' | 'ticket.updated' | 'ticket.created' | 'reaction.added' | 'chat.label.updated' | 'message.flagged';
227
242
  }>;
228
243
  export declare const RuleNameMap: Record<Rule['trigger'], {
229
244
  title: string;
230
245
  description: string;
246
+ base_conditions: {
247
+ org_phone: boolean;
248
+ };
231
249
  }>;
232
250
  export declare const ActionNameMap: Record<Action['type'], {
233
251
  title: string;
@@ -100,6 +100,18 @@ exports.MessageVariableNameMap = {
100
100
  value: 'org.members',
101
101
  filters: ['EQ', 'NEQ'],
102
102
  },
103
+ "message.chat_id": {
104
+ text: 'Chat ID',
105
+ type: 'string',
106
+ filters: ['EQ', 'NEQ'],
107
+ hidden: true
108
+ },
109
+ "message.message_id": {
110
+ text: 'Message ID',
111
+ type: 'string',
112
+ filters: ['EQ', 'NEQ'],
113
+ hidden: true
114
+ }
103
115
  };
104
116
  exports.SenderVariableNameMap = {
105
117
  'sender.is_business': {
@@ -171,8 +183,14 @@ exports.ChatVariableNameMap = {
171
183
  text: 'Chat Labels',
172
184
  type: 'dropdown',
173
185
  value: 'org.labels',
174
- filters: ['EQ', 'NEQ'],
186
+ filters: ['CONTAINS', 'NCONTAINS'],
175
187
  },
188
+ "chat.chat_id": {
189
+ text: 'Chat ID',
190
+ type: 'string',
191
+ filters: ['EQ', 'NEQ'],
192
+ hidden: true
193
+ }
176
194
  };
177
195
  exports.TicketVariableNameMap = {
178
196
  'ticket.subject': {
@@ -236,6 +254,12 @@ exports.TicketVariableNameMap = {
236
254
  value: 'org.members',
237
255
  filters: ['EQ', 'NEQ'],
238
256
  },
257
+ "ticket.ticket_id": {
258
+ text: 'Ticket ID',
259
+ type: 'string',
260
+ filters: ['EQ', 'NEQ'],
261
+ hidden: true
262
+ }
239
263
  };
240
264
  exports.ReactionVariableNameMap = {
241
265
  'reaction.reaction': {
@@ -270,32 +294,60 @@ const isSendMessageAction = (action) => {
270
294
  exports.isSendMessageAction = isSendMessageAction;
271
295
  exports.RuleNameMap = {
272
296
  'message.created': {
273
- title: 'New Message Sent/Received',
297
+ title: 'New Message Received',
274
298
  description: 'When a new message is sent or received',
275
- },
276
- 'message.updated': {
277
- title: 'Message Updated',
278
- description: 'When a message is updated',
299
+ base_conditions: {
300
+ org_phone: true,
301
+ },
279
302
  },
280
303
  'chat.created': {
281
304
  title: 'New Chat Created',
282
305
  description: 'When a new chat is created',
306
+ base_conditions: {
307
+ org_phone: true,
308
+ },
283
309
  },
284
310
  'ticket.created': {
285
311
  title: 'New Ticket Created',
286
312
  description: 'When a new ticket is created',
313
+ base_conditions: {
314
+ org_phone: false,
315
+ },
316
+ },
317
+ 'reaction.added': {
318
+ title: 'New Reaction Added',
319
+ description: 'When a reaction is added on a message',
320
+ base_conditions: {
321
+ org_phone: true,
322
+ },
323
+ },
324
+ 'message.updated': {
325
+ title: 'Message Updated',
326
+ description: 'When a message is updated',
327
+ base_conditions: {
328
+ org_phone: true,
329
+ },
287
330
  },
288
331
  'ticket.updated': {
289
332
  title: 'Ticket Updated',
290
333
  description: 'When a ticket is updated',
334
+ base_conditions: {
335
+ org_phone: false,
336
+ },
291
337
  },
292
- 'reaction.created': {
293
- title: 'Reaction Created',
294
- description: 'When a reaction is created',
338
+ 'chat.label.updated': {
339
+ title: 'Chat Label Added/Removed',
340
+ description: 'When labels on chats are updated',
341
+ base_conditions: {
342
+ org_phone: false,
343
+ },
295
344
  },
296
- 'reaction.updated': {
297
- title: 'Reaction Updated',
298
- description: 'When a reaction is updated',
345
+ 'message.flagged': {
346
+ title: 'Message Flagged',
347
+ description: 'When a message is flagged',
348
+ base_conditions: {
349
+ org_phone: true,
350
+ },
299
351
  },
300
352
  };
301
353
  exports.ActionNameMap = {
@@ -324,8 +376,34 @@ exports.ActionNameMap = {
324
376
  'chat.created',
325
377
  'ticket.updated',
326
378
  'ticket.created',
327
- 'reaction.created',
328
- 'reaction.updated',
379
+ 'reaction.added',
380
+ 'message.flagged',
381
+ ],
382
+ },
383
+ reply_to_message: {
384
+ title: 'Reply to message',
385
+ description: 'Send a message with the quoted message',
386
+ inputs: {
387
+ message: {
388
+ id: 'message',
389
+ type: 'editor',
390
+ label: 'Message',
391
+ placeholder: 'Enter message',
392
+ value: null,
393
+ },
394
+ media: {
395
+ id: 'media',
396
+ type: 'file',
397
+ label: 'Media',
398
+ placeholder: 'Upload media',
399
+ value: null,
400
+ },
401
+ },
402
+ validTriggers: [
403
+ 'message.created',
404
+ 'message.updated',
405
+ 'reaction.added',
406
+ 'message.flagged',
329
407
  ],
330
408
  },
331
409
  notify_http: {
@@ -346,8 +424,8 @@ exports.ActionNameMap = {
346
424
  'chat.created',
347
425
  'ticket.updated',
348
426
  'ticket.created',
349
- 'reaction.created',
350
- 'reaction.updated',
427
+ 'reaction.added',
428
+ 'message.flagged',
351
429
  ],
352
430
  },
353
431
  create_ticket: {
@@ -386,8 +464,8 @@ exports.ActionNameMap = {
386
464
  'message.created',
387
465
  'message.updated',
388
466
  'chat.created',
389
- 'reaction.created',
390
- 'reaction.updated',
467
+ 'reaction.added',
468
+ 'message.flagged',
391
469
  ],
392
470
  },
393
471
  flag_message: {
@@ -405,12 +483,7 @@ exports.ActionNameMap = {
405
483
  placeholder: 'Select flag',
406
484
  },
407
485
  },
408
- validTriggers: [
409
- 'message.created',
410
- 'message.updated',
411
- 'reaction.created',
412
- 'reaction.updated',
413
- ],
486
+ validTriggers: ['message.created', 'message.updated', 'reaction.added'],
414
487
  },
415
488
  assign_ticket: {
416
489
  title: 'Assign Ticket',
@@ -458,8 +531,7 @@ exports.ActionNameMap = {
458
531
  'chat.created',
459
532
  'ticket.updated',
460
533
  'ticket.created',
461
- 'reaction.created',
462
- 'reaction.updated',
534
+ 'reaction.added',
463
535
  ],
464
536
  },
465
537
  add_ticket_label: {
@@ -494,8 +566,7 @@ exports.ActionNameMap = {
494
566
  'chat.created',
495
567
  'ticket.updated',
496
568
  'ticket.created',
497
- 'reaction.created',
498
- 'reaction.updated',
569
+ 'reaction.added',
499
570
  ],
500
571
  },
501
572
  forward_message: {
@@ -523,8 +594,8 @@ exports.ActionNameMap = {
523
594
  'chat.created',
524
595
  'ticket.updated',
525
596
  'ticket.created',
526
- 'reaction.created',
527
- 'reaction.updated',
597
+ 'reaction.added',
598
+ 'message.flagged',
528
599
  ],
529
600
  },
530
601
  send_email: {
@@ -559,8 +630,8 @@ exports.ActionNameMap = {
559
630
  'chat.created',
560
631
  'ticket.updated',
561
632
  'ticket.created',
562
- 'reaction.created',
563
- 'reaction.updated',
633
+ 'reaction.added',
634
+ 'message.flagged',
564
635
  ],
565
636
  },
566
637
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@periskope/types",
3
- "version": "0.6.137.3",
3
+ "version": "0.6.137.5",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/rules.types.ts CHANGED
@@ -16,6 +16,7 @@ export type TicketVariablesType = Merge<
16
16
  | 'priority'
17
17
  | 'raised_by'
18
18
  | 'due_date'
19
+ | 'ticket_id'
19
20
  >,
20
21
  {
21
22
  labels: string[];
@@ -31,6 +32,8 @@ export type MessageVariablesType = Pick<
31
32
  | 'has_quoted_msg'
32
33
  | 'media'
33
34
  | 'performed_by'
35
+ | 'message_id'
36
+ | 'chat_id'
34
37
  >;
35
38
 
36
39
  export type SenderVariablesType = Merge<
@@ -55,7 +58,7 @@ export type ReactionVariablesType = Pick<
55
58
  export type ChatVariablesType = Merge<
56
59
  Pick<
57
60
  Tables<'view_chats'>,
58
- 'assigned_to' | 'chat_name' | 'org_phone' | 'chat_type'
61
+ 'assigned_to' | 'chat_name' | 'org_phone' | 'chat_type' | 'chat_id'
59
62
  >,
60
63
  {
61
64
  members: string[];
@@ -246,6 +249,7 @@ export type VariableNameValueType = {
246
249
  }[]
247
250
  | null;
248
251
  filters: Filter['condition'][];
252
+ hidden?: boolean;
249
253
  };
250
254
 
251
255
  export const MessageVariableNameMap: Record<
@@ -288,6 +292,18 @@ export const MessageVariableNameMap: Record<
288
292
  value: 'org.members',
289
293
  filters: ['EQ', 'NEQ'],
290
294
  },
295
+ "message.chat_id":{
296
+ text: 'Chat ID',
297
+ type: 'string',
298
+ filters: ['EQ', 'NEQ'],
299
+ hidden: true
300
+ },
301
+ "message.message_id":{
302
+ text: 'Message ID',
303
+ type: 'string',
304
+ filters: ['EQ', 'NEQ'],
305
+ hidden: true
306
+ }
291
307
  };
292
308
 
293
309
  export const SenderVariableNameMap: Record<
@@ -367,8 +383,14 @@ export const ChatVariableNameMap: Record<
367
383
  text: 'Chat Labels',
368
384
  type: 'dropdown',
369
385
  value: 'org.labels',
370
- filters: ['EQ', 'NEQ'],
386
+ filters: ['CONTAINS', 'NCONTAINS'],
371
387
  },
388
+ "chat.chat_id": {
389
+ text: 'Chat ID',
390
+ type: 'string',
391
+ filters: ['EQ', 'NEQ'],
392
+ hidden: true
393
+ }
372
394
  };
373
395
 
374
396
  export const TicketVariableNameMap: Record<
@@ -436,6 +458,12 @@ export const TicketVariableNameMap: Record<
436
458
  value: 'org.members',
437
459
  filters: ['EQ', 'NEQ'],
438
460
  },
461
+ "ticket.ticket_id": {
462
+ text: 'Ticket ID',
463
+ type: 'string',
464
+ filters: ['EQ', 'NEQ'],
465
+ hidden: true
466
+ }
439
467
  };
440
468
 
441
469
  export const ReactionVariableNameMap: Record<
@@ -479,6 +507,7 @@ export interface Conditions {
479
507
  condition: 'allOf' | 'anyOf' | 'noneOf';
480
508
  variables: string[];
481
509
  delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
510
+ org_phones: string[];
482
511
  }
483
512
 
484
513
  export type SendMessageAction = {
@@ -588,6 +617,20 @@ export type SendEmailAction = {
588
617
  };
589
618
  };
590
619
 
620
+ export type ReplyToMessage = {
621
+ id: string;
622
+ type: 'reply_to_message';
623
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
624
+ metadata: {
625
+ message: string;
626
+ media?: {
627
+ url: string;
628
+ type: 'image' | 'video' | 'audio' | 'document';
629
+ name: string;
630
+ };
631
+ };
632
+ };
633
+
591
634
  export type Action =
592
635
  | SendMessageAction
593
636
  | NotifyHttpAction
@@ -599,7 +642,8 @@ export type Action =
599
642
  | AddTicketLabelAction
600
643
  | AssignChatAction
601
644
  | ForwardMessageAction
602
- | SendEmailAction;
645
+ | SendEmailAction
646
+ | ReplyToMessage;
603
647
 
604
648
  export const isSendMessageAction = (
605
649
  action: Action
@@ -618,8 +662,9 @@ export type Rule = OverrideProperties<
618
662
  | 'chat.created'
619
663
  | 'ticket.updated'
620
664
  | 'ticket.created'
621
- | 'reaction.created'
622
- | 'reaction.updated';
665
+ | 'reaction.added'
666
+ | 'chat.label.updated'
667
+ | 'message.flagged';
623
668
  }
624
669
  >;
625
670
 
@@ -628,35 +673,66 @@ export const RuleNameMap: Record<
628
673
  {
629
674
  title: string;
630
675
  description: string;
676
+ base_conditions: {
677
+ org_phone: boolean;
678
+ };
631
679
  }
632
680
  > = {
633
681
  'message.created': {
634
- title: 'New Message Sent/Received',
682
+ title: 'New Message Received',
635
683
  description: 'When a new message is sent or received',
636
- },
637
- 'message.updated': {
638
- title: 'Message Updated',
639
- description: 'When a message is updated',
684
+ base_conditions: {
685
+ org_phone: true,
686
+ },
640
687
  },
641
688
  'chat.created': {
642
689
  title: 'New Chat Created',
643
690
  description: 'When a new chat is created',
691
+ base_conditions: {
692
+ org_phone: true,
693
+ },
644
694
  },
645
695
  'ticket.created': {
646
696
  title: 'New Ticket Created',
647
697
  description: 'When a new ticket is created',
698
+ base_conditions: {
699
+ org_phone: false,
700
+ },
701
+ },
702
+ 'reaction.added': {
703
+ title: 'New Reaction Added',
704
+ description: 'When a reaction is added on a message',
705
+ base_conditions: {
706
+ org_phone: true,
707
+ },
708
+ },
709
+ 'message.updated': {
710
+ title: 'Message Updated',
711
+ description: 'When a message is updated',
712
+ base_conditions: {
713
+ org_phone: true,
714
+ },
648
715
  },
649
716
  'ticket.updated': {
650
717
  title: 'Ticket Updated',
651
718
  description: 'When a ticket is updated',
719
+ base_conditions: {
720
+ org_phone: false,
721
+ },
652
722
  },
653
- 'reaction.created': {
654
- title: 'Reaction Created',
655
- description: 'When a reaction is created',
723
+ 'chat.label.updated': {
724
+ title: 'Chat Label Added/Removed',
725
+ description: 'When labels on chats are updated',
726
+ base_conditions: {
727
+ org_phone: false,
728
+ },
656
729
  },
657
- 'reaction.updated': {
658
- title: 'Reaction Updated',
659
- description: 'When a reaction is updated',
730
+ 'message.flagged': {
731
+ title: 'Message Flagged',
732
+ description: 'When a message is flagged',
733
+ base_conditions: {
734
+ org_phone: true,
735
+ },
660
736
  },
661
737
  };
662
738
 
@@ -713,8 +789,34 @@ export const ActionNameMap: Record<
713
789
  'chat.created',
714
790
  'ticket.updated',
715
791
  'ticket.created',
716
- 'reaction.created',
717
- 'reaction.updated',
792
+ 'reaction.added',
793
+ 'message.flagged',
794
+ ],
795
+ },
796
+ reply_to_message: {
797
+ title: 'Reply to message',
798
+ description: 'Send a message with the quoted message',
799
+ inputs: {
800
+ message: {
801
+ id: 'message',
802
+ type: 'editor',
803
+ label: 'Message',
804
+ placeholder: 'Enter message',
805
+ value: null,
806
+ },
807
+ media: {
808
+ id: 'media',
809
+ type: 'file',
810
+ label: 'Media',
811
+ placeholder: 'Upload media',
812
+ value: null,
813
+ },
814
+ },
815
+ validTriggers: [
816
+ 'message.created',
817
+ 'message.updated',
818
+ 'reaction.added',
819
+ 'message.flagged',
718
820
  ],
719
821
  },
720
822
  notify_http: {
@@ -735,8 +837,8 @@ export const ActionNameMap: Record<
735
837
  'chat.created',
736
838
  'ticket.updated',
737
839
  'ticket.created',
738
- 'reaction.created',
739
- 'reaction.updated',
840
+ 'reaction.added',
841
+ 'message.flagged',
740
842
  ],
741
843
  },
742
844
  create_ticket: {
@@ -775,8 +877,8 @@ export const ActionNameMap: Record<
775
877
  'message.created',
776
878
  'message.updated',
777
879
  'chat.created',
778
- 'reaction.created',
779
- 'reaction.updated',
880
+ 'reaction.added',
881
+ 'message.flagged',
780
882
  ],
781
883
  },
782
884
  flag_message: {
@@ -794,12 +896,7 @@ export const ActionNameMap: Record<
794
896
  placeholder: 'Select flag',
795
897
  },
796
898
  },
797
- validTriggers: [
798
- 'message.created',
799
- 'message.updated',
800
- 'reaction.created',
801
- 'reaction.updated',
802
- ],
899
+ validTriggers: ['message.created', 'message.updated', 'reaction.added'],
803
900
  },
804
901
  assign_ticket: {
805
902
  title: 'Assign Ticket',
@@ -847,8 +944,7 @@ export const ActionNameMap: Record<
847
944
  'chat.created',
848
945
  'ticket.updated',
849
946
  'ticket.created',
850
- 'reaction.created',
851
- 'reaction.updated',
947
+ 'reaction.added',
852
948
  ],
853
949
  },
854
950
  add_ticket_label: {
@@ -883,8 +979,7 @@ export const ActionNameMap: Record<
883
979
  'chat.created',
884
980
  'ticket.updated',
885
981
  'ticket.created',
886
- 'reaction.created',
887
- 'reaction.updated',
982
+ 'reaction.added',
888
983
  ],
889
984
  },
890
985
  forward_message: {
@@ -912,8 +1007,8 @@ export const ActionNameMap: Record<
912
1007
  'chat.created',
913
1008
  'ticket.updated',
914
1009
  'ticket.created',
915
- 'reaction.created',
916
- 'reaction.updated',
1010
+ 'reaction.added',
1011
+ 'message.flagged',
917
1012
  ],
918
1013
  },
919
1014
  send_email: {
@@ -948,8 +1043,8 @@ export const ActionNameMap: Record<
948
1043
  'chat.created',
949
1044
  'ticket.updated',
950
1045
  'ticket.created',
951
- 'reaction.created',
952
- 'reaction.updated',
1046
+ 'reaction.added',
1047
+ 'message.flagged',
953
1048
  ],
954
1049
  },
955
1050
  };