@periskope/types 0.6.166 → 0.6.167
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.
- package/dist/rules.types.js +6 -4
- package/dist/supabase.types.d.ts +10 -25
- package/index.ts +3 -3
- package/package.json +1 -2
- package/rules.types.ts +1601 -1599
- package/supabase.types.ts +11 -26
- package/types.ts +813 -813
package/types.ts
CHANGED
|
@@ -1,814 +1,814 @@
|
|
|
1
|
-
import type { default as _Stripe } from 'stripe';
|
|
2
|
-
import { Merge, OverrideProperties } from 'type-fest';
|
|
3
|
-
import { Filter, Rule } from "./rules.types";
|
|
4
|
-
import { Tables, TablesUpdate } from './supabase.types';
|
|
5
|
-
|
|
6
|
-
/* ----------------------------- TYPE SHORTHANDS ---------------------------- */
|
|
7
|
-
|
|
8
|
-
/* ------------------------------ PERISKOPE TYPES ------------------------------ */
|
|
9
|
-
|
|
10
|
-
export enum AllPlans {
|
|
11
|
-
FREE_TRIAL = 'free-trial',
|
|
12
|
-
// MONTHLY_STARTER = 'monthly-starter',
|
|
13
|
-
// YEARLY_STARTER = 'yearly-starter',
|
|
14
|
-
// MONTHLY_PRO = 'monthly-pro',
|
|
15
|
-
// YEARLY_PRO = 'yearly-pro',
|
|
16
|
-
ENTERPRISE = 'enterprise',
|
|
17
|
-
MONTHLY_STARTER_SINGLE = 'monthly-starter-single',
|
|
18
|
-
YEARLY_STARTER_SINGLE = 'yearly-starter-single',
|
|
19
|
-
MONTHLY_PRO_SINGLE = 'monthly-pro-single',
|
|
20
|
-
YEARLY_PRO_SINGLE = 'yearly-pro-single',
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type Frequency = 'yearly' | 'monthly' | 'weekly' | 'custom';
|
|
24
|
-
|
|
25
|
-
export type Enterprise = `${string}-enterprise`;
|
|
26
|
-
|
|
27
|
-
export type OrgPlanEnterprise = {
|
|
28
|
-
subscription_id: string;
|
|
29
|
-
plan_id: Enterprise;
|
|
30
|
-
interval: number;
|
|
31
|
-
frequency: Frequency;
|
|
32
|
-
user_limit: number;
|
|
33
|
-
phone_limit: number;
|
|
34
|
-
current_period_start: number;
|
|
35
|
-
current_period_end: number | null;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type OrgPlanNonEnterprise = {
|
|
39
|
-
subscription_id: string;
|
|
40
|
-
plan_id: AllPlans;
|
|
41
|
-
interval: number;
|
|
42
|
-
frequency: Frequency;
|
|
43
|
-
user_limit: number;
|
|
44
|
-
phone_limit: number;
|
|
45
|
-
current_period_end: number;
|
|
46
|
-
current_period_start: number;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type OrgPlan<T extends AllPlans | Enterprise> = T extends Enterprise
|
|
50
|
-
? OrgPlanEnterprise
|
|
51
|
-
: T extends AllPlans
|
|
52
|
-
? OrgPlanNonEnterprise
|
|
53
|
-
: never;
|
|
54
|
-
|
|
55
|
-
export type MicrosurveyData = {
|
|
56
|
-
key: string;
|
|
57
|
-
text: string;
|
|
58
|
-
checked: boolean;
|
|
59
|
-
}[];
|
|
60
|
-
|
|
61
|
-
export type OrgPreferences = {
|
|
62
|
-
disable_ai_flagging?: boolean;
|
|
63
|
-
disable_allow_exports?: boolean;
|
|
64
|
-
sync_phone_contacts?: boolean;
|
|
65
|
-
mask_phone_numbers?: boolean;
|
|
66
|
-
show_sender_names?: boolean;
|
|
67
|
-
closed_chats?: Record<string, number>;
|
|
68
|
-
auto_read_muted_chats?: boolean;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
type OrgPreferenceKey = keyof OrgPreferences;
|
|
72
|
-
|
|
73
|
-
export type OrgPreferencesValue = {
|
|
74
|
-
[K in OrgPreferenceKey]: { key: K; value: OrgPreferences[K] };
|
|
75
|
-
}[OrgPreferenceKey];
|
|
76
|
-
|
|
77
|
-
export type OrgMetadata = {
|
|
78
|
-
phone_number: string;
|
|
79
|
-
ticket_prefix: string;
|
|
80
|
-
referralSource?: string;
|
|
81
|
-
surveyData?: MicrosurveyData;
|
|
82
|
-
preferences?: OrgPreferences;
|
|
83
|
-
hubspot: {
|
|
84
|
-
hubspot_pipelines?: {
|
|
85
|
-
id: string;
|
|
86
|
-
label: string;
|
|
87
|
-
default_stage: { id: string; label: string };
|
|
88
|
-
}[];
|
|
89
|
-
hubspot_hidden_fields?: string[];
|
|
90
|
-
}
|
|
91
|
-
partition?: boolean;
|
|
92
|
-
tickets: {
|
|
93
|
-
prefix?: string;
|
|
94
|
-
emoji_ticketing: {
|
|
95
|
-
is_enabled?: boolean;
|
|
96
|
-
is_message_enabled?: boolean;
|
|
97
|
-
message_template?: string;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
attribution?: Object;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
type AccessScopes = {
|
|
104
|
-
feature_flags: Record<string, boolean>;
|
|
105
|
-
integrations: boolean;
|
|
106
|
-
exports: boolean;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export type OrgType = OverrideProperties<
|
|
110
|
-
Merge<
|
|
111
|
-
Tables<'tbl_org'>,
|
|
112
|
-
{
|
|
113
|
-
user: Tables<'tbl_org_members'>;
|
|
114
|
-
members: Tables<'tbl_org_members'>[];
|
|
115
|
-
phones: Tables<'tbl_org_phones'>[];
|
|
116
|
-
labels: Tables<'tbl_org_labels'>[];
|
|
117
|
-
quick_replies: Tables<'tbl_quick_replies'>[];
|
|
118
|
-
custom_properties: Tables<'tbl_custom_properties'>[];
|
|
119
|
-
subscription_status: 'active' | 'inactive' | 'unpaid';
|
|
120
|
-
is_enterprise: boolean;
|
|
121
|
-
is_free_trial: boolean;
|
|
122
|
-
is_hubspot_connected: boolean;
|
|
123
|
-
is_freshdesk_connected: boolean;
|
|
124
|
-
is_zohodesk_connected: boolean;
|
|
125
|
-
access_scopes: AccessScopes;
|
|
126
|
-
rules: Rule[];
|
|
127
|
-
}
|
|
128
|
-
>,
|
|
129
|
-
{
|
|
130
|
-
org_plan: OrgPlan<AllPlans | Enterprise>;
|
|
131
|
-
stripe_customer_details: _Stripe.Customer | null;
|
|
132
|
-
stripe_subscription_details: Array<_Stripe.Subscription> | null;
|
|
133
|
-
stripe_customer_id: _Stripe.Customer['id'] | null;
|
|
134
|
-
org_metadata: OrgMetadata;
|
|
135
|
-
}
|
|
136
|
-
>;
|
|
137
|
-
|
|
138
|
-
export type ChatMemberType = Merge<
|
|
139
|
-
Tables<'tbl_chat_participants'>,
|
|
140
|
-
Tables<'tbl_contacts'>
|
|
141
|
-
>;
|
|
142
|
-
|
|
143
|
-
export type ChatType = Merge<
|
|
144
|
-
Tables<'view_chats'>,
|
|
145
|
-
{
|
|
146
|
-
chat_id: string;
|
|
147
|
-
latest_message: MessageType | null;
|
|
148
|
-
latest_message_timestamp: number | null;
|
|
149
|
-
members: { [key: string]: ChatMemberType } | null;
|
|
150
|
-
chat_type: 'user' | 'group' | 'business' | 'unknown';
|
|
151
|
-
chat_access: { [key: string]: boolean };
|
|
152
|
-
label_ids: { [key: string]: boolean };
|
|
153
|
-
chat_org_phones?: string[];
|
|
154
|
-
message_unread_count: number | null;
|
|
155
|
-
hubspot_metadata: {
|
|
156
|
-
id: string;
|
|
157
|
-
type: string;
|
|
158
|
-
hubId: string;
|
|
159
|
-
object_data: HubspotObjectDataType;
|
|
160
|
-
} | null;
|
|
161
|
-
info_admins_only: boolean;
|
|
162
|
-
messages_admins_only: boolean;
|
|
163
|
-
unread_count?: { [key: string]: number };
|
|
164
|
-
active_phone: string | null;
|
|
165
|
-
flag_count_map?: { [key: string]: number };
|
|
166
|
-
is_archived?: boolean;
|
|
167
|
-
is_pinned?: boolean;
|
|
168
|
-
closed_at?: number | null;
|
|
169
|
-
common_chats?: string[];
|
|
170
|
-
}
|
|
171
|
-
>;
|
|
172
|
-
|
|
173
|
-
/* -------------------------------------------------------------------------- */
|
|
174
|
-
/* MESSAGE */
|
|
175
|
-
/* -------------------------------------------------------------------------- */
|
|
176
|
-
|
|
177
|
-
export type MediaType = {
|
|
178
|
-
path: string;
|
|
179
|
-
mimetype?: string;
|
|
180
|
-
filename?: string;
|
|
181
|
-
dimensions?: { width: number; height: number; ar: number };
|
|
182
|
-
size?: number;
|
|
183
|
-
thumbnail?: string;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
export type MessageType = Merge<
|
|
187
|
-
OverrideProperties<
|
|
188
|
-
Tables<'tbl_chat_messages'>,
|
|
189
|
-
{
|
|
190
|
-
message_id: string;
|
|
191
|
-
org_id: string;
|
|
192
|
-
org_phone: string;
|
|
193
|
-
chat_id: string;
|
|
194
|
-
message_type: (typeof SUPPORTED_TYPES)[number];
|
|
195
|
-
media: MediaType | null;
|
|
196
|
-
flag_metadata: MessageFlagType | null;
|
|
197
|
-
poll_info?: PollSendType | null;
|
|
198
|
-
poll_results?: PollResultType | null;
|
|
199
|
-
delivery_info?: DeliveryInfoType | null;
|
|
200
|
-
}
|
|
201
|
-
>,
|
|
202
|
-
{
|
|
203
|
-
reactions?: ReactionType[];
|
|
204
|
-
message_payload?: SingleMessagePayload;
|
|
205
|
-
highlight?: number;
|
|
206
|
-
}
|
|
207
|
-
>;
|
|
208
|
-
|
|
209
|
-
export type MessageFlagType = {
|
|
210
|
-
status: boolean;
|
|
211
|
-
response_type?: 'message' | 'reaction' | 'ticket' | 'manual';
|
|
212
|
-
response_id?: string;
|
|
213
|
-
response_timestamp?: string;
|
|
214
|
-
response_email?: string;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
/* -------------------------------------------------------------------------- */
|
|
218
|
-
|
|
219
|
-
export type TicketType = OverrideProperties<
|
|
220
|
-
Tables<'tbl_chat_tickets'>,
|
|
221
|
-
{
|
|
222
|
-
label_ids: { [key: string]: boolean };
|
|
223
|
-
hubspot_metadata: {
|
|
224
|
-
id?: string;
|
|
225
|
-
type?: string;
|
|
226
|
-
hubId?: string;
|
|
227
|
-
pipeline: {
|
|
228
|
-
id: string;
|
|
229
|
-
label: string;
|
|
230
|
-
};
|
|
231
|
-
object_data?: HubspotObjectDataType;
|
|
232
|
-
} | null;
|
|
233
|
-
freshdesk_metadata: Record<string, string>;
|
|
234
|
-
close_ticket_metadata?:
|
|
235
|
-
| {
|
|
236
|
-
closed_by: string;
|
|
237
|
-
closed_at: string;
|
|
238
|
-
closed_message?: string | null;
|
|
239
|
-
send_reply_message_id?: string | null;
|
|
240
|
-
}
|
|
241
|
-
| any;
|
|
242
|
-
}
|
|
243
|
-
>;
|
|
244
|
-
|
|
245
|
-
export type ContactType = Merge<
|
|
246
|
-
Tables<'tbl_contacts'>,
|
|
247
|
-
{
|
|
248
|
-
chats: ChatType[] | null;
|
|
249
|
-
chat_ids?: string[];
|
|
250
|
-
}
|
|
251
|
-
>;
|
|
252
|
-
export type ReactionType = Tables<'tbl_chat_reactions'>;
|
|
253
|
-
|
|
254
|
-
export type NotificationType = Tables<'tbl_chat_notifications'>;
|
|
255
|
-
|
|
256
|
-
export type ChatAccessType = Merge<
|
|
257
|
-
TablesUpdate<'tbl_org_members'>,
|
|
258
|
-
{
|
|
259
|
-
has_access?: boolean;
|
|
260
|
-
email: string | null;
|
|
261
|
-
}
|
|
262
|
-
>;
|
|
263
|
-
|
|
264
|
-
/* -------------------------------- CONSTANTS ------------------------------- */
|
|
265
|
-
|
|
266
|
-
export const labelColors = [
|
|
267
|
-
'#9333EA',
|
|
268
|
-
'#0D9488',
|
|
269
|
-
'#DB2777',
|
|
270
|
-
'#2563EB',
|
|
271
|
-
'#F97316',
|
|
272
|
-
];
|
|
273
|
-
|
|
274
|
-
export const enumChatColors = [
|
|
275
|
-
'#B4876E',
|
|
276
|
-
'#A5B337',
|
|
277
|
-
'#06CF9C',
|
|
278
|
-
'#25D366',
|
|
279
|
-
'#02A698',
|
|
280
|
-
'#7D9EF1',
|
|
281
|
-
'#007BFC',
|
|
282
|
-
'#5E47DE',
|
|
283
|
-
'#7F66FF',
|
|
284
|
-
'#9333EA',
|
|
285
|
-
'#FA6533',
|
|
286
|
-
'#C4532D',
|
|
287
|
-
'#DC2626',
|
|
288
|
-
'#FF2E74',
|
|
289
|
-
'#DB2777',
|
|
290
|
-
] as const;
|
|
291
|
-
|
|
292
|
-
/* -------------------------- SEND MESSAGE PAYLOAD -------------------------- */
|
|
293
|
-
|
|
294
|
-
export const SUPPORTED_TYPES = [
|
|
295
|
-
'chat',
|
|
296
|
-
'sticker',
|
|
297
|
-
'image',
|
|
298
|
-
'video',
|
|
299
|
-
'document',
|
|
300
|
-
'vcard',
|
|
301
|
-
'multi_vcard',
|
|
302
|
-
'audio',
|
|
303
|
-
'ptt',
|
|
304
|
-
'poll_creation',
|
|
305
|
-
'location',
|
|
306
|
-
'ciphertext',
|
|
307
|
-
] as const;
|
|
308
|
-
|
|
309
|
-
export type SendMessageContent = {
|
|
310
|
-
message_type?: (typeof SUPPORTED_TYPES)[number];
|
|
311
|
-
body?: string;
|
|
312
|
-
media?: MediaType;
|
|
313
|
-
contact_ids?: string[];
|
|
314
|
-
location?: {
|
|
315
|
-
latitude: string;
|
|
316
|
-
longitude: string;
|
|
317
|
-
options?: { name?: string; address?: string; url?: string };
|
|
318
|
-
};
|
|
319
|
-
poll?: PollSendType;
|
|
320
|
-
quoted_message_id?: string;
|
|
321
|
-
quoted_message_type?: 'reply' | 'forward' | 'reply_private';
|
|
322
|
-
broadcast_id?: string;
|
|
323
|
-
performed_by?: string;
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
export type QuickReplyContent = Omit<
|
|
327
|
-
SendMessageContent,
|
|
328
|
-
'broadcast_id' | 'variables'
|
|
329
|
-
>;
|
|
330
|
-
|
|
331
|
-
export type BroadcastVariableType = {
|
|
332
|
-
chat_id: string;
|
|
333
|
-
values: { [key: string]: string };
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
export type BroadcastMessagePayload = SendMessageContent & {
|
|
337
|
-
chat_ids: string[];
|
|
338
|
-
broadcast_id?: string;
|
|
339
|
-
variables?: BroadcastVariableType[];
|
|
340
|
-
delay?: number;
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
export type SingleMessagePayload = SendMessageContent & {
|
|
344
|
-
chat_id: string;
|
|
345
|
-
job_id?: string;
|
|
346
|
-
priority?: number;
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
export type MessageAttachmentFileTypes =
|
|
350
|
-
| 'image'
|
|
351
|
-
| 'audio'
|
|
352
|
-
| 'document'
|
|
353
|
-
| 'video';
|
|
354
|
-
|
|
355
|
-
export type AttachmentFileType = {
|
|
356
|
-
result: string;
|
|
357
|
-
file: File | null;
|
|
358
|
-
type: MessageAttachmentFileTypes;
|
|
359
|
-
localFileURL?: string;
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
export type AttachmentLinkType = {
|
|
363
|
-
link: {
|
|
364
|
-
url: string;
|
|
365
|
-
type: MessageAttachmentFileTypes;
|
|
366
|
-
name: string;
|
|
367
|
-
mimetype?: string;
|
|
368
|
-
};
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
export type AttachmentTypeProps = AttachmentFileType | AttachmentLinkType;
|
|
372
|
-
|
|
373
|
-
/* -------------------------------- BROADCAST ------------------------------- */
|
|
374
|
-
|
|
375
|
-
export type BroadcastLogType = Tables<'view_broadcast_logs'> & {
|
|
376
|
-
logs: (Tables<'tbl_broadcast_logs'> & Partial<ChatType>)[];
|
|
377
|
-
} & {
|
|
378
|
-
chats: ChatType[];
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
/* ----------------------- CHAT PARTICIPANT OPERATION ----------------------- */
|
|
382
|
-
|
|
383
|
-
export type ChatLogType = {
|
|
384
|
-
log: Tables<'view_chat_logs'>;
|
|
385
|
-
operations: Tables<'tbl_chat_logs'>[];
|
|
386
|
-
};
|
|
387
|
-
export type ChatOperationsType = 'ADD' | 'REMOVE' | 'PROMOTE' | 'DEMOTE';
|
|
388
|
-
|
|
389
|
-
export type ChatParticipantOperationPayload = {
|
|
390
|
-
participant_ids: string[];
|
|
391
|
-
chat_ids: string[];
|
|
392
|
-
performed_by: string;
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
export type ChatOperationReturn = {
|
|
396
|
-
[participant_id: string]: {
|
|
397
|
-
is_success: boolean;
|
|
398
|
-
message?: string;
|
|
399
|
-
code?: number;
|
|
400
|
-
isInviteV4Sent?: boolean;
|
|
401
|
-
};
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
/* ----------------------- BILLING - STRIPE ----------------------- */
|
|
405
|
-
|
|
406
|
-
export type StripeSubscription = _Stripe.Subscription;
|
|
407
|
-
export type StripeCustomer = _Stripe.Customer;
|
|
408
|
-
export type StripeCoupon = _Stripe.Coupon;
|
|
409
|
-
export type StripePrice = _Stripe.Price;
|
|
410
|
-
export type Stripe = _Stripe;
|
|
411
|
-
export type StripeUpcomingInvoice = _Stripe.UpcomingInvoice;
|
|
412
|
-
export type StripeLineItem = _Stripe.Checkout.SessionCreateParams.LineItem;
|
|
413
|
-
|
|
414
|
-
/* -------------------------------- REALTIME -------------------------------- */
|
|
415
|
-
|
|
416
|
-
export type PhoneStateType = {
|
|
417
|
-
loading: boolean;
|
|
418
|
-
state: string;
|
|
419
|
-
sync: number;
|
|
420
|
-
percent: number | null;
|
|
421
|
-
message?: string;
|
|
422
|
-
error?: string;
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
/* ------------------------------- INTEGRATIONS ----------------------------- */
|
|
426
|
-
|
|
427
|
-
export type ChatInfoType = Merge<
|
|
428
|
-
ChatType,
|
|
429
|
-
{
|
|
430
|
-
members: {
|
|
431
|
-
[key: string]: Merge<ChatMemberType, { contact_labels: string }>;
|
|
432
|
-
} | null;
|
|
433
|
-
chat_labels: string | null;
|
|
434
|
-
custom_properties: { [key: string]: string } | null;
|
|
435
|
-
}
|
|
436
|
-
>;
|
|
437
|
-
|
|
438
|
-
export type TicketInfoType = {
|
|
439
|
-
chat: ChatInfoType;
|
|
440
|
-
message: {
|
|
441
|
-
body: string;
|
|
442
|
-
chat_id: string;
|
|
443
|
-
org_phone: string;
|
|
444
|
-
timestamp: string;
|
|
445
|
-
media_path: string;
|
|
446
|
-
message_id: string;
|
|
447
|
-
sender_name: string;
|
|
448
|
-
performed_by: string;
|
|
449
|
-
sender_phone: string;
|
|
450
|
-
};
|
|
451
|
-
ticket: {
|
|
452
|
-
org_id: string;
|
|
453
|
-
status: string;
|
|
454
|
-
subject: string;
|
|
455
|
-
assignee: string;
|
|
456
|
-
due_date: string;
|
|
457
|
-
priority: 0 | 1 | 2 | 3 | 4;
|
|
458
|
-
raised_by: string;
|
|
459
|
-
ticket_id: string;
|
|
460
|
-
created_at: string;
|
|
461
|
-
assigned_by: string;
|
|
462
|
-
ticket_labels: string;
|
|
463
|
-
quoted_message_id: string;
|
|
464
|
-
ticket_custom_properties: { [key: string]: string } | null;
|
|
465
|
-
};
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
export type IntegrationLogObjectType =
|
|
469
|
-
| 'chat'
|
|
470
|
-
| 'message'
|
|
471
|
-
| 'reaction'
|
|
472
|
-
| 'ticket';
|
|
473
|
-
|
|
474
|
-
export enum IntegrationLogType {
|
|
475
|
-
NEW_CHAT = 'chat.created',
|
|
476
|
-
NEW_CHAT_NOTIFICATION = 'chat.notification.created',
|
|
477
|
-
NEW_MESSAGE = 'message.created',
|
|
478
|
-
MESSAGE_UPDATED = 'message.updated',
|
|
479
|
-
MESSAGE_DELETED = 'message.deleted',
|
|
480
|
-
MESSAGE_ACK_UPDATED = 'message.ack.updated',
|
|
481
|
-
REACTION_CREATED = 'reaction.created',
|
|
482
|
-
REACTION_UPDATED = 'reaction.updated',
|
|
483
|
-
NEW_TICKET = 'ticket.created',
|
|
484
|
-
TICKET_UPDATED = 'ticket.updated',
|
|
485
|
-
TICKET_DELETED = 'ticket.deleted',
|
|
486
|
-
MESSAGE_FLAGGED = 'message.flagged',
|
|
487
|
-
MESSAGE_UNFLAGGED = 'message.unflagged',
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
export type IntegrationLogMetadataType<T extends IntegrationLogType> =
|
|
491
|
-
T extends IntegrationLogType.NEW_TICKET | IntegrationLogType.TICKET_UPDATED
|
|
492
|
-
? TicketInfoType
|
|
493
|
-
: T extends IntegrationLogType.NEW_CHAT
|
|
494
|
-
? Tables<'tbl_chats'>
|
|
495
|
-
: T extends
|
|
496
|
-
| IntegrationLogType.NEW_MESSAGE
|
|
497
|
-
| IntegrationLogType.MESSAGE_UPDATED
|
|
498
|
-
| IntegrationLogType.MESSAGE_DELETED
|
|
499
|
-
| IntegrationLogType.MESSAGE_ACK_UPDATED
|
|
500
|
-
| IntegrationLogType.MESSAGE_FLAGGED
|
|
501
|
-
| IntegrationLogType.MESSAGE_UNFLAGGED
|
|
502
|
-
? Tables<'tbl_chat_messages'>
|
|
503
|
-
: T extends
|
|
504
|
-
| IntegrationLogType.REACTION_CREATED
|
|
505
|
-
| IntegrationLogType.REACTION_UPDATED
|
|
506
|
-
? Tables<'tbl_chat_reactions'>
|
|
507
|
-
: {
|
|
508
|
-
[key: string]: unknown;
|
|
509
|
-
};
|
|
510
|
-
|
|
511
|
-
export type IntegrationLogDetailsType<T extends IntegrationLogType> =
|
|
512
|
-
OverrideProperties<
|
|
513
|
-
Tables<'tbl_integration_logs'>,
|
|
514
|
-
{
|
|
515
|
-
integration_name: T;
|
|
516
|
-
metadata: {
|
|
517
|
-
event: IntegrationLogMetadataType<T> & {
|
|
518
|
-
event_type: string;
|
|
519
|
-
org_id: string;
|
|
520
|
-
previous_attributes: {
|
|
521
|
-
[key: string]: unknown;
|
|
522
|
-
};
|
|
523
|
-
};
|
|
524
|
-
hook_id: string;
|
|
525
|
-
name: string;
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
>;
|
|
529
|
-
|
|
530
|
-
export type APIAuthDetails = {
|
|
531
|
-
org_details: Tables<'view_org'> | null;
|
|
532
|
-
phone_details: Tables<'tbl_org_phones'> | null;
|
|
533
|
-
token_details: Tables<'tbl_integration_tokens'> | null;
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
export type WebhookDataType = OverrideProperties<
|
|
537
|
-
Tables<'tbl_integration_hooks'>,
|
|
538
|
-
{
|
|
539
|
-
integration_name: string[];
|
|
540
|
-
}
|
|
541
|
-
>;
|
|
542
|
-
|
|
543
|
-
export type HubspotObjectDataType = {
|
|
544
|
-
createdAt: string;
|
|
545
|
-
archived: boolean;
|
|
546
|
-
id: string;
|
|
547
|
-
type: 'contacts' | 'tickets' | 'companies';
|
|
548
|
-
properties: Record<
|
|
549
|
-
string,
|
|
550
|
-
{
|
|
551
|
-
groupLabel: string;
|
|
552
|
-
groupName: string;
|
|
553
|
-
propertyKeyName: string;
|
|
554
|
-
propertyKey: string;
|
|
555
|
-
propertyInternalValue: string;
|
|
556
|
-
propertyValue: string;
|
|
557
|
-
propertyType: string;
|
|
558
|
-
propertyFieldType: string;
|
|
559
|
-
}[]
|
|
560
|
-
>;
|
|
561
|
-
};
|
|
562
|
-
|
|
563
|
-
/* ---------------------------- USER PREFERENCES ---------------------------- */
|
|
564
|
-
|
|
565
|
-
export type UserPreferences = {
|
|
566
|
-
theme: 'light' | 'dark';
|
|
567
|
-
language: 'en' | 'es';
|
|
568
|
-
left_sidebar_open: boolean;
|
|
569
|
-
right_sidepanel_open: boolean;
|
|
570
|
-
sync_wa_unread_count: boolean;
|
|
571
|
-
pinned_chats: string[];
|
|
572
|
-
archived_chats: string[];
|
|
573
|
-
closed_chats: Record<string, number>;
|
|
574
|
-
periskope_chat_limit: number;
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
/* ----------------------------- POLL VOTE INFO ----------------------------- */
|
|
578
|
-
|
|
579
|
-
export type PollSendType = {
|
|
580
|
-
pollName: string;
|
|
581
|
-
pollOptions: string[];
|
|
582
|
-
options?: {
|
|
583
|
-
allowMultipleAnswers?: boolean;
|
|
584
|
-
messageSecret?: number[] | null;
|
|
585
|
-
pollId?: string;
|
|
586
|
-
};
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
export type PollResultType = {
|
|
590
|
-
[name: string]: Record<string, string>;
|
|
591
|
-
};
|
|
592
|
-
|
|
593
|
-
/* -------------------------- CREATE GROUP OPTIONS -------------------------- */
|
|
594
|
-
|
|
595
|
-
export type CreateGroupOptions = {
|
|
596
|
-
messagesAdminsOnly?: boolean;
|
|
597
|
-
infoAdminsOnly?: boolean;
|
|
598
|
-
memberAddMode?: boolean;
|
|
599
|
-
image?: string;
|
|
600
|
-
name?: string;
|
|
601
|
-
description?: string;
|
|
602
|
-
};
|
|
603
|
-
|
|
604
|
-
/* ------------------------------ DELIVERY INFO ----------------------------- */
|
|
605
|
-
|
|
606
|
-
export type DeliveryInfoType = {
|
|
607
|
-
delivered: Record<string, number | undefined>;
|
|
608
|
-
read: Record<string, number | undefined>;
|
|
609
|
-
pending: string[];
|
|
610
|
-
read_count: number;
|
|
611
|
-
delivered_count: number;
|
|
612
|
-
};
|
|
613
|
-
|
|
614
|
-
/* ---------------------------- CREDITS SYSTEM ---------------------------- */
|
|
615
|
-
|
|
616
|
-
export type OrgCreditsType = {
|
|
617
|
-
org_id: string;
|
|
618
|
-
recurring_allowance: number; // recurring credits replenished every month
|
|
619
|
-
recurring_balance: number; // recurring credits remaining in current month
|
|
620
|
-
topup_balance: number; // topup credits remaining
|
|
621
|
-
total_credits_used: number; // total credits used in current month
|
|
622
|
-
next_renewal_date: string;
|
|
623
|
-
};
|
|
624
|
-
|
|
625
|
-
/* --------------------------------- RULE INFO TYPE -------------------------------- */
|
|
626
|
-
|
|
627
|
-
export type ChatRuleInfoType = Merge<
|
|
628
|
-
Pick<
|
|
629
|
-
Tables<'view_chats'>,
|
|
630
|
-
| 'assigned_to'
|
|
631
|
-
| 'chat_id'
|
|
632
|
-
| 'chat_name'
|
|
633
|
-
| 'chat_type'
|
|
634
|
-
| 'created_at'
|
|
635
|
-
| 'group_description'
|
|
636
|
-
| 'info_admins_only'
|
|
637
|
-
| 'org_id'
|
|
638
|
-
| 'org_phone'
|
|
639
|
-
| 'chat_org_phones'
|
|
640
|
-
| 'messages_admins_only'
|
|
641
|
-
| 'custom_properties'
|
|
642
|
-
>,
|
|
643
|
-
{
|
|
644
|
-
has_flagged_messages: boolean;
|
|
645
|
-
labels: string[];
|
|
646
|
-
members: string[];
|
|
647
|
-
custom_properties: { [key: string]: string } | null;
|
|
648
|
-
}
|
|
649
|
-
>;
|
|
650
|
-
|
|
651
|
-
export type SenderRuleInfoType = Merge<
|
|
652
|
-
Omit<
|
|
653
|
-
Merge<Tables<'tbl_contacts'>, Tables<'tbl_chat_participants'>>,
|
|
654
|
-
| 'verified_name'
|
|
655
|
-
| 'verified_level'
|
|
656
|
-
| 'updated_at'
|
|
657
|
-
| 'short_name'
|
|
658
|
-
| 'pushname'
|
|
659
|
-
| 'periskope_name'
|
|
660
|
-
| 'org_phone'
|
|
661
|
-
| 'number'
|
|
662
|
-
| 'name'
|
|
663
|
-
| 'label_ids'
|
|
664
|
-
| 'is_wa_contact'
|
|
665
|
-
| 'is_user'
|
|
666
|
-
| 'is_my_contact'
|
|
667
|
-
| 'is_me'
|
|
668
|
-
| 'is_imported'
|
|
669
|
-
| 'is_group'
|
|
670
|
-
| 'is_blocked'
|
|
671
|
-
| 'contact_color'
|
|
672
|
-
| 'business_profile'
|
|
673
|
-
| 'id'
|
|
674
|
-
| 'contact_image'
|
|
675
|
-
| 'contact_type'
|
|
676
|
-
| 'chat_id'
|
|
677
|
-
| 'is_business'
|
|
678
|
-
| 'is_enterprise'
|
|
679
|
-
| 'is_super_admin'
|
|
680
|
-
>,
|
|
681
|
-
{
|
|
682
|
-
is_internal: boolean;
|
|
683
|
-
labels: string[] | null;
|
|
684
|
-
}
|
|
685
|
-
>;
|
|
686
|
-
|
|
687
|
-
export type MessageRuleInfoType = {
|
|
688
|
-
chat: ChatRuleInfoType;
|
|
689
|
-
sender: SenderRuleInfoType;
|
|
690
|
-
message: OverrideProperties<
|
|
691
|
-
Omit<
|
|
692
|
-
Tables<'tbl_chat_messages'>,
|
|
693
|
-
| 'vcards'
|
|
694
|
-
| 'updated_at'
|
|
695
|
-
| 'unique_id'
|
|
696
|
-
| 'token'
|
|
697
|
-
| 'to'
|
|
698
|
-
| 'sent_message_id'
|
|
699
|
-
| 'raw_data'
|
|
700
|
-
| 'delivery_info'
|
|
701
|
-
| 'poll_results'
|
|
702
|
-
| 'poll_info'
|
|
703
|
-
| 'order_id'
|
|
704
|
-
| 'mentioned_ids'
|
|
705
|
-
| 'media_key'
|
|
706
|
-
| 'location'
|
|
707
|
-
| 'links'
|
|
708
|
-
| 'is_status'
|
|
709
|
-
| 'is_starred'
|
|
710
|
-
| 'is_gif'
|
|
711
|
-
| 'is_forwarded'
|
|
712
|
-
| 'is_ephemeral'
|
|
713
|
-
| 'is_deleted'
|
|
714
|
-
| 'fts'
|
|
715
|
-
| 'quoted_message_id'
|
|
716
|
-
| 'invite_v4'
|
|
717
|
-
| 'id'
|
|
718
|
-
| 'has_reaction'
|
|
719
|
-
| 'has_media'
|
|
720
|
-
| 'duration'
|
|
721
|
-
| 'broadcast'
|
|
722
|
-
| 'broadcast_id'
|
|
723
|
-
| 'device_type'
|
|
724
|
-
| 'forwarding_score'
|
|
725
|
-
| 'from'
|
|
726
|
-
| 'from_me'
|
|
727
|
-
| 'message_ticket_id'
|
|
728
|
-
| 'prev_body'
|
|
729
|
-
| 'flag_response_time'
|
|
730
|
-
| 'flag_metadata'
|
|
731
|
-
| 'ack'
|
|
732
|
-
>,
|
|
733
|
-
{
|
|
734
|
-
media: MediaType | null;
|
|
735
|
-
}
|
|
736
|
-
>;
|
|
737
|
-
};
|
|
738
|
-
|
|
739
|
-
export type ReactionRuleInfoType = {
|
|
740
|
-
chat: ChatRuleInfoType;
|
|
741
|
-
sender: SenderRuleInfoType;
|
|
742
|
-
message: MessageRuleInfoType['message'];
|
|
743
|
-
reaction: Pick<
|
|
744
|
-
Tables<'tbl_chat_reactions'>,
|
|
745
|
-
'reaction' | 'sender_id' | 'message_id' | 'chat_id' | 'reaction_id'
|
|
746
|
-
>;
|
|
747
|
-
};
|
|
748
|
-
|
|
749
|
-
export type TicketRuleInfoType = {
|
|
750
|
-
chat: ChatRuleInfoType;
|
|
751
|
-
sender: SenderRuleInfoType;
|
|
752
|
-
ticket: Merge<
|
|
753
|
-
Pick<
|
|
754
|
-
Tables<'tbl_chat_tickets'>,
|
|
755
|
-
| 'org_id'
|
|
756
|
-
| 'status'
|
|
757
|
-
| 'chat_id'
|
|
758
|
-
| 'subject'
|
|
759
|
-
| 'assignee'
|
|
760
|
-
| 'due_date'
|
|
761
|
-
| 'priority'
|
|
762
|
-
| 'raised_by'
|
|
763
|
-
| 'ticket_id'
|
|
764
|
-
| 'created_at'
|
|
765
|
-
| 'is_deleted'
|
|
766
|
-
>,
|
|
767
|
-
{
|
|
768
|
-
labels: string[] | null;
|
|
769
|
-
custom_properties: { [key: string]: string } | null;
|
|
770
|
-
}
|
|
771
|
-
>;
|
|
772
|
-
message: MessageRuleInfoType['message'];
|
|
773
|
-
};
|
|
774
|
-
export type FeatureFlagReturnType = Record<string, boolean>;
|
|
775
|
-
|
|
776
|
-
export type RuleLogsType = OverrideProperties<
|
|
777
|
-
Tables<'tbl_rules_logs'>,
|
|
778
|
-
{
|
|
779
|
-
actions_progress: {
|
|
780
|
-
action_id: string;
|
|
781
|
-
action_type: Rule['actions'][number]['type'];
|
|
782
|
-
action_delay: Rule['actions'][number]['delay'];
|
|
783
|
-
ran_at: string | null;
|
|
784
|
-
action_status: 'success' | 'failed' | 'pending';
|
|
785
|
-
action_response: {
|
|
786
|
-
success: boolean;
|
|
787
|
-
data: Record<string, unknown> | null;
|
|
788
|
-
error: {
|
|
789
|
-
message: string;
|
|
790
|
-
name: string;
|
|
791
|
-
stack?: string;
|
|
792
|
-
_error?: Error | Record<string, unknown>;
|
|
793
|
-
} | null;
|
|
794
|
-
};
|
|
795
|
-
}[];
|
|
796
|
-
metadata: {
|
|
797
|
-
conditions: Rule['conditions'];
|
|
798
|
-
actions: Rule['actions'];
|
|
799
|
-
data: Record<string, unknown>;
|
|
800
|
-
};
|
|
801
|
-
conditions_progress: {
|
|
802
|
-
is_valid: boolean;
|
|
803
|
-
validation_progress: Record<
|
|
804
|
-
string,
|
|
805
|
-
{
|
|
806
|
-
res: boolean;
|
|
807
|
-
filter: Filter;
|
|
808
|
-
value: unknown;
|
|
809
|
-
}
|
|
810
|
-
>;
|
|
811
|
-
checked_at: string | null;
|
|
812
|
-
};
|
|
813
|
-
}
|
|
1
|
+
import type { default as _Stripe } from 'stripe';
|
|
2
|
+
import { Merge, OverrideProperties } from 'type-fest';
|
|
3
|
+
import { Filter, Rule } from "./rules.types";
|
|
4
|
+
import { Tables, TablesUpdate } from './supabase.types';
|
|
5
|
+
|
|
6
|
+
/* ----------------------------- TYPE SHORTHANDS ---------------------------- */
|
|
7
|
+
|
|
8
|
+
/* ------------------------------ PERISKOPE TYPES ------------------------------ */
|
|
9
|
+
|
|
10
|
+
export enum AllPlans {
|
|
11
|
+
FREE_TRIAL = 'free-trial',
|
|
12
|
+
// MONTHLY_STARTER = 'monthly-starter',
|
|
13
|
+
// YEARLY_STARTER = 'yearly-starter',
|
|
14
|
+
// MONTHLY_PRO = 'monthly-pro',
|
|
15
|
+
// YEARLY_PRO = 'yearly-pro',
|
|
16
|
+
ENTERPRISE = 'enterprise',
|
|
17
|
+
MONTHLY_STARTER_SINGLE = 'monthly-starter-single',
|
|
18
|
+
YEARLY_STARTER_SINGLE = 'yearly-starter-single',
|
|
19
|
+
MONTHLY_PRO_SINGLE = 'monthly-pro-single',
|
|
20
|
+
YEARLY_PRO_SINGLE = 'yearly-pro-single',
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type Frequency = 'yearly' | 'monthly' | 'weekly' | 'custom';
|
|
24
|
+
|
|
25
|
+
export type Enterprise = `${string}-enterprise`;
|
|
26
|
+
|
|
27
|
+
export type OrgPlanEnterprise = {
|
|
28
|
+
subscription_id: string;
|
|
29
|
+
plan_id: Enterprise;
|
|
30
|
+
interval: number;
|
|
31
|
+
frequency: Frequency;
|
|
32
|
+
user_limit: number;
|
|
33
|
+
phone_limit: number;
|
|
34
|
+
current_period_start: number;
|
|
35
|
+
current_period_end: number | null;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type OrgPlanNonEnterprise = {
|
|
39
|
+
subscription_id: string;
|
|
40
|
+
plan_id: AllPlans;
|
|
41
|
+
interval: number;
|
|
42
|
+
frequency: Frequency;
|
|
43
|
+
user_limit: number;
|
|
44
|
+
phone_limit: number;
|
|
45
|
+
current_period_end: number;
|
|
46
|
+
current_period_start: number;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type OrgPlan<T extends AllPlans | Enterprise> = T extends Enterprise
|
|
50
|
+
? OrgPlanEnterprise
|
|
51
|
+
: T extends AllPlans
|
|
52
|
+
? OrgPlanNonEnterprise
|
|
53
|
+
: never;
|
|
54
|
+
|
|
55
|
+
export type MicrosurveyData = {
|
|
56
|
+
key: string;
|
|
57
|
+
text: string;
|
|
58
|
+
checked: boolean;
|
|
59
|
+
}[];
|
|
60
|
+
|
|
61
|
+
export type OrgPreferences = {
|
|
62
|
+
disable_ai_flagging?: boolean;
|
|
63
|
+
disable_allow_exports?: boolean;
|
|
64
|
+
sync_phone_contacts?: boolean;
|
|
65
|
+
mask_phone_numbers?: boolean;
|
|
66
|
+
show_sender_names?: boolean;
|
|
67
|
+
closed_chats?: Record<string, number>;
|
|
68
|
+
auto_read_muted_chats?: boolean;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type OrgPreferenceKey = keyof OrgPreferences;
|
|
72
|
+
|
|
73
|
+
export type OrgPreferencesValue = {
|
|
74
|
+
[K in OrgPreferenceKey]: { key: K; value: OrgPreferences[K] };
|
|
75
|
+
}[OrgPreferenceKey];
|
|
76
|
+
|
|
77
|
+
export type OrgMetadata = {
|
|
78
|
+
phone_number: string;
|
|
79
|
+
ticket_prefix: string;
|
|
80
|
+
referralSource?: string;
|
|
81
|
+
surveyData?: MicrosurveyData;
|
|
82
|
+
preferences?: OrgPreferences;
|
|
83
|
+
hubspot: {
|
|
84
|
+
hubspot_pipelines?: {
|
|
85
|
+
id: string;
|
|
86
|
+
label: string;
|
|
87
|
+
default_stage: { id: string; label: string };
|
|
88
|
+
}[];
|
|
89
|
+
hubspot_hidden_fields?: string[];
|
|
90
|
+
}
|
|
91
|
+
partition?: boolean;
|
|
92
|
+
tickets: {
|
|
93
|
+
prefix?: string;
|
|
94
|
+
emoji_ticketing: {
|
|
95
|
+
is_enabled?: boolean;
|
|
96
|
+
is_message_enabled?: boolean;
|
|
97
|
+
message_template?: string;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
attribution?: Object;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
type AccessScopes = {
|
|
104
|
+
feature_flags: Record<string, boolean>;
|
|
105
|
+
integrations: boolean;
|
|
106
|
+
exports: boolean;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type OrgType = OverrideProperties<
|
|
110
|
+
Merge<
|
|
111
|
+
Tables<'tbl_org'>,
|
|
112
|
+
{
|
|
113
|
+
user: Tables<'tbl_org_members'>;
|
|
114
|
+
members: Tables<'tbl_org_members'>[];
|
|
115
|
+
phones: Tables<'tbl_org_phones'>[];
|
|
116
|
+
labels: Tables<'tbl_org_labels'>[];
|
|
117
|
+
quick_replies: Tables<'tbl_quick_replies'>[];
|
|
118
|
+
custom_properties: Tables<'tbl_custom_properties'>[];
|
|
119
|
+
subscription_status: 'active' | 'inactive' | 'unpaid';
|
|
120
|
+
is_enterprise: boolean;
|
|
121
|
+
is_free_trial: boolean;
|
|
122
|
+
is_hubspot_connected: boolean;
|
|
123
|
+
is_freshdesk_connected: boolean;
|
|
124
|
+
is_zohodesk_connected: boolean;
|
|
125
|
+
access_scopes: AccessScopes;
|
|
126
|
+
rules: Rule[];
|
|
127
|
+
}
|
|
128
|
+
>,
|
|
129
|
+
{
|
|
130
|
+
org_plan: OrgPlan<AllPlans | Enterprise>;
|
|
131
|
+
stripe_customer_details: _Stripe.Customer | null;
|
|
132
|
+
stripe_subscription_details: Array<_Stripe.Subscription> | null;
|
|
133
|
+
stripe_customer_id: _Stripe.Customer['id'] | null;
|
|
134
|
+
org_metadata: OrgMetadata;
|
|
135
|
+
}
|
|
136
|
+
>;
|
|
137
|
+
|
|
138
|
+
export type ChatMemberType = Merge<
|
|
139
|
+
Tables<'tbl_chat_participants'>,
|
|
140
|
+
Tables<'tbl_contacts'>
|
|
141
|
+
>;
|
|
142
|
+
|
|
143
|
+
export type ChatType = Merge<
|
|
144
|
+
Tables<'view_chats'>,
|
|
145
|
+
{
|
|
146
|
+
chat_id: string;
|
|
147
|
+
latest_message: MessageType | null;
|
|
148
|
+
latest_message_timestamp: number | null;
|
|
149
|
+
members: { [key: string]: ChatMemberType } | null;
|
|
150
|
+
chat_type: 'user' | 'group' | 'business' | 'unknown';
|
|
151
|
+
chat_access: { [key: string]: boolean };
|
|
152
|
+
label_ids: { [key: string]: boolean };
|
|
153
|
+
chat_org_phones?: string[];
|
|
154
|
+
message_unread_count: number | null;
|
|
155
|
+
hubspot_metadata: {
|
|
156
|
+
id: string;
|
|
157
|
+
type: string;
|
|
158
|
+
hubId: string;
|
|
159
|
+
object_data: HubspotObjectDataType;
|
|
160
|
+
} | null;
|
|
161
|
+
info_admins_only: boolean;
|
|
162
|
+
messages_admins_only: boolean;
|
|
163
|
+
unread_count?: { [key: string]: number };
|
|
164
|
+
active_phone: string | null;
|
|
165
|
+
flag_count_map?: { [key: string]: number };
|
|
166
|
+
is_archived?: boolean;
|
|
167
|
+
is_pinned?: boolean;
|
|
168
|
+
closed_at?: number | null;
|
|
169
|
+
common_chats?: string[];
|
|
170
|
+
}
|
|
171
|
+
>;
|
|
172
|
+
|
|
173
|
+
/* -------------------------------------------------------------------------- */
|
|
174
|
+
/* MESSAGE */
|
|
175
|
+
/* -------------------------------------------------------------------------- */
|
|
176
|
+
|
|
177
|
+
export type MediaType = {
|
|
178
|
+
path: string;
|
|
179
|
+
mimetype?: string;
|
|
180
|
+
filename?: string;
|
|
181
|
+
dimensions?: { width: number; height: number; ar: number };
|
|
182
|
+
size?: number;
|
|
183
|
+
thumbnail?: string;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export type MessageType = Merge<
|
|
187
|
+
OverrideProperties<
|
|
188
|
+
Tables<'tbl_chat_messages'>,
|
|
189
|
+
{
|
|
190
|
+
message_id: string;
|
|
191
|
+
org_id: string;
|
|
192
|
+
org_phone: string;
|
|
193
|
+
chat_id: string;
|
|
194
|
+
message_type: (typeof SUPPORTED_TYPES)[number];
|
|
195
|
+
media: MediaType | null;
|
|
196
|
+
flag_metadata: MessageFlagType | null;
|
|
197
|
+
poll_info?: PollSendType | null;
|
|
198
|
+
poll_results?: PollResultType | null;
|
|
199
|
+
delivery_info?: DeliveryInfoType | null;
|
|
200
|
+
}
|
|
201
|
+
>,
|
|
202
|
+
{
|
|
203
|
+
reactions?: ReactionType[];
|
|
204
|
+
message_payload?: SingleMessagePayload;
|
|
205
|
+
highlight?: number;
|
|
206
|
+
}
|
|
207
|
+
>;
|
|
208
|
+
|
|
209
|
+
export type MessageFlagType = {
|
|
210
|
+
status: boolean;
|
|
211
|
+
response_type?: 'message' | 'reaction' | 'ticket' | 'manual';
|
|
212
|
+
response_id?: string;
|
|
213
|
+
response_timestamp?: string;
|
|
214
|
+
response_email?: string;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/* -------------------------------------------------------------------------- */
|
|
218
|
+
|
|
219
|
+
export type TicketType = OverrideProperties<
|
|
220
|
+
Tables<'tbl_chat_tickets'>,
|
|
221
|
+
{
|
|
222
|
+
label_ids: { [key: string]: boolean };
|
|
223
|
+
hubspot_metadata: {
|
|
224
|
+
id?: string;
|
|
225
|
+
type?: string;
|
|
226
|
+
hubId?: string;
|
|
227
|
+
pipeline: {
|
|
228
|
+
id: string;
|
|
229
|
+
label: string;
|
|
230
|
+
};
|
|
231
|
+
object_data?: HubspotObjectDataType;
|
|
232
|
+
} | null;
|
|
233
|
+
freshdesk_metadata: Record<string, string>;
|
|
234
|
+
close_ticket_metadata?:
|
|
235
|
+
| {
|
|
236
|
+
closed_by: string;
|
|
237
|
+
closed_at: string;
|
|
238
|
+
closed_message?: string | null;
|
|
239
|
+
send_reply_message_id?: string | null;
|
|
240
|
+
}
|
|
241
|
+
| any;
|
|
242
|
+
}
|
|
243
|
+
>;
|
|
244
|
+
|
|
245
|
+
export type ContactType = Merge<
|
|
246
|
+
Tables<'tbl_contacts'>,
|
|
247
|
+
{
|
|
248
|
+
chats: ChatType[] | null;
|
|
249
|
+
chat_ids?: string[];
|
|
250
|
+
}
|
|
251
|
+
>;
|
|
252
|
+
export type ReactionType = Tables<'tbl_chat_reactions'>;
|
|
253
|
+
|
|
254
|
+
export type NotificationType = Tables<'tbl_chat_notifications'>;
|
|
255
|
+
|
|
256
|
+
export type ChatAccessType = Merge<
|
|
257
|
+
TablesUpdate<'tbl_org_members'>,
|
|
258
|
+
{
|
|
259
|
+
has_access?: boolean;
|
|
260
|
+
email: string | null;
|
|
261
|
+
}
|
|
262
|
+
>;
|
|
263
|
+
|
|
264
|
+
/* -------------------------------- CONSTANTS ------------------------------- */
|
|
265
|
+
|
|
266
|
+
export const labelColors = [
|
|
267
|
+
'#9333EA',
|
|
268
|
+
'#0D9488',
|
|
269
|
+
'#DB2777',
|
|
270
|
+
'#2563EB',
|
|
271
|
+
'#F97316',
|
|
272
|
+
];
|
|
273
|
+
|
|
274
|
+
export const enumChatColors = [
|
|
275
|
+
'#B4876E',
|
|
276
|
+
'#A5B337',
|
|
277
|
+
'#06CF9C',
|
|
278
|
+
'#25D366',
|
|
279
|
+
'#02A698',
|
|
280
|
+
'#7D9EF1',
|
|
281
|
+
'#007BFC',
|
|
282
|
+
'#5E47DE',
|
|
283
|
+
'#7F66FF',
|
|
284
|
+
'#9333EA',
|
|
285
|
+
'#FA6533',
|
|
286
|
+
'#C4532D',
|
|
287
|
+
'#DC2626',
|
|
288
|
+
'#FF2E74',
|
|
289
|
+
'#DB2777',
|
|
290
|
+
] as const;
|
|
291
|
+
|
|
292
|
+
/* -------------------------- SEND MESSAGE PAYLOAD -------------------------- */
|
|
293
|
+
|
|
294
|
+
export const SUPPORTED_TYPES = [
|
|
295
|
+
'chat',
|
|
296
|
+
'sticker',
|
|
297
|
+
'image',
|
|
298
|
+
'video',
|
|
299
|
+
'document',
|
|
300
|
+
'vcard',
|
|
301
|
+
'multi_vcard',
|
|
302
|
+
'audio',
|
|
303
|
+
'ptt',
|
|
304
|
+
'poll_creation',
|
|
305
|
+
'location',
|
|
306
|
+
'ciphertext',
|
|
307
|
+
] as const;
|
|
308
|
+
|
|
309
|
+
export type SendMessageContent = {
|
|
310
|
+
message_type?: (typeof SUPPORTED_TYPES)[number];
|
|
311
|
+
body?: string;
|
|
312
|
+
media?: MediaType;
|
|
313
|
+
contact_ids?: string[];
|
|
314
|
+
location?: {
|
|
315
|
+
latitude: string;
|
|
316
|
+
longitude: string;
|
|
317
|
+
options?: { name?: string; address?: string; url?: string };
|
|
318
|
+
};
|
|
319
|
+
poll?: PollSendType;
|
|
320
|
+
quoted_message_id?: string;
|
|
321
|
+
quoted_message_type?: 'reply' | 'forward' | 'reply_private';
|
|
322
|
+
broadcast_id?: string;
|
|
323
|
+
performed_by?: string;
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
export type QuickReplyContent = Omit<
|
|
327
|
+
SendMessageContent,
|
|
328
|
+
'broadcast_id' | 'variables'
|
|
329
|
+
>;
|
|
330
|
+
|
|
331
|
+
export type BroadcastVariableType = {
|
|
332
|
+
chat_id: string;
|
|
333
|
+
values: { [key: string]: string };
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
export type BroadcastMessagePayload = SendMessageContent & {
|
|
337
|
+
chat_ids: string[];
|
|
338
|
+
broadcast_id?: string;
|
|
339
|
+
variables?: BroadcastVariableType[];
|
|
340
|
+
delay?: number;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
export type SingleMessagePayload = SendMessageContent & {
|
|
344
|
+
chat_id: string;
|
|
345
|
+
job_id?: string;
|
|
346
|
+
priority?: number;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
export type MessageAttachmentFileTypes =
|
|
350
|
+
| 'image'
|
|
351
|
+
| 'audio'
|
|
352
|
+
| 'document'
|
|
353
|
+
| 'video';
|
|
354
|
+
|
|
355
|
+
export type AttachmentFileType = {
|
|
356
|
+
result: string;
|
|
357
|
+
file: File | null;
|
|
358
|
+
type: MessageAttachmentFileTypes;
|
|
359
|
+
localFileURL?: string;
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
export type AttachmentLinkType = {
|
|
363
|
+
link: {
|
|
364
|
+
url: string;
|
|
365
|
+
type: MessageAttachmentFileTypes;
|
|
366
|
+
name: string;
|
|
367
|
+
mimetype?: string;
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
export type AttachmentTypeProps = AttachmentFileType | AttachmentLinkType;
|
|
372
|
+
|
|
373
|
+
/* -------------------------------- BROADCAST ------------------------------- */
|
|
374
|
+
|
|
375
|
+
export type BroadcastLogType = Tables<'view_broadcast_logs'> & {
|
|
376
|
+
logs: (Tables<'tbl_broadcast_logs'> & Partial<ChatType>)[];
|
|
377
|
+
} & {
|
|
378
|
+
chats: ChatType[];
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
/* ----------------------- CHAT PARTICIPANT OPERATION ----------------------- */
|
|
382
|
+
|
|
383
|
+
export type ChatLogType = {
|
|
384
|
+
log: Tables<'view_chat_logs'>;
|
|
385
|
+
operations: Tables<'tbl_chat_logs'>[];
|
|
386
|
+
};
|
|
387
|
+
export type ChatOperationsType = 'ADD' | 'REMOVE' | 'PROMOTE' | 'DEMOTE';
|
|
388
|
+
|
|
389
|
+
export type ChatParticipantOperationPayload = {
|
|
390
|
+
participant_ids: string[];
|
|
391
|
+
chat_ids: string[];
|
|
392
|
+
performed_by: string;
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
export type ChatOperationReturn = {
|
|
396
|
+
[participant_id: string]: {
|
|
397
|
+
is_success: boolean;
|
|
398
|
+
message?: string;
|
|
399
|
+
code?: number;
|
|
400
|
+
isInviteV4Sent?: boolean;
|
|
401
|
+
};
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
/* ----------------------- BILLING - STRIPE ----------------------- */
|
|
405
|
+
|
|
406
|
+
export type StripeSubscription = _Stripe.Subscription;
|
|
407
|
+
export type StripeCustomer = _Stripe.Customer;
|
|
408
|
+
export type StripeCoupon = _Stripe.Coupon;
|
|
409
|
+
export type StripePrice = _Stripe.Price;
|
|
410
|
+
export type Stripe = _Stripe;
|
|
411
|
+
export type StripeUpcomingInvoice = _Stripe.UpcomingInvoice;
|
|
412
|
+
export type StripeLineItem = _Stripe.Checkout.SessionCreateParams.LineItem;
|
|
413
|
+
|
|
414
|
+
/* -------------------------------- REALTIME -------------------------------- */
|
|
415
|
+
|
|
416
|
+
export type PhoneStateType = {
|
|
417
|
+
loading: boolean;
|
|
418
|
+
state: string;
|
|
419
|
+
sync: number;
|
|
420
|
+
percent: number | null;
|
|
421
|
+
message?: string;
|
|
422
|
+
error?: string;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
/* ------------------------------- INTEGRATIONS ----------------------------- */
|
|
426
|
+
|
|
427
|
+
export type ChatInfoType = Merge<
|
|
428
|
+
ChatType,
|
|
429
|
+
{
|
|
430
|
+
members: {
|
|
431
|
+
[key: string]: Merge<ChatMemberType, { contact_labels: string }>;
|
|
432
|
+
} | null;
|
|
433
|
+
chat_labels: string | null;
|
|
434
|
+
custom_properties: { [key: string]: string } | null;
|
|
435
|
+
}
|
|
436
|
+
>;
|
|
437
|
+
|
|
438
|
+
export type TicketInfoType = {
|
|
439
|
+
chat: ChatInfoType;
|
|
440
|
+
message: {
|
|
441
|
+
body: string;
|
|
442
|
+
chat_id: string;
|
|
443
|
+
org_phone: string;
|
|
444
|
+
timestamp: string;
|
|
445
|
+
media_path: string;
|
|
446
|
+
message_id: string;
|
|
447
|
+
sender_name: string;
|
|
448
|
+
performed_by: string;
|
|
449
|
+
sender_phone: string;
|
|
450
|
+
};
|
|
451
|
+
ticket: {
|
|
452
|
+
org_id: string;
|
|
453
|
+
status: string;
|
|
454
|
+
subject: string;
|
|
455
|
+
assignee: string;
|
|
456
|
+
due_date: string;
|
|
457
|
+
priority: 0 | 1 | 2 | 3 | 4;
|
|
458
|
+
raised_by: string;
|
|
459
|
+
ticket_id: string;
|
|
460
|
+
created_at: string;
|
|
461
|
+
assigned_by: string;
|
|
462
|
+
ticket_labels: string;
|
|
463
|
+
quoted_message_id: string;
|
|
464
|
+
ticket_custom_properties: { [key: string]: string } | null;
|
|
465
|
+
};
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
export type IntegrationLogObjectType =
|
|
469
|
+
| 'chat'
|
|
470
|
+
| 'message'
|
|
471
|
+
| 'reaction'
|
|
472
|
+
| 'ticket';
|
|
473
|
+
|
|
474
|
+
export enum IntegrationLogType {
|
|
475
|
+
NEW_CHAT = 'chat.created',
|
|
476
|
+
NEW_CHAT_NOTIFICATION = 'chat.notification.created',
|
|
477
|
+
NEW_MESSAGE = 'message.created',
|
|
478
|
+
MESSAGE_UPDATED = 'message.updated',
|
|
479
|
+
MESSAGE_DELETED = 'message.deleted',
|
|
480
|
+
MESSAGE_ACK_UPDATED = 'message.ack.updated',
|
|
481
|
+
REACTION_CREATED = 'reaction.created',
|
|
482
|
+
REACTION_UPDATED = 'reaction.updated',
|
|
483
|
+
NEW_TICKET = 'ticket.created',
|
|
484
|
+
TICKET_UPDATED = 'ticket.updated',
|
|
485
|
+
TICKET_DELETED = 'ticket.deleted',
|
|
486
|
+
MESSAGE_FLAGGED = 'message.flagged',
|
|
487
|
+
MESSAGE_UNFLAGGED = 'message.unflagged',
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export type IntegrationLogMetadataType<T extends IntegrationLogType> =
|
|
491
|
+
T extends IntegrationLogType.NEW_TICKET | IntegrationLogType.TICKET_UPDATED
|
|
492
|
+
? TicketInfoType
|
|
493
|
+
: T extends IntegrationLogType.NEW_CHAT
|
|
494
|
+
? Tables<'tbl_chats'>
|
|
495
|
+
: T extends
|
|
496
|
+
| IntegrationLogType.NEW_MESSAGE
|
|
497
|
+
| IntegrationLogType.MESSAGE_UPDATED
|
|
498
|
+
| IntegrationLogType.MESSAGE_DELETED
|
|
499
|
+
| IntegrationLogType.MESSAGE_ACK_UPDATED
|
|
500
|
+
| IntegrationLogType.MESSAGE_FLAGGED
|
|
501
|
+
| IntegrationLogType.MESSAGE_UNFLAGGED
|
|
502
|
+
? Tables<'tbl_chat_messages'>
|
|
503
|
+
: T extends
|
|
504
|
+
| IntegrationLogType.REACTION_CREATED
|
|
505
|
+
| IntegrationLogType.REACTION_UPDATED
|
|
506
|
+
? Tables<'tbl_chat_reactions'>
|
|
507
|
+
: {
|
|
508
|
+
[key: string]: unknown;
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
export type IntegrationLogDetailsType<T extends IntegrationLogType> =
|
|
512
|
+
OverrideProperties<
|
|
513
|
+
Tables<'tbl_integration_logs'>,
|
|
514
|
+
{
|
|
515
|
+
integration_name: T;
|
|
516
|
+
metadata: {
|
|
517
|
+
event: IntegrationLogMetadataType<T> & {
|
|
518
|
+
event_type: string;
|
|
519
|
+
org_id: string;
|
|
520
|
+
previous_attributes: {
|
|
521
|
+
[key: string]: unknown;
|
|
522
|
+
};
|
|
523
|
+
};
|
|
524
|
+
hook_id: string;
|
|
525
|
+
name: string;
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
>;
|
|
529
|
+
|
|
530
|
+
export type APIAuthDetails = {
|
|
531
|
+
org_details: Tables<'view_org'> | null;
|
|
532
|
+
phone_details: Tables<'tbl_org_phones'> | null;
|
|
533
|
+
token_details: Tables<'tbl_integration_tokens'> | null;
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
export type WebhookDataType = OverrideProperties<
|
|
537
|
+
Tables<'tbl_integration_hooks'>,
|
|
538
|
+
{
|
|
539
|
+
integration_name: string[];
|
|
540
|
+
}
|
|
541
|
+
>;
|
|
542
|
+
|
|
543
|
+
export type HubspotObjectDataType = {
|
|
544
|
+
createdAt: string;
|
|
545
|
+
archived: boolean;
|
|
546
|
+
id: string;
|
|
547
|
+
type: 'contacts' | 'tickets' | 'companies';
|
|
548
|
+
properties: Record<
|
|
549
|
+
string,
|
|
550
|
+
{
|
|
551
|
+
groupLabel: string;
|
|
552
|
+
groupName: string;
|
|
553
|
+
propertyKeyName: string;
|
|
554
|
+
propertyKey: string;
|
|
555
|
+
propertyInternalValue: string;
|
|
556
|
+
propertyValue: string;
|
|
557
|
+
propertyType: string;
|
|
558
|
+
propertyFieldType: string;
|
|
559
|
+
}[]
|
|
560
|
+
>;
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
/* ---------------------------- USER PREFERENCES ---------------------------- */
|
|
564
|
+
|
|
565
|
+
export type UserPreferences = {
|
|
566
|
+
theme: 'light' | 'dark';
|
|
567
|
+
language: 'en' | 'es';
|
|
568
|
+
left_sidebar_open: boolean;
|
|
569
|
+
right_sidepanel_open: boolean;
|
|
570
|
+
sync_wa_unread_count: boolean;
|
|
571
|
+
pinned_chats: string[];
|
|
572
|
+
archived_chats: string[];
|
|
573
|
+
closed_chats: Record<string, number>;
|
|
574
|
+
periskope_chat_limit: number;
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
/* ----------------------------- POLL VOTE INFO ----------------------------- */
|
|
578
|
+
|
|
579
|
+
export type PollSendType = {
|
|
580
|
+
pollName: string;
|
|
581
|
+
pollOptions: string[];
|
|
582
|
+
options?: {
|
|
583
|
+
allowMultipleAnswers?: boolean;
|
|
584
|
+
messageSecret?: number[] | null;
|
|
585
|
+
pollId?: string;
|
|
586
|
+
};
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
export type PollResultType = {
|
|
590
|
+
[name: string]: Record<string, string>;
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
/* -------------------------- CREATE GROUP OPTIONS -------------------------- */
|
|
594
|
+
|
|
595
|
+
export type CreateGroupOptions = {
|
|
596
|
+
messagesAdminsOnly?: boolean;
|
|
597
|
+
infoAdminsOnly?: boolean;
|
|
598
|
+
memberAddMode?: boolean;
|
|
599
|
+
image?: string;
|
|
600
|
+
name?: string;
|
|
601
|
+
description?: string;
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
/* ------------------------------ DELIVERY INFO ----------------------------- */
|
|
605
|
+
|
|
606
|
+
export type DeliveryInfoType = {
|
|
607
|
+
delivered: Record<string, number | undefined>;
|
|
608
|
+
read: Record<string, number | undefined>;
|
|
609
|
+
pending: string[];
|
|
610
|
+
read_count: number;
|
|
611
|
+
delivered_count: number;
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
/* ---------------------------- CREDITS SYSTEM ---------------------------- */
|
|
615
|
+
|
|
616
|
+
export type OrgCreditsType = {
|
|
617
|
+
org_id: string;
|
|
618
|
+
recurring_allowance: number; // recurring credits replenished every month
|
|
619
|
+
recurring_balance: number; // recurring credits remaining in current month
|
|
620
|
+
topup_balance: number; // topup credits remaining
|
|
621
|
+
total_credits_used: number; // total credits used in current month
|
|
622
|
+
next_renewal_date: string;
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
/* --------------------------------- RULE INFO TYPE -------------------------------- */
|
|
626
|
+
|
|
627
|
+
export type ChatRuleInfoType = Merge<
|
|
628
|
+
Pick<
|
|
629
|
+
Tables<'view_chats'>,
|
|
630
|
+
| 'assigned_to'
|
|
631
|
+
| 'chat_id'
|
|
632
|
+
| 'chat_name'
|
|
633
|
+
| 'chat_type'
|
|
634
|
+
| 'created_at'
|
|
635
|
+
| 'group_description'
|
|
636
|
+
| 'info_admins_only'
|
|
637
|
+
| 'org_id'
|
|
638
|
+
| 'org_phone'
|
|
639
|
+
| 'chat_org_phones'
|
|
640
|
+
| 'messages_admins_only'
|
|
641
|
+
| 'custom_properties'
|
|
642
|
+
>,
|
|
643
|
+
{
|
|
644
|
+
has_flagged_messages: boolean;
|
|
645
|
+
labels: string[];
|
|
646
|
+
members: string[];
|
|
647
|
+
custom_properties: { [key: string]: string } | null;
|
|
648
|
+
}
|
|
649
|
+
>;
|
|
650
|
+
|
|
651
|
+
export type SenderRuleInfoType = Merge<
|
|
652
|
+
Omit<
|
|
653
|
+
Merge<Tables<'tbl_contacts'>, Tables<'tbl_chat_participants'>>,
|
|
654
|
+
| 'verified_name'
|
|
655
|
+
| 'verified_level'
|
|
656
|
+
| 'updated_at'
|
|
657
|
+
| 'short_name'
|
|
658
|
+
| 'pushname'
|
|
659
|
+
| 'periskope_name'
|
|
660
|
+
| 'org_phone'
|
|
661
|
+
| 'number'
|
|
662
|
+
| 'name'
|
|
663
|
+
| 'label_ids'
|
|
664
|
+
| 'is_wa_contact'
|
|
665
|
+
| 'is_user'
|
|
666
|
+
| 'is_my_contact'
|
|
667
|
+
| 'is_me'
|
|
668
|
+
| 'is_imported'
|
|
669
|
+
| 'is_group'
|
|
670
|
+
| 'is_blocked'
|
|
671
|
+
| 'contact_color'
|
|
672
|
+
| 'business_profile'
|
|
673
|
+
| 'id'
|
|
674
|
+
| 'contact_image'
|
|
675
|
+
| 'contact_type'
|
|
676
|
+
| 'chat_id'
|
|
677
|
+
| 'is_business'
|
|
678
|
+
| 'is_enterprise'
|
|
679
|
+
| 'is_super_admin'
|
|
680
|
+
>,
|
|
681
|
+
{
|
|
682
|
+
is_internal: boolean;
|
|
683
|
+
labels: string[] | null;
|
|
684
|
+
}
|
|
685
|
+
>;
|
|
686
|
+
|
|
687
|
+
export type MessageRuleInfoType = {
|
|
688
|
+
chat: ChatRuleInfoType;
|
|
689
|
+
sender: SenderRuleInfoType;
|
|
690
|
+
message: OverrideProperties<
|
|
691
|
+
Omit<
|
|
692
|
+
Tables<'tbl_chat_messages'>,
|
|
693
|
+
| 'vcards'
|
|
694
|
+
| 'updated_at'
|
|
695
|
+
| 'unique_id'
|
|
696
|
+
| 'token'
|
|
697
|
+
| 'to'
|
|
698
|
+
| 'sent_message_id'
|
|
699
|
+
| 'raw_data'
|
|
700
|
+
| 'delivery_info'
|
|
701
|
+
| 'poll_results'
|
|
702
|
+
| 'poll_info'
|
|
703
|
+
| 'order_id'
|
|
704
|
+
| 'mentioned_ids'
|
|
705
|
+
| 'media_key'
|
|
706
|
+
| 'location'
|
|
707
|
+
| 'links'
|
|
708
|
+
| 'is_status'
|
|
709
|
+
| 'is_starred'
|
|
710
|
+
| 'is_gif'
|
|
711
|
+
| 'is_forwarded'
|
|
712
|
+
| 'is_ephemeral'
|
|
713
|
+
| 'is_deleted'
|
|
714
|
+
| 'fts'
|
|
715
|
+
| 'quoted_message_id'
|
|
716
|
+
| 'invite_v4'
|
|
717
|
+
| 'id'
|
|
718
|
+
| 'has_reaction'
|
|
719
|
+
| 'has_media'
|
|
720
|
+
| 'duration'
|
|
721
|
+
| 'broadcast'
|
|
722
|
+
| 'broadcast_id'
|
|
723
|
+
| 'device_type'
|
|
724
|
+
| 'forwarding_score'
|
|
725
|
+
| 'from'
|
|
726
|
+
| 'from_me'
|
|
727
|
+
| 'message_ticket_id'
|
|
728
|
+
| 'prev_body'
|
|
729
|
+
| 'flag_response_time'
|
|
730
|
+
| 'flag_metadata'
|
|
731
|
+
| 'ack'
|
|
732
|
+
>,
|
|
733
|
+
{
|
|
734
|
+
media: MediaType | null;
|
|
735
|
+
}
|
|
736
|
+
>;
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
export type ReactionRuleInfoType = {
|
|
740
|
+
chat: ChatRuleInfoType;
|
|
741
|
+
sender: SenderRuleInfoType;
|
|
742
|
+
message: MessageRuleInfoType['message'];
|
|
743
|
+
reaction: Pick<
|
|
744
|
+
Tables<'tbl_chat_reactions'>,
|
|
745
|
+
'reaction' | 'sender_id' | 'message_id' | 'chat_id' | 'reaction_id'
|
|
746
|
+
>;
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
export type TicketRuleInfoType = {
|
|
750
|
+
chat: ChatRuleInfoType;
|
|
751
|
+
sender: SenderRuleInfoType;
|
|
752
|
+
ticket: Merge<
|
|
753
|
+
Pick<
|
|
754
|
+
Tables<'tbl_chat_tickets'>,
|
|
755
|
+
| 'org_id'
|
|
756
|
+
| 'status'
|
|
757
|
+
| 'chat_id'
|
|
758
|
+
| 'subject'
|
|
759
|
+
| 'assignee'
|
|
760
|
+
| 'due_date'
|
|
761
|
+
| 'priority'
|
|
762
|
+
| 'raised_by'
|
|
763
|
+
| 'ticket_id'
|
|
764
|
+
| 'created_at'
|
|
765
|
+
| 'is_deleted'
|
|
766
|
+
>,
|
|
767
|
+
{
|
|
768
|
+
labels: string[] | null;
|
|
769
|
+
custom_properties: { [key: string]: string } | null;
|
|
770
|
+
}
|
|
771
|
+
>;
|
|
772
|
+
message: MessageRuleInfoType['message'];
|
|
773
|
+
};
|
|
774
|
+
export type FeatureFlagReturnType = Record<string, boolean>;
|
|
775
|
+
|
|
776
|
+
export type RuleLogsType = OverrideProperties<
|
|
777
|
+
Tables<'tbl_rules_logs'>,
|
|
778
|
+
{
|
|
779
|
+
actions_progress: {
|
|
780
|
+
action_id: string;
|
|
781
|
+
action_type: Rule['actions'][number]['type'];
|
|
782
|
+
action_delay: Rule['actions'][number]['delay'];
|
|
783
|
+
ran_at: string | null;
|
|
784
|
+
action_status: 'success' | 'failed' | 'pending';
|
|
785
|
+
action_response: {
|
|
786
|
+
success: boolean;
|
|
787
|
+
data: Record<string, unknown> | null;
|
|
788
|
+
error: {
|
|
789
|
+
message: string;
|
|
790
|
+
name: string;
|
|
791
|
+
stack?: string;
|
|
792
|
+
_error?: Error | Record<string, unknown>;
|
|
793
|
+
} | null;
|
|
794
|
+
};
|
|
795
|
+
}[];
|
|
796
|
+
metadata: {
|
|
797
|
+
conditions: Rule['conditions'];
|
|
798
|
+
actions: Rule['actions'];
|
|
799
|
+
data: Record<string, unknown>;
|
|
800
|
+
};
|
|
801
|
+
conditions_progress: {
|
|
802
|
+
is_valid: boolean;
|
|
803
|
+
validation_progress: Record<
|
|
804
|
+
string,
|
|
805
|
+
{
|
|
806
|
+
res: boolean;
|
|
807
|
+
filter: Filter;
|
|
808
|
+
value: unknown;
|
|
809
|
+
}
|
|
810
|
+
>;
|
|
811
|
+
checked_at: string | null;
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
814
|
>;
|