@periskope/types 0.6.142 → 0.6.144

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.
@@ -0,0 +1,679 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActionNameMap = exports.RuleNameMap = exports.isSendMessageAction = exports.FilterConditionMap = exports.ReactionVariableNameMap = exports.TicketVariableNameMap = exports.ChatVariableNameMap = exports.SenderVariableNameMap = exports.MessageVariableNameMap = exports.FilterNameMap = exports.isFilter = void 0;
4
+ const isFilter = (filter) => {
5
+ return (typeof filter === 'object' &&
6
+ 'id' in filter &&
7
+ 'condition' in filter &&
8
+ 'variable' in filter &&
9
+ 'value' in filter);
10
+ };
11
+ exports.isFilter = isFilter;
12
+ exports.FilterNameMap = {
13
+ CONTAINS: {
14
+ name: 'contains',
15
+ input: true,
16
+ },
17
+ NCONTAINS: {
18
+ name: 'does not contain',
19
+ input: true,
20
+ },
21
+ EQ: {
22
+ name: 'equals to',
23
+ input: true,
24
+ },
25
+ NEQ: {
26
+ name: 'not equals to',
27
+ input: true,
28
+ },
29
+ LT: {
30
+ name: 'less than',
31
+ input: true,
32
+ },
33
+ LTE: {
34
+ name: 'less than or equals to',
35
+ input: true,
36
+ },
37
+ GT: {
38
+ name: 'greater than',
39
+ input: true,
40
+ },
41
+ GTE: {
42
+ name: 'greater than or equals to',
43
+ input: true,
44
+ },
45
+ KNOWN: {
46
+ name: 'is known',
47
+ input: false,
48
+ },
49
+ NKNOWN: {
50
+ name: 'is not known',
51
+ input: false,
52
+ },
53
+ IS: {
54
+ name: 'is',
55
+ input: true,
56
+ },
57
+ NIS: {
58
+ name: 'is not',
59
+ input: true,
60
+ },
61
+ };
62
+ exports.MessageVariableNameMap = {
63
+ 'message.body': {
64
+ text: 'Message Body',
65
+ type: 'string',
66
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
67
+ },
68
+ 'message.sender_phone': {
69
+ text: 'Message Sender Phone',
70
+ type: 'string',
71
+ filters: ['EQ', 'NEQ'],
72
+ },
73
+ 'message.timestamp': {
74
+ text: 'Message Timestamp',
75
+ type: 'date',
76
+ filters: ['LT', 'LTE', 'GT', 'GTE', 'IS'],
77
+ },
78
+ 'message.flag_status': {
79
+ text: 'Message Flag Status',
80
+ filters: ['IS'],
81
+ type: 'boolean',
82
+ },
83
+ 'message.has_quoted_msg': {
84
+ text: 'Quoted Message',
85
+ filters: ['IS'],
86
+ type: 'boolean',
87
+ },
88
+ 'message.media': {
89
+ text: 'Message Media',
90
+ type: 'boolean',
91
+ filters: ['KNOWN', 'NKNOWN'],
92
+ },
93
+ 'message.performed_by': {
94
+ text: 'Message Performed By',
95
+ type: 'dropdown',
96
+ value: 'org.members',
97
+ filters: ['EQ', 'NEQ'],
98
+ },
99
+ "message.chat_id": {
100
+ text: 'Chat ID',
101
+ type: 'string',
102
+ filters: ['EQ', 'NEQ'],
103
+ hidden: true
104
+ },
105
+ "message.message_id": {
106
+ text: 'Message ID',
107
+ type: 'string',
108
+ filters: ['EQ', 'NEQ'],
109
+ hidden: true
110
+ }
111
+ };
112
+ exports.SenderVariableNameMap = {
113
+ 'sender.is_business': {
114
+ // remove
115
+ text: 'Sender is business',
116
+ type: 'boolean',
117
+ filters: ['IS'],
118
+ },
119
+ 'sender.is_enterprise': {
120
+ // remove
121
+ text: 'Sender is enterprise',
122
+ type: 'boolean',
123
+ filters: ['IS'],
124
+ },
125
+ 'sender.is_internal': {
126
+ text: 'Sender is internal',
127
+ type: 'boolean',
128
+ filters: ['IS'],
129
+ },
130
+ 'sender.contact_name': {
131
+ text: 'Sender Name',
132
+ type: 'string',
133
+ filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
134
+ },
135
+ 'sender.contact_id': {
136
+ text: 'Sender Contact Phone',
137
+ type: 'string',
138
+ filters: ['EQ', 'NEQ'],
139
+ },
140
+ 'sender.labels': {
141
+ text: 'Sender Labels',
142
+ type: 'dropdown',
143
+ value: 'org.labels',
144
+ filters: ['EQ', 'NEQ'],
145
+ },
146
+ };
147
+ exports.ChatVariableNameMap = {
148
+ 'chat.assigned_to': {
149
+ text: 'Chat Assignee',
150
+ type: 'dropdown',
151
+ value: 'org.members',
152
+ filters: ['EQ', 'NEQ', 'KNOWN', 'NKNOWN'],
153
+ },
154
+ 'chat.chat_name': {
155
+ text: 'Chat Name',
156
+ type: 'string',
157
+ filters: ['EQ', 'NEQ'],
158
+ },
159
+ 'chat.org_phone': {
160
+ text: 'Chat Org Phone',
161
+ type: 'string',
162
+ filters: ['EQ', 'NEQ'],
163
+ },
164
+ 'chat.chat_type': {
165
+ text: 'Chat Type',
166
+ type: 'dropdown',
167
+ value: [
168
+ { id: 'user', value: 'user', label: 'User' },
169
+ { id: 'group', value: 'group', label: 'Group' },
170
+ ],
171
+ filters: ['EQ', 'NEQ'],
172
+ },
173
+ 'chat.members': {
174
+ text: 'Chat Members',
175
+ type: 'string',
176
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
177
+ },
178
+ 'chat.labels': {
179
+ text: 'Chat Labels',
180
+ type: 'dropdown',
181
+ value: 'org.labels',
182
+ filters: ['CONTAINS', 'NCONTAINS'],
183
+ },
184
+ "chat.chat_id": {
185
+ text: 'Chat ID',
186
+ type: 'string',
187
+ filters: ['EQ', 'NEQ'],
188
+ }
189
+ };
190
+ exports.TicketVariableNameMap = {
191
+ 'ticket.subject': {
192
+ text: 'Ticket Subject',
193
+ type: 'string',
194
+ filters: ['CONTAINS', 'NCONTAINS', 'EQ', 'NEQ'],
195
+ },
196
+ 'ticket.status': {
197
+ text: 'Ticket Status',
198
+ type: 'dropdown',
199
+ value: [
200
+ { id: 'open', value: 'open', label: 'Open' },
201
+ { id: 'closed', value: 'closed', label: 'Closed' },
202
+ { id: 'inprogress', value: 'inprogress', label: 'In progress' },
203
+ ],
204
+ filters: ['EQ', 'NEQ'],
205
+ },
206
+ 'ticket.priority': {
207
+ text: 'Ticket Priority',
208
+ type: 'dropdown',
209
+ value: [
210
+ { id: '0', value: '0', label: 'No Prioriy' },
211
+ { id: '1', value: '1', label: 'Low' },
212
+ { id: '2', value: '2', label: 'Medium' },
213
+ { id: '3', value: '3', label: 'High' },
214
+ { id: '4', value: '4', label: 'Urgent' },
215
+ ],
216
+ filters: ['EQ', 'NEQ'],
217
+ },
218
+ 'ticket.assignee': {
219
+ text: 'Ticket Assignee',
220
+ type: 'dropdown',
221
+ value: 'org.members',
222
+ filters: ['EQ', 'NEQ'],
223
+ },
224
+ 'ticket.labels': {
225
+ text: 'Ticket Labels',
226
+ type: 'dropdown',
227
+ value: 'org.labels',
228
+ filters: ['EQ', 'NEQ'],
229
+ },
230
+ 'ticket.is_deleted': {
231
+ text: 'Ticket is deleted',
232
+ type: 'boolean',
233
+ filters: ['IS'],
234
+ },
235
+ 'ticket.raised_by': {
236
+ text: 'Ticket Raised By',
237
+ type: 'dropdown',
238
+ value: 'org.members',
239
+ filters: ['EQ', 'NEQ'],
240
+ },
241
+ 'ticket.due_date': {
242
+ text: 'Ticket Due Date',
243
+ type: 'date',
244
+ filters: ['LT', 'LTE', 'GT', 'GTE'],
245
+ },
246
+ 'ticket.assigned_by': {
247
+ text: 'Ticket assignee',
248
+ type: 'dropdown',
249
+ value: 'org.members',
250
+ filters: ['EQ', 'NEQ'],
251
+ },
252
+ "ticket.ticket_id": {
253
+ text: 'Ticket ID',
254
+ type: 'string',
255
+ filters: ['EQ', 'NEQ'],
256
+ hidden: true
257
+ }
258
+ };
259
+ exports.ReactionVariableNameMap = {
260
+ 'reaction.reaction': {
261
+ text: 'Reaction',
262
+ type: 'string',
263
+ filters: ['EQ', 'NEQ'],
264
+ },
265
+ 'reaction.sender_id': {
266
+ text: 'Reaction Sender Phone',
267
+ type: 'string',
268
+ filters: ['EQ', 'NEQ'],
269
+ },
270
+ 'reaction.message_id': {
271
+ text: 'Reaction Message ID',
272
+ type: 'string',
273
+ filters: ['EQ', 'NEQ'],
274
+ hidden: true
275
+ },
276
+ "reaction.chat_id": {
277
+ text: 'Chat ID',
278
+ type: 'string',
279
+ filters: ['EQ', 'NEQ'],
280
+ hidden: true
281
+ },
282
+ "reaction.reaction_id": {
283
+ text: 'Reaction ID',
284
+ type: 'string',
285
+ filters: ['EQ', 'NEQ'],
286
+ hidden: true
287
+ }
288
+ };
289
+ var FilterConditionMap;
290
+ (function (FilterConditionMap) {
291
+ FilterConditionMap["CONTAINS"] = "contains";
292
+ FilterConditionMap["NCONTAINS"] = "does not contain";
293
+ FilterConditionMap["EQ"] = "=";
294
+ FilterConditionMap["NEQ"] = "<>";
295
+ FilterConditionMap["LT"] = "<";
296
+ FilterConditionMap["LTE"] = "<=";
297
+ FilterConditionMap["GT"] = ">";
298
+ FilterConditionMap["GTE"] = ">=";
299
+ FilterConditionMap["KNOWN"] = "is known";
300
+ FilterConditionMap["NKNOWN"] = "is not known";
301
+ FilterConditionMap["IS"] = "=";
302
+ FilterConditionMap["NIS"] = "<>";
303
+ })(FilterConditionMap || (exports.FilterConditionMap = FilterConditionMap = {}));
304
+ const isSendMessageAction = (action) => {
305
+ return action.type === 'send_message';
306
+ };
307
+ exports.isSendMessageAction = isSendMessageAction;
308
+ exports.RuleNameMap = {
309
+ 'message.created': {
310
+ title: 'New Message Received',
311
+ description: 'When a new message is sent or received',
312
+ base_conditions: {
313
+ org_phone: true,
314
+ },
315
+ },
316
+ 'chat.created': {
317
+ title: 'New Chat Created',
318
+ description: 'When a new chat is created',
319
+ base_conditions: {
320
+ org_phone: true,
321
+ },
322
+ },
323
+ 'ticket.created': {
324
+ title: 'New Ticket Created',
325
+ description: 'When a new ticket is created',
326
+ base_conditions: {
327
+ org_phone: false,
328
+ },
329
+ },
330
+ 'reaction.added': {
331
+ title: 'New Reaction Added',
332
+ description: 'When a reaction is added on a message',
333
+ base_conditions: {
334
+ org_phone: true,
335
+ },
336
+ },
337
+ 'message.updated': {
338
+ title: 'Message Updated',
339
+ description: 'When a message is updated',
340
+ base_conditions: {
341
+ org_phone: true,
342
+ },
343
+ },
344
+ 'ticket.updated': {
345
+ title: 'Ticket Updated',
346
+ description: 'When a ticket is updated',
347
+ base_conditions: {
348
+ org_phone: false,
349
+ },
350
+ },
351
+ 'chat.label.updated': {
352
+ title: 'Chat Label Added/Removed',
353
+ description: 'When labels on chats are updated',
354
+ base_conditions: {
355
+ org_phone: false,
356
+ },
357
+ },
358
+ 'message.flagged': {
359
+ title: 'Message Flagged',
360
+ description: 'When a message is flagged',
361
+ base_conditions: {
362
+ org_phone: true,
363
+ },
364
+ },
365
+ };
366
+ exports.ActionNameMap = {
367
+ send_message: {
368
+ title: 'Send Message',
369
+ description: 'Send a message',
370
+ inputs: {
371
+ message: {
372
+ id: 'message',
373
+ type: 'editor',
374
+ label: 'Message',
375
+ placeholder: 'Enter message',
376
+ value: null,
377
+ },
378
+ media: {
379
+ id: 'media',
380
+ type: 'file',
381
+ label: 'Media',
382
+ placeholder: 'Upload media',
383
+ value: null,
384
+ },
385
+ },
386
+ validTriggers: [
387
+ 'message.created',
388
+ 'message.updated',
389
+ 'chat.created',
390
+ 'ticket.updated',
391
+ 'ticket.created',
392
+ 'reaction.added',
393
+ 'message.flagged',
394
+ ],
395
+ },
396
+ reply_to_message: {
397
+ title: 'Reply to message',
398
+ description: 'Send a message with the quoted message',
399
+ inputs: {
400
+ message: {
401
+ id: 'message',
402
+ type: 'editor',
403
+ label: 'Message',
404
+ placeholder: 'Enter message',
405
+ value: null,
406
+ },
407
+ media: {
408
+ id: 'media',
409
+ type: 'file',
410
+ label: 'Media',
411
+ placeholder: 'Upload media',
412
+ value: null,
413
+ },
414
+ },
415
+ validTriggers: [
416
+ 'message.created',
417
+ 'message.updated',
418
+ 'reaction.added',
419
+ 'message.flagged',
420
+ ],
421
+ },
422
+ notify_http: {
423
+ title: 'Notify HTTP',
424
+ description: 'Notify an HTTP endpoint',
425
+ inputs: {
426
+ url: {
427
+ id: 'url',
428
+ type: 'text',
429
+ label: 'URL',
430
+ placeholder: 'Enter URL',
431
+ value: null,
432
+ },
433
+ },
434
+ validTriggers: [
435
+ 'message.created',
436
+ 'message.updated',
437
+ 'chat.created',
438
+ 'ticket.updated',
439
+ 'ticket.created',
440
+ 'reaction.added',
441
+ 'message.flagged',
442
+ ],
443
+ },
444
+ create_ticket: {
445
+ title: 'Create Ticket',
446
+ description: 'Create a ticket',
447
+ inputs: {
448
+ assignee: {
449
+ id: 'assignee',
450
+ type: 'dropdown',
451
+ value: 'org.members',
452
+ label: 'Assignee',
453
+ placeholder: 'Select assignee',
454
+ },
455
+ priority: {
456
+ id: 'priority',
457
+ type: 'dropdown',
458
+ value: [
459
+ { id: '0', value: '0', label: 'Low' },
460
+ { id: '1', value: '1', label: 'Medium' },
461
+ { id: '2', value: '2', label: 'High' },
462
+ { id: '3', value: '3', label: 'Urgent' },
463
+ { id: '4', value: '4', label: 'Immediate' },
464
+ ],
465
+ label: 'Priority',
466
+ placeholder: 'Select priority',
467
+ },
468
+ label: {
469
+ id: 'label',
470
+ type: 'dropdown',
471
+ value: 'ticket.labels',
472
+ label: 'Label',
473
+ placeholder: 'Select label',
474
+ },
475
+ },
476
+ validTriggers: [
477
+ 'message.created',
478
+ 'message.updated',
479
+ 'chat.created',
480
+ 'reaction.added',
481
+ 'message.flagged',
482
+ ],
483
+ },
484
+ flag_message: {
485
+ title: 'Update flag status',
486
+ description: 'Flag/Unflag a message',
487
+ inputs: {
488
+ flag: {
489
+ id: 'flag',
490
+ type: 'dropdown',
491
+ value: [
492
+ { id: 'flag', value: 'true', label: 'TRUE' },
493
+ { id: 'unflag', value: 'false', label: 'FALSE' },
494
+ ],
495
+ label: 'Flag status',
496
+ placeholder: 'Select flag',
497
+ },
498
+ },
499
+ validTriggers: ['message.created', 'message.updated', 'reaction.added'],
500
+ },
501
+ assign_ticket: {
502
+ title: 'Assign Ticket',
503
+ description: 'Assign a ticket',
504
+ inputs: {
505
+ assignee: {
506
+ id: 'assignee',
507
+ type: 'dropdown',
508
+ value: 'org.members',
509
+ label: 'Assignee',
510
+ placeholder: 'Select assignee',
511
+ },
512
+ },
513
+ validTriggers: ['ticket.updated', 'ticket.created'],
514
+ },
515
+ close_ticket: {
516
+ title: 'Close Ticket',
517
+ description: 'Close a ticket',
518
+ inputs: {
519
+ closing_note: {
520
+ id: 'closing_note',
521
+ type: 'textarea',
522
+ label: 'Closing Note',
523
+ placeholder: 'Enter closing note',
524
+ value: null,
525
+ },
526
+ },
527
+ validTriggers: ['ticket.updated', 'ticket.created'],
528
+ },
529
+ add_chat_label: {
530
+ title: 'Add Chat Label',
531
+ description: 'Add a label to referred chat',
532
+ inputs: {
533
+ label: {
534
+ id: 'label',
535
+ type: 'dropdown',
536
+ value: 'chat.labels',
537
+ label: 'Label',
538
+ placeholder: 'Select label',
539
+ },
540
+ },
541
+ validTriggers: [
542
+ 'message.created',
543
+ 'message.updated',
544
+ 'chat.created',
545
+ 'ticket.updated',
546
+ 'ticket.created',
547
+ 'reaction.added',
548
+ ],
549
+ },
550
+ add_ticket_label: {
551
+ title: 'Add Ticket Label',
552
+ description: 'Add a label to referred ticket',
553
+ inputs: {
554
+ label: {
555
+ id: 'label',
556
+ type: 'dropdown',
557
+ value: 'ticket.labels',
558
+ label: 'Label',
559
+ placeholder: 'Select label',
560
+ },
561
+ },
562
+ validTriggers: ['ticket.updated', 'ticket.created'],
563
+ },
564
+ update_custom_property: {
565
+ description: 'Update a custom property',
566
+ title: 'Update Chat Custom Property',
567
+ validTriggers: [
568
+ 'message.created',
569
+ 'message.updated',
570
+ 'chat.created',
571
+ 'ticket.updated',
572
+ 'ticket.created',
573
+ 'reaction.added',
574
+ 'message.flagged',
575
+ ],
576
+ inputs: {
577
+ property_id: {
578
+ id: 'property_id',
579
+ type: 'dropdown',
580
+ value: 'org.custom_properties',
581
+ label: 'Property',
582
+ placeholder: 'Select property',
583
+ },
584
+ value: {
585
+ id: 'value',
586
+ type: 'dynamic',
587
+ label: 'Value',
588
+ placeholder: 'Enter value',
589
+ value: 'custom_property_values',
590
+ },
591
+ }
592
+ },
593
+ assign_chat: {
594
+ title: 'Assign Chat',
595
+ description: 'Assign a chat',
596
+ inputs: {
597
+ assignee: {
598
+ id: 'assignee',
599
+ type: 'dropdown',
600
+ value: 'org.members',
601
+ label: 'Assignee',
602
+ placeholder: 'Select assignee',
603
+ },
604
+ },
605
+ validTriggers: [
606
+ 'message.created',
607
+ 'message.updated',
608
+ 'chat.created',
609
+ 'ticket.updated',
610
+ 'ticket.created',
611
+ 'reaction.added',
612
+ ],
613
+ },
614
+ forward_message: {
615
+ title: 'Forward Message',
616
+ description: 'Forward a message',
617
+ inputs: {
618
+ chat_id: {
619
+ id: 'chat_id',
620
+ type: 'dropdown',
621
+ value: 'org.chats',
622
+ label: 'Chat',
623
+ placeholder: 'Select chat',
624
+ },
625
+ prefix: {
626
+ id: 'prefix',
627
+ type: 'editor',
628
+ label: 'Prefix',
629
+ placeholder: 'Enter prefix',
630
+ value: null,
631
+ },
632
+ },
633
+ validTriggers: [
634
+ 'message.created',
635
+ 'message.updated',
636
+ 'chat.created',
637
+ 'ticket.updated',
638
+ 'ticket.created',
639
+ 'reaction.added',
640
+ 'message.flagged',
641
+ ],
642
+ },
643
+ send_email: {
644
+ title: 'Send Email',
645
+ description: 'Send an email',
646
+ inputs: {
647
+ email: {
648
+ id: 'email',
649
+ type: 'text',
650
+ label: 'Email',
651
+ placeholder: 'Enter email',
652
+ value: null,
653
+ },
654
+ subject: {
655
+ id: 'subject',
656
+ type: 'text',
657
+ label: 'Subject',
658
+ placeholder: 'Enter subject',
659
+ value: null,
660
+ },
661
+ body: {
662
+ id: 'body',
663
+ type: 'editor',
664
+ label: 'Body',
665
+ placeholder: 'Enter body',
666
+ value: null,
667
+ },
668
+ },
669
+ validTriggers: [
670
+ 'message.created',
671
+ 'message.updated',
672
+ 'chat.created',
673
+ 'ticket.updated',
674
+ 'ticket.created',
675
+ 'reaction.added',
676
+ 'message.flagged',
677
+ ],
678
+ },
679
+ };