@periskope/types 0.6.13 → 0.6.14-5.2

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/types.d.ts CHANGED
@@ -1,47 +1,466 @@
1
+ import type { default as _Stripe } from 'stripe';
1
2
  import { Merge, OverrideProperties } from 'type-fest';
2
- import { Chat, MessageTypes } from 'whatsapp-web.js';
3
- import { Tables } from './supabase.types';
4
- export type WhatsappChat = Chat & {
5
- groupMetadata?: any;
6
- pinned?: boolean;
7
- invite_link?: string;
8
- };
9
- export type OrgType = Tables<'tbl_org'> & {
3
+ import { Tables, TablesUpdate } from './supabase.types';
4
+ export declare enum AllPlans {
5
+ FREE_TRIAL = "free-trial",
6
+ ENTERPRISE = "enterprise",
7
+ MONTHLY_STARTER_SINGLE = "monthly-starter-single",
8
+ YEARLY_STARTER_SINGLE = "yearly-starter-single",
9
+ MONTHLY_PRO_SINGLE = "monthly-pro-single",
10
+ YEARLY_PRO_SINGLE = "yearly-pro-single"
11
+ }
12
+ export type Frequency = 'yearly' | 'monthly' | 'weekly' | 'custom';
13
+ export type Enterprise = `${string}-enterprise`;
14
+ export type OrgPlanEnterprise = {
15
+ subscription_id: string;
16
+ plan_id: Enterprise;
17
+ interval: number;
18
+ frequency: Frequency;
19
+ user_limit: number;
20
+ phone_limit: number;
21
+ current_period_start: number;
22
+ current_period_end: number | null;
23
+ };
24
+ export type OrgPlanNonEnterprise = {
25
+ subscription_id: string;
26
+ plan_id: AllPlans;
27
+ interval: number;
28
+ frequency: Frequency;
29
+ user_limit: number;
30
+ phone_limit: number;
31
+ current_period_end: number;
32
+ current_period_start: number;
33
+ };
34
+ export type OrgPlan<T extends AllPlans | Enterprise> = T extends Enterprise ? OrgPlanEnterprise : T extends AllPlans ? OrgPlanNonEnterprise : never;
35
+ export type MicrosurveyData = {
36
+ key: string;
37
+ text: string;
38
+ checked: boolean;
39
+ }[];
40
+ export type OrgPreferences = {
41
+ disable_ai_flagging?: boolean;
42
+ disable_allow_exports?: boolean;
43
+ sync_phone_contacts?: boolean;
44
+ mask_phone_numbers?: boolean;
45
+ show_sender_names?: boolean;
46
+ };
47
+ type OrgPreferenceKey = keyof OrgPreferences;
48
+ export type OrgPreferencesValue = {
49
+ [K in OrgPreferenceKey]: {
50
+ key: K;
51
+ value: OrgPreferences[K];
52
+ };
53
+ }[OrgPreferenceKey];
54
+ export type OrgMetadata = {
55
+ phone_number: string;
56
+ ticket_prefix: string;
57
+ referralSource?: string;
58
+ surveyData?: MicrosurveyData;
59
+ preferences?: OrgPreferences;
60
+ hubspot_pipelines?: {
61
+ id: string;
62
+ label: string;
63
+ default_stage: {
64
+ id: string;
65
+ label: string;
66
+ };
67
+ }[];
68
+ partition?: boolean;
69
+ };
70
+ type AccessScopes = {
71
+ integrations: boolean;
72
+ exports: boolean;
73
+ };
74
+ export type OrgType = OverrideProperties<Merge<Tables<'tbl_org'>, {
10
75
  user: Tables<'tbl_org_members'>;
11
76
  members: Tables<'tbl_org_members'>[];
12
77
  phones: Tables<'tbl_org_phones'>[];
13
78
  labels: Tables<'tbl_org_labels'>[];
14
- };
79
+ quick_replies: Tables<'tbl_quick_replies'>[];
80
+ custom_properties: Tables<'tbl_custom_properties'>[];
81
+ subscription_status: 'active' | 'inactive' | 'unpaid';
82
+ is_enterprise: boolean;
83
+ is_free_trial: boolean;
84
+ is_hubspot_connected: boolean;
85
+ is_freshdesk_connected: boolean;
86
+ is_zohodesk_connected: boolean;
87
+ access_scopes: AccessScopes;
88
+ }>, {
89
+ org_plan: OrgPlan<AllPlans | Enterprise>;
90
+ stripe_customer_details: _Stripe.Customer | null;
91
+ stripe_subscription_details: Array<_Stripe.Subscription> | null;
92
+ stripe_customer_id: _Stripe.Customer['id'] | null;
93
+ org_metadata: OrgMetadata;
94
+ }>;
15
95
  export type ChatMemberType = Merge<Tables<'tbl_chat_participants'>, Tables<'tbl_contacts'>>;
16
96
  export type ChatType = Merge<Tables<'view_chats'>, {
17
97
  chat_id: string;
18
98
  latest_message: MessageType | null;
19
- members: Record<string, ChatMemberType> | null;
20
- chat_type: 'user' | 'group' | 'business';
21
- active_phone?: string;
22
- chat_access: Record<string, boolean>;
23
- label_ids: Record<string, boolean>;
99
+ latest_message_timestamp: number | null;
100
+ members: {
101
+ [key: string]: ChatMemberType;
102
+ } | null;
103
+ chat_type: 'user' | 'group' | 'business' | 'unknown';
104
+ chat_access: {
105
+ [key: string]: boolean;
106
+ };
107
+ label_ids: {
108
+ [key: string]: boolean;
109
+ };
24
110
  chat_org_phones?: string[];
111
+ message_unread_count: number | null;
112
+ hubspot_metadata: {
113
+ id: string;
114
+ type: string;
115
+ hubId: string;
116
+ object_data: HubspotObjectDataType;
117
+ } | null;
118
+ info_admins_only: boolean;
119
+ messages_admins_only: boolean;
120
+ unread_count?: {
121
+ [key: string]: number;
122
+ };
123
+ active_phone: string | null;
124
+ flag_count_map?: {
125
+ [key: string]: number;
126
+ };
127
+ pin?: boolean;
25
128
  }>;
26
129
  export type MediaType = {
27
130
  path: string;
28
- mimetype: string | null;
29
- filename: string | null;
131
+ mimetype?: string;
132
+ filename?: string;
133
+ dimensions?: {
134
+ width: number;
135
+ height: number;
136
+ ar: number;
137
+ };
138
+ size?: number;
139
+ thumbnail?: string;
30
140
  };
31
- export type MessageType = OverrideProperties<Tables<'tbl_chat_messages'>, {
32
- message_type: MessageTypes;
141
+ export type MessageType = Merge<OverrideProperties<Tables<'tbl_chat_messages'>, {
142
+ message_id: string;
143
+ org_id: string;
144
+ org_phone: string;
145
+ chat_id: string;
146
+ message_type: (typeof SUPPORTED_TYPES)[number];
33
147
  media: MediaType | null;
148
+ flag_metadata: MessageFlagType | null;
149
+ poll_info?: PollSendType | null;
150
+ poll_results?: PollResultType | null;
151
+ delivery_info?: DeliveryInfoType | null;
152
+ }>, {
153
+ reactions?: ReactionType[];
154
+ message_payload?: SingleMessagePayload;
155
+ show_unread?: boolean;
156
+ highlight?: number;
157
+ }>;
158
+ export type MessageFlagType = {
159
+ status: boolean;
160
+ response_type?: 'message' | 'reaction' | 'ticket' | 'manual';
161
+ response_id?: string;
162
+ response_timestamp?: string;
163
+ response_email?: string;
164
+ };
165
+ export type TicketType = OverrideProperties<Tables<'tbl_chat_tickets'>, {
166
+ label_ids: {
167
+ [key: string]: boolean;
168
+ };
169
+ hubspot_metadata: {
170
+ id?: string;
171
+ type?: string;
172
+ hubId?: string;
173
+ pipeline: {
174
+ id: string;
175
+ label: string;
176
+ };
177
+ object_data?: HubspotObjectDataType;
178
+ } | null;
179
+ freshdesk_metadata: Record<string, string>;
180
+ close_ticket_metadata?: {
181
+ closed_by: string;
182
+ closed_at: string;
183
+ closed_message?: string | null;
184
+ send_reply_message_id?: string | null;
185
+ } | any;
34
186
  }>;
35
187
  export type ContactType = Merge<Tables<'tbl_contacts'>, {
36
188
  chats: ChatType[] | null;
37
- chat_count: number | null;
38
- chat_ids: string[] | null;
189
+ chat_ids?: string[];
190
+ }>;
191
+ export type ReactionType = Tables<'tbl_chat_reactions'>;
192
+ export type NotificationType = Tables<'tbl_chat_notifications'>;
193
+ export type ChatAccessType = Merge<TablesUpdate<'tbl_org_members'>, {
194
+ has_access?: boolean;
195
+ email: string | null;
39
196
  }>;
40
- export type ChatAccessType = Merge<Partial<Tables<'tbl_chat_access'>>, Tables<'tbl_org_members'>>;
41
- export type ServerStateType = {
197
+ export declare const labelColors: string[];
198
+ export declare const enumChatColors: readonly ["#B4876E", "#A5B337", "#06CF9C", "#25D366", "#02A698", "#7D9EF1", "#007BFC", "#5E47DE", "#7F66FF", "#9333EA", "#FA6533", "#C4532D", "#DC2626", "#FF2E74", "#DB2777"];
199
+ export declare const SUPPORTED_TYPES: readonly ["chat", "sticker", "image", "video", "document", "vcard", "multi_vcard", "audio", "ptt", "poll_creation", "location", "ciphertext"];
200
+ export type SendMessageContent = {
201
+ message_type?: (typeof SUPPORTED_TYPES)[number];
202
+ body?: string;
203
+ media?: MediaType;
204
+ contact_ids?: string[];
205
+ location?: {
206
+ latitude: string;
207
+ longitude: string;
208
+ options?: {
209
+ name?: string;
210
+ address?: string;
211
+ url?: string;
212
+ };
213
+ };
214
+ poll?: PollSendType;
215
+ quoted_message_id?: string;
216
+ quoted_message_type?: 'reply' | 'forward' | 'reply_private';
217
+ broadcast_id?: string;
218
+ performed_by?: string;
219
+ };
220
+ export type QuickReplyContent = Omit<SendMessageContent, 'broadcast_id' | 'variables'>;
221
+ export type BroadcastVariableType = {
222
+ chat_id: string;
223
+ values: {
224
+ [key: string]: string;
225
+ };
226
+ };
227
+ export type BroadcastMessagePayload = SendMessageContent & {
228
+ chat_ids: string[];
229
+ broadcast_id?: string;
230
+ variables?: BroadcastVariableType[];
231
+ };
232
+ export type SingleMessagePayload = SendMessageContent & {
233
+ chat_id: string;
234
+ job_id?: string;
235
+ };
236
+ export type MessageAttachmentFileTypes = 'image' | 'audio' | 'document' | 'video';
237
+ export type AttachmentFileType = {
238
+ result: string;
239
+ file: File | null;
240
+ type: MessageAttachmentFileTypes;
241
+ localFileURL?: string;
242
+ };
243
+ export type AttachmentLinkType = {
244
+ link: {
245
+ url: string;
246
+ type: MessageAttachmentFileTypes;
247
+ name: string;
248
+ mimetype?: string;
249
+ };
250
+ };
251
+ export type AttachmentTypeProps = AttachmentFileType | AttachmentLinkType;
252
+ export type BroadcastLogType = Tables<'view_broadcast_logs'> & {
253
+ logs: (Tables<'tbl_broadcast_logs'> & Partial<ChatType>)[];
254
+ } & {
255
+ chats: ChatType[];
256
+ };
257
+ export type ChatLogType = {
258
+ log: Tables<'view_chat_logs'>;
259
+ operations: Tables<'tbl_chat_logs'>[];
260
+ };
261
+ export type ChatOperationsType = 'ADD' | 'REMOVE' | 'PROMOTE' | 'DEMOTE';
262
+ export type ChatParticipantOperationPayload = {
263
+ participant_ids: string[];
264
+ chat_ids: string[];
265
+ performed_by: string;
266
+ };
267
+ export type ChatOperationReturn = {
268
+ [participant_id: string]: {
269
+ is_success: boolean;
270
+ message?: string;
271
+ code?: number;
272
+ isInviteV4Sent?: boolean;
273
+ };
274
+ };
275
+ export type StripeSubscription = _Stripe.Subscription;
276
+ export type StripeCustomer = _Stripe.Customer;
277
+ export type StripeCoupon = _Stripe.Coupon;
278
+ export type StripePrice = _Stripe.Price;
279
+ export type Stripe = _Stripe;
280
+ export type StripeUpcomingInvoice = _Stripe.UpcomingInvoice;
281
+ export type StripeLineItem = _Stripe.Checkout.SessionCreateParams.LineItem;
282
+ export type PhoneStateType = {
42
283
  loading: boolean;
284
+ state: string;
285
+ sync: number;
43
286
  percent: number | null;
44
- ready: boolean;
287
+ message?: string;
288
+ error?: string;
45
289
  };
46
- export declare const labelColors: string[];
47
- export declare const enumChatColors: readonly ["#B4876E", "#A5B337", "#06CF9C", "#25D366", "#02A698", "#7D9EF1", "#007BFC", "#5E47DE", "#7F66FF", "#9333EA", "#FA6533", "#C4532D", "#DC2626", "#FF2E74", "#DB2777"];
290
+ export type ChatInfoType = Merge<ChatType, {
291
+ members: {
292
+ [key: string]: Merge<ChatMemberType, {
293
+ contact_labels: string;
294
+ }>;
295
+ } | null;
296
+ chat_labels: string | null;
297
+ custom_properties: {
298
+ [key: string]: string;
299
+ } | null;
300
+ }>;
301
+ export type TicketInfoType = {
302
+ chat: ChatInfoType;
303
+ message: {
304
+ body: string;
305
+ chat_id: string;
306
+ org_phone: string;
307
+ timestamp: string;
308
+ media_path: string;
309
+ message_id: string;
310
+ sender_name: string;
311
+ performed_by: string;
312
+ sender_phone: string;
313
+ };
314
+ ticket: {
315
+ org_id: string;
316
+ status: string;
317
+ subject: string;
318
+ assignee: string;
319
+ due_date: string;
320
+ priority: 0 | 1 | 2 | 3 | 4;
321
+ raised_by: string;
322
+ ticket_id: string;
323
+ created_at: string;
324
+ assigned_by: string;
325
+ ticket_labels: string;
326
+ quoted_message_id: string;
327
+ ticket_custom_properties: {
328
+ [key: string]: string;
329
+ } | null;
330
+ };
331
+ };
332
+ export type IntegrationLogObjectType = 'chat' | 'message' | 'reaction' | 'ticket';
333
+ export declare enum IntegrationLogType {
334
+ NEW_CHAT = "chat.created",
335
+ NEW_CHAT_NOTIFICATION = "chat.notification.created",
336
+ NEW_MESSAGE = "message.created",
337
+ MESSAGE_UPDATED = "message.updated",
338
+ MESSAGE_DELETED = "message.deleted",
339
+ MESSAGE_ACK_UPDATED = "message.ack.updated",
340
+ REACTION_CREATED = "reaction.created",
341
+ REACTION_UPDATED = "reaction.updated",
342
+ NEW_TICKET = "ticket.created",
343
+ TICKET_UPDATED = "ticket.updated",
344
+ TICKET_DELETED = "ticket.deleted"
345
+ }
346
+ export type IntegrationLogMetadataType<T extends IntegrationLogType> = T extends IntegrationLogType.NEW_TICKET | IntegrationLogType.TICKET_UPDATED ? TicketInfoType : T extends IntegrationLogType.NEW_CHAT ? Tables<'tbl_chats'> : T extends IntegrationLogType.NEW_MESSAGE | IntegrationLogType.MESSAGE_UPDATED | IntegrationLogType.MESSAGE_DELETED | IntegrationLogType.MESSAGE_ACK_UPDATED ? Tables<'tbl_chat_messages'> : T extends IntegrationLogType.REACTION_CREATED | IntegrationLogType.REACTION_UPDATED ? Tables<'tbl_chat_reactions'> : {
347
+ [key: string]: unknown;
348
+ };
349
+ export type IntegrationLogDetailsType<T extends IntegrationLogType> = OverrideProperties<Tables<'tbl_integration_logs'>, {
350
+ integration_name: T;
351
+ metadata: {
352
+ event: IntegrationLogMetadataType<T> & {
353
+ event_type: string;
354
+ org_id: string;
355
+ previous_attributes: {
356
+ [key: string]: unknown;
357
+ };
358
+ };
359
+ hook_id: string;
360
+ name: string;
361
+ };
362
+ }>;
363
+ export type APIAuthDetails = {
364
+ org_details: Tables<'view_org'> | null;
365
+ phone_details: Tables<'tbl_org_phones'> | null;
366
+ token_details: Tables<'tbl_integration_tokens'> | null;
367
+ };
368
+ export type WebhookDataType = OverrideProperties<Tables<'tbl_integration_hooks'>, {
369
+ integration_name: string[];
370
+ }>;
371
+ export type HubspotObjectDataType = {
372
+ createdAt: string;
373
+ archived: boolean;
374
+ id: string;
375
+ type: 'contacts' | 'tickets' | 'companies';
376
+ properties: Record<string, {
377
+ groupLabel: string;
378
+ groupName: string;
379
+ propertyKeyName: string;
380
+ propertyKey: string;
381
+ propertyInternalValue: string;
382
+ propertyValue: string;
383
+ propertyType: string;
384
+ propertyFieldType: string;
385
+ }[]>;
386
+ };
387
+ export type UserPreferences = {
388
+ theme: 'light' | 'dark';
389
+ language: 'en' | 'es';
390
+ left_sidebar_open: boolean;
391
+ right_sidepanel_open: boolean;
392
+ sync_wa_unread_count: boolean;
393
+ pinned_chats: string[];
394
+ };
395
+ export type PollSendType = {
396
+ pollName: string;
397
+ pollOptions: string[];
398
+ options?: {
399
+ allowMultipleAnswers?: boolean;
400
+ messageSecret?: number[] | null;
401
+ pollId?: string;
402
+ };
403
+ };
404
+ export type PollResultType = {
405
+ [name: string]: Record<string, string>;
406
+ };
407
+ export type CreateGroupOptions = {
408
+ messagesAdminsOnly?: boolean;
409
+ infoAdminsOnly?: boolean;
410
+ memberAddMode?: boolean;
411
+ image?: string;
412
+ name?: string;
413
+ description?: string;
414
+ };
415
+ export type DeliveryInfoType = {
416
+ delivered: Record<string, number | undefined>;
417
+ read: Record<string, number | undefined>;
418
+ pending: string[];
419
+ read_count: number;
420
+ delivered_count: number;
421
+ };
422
+ export type OrgCreditsType = {
423
+ org_id: string;
424
+ recurring_allowance: number;
425
+ recurring_balance: number;
426
+ topup_balance: number;
427
+ total_credits_used: number;
428
+ next_renewal_date: string;
429
+ };
430
+ export type ChatRuleInfoType = Merge<Pick<Tables<'view_chats'>, 'assigned_to' | 'chat_id' | 'chat_name' | 'chat_type' | 'created_at' | 'group_description' | 'info_admins_only' | 'is_archived' | 'is_exited' | 'is_muted' | 'org_id' | 'org_phone' | 'chat_org_phones' | 'messages_admins_only' | 'custom_properties'>, {
431
+ has_flagged_messages: boolean;
432
+ labels: string[];
433
+ members: string[];
434
+ custom_properties: {
435
+ [key: string]: string;
436
+ } | null;
437
+ }>;
438
+ export type SenderRuleInfoType = Merge<Omit<Merge<Tables<'tbl_contacts'>, Tables<'tbl_chat_participants'>>, 'verified_name' | 'verified_level' | 'updated_at' | 'short_name' | 'pushname' | 'periskope_name' | 'org_phone' | 'number' | 'name' | 'label_ids' | 'is_wa_contact' | 'is_user' | 'is_my_contact' | 'is_me' | 'is_imported' | 'is_group' | 'is_blocked' | 'contact_color' | 'business_profile' | 'id' | 'contact_image' | 'contact_type' | 'chat_id'>, {
439
+ is_internal: boolean;
440
+ labels: string[] | null;
441
+ }>;
442
+ export type MessageRuleInfoType = {
443
+ chat: ChatRuleInfoType;
444
+ sender: SenderRuleInfoType;
445
+ message: OverrideProperties<Omit<Tables<'tbl_chat_messages'>, 'vcards' | 'updated_at' | 'unique_id' | 'token' | 'to' | 'sent_message_id' | 'raw_data' | 'delivery_info' | 'poll_results' | 'poll_info' | 'order_id' | 'mentioned_ids' | 'media_key' | 'location' | 'links' | 'is_status' | 'is_starred' | 'is_gif' | 'is_forwarded' | 'is_ephemeral' | 'is_deleted' | 'fts' | 'quoted_message_id' | 'invite_v4' | 'id' | 'has_reaction' | 'has_media' | 'duration' | 'broadcast' | 'broadcast_id' | 'device_type' | 'forwarding_score' | 'from' | 'from_me' | 'message_ticket_id' | 'prev_body' | 'flag_response_time' | 'flag_metadata'>, {
446
+ media: MediaType | null;
447
+ }>;
448
+ };
449
+ export type ReactionRuleInfoType = {
450
+ chat: ChatRuleInfoType;
451
+ sender: SenderRuleInfoType;
452
+ message: MessageRuleInfoType['message'];
453
+ reaction: Pick<Tables<'tbl_chat_reactions'>, 'reaction' | 'sender_id' | 'message_id' | 'chat_id' | 'reaction_id'>;
454
+ };
455
+ export type TicketRuleInfoType = {
456
+ chat: ChatRuleInfoType;
457
+ sender: SenderRuleInfoType;
458
+ ticket: Merge<Pick<Tables<'tbl_chat_tickets'>, 'org_id' | 'status' | 'chat_id' | 'subject' | 'assignee' | 'due_date' | 'priority' | 'raised_by' | 'ticket_id' | 'created_at' | 'is_deleted'>, {
459
+ labels: string[] | null;
460
+ custom_properties: {
461
+ [key: string]: string;
462
+ } | null;
463
+ }>;
464
+ message: MessageRuleInfoType['message'];
465
+ };
466
+ export {};
package/dist/types.js CHANGED
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.enumChatColors = exports.labelColors = void 0;
3
+ exports.IntegrationLogType = exports.SUPPORTED_TYPES = exports.enumChatColors = exports.labelColors = exports.AllPlans = void 0;
4
+ /* ----------------------------- TYPE SHORTHANDS ---------------------------- */
5
+ /* ------------------------------ PERISKOPE TYPES ------------------------------ */
6
+ var AllPlans;
7
+ (function (AllPlans) {
8
+ AllPlans["FREE_TRIAL"] = "free-trial";
9
+ // MONTHLY_STARTER = 'monthly-starter',
10
+ // YEARLY_STARTER = 'yearly-starter',
11
+ // MONTHLY_PRO = 'monthly-pro',
12
+ // YEARLY_PRO = 'yearly-pro',
13
+ AllPlans["ENTERPRISE"] = "enterprise";
14
+ AllPlans["MONTHLY_STARTER_SINGLE"] = "monthly-starter-single";
15
+ AllPlans["YEARLY_STARTER_SINGLE"] = "yearly-starter-single";
16
+ AllPlans["MONTHLY_PRO_SINGLE"] = "monthly-pro-single";
17
+ AllPlans["YEARLY_PRO_SINGLE"] = "yearly-pro-single";
18
+ })(AllPlans || (exports.AllPlans = AllPlans = {}));
4
19
  /* -------------------------------- CONSTANTS ------------------------------- */
5
20
  exports.labelColors = [
6
21
  '#9333EA',
@@ -26,3 +41,32 @@ exports.enumChatColors = [
26
41
  '#FF2E74',
27
42
  '#DB2777',
28
43
  ];
44
+ /* -------------------------- SEND MESSAGE PAYLOAD -------------------------- */
45
+ exports.SUPPORTED_TYPES = [
46
+ 'chat',
47
+ 'sticker',
48
+ 'image',
49
+ 'video',
50
+ 'document',
51
+ 'vcard',
52
+ 'multi_vcard',
53
+ 'audio',
54
+ 'ptt',
55
+ 'poll_creation',
56
+ 'location',
57
+ 'ciphertext',
58
+ ];
59
+ var IntegrationLogType;
60
+ (function (IntegrationLogType) {
61
+ IntegrationLogType["NEW_CHAT"] = "chat.created";
62
+ IntegrationLogType["NEW_CHAT_NOTIFICATION"] = "chat.notification.created";
63
+ IntegrationLogType["NEW_MESSAGE"] = "message.created";
64
+ IntegrationLogType["MESSAGE_UPDATED"] = "message.updated";
65
+ IntegrationLogType["MESSAGE_DELETED"] = "message.deleted";
66
+ IntegrationLogType["MESSAGE_ACK_UPDATED"] = "message.ack.updated";
67
+ IntegrationLogType["REACTION_CREATED"] = "reaction.created";
68
+ IntegrationLogType["REACTION_UPDATED"] = "reaction.updated";
69
+ IntegrationLogType["NEW_TICKET"] = "ticket.created";
70
+ IntegrationLogType["TICKET_UPDATED"] = "ticket.updated";
71
+ IntegrationLogType["TICKET_DELETED"] = "ticket.deleted";
72
+ })(IntegrationLogType || (exports.IntegrationLogType = IntegrationLogType = {}));
package/index.ts CHANGED
@@ -1,3 +1,3 @@
1
+ export * from './rules.types';
1
2
  export * from './supabase.types';
2
3
  export * from './types';
3
-
package/mod_json_type.ps1 CHANGED
@@ -11,5 +11,99 @@ $newTypeDefinition = 'export type Json = { [key: string]: any } | any'
11
11
  # Replace the old type definition with the new one
12
12
  $updatedContent = $fileContent -replace $oldTypeDefinition, $newTypeDefinition
13
13
 
14
+ # Update interface to type
15
+ $oldText = 'export interface Database '
16
+ $newText = 'export type Database = '
17
+
18
+ $updatedContent = $updatedContent -replace $oldText, $newText
19
+
20
+ # # Append the new type definition if it doesn't exist
21
+ # $addContent = @"
22
+ # type PublicSchema = Database[Extract<keyof Database, "public">]
23
+
24
+ # export type Tables<
25
+ # PublicTableNameOrOptions extends
26
+ # | keyof (PublicSchema["Tables"] & PublicSchema["Views"])
27
+ # | { schema: keyof Database },
28
+ # TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
29
+ # ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
30
+ # Database[PublicTableNameOrOptions["schema"]]["Views"])
31
+ # : never = never,
32
+ # > = PublicTableNameOrOptions extends { schema: keyof Database }
33
+ # ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
34
+ # Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends {
35
+ # Row: infer R
36
+ # }
37
+ # ? R
38
+ # : never
39
+ # : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] &
40
+ # PublicSchema["Views"])
41
+ # ? (PublicSchema["Tables"] &
42
+ # PublicSchema["Views"])[PublicTableNameOrOptions] extends {
43
+ # Row: infer R
44
+ # }
45
+ # ? R
46
+ # : never
47
+ # : never
48
+
49
+ # export type TablesInsert<
50
+ # PublicTableNameOrOptions extends
51
+ # | keyof PublicSchema["Tables"]
52
+ # | { schema: keyof Database },
53
+ # TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
54
+ # ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
55
+ # : never = never,
56
+ # > = PublicTableNameOrOptions extends { schema: keyof Database }
57
+ # ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
58
+ # Insert: infer I
59
+ # }
60
+ # ? I
61
+ # : never
62
+ # : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
63
+ # ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
64
+ # Insert: infer I
65
+ # }
66
+ # ? I
67
+ # : never
68
+ # : never
69
+
70
+ # export type TablesUpdate<
71
+ # PublicTableNameOrOptions extends
72
+ # | keyof PublicSchema["Tables"]
73
+ # | { schema: keyof Database },
74
+ # TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
75
+ # ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
76
+ # : never = never,
77
+ # > = PublicTableNameOrOptions extends { schema: keyof Database }
78
+ # ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
79
+ # Update: infer U
80
+ # }
81
+ # ? U
82
+ # : never
83
+ # : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
84
+ # ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
85
+ # Update: infer U
86
+ # }
87
+ # ? U
88
+ # : never
89
+ # : never
90
+
91
+ # export type Enums<
92
+ # PublicEnumNameOrOptions extends
93
+ # | keyof PublicSchema["Enums"]
94
+ # | { schema: keyof Database },
95
+ # EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
96
+ # ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"]
97
+ # : never = never,
98
+ # > = PublicEnumNameOrOptions extends { schema: keyof Database }
99
+ # ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName]
100
+ # : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"]
101
+ # ? PublicSchema["Enums"][PublicEnumNameOrOptions]
102
+ # : never
103
+ # "@
104
+
105
+ # # Append the new content to the updated content
106
+ # $updatedContent += $addContent
107
+
14
108
  # Write the updated content back to the file
15
- $updatedContent | Set-Content $filePath
109
+ $updatedContent | Set-Content $filePath
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+
3
+ # Define the path to the TypeScript file
4
+ filePath="./supabase.types.ts"
5
+
6
+ # Read the content of the file as a single string
7
+ fileContent=$(cat "$filePath")
8
+
9
+ # Define the current and new type definitions using Perl-style regular expressions
10
+ oldTypeDefinition='export type Json =\s*\| string\s*\| number\s*\| boolean\s*\| null\s*\| \{ \[key: string\]: Json \| undefined \}\s*\| Json\[\]'
11
+ newTypeDefinition='export type Json = { [key: string]: any } | any'
12
+
13
+ # Replace the old type definition with the new one
14
+ updatedContent=$(echo "$fileContent" | perl -0777 -pe "s/$oldTypeDefinition/$newTypeDefinition/g")
15
+
16
+ # Update interface to type
17
+ oldText='export interface Database '
18
+ newText='export type Database = '
19
+
20
+ updatedContent=$(echo "$updatedContent" | sed "s/$oldText/$newText/g")
21
+
22
+ # Write the updated content back to the file
23
+ echo "$updatedContent" > "$filePath"