@periskope/types 0.6.17 → 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
  {
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.17",
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
  {
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
+ };