@periskope/types 0.6.120 → 0.6.122

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.
@@ -560,7 +560,7 @@ export type Database = {
560
560
  chat_id: string;
561
561
  chat_org_phones: string[];
562
562
  custom_properties: Json | null;
563
- flag_count: Json | null;
563
+ flag_count_map: Json | null;
564
564
  hubspot_metadata: Json | null;
565
565
  label_ids: Json | null;
566
566
  org_id: string;
@@ -573,7 +573,7 @@ export type Database = {
573
573
  chat_id: string;
574
574
  chat_org_phones?: string[];
575
575
  custom_properties?: Json | null;
576
- flag_count?: Json | null;
576
+ flag_count_map?: Json | null;
577
577
  hubspot_metadata?: Json | null;
578
578
  label_ids?: Json | null;
579
579
  org_id: string;
@@ -586,7 +586,7 @@ export type Database = {
586
586
  chat_id?: string;
587
587
  chat_org_phones?: string[];
588
588
  custom_properties?: Json | null;
589
- flag_count?: Json | null;
589
+ flag_count_map?: Json | null;
590
590
  hubspot_metadata?: Json | null;
591
591
  label_ids?: Json | null;
592
592
  org_id?: string;
@@ -665,6 +665,7 @@ export type Database = {
665
665
  close_ticket_metadata: Json | null;
666
666
  closed_at: string | null;
667
667
  created_at: string;
668
+ custom_properties: Json | null;
668
669
  due_date: string | null;
669
670
  freshdesk_metadata: Json | null;
670
671
  hubspot_metadata: Json | null;
@@ -688,6 +689,7 @@ export type Database = {
688
689
  close_ticket_metadata?: Json | null;
689
690
  closed_at?: string | null;
690
691
  created_at?: string;
692
+ custom_properties?: Json | null;
691
693
  due_date?: string | null;
692
694
  freshdesk_metadata?: Json | null;
693
695
  hubspot_metadata?: Json | null;
@@ -711,6 +713,7 @@ export type Database = {
711
713
  close_ticket_metadata?: Json | null;
712
714
  closed_at?: string | null;
713
715
  created_at?: string;
716
+ custom_properties?: Json | null;
714
717
  due_date?: string | null;
715
718
  freshdesk_metadata?: Json | null;
716
719
  hubspot_metadata?: Json | null;
@@ -840,6 +843,7 @@ export type Database = {
840
843
  is_business: boolean | null;
841
844
  is_enterprise: boolean | null;
842
845
  is_group: boolean | null;
846
+ is_imported: boolean | null;
843
847
  is_internal: boolean | null;
844
848
  is_me: boolean | null;
845
849
  is_my_contact: boolean | null;
@@ -868,6 +872,7 @@ export type Database = {
868
872
  is_business?: boolean | null;
869
873
  is_enterprise?: boolean | null;
870
874
  is_group?: boolean | null;
875
+ is_imported?: boolean | null;
871
876
  is_internal?: boolean | null;
872
877
  is_me?: boolean | null;
873
878
  is_my_contact?: boolean | null;
@@ -896,6 +901,7 @@ export type Database = {
896
901
  is_business?: boolean | null;
897
902
  is_enterprise?: boolean | null;
898
903
  is_group?: boolean | null;
904
+ is_imported?: boolean | null;
899
905
  is_internal?: boolean | null;
900
906
  is_me?: boolean | null;
901
907
  is_my_contact?: boolean | null;
@@ -1309,6 +1315,7 @@ export type Database = {
1309
1315
  qr_code: string | null;
1310
1316
  server_image: string | null;
1311
1317
  server_ip: string | null;
1318
+ soft_restart: boolean;
1312
1319
  updated_at: string | null;
1313
1320
  wa_state: string | null;
1314
1321
  wa_version: string | null;
@@ -1328,6 +1335,7 @@ export type Database = {
1328
1335
  qr_code?: string | null;
1329
1336
  server_image?: string | null;
1330
1337
  server_ip?: string | null;
1338
+ soft_restart?: boolean;
1331
1339
  updated_at?: string | null;
1332
1340
  wa_state?: string | null;
1333
1341
  wa_version?: string | null;
@@ -1347,6 +1355,7 @@ export type Database = {
1347
1355
  qr_code?: string | null;
1348
1356
  server_image?: string | null;
1349
1357
  server_ip?: string | null;
1358
+ soft_restart?: boolean;
1350
1359
  updated_at?: string | null;
1351
1360
  wa_state?: string | null;
1352
1361
  wa_version?: string | null;
@@ -1527,6 +1536,7 @@ export type Database = {
1527
1536
  created_at: string | null;
1528
1537
  custom_properties: Json | null;
1529
1538
  flag_count: number | null;
1539
+ flag_count_map: Json | null;
1530
1540
  group_description: string | null;
1531
1541
  hubspot_metadata: Json | null;
1532
1542
  info_admins_only: boolean | null;
@@ -1705,15 +1715,6 @@ export type Database = {
1705
1715
  };
1706
1716
  Returns: Json;
1707
1717
  };
1708
- get_dashboard_statistics_between_dates: {
1709
- Args: {
1710
- org_id_input: string;
1711
- start_date: string;
1712
- end_date: string;
1713
- chat_id_input?: string[];
1714
- };
1715
- Returns: Json;
1716
- };
1717
1718
  get_export_chats_data: {
1718
1719
  Args: {
1719
1720
  org_id_input: string;
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { default as _Stripe } from 'stripe';
2
2
  import { Merge, OverrideProperties } from 'type-fest';
3
- import { Tables } from './supabase.types';
3
+ import { Tables, TablesUpdate } from './supabase.types';
4
4
  export declare enum AllPlans {
5
5
  FREE_TRIAL = "free-trial",
6
6
  ENTERPRISE = "enterprise",
@@ -180,8 +180,9 @@ export type ContactType = Merge<Tables<'tbl_contacts'>, {
180
180
  }>;
181
181
  export type ReactionType = Tables<'tbl_chat_reactions'>;
182
182
  export type NotificationType = Tables<'tbl_chat_notifications'>;
183
- export type ChatAccessType = Merge<Tables<'tbl_org_members'>, {
183
+ export type ChatAccessType = Merge<TablesUpdate<'tbl_org_members'>, {
184
184
  has_access?: boolean;
185
+ email: string | null;
185
186
  }>;
186
187
  export declare const labelColors: string[];
187
188
  export declare const enumChatColors: readonly ["#B4876E", "#A5B337", "#06CF9C", "#25D366", "#02A698", "#7D9EF1", "#007BFC", "#5E47DE", "#7F66FF", "#9333EA", "#FA6533", "#C4532D", "#DC2626", "#FF2E74", "#DB2777"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@periskope/types",
3
- "version": "0.6.120",
3
+ "version": "0.6.122",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/supabase.types.ts CHANGED
@@ -565,7 +565,7 @@ export type Database = {
565
565
  chat_id: string
566
566
  chat_org_phones: string[]
567
567
  custom_properties: Json | null
568
- flag_count: Json | null
568
+ flag_count_map: Json | null
569
569
  hubspot_metadata: Json | null
570
570
  label_ids: Json | null
571
571
  org_id: string
@@ -578,7 +578,7 @@ export type Database = {
578
578
  chat_id: string
579
579
  chat_org_phones?: string[]
580
580
  custom_properties?: Json | null
581
- flag_count?: Json | null
581
+ flag_count_map?: Json | null
582
582
  hubspot_metadata?: Json | null
583
583
  label_ids?: Json | null
584
584
  org_id: string
@@ -591,7 +591,7 @@ export type Database = {
591
591
  chat_id?: string
592
592
  chat_org_phones?: string[]
593
593
  custom_properties?: Json | null
594
- flag_count?: Json | null
594
+ flag_count_map?: Json | null
595
595
  hubspot_metadata?: Json | null
596
596
  label_ids?: Json | null
597
597
  org_id?: string
@@ -670,6 +670,7 @@ export type Database = {
670
670
  close_ticket_metadata: Json | null
671
671
  closed_at: string | null
672
672
  created_at: string
673
+ custom_properties: Json | null
673
674
  due_date: string | null
674
675
  freshdesk_metadata: Json | null
675
676
  hubspot_metadata: Json | null
@@ -693,6 +694,7 @@ export type Database = {
693
694
  close_ticket_metadata?: Json | null
694
695
  closed_at?: string | null
695
696
  created_at?: string
697
+ custom_properties?: Json | null
696
698
  due_date?: string | null
697
699
  freshdesk_metadata?: Json | null
698
700
  hubspot_metadata?: Json | null
@@ -718,6 +720,7 @@ export type Database = {
718
720
  close_ticket_metadata?: Json | null
719
721
  closed_at?: string | null
720
722
  created_at?: string
723
+ custom_properties?: Json | null
721
724
  due_date?: string | null
722
725
  freshdesk_metadata?: Json | null
723
726
  hubspot_metadata?: Json | null
@@ -849,6 +852,7 @@ export type Database = {
849
852
  is_business: boolean | null
850
853
  is_enterprise: boolean | null
851
854
  is_group: boolean | null
855
+ is_imported: boolean | null
852
856
  is_internal: boolean | null
853
857
  is_me: boolean | null
854
858
  is_my_contact: boolean | null
@@ -877,6 +881,7 @@ export type Database = {
877
881
  is_business?: boolean | null
878
882
  is_enterprise?: boolean | null
879
883
  is_group?: boolean | null
884
+ is_imported?: boolean | null
880
885
  is_internal?: boolean | null
881
886
  is_me?: boolean | null
882
887
  is_my_contact?: boolean | null
@@ -905,6 +910,7 @@ export type Database = {
905
910
  is_business?: boolean | null
906
911
  is_enterprise?: boolean | null
907
912
  is_group?: boolean | null
913
+ is_imported?: boolean | null
908
914
  is_internal?: boolean | null
909
915
  is_me?: boolean | null
910
916
  is_my_contact?: boolean | null
@@ -1318,6 +1324,7 @@ export type Database = {
1318
1324
  qr_code: string | null
1319
1325
  server_image: string | null
1320
1326
  server_ip: string | null
1327
+ soft_restart: boolean
1321
1328
  updated_at: string | null
1322
1329
  wa_state: string | null
1323
1330
  wa_version: string | null
@@ -1337,6 +1344,7 @@ export type Database = {
1337
1344
  qr_code?: string | null
1338
1345
  server_image?: string | null
1339
1346
  server_ip?: string | null
1347
+ soft_restart?: boolean
1340
1348
  updated_at?: string | null
1341
1349
  wa_state?: string | null
1342
1350
  wa_version?: string | null
@@ -1356,6 +1364,7 @@ export type Database = {
1356
1364
  qr_code?: string | null
1357
1365
  server_image?: string | null
1358
1366
  server_ip?: string | null
1367
+ soft_restart?: boolean
1359
1368
  updated_at?: string | null
1360
1369
  wa_state?: string | null
1361
1370
  wa_version?: string | null
@@ -1538,6 +1547,7 @@ export type Database = {
1538
1547
  created_at: string | null
1539
1548
  custom_properties: Json | null
1540
1549
  flag_count: number | null
1550
+ flag_count_map: Json | null
1541
1551
  group_description: string | null
1542
1552
  hubspot_metadata: Json | null
1543
1553
  info_admins_only: boolean | null
@@ -1716,15 +1726,6 @@ export type Database = {
1716
1726
  }
1717
1727
  Returns: Json
1718
1728
  }
1719
- get_dashboard_statistics_between_dates: {
1720
- Args: {
1721
- org_id_input: string
1722
- start_date: string
1723
- end_date: string
1724
- chat_id_input?: string[]
1725
- }
1726
- Returns: Json
1727
- }
1728
1729
  get_export_chats_data: {
1729
1730
  Args: {
1730
1731
  org_id_input: string
@@ -2284,4 +2285,4 @@ export type Enums<
2284
2285
  ? PublicSchema["Enums"][PublicEnumNameOrOptions]
2285
2286
  : never
2286
2287
 
2287
-
2288
+
package/types.ts CHANGED
@@ -1,533 +1,534 @@
1
- import type { default as _Stripe } from 'stripe';
2
- import { Merge, OverrideProperties } from 'type-fest';
3
- import { Tables } from './supabase.types';
4
-
5
- /* ----------------------------- TYPE SHORTHANDS ---------------------------- */
6
-
7
- /* ------------------------------ PERISKOPE TYPES ------------------------------ */
8
-
9
- export enum AllPlans {
10
- FREE_TRIAL = 'free-trial',
11
- // MONTHLY_STARTER = 'monthly-starter',
12
- // YEARLY_STARTER = 'yearly-starter',
13
- // MONTHLY_PRO = 'monthly-pro',
14
- // YEARLY_PRO = 'yearly-pro',
15
- ENTERPRISE = 'enterprise',
16
- MONTHLY_STARTER_SINGLE = 'monthly-starter-single',
17
- YEARLY_STARTER_SINGLE = 'yearly-starter-single',
18
- MONTHLY_PRO_SINGLE = 'monthly-pro-single',
19
- YEARLY_PRO_SINGLE = 'yearly-pro-single',
20
- }
21
-
22
- export type Frequency = 'yearly' | 'monthly' | 'weekly' | 'custom';
23
-
24
- export type Enterprise = `${string}-enterprise`;
25
-
26
- export type OrgPlanEnterprise = {
27
- subscription_id: string;
28
- plan_id: Enterprise;
29
- interval: number;
30
- frequency: Frequency;
31
- user_limit: number;
32
- phone_limit: number;
33
- current_period_start: number;
34
- current_period_end: number | null;
35
- };
36
-
37
- export type OrgPlanNonEnterprise = {
38
- subscription_id: string;
39
- plan_id: AllPlans;
40
- interval: number;
41
- frequency: Frequency;
42
- user_limit: number;
43
- phone_limit: number;
44
- current_period_end: number;
45
- current_period_start: number;
46
- };
47
-
48
- export type OrgPlan<T extends AllPlans | Enterprise> = T extends Enterprise
49
- ? OrgPlanEnterprise
50
- : T extends AllPlans
51
- ? OrgPlanNonEnterprise
52
- : never;
53
-
54
- export type MicrosurveyData = {
55
- key: string;
56
- text: string;
57
- checked: boolean;
58
- }[];
59
-
60
- export type OrgPreferences = {
61
- disable_ai_flagging?: boolean;
62
- disable_allow_exports?: boolean;
63
- sync_phone_contacts?: boolean;
64
- mask_phone_numbers?: boolean;
65
- show_sender_names?: boolean;
66
- };
67
-
68
- type OrgPreferenceKey = keyof OrgPreferences;
69
-
70
- export type OrgPreferencesValue = {
71
- [K in OrgPreferenceKey]: { key: K; value: OrgPreferences[K] };
72
- }[OrgPreferenceKey];
73
-
74
- export type OrgMetadata = {
75
- phone_number: string;
76
- ticket_prefix: string;
77
- referralSource?: string;
78
- surveyData?: MicrosurveyData;
79
- preferences?: OrgPreferences;
80
- hubspot_pipelines?: {
81
- id: string;
82
- label: string;
83
- default_stage: { id: string; label: string };
84
- }[];
85
- partition?: boolean;
86
- };
87
-
88
- type AccessScopes = {
89
- integrations: boolean;
90
- exports: boolean;
91
- };
92
-
93
- export type OrgType = OverrideProperties<
94
- Merge<
95
- Tables<'tbl_org'>,
96
- {
97
- user: Tables<'tbl_org_members'>;
98
- members: Tables<'tbl_org_members'>[];
99
- phones: Tables<'tbl_org_phones'>[];
100
- labels: Tables<'tbl_org_labels'>[];
101
- quick_replies: Tables<'tbl_quick_replies'>[];
102
- custom_properties: Tables<'tbl_custom_properties'>[];
103
- subscription_status: 'active' | 'inactive' | 'unpaid';
104
- is_enterprise: boolean;
105
- is_free_trial: boolean;
106
- is_hubspot_connected: boolean;
107
- is_freshdesk_connected: boolean;
108
- is_zohodesk_connected: boolean;
109
- access_scopes: AccessScopes;
110
- }
111
- >,
112
- {
113
- org_plan: OrgPlan<AllPlans | Enterprise>;
114
- stripe_customer_details: _Stripe.Customer | null;
115
- stripe_subscription_details: Array<_Stripe.Subscription> | null;
116
- stripe_customer_id: _Stripe.Customer['id'] | null;
117
- org_metadata: OrgMetadata;
118
- }
119
- >;
120
-
121
- export type ChatMemberType = Merge<
122
- Tables<'tbl_chat_participants'>,
123
- Tables<'tbl_contacts'>
124
- >;
125
-
126
- export type ChatType = Merge<
127
- Tables<'view_chats'>,
128
- {
129
- chat_id: string;
130
- latest_message: MessageType | null;
131
- members: { [key: string]: ChatMemberType } | null;
132
- chat_type: 'user' | 'group' | 'business' | 'unknown';
133
- chat_access: { [key: string]: boolean };
134
- label_ids: { [key: string]: boolean };
135
- chat_org_phones?: string[];
136
- message_unread_count: number | null;
137
- hubspot_metadata: {
138
- id: string;
139
- type: string;
140
- hubId: string;
141
- object_data: HubspotObjectDataType;
142
- } | null;
143
- info_admins_only: boolean;
144
- messages_admins_only: boolean;
145
- unread_count?: { [key: string]: number };
146
- active_phone: string | null;
147
- flag_count_map?: { [key: string]: number };
148
- }
149
- >;
150
-
151
- /* -------------------------------------------------------------------------- */
152
- /* MESSAGE */
153
- /* -------------------------------------------------------------------------- */
154
-
155
- export type MediaType = {
156
- path: string;
157
- mimetype?: string;
158
- filename?: string;
159
- dimensions?: { width: number; height: number; ar: number };
160
- size?: number;
161
- thumbnail?: string;
162
- };
163
-
164
- export type MessageType = OverrideProperties<
165
- Tables<'tbl_chat_messages'>,
166
- {
167
- message_id: string;
168
- org_id: string;
169
- org_phone: string;
170
- chat_id: string;
171
- message_type: (typeof SUPPORTED_TYPES)[number];
172
- media: MediaType | null;
173
- flag_metadata: MessageFlagType | null;
174
- }
175
- >;
176
-
177
- export type MessageFlagType = {
178
- status: boolean;
179
- response_type?: 'message' | 'reaction' | 'ticket';
180
- response_id?: string;
181
- response_timestamp?: string;
182
- response_email?: string;
183
- };
184
-
185
- /* -------------------------------------------------------------------------- */
186
-
187
- export type TicketType = OverrideProperties<
188
- Tables<'tbl_chat_tickets'>,
189
- {
190
- label_ids: { [key: string]: boolean };
191
- hubspot_metadata: {
192
- id?: string;
193
- type?: string;
194
- hubId?: string;
195
- pipeline: {
196
- id: string;
197
- label: string;
198
- };
199
- object_data?: HubspotObjectDataType;
200
- } | null;
201
- freshdesk_metadata: Record<string, string>;
202
- close_ticket_metadata?:
203
- | {
204
- closed_by: string;
205
- closed_at: string;
206
- closed_message?: string | null;
207
- send_reply_message_id?: string | null;
208
- }
209
- | any;
210
- }
211
- >;
212
-
213
- export type ContactType = Merge<
214
- Tables<'tbl_contacts'>,
215
- {
216
- chats: ChatType[] | null;
217
- chat_ids?: string[];
218
- }
219
- >;
220
- export type ReactionType = Tables<'tbl_chat_reactions'>;
221
-
222
- export type NotificationType = Tables<'tbl_chat_notifications'>;
223
-
224
- export type ChatAccessType = Merge<
225
- Tables<'tbl_org_members'>,
226
- {
227
- has_access?: boolean;
228
- }
229
- >;
230
-
231
- /* -------------------------------- CONSTANTS ------------------------------- */
232
-
233
- export const labelColors = [
234
- '#9333EA',
235
- '#0D9488',
236
- '#DB2777',
237
- '#2563EB',
238
- '#F97316',
239
- ];
240
-
241
- export const enumChatColors = [
242
- '#B4876E',
243
- '#A5B337',
244
- '#06CF9C',
245
- '#25D366',
246
- '#02A698',
247
- '#7D9EF1',
248
- '#007BFC',
249
- '#5E47DE',
250
- '#7F66FF',
251
- '#9333EA',
252
- '#FA6533',
253
- '#C4532D',
254
- '#DC2626',
255
- '#FF2E74',
256
- '#DB2777',
257
- ] as const;
258
-
259
- /* -------------------------- SEND MESSAGE PAYLOAD -------------------------- */
260
-
261
- export const SUPPORTED_TYPES = [
262
- 'chat',
263
- 'sticker',
264
- 'image',
265
- 'video',
266
- 'document',
267
- 'vcard',
268
- 'multi_vcard',
269
- 'audio',
270
- 'ptt',
271
- 'poll_creation',
272
- 'location',
273
- 'ciphertext',
274
- ] as const;
275
-
276
- export type SendMessageContent = {
277
- message_type?: (typeof SUPPORTED_TYPES)[number];
278
- body?: string;
279
- media?: MediaType;
280
- contact_ids?: string[];
281
- location?: {
282
- latitude: string;
283
- longitude: string;
284
- options?: { name?: string; address?: string; url?: string };
285
- };
286
- poll?: {
287
- pollName: string;
288
- pollOptions: string[];
289
- options?: {
290
- allowMultipleAnswers?: boolean;
291
- messageSecret?: number[] | null;
292
- pollId?: string;
293
- };
294
- };
295
- quoted_message_id?: string;
296
- quoted_message_type?: 'reply' | 'forward' | 'reply_private';
297
- broadcast_id?: string;
298
- performed_by?: string;
299
- };
300
-
301
- export type QuickReplyContent = Omit<
302
- SendMessageContent,
303
- 'broadcast_id' | 'variables'
304
- >;
305
-
306
- export type BroadcastVariableType = {
307
- chat_id: string;
308
- values: { [key: string]: string };
309
- };
310
-
311
- export type BroadcastMessagePayload = SendMessageContent & {
312
- chat_ids: string[];
313
- broadcast_id?: string;
314
- variables?: BroadcastVariableType[];
315
- };
316
-
317
- export type SingleMessagePayload = SendMessageContent & {
318
- chat_id: string;
319
- job_id?: string;
320
- };
321
-
322
- export type MessageAttachmentFileTypes =
323
- | 'image'
324
- | 'audio'
325
- | 'document'
326
- | 'video';
327
-
328
- export type AttachmentFileType = {
329
- result: string;
330
- file: File | null;
331
- type: MessageAttachmentFileTypes;
332
- localFileURL?: string;
333
- };
334
-
335
- export type AttachmentLinkType = {
336
- link: {
337
- url: string;
338
- type: MessageAttachmentFileTypes;
339
- name: string;
340
- mimetype?: string;
341
- };
342
- };
343
-
344
- export type AttachmentTypeProps = AttachmentFileType | AttachmentLinkType;
345
-
346
- /* -------------------------------- BROADCAST ------------------------------- */
347
-
348
- export type BroadcastLogType = Tables<'view_broadcast_logs'> & {
349
- logs: (Tables<'tbl_broadcast_logs'> & Partial<ChatType>)[];
350
- } & {
351
- chats: ChatType[];
352
- };
353
-
354
- /* ----------------------- CHAT PARTICIPANT OPERATION ----------------------- */
355
-
356
- export type ChatLogType = {
357
- log: Tables<'view_chat_logs'>;
358
- operations: Tables<'tbl_chat_logs'>[];
359
- };
360
- export type ChatOperationsType = 'ADD' | 'REMOVE' | 'PROMOTE' | 'DEMOTE';
361
-
362
- export type ChatParticipantOperationPayload = {
363
- participant_ids: string[];
364
- chat_ids: string[];
365
- performed_by: string;
366
- };
367
-
368
- export type ChatOperationReturn = {
369
- [participant_id: string]: {
370
- is_success: boolean;
371
- message?: string;
372
- code?: number;
373
- isInviteV4Sent?: boolean;
374
- };
375
- };
376
-
377
- /* ----------------------- BILLING - STRIPE ----------------------- */
378
-
379
- export type StripeSubscription = _Stripe.Subscription;
380
- export type StripeCustomer = _Stripe.Customer;
381
- export type StripeCoupon = _Stripe.Coupon;
382
- export type StripePrice = _Stripe.Price;
383
- export type Stripe = _Stripe;
384
- export type StripeUpcomingInvoice = _Stripe.UpcomingInvoice;
385
- export type StripeLineItem = _Stripe.Checkout.SessionCreateParams.LineItem;
386
-
387
- /* -------------------------------- REALTIME -------------------------------- */
388
-
389
- export type PhoneStateType = {
390
- loading: boolean;
391
- state: string;
392
- sync: number;
393
- percent: number | null;
394
- message?: string;
395
- error?: string;
396
- };
397
-
398
- /* ------------------------------- INTEGRATIONS ----------------------------- */
399
-
400
- export type ChatInfoType = Merge<
401
- ChatType,
402
- {
403
- members: {
404
- [key: string]: Merge<ChatMemberType, { contact_labels: string }>;
405
- } | null;
406
- chat_labels: string | null;
407
- custom_properties: { [key: string]: string } | null;
408
- }
409
- >;
410
-
411
- export type TicketInfoType = {
412
- chat: ChatInfoType;
413
- message: {
414
- body: string;
415
- chat_id: string;
416
- org_phone: string;
417
- timestamp: string;
418
- media_path: string;
419
- message_id: string;
420
- sender_name: string;
421
- performed_by: string;
422
- sender_phone: string;
423
- };
424
- ticket: {
425
- org_id: string;
426
- status: string;
427
- subject: string;
428
- assignee: string;
429
- due_date: string;
430
- priority: 0 | 1 | 2 | 3 | 4;
431
- raised_by: string;
432
- ticket_id: string;
433
- created_at: string;
434
- assigned_by: string;
435
- ticket_labels: string;
436
- quoted_message_id: string;
437
- };
438
- };
439
-
440
- export enum IntegrationLogType {
441
- NEW_CHAT = 'chat.created',
442
- NEW_CHAT_NOTIFICATION = 'chat.notification.created',
443
- NEW_MESSAGE = 'message.created',
444
- MESSAGE_UPDATED = 'message.updated',
445
- MESSAGE_DELETED = 'message.deleted',
446
- MESSAGE_ACK_UPDATED = 'message.ack.updated',
447
- REACTION_CREATED = 'reaction.created',
448
- REACTION_UPDATED = 'reaction.updated',
449
- NEW_TICKET = 'ticket.created',
450
- TICKET_UPDATED = 'ticket.updated',
451
- TICKET_DELETED = 'ticket.deleted',
452
- }
453
-
454
- export type IntegrationLogMetadataType<T extends IntegrationLogType> =
455
- T extends IntegrationLogType.NEW_TICKET | IntegrationLogType.TICKET_UPDATED
456
- ? TicketInfoType
457
- : T extends IntegrationLogType.NEW_CHAT
458
- ? Tables<'tbl_chats'>
459
- : T extends
460
- | IntegrationLogType.NEW_MESSAGE
461
- | IntegrationLogType.MESSAGE_UPDATED
462
- | IntegrationLogType.MESSAGE_DELETED
463
- | IntegrationLogType.MESSAGE_ACK_UPDATED
464
- ? Tables<'tbl_chat_messages'>
465
- : T extends
466
- | IntegrationLogType.REACTION_CREATED
467
- | IntegrationLogType.REACTION_UPDATED
468
- ? Tables<'tbl_chat_reactions'>
469
- : {
470
- [key: string]: unknown;
471
- };
472
-
473
- export type IntegrationLogDetailsType<T extends IntegrationLogType> =
474
- OverrideProperties<
475
- Tables<'tbl_integration_logs'>,
476
- {
477
- integration_name: T;
478
- metadata: {
479
- event: IntegrationLogMetadataType<T> & {
480
- event_type: string;
481
- org_id: string;
482
- previous_attributes: {
483
- [key: string]: unknown;
484
- };
485
- };
486
- hook_id: string;
487
- name: string;
488
- };
489
- }
490
- >;
491
-
492
- export type APIAuthDetails = {
493
- org_details: Tables<'view_org'> | null;
494
- phone_details: Tables<'tbl_org_phones'> | null;
495
- token_details: Tables<'tbl_integration_tokens'> | null;
496
- };
497
-
498
- export type WebhookDataType = OverrideProperties<
499
- Tables<'tbl_integration_hooks'>,
500
- {
501
- integration_name: string[];
502
- }
503
- >;
504
-
505
- export type HubspotObjectDataType = {
506
- createdAt: string;
507
- archived: boolean;
508
- id: string;
509
- type: 'contacts' | 'tickets' | 'companies';
510
- properties: Record<
511
- string,
512
- {
513
- groupLabel: string;
514
- groupName: string;
515
- propertyKeyName: string;
516
- propertyKey: string;
517
- propertyInternalValue: string;
518
- propertyValue: string;
519
- propertyType: string;
520
- propertyFieldType: string;
521
- }[]
522
- >;
523
- };
524
-
525
- /* ---------------------------- USER PREFERENCES ---------------------------- */
526
-
527
- export type UserPreferences = {
528
- theme: 'light' | 'dark';
529
- language: 'en' | 'es';
530
- left_sidebar_open: boolean;
531
- right_sidepanel_open: boolean;
532
- sync_wa_unread_count: boolean;
533
- };
1
+ import type { default as _Stripe } from 'stripe';
2
+ import { Merge, OverrideProperties } from 'type-fest';
3
+ import { Tables, TablesUpdate } from './supabase.types';
4
+
5
+ /* ----------------------------- TYPE SHORTHANDS ---------------------------- */
6
+
7
+ /* ------------------------------ PERISKOPE TYPES ------------------------------ */
8
+
9
+ export enum AllPlans {
10
+ FREE_TRIAL = 'free-trial',
11
+ // MONTHLY_STARTER = 'monthly-starter',
12
+ // YEARLY_STARTER = 'yearly-starter',
13
+ // MONTHLY_PRO = 'monthly-pro',
14
+ // YEARLY_PRO = 'yearly-pro',
15
+ ENTERPRISE = 'enterprise',
16
+ MONTHLY_STARTER_SINGLE = 'monthly-starter-single',
17
+ YEARLY_STARTER_SINGLE = 'yearly-starter-single',
18
+ MONTHLY_PRO_SINGLE = 'monthly-pro-single',
19
+ YEARLY_PRO_SINGLE = 'yearly-pro-single',
20
+ }
21
+
22
+ export type Frequency = 'yearly' | 'monthly' | 'weekly' | 'custom';
23
+
24
+ export type Enterprise = `${string}-enterprise`;
25
+
26
+ export type OrgPlanEnterprise = {
27
+ subscription_id: string;
28
+ plan_id: Enterprise;
29
+ interval: number;
30
+ frequency: Frequency;
31
+ user_limit: number;
32
+ phone_limit: number;
33
+ current_period_start: number;
34
+ current_period_end: number | null;
35
+ };
36
+
37
+ export type OrgPlanNonEnterprise = {
38
+ subscription_id: string;
39
+ plan_id: AllPlans;
40
+ interval: number;
41
+ frequency: Frequency;
42
+ user_limit: number;
43
+ phone_limit: number;
44
+ current_period_end: number;
45
+ current_period_start: number;
46
+ };
47
+
48
+ export type OrgPlan<T extends AllPlans | Enterprise> = T extends Enterprise
49
+ ? OrgPlanEnterprise
50
+ : T extends AllPlans
51
+ ? OrgPlanNonEnterprise
52
+ : never;
53
+
54
+ export type MicrosurveyData = {
55
+ key: string;
56
+ text: string;
57
+ checked: boolean;
58
+ }[];
59
+
60
+ export type OrgPreferences = {
61
+ disable_ai_flagging?: boolean;
62
+ disable_allow_exports?: boolean;
63
+ sync_phone_contacts?: boolean;
64
+ mask_phone_numbers?: boolean;
65
+ show_sender_names?: boolean;
66
+ };
67
+
68
+ type OrgPreferenceKey = keyof OrgPreferences;
69
+
70
+ export type OrgPreferencesValue = {
71
+ [K in OrgPreferenceKey]: { key: K; value: OrgPreferences[K] };
72
+ }[OrgPreferenceKey];
73
+
74
+ export type OrgMetadata = {
75
+ phone_number: string;
76
+ ticket_prefix: string;
77
+ referralSource?: string;
78
+ surveyData?: MicrosurveyData;
79
+ preferences?: OrgPreferences;
80
+ hubspot_pipelines?: {
81
+ id: string;
82
+ label: string;
83
+ default_stage: { id: string; label: string };
84
+ }[];
85
+ partition?: boolean;
86
+ };
87
+
88
+ type AccessScopes = {
89
+ integrations: boolean;
90
+ exports: boolean;
91
+ };
92
+
93
+ export type OrgType = OverrideProperties<
94
+ Merge<
95
+ Tables<'tbl_org'>,
96
+ {
97
+ user: Tables<'tbl_org_members'>;
98
+ members: Tables<'tbl_org_members'>[];
99
+ phones: Tables<'tbl_org_phones'>[];
100
+ labels: Tables<'tbl_org_labels'>[];
101
+ quick_replies: Tables<'tbl_quick_replies'>[];
102
+ custom_properties: Tables<'tbl_custom_properties'>[];
103
+ subscription_status: 'active' | 'inactive' | 'unpaid';
104
+ is_enterprise: boolean;
105
+ is_free_trial: boolean;
106
+ is_hubspot_connected: boolean;
107
+ is_freshdesk_connected: boolean;
108
+ is_zohodesk_connected: boolean;
109
+ access_scopes: AccessScopes;
110
+ }
111
+ >,
112
+ {
113
+ org_plan: OrgPlan<AllPlans | Enterprise>;
114
+ stripe_customer_details: _Stripe.Customer | null;
115
+ stripe_subscription_details: Array<_Stripe.Subscription> | null;
116
+ stripe_customer_id: _Stripe.Customer['id'] | null;
117
+ org_metadata: OrgMetadata;
118
+ }
119
+ >;
120
+
121
+ export type ChatMemberType = Merge<
122
+ Tables<'tbl_chat_participants'>,
123
+ Tables<'tbl_contacts'>
124
+ >;
125
+
126
+ export type ChatType = Merge<
127
+ Tables<'view_chats'>,
128
+ {
129
+ chat_id: string;
130
+ latest_message: MessageType | null;
131
+ members: { [key: string]: ChatMemberType } | null;
132
+ chat_type: 'user' | 'group' | 'business' | 'unknown';
133
+ chat_access: { [key: string]: boolean };
134
+ label_ids: { [key: string]: boolean };
135
+ chat_org_phones?: string[];
136
+ message_unread_count: number | null;
137
+ hubspot_metadata: {
138
+ id: string;
139
+ type: string;
140
+ hubId: string;
141
+ object_data: HubspotObjectDataType;
142
+ } | null;
143
+ info_admins_only: boolean;
144
+ messages_admins_only: boolean;
145
+ unread_count?: { [key: string]: number };
146
+ active_phone: string | null;
147
+ flag_count_map?: { [key: string]: number };
148
+ }
149
+ >;
150
+
151
+ /* -------------------------------------------------------------------------- */
152
+ /* MESSAGE */
153
+ /* -------------------------------------------------------------------------- */
154
+
155
+ export type MediaType = {
156
+ path: string;
157
+ mimetype?: string;
158
+ filename?: string;
159
+ dimensions?: { width: number; height: number; ar: number };
160
+ size?: number;
161
+ thumbnail?: string;
162
+ };
163
+
164
+ export type MessageType = OverrideProperties<
165
+ Tables<'tbl_chat_messages'>,
166
+ {
167
+ message_id: string;
168
+ org_id: string;
169
+ org_phone: string;
170
+ chat_id: string;
171
+ message_type: (typeof SUPPORTED_TYPES)[number];
172
+ media: MediaType | null;
173
+ flag_metadata: MessageFlagType | null;
174
+ }
175
+ >;
176
+
177
+ export type MessageFlagType = {
178
+ status: boolean;
179
+ response_type?: 'message' | 'reaction' | 'ticket';
180
+ response_id?: string;
181
+ response_timestamp?: string;
182
+ response_email?: string;
183
+ };
184
+
185
+ /* -------------------------------------------------------------------------- */
186
+
187
+ export type TicketType = OverrideProperties<
188
+ Tables<'tbl_chat_tickets'>,
189
+ {
190
+ label_ids: { [key: string]: boolean };
191
+ hubspot_metadata: {
192
+ id?: string;
193
+ type?: string;
194
+ hubId?: string;
195
+ pipeline: {
196
+ id: string;
197
+ label: string;
198
+ };
199
+ object_data?: HubspotObjectDataType;
200
+ } | null;
201
+ freshdesk_metadata: Record<string, string>;
202
+ close_ticket_metadata?:
203
+ | {
204
+ closed_by: string;
205
+ closed_at: string;
206
+ closed_message?: string | null;
207
+ send_reply_message_id?: string | null;
208
+ }
209
+ | any;
210
+ }
211
+ >;
212
+
213
+ export type ContactType = Merge<
214
+ Tables<'tbl_contacts'>,
215
+ {
216
+ chats: ChatType[] | null;
217
+ chat_ids?: string[];
218
+ }
219
+ >;
220
+ export type ReactionType = Tables<'tbl_chat_reactions'>;
221
+
222
+ export type NotificationType = Tables<'tbl_chat_notifications'>;
223
+
224
+ export type ChatAccessType = Merge<
225
+ TablesUpdate<'tbl_org_members'>,
226
+ {
227
+ has_access?: boolean;
228
+ email: string | null;
229
+ }
230
+ >;
231
+
232
+ /* -------------------------------- CONSTANTS ------------------------------- */
233
+
234
+ export const labelColors = [
235
+ '#9333EA',
236
+ '#0D9488',
237
+ '#DB2777',
238
+ '#2563EB',
239
+ '#F97316',
240
+ ];
241
+
242
+ export const enumChatColors = [
243
+ '#B4876E',
244
+ '#A5B337',
245
+ '#06CF9C',
246
+ '#25D366',
247
+ '#02A698',
248
+ '#7D9EF1',
249
+ '#007BFC',
250
+ '#5E47DE',
251
+ '#7F66FF',
252
+ '#9333EA',
253
+ '#FA6533',
254
+ '#C4532D',
255
+ '#DC2626',
256
+ '#FF2E74',
257
+ '#DB2777',
258
+ ] as const;
259
+
260
+ /* -------------------------- SEND MESSAGE PAYLOAD -------------------------- */
261
+
262
+ export const SUPPORTED_TYPES = [
263
+ 'chat',
264
+ 'sticker',
265
+ 'image',
266
+ 'video',
267
+ 'document',
268
+ 'vcard',
269
+ 'multi_vcard',
270
+ 'audio',
271
+ 'ptt',
272
+ 'poll_creation',
273
+ 'location',
274
+ 'ciphertext',
275
+ ] as const;
276
+
277
+ export type SendMessageContent = {
278
+ message_type?: (typeof SUPPORTED_TYPES)[number];
279
+ body?: string;
280
+ media?: MediaType;
281
+ contact_ids?: string[];
282
+ location?: {
283
+ latitude: string;
284
+ longitude: string;
285
+ options?: { name?: string; address?: string; url?: string };
286
+ };
287
+ poll?: {
288
+ pollName: string;
289
+ pollOptions: string[];
290
+ options?: {
291
+ allowMultipleAnswers?: boolean;
292
+ messageSecret?: number[] | null;
293
+ pollId?: string;
294
+ };
295
+ };
296
+ quoted_message_id?: string;
297
+ quoted_message_type?: 'reply' | 'forward' | 'reply_private';
298
+ broadcast_id?: string;
299
+ performed_by?: string;
300
+ };
301
+
302
+ export type QuickReplyContent = Omit<
303
+ SendMessageContent,
304
+ 'broadcast_id' | 'variables'
305
+ >;
306
+
307
+ export type BroadcastVariableType = {
308
+ chat_id: string;
309
+ values: { [key: string]: string };
310
+ };
311
+
312
+ export type BroadcastMessagePayload = SendMessageContent & {
313
+ chat_ids: string[];
314
+ broadcast_id?: string;
315
+ variables?: BroadcastVariableType[];
316
+ };
317
+
318
+ export type SingleMessagePayload = SendMessageContent & {
319
+ chat_id: string;
320
+ job_id?: string;
321
+ };
322
+
323
+ export type MessageAttachmentFileTypes =
324
+ | 'image'
325
+ | 'audio'
326
+ | 'document'
327
+ | 'video';
328
+
329
+ export type AttachmentFileType = {
330
+ result: string;
331
+ file: File | null;
332
+ type: MessageAttachmentFileTypes;
333
+ localFileURL?: string;
334
+ };
335
+
336
+ export type AttachmentLinkType = {
337
+ link: {
338
+ url: string;
339
+ type: MessageAttachmentFileTypes;
340
+ name: string;
341
+ mimetype?: string;
342
+ };
343
+ };
344
+
345
+ export type AttachmentTypeProps = AttachmentFileType | AttachmentLinkType;
346
+
347
+ /* -------------------------------- BROADCAST ------------------------------- */
348
+
349
+ export type BroadcastLogType = Tables<'view_broadcast_logs'> & {
350
+ logs: (Tables<'tbl_broadcast_logs'> & Partial<ChatType>)[];
351
+ } & {
352
+ chats: ChatType[];
353
+ };
354
+
355
+ /* ----------------------- CHAT PARTICIPANT OPERATION ----------------------- */
356
+
357
+ export type ChatLogType = {
358
+ log: Tables<'view_chat_logs'>;
359
+ operations: Tables<'tbl_chat_logs'>[];
360
+ };
361
+ export type ChatOperationsType = 'ADD' | 'REMOVE' | 'PROMOTE' | 'DEMOTE';
362
+
363
+ export type ChatParticipantOperationPayload = {
364
+ participant_ids: string[];
365
+ chat_ids: string[];
366
+ performed_by: string;
367
+ };
368
+
369
+ export type ChatOperationReturn = {
370
+ [participant_id: string]: {
371
+ is_success: boolean;
372
+ message?: string;
373
+ code?: number;
374
+ isInviteV4Sent?: boolean;
375
+ };
376
+ };
377
+
378
+ /* ----------------------- BILLING - STRIPE ----------------------- */
379
+
380
+ export type StripeSubscription = _Stripe.Subscription;
381
+ export type StripeCustomer = _Stripe.Customer;
382
+ export type StripeCoupon = _Stripe.Coupon;
383
+ export type StripePrice = _Stripe.Price;
384
+ export type Stripe = _Stripe;
385
+ export type StripeUpcomingInvoice = _Stripe.UpcomingInvoice;
386
+ export type StripeLineItem = _Stripe.Checkout.SessionCreateParams.LineItem;
387
+
388
+ /* -------------------------------- REALTIME -------------------------------- */
389
+
390
+ export type PhoneStateType = {
391
+ loading: boolean;
392
+ state: string;
393
+ sync: number;
394
+ percent: number | null;
395
+ message?: string;
396
+ error?: string;
397
+ };
398
+
399
+ /* ------------------------------- INTEGRATIONS ----------------------------- */
400
+
401
+ export type ChatInfoType = Merge<
402
+ ChatType,
403
+ {
404
+ members: {
405
+ [key: string]: Merge<ChatMemberType, { contact_labels: string }>;
406
+ } | null;
407
+ chat_labels: string | null;
408
+ custom_properties: { [key: string]: string } | null;
409
+ }
410
+ >;
411
+
412
+ export type TicketInfoType = {
413
+ chat: ChatInfoType;
414
+ message: {
415
+ body: string;
416
+ chat_id: string;
417
+ org_phone: string;
418
+ timestamp: string;
419
+ media_path: string;
420
+ message_id: string;
421
+ sender_name: string;
422
+ performed_by: string;
423
+ sender_phone: string;
424
+ };
425
+ ticket: {
426
+ org_id: string;
427
+ status: string;
428
+ subject: string;
429
+ assignee: string;
430
+ due_date: string;
431
+ priority: 0 | 1 | 2 | 3 | 4;
432
+ raised_by: string;
433
+ ticket_id: string;
434
+ created_at: string;
435
+ assigned_by: string;
436
+ ticket_labels: string;
437
+ quoted_message_id: string;
438
+ };
439
+ };
440
+
441
+ export enum IntegrationLogType {
442
+ NEW_CHAT = 'chat.created',
443
+ NEW_CHAT_NOTIFICATION = 'chat.notification.created',
444
+ NEW_MESSAGE = 'message.created',
445
+ MESSAGE_UPDATED = 'message.updated',
446
+ MESSAGE_DELETED = 'message.deleted',
447
+ MESSAGE_ACK_UPDATED = 'message.ack.updated',
448
+ REACTION_CREATED = 'reaction.created',
449
+ REACTION_UPDATED = 'reaction.updated',
450
+ NEW_TICKET = 'ticket.created',
451
+ TICKET_UPDATED = 'ticket.updated',
452
+ TICKET_DELETED = 'ticket.deleted',
453
+ }
454
+
455
+ export type IntegrationLogMetadataType<T extends IntegrationLogType> =
456
+ T extends IntegrationLogType.NEW_TICKET | IntegrationLogType.TICKET_UPDATED
457
+ ? TicketInfoType
458
+ : T extends IntegrationLogType.NEW_CHAT
459
+ ? Tables<'tbl_chats'>
460
+ : T extends
461
+ | IntegrationLogType.NEW_MESSAGE
462
+ | IntegrationLogType.MESSAGE_UPDATED
463
+ | IntegrationLogType.MESSAGE_DELETED
464
+ | IntegrationLogType.MESSAGE_ACK_UPDATED
465
+ ? Tables<'tbl_chat_messages'>
466
+ : T extends
467
+ | IntegrationLogType.REACTION_CREATED
468
+ | IntegrationLogType.REACTION_UPDATED
469
+ ? Tables<'tbl_chat_reactions'>
470
+ : {
471
+ [key: string]: unknown;
472
+ };
473
+
474
+ export type IntegrationLogDetailsType<T extends IntegrationLogType> =
475
+ OverrideProperties<
476
+ Tables<'tbl_integration_logs'>,
477
+ {
478
+ integration_name: T;
479
+ metadata: {
480
+ event: IntegrationLogMetadataType<T> & {
481
+ event_type: string;
482
+ org_id: string;
483
+ previous_attributes: {
484
+ [key: string]: unknown;
485
+ };
486
+ };
487
+ hook_id: string;
488
+ name: string;
489
+ };
490
+ }
491
+ >;
492
+
493
+ export type APIAuthDetails = {
494
+ org_details: Tables<'view_org'> | null;
495
+ phone_details: Tables<'tbl_org_phones'> | null;
496
+ token_details: Tables<'tbl_integration_tokens'> | null;
497
+ };
498
+
499
+ export type WebhookDataType = OverrideProperties<
500
+ Tables<'tbl_integration_hooks'>,
501
+ {
502
+ integration_name: string[];
503
+ }
504
+ >;
505
+
506
+ export type HubspotObjectDataType = {
507
+ createdAt: string;
508
+ archived: boolean;
509
+ id: string;
510
+ type: 'contacts' | 'tickets' | 'companies';
511
+ properties: Record<
512
+ string,
513
+ {
514
+ groupLabel: string;
515
+ groupName: string;
516
+ propertyKeyName: string;
517
+ propertyKey: string;
518
+ propertyInternalValue: string;
519
+ propertyValue: string;
520
+ propertyType: string;
521
+ propertyFieldType: string;
522
+ }[]
523
+ >;
524
+ };
525
+
526
+ /* ---------------------------- USER PREFERENCES ---------------------------- */
527
+
528
+ export type UserPreferences = {
529
+ theme: 'light' | 'dark';
530
+ language: 'en' | 'es';
531
+ left_sidebar_open: boolean;
532
+ right_sidepanel_open: boolean;
533
+ sync_wa_unread_count: boolean;
534
+ };