@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.
@@ -1,20 +1,14 @@
1
1
  import { Merge, OverrideProperties } from 'type-fest';
2
2
  import { Tables } from './supabase.types';
3
+ import { ChatRuleInfoType, MessageRuleInfoType, ReactionRuleInfoType, SenderRuleInfoType, TicketRuleInfoType } from './types';
3
4
  export type AppendTypes<T extends object, O extends string> = {
4
5
  [K in keyof T & string as `${K}${O}${keyof T[K] & string}`]: T[K][keyof T[K]];
5
6
  };
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
- labels: string[];
8
- }>;
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
- export type SenderVariablesType = Merge<Pick<Tables<'tbl_contacts'>, 'is_business' | 'is_enterprise' | 'is_internal' | 'contact_name' | 'contact_id'>, {
11
- labels: string[];
12
- }>;
13
- export type ReactionVariablesType = Pick<Tables<'tbl_chat_reactions'>, 'reaction' | 'sender_id' | 'reaction_id' | 'message_id' | 'chat_id'>;
14
- export type ChatVariablesType = Merge<Pick<Tables<'view_chats'>, 'assigned_to' | 'chat_name' | 'org_phone' | 'chat_type' | 'chat_id'>, {
15
- members: string[];
16
- labels: string[];
17
- }>;
7
+ export type TicketVariablesType = TicketRuleInfoType['ticket'];
8
+ export type MessageVariablesType = MessageRuleInfoType['message'];
9
+ export type SenderVariablesType = SenderRuleInfoType;
10
+ export type ReactionVariablesType = ReactionRuleInfoType['reaction'];
11
+ export type ChatVariablesType = ChatRuleInfoType;
18
12
  export type MessageRulesInfoType = Merge<AppendTypes<{
19
13
  message: MessageVariablesType;
20
14
  sender: SenderVariablesType;
@@ -40,18 +34,15 @@ export type ReactionRulesInfoType = Merge<AppendTypes<{
40
34
  reaction: ReactionVariablesType;
41
35
  message: MessageVariablesType;
42
36
  sender: SenderVariablesType;
43
- ticket: TicketVariablesType;
44
37
  chat: ChatVariablesType;
45
38
  }, '.'>, {
46
39
  rule: Tables<'tbl_automation_rules'>[];
47
40
  id: 'reaction.reaction_id';
48
- type: `reaction.${'created' | 'updated'}`;
41
+ type: `reaction.added`;
49
42
  org_id: string;
50
43
  }>;
51
44
  export type ChatRulesInfoType = Merge<AppendTypes<{
52
45
  chat: ChatVariablesType;
53
- message: MessageVariablesType;
54
- sender: SenderVariablesType;
55
46
  }, '.'>, {
56
47
  rule: Tables<'tbl_automation_rules'>[];
57
48
  id: 'chat.chat_id';
@@ -73,7 +64,7 @@ export declare const FilterNameMap: Record<Filter['condition'], {
73
64
  }>;
74
65
  export type VariableNameValueType = {
75
66
  text: string;
76
- type: 'string' | 'date' | 'boolean' | 'dropdown';
67
+ type: 'string' | 'time' | 'boolean' | 'dropdown' | 'day-time' | 'number';
77
68
  value?: string | {
78
69
  id: string;
79
70
  value: string;
@@ -81,6 +72,7 @@ export type VariableNameValueType = {
81
72
  }[] | null;
82
73
  filters: Filter['condition'][];
83
74
  hidden?: boolean;
75
+ placeholder?: string;
84
76
  };
85
77
  export declare const MessageVariableNameMap: Record<keyof AppendTypes<{
86
78
  message: MessageVariablesType;
@@ -64,15 +64,17 @@ exports.MessageVariableNameMap = {
64
64
  text: 'Message Body',
65
65
  type: 'string',
66
66
  filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
67
+ placeholder: 'e.g. Test message',
67
68
  },
68
69
  'message.sender_phone': {
69
70
  text: 'Message Sender Phone',
70
71
  type: 'string',
71
72
  filters: ['EQ', 'NEQ'],
73
+ placeholder: 'e.g. 919876543210@c.us',
72
74
  },
73
75
  'message.timestamp': {
74
76
  text: 'Message Timestamp',
75
- type: 'date',
77
+ type: 'day-time',
76
78
  filters: ['LT', 'LTE', 'GT', 'GTE', 'IS'],
77
79
  },
78
80
  'message.flag_status': {
@@ -96,28 +98,67 @@ exports.MessageVariableNameMap = {
96
98
  value: 'org.members',
97
99
  filters: ['EQ', 'NEQ'],
98
100
  },
99
- "message.chat_id": {
101
+ 'message.chat_id': {
100
102
  text: 'Chat ID',
101
103
  type: 'string',
102
104
  filters: ['EQ', 'NEQ'],
103
- hidden: true
105
+ hidden: true,
104
106
  },
105
- "message.message_id": {
107
+ 'message.message_id': {
106
108
  text: 'Message ID',
107
109
  type: 'string',
108
110
  filters: ['EQ', 'NEQ'],
109
- hidden: true
110
- }
111
+ hidden: true,
112
+ },
113
+ 'message.org_phone': {
114
+ text: 'Org Phone',
115
+ type: 'string',
116
+ filters: ['EQ', 'NEQ'],
117
+ hidden: true,
118
+ },
119
+ 'message.org_id': {
120
+ text: 'Org ID',
121
+ type: 'string',
122
+ filters: ['EQ', 'NEQ'],
123
+ hidden: true,
124
+ },
125
+ 'message.message_type': {
126
+ text: 'Message Type',
127
+ type: 'dropdown',
128
+ value: [
129
+ { id: 'text', value: 'text', label: 'Text' },
130
+ { id: 'image', value: 'image', label: 'Image' },
131
+ { id: 'video', value: 'video', label: 'Video' },
132
+ { id: 'audio', value: 'audio', label: 'Audio' },
133
+ { id: 'document', value: 'document', label: 'Document' },
134
+ ],
135
+ filters: ['EQ', 'NEQ'],
136
+ },
137
+ 'message.author': {
138
+ text: 'Message Author',
139
+ type: 'string',
140
+ filters: ['EQ', 'NEQ'],
141
+ hidden: true,
142
+ },
143
+ 'message.ack': {
144
+ text: 'Message acknowledment status',
145
+ type: 'dropdown',
146
+ value: [
147
+ { id: '0', value: '0', label: '0' },
148
+ { id: '1', value: '1', label: '1' },
149
+ { id: '2', value: '2', label: '2' },
150
+ { id: '3', value: '3', label: '3' },
151
+ ],
152
+ filters: ['EQ'],
153
+ },
111
154
  };
112
155
  exports.SenderVariableNameMap = {
113
156
  'sender.is_business': {
114
- // remove
115
157
  text: 'Sender is business',
116
158
  type: 'boolean',
117
159
  filters: ['IS'],
118
160
  },
119
161
  'sender.is_enterprise': {
120
- // remove
121
162
  text: 'Sender is enterprise',
122
163
  type: 'boolean',
123
164
  filters: ['IS'],
@@ -131,11 +172,13 @@ exports.SenderVariableNameMap = {
131
172
  text: 'Sender Name',
132
173
  type: 'string',
133
174
  filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
175
+ placeholder: 'e.g. John Doe',
134
176
  },
135
177
  'sender.contact_id': {
136
178
  text: 'Sender Contact Phone',
137
179
  type: 'string',
138
180
  filters: ['EQ', 'NEQ'],
181
+ placeholder: 'e.g. 919876543210@c.us'
139
182
  },
140
183
  'sender.labels': {
141
184
  text: 'Sender Labels',
@@ -143,6 +186,46 @@ exports.SenderVariableNameMap = {
143
186
  value: 'org.labels',
144
187
  filters: ['EQ', 'NEQ'],
145
188
  },
189
+ 'sender.org_id': {
190
+ text: 'Org ID',
191
+ type: 'string',
192
+ filters: ['EQ', 'NEQ'],
193
+ hidden: true,
194
+ },
195
+ 'sender.is_super_admin': {
196
+ text: 'Sender is super admin',
197
+ type: 'dropdown',
198
+ filters: ['EQ', 'NEQ'],
199
+ value: [
200
+ {
201
+ id: 'true',
202
+ value: 'true',
203
+ label: 'True',
204
+ },
205
+ {
206
+ id: 'false',
207
+ value: 'false',
208
+ label: 'False',
209
+ },
210
+ ],
211
+ },
212
+ 'sender.is_admin': {
213
+ text: 'Sender is admin',
214
+ type: 'dropdown',
215
+ filters: ['EQ', 'NEQ'],
216
+ value: [
217
+ {
218
+ id: 'true',
219
+ value: 'true',
220
+ label: 'True',
221
+ },
222
+ {
223
+ id: 'false',
224
+ value: 'false',
225
+ label: 'False',
226
+ },
227
+ ],
228
+ },
146
229
  };
147
230
  exports.ChatVariableNameMap = {
148
231
  'chat.assigned_to': {
@@ -155,10 +238,12 @@ exports.ChatVariableNameMap = {
155
238
  text: 'Chat Name',
156
239
  type: 'string',
157
240
  filters: ['EQ', 'NEQ'],
241
+ placeholder: 'e.g. Support Chat',
158
242
  },
159
243
  'chat.org_phone': {
160
244
  text: 'Chat Org Phone',
161
- type: 'string',
245
+ type: 'dropdown',
246
+ value: 'org.org_phones',
162
247
  filters: ['EQ', 'NEQ'],
163
248
  },
164
249
  'chat.chat_type': {
@@ -173,7 +258,8 @@ exports.ChatVariableNameMap = {
173
258
  'chat.members': {
174
259
  text: 'Chat Members',
175
260
  type: 'string',
176
- filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
261
+ filters: ['CONTAINS', 'NCONTAINS'],
262
+ placeholder: 'e.g. 919876543210'
177
263
  },
178
264
  'chat.labels': {
179
265
  text: 'Chat Labels',
@@ -181,17 +267,151 @@ exports.ChatVariableNameMap = {
181
267
  value: 'org.labels',
182
268
  filters: ['CONTAINS', 'NCONTAINS'],
183
269
  },
184
- "chat.chat_id": {
270
+ 'chat.chat_id': {
185
271
  text: 'Chat ID',
186
272
  type: 'string',
187
273
  filters: ['EQ', 'NEQ'],
188
- }
274
+ placeholder: 'e.g. 12027747916749@c.us'
275
+ },
276
+ 'chat.chat_org_phones': {
277
+ text: 'Chat Org Phones',
278
+ type: 'dropdown',
279
+ filters: ['CONTAINS', 'NCONTAINS'],
280
+ hidden: true,
281
+ },
282
+ 'chat.org_id': {
283
+ text: 'Org ID',
284
+ type: 'string',
285
+ filters: [],
286
+ hidden: true,
287
+ },
288
+ 'chat.messages_admins_only': {
289
+ text: 'Chat Messages Admins Only',
290
+ type: 'boolean',
291
+ filters: ['EQ', 'NEQ'],
292
+ value: [
293
+ {
294
+ id: 'true',
295
+ value: 'true',
296
+ label: 'True',
297
+ },
298
+ {
299
+ id: 'false',
300
+ value: 'false',
301
+ label: 'False',
302
+ },
303
+ ],
304
+ },
305
+ 'chat.is_muted': {
306
+ text: 'Chat is muted',
307
+ type: 'boolean',
308
+ filters: ['EQ', 'NEQ'],
309
+ value: [
310
+ {
311
+ id: 'true',
312
+ value: 'true',
313
+ label: 'True',
314
+ },
315
+ {
316
+ id: 'false',
317
+ value: 'false',
318
+ label: 'False',
319
+ },
320
+ ],
321
+ },
322
+ 'chat.is_exited': {
323
+ text: 'Chat is exited',
324
+ type: 'boolean',
325
+ filters: ['EQ', 'NEQ'],
326
+ value: [
327
+ {
328
+ id: 'true',
329
+ value: 'true',
330
+ label: 'True',
331
+ },
332
+ {
333
+ id: 'false',
334
+ value: 'false',
335
+ label: 'False',
336
+ },
337
+ ],
338
+ },
339
+ // 'chat.is_archived': {
340
+ // text: 'Chat is archived',
341
+ // type: 'boolean',
342
+ // filters: ['EQ', 'NEQ'],
343
+ // value: [
344
+ // {
345
+ // id: 'true',
346
+ // value: 'true',
347
+ // label: 'True',
348
+ // },
349
+ // {
350
+ // id: 'false',
351
+ // value: 'false',
352
+ // label: 'False',
353
+ // },
354
+ // ],
355
+ // },
356
+ 'chat.info_admins_only': {
357
+ text: 'Chat Info Admins Only',
358
+ type: 'boolean',
359
+ filters: ['EQ', 'NEQ'],
360
+ value: [
361
+ {
362
+ id: 'true',
363
+ value: 'true',
364
+ label: 'True',
365
+ },
366
+ {
367
+ id: 'false',
368
+ value: 'false',
369
+ label: 'False',
370
+ },
371
+ ],
372
+ },
373
+ 'chat.has_flagged_messages': {
374
+ text: 'Chat has flagged messages',
375
+ type: 'boolean',
376
+ filters: ['EQ', 'NEQ'],
377
+ value: [
378
+ {
379
+ id: 'true',
380
+ value: 'true',
381
+ label: 'True',
382
+ },
383
+ {
384
+ id: 'false',
385
+ value: 'false',
386
+ label: 'False',
387
+ },
388
+ ],
389
+ },
390
+ 'chat.group_description': {
391
+ text: 'Group Description',
392
+ type: 'string',
393
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
394
+ placeholder: 'e.g. Group description',
395
+ },
396
+ 'chat.custom_properties': {
397
+ text: 'Chat Custom Properties',
398
+ type: 'dropdown',
399
+ value: 'org.custom_properties',
400
+ filters: ['EQ', 'NEQ'],
401
+ hidden: true,
402
+ },
403
+ 'chat.created_at': {
404
+ text: 'Chat Created At',
405
+ type: 'day-time',
406
+ filters: ['LT', 'LTE', 'GT', 'GTE', 'IS'],
407
+ },
189
408
  };
190
409
  exports.TicketVariableNameMap = {
191
410
  'ticket.subject': {
192
411
  text: 'Ticket Subject',
193
412
  type: 'string',
194
413
  filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
414
+ placeholder: 'e.g. Test ticket',
195
415
  },
196
416
  'ticket.status': {
197
417
  text: 'Ticket Status',
@@ -219,7 +439,7 @@ exports.TicketVariableNameMap = {
219
439
  text: 'Ticket Assignee',
220
440
  type: 'dropdown',
221
441
  value: 'org.members',
222
- filters: ['EQ', 'NEQ'],
442
+ filters: ['EQ', 'NEQ', "KNOWN", "NKNOWN"],
223
443
  },
224
444
  'ticket.labels': {
225
445
  text: 'Ticket Labels',
@@ -240,51 +460,71 @@ exports.TicketVariableNameMap = {
240
460
  },
241
461
  'ticket.due_date': {
242
462
  text: 'Ticket Due Date',
243
- type: 'date',
244
- filters: ['LT', 'LTE', 'GT', 'GTE'],
463
+ type: 'string',
464
+ filters: ['KNOWN', 'NKNOWN'],
465
+ },
466
+ 'ticket.ticket_id': {
467
+ text: 'Ticket ID',
468
+ type: 'string',
469
+ filters: ['EQ', 'NEQ'],
470
+ hidden: true,
245
471
  },
246
- 'ticket.assigned_by': {
247
- text: 'Ticket assignee',
472
+ 'ticket.org_id': {
473
+ text: 'Org ID',
474
+ type: 'string',
475
+ filters: ['EQ', 'NEQ'],
476
+ hidden: true,
477
+ },
478
+ 'ticket.custom_properties': {
479
+ text: 'Ticket Custom Properties',
248
480
  type: 'dropdown',
249
- value: 'org.members',
481
+ value: 'org.custom_properties',
250
482
  filters: ['EQ', 'NEQ'],
483
+ hidden: true,
251
484
  },
252
- "ticket.ticket_id": {
253
- text: 'Ticket ID',
485
+ 'ticket.created_at': {
486
+ text: 'Ticket Created At',
487
+ type: 'day-time',
488
+ filters: ['LT', 'LTE', 'GT', 'GTE'],
489
+ },
490
+ 'ticket.chat_id': {
491
+ text: 'Chat ID',
254
492
  type: 'string',
255
493
  filters: ['EQ', 'NEQ'],
256
- hidden: true
257
- }
494
+ hidden: true,
495
+ },
258
496
  };
259
497
  exports.ReactionVariableNameMap = {
260
498
  'reaction.reaction': {
261
499
  text: 'Reaction',
262
500
  type: 'string',
263
501
  filters: ['EQ', 'NEQ'],
502
+ placeholder: 'e.g. 👍',
264
503
  },
265
504
  'reaction.sender_id': {
266
505
  text: 'Reaction Sender Phone',
267
506
  type: 'string',
268
507
  filters: ['EQ', 'NEQ'],
508
+ placeholder: 'e.g. 919876543210@c.us'
269
509
  },
270
510
  'reaction.message_id': {
271
511
  text: 'Reaction Message ID',
272
512
  type: 'string',
273
513
  filters: ['EQ', 'NEQ'],
274
- hidden: true
514
+ hidden: true,
275
515
  },
276
- "reaction.chat_id": {
516
+ 'reaction.chat_id': {
277
517
  text: 'Chat ID',
278
518
  type: 'string',
279
519
  filters: ['EQ', 'NEQ'],
280
- hidden: true
520
+ hidden: true,
281
521
  },
282
- "reaction.reaction_id": {
522
+ 'reaction.reaction_id': {
283
523
  text: 'Reaction ID',
284
524
  type: 'string',
285
525
  filters: ['EQ', 'NEQ'],
286
- hidden: true
287
- }
526
+ hidden: true,
527
+ },
288
528
  };
289
529
  var FilterConditionMap;
290
530
  (function (FilterConditionMap) {
@@ -391,6 +631,7 @@ exports.ActionNameMap = {
391
631
  'ticket.created',
392
632
  'reaction.added',
393
633
  'message.flagged',
634
+ 'chat.label.updated'
394
635
  ],
395
636
  },
396
637
  reply_to_message: {
@@ -439,6 +680,7 @@ exports.ActionNameMap = {
439
680
  'ticket.created',
440
681
  'reaction.added',
441
682
  'message.flagged',
683
+ 'chat.label.updated'
442
684
  ],
443
685
  },
444
686
  create_ticket: {
@@ -476,7 +718,6 @@ exports.ActionNameMap = {
476
718
  validTriggers: [
477
719
  'message.created',
478
720
  'message.updated',
479
- 'chat.created',
480
721
  'reaction.added',
481
722
  'message.flagged',
482
723
  ],
@@ -502,8 +743,8 @@ exports.ActionNameMap = {
502
743
  title: 'Assign Ticket',
503
744
  description: 'Assign a ticket',
504
745
  inputs: {
505
- assignee: {
506
- id: 'assignee',
746
+ email: {
747
+ id: 'email',
507
748
  type: 'dropdown',
508
749
  value: 'org.members',
509
750
  label: 'Assignee',
@@ -545,6 +786,7 @@ exports.ActionNameMap = {
545
786
  'ticket.updated',
546
787
  'ticket.created',
547
788
  'reaction.added',
789
+ 'chat.label.updated'
548
790
  ],
549
791
  },
550
792
  add_ticket_label: {
@@ -582,20 +824,20 @@ exports.ActionNameMap = {
582
824
  placeholder: 'Select property',
583
825
  },
584
826
  value: {
585
- id: 'value',
827
+ id: 'property_id',
586
828
  type: 'dynamic',
587
829
  label: 'Value',
588
830
  placeholder: 'Enter value',
589
831
  value: 'custom_property_values',
590
832
  },
591
- }
833
+ },
592
834
  },
593
835
  assign_chat: {
594
836
  title: 'Assign Chat',
595
837
  description: 'Assign a chat',
596
838
  inputs: {
597
- assignee: {
598
- id: 'assignee',
839
+ email: {
840
+ id: 'email',
599
841
  type: 'dropdown',
600
842
  value: 'org.members',
601
843
  label: 'Assignee',
@@ -609,6 +851,7 @@ exports.ActionNameMap = {
609
851
  'ticket.updated',
610
852
  'ticket.created',
611
853
  'reaction.added',
854
+ 'chat.label.updated'
612
855
  ],
613
856
  },
614
857
  forward_message: {
@@ -622,13 +865,13 @@ exports.ActionNameMap = {
622
865
  label: 'Chat',
623
866
  placeholder: 'Select chat',
624
867
  },
625
- prefix: {
626
- id: 'prefix',
627
- type: 'editor',
628
- label: 'Prefix',
629
- placeholder: 'Enter prefix',
630
- value: null,
631
- },
868
+ // prefix: {
869
+ // id: 'prefix',
870
+ // type: 'editor',
871
+ // label: 'Prefix',
872
+ // placeholder: 'Enter prefix',
873
+ // value: null,
874
+ // },
632
875
  },
633
876
  validTriggers: [
634
877
  'message.created',
@@ -674,6 +917,7 @@ exports.ActionNameMap = {
674
917
  'ticket.created',
675
918
  'reaction.added',
676
919
  'message.flagged',
920
+ 'chat.label.updated'
677
921
  ],
678
922
  },
679
923
  };