@periskope/types 0.6.75 → 0.6.77

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/types.ts CHANGED
@@ -52,6 +52,21 @@ export type OrgPlan<T extends AllPlans | Enterprise> = T extends Enterprise
52
52
  ? OrgPlanNonEnterprise
53
53
  : never;
54
54
 
55
+ export type MicrosurveyData = {
56
+ key: string;
57
+ text: string;
58
+ checked: boolean;
59
+ }[];
60
+
61
+ export type OrgMetadata = {
62
+ phone_number: string;
63
+ ticket_prefix: string;
64
+ referralSource?: string;
65
+ surveyData?: MicrosurveyData;
66
+ onboarding: Record<string, boolean>;
67
+ onboarding_completed_at: Date | null;
68
+ };
69
+
55
70
  export type OrgType = OverrideProperties<
56
71
  Merge<
57
72
  Tables<'tbl_org'>,
@@ -72,6 +87,7 @@ export type OrgType = OverrideProperties<
72
87
  stripe_customer_details: _Stripe.Customer | null;
73
88
  stripe_subscription_details: Array<_Stripe.Subscription> | null;
74
89
  stripe_customer_id: _Stripe.Customer['id'] | null;
90
+ org_metadata: OrgMetadata;
75
91
  }
76
92
  >;
77
93
 
@@ -267,28 +283,82 @@ export type PhoneStateType = {
267
283
  };
268
284
 
269
285
  /* ------------------------------- INTEGRATIONS ----------------------------- */
270
-
271
- export type TicketLogType = OverrideProperties<
272
- Tables<'tbl_integration_logs'>,
273
- {
274
- integration_name: IntegrationLogType.NEW_TICKET;
275
- metadata: {
276
- ticket_id: string;
277
- name: string;
278
- };
279
- }
280
- >;
281
-
282
- export type IntegrationLogDetailsType = TicketLogType;
286
+ export type TicketInfoType = {
287
+ chat: {
288
+ chat_id: string;
289
+ chat_name: string;
290
+ chat_image: string;
291
+ chat_labels: string;
292
+ [key: string]: string;
293
+ };
294
+ message: {
295
+ text: string;
296
+ timestamp: string;
297
+ message_id: string;
298
+ sender_phone: string;
299
+ };
300
+ ticket: {
301
+ ticket_labels: string;
302
+ status: string;
303
+ subject: string;
304
+ assignee: string;
305
+ due_date: string;
306
+ priority: 0 | 1 | 2 | 3 | 4;
307
+ raised_by: string;
308
+ ticket_id: string;
309
+ created_at: string;
310
+ };
311
+ };
283
312
 
284
313
  export enum IntegrationLogType {
314
+ NEW_CHAT = 'chat.created',
315
+ NEW_MESSAGE = 'message.created',
316
+ MESSAGE_UPDATED = 'message.updated',
317
+ MESSAGE_ACK_UPDATED = 'message.ack.updated',
318
+ REACTION_CREATED = 'reaction.created',
319
+ REACTION_UPDATED = 'reaction.updated',
320
+ REACTION_DELETED = 'reaction.deleted',
285
321
  NEW_TICKET = 'ticket.created',
322
+ TICKET_UPDATED = 'ticket.updated',
286
323
  }
287
324
 
288
- export type LogTypeMap<T extends IntegrationLogType> =
289
- T extends IntegrationLogType.NEW_TICKET
290
- ? TicketLogType
291
- : Tables<'tbl_integration_logs'>;
325
+ export type IntegrationLogMetadataType<T extends IntegrationLogType> =
326
+ T extends IntegrationLogType.NEW_TICKET | IntegrationLogType.TICKET_UPDATED
327
+ ? TicketInfoType
328
+ : T extends IntegrationLogType.NEW_CHAT
329
+ ? Tables<'tbl_chats'>
330
+ : T extends
331
+ | IntegrationLogType.NEW_MESSAGE
332
+ | IntegrationLogType.MESSAGE_UPDATED
333
+ | IntegrationLogType.MESSAGE_ACK_UPDATED
334
+ ? Tables<'tbl_chat_messages'>
335
+ : T extends
336
+ | IntegrationLogType.REACTION_CREATED
337
+ | IntegrationLogType.REACTION_UPDATED
338
+ | IntegrationLogType.REACTION_DELETED
339
+ ? Tables<'tbl_chat_reactions'>
340
+ : {
341
+ [key: string]: unknown;
342
+ };
343
+
344
+ export type IntegrationLogDetailsType<T extends IntegrationLogType> =
345
+ OverrideProperties<
346
+ Tables<'tbl_integration_logs'>,
347
+ {
348
+ integration_name: T;
349
+ metadata: {
350
+ event: IntegrationLogMetadataType<T> & {
351
+ event_type: string;
352
+ org_id: string;
353
+ previous_attributes: {
354
+ [key: string]: unknown;
355
+ };
356
+ };
357
+ hook_id: string;
358
+ name: string;
359
+ };
360
+ }
361
+ >;
292
362
 
293
363
  export type APIAuthDetails = {
294
364
  org_details: Tables<'view_org'> | null;