@periskope/types 0.6.288-1 → 0.6.289

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,6 +1,31 @@
1
1
  export type Json = { [key: string]: any } | any
2
2
 
3
3
  export type Database = {
4
+ graphql_public: {
5
+ Tables: {
6
+ [_ in never]: never
7
+ }
8
+ Views: {
9
+ [_ in never]: never
10
+ }
11
+ Functions: {
12
+ graphql: {
13
+ Args: {
14
+ operationName?: string
15
+ query?: string
16
+ variables?: Json
17
+ extensions?: Json
18
+ }
19
+ Returns: Json
20
+ }
21
+ }
22
+ Enums: {
23
+ [_ in never]: never
24
+ }
25
+ CompositeTypes: {
26
+ [_ in never]: never
27
+ }
28
+ }
4
29
  internal: {
5
30
  Tables: {
6
31
  config: {
@@ -1042,6 +1067,7 @@ export type Database = {
1042
1067
  created_at: string
1043
1068
  custom_properties: Json | null
1044
1069
  due_date: string | null
1070
+ first_assigned_at: string | null
1045
1071
  freshdesk_metadata: Json | null
1046
1072
  hubspot_metadata: Json | null
1047
1073
  is_deleted: boolean
@@ -1066,6 +1092,7 @@ export type Database = {
1066
1092
  created_at?: string
1067
1093
  custom_properties?: Json | null
1068
1094
  due_date?: string | null
1095
+ first_assigned_at?: string | null
1069
1096
  freshdesk_metadata?: Json | null
1070
1097
  hubspot_metadata?: Json | null
1071
1098
  is_deleted?: boolean
@@ -1092,6 +1119,7 @@ export type Database = {
1092
1119
  created_at?: string
1093
1120
  custom_properties?: Json | null
1094
1121
  due_date?: string | null
1122
+ first_assigned_at?: string | null
1095
1123
  freshdesk_metadata?: Json | null
1096
1124
  hubspot_metadata?: Json | null
1097
1125
  is_deleted?: boolean
@@ -2392,6 +2420,7 @@ export type Database = {
2392
2420
  info_admins_only: boolean | null
2393
2421
  initiated_by: string | null
2394
2422
  invite_link: string | null
2423
+ is_archived: boolean | null
2395
2424
  is_exited: boolean | null
2396
2425
  is_muted: boolean | null
2397
2426
  label_ids: Json | null
@@ -2576,6 +2605,14 @@ export type Database = {
2576
2605
  }
2577
2606
  Returns: Json
2578
2607
  }
2608
+ get_chat_workflow_info: {
2609
+ Args: {
2610
+ chat_id_input: string
2611
+ org_id_input: string
2612
+ org_phone_input: string
2613
+ }
2614
+ Returns: Json
2615
+ }
2579
2616
  get_chats: {
2580
2617
  Args: {
2581
2618
  org_id_input: string
@@ -2660,6 +2697,16 @@ export type Database = {
2660
2697
  }
2661
2698
  Returns: Json
2662
2699
  }
2700
+ get_message_workflow_info: {
2701
+ Args: {
2702
+ chat_id_input: string
2703
+ org_id_input: string
2704
+ org_phone_input: string
2705
+ message_id_input: string
2706
+ sender_id_input: string
2707
+ }
2708
+ Returns: Json
2709
+ }
2663
2710
  get_messages_notifications_reactions: {
2664
2711
  Args: {
2665
2712
  org_id_input: string
@@ -2710,6 +2757,15 @@ export type Database = {
2710
2757
  }
2711
2758
  Returns: Json
2712
2759
  }
2760
+ get_sender_workflow_info: {
2761
+ Args: {
2762
+ chat_id_input: string
2763
+ org_id_input: string
2764
+ org_phone_input: string
2765
+ contact_id_input: string
2766
+ }
2767
+ Returns: Json
2768
+ }
2713
2769
  get_team_metrics_between_dates: {
2714
2770
  Args: {
2715
2771
  org_id_input: string
@@ -3516,6 +3572,9 @@ export type CompositeTypes<
3516
3572
  : never
3517
3573
 
3518
3574
  export const Constants = {
3575
+ graphql_public: {
3576
+ Enums: {},
3577
+ },
3519
3578
  internal: {
3520
3579
  Enums: {},
3521
3580
  },
@@ -3592,5 +3651,3 @@ export const Constants = {
3592
3651
  Enums: {},
3593
3652
  },
3594
3653
  } as const
3595
-
3596
-
package/src/types.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import type { default as _Stripe } from 'stripe';
2
2
  import { Merge, OverrideProperties } from 'type-fest';
3
3
  import { Filter, Rule } from './rules.types';
4
- import { Enums, Tables, TablesInsert, TablesUpdate } from './supabase.types';
5
- import { WorkflowActionTypes } from './workflows.types';
4
+ import { Tables, TablesInsert, TablesUpdate } from './supabase.types';
6
5
 
7
6
  /* ----------------------------- TYPE SHORTHANDS ---------------------------- */
8
7
 
@@ -812,6 +811,7 @@ export type TicketInfoType = {
812
811
  closed_at: string;
813
812
  closed_by: string;
814
813
  closed_message: string;
814
+ first_assigned_at: string | null;
815
815
  };
816
816
  attached_messages: {
817
817
  body: string;
@@ -1,7 +1,8 @@
1
1
  import { Merge, OverrideProperties } from 'type-fest';
2
- import { AppendTypes } from './rules.types';
3
2
  import { Tables } from './supabase.types';
4
- import { ChatInfoType, TaskType } from './types';
3
+ import { TaskType } from './types';
4
+ import { AppendTypes } from './rules.types';
5
+
5
6
 
6
7
  /***************************** WORKFLOWS *****************************/
7
8
 
@@ -13,7 +14,7 @@ export type NormalWorkflowActions = {
13
14
 
14
15
  export type SplitPathActions = {
15
16
  id: string;
16
- action_metadata: SplitPathAction;
17
+ action_metadata: SplitPathWorkflowAction;
17
18
  };
18
19
 
19
20
  export type WorkflowAction = NormalWorkflowActions | SplitPathActions;
@@ -210,6 +211,7 @@ export type WorkflowRawDataTypes = {
210
211
  members: string[];
211
212
  }
212
213
  >;
214
+ chat_label: Tables<'tbl_chat_properties'>;
213
215
  ticket: Tables<'tbl_chat_tickets'>;
214
216
  task: Tables<'tbl_org_tasks'>;
215
217
  sender: Tables<'tbl_contacts'> & Tables<'tbl_chat_participants'>;
@@ -220,7 +222,6 @@ export type MessageWorkflowDataTypes = AppendTypes<
220
222
  message: WorkflowRawDataTypes['message'];
221
223
  sender: WorkflowRawDataTypes['sender'];
222
224
  chat: WorkflowRawDataTypes['chat'];
223
- ticket: WorkflowRawDataTypes['ticket'];
224
225
  },
225
226
  '.'
226
227
  >;
@@ -284,22 +285,22 @@ export type WorkflowDataType<T extends Triggers = Triggers> = T extends
284
285
  | Triggers.MESSAGE_UNFLAGGED
285
286
  ? MessageWorkflowDataTypes
286
287
  : T extends
287
- | Triggers.CHAT_CREATED
288
- | Triggers.CHAT_LABEL_UPDATED
289
- | Triggers.CHAT_CLOSED
290
- ? ChatWorkflowDataTypes
291
- : T extends
292
- | Triggers.TICKET_CREATED
293
- | Triggers.TICKET_UPDATED
294
- | Triggers.TICKET_DELETED
295
- | Triggers.TICKET_CLOSED
296
- | Triggers.TICKET_DUE
297
- ? TicketWorkflowDataTypes
298
- : T extends Triggers.REACTION_ADDED
299
- ? ReactionWorkflowDataTypes
300
- : T extends Triggers.TASK_CREATED | Triggers.TASK_DUE
301
- ? TaskWorkflowDataTypes
302
- : never;
288
+ | Triggers.CHAT_CREATED
289
+ | Triggers.CHAT_LABEL_UPDATED
290
+ | Triggers.CHAT_CLOSED
291
+ ? ChatWorkflowDataTypes
292
+ : T extends
293
+ | Triggers.TICKET_CREATED
294
+ | Triggers.TICKET_UPDATED
295
+ | Triggers.TICKET_DELETED
296
+ | Triggers.TICKET_CLOSED
297
+ | Triggers.TICKET_DUE
298
+ ? TicketWorkflowDataTypes
299
+ : T extends Triggers.REACTION_ADDED
300
+ ? ReactionWorkflowDataTypes
301
+ : T extends Triggers.TASK_CREATED | Triggers.TASK_DUE
302
+ ? TaskWorkflowDataTypes
303
+ : never;
303
304
 
304
305
  /***************************** ACTION TYPES *****************************/
305
306
 
@@ -311,32 +312,18 @@ export type SendMessageToChatWorkflowAction = {
311
312
  url: string;
312
313
  type: 'image' | 'video' | 'audio' | 'document';
313
314
  name: string;
314
- };
315
- is_reply?: boolean;
315
+ } | null;
316
316
  debounce?: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}` | null;
317
317
  chat_id: `${string}${'@g.us' | '@c.us'}` | 'trigger_chat' | null;
318
318
  unflag_chat?: boolean;
319
- };
320
- };
321
-
322
- export type SendReplyWorkflowAction = {
323
- type: 'send_reply_message';
324
- metadata: {
325
- message: string;
326
- media?: {
327
- url: string;
328
- type: 'image' | 'video' | 'audio' | 'document';
329
- name: string;
330
- };
331
- debounce?: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}` | null;
332
- unflag_chat?: boolean;
319
+ as_reply?: boolean;
333
320
  };
334
321
  };
335
322
 
336
323
  export type CreateTicketWorkflowAction = {
337
324
  type: 'create_ticket';
338
325
  metadata: {
339
- subject: string;
326
+ subject: string | null;
340
327
  assignee:
341
328
  | {
342
329
  round_robin: true;
@@ -344,13 +331,13 @@ export type CreateTicketWorkflowAction = {
344
331
  assignee_check_for?: 'shift_times' | 'online_offline' | 'all';
345
332
  }
346
333
  | {
347
- email: string;
334
+ email: string | null;
348
335
  round_robin: false;
349
336
  };
350
337
  priority?: '0' | '1' | '2' | '3' | '4';
351
338
  status: 'open' | 'inprogress' | 'closed';
352
339
  labels: string[];
353
- due_date: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}` | null;
340
+ due_in: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}` | null;
354
341
  };
355
342
  };
356
343
 
@@ -391,7 +378,7 @@ export type AssignTicketWorkflowAction = {
391
378
  assignee_check_for?: 'shift_times' | 'online_offline' | 'all';
392
379
  }
393
380
  | {
394
- email: string;
381
+ email: string | null;
395
382
  round_robin: false;
396
383
  };
397
384
  };
@@ -443,7 +430,7 @@ export type AssignChatWorkflowAction = {
443
430
  assignee_check_for?: 'shift_times' | 'online_offline' | 'all';
444
431
  }
445
432
  | {
446
- email: string;
433
+ email: string | null;
447
434
  round_robin: false;
448
435
  };
449
436
  };
@@ -452,7 +439,7 @@ export type AssignChatWorkflowAction = {
452
439
  export type ForwardMessageWorkflowAction = {
453
440
  type: 'forward_message';
454
441
  metadata: {
455
- chat_id: `${string}${'@g.us' | '@c.us'}`;
442
+ chat_id: `${string}${'@g.us' | '@c.us'}` | null;
456
443
  };
457
444
  };
458
445
 
@@ -480,14 +467,14 @@ export type ValidateWorkflowAction = {
480
467
  metadata: WorkflowConditionGroup;
481
468
  };
482
469
 
483
- export type DelayAction = {
470
+ export type DelayWorkflowAction = {
484
471
  type: 'delay';
485
472
  metadata: {
486
473
  delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
487
474
  };
488
475
  };
489
476
 
490
- export type SendSlackNotification = {
477
+ export type SendSlackNotificationWorkflowAction = {
491
478
  type: 'send_slack_notification';
492
479
  metadata: {
493
480
  slack_payload: string;
@@ -495,7 +482,7 @@ export type SendSlackNotification = {
495
482
  };
496
483
  };
497
484
 
498
- export type SplitPathAction = {
485
+ export type SplitPathWorkflowAction = {
499
486
  type: 'split_path';
500
487
  metadata: {
501
488
  paths: Array<{
@@ -506,8 +493,8 @@ export type SplitPathAction = {
506
493
  };
507
494
 
508
495
  // experimental
509
- export type AIPromptCheckWorkflowAction = {
510
- type: 'ai_prompt_check';
496
+ export type AIPromptWorkflowAction = {
497
+ type: 'ai_prompt';
511
498
  metadata: {
512
499
  query: string;
513
500
  body: string;
@@ -516,7 +503,6 @@ export type AIPromptCheckWorkflowAction = {
516
503
 
517
504
  export type NormalWorkflowActionTypes =
518
505
  | SendMessageToChatWorkflowAction
519
- | SendReplyWorkflowAction
520
506
  | CreateTicketWorkflowAction
521
507
  | AttachToLatestTicket
522
508
  | NotifyHTTPWorkflowAction
@@ -534,11 +520,200 @@ export type NormalWorkflowActionTypes =
534
520
  | DeleteMessageWorkflowAction
535
521
  | CloseChatWorkflowAction
536
522
  | ValidateWorkflowAction
537
- | DelayAction
538
- | SendSlackNotification
539
- | AIPromptCheckWorkflowAction;
523
+ | DelayWorkflowAction
524
+ | SendSlackNotificationWorkflowAction
525
+ | AIPromptWorkflowAction;
526
+
527
+ export type WorkflowActionsTypeMap = {
528
+ send_message_to_chat: SendMessageToChatWorkflowAction;
529
+ create_ticket: CreateTicketWorkflowAction;
530
+ attach_to_latest_ticket: AttachToLatestTicket;
531
+ notify_http: NotifyHTTPWorkflowAction;
532
+ flag_message: FlagMessageWorkflowAction;
533
+ unflag_message: UnflagMessageWorkflowAction;
534
+ assign_ticket: AssignTicketWorkflowAction;
535
+ close_ticket: CloseTicketWorkflowAction;
536
+ add_chat_label: AddChatLabelWorkflowAction;
537
+ remove_chat_label: RemoveChatLabelWorkflowAction;
538
+ add_ticket_label: AddTicketLabelWorkflowAction;
539
+ remove_ticket_label: RemoveTicketLabelWorkflowAction;
540
+ assign_chat: AssignChatWorkflowAction;
541
+ forward_message: ForwardMessageWorkflowAction;
542
+ send_email: SendEmailWorkflowAction;
543
+ delete_message: DeleteMessageWorkflowAction;
544
+ close_chat: CloseChatWorkflowAction;
545
+ validate_action: ValidateWorkflowAction;
546
+ delay: DelayWorkflowAction;
547
+ send_slack_notification: SendSlackNotificationWorkflowAction;
548
+ ai_prompt: AIPromptWorkflowAction;
549
+ split_path: SplitPathWorkflowAction;
550
+ };
551
+
552
+ export type WorkflowActionTypes =
553
+ | NormalWorkflowActionTypes
554
+ | SplitPathWorkflowAction;
555
+
556
+ export type WorkflowActionCategory =
557
+ | 'message'
558
+ | 'ticket'
559
+ | 'chat'
560
+ | 'custom'
561
+ | 'flow'
562
+ | 'ai';
563
+
564
+ export const ActionCategoryMap: Record<
565
+ WorkflowActionTypes['type'],
566
+ WorkflowActionCategory
567
+ > = {
568
+ send_message_to_chat: 'message',
569
+ create_ticket: 'ticket',
570
+ attach_to_latest_ticket: 'ticket',
571
+ notify_http: 'custom',
572
+ flag_message: 'message',
573
+ unflag_message: 'message',
574
+ assign_ticket: 'ticket',
575
+ close_ticket: 'ticket',
576
+ add_chat_label: 'chat',
577
+ remove_chat_label: 'chat',
578
+ add_ticket_label: 'ticket',
579
+ remove_ticket_label: 'ticket',
580
+ assign_chat: 'chat',
581
+ forward_message: 'message',
582
+ send_email: 'custom',
583
+ delete_message: 'message',
584
+ close_chat: 'chat',
585
+ validate_action: 'flow',
586
+ delay: 'flow',
587
+ send_slack_notification: 'custom',
588
+ ai_prompt: 'ai',
589
+ split_path: 'flow',
590
+ };
591
+
592
+ export const CategoryNameMap: Record<WorkflowActionCategory, string> = {
593
+ message: 'Message',
594
+ ticket: 'Ticket',
595
+ chat: 'Chat',
596
+ custom: 'Custom',
597
+ flow: 'Flow',
598
+ ai: 'AI',
599
+ };
600
+
601
+ export const TriggerNameMap: Record<Triggers, string> = {
602
+ 'chat.closed': 'Chat Closed',
603
+ 'chat.created': 'Chat Created',
604
+ 'chat.label.updated': 'Chat Label Updated',
605
+ 'message.created': 'Message Created',
606
+ 'message.deleted': 'Message Deleted',
607
+ 'message.flagged': 'Message Flagged',
608
+ 'message.unflagged': 'Message Unflagged',
609
+ 'message.updated': 'Message Updated',
610
+ 'reaction.added': 'Reaction Added',
611
+ 'ticket.closed': 'Ticket Closed',
612
+ 'ticket.created': 'Ticket Created',
613
+ 'ticket.deleted': 'Ticket Deleted',
614
+ 'ticket.due': 'Ticket Due',
615
+ 'ticket.updated': 'Ticket Updated',
616
+ 'task.created': 'Task Created',
617
+ 'task.due': 'Task Due',
618
+ };
540
619
 
541
- export type WorkflowActionTypes = NormalWorkflowActionTypes | SplitPathAction;
620
+ export const WorkflowActionNameMap: Record<
621
+ WorkflowType['actions'][number]['action_metadata']['type'],
622
+ {
623
+ title: string;
624
+ description: string;
625
+ }
626
+ > = {
627
+ add_chat_label: {
628
+ title: 'Add Chat Label',
629
+ description: 'Add a label to the trigger chat',
630
+ },
631
+ add_ticket_label: {
632
+ title: 'Add Ticket Label',
633
+ description: 'Add a label to the trigger ticket',
634
+ },
635
+ assign_chat: {
636
+ title: 'Assign Chat',
637
+ description: 'Assign a chat to org user',
638
+ },
639
+ attach_to_latest_ticket: {
640
+ title: 'Attach to Latest Ticket',
641
+ description: 'Attach to the latest ticket of trigger chat',
642
+ },
643
+ close_chat: {
644
+ title: 'Close Chat',
645
+ description: 'Close the chat',
646
+ },
647
+ close_ticket: {
648
+ title: 'Close Ticket',
649
+ description: 'Close the trigger ticket or ticket attached to the message',
650
+ },
651
+ create_ticket: {
652
+ title: 'Create Ticket',
653
+ description: 'Create a ticket attached to the trigger message',
654
+ },
655
+ delay: {
656
+ title: 'Delay',
657
+ description: 'Add a delay to next sequential actions',
658
+ },
659
+ ai_prompt: {
660
+ title: 'AI Prompt',
661
+ description: 'Analyse, filter, categorise, and generate text using AI',
662
+ },
663
+ flag_message: {
664
+ title: 'Flag Message',
665
+ description: 'Flag the trigger message or message attached to the ticket',
666
+ },
667
+ remove_chat_label: {
668
+ title: 'Remove Chat Label',
669
+ description: 'Remove a label from the trigger chat',
670
+ },
671
+ remove_ticket_label: {
672
+ title: 'Remove Ticket Label',
673
+ description:
674
+ 'Remove a label from the trigger ticket or ticket attached to the message',
675
+ },
676
+ send_email: {
677
+ title: 'Send Email',
678
+ description: 'Send custom text to an email',
679
+ },
680
+ send_message_to_chat: {
681
+ title: 'Send Message to Chat',
682
+ description: 'Send a message to the chat attached to the trigger',
683
+ },
684
+ send_slack_notification: {
685
+ title: 'Send Slack Notification',
686
+ description: 'Send a slack notification',
687
+ },
688
+ split_path: {
689
+ title: 'Split Path',
690
+ description: 'Split the workflow path based on the condition',
691
+ },
692
+ unflag_message: {
693
+ title: 'Unflag Message',
694
+ description: 'Unflag the trigger message or message attached to the ticket',
695
+ },
696
+ validate_action: {
697
+ title: 'Validate Action',
698
+ description: 'Validate the action based on multiple criterias',
699
+ },
700
+ notify_http: {
701
+ title: 'Notify HTTP',
702
+ description: 'Send a custom HTTP request to an endpoint',
703
+ },
704
+ assign_ticket: {
705
+ title: 'Assign Ticket',
706
+ description: 'Assign a ticket to an org user',
707
+ },
708
+ forward_message: {
709
+ title: 'Forward Message',
710
+ description: 'Forward a message to a chat',
711
+ },
712
+ delete_message: {
713
+ title: 'Delete Message',
714
+ description: 'Delete the trigger message or message attached to the ticket',
715
+ },
716
+ };
542
717
 
543
718
  export type SendMessageToChatActionReturnInfo = {
544
719
  message_details: {
@@ -574,54 +749,6 @@ export type ActionInfo = {
574
749
  add_chat_label: AddChatLabelActionReturnInfo;
575
750
  };
576
751
 
577
- export const TriggerNameMap: Record<Triggers, string> = {
578
- 'chat.closed': 'Chat Closed',
579
- 'chat.created': 'Chat Created',
580
- 'chat.label.updated': 'Chat Label Updated',
581
- 'message.created': 'Message Created',
582
- 'message.deleted': 'Message Deleted',
583
- 'message.flagged': 'Message Flagged',
584
- 'message.unflagged': 'Message Unflagged',
585
- 'message.updated': 'Message Updated',
586
- 'reaction.added': 'Reaction Added',
587
- 'ticket.closed': 'Ticket Closed',
588
- 'ticket.created': 'Ticket Created',
589
- 'ticket.deleted': 'Ticket Deleted',
590
- 'ticket.due': 'Ticket Due',
591
- 'ticket.updated': 'Ticket Updated',
592
- 'task.created': 'Task Created',
593
- 'task.due': 'Task Due',
594
- };
595
-
596
- export const WorkflowActionNameMap: Record<
597
- WorkflowType['actions'][number]['action_metadata']['type'],
598
- string
599
- > = {
600
- add_chat_label: 'Add Chat Label',
601
- add_ticket_label: 'Add Ticket Label',
602
- assign_chat: 'Assign Chat',
603
- assign_ticket: 'Assign Ticket',
604
- attach_to_latest_ticket: 'Attach to Latest Ticket',
605
- close_chat: 'Close Chat',
606
- close_ticket: 'Close Ticket',
607
- create_ticket: 'Create Ticket',
608
- delete_message: 'Delete Message',
609
- delay: 'Delay',
610
- ai_prompt_check: 'AI Prompt',
611
- flag_message: 'Flag Message',
612
- forward_message: 'Forward Message',
613
- notify_http: 'Notify HTTP',
614
- remove_chat_label: 'Remove Chat Label',
615
- remove_ticket_label: 'Remove Ticket Label',
616
- send_email: 'Send Email',
617
- send_message_to_chat: 'Send Message to Chat',
618
- send_reply_message: 'Send Reply Message',
619
- send_slack_notification: 'Send Slack Notification',
620
- split_path: 'Split Path',
621
- unflag_message: 'Unflag Message',
622
- validate_action: 'Validate Action',
623
- };
624
-
625
752
  // Example workflow type ->
626
753
 
627
754
  // const demoWorkflow: WorkflowType = {
package/tsconfig.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
3
  "include": [
4
- "src/**/*"
5
- // "src/index.ts",
4
+ "src/**/*",
5
+ "src/index.ts",
6
+ "index.d.ts"
6
7
  ],
7
8
  "exclude": [
8
9
  "node_modules",