@periskope/types 0.6.16 → 0.6.18

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.
@@ -29,90 +29,71 @@ export interface Database {
29
29
  };
30
30
  public: {
31
31
  Tables: {
32
- tbl_broadcast_scheduled_messages: {
32
+ tbl_broadcast_messages: {
33
33
  Row: {
34
- added_by: string | null;
35
- chat_ids: Json | null;
34
+ broadcast_id: string;
35
+ chat_ids: string[] | null;
36
36
  created_at: string;
37
37
  message_payload: Json | null;
38
- org_id: string | null;
38
+ org_id: string;
39
39
  scheduled_at: string | null;
40
- scheduled_message_id: string;
40
+ sent_by: string | null;
41
41
  status: string | null;
42
- template_id: string | null;
43
42
  };
44
43
  Insert: {
45
- added_by?: string | null;
46
- chat_ids?: Json | null;
44
+ broadcast_id?: string;
45
+ chat_ids?: string[] | null;
47
46
  created_at?: string;
48
47
  message_payload?: Json | null;
49
- org_id?: string | null;
48
+ org_id?: string;
50
49
  scheduled_at?: string | null;
51
- scheduled_message_id?: string;
50
+ sent_by?: string | null;
52
51
  status?: string | null;
53
- template_id?: string | null;
54
52
  };
55
53
  Update: {
56
- added_by?: string | null;
57
- chat_ids?: Json | null;
54
+ broadcast_id?: string;
55
+ chat_ids?: string[] | null;
58
56
  created_at?: string;
59
57
  message_payload?: Json | null;
60
- org_id?: string | null;
58
+ org_id?: string;
61
59
  scheduled_at?: string | null;
62
- scheduled_message_id?: string;
60
+ sent_by?: string | null;
63
61
  status?: string | null;
64
- template_id?: string | null;
65
62
  };
66
63
  Relationships: [
67
64
  {
68
- foreignKeyName: "tbl_broadcast_scheduled_messages_org_id_fkey";
65
+ foreignKeyName: "tbl_broadcast_messages_org_id_fkey";
69
66
  columns: ["org_id"];
70
67
  isOneToOne: false;
71
68
  referencedRelation: "tbl_org";
72
69
  referencedColumns: ["org_id"];
73
- },
74
- {
75
- foreignKeyName: "tbl_broadcast_scheduled_messages_template_id_fkey";
76
- columns: ["template_id"];
77
- isOneToOne: false;
78
- referencedRelation: "tbl_broadcast_templates";
79
- referencedColumns: ["template_id"];
80
70
  }
81
71
  ];
82
72
  };
83
73
  tbl_broadcast_templates: {
84
74
  Row: {
85
- body: string | null;
86
75
  created_at: string;
87
- filename: string | null;
88
- mimetype: string | null;
76
+ message_payload: Json | null;
89
77
  org_id: string;
90
78
  template_id: string;
91
79
  template_name: string | null;
92
80
  updated_at: string | null;
93
- url: string | null;
94
81
  };
95
82
  Insert: {
96
- body?: string | null;
97
83
  created_at?: string;
98
- filename?: string | null;
99
- mimetype?: string | null;
84
+ message_payload?: Json | null;
100
85
  org_id?: string;
101
86
  template_id?: string;
102
87
  template_name?: string | null;
103
88
  updated_at?: string | null;
104
- url?: string | null;
105
89
  };
106
90
  Update: {
107
- body?: string | null;
108
91
  created_at?: string;
109
- filename?: string | null;
110
- mimetype?: string | null;
92
+ message_payload?: Json | null;
111
93
  org_id?: string;
112
94
  template_id?: string;
113
95
  template_name?: string | null;
114
96
  updated_at?: string | null;
115
- url?: string | null;
116
97
  };
117
98
  Relationships: [
118
99
  {
@@ -374,7 +355,22 @@ export interface Database {
374
355
  org_id?: string;
375
356
  org_phone?: string;
376
357
  };
377
- Relationships: [];
358
+ Relationships: [
359
+ {
360
+ foreignKeyName: "tbl_chat_participants_fkey_tbl_chats";
361
+ columns: ["org_id", "org_phone", "chat_id"];
362
+ isOneToOne: false;
363
+ referencedRelation: "tbl_chats";
364
+ referencedColumns: ["org_id", "org_phone", "chat_id"];
365
+ },
366
+ {
367
+ foreignKeyName: "tbl_chat_participants_fkey_tbl_chats";
368
+ columns: ["org_id", "org_phone", "chat_id"];
369
+ isOneToOne: false;
370
+ referencedRelation: "view_chats";
371
+ referencedColumns: ["org_id", "org_phone", "chat_id"];
372
+ }
373
+ ];
378
374
  };
379
375
  tbl_chat_reactions: {
380
376
  Row: {
@@ -492,11 +488,11 @@ export interface Database {
492
488
  };
493
489
  Relationships: [
494
490
  {
495
- foreignKeyName: "tbl_chats_org_id_fkey";
496
- columns: ["org_id"];
491
+ foreignKeyName: "tbl_chats_fkey_tbl_org_phones";
492
+ columns: ["org_phone", "org_id"];
497
493
  isOneToOne: false;
498
- referencedRelation: "tbl_org";
499
- referencedColumns: ["org_id"];
494
+ referencedRelation: "tbl_org_phones";
495
+ referencedColumns: ["org_phone", "org_id"];
500
496
  }
501
497
  ];
502
498
  };
@@ -705,7 +701,7 @@ export interface Database {
705
701
  tbl_org_phones: {
706
702
  Row: {
707
703
  created_at: string;
708
- is_ready: boolean;
704
+ is_ready: boolean | null;
709
705
  org_id: string;
710
706
  org_phone: string | null;
711
707
  phone_id: string;
@@ -718,7 +714,7 @@ export interface Database {
718
714
  };
719
715
  Insert: {
720
716
  created_at?: string;
721
- is_ready?: boolean;
717
+ is_ready?: boolean | null;
722
718
  org_id: string;
723
719
  org_phone?: string | null;
724
720
  phone_id?: string;
@@ -731,7 +727,7 @@ export interface Database {
731
727
  };
732
728
  Update: {
733
729
  created_at?: string;
734
- is_ready?: boolean;
730
+ is_ready?: boolean | null;
735
731
  org_id?: string;
736
732
  org_phone?: string | null;
737
733
  phone_id?: string;
@@ -760,6 +756,7 @@ export interface Database {
760
756
  chat_access: Json | null;
761
757
  chat_id: string | null;
762
758
  chat_image: string | null;
759
+ chat_name: string | null;
763
760
  chat_type: string | null;
764
761
  group_metadata: Json | null;
765
762
  has_access: boolean | null;
@@ -784,11 +781,11 @@ export interface Database {
784
781
  };
785
782
  Relationships: [
786
783
  {
787
- foreignKeyName: "tbl_chats_org_id_fkey";
788
- columns: ["org_id"];
784
+ foreignKeyName: "tbl_chats_fkey_tbl_org_phones";
785
+ columns: ["org_phone", "org_id"];
789
786
  isOneToOne: false;
790
- referencedRelation: "tbl_org";
791
- referencedColumns: ["org_id"];
787
+ referencedRelation: "tbl_org_phones";
788
+ referencedColumns: ["org_phone", "org_id"];
792
789
  }
793
790
  ];
794
791
  };
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Merge, OverrideProperties } from 'type-fest';
2
2
  import { Chat, MessageTypes } from 'whatsapp-web.js';
3
- import { Tables } from './supabase.types';
3
+ import { Tables, TablesInsert } from './supabase.types';
4
4
  export type WhatsappChat = Chat & {
5
5
  groupMetadata?: any;
6
6
  pinned?: boolean;
@@ -38,10 +38,35 @@ export type ContactType = Merge<Tables<'tbl_contacts'>, {
38
38
  chat_ids: string[] | null;
39
39
  }>;
40
40
  export type ChatAccessType = Merge<Partial<Tables<'tbl_chat_access'>>, Tables<'tbl_org_members'>>;
41
- export type ServerStateType = {
42
- loading: boolean;
43
- percent: number | null;
44
- ready: boolean;
45
- };
41
+ export type BroadcastMessageType = Merge<TablesInsert<'tbl_broadcast_messages'>, {
42
+ message_payload?: SendMessageContent;
43
+ }>;
44
+ export type BroadcastTemplateType = Merge<TablesInsert<'tbl_broadcast_templates'>, {
45
+ message_payload?: SendMessageContent;
46
+ }>;
46
47
  export declare const labelColors: string[];
47
48
  export declare const enumChatColors: readonly ["#B4876E", "#A5B337", "#06CF9C", "#25D366", "#02A698", "#7D9EF1", "#007BFC", "#5E47DE", "#7F66FF", "#9333EA", "#FA6533", "#C4532D", "#DC2626", "#FF2E74", "#DB2777"];
49
+ export type SendMessageContent = {
50
+ message_type?: 'chat' | 'audio' | 'ptt' | 'image' | 'video' | 'document' | 'sticker' | 'location' | 'vcard';
51
+ body?: string;
52
+ media?: {
53
+ url: string;
54
+ mimetype?: string;
55
+ filename?: string;
56
+ };
57
+ contact_ids?: string[];
58
+ location?: Location;
59
+ quoted_message_id?: string;
60
+ quoted_message_type?: 'reply' | 'forward' | 'reply_private';
61
+ broadcast_id?: string;
62
+ variables?: Record<string, VariableType>;
63
+ };
64
+ export type VariableType = Record<string, string>;
65
+ export type BroadcastMessagePayload = SendMessageContent & {
66
+ chat_ids: string[];
67
+ broadcast_id?: string;
68
+ };
69
+ export type SingleMessagePayload = SendMessageContent & {
70
+ chat_id: string;
71
+ job_id?: string;
72
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@periskope/types",
3
- "version": "0.6.16",
3
+ "version": "0.6.18",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/supabase.types.ts CHANGED
@@ -28,90 +28,71 @@ export interface Database {
28
28
  }
29
29
  public: {
30
30
  Tables: {
31
- tbl_broadcast_scheduled_messages: {
31
+ tbl_broadcast_messages: {
32
32
  Row: {
33
- added_by: string | null
34
- chat_ids: Json | null
33
+ broadcast_id: string
34
+ chat_ids: string[] | null
35
35
  created_at: string
36
36
  message_payload: Json | null
37
- org_id: string | null
37
+ org_id: string
38
38
  scheduled_at: string | null
39
- scheduled_message_id: string
39
+ sent_by: string | null
40
40
  status: string | null
41
- template_id: string | null
42
41
  }
43
42
  Insert: {
44
- added_by?: string | null
45
- chat_ids?: Json | null
43
+ broadcast_id?: string
44
+ chat_ids?: string[] | null
46
45
  created_at?: string
47
46
  message_payload?: Json | null
48
- org_id?: string | null
47
+ org_id?: string
49
48
  scheduled_at?: string | null
50
- scheduled_message_id?: string
49
+ sent_by?: string | null
51
50
  status?: string | null
52
- template_id?: string | null
53
51
  }
54
52
  Update: {
55
- added_by?: string | null
56
- chat_ids?: Json | null
53
+ broadcast_id?: string
54
+ chat_ids?: string[] | null
57
55
  created_at?: string
58
56
  message_payload?: Json | null
59
- org_id?: string | null
57
+ org_id?: string
60
58
  scheduled_at?: string | null
61
- scheduled_message_id?: string
59
+ sent_by?: string | null
62
60
  status?: string | null
63
- template_id?: string | null
64
61
  }
65
62
  Relationships: [
66
63
  {
67
- foreignKeyName: "tbl_broadcast_scheduled_messages_org_id_fkey"
64
+ foreignKeyName: "tbl_broadcast_messages_org_id_fkey"
68
65
  columns: ["org_id"]
69
66
  isOneToOne: false
70
67
  referencedRelation: "tbl_org"
71
68
  referencedColumns: ["org_id"]
72
- },
73
- {
74
- foreignKeyName: "tbl_broadcast_scheduled_messages_template_id_fkey"
75
- columns: ["template_id"]
76
- isOneToOne: false
77
- referencedRelation: "tbl_broadcast_templates"
78
- referencedColumns: ["template_id"]
79
69
  }
80
70
  ]
81
71
  }
82
72
  tbl_broadcast_templates: {
83
73
  Row: {
84
- body: string | null
85
74
  created_at: string
86
- filename: string | null
87
- mimetype: string | null
75
+ message_payload: Json | null
88
76
  org_id: string
89
77
  template_id: string
90
78
  template_name: string | null
91
79
  updated_at: string | null
92
- url: string | null
93
80
  }
94
81
  Insert: {
95
- body?: string | null
96
82
  created_at?: string
97
- filename?: string | null
98
- mimetype?: string | null
83
+ message_payload?: Json | null
99
84
  org_id?: string
100
85
  template_id?: string
101
86
  template_name?: string | null
102
87
  updated_at?: string | null
103
- url?: string | null
104
88
  }
105
89
  Update: {
106
- body?: string | null
107
90
  created_at?: string
108
- filename?: string | null
109
- mimetype?: string | null
91
+ message_payload?: Json | null
110
92
  org_id?: string
111
93
  template_id?: string
112
94
  template_name?: string | null
113
95
  updated_at?: string | null
114
- url?: string | null
115
96
  }
116
97
  Relationships: [
117
98
  {
@@ -373,7 +354,22 @@ export interface Database {
373
354
  org_id?: string
374
355
  org_phone?: string
375
356
  }
376
- Relationships: []
357
+ Relationships: [
358
+ {
359
+ foreignKeyName: "tbl_chat_participants_fkey_tbl_chats"
360
+ columns: ["org_id", "org_phone", "chat_id"]
361
+ isOneToOne: false
362
+ referencedRelation: "tbl_chats"
363
+ referencedColumns: ["org_id", "org_phone", "chat_id"]
364
+ },
365
+ {
366
+ foreignKeyName: "tbl_chat_participants_fkey_tbl_chats"
367
+ columns: ["org_id", "org_phone", "chat_id"]
368
+ isOneToOne: false
369
+ referencedRelation: "view_chats"
370
+ referencedColumns: ["org_id", "org_phone", "chat_id"]
371
+ }
372
+ ]
377
373
  }
378
374
  tbl_chat_reactions: {
379
375
  Row: {
@@ -491,11 +487,11 @@ export interface Database {
491
487
  }
492
488
  Relationships: [
493
489
  {
494
- foreignKeyName: "tbl_chats_org_id_fkey"
495
- columns: ["org_id"]
490
+ foreignKeyName: "tbl_chats_fkey_tbl_org_phones"
491
+ columns: ["org_phone", "org_id"]
496
492
  isOneToOne: false
497
- referencedRelation: "tbl_org"
498
- referencedColumns: ["org_id"]
493
+ referencedRelation: "tbl_org_phones"
494
+ referencedColumns: ["org_phone", "org_id"]
499
495
  }
500
496
  ]
501
497
  }
@@ -704,7 +700,7 @@ export interface Database {
704
700
  tbl_org_phones: {
705
701
  Row: {
706
702
  created_at: string
707
- is_ready: boolean
703
+ is_ready: boolean | null
708
704
  org_id: string
709
705
  org_phone: string | null
710
706
  phone_id: string
@@ -717,7 +713,7 @@ export interface Database {
717
713
  }
718
714
  Insert: {
719
715
  created_at?: string
720
- is_ready?: boolean
716
+ is_ready?: boolean | null
721
717
  org_id: string
722
718
  org_phone?: string | null
723
719
  phone_id?: string
@@ -730,7 +726,7 @@ export interface Database {
730
726
  }
731
727
  Update: {
732
728
  created_at?: string
733
- is_ready?: boolean
729
+ is_ready?: boolean | null
734
730
  org_id?: string
735
731
  org_phone?: string | null
736
732
  phone_id?: string
@@ -759,6 +755,7 @@ export interface Database {
759
755
  chat_access: Json | null
760
756
  chat_id: string | null
761
757
  chat_image: string | null
758
+ chat_name: string | null
762
759
  chat_type: string | null
763
760
  group_metadata: Json | null
764
761
  has_access: boolean | null
@@ -783,11 +780,11 @@ export interface Database {
783
780
  }
784
781
  Relationships: [
785
782
  {
786
- foreignKeyName: "tbl_chats_org_id_fkey"
787
- columns: ["org_id"]
783
+ foreignKeyName: "tbl_chats_fkey_tbl_org_phones"
784
+ columns: ["org_phone", "org_id"]
788
785
  isOneToOne: false
789
- referencedRelation: "tbl_org"
790
- referencedColumns: ["org_id"]
786
+ referencedRelation: "tbl_org_phones"
787
+ referencedColumns: ["org_phone", "org_id"]
791
788
  }
792
789
  ]
793
790
  }
package/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Merge, OverrideProperties } from 'type-fest';
2
2
  import { Chat, MessageTypes } from 'whatsapp-web.js';
3
- import { Tables } from './supabase.types';
3
+ import { Tables, TablesInsert } from './supabase.types';
4
4
 
5
5
  /* ----------------------------- TYPE SHORTHANDS ---------------------------- */
6
6
 
@@ -68,11 +68,19 @@ export type ChatAccessType = Merge<
68
68
  Tables<'tbl_org_members'>
69
69
  >;
70
70
 
71
- export type ServerStateType = {
72
- loading: boolean;
73
- percent: number | null;
74
- ready: boolean;
75
- };
71
+ export type BroadcastMessageType = Merge<
72
+ TablesInsert<'tbl_broadcast_messages'>,
73
+ {
74
+ message_payload?: SendMessageContent;
75
+ }
76
+ >;
77
+
78
+ export type BroadcastTemplateType = Merge<
79
+ TablesInsert<'tbl_broadcast_templates'>,
80
+ {
81
+ message_payload?: SendMessageContent;
82
+ }
83
+ >;
76
84
 
77
85
  /* -------------------------------- CONSTANTS ------------------------------- */
78
86
 
@@ -101,3 +109,42 @@ export const enumChatColors = [
101
109
  '#FF2E74',
102
110
  '#DB2777',
103
111
  ] as const;
112
+
113
+ /* -------------------------- SEND MESSAGE PAYLOAD -------------------------- */
114
+
115
+ export type SendMessageContent = {
116
+ message_type?:
117
+ | 'chat'
118
+ | 'audio'
119
+ | 'ptt'
120
+ | 'image'
121
+ | 'video'
122
+ | 'document'
123
+ | 'sticker'
124
+ | 'location'
125
+ | 'vcard';
126
+ body?: string;
127
+ media?: {
128
+ url: string;
129
+ mimetype?: string;
130
+ filename?: string;
131
+ };
132
+ contact_ids?: string[];
133
+ location?: Location;
134
+ quoted_message_id?: string;
135
+ quoted_message_type?: 'reply' | 'forward' | 'reply_private';
136
+ broadcast_id?: string;
137
+ variables?: Record<string, VariableType>;
138
+ };
139
+
140
+ export type VariableType = Record<string, string>;
141
+
142
+ export type BroadcastMessagePayload = SendMessageContent & {
143
+ chat_ids: string[];
144
+ broadcast_id?: string;
145
+ };
146
+
147
+ export type SingleMessagePayload = SendMessageContent & {
148
+ chat_id: string;
149
+ job_id?: string;
150
+ };