@periskope/types 0.6.52 → 0.6.54

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/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- export * from './supabase.columns';
2
1
  export * from './supabase.types';
3
2
  export * from './types';
package/dist/index.js CHANGED
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./supabase.columns"), exports);
18
17
  __exportStar(require("./supabase.types"), exports);
19
18
  __exportStar(require("./types"), exports);
@@ -2,18 +2,17 @@ export declare const TableColumns: {
2
2
  readonly tbl_broadcast_messages: readonly ["broadcast_id", "created_at", "chat_ids", "scheduled_at", "org_id", "message_payload", "completed_at", "performed_by"];
3
3
  readonly tbl_broadcast_templates: readonly ["template_id", "created_at", "template_name", "org_id", "updated_at", "message_payload"];
4
4
  readonly tbl_chat_access: readonly ["org_id", "email", "chat_id", "has_access", "last_read_timestamp", "active_phone"];
5
- readonly tbl_chat_messages: readonly ["message_id", "org_id", "ack", "author", "body", "broadcast", "device_type", "duration", "forwarding_score", "from", "from_me", "has_media", "has_quoted_msg", "has_reaction", "id", "invite_v4", "is_ephemeral", "is_forwarded", "is_gif", "is_starred", "is_status", "links", "location", "media_key", "mentioned_ids", "order_id", "raw_data", "to", "token", "message_type", "vcards", "chat_id", "timestamp", "org_phone", "broadcast_id", "is_deleted", "media", "performed_by", "prev_body", "quoted_message_id", "sent_message_id", "delivery_info", "updated_at", "message_ticket_id"];
5
+ readonly tbl_chat_messages: readonly ["message_id", "org_id", "ack", "author", "body", "from_me", "invite_v4", "links", "location", "mentioned_ids", "message_type", "vcards", "chat_id", "timestamp", "org_phone", "broadcast_id", "is_deleted", "media", "performed_by", "prev_body", "quoted_message_id", "sender_phone", "sent_message_id", "delivery_info", "updated_at", "message_ticket_id", "unique_id", "is_gif", "is_forwarded", "is_starred"];
6
6
  readonly tbl_chat_notifications: readonly ["org_id", "notification_id", "chat_id", "author", "body", "id", "recipientids", "type", "timestamp", "org_phone"];
7
7
  readonly tbl_chat_participants: readonly ["org_id", "chat_id", "contact_id", "id", "is_admin", "is_super_admin", "org_phone"];
8
8
  readonly tbl_chat_reactions: readonly ["org_id", "message_id", "ack", "id", "orphan", "reaction", "read", "reaction_id", "timestamp", "msg_id", "orphan_reason", "sender_id", "org_phone"];
9
9
  readonly tbl_chat_tickets: readonly ["created_at", "ticket_id", "subject", "status", "assignee", "assigned_by", "chat_id", "due_date", "org_id", "label_ids", "quoted_message_id", "raised_by", "priority", "last_updated_at", "is_deleted"];
10
- readonly tbl_chats: readonly ["org_id", "chat_id", "archived", "id", "is_group", "is_muted", "is_read_only", "mute_expiration", "name", "pinned", "unread_count", "group_metadata", "chat_image", "timestamp", "invite_link", "org_phone", "label_ids", "updated_at"];
10
+ readonly tbl_chats: readonly ["org_id", "chat_id", "archived", "id", "is_group", "is_muted", "is_read_only", "mute_expiration", "name", "pinned", "unread_count", "group_metadata", "chat_image", "timestamp", "invite_link", "org_phone", "label_ids", "updated_at", "latest_message", "member_count"];
11
11
  readonly tbl_contacts: readonly ["org_id", "contact_id", "id", "number", "is_business", "is_enterprise", "name", "pushname", "short_name", "contact_type", "is_me", "is_user", "is_group", "is_wa_contact", "is_my_contact", "is_blocked", "contact_image", "contact_color", "business_profile", "verified_name", "is_internal", "label_ids", "verified_level", "updated_at"];
12
12
  readonly tbl_org: readonly ["org_id", "created_at", "org_image", "org_name", "support_link", "org_metadata", "org_plan", "stripe_customer_details", "stripe_customer_id", "stripe_subscription_details"];
13
13
  readonly tbl_org_labels: readonly ["label_id", "created_at", "org_id", "name", "color", "type"];
14
14
  readonly tbl_org_members: readonly ["created_at", "email", "user_id", "invited_at", "invited_by", "org_id", "role", "member_image", "member_name", "is_active", "member_color"];
15
15
  readonly tbl_org_phones: readonly ["org_id", "org_phone", "created_at", "updated_at", "wa_state", "phone_id", "qr_code", "phone_image", "phone_name", "server_ip"];
16
16
  readonly view_broadcast_logs: readonly ["broadcast_id", "org_id", "message_payload", "created_at", "total_chats", "sent_chats", "failed_chats", "total_member_count", "delivered_member_count", "read_member_count", "completed_at", "scheduled_at", "performed_by", "delivery_percentage", "read_percentage"];
17
- readonly view_chat_messages: readonly ["message_id", "org_id", "ack", "author", "body", "from_me", "invite_v4", "links", "location", "mentioned_ids", "message_type", "vcards", "chat_id", "timestamp", "org_phone", "broadcast_id", "is_deleted", "media", "performed_by", "prev_body", "quoted_message_id", "sender_phone", "sent_message_id", "delivery_info", "updated_at", "message_ticket_id", "unique_id", "is_gif", "is_forwarded", "is_starred"];
18
- readonly view_chats: readonly ["org_id", "chat_id", "org_phone", "chat_image", "invite_link", "label_ids", "updated_at", "chat_name", "latest_message", "message_unread_count", "member_count", "chat_type", "chat_access", "has_access", "last_read_timestamp", "chat_org_phones", "active_phone", "group_description"];
17
+ readonly view_chats: readonly ["org_id", "chat_id", "org_phone", "chat_image", "invite_link", "label_ids", "updated_at", "chat_name", "latest_message", "member_count", "chat_type", "chat_access", "has_access", "last_read_timestamp", "chat_org_phones", "active_phone", "group_description"];
19
18
  };
@@ -145,7 +145,9 @@ exports.TableColumns = {
145
145
  "invite_link",
146
146
  "org_phone",
147
147
  "label_ids",
148
- "updated_at"
148
+ "updated_at",
149
+ "latest_message",
150
+ "member_count"
149
151
  ],
150
152
  "tbl_contacts": [
151
153
  "org_id",
@@ -235,7 +237,7 @@ exports.TableColumns = {
235
237
  "delivery_percentage",
236
238
  "read_percentage"
237
239
  ],
238
- "view_chat_messages": [
240
+ "tbl_chat_messages": [
239
241
  "message_id",
240
242
  "org_id",
241
243
  "ack",
@@ -277,7 +279,6 @@ exports.TableColumns = {
277
279
  "updated_at",
278
280
  "chat_name",
279
281
  "latest_message",
280
- "message_unread_count",
281
282
  "member_count",
282
283
  "chat_type",
283
284
  "chat_access",
@@ -526,6 +526,8 @@ export interface Database {
526
526
  is_muted: boolean | null;
527
527
  is_read_only: boolean | null;
528
528
  label_ids: Json;
529
+ latest_message: Json | null;
530
+ member_count: number | null;
529
531
  mute_expiration: number | null;
530
532
  name: string | null;
531
533
  org_id: string;
@@ -546,6 +548,8 @@ export interface Database {
546
548
  is_muted?: boolean | null;
547
549
  is_read_only?: boolean | null;
548
550
  label_ids?: Json;
551
+ latest_message?: Json | null;
552
+ member_count?: number | null;
549
553
  mute_expiration?: number | null;
550
554
  name?: string | null;
551
555
  org_id: string;
@@ -566,6 +570,8 @@ export interface Database {
566
570
  is_muted?: boolean | null;
567
571
  is_read_only?: boolean | null;
568
572
  label_ids?: Json;
573
+ latest_message?: Json | null;
574
+ member_count?: number | null;
569
575
  mute_expiration?: number | null;
570
576
  name?: string | null;
571
577
  org_id?: string;
@@ -895,49 +901,6 @@ export interface Database {
895
901
  }
896
902
  ];
897
903
  };
898
- view_chat_messages: {
899
- Row: {
900
- ack: string | null;
901
- author: string | null;
902
- body: string | null;
903
- broadcast_id: string | null;
904
- chat_id: string | null;
905
- delivery_info: Json | null;
906
- from_me: boolean | null;
907
- invite_v4: Json | null;
908
- is_deleted: boolean | null;
909
- is_forwarded: boolean | null;
910
- is_gif: boolean | null;
911
- is_starred: boolean | null;
912
- links: Json | null;
913
- location: Json | null;
914
- media: Json | null;
915
- mentioned_ids: string[] | null;
916
- message_id: string | null;
917
- message_ticket_id: string | null;
918
- message_type: string | null;
919
- org_id: string | null;
920
- org_phone: string | null;
921
- performed_by: string | null;
922
- prev_body: string | null;
923
- quoted_message_id: string | null;
924
- sender_phone: string | null;
925
- sent_message_id: string | null;
926
- timestamp: string | null;
927
- unique_id: string | null;
928
- updated_at: string | null;
929
- vcards: string[] | null;
930
- };
931
- Relationships: [
932
- {
933
- foreignKeyName: "tbl_chat_messages_fkey_tbl_org_phones";
934
- columns: ["org_phone", "org_id"];
935
- isOneToOne: false;
936
- referencedRelation: "tbl_org_phones";
937
- referencedColumns: ["org_phone", "org_id"];
938
- }
939
- ];
940
- };
941
904
  view_chats: {
942
905
  Row: {
943
906
  active_phone: string | null;
@@ -954,7 +917,6 @@ export interface Database {
954
917
  last_read_timestamp: string | null;
955
918
  latest_message: Json | null;
956
919
  member_count: number | null;
957
- message_unread_count: number | null;
958
920
  org_id: string | null;
959
921
  org_phone: string | null;
960
922
  updated_at: string | null;
@@ -980,7 +942,9 @@ export interface Database {
980
942
  Returns: string;
981
943
  };
982
944
  gen_ticket_id: {
983
- Args: Record<PropertyKey, never>;
945
+ Args: {
946
+ org_id_input?: string;
947
+ };
984
948
  Returns: string;
985
949
  };
986
950
  get_broadcast_id: {
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { default as _Stripe } from "stripe";
2
- import { Merge, OverrideProperties } from "type-fest";
3
- import { Chat, Location, MessageInfo } from "whatsapp-web.js";
4
- import { Tables } from "./supabase.types";
1
+ import type { default as _Stripe } from 'stripe';
2
+ import { Merge, OverrideProperties } from 'type-fest';
3
+ import { Chat, Location, MessageInfo } from 'whatsapp-web.js';
4
+ import { Tables } from './supabase.types';
5
5
  export type WhatsappChat = Chat & {
6
6
  groupMetadata?: any;
7
7
  pinned?: boolean;
@@ -15,8 +15,17 @@ export declare enum AllPlans {
15
15
  YEARLY_PRO = "yearly-pro",
16
16
  ENTERPRISE = "enterprise"
17
17
  }
18
- export type Frequency = "yearly" | "monthly" | "weekly";
19
- export type OrgPlan = {
18
+ export type Frequency = 'yearly' | 'monthly' | 'weekly' | 'custom';
19
+ export type Enterprise = `${string}-enterprise`;
20
+ export type OrgPlanEnterprise = {
21
+ plan_id: Enterprise;
22
+ frequency: Frequency;
23
+ user_limit: number;
24
+ phone_limit: number;
25
+ current_period_start: number;
26
+ current_period_end: number | null;
27
+ };
28
+ export type OrgPlanNonEnterprise = {
20
29
  plan_id: AllPlans;
21
30
  interval: number;
22
31
  frequency: Frequency;
@@ -24,23 +33,24 @@ export type OrgPlan = {
24
33
  phone_limit: number;
25
34
  percent_off: number | null;
26
35
  };
27
- export type OrgType = OverrideProperties<Tables<"tbl_org"> & {
28
- user: Tables<"tbl_org_members">;
29
- members: Tables<"tbl_org_members">[];
30
- phones: Tables<"tbl_org_phones">[];
31
- labels: Tables<"tbl_org_labels">[];
36
+ export type OrgPlan<T extends AllPlans | Enterprise> = T extends Enterprise ? OrgPlanEnterprise : T extends AllPlans ? OrgPlanNonEnterprise : never;
37
+ export type OrgType = OverrideProperties<Tables<'tbl_org'> & {
38
+ user: Tables<'tbl_org_members'>;
39
+ members: Tables<'tbl_org_members'>[];
40
+ phones: Tables<'tbl_org_phones'>[];
41
+ labels: Tables<'tbl_org_labels'>[];
32
42
  }, {
33
- org_plan: OrgPlan;
43
+ org_plan: OrgPlan<AllPlans | Enterprise>;
34
44
  stripe_customer_details: _Stripe.Customer | null;
35
45
  stripe_subscription_details: Array<_Stripe.Subscription> | null;
36
- stripe_customer_id: _Stripe.Customer["id"] | null;
46
+ stripe_customer_id: _Stripe.Customer['id'] | null;
37
47
  }>;
38
- export type ChatMemberType = Merge<Tables<"tbl_chat_participants">, Tables<"tbl_contacts">>;
39
- export type ChatType = Merge<Tables<"view_chats">, {
48
+ export type ChatMemberType = Merge<Tables<'tbl_chat_participants'>, Tables<'tbl_contacts'>>;
49
+ export type ChatType = Merge<Tables<'view_chats'>, {
40
50
  chat_id: string;
41
51
  latest_message: MessageType | null;
42
52
  members: Record<string, ChatMemberType> | null;
43
- chat_type: "user" | "group" | "business" | "unknown";
53
+ chat_type: 'user' | 'group' | 'business' | 'unknown';
44
54
  chat_access: Record<string, boolean>;
45
55
  label_ids: Record<string, boolean>;
46
56
  chat_org_phones?: string[];
@@ -57,7 +67,7 @@ export type MediaType = {
57
67
  };
58
68
  size?: number;
59
69
  };
60
- export type MessageType = OverrideProperties<Tables<"view_chat_messages">, {
70
+ export type MessageType = OverrideProperties<Tables<'tbl_chat_messages'>, {
61
71
  message_id: string;
62
72
  org_id: string;
63
73
  org_phone: string;
@@ -65,15 +75,15 @@ export type MessageType = OverrideProperties<Tables<"view_chat_messages">, {
65
75
  message_type: (typeof SUPPORTED_TYPES)[number];
66
76
  media: MediaType | null;
67
77
  }>;
68
- export type TicketType = OverrideProperties<Tables<"tbl_chat_tickets">, {
78
+ export type TicketType = OverrideProperties<Tables<'tbl_chat_tickets'>, {
69
79
  label_ids: Record<string, boolean>;
70
80
  }>;
71
- export type ContactType = Merge<Tables<"tbl_contacts">, {
81
+ export type ContactType = Merge<Tables<'tbl_contacts'>, {
72
82
  chats: ChatType[] | null;
73
83
  }>;
74
- export type ReactionType = Tables<"tbl_chat_reactions">;
75
- export type NotificationType = Tables<"tbl_chat_notifications">;
76
- export type ChatAccessType = Merge<Partial<Tables<"tbl_chat_access">>, Tables<"tbl_org_members">>;
84
+ export type ReactionType = Tables<'tbl_chat_reactions'>;
85
+ export type NotificationType = Tables<'tbl_chat_notifications'>;
86
+ export type ChatAccessType = Merge<Partial<Tables<'tbl_chat_access'>>, Tables<'tbl_org_members'>>;
77
87
  export declare const labelColors: string[];
78
88
  export declare const enumChatColors: readonly ["#B4876E", "#A5B337", "#06CF9C", "#25D366", "#02A698", "#7D9EF1", "#007BFC", "#5E47DE", "#7F66FF", "#9333EA", "#FA6533", "#C4532D", "#DC2626", "#FF2E74", "#DB2777"];
79
89
  export declare const SUPPORTED_TYPES: readonly ["chat", "sticker", "image", "video", "document", "vcard", "multi_vcard", "audio", "ptt", "poll_creation"];
@@ -84,7 +94,7 @@ export type SendMessageContent = {
84
94
  contact_ids?: string[];
85
95
  location?: Location;
86
96
  quoted_message_id?: string;
87
- quoted_message_type?: "reply" | "forward" | "reply_private";
97
+ quoted_message_type?: 'reply' | 'forward' | 'reply_private';
88
98
  broadcast_id?: string;
89
99
  performed_by?: string;
90
100
  variables?: Record<string, VariableType>;
@@ -101,7 +111,7 @@ export type SingleMessagePayload = SendMessageContent & {
101
111
  export type AttachmentTypeProps = {
102
112
  result: string;
103
113
  file: File | null;
104
- type: "image" | "audio" | "document" | "video";
114
+ type: 'image' | 'audio' | 'document' | 'video';
105
115
  };
106
116
  export type LogsType = {
107
117
  chat_id: string | null;
@@ -113,12 +123,12 @@ export type LogsType = {
113
123
  members: Partial<ChatMemberType>[];
114
124
  member_count: number | null;
115
125
  };
116
- export type BroadcastLogType = Tables<"view_broadcast_logs"> & {
126
+ export type BroadcastLogType = Tables<'view_broadcast_logs'> & {
117
127
  logs: (LogsType & ChatType)[];
118
128
  };
119
129
  export type ChatParticipantOperation = {
120
130
  participant_ids: string[];
121
- operation_type: "ADD" | "REMOVE" | "PROMOTE" | "DEMOTE";
131
+ operation_type: 'ADD' | 'REMOVE' | 'PROMOTE' | 'DEMOTE';
122
132
  };
123
133
  export type ChatParticipantOperationPayload = ChatParticipantOperation & {
124
134
  chat_ids: string[];
package/dist/types.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SUPPORTED_TYPES = exports.enumChatColors = exports.labelColors = exports.AllPlans = void 0;
4
4
  /* ------------------------------ PERISKOPE TYPES ------------------------------ */
5
- // TODO - @rbkayz - Need to update these types to unpkg and remove type OrgPlanType from hooks.helpers.ts:24 and import this there
6
5
  var AllPlans;
7
6
  (function (AllPlans) {
8
7
  AllPlans["FREE_TRIAL"] = "free-trial";
@@ -14,39 +13,39 @@ var AllPlans;
14
13
  })(AllPlans || (exports.AllPlans = AllPlans = {}));
15
14
  /* -------------------------------- CONSTANTS ------------------------------- */
16
15
  exports.labelColors = [
17
- "#9333EA",
18
- "#0D9488",
19
- "#DB2777",
20
- "#2563EB",
21
- "#F97316",
16
+ '#9333EA',
17
+ '#0D9488',
18
+ '#DB2777',
19
+ '#2563EB',
20
+ '#F97316',
22
21
  ];
23
22
  exports.enumChatColors = [
24
- "#B4876E",
25
- "#A5B337",
26
- "#06CF9C",
27
- "#25D366",
28
- "#02A698",
29
- "#7D9EF1",
30
- "#007BFC",
31
- "#5E47DE",
32
- "#7F66FF",
33
- "#9333EA",
34
- "#FA6533",
35
- "#C4532D",
36
- "#DC2626",
37
- "#FF2E74",
38
- "#DB2777",
23
+ '#B4876E',
24
+ '#A5B337',
25
+ '#06CF9C',
26
+ '#25D366',
27
+ '#02A698',
28
+ '#7D9EF1',
29
+ '#007BFC',
30
+ '#5E47DE',
31
+ '#7F66FF',
32
+ '#9333EA',
33
+ '#FA6533',
34
+ '#C4532D',
35
+ '#DC2626',
36
+ '#FF2E74',
37
+ '#DB2777',
39
38
  ];
40
39
  /* -------------------------- SEND MESSAGE PAYLOAD -------------------------- */
41
40
  exports.SUPPORTED_TYPES = [
42
- "chat",
43
- "sticker",
44
- "image",
45
- "video",
46
- "document",
47
- "vcard",
48
- "multi_vcard",
49
- "audio",
50
- "ptt",
51
- "poll_creation",
41
+ 'chat',
42
+ 'sticker',
43
+ 'image',
44
+ 'video',
45
+ 'document',
46
+ 'vcard',
47
+ 'multi_vcard',
48
+ 'audio',
49
+ 'ptt',
50
+ 'poll_creation',
52
51
  ];
package/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './supabase.columns';
2
1
  export * from './supabase.types';
3
2
  export * from './types';
4
3
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@periskope/types",
3
- "version": "0.6.52",
3
+ "version": "0.6.54",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,6 +13,6 @@
13
13
  "whatsapp-web.js": "1.23.1-alpha.4"
14
14
  },
15
15
  "scripts": {
16
- "update-package": "node scripts/extractColumnNames.js \u0026\u0026 tsc \u0026\u0026 npm publish --access public"
16
+ "update-package": "tsc \u0026\u0026 npm publish --access public"
17
17
  }
18
18
  }
package/supabase.types.ts CHANGED
@@ -529,6 +529,8 @@ export interface Database {
529
529
  is_muted: boolean | null
530
530
  is_read_only: boolean | null
531
531
  label_ids: Json
532
+ latest_message: Json | null
533
+ member_count: number | null
532
534
  mute_expiration: number | null
533
535
  name: string | null
534
536
  org_id: string
@@ -549,6 +551,8 @@ export interface Database {
549
551
  is_muted?: boolean | null
550
552
  is_read_only?: boolean | null
551
553
  label_ids?: Json
554
+ latest_message?: Json | null
555
+ member_count?: number | null
552
556
  mute_expiration?: number | null
553
557
  name?: string | null
554
558
  org_id: string
@@ -569,6 +573,8 @@ export interface Database {
569
573
  is_muted?: boolean | null
570
574
  is_read_only?: boolean | null
571
575
  label_ids?: Json
576
+ latest_message?: Json | null
577
+ member_count?: number | null
572
578
  mute_expiration?: number | null
573
579
  name?: string | null
574
580
  org_id?: string
@@ -898,49 +904,6 @@ export interface Database {
898
904
  }
899
905
  ]
900
906
  }
901
- view_chat_messages: {
902
- Row: {
903
- ack: string | null
904
- author: string | null
905
- body: string | null
906
- broadcast_id: string | null
907
- chat_id: string | null
908
- delivery_info: Json | null
909
- from_me: boolean | null
910
- invite_v4: Json | null
911
- is_deleted: boolean | null
912
- is_forwarded: boolean | null
913
- is_gif: boolean | null
914
- is_starred: boolean | null
915
- links: Json | null
916
- location: Json | null
917
- media: Json | null
918
- mentioned_ids: string[] | null
919
- message_id: string | null
920
- message_ticket_id: string | null
921
- message_type: string | null
922
- org_id: string | null
923
- org_phone: string | null
924
- performed_by: string | null
925
- prev_body: string | null
926
- quoted_message_id: string | null
927
- sender_phone: string | null
928
- sent_message_id: string | null
929
- timestamp: string | null
930
- unique_id: string | null
931
- updated_at: string | null
932
- vcards: string[] | null
933
- }
934
- Relationships: [
935
- {
936
- foreignKeyName: "tbl_chat_messages_fkey_tbl_org_phones"
937
- columns: ["org_phone", "org_id"]
938
- isOneToOne: false
939
- referencedRelation: "tbl_org_phones"
940
- referencedColumns: ["org_phone", "org_id"]
941
- }
942
- ]
943
- }
944
907
  view_chats: {
945
908
  Row: {
946
909
  active_phone: string | null
@@ -957,7 +920,6 @@ export interface Database {
957
920
  last_read_timestamp: string | null
958
921
  latest_message: Json | null
959
922
  member_count: number | null
960
- message_unread_count: number | null
961
923
  org_id: string | null
962
924
  org_phone: string | null
963
925
  updated_at: string | null
@@ -983,7 +945,9 @@ export interface Database {
983
945
  Returns: string
984
946
  }
985
947
  gen_ticket_id: {
986
- Args: Record<PropertyKey, never>
948
+ Args: {
949
+ org_id_input?: string
950
+ }
987
951
  Returns: string
988
952
  }
989
953
  get_broadcast_id: {
package/types.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { default as _Stripe } from "stripe";
2
- import { Merge, OverrideProperties } from "type-fest";
3
- import { Chat, Location, MessageInfo } from "whatsapp-web.js";
4
- import { Tables } from "./supabase.types";
1
+ import type { default as _Stripe } from 'stripe';
2
+ import { Merge, OverrideProperties } from 'type-fest';
3
+ import { Chat, Location, MessageInfo } from 'whatsapp-web.js';
4
+ import { Tables } from './supabase.types';
5
5
 
6
6
  /* ----------------------------- TYPE SHORTHANDS ---------------------------- */
7
7
 
@@ -15,20 +15,29 @@ export type WhatsappChat = Chat & {
15
15
 
16
16
  /* ------------------------------ PERISKOPE TYPES ------------------------------ */
17
17
 
18
- // TODO - @rbkayz - Need to update these types to unpkg and remove type OrgPlanType from hooks.helpers.ts:24 and import this there
19
-
20
18
  export enum AllPlans {
21
- FREE_TRIAL = "free-trial",
22
- MONTHLY_STARTER = "monthly-starter",
23
- YEARLY_STARTER = "yearly-starter",
24
- MONTHLY_PRO = "monthly-pro",
25
- YEARLY_PRO = "yearly-pro",
26
- ENTERPRISE = "enterprise",
19
+ FREE_TRIAL = 'free-trial',
20
+ MONTHLY_STARTER = 'monthly-starter',
21
+ YEARLY_STARTER = 'yearly-starter',
22
+ MONTHLY_PRO = 'monthly-pro',
23
+ YEARLY_PRO = 'yearly-pro',
24
+ ENTERPRISE = 'enterprise',
27
25
  }
28
26
 
29
- export type Frequency = "yearly" | "monthly" | "weekly";
27
+ export type Frequency = 'yearly' | 'monthly' | 'weekly' | 'custom';
28
+
29
+ export type Enterprise = `${string}-enterprise`;
30
+
31
+ export type OrgPlanEnterprise = {
32
+ plan_id: Enterprise;
33
+ frequency: Frequency;
34
+ user_limit: number;
35
+ phone_limit: number;
36
+ current_period_start: number;
37
+ current_period_end: number | null;
38
+ };
30
39
 
31
- export type OrgPlan = {
40
+ export type OrgPlanNonEnterprise = {
32
41
  plan_id: AllPlans;
33
42
  interval: number;
34
43
  frequency: Frequency;
@@ -37,33 +46,39 @@ export type OrgPlan = {
37
46
  percent_off: number | null;
38
47
  };
39
48
 
49
+ export type OrgPlan<T extends AllPlans | Enterprise> = T extends Enterprise
50
+ ? OrgPlanEnterprise
51
+ : T extends AllPlans
52
+ ? OrgPlanNonEnterprise
53
+ : never;
54
+
40
55
  export type OrgType = OverrideProperties<
41
- Tables<"tbl_org"> & {
42
- user: Tables<"tbl_org_members">;
43
- members: Tables<"tbl_org_members">[];
44
- phones: Tables<"tbl_org_phones">[];
45
- labels: Tables<"tbl_org_labels">[];
56
+ Tables<'tbl_org'> & {
57
+ user: Tables<'tbl_org_members'>;
58
+ members: Tables<'tbl_org_members'>[];
59
+ phones: Tables<'tbl_org_phones'>[];
60
+ labels: Tables<'tbl_org_labels'>[];
46
61
  },
47
62
  {
48
- org_plan: OrgPlan;
63
+ org_plan: OrgPlan<AllPlans | Enterprise>;
49
64
  stripe_customer_details: _Stripe.Customer | null;
50
65
  stripe_subscription_details: Array<_Stripe.Subscription> | null;
51
- stripe_customer_id: _Stripe.Customer["id"] | null;
66
+ stripe_customer_id: _Stripe.Customer['id'] | null;
52
67
  }
53
68
  >;
54
69
 
55
70
  export type ChatMemberType = Merge<
56
- Tables<"tbl_chat_participants">,
57
- Tables<"tbl_contacts">
71
+ Tables<'tbl_chat_participants'>,
72
+ Tables<'tbl_contacts'>
58
73
  >;
59
74
 
60
75
  export type ChatType = Merge<
61
- Tables<"view_chats">,
76
+ Tables<'view_chats'>,
62
77
  {
63
78
  chat_id: string;
64
79
  latest_message: MessageType | null;
65
80
  members: Record<string, ChatMemberType> | null;
66
- chat_type: "user" | "group" | "business" | "unknown";
81
+ chat_type: 'user' | 'group' | 'business' | 'unknown';
67
82
  chat_access: Record<string, boolean>;
68
83
  label_ids: Record<string, boolean>;
69
84
  chat_org_phones?: string[];
@@ -80,7 +95,7 @@ export type MediaType = {
80
95
  };
81
96
 
82
97
  export type MessageType = OverrideProperties<
83
- Tables<"view_chat_messages">,
98
+ Tables<'tbl_chat_messages'>,
84
99
  {
85
100
  message_id: string;
86
101
  org_id: string;
@@ -91,67 +106,67 @@ export type MessageType = OverrideProperties<
91
106
  }
92
107
  >;
93
108
  export type TicketType = OverrideProperties<
94
- Tables<"tbl_chat_tickets">,
109
+ Tables<'tbl_chat_tickets'>,
95
110
  {
96
111
  label_ids: Record<string, boolean>;
97
112
  }
98
113
  >;
99
114
  export type ContactType = Merge<
100
- Tables<"tbl_contacts">,
115
+ Tables<'tbl_contacts'>,
101
116
  {
102
117
  chats: ChatType[] | null;
103
118
  }
104
119
  >;
105
- export type ReactionType = Tables<"tbl_chat_reactions">;
120
+ export type ReactionType = Tables<'tbl_chat_reactions'>;
106
121
 
107
- export type NotificationType = Tables<"tbl_chat_notifications">;
122
+ export type NotificationType = Tables<'tbl_chat_notifications'>;
108
123
 
109
124
  export type ChatAccessType = Merge<
110
- Partial<Tables<"tbl_chat_access">>,
111
- Tables<"tbl_org_members">
125
+ Partial<Tables<'tbl_chat_access'>>,
126
+ Tables<'tbl_org_members'>
112
127
  >;
113
128
 
114
129
  /* -------------------------------- CONSTANTS ------------------------------- */
115
130
 
116
131
  export const labelColors = [
117
- "#9333EA",
118
- "#0D9488",
119
- "#DB2777",
120
- "#2563EB",
121
- "#F97316",
132
+ '#9333EA',
133
+ '#0D9488',
134
+ '#DB2777',
135
+ '#2563EB',
136
+ '#F97316',
122
137
  ];
123
138
 
124
139
  export const enumChatColors = [
125
- "#B4876E",
126
- "#A5B337",
127
- "#06CF9C",
128
- "#25D366",
129
- "#02A698",
130
- "#7D9EF1",
131
- "#007BFC",
132
- "#5E47DE",
133
- "#7F66FF",
134
- "#9333EA",
135
- "#FA6533",
136
- "#C4532D",
137
- "#DC2626",
138
- "#FF2E74",
139
- "#DB2777",
140
+ '#B4876E',
141
+ '#A5B337',
142
+ '#06CF9C',
143
+ '#25D366',
144
+ '#02A698',
145
+ '#7D9EF1',
146
+ '#007BFC',
147
+ '#5E47DE',
148
+ '#7F66FF',
149
+ '#9333EA',
150
+ '#FA6533',
151
+ '#C4532D',
152
+ '#DC2626',
153
+ '#FF2E74',
154
+ '#DB2777',
140
155
  ] as const;
141
156
 
142
157
  /* -------------------------- SEND MESSAGE PAYLOAD -------------------------- */
143
158
 
144
159
  export const SUPPORTED_TYPES = [
145
- "chat",
146
- "sticker",
147
- "image",
148
- "video",
149
- "document",
150
- "vcard",
151
- "multi_vcard",
152
- "audio",
153
- "ptt",
154
- "poll_creation",
160
+ 'chat',
161
+ 'sticker',
162
+ 'image',
163
+ 'video',
164
+ 'document',
165
+ 'vcard',
166
+ 'multi_vcard',
167
+ 'audio',
168
+ 'ptt',
169
+ 'poll_creation',
155
170
  ] as const;
156
171
 
157
172
  export type SendMessageContent = {
@@ -161,7 +176,7 @@ export type SendMessageContent = {
161
176
  contact_ids?: string[];
162
177
  location?: Location;
163
178
  quoted_message_id?: string;
164
- quoted_message_type?: "reply" | "forward" | "reply_private";
179
+ quoted_message_type?: 'reply' | 'forward' | 'reply_private';
165
180
  broadcast_id?: string;
166
181
  performed_by?: string;
167
182
  variables?: Record<string, VariableType>;
@@ -182,7 +197,7 @@ export type SingleMessagePayload = SendMessageContent & {
182
197
  export type AttachmentTypeProps = {
183
198
  result: string;
184
199
  file: File | null;
185
- type: "image" | "audio" | "document" | "video";
200
+ type: 'image' | 'audio' | 'document' | 'video';
186
201
  };
187
202
 
188
203
  /* -------------------------------- BROADCAST ------------------------------- */
@@ -198,7 +213,7 @@ export type LogsType = {
198
213
  member_count: number | null;
199
214
  };
200
215
 
201
- export type BroadcastLogType = Tables<"view_broadcast_logs"> & {
216
+ export type BroadcastLogType = Tables<'view_broadcast_logs'> & {
202
217
  logs: (LogsType & ChatType)[];
203
218
  };
204
219
 
@@ -206,7 +221,7 @@ export type BroadcastLogType = Tables<"view_broadcast_logs"> & {
206
221
 
207
222
  export type ChatParticipantOperation = {
208
223
  participant_ids: string[];
209
- operation_type: "ADD" | "REMOVE" | "PROMOTE" | "DEMOTE";
224
+ operation_type: 'ADD' | 'REMOVE' | 'PROMOTE' | 'DEMOTE';
210
225
  };
211
226
 
212
227
  export type ChatParticipantOperationPayload = ChatParticipantOperation & {
@@ -231,4 +246,4 @@ export type PhoneRealtimeChannel = {
231
246
  message?: string;
232
247
  error?: string;
233
248
  presence_ref?: string;
234
- }
249
+ };
@@ -1,55 +0,0 @@
1
- const { Pool } = require('pg');
2
- const fs = require('fs');
3
-
4
- const SUPABASE_DB_URL =
5
- 'postgresql://postgres:postgres@localhost:54322/postgres';
6
- const pool = new Pool({
7
- connectionString: SUPABASE_DB_URL,
8
- });
9
- const outputFile = './supabase.columns.ts';
10
-
11
- async function fetchNonGeneratedColumns() {
12
- const query = `
13
- SELECT
14
- table_name,
15
- array_agg(column_name ORDER BY ordinal_position) AS non_generated_columns
16
- FROM
17
- information_schema.columns
18
- WHERE
19
- table_schema = 'public' -- Adjust this to your schema
20
- AND is_generated = 'NEVER'
21
- GROUP BY
22
- table_name;
23
- `;
24
-
25
- try {
26
- const res = await pool.query(query);
27
- return res.rows; // Each row will have `table_name` and `non_generated_columns`
28
- } catch (err) {
29
- console.error('Error fetching non-generated columns:', err);
30
- throw err;
31
- }
32
- }
33
-
34
- fetchNonGeneratedColumns().then((tables) => {
35
- const tableColumns = tables.reduce(
36
- (acc, { table_name, non_generated_columns }) => {
37
- const columns = non_generated_columns
38
- .slice(1, -1) // Remove the curly braces
39
- .split(',') // Split by comma to get individual column names
40
- .map((column) => column.trim()); // Trim any whitespace around column names
41
-
42
- acc[table_name] = columns;
43
- return acc;
44
- },
45
- {}
46
- );
47
-
48
- const tsContent = `export const TableColumns = ${JSON.stringify(
49
- tableColumns,
50
- null,
51
- 2
52
- )} as const;`;
53
-
54
- fs.writeFileSync(outputFile, tsContent, 'utf8'); // Write the TS content to file
55
- });
@@ -1,287 +0,0 @@
1
- export const TableColumns = {
2
- "tbl_broadcast_messages": [
3
- "broadcast_id",
4
- "created_at",
5
- "chat_ids",
6
- "scheduled_at",
7
- "org_id",
8
- "message_payload",
9
- "completed_at",
10
- "performed_by"
11
- ],
12
- "tbl_broadcast_templates": [
13
- "template_id",
14
- "created_at",
15
- "template_name",
16
- "org_id",
17
- "updated_at",
18
- "message_payload"
19
- ],
20
- "tbl_chat_access": [
21
- "org_id",
22
- "email",
23
- "chat_id",
24
- "has_access",
25
- "last_read_timestamp",
26
- "active_phone"
27
- ],
28
- "tbl_chat_messages": [
29
- "message_id",
30
- "org_id",
31
- "ack",
32
- "author",
33
- "body",
34
- "broadcast",
35
- "device_type",
36
- "duration",
37
- "forwarding_score",
38
- "from",
39
- "from_me",
40
- "has_media",
41
- "has_quoted_msg",
42
- "has_reaction",
43
- "id",
44
- "invite_v4",
45
- "is_ephemeral",
46
- "is_forwarded",
47
- "is_gif",
48
- "is_starred",
49
- "is_status",
50
- "links",
51
- "location",
52
- "media_key",
53
- "mentioned_ids",
54
- "order_id",
55
- "raw_data",
56
- "to",
57
- "token",
58
- "message_type",
59
- "vcards",
60
- "chat_id",
61
- "timestamp",
62
- "org_phone",
63
- "broadcast_id",
64
- "is_deleted",
65
- "media",
66
- "performed_by",
67
- "prev_body",
68
- "quoted_message_id",
69
- "sent_message_id",
70
- "delivery_info",
71
- "updated_at",
72
- "message_ticket_id"
73
- ],
74
- "tbl_chat_notifications": [
75
- "org_id",
76
- "notification_id",
77
- "chat_id",
78
- "author",
79
- "body",
80
- "id",
81
- "recipientids",
82
- "type",
83
- "timestamp",
84
- "org_phone"
85
- ],
86
- "tbl_chat_participants": [
87
- "org_id",
88
- "chat_id",
89
- "contact_id",
90
- "id",
91
- "is_admin",
92
- "is_super_admin",
93
- "org_phone"
94
- ],
95
- "tbl_chat_reactions": [
96
- "org_id",
97
- "message_id",
98
- "ack",
99
- "id",
100
- "orphan",
101
- "reaction",
102
- "read",
103
- "reaction_id",
104
- "timestamp",
105
- "msg_id",
106
- "orphan_reason",
107
- "sender_id",
108
- "org_phone"
109
- ],
110
- "tbl_chat_tickets": [
111
- "created_at",
112
- "ticket_id",
113
- "subject",
114
- "status",
115
- "assignee",
116
- "assigned_by",
117
- "chat_id",
118
- "due_date",
119
- "org_id",
120
- "label_ids",
121
- "quoted_message_id",
122
- "raised_by",
123
- "priority",
124
- "last_updated_at",
125
- "is_deleted"
126
- ],
127
- "tbl_chats": [
128
- "org_id",
129
- "chat_id",
130
- "archived",
131
- "id",
132
- "is_group",
133
- "is_muted",
134
- "is_read_only",
135
- "mute_expiration",
136
- "name",
137
- "pinned",
138
- "unread_count",
139
- "group_metadata",
140
- "chat_image",
141
- "timestamp",
142
- "invite_link",
143
- "org_phone",
144
- "label_ids",
145
- "updated_at"
146
- ],
147
- "tbl_contacts": [
148
- "org_id",
149
- "contact_id",
150
- "id",
151
- "number",
152
- "is_business",
153
- "is_enterprise",
154
- "name",
155
- "pushname",
156
- "short_name",
157
- "contact_type",
158
- "is_me",
159
- "is_user",
160
- "is_group",
161
- "is_wa_contact",
162
- "is_my_contact",
163
- "is_blocked",
164
- "contact_image",
165
- "contact_color",
166
- "business_profile",
167
- "verified_name",
168
- "is_internal",
169
- "label_ids",
170
- "verified_level",
171
- "updated_at"
172
- ],
173
- "tbl_org": [
174
- "org_id",
175
- "created_at",
176
- "org_image",
177
- "org_name",
178
- "support_link",
179
- "org_metadata",
180
- "org_plan",
181
- "stripe_customer_details",
182
- "stripe_customer_id",
183
- "stripe_subscription_details"
184
- ],
185
- "tbl_org_labels": [
186
- "label_id",
187
- "created_at",
188
- "org_id",
189
- "name",
190
- "color",
191
- "type"
192
- ],
193
- "tbl_org_members": [
194
- "created_at",
195
- "email",
196
- "user_id",
197
- "invited_at",
198
- "invited_by",
199
- "org_id",
200
- "role",
201
- "member_image",
202
- "member_name",
203
- "is_active",
204
- "member_color"
205
- ],
206
- "tbl_org_phones": [
207
- "org_id",
208
- "org_phone",
209
- "created_at",
210
- "updated_at",
211
- "wa_state",
212
- "phone_id",
213
- "qr_code",
214
- "phone_image",
215
- "phone_name",
216
- "server_ip"
217
- ],
218
- "view_broadcast_logs": [
219
- "broadcast_id",
220
- "org_id",
221
- "message_payload",
222
- "created_at",
223
- "total_chats",
224
- "sent_chats",
225
- "failed_chats",
226
- "total_member_count",
227
- "delivered_member_count",
228
- "read_member_count",
229
- "completed_at",
230
- "scheduled_at",
231
- "performed_by",
232
- "delivery_percentage",
233
- "read_percentage"
234
- ],
235
- "view_chat_messages": [
236
- "message_id",
237
- "org_id",
238
- "ack",
239
- "author",
240
- "body",
241
- "from_me",
242
- "invite_v4",
243
- "links",
244
- "location",
245
- "mentioned_ids",
246
- "message_type",
247
- "vcards",
248
- "chat_id",
249
- "timestamp",
250
- "org_phone",
251
- "broadcast_id",
252
- "is_deleted",
253
- "media",
254
- "performed_by",
255
- "prev_body",
256
- "quoted_message_id",
257
- "sender_phone",
258
- "sent_message_id",
259
- "delivery_info",
260
- "updated_at",
261
- "message_ticket_id",
262
- "unique_id",
263
- "is_gif",
264
- "is_forwarded",
265
- "is_starred"
266
- ],
267
- "view_chats": [
268
- "org_id",
269
- "chat_id",
270
- "org_phone",
271
- "chat_image",
272
- "invite_link",
273
- "label_ids",
274
- "updated_at",
275
- "chat_name",
276
- "latest_message",
277
- "message_unread_count",
278
- "member_count",
279
- "chat_type",
280
- "chat_access",
281
- "has_access",
282
- "last_read_timestamp",
283
- "chat_org_phones",
284
- "active_phone",
285
- "group_description"
286
- ]
287
- } as const;