@periskope/types 0.6.45 → 0.6.47

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,2 +1,3 @@
1
+ export * from './supabase.columns';
1
2
  export * from './supabase.types';
2
3
  export * from './types';
package/dist/index.js CHANGED
@@ -14,5 +14,6 @@ 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);
17
18
  __exportStar(require("./supabase.types"), exports);
18
19
  __exportStar(require("./types"), exports);
@@ -1,14 +1 @@
1
- export declare const tbl_broadcast_messages_columns: string[];
2
- export declare const tbl_broadcast_templates_columns: string[];
3
- export declare const tbl_chat_access_columns: string[];
4
- export declare const tbl_chat_messages_columns: string[];
5
- export declare const tbl_chat_notifications_columns: string[];
6
- export declare const tbl_chat_participants_columns: string[];
7
- export declare const tbl_chat_reactions_columns: string[];
8
- export declare const tbl_chat_tickets_columns: string[];
9
- export declare const tbl_chats_columns: string[];
10
- export declare const tbl_contacts_columns: string[];
11
- export declare const tbl_org_columns: string[];
12
- export declare const tbl_org_labels_columns: string[];
13
- export declare const tbl_org_members_columns: string[];
14
- export declare const tbl_org_phones_columns: string[];
1
+ export declare const TableColumns: Record<string, string[]>;
@@ -1,17 +1,282 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tbl_org_phones_columns = exports.tbl_org_members_columns = exports.tbl_org_labels_columns = exports.tbl_org_columns = exports.tbl_contacts_columns = exports.tbl_chats_columns = exports.tbl_chat_tickets_columns = exports.tbl_chat_reactions_columns = exports.tbl_chat_participants_columns = exports.tbl_chat_notifications_columns = exports.tbl_chat_messages_columns = exports.tbl_chat_access_columns = exports.tbl_broadcast_templates_columns = exports.tbl_broadcast_messages_columns = void 0;
4
- exports.tbl_broadcast_messages_columns = ['broadcast_id', 'chat_ids', 'completed_at', 'created_at', 'message_payload', 'org_id', 'performed_by', 'scheduled_at'];
5
- exports.tbl_broadcast_templates_columns = ['created_at', 'message_payload', 'org_id', 'template_id', 'template_name', 'updated_at'];
6
- exports.tbl_chat_access_columns = ['active_phone', 'chat_id', 'email', 'has_access', 'last_read_timestamp', 'org_id'];
7
- exports.tbl_chat_messages_columns = ['ack', 'author', 'body', 'broadcast', 'broadcast_id', 'chat_id', 'delivery_info', 'device_type', 'duration', 'forwarding_score', 'from', 'from_me', 'has_media', 'has_quoted_msg', 'has_reaction', 'id', 'invite_v4', 'is_deleted', 'is_ephemeral', 'is_forwarded', 'is_gif', 'is_starred', 'is_status', 'links', 'location', 'media', 'media_key', 'mentioned_ids', 'message_id', 'message_ticket_id', 'message_type', 'order_id', 'org_id', 'org_phone', 'performed_by', 'prev_body', 'quoted_message_id', 'raw_data', 'sender_phone', 'sent_message_id', 'timestamp', 'to', 'token', 'unique_id', 'updated_at', 'vcards'];
8
- exports.tbl_chat_notifications_columns = ['author', 'body', 'chat_id', 'id', 'notification_id', 'org_id', 'org_phone', 'recipientids', 'timestamp', 'type', 'unique_id'];
9
- exports.tbl_chat_participants_columns = ['chat_id', 'contact_id', 'id', 'is_admin', 'is_super_admin', 'org_id', 'org_phone'];
10
- exports.tbl_chat_reactions_columns = ['ack', 'chat_id', 'id', 'message_id', 'msg_id', 'org_id', 'org_phone', 'orphan', 'orphan_reason', 'reaction', 'reaction_id', 'read', 'sender_id', 'timestamp', 'unique_id'];
11
- exports.tbl_chat_tickets_columns = ['assigned_by', 'assignee', 'chat_id', 'created_at', 'due_date', 'label_ids', 'last_updated_at', 'org_id', 'priority', 'quoted_message_id', 'raised_by', 'status', 'subject', 'ticket_id'];
12
- exports.tbl_chats_columns = ['archived', 'chat_id', 'chat_image', 'group_metadata', 'id', 'invite_link', 'is_group', 'is_muted', 'is_read_only', 'label_ids', 'mute_expiration', 'name', 'org_id', 'org_phone', 'pinned', 'timestamp', 'unread_count', 'updated_at'];
13
- exports.tbl_contacts_columns = ['business_profile', 'contact_color', 'contact_id', 'contact_image', 'contact_name', 'contact_type', 'id', 'is_blocked', 'is_business', 'is_enterprise', 'is_group', 'is_internal', 'is_me', 'is_my_contact', 'is_user', 'is_wa_contact', 'label_ids', 'name', 'number', 'org_id', 'pushname', 'short_name', 'updated_at', 'verified_level', 'verified_name'];
14
- exports.tbl_org_columns = ['created_at', 'org_id', 'org_image', 'org_metadata', 'org_name', 'org_plan', 'support_link'];
15
- exports.tbl_org_labels_columns = ['color', 'created_at', 'label_id', 'name', 'org_id', 'type'];
16
- exports.tbl_org_members_columns = ['created_at', 'email', 'invited_at', 'invited_by', 'is_active', 'member_color', 'member_image', 'member_name', 'org_id', 'role', 'user_id'];
17
- exports.tbl_org_phones_columns = ['created_at', 'is_ready', 'org_id', 'org_phone', 'phone_id', 'phone_image', 'phone_name', 'qr_code', 'server_ip', 'updated_at', 'wa_state'];
3
+ exports.TableColumns = void 0;
4
+ exports.TableColumns = {
5
+ "tbl_broadcast_messages": [
6
+ "broadcast_id",
7
+ "created_at",
8
+ "chat_ids",
9
+ "scheduled_at",
10
+ "org_id",
11
+ "message_payload",
12
+ "completed_at",
13
+ "performed_by"
14
+ ],
15
+ "tbl_broadcast_templates": [
16
+ "template_id",
17
+ "created_at",
18
+ "template_name",
19
+ "org_id",
20
+ "updated_at",
21
+ "message_payload"
22
+ ],
23
+ "tbl_chat_access": [
24
+ "org_id",
25
+ "email",
26
+ "chat_id",
27
+ "has_access",
28
+ "last_read_timestamp",
29
+ "active_phone"
30
+ ],
31
+ "tbl_chat_messages": [
32
+ "message_id",
33
+ "org_id",
34
+ "ack",
35
+ "author",
36
+ "body",
37
+ "broadcast",
38
+ "device_type",
39
+ "duration",
40
+ "forwarding_score",
41
+ "from",
42
+ "from_me",
43
+ "has_media",
44
+ "has_quoted_msg",
45
+ "has_reaction",
46
+ "id",
47
+ "invite_v4",
48
+ "is_ephemeral",
49
+ "is_forwarded",
50
+ "is_gif",
51
+ "is_starred",
52
+ "is_status",
53
+ "links",
54
+ "location",
55
+ "media_key",
56
+ "mentioned_ids",
57
+ "order_id",
58
+ "raw_data",
59
+ "to",
60
+ "token",
61
+ "message_type",
62
+ "vcards",
63
+ "chat_id",
64
+ "timestamp",
65
+ "org_phone",
66
+ "broadcast_id",
67
+ "is_deleted",
68
+ "media",
69
+ "performed_by",
70
+ "prev_body",
71
+ "quoted_message_id",
72
+ "sent_message_id",
73
+ "delivery_info",
74
+ "updated_at",
75
+ "message_ticket_id"
76
+ ],
77
+ "tbl_chat_notifications": [
78
+ "org_id",
79
+ "notification_id",
80
+ "chat_id",
81
+ "author",
82
+ "body",
83
+ "id",
84
+ "recipientids",
85
+ "type",
86
+ "timestamp",
87
+ "org_phone"
88
+ ],
89
+ "tbl_chat_participants": [
90
+ "org_id",
91
+ "chat_id",
92
+ "contact_id",
93
+ "id",
94
+ "is_admin",
95
+ "is_super_admin",
96
+ "org_phone"
97
+ ],
98
+ "tbl_chat_reactions": [
99
+ "org_id",
100
+ "message_id",
101
+ "ack",
102
+ "id",
103
+ "orphan",
104
+ "reaction",
105
+ "read",
106
+ "reaction_id",
107
+ "timestamp",
108
+ "msg_id",
109
+ "orphan_reason",
110
+ "sender_id",
111
+ "org_phone"
112
+ ],
113
+ "tbl_chat_tickets": [
114
+ "created_at",
115
+ "ticket_id",
116
+ "subject",
117
+ "status",
118
+ "assignee",
119
+ "assigned_by",
120
+ "chat_id",
121
+ "due_date",
122
+ "org_id",
123
+ "label_ids",
124
+ "quoted_message_id",
125
+ "raised_by",
126
+ "priority",
127
+ "last_updated_at"
128
+ ],
129
+ "tbl_chats": [
130
+ "org_id",
131
+ "chat_id",
132
+ "archived",
133
+ "id",
134
+ "is_group",
135
+ "is_muted",
136
+ "is_read_only",
137
+ "mute_expiration",
138
+ "name",
139
+ "pinned",
140
+ "unread_count",
141
+ "group_metadata",
142
+ "chat_image",
143
+ "timestamp",
144
+ "invite_link",
145
+ "org_phone",
146
+ "label_ids",
147
+ "updated_at"
148
+ ],
149
+ "tbl_contacts": [
150
+ "org_id",
151
+ "contact_id",
152
+ "id",
153
+ "number",
154
+ "is_business",
155
+ "is_enterprise",
156
+ "name",
157
+ "pushname",
158
+ "short_name",
159
+ "contact_type",
160
+ "is_me",
161
+ "is_user",
162
+ "is_group",
163
+ "is_wa_contact",
164
+ "is_my_contact",
165
+ "is_blocked",
166
+ "contact_image",
167
+ "contact_color",
168
+ "business_profile",
169
+ "verified_name",
170
+ "is_internal",
171
+ "label_ids",
172
+ "verified_level",
173
+ "updated_at"
174
+ ],
175
+ "tbl_org": [
176
+ "org_id",
177
+ "created_at",
178
+ "org_image",
179
+ "org_name",
180
+ "support_link",
181
+ "org_metadata",
182
+ "org_plan"
183
+ ],
184
+ "tbl_org_labels": [
185
+ "label_id",
186
+ "created_at",
187
+ "org_id",
188
+ "name",
189
+ "color",
190
+ "type"
191
+ ],
192
+ "tbl_org_members": [
193
+ "created_at",
194
+ "email",
195
+ "user_id",
196
+ "invited_at",
197
+ "invited_by",
198
+ "org_id",
199
+ "role",
200
+ "member_image",
201
+ "member_name",
202
+ "is_active",
203
+ "member_color"
204
+ ],
205
+ "tbl_org_phones": [
206
+ "org_id",
207
+ "org_phone",
208
+ "created_at",
209
+ "updated_at",
210
+ "wa_state",
211
+ "phone_id",
212
+ "qr_code",
213
+ "phone_image",
214
+ "phone_name",
215
+ "server_ip"
216
+ ],
217
+ "view_broadcast_logs": [
218
+ "broadcast_id",
219
+ "org_id",
220
+ "message_payload",
221
+ "created_at",
222
+ "total_chats",
223
+ "sent_chats",
224
+ "failed_chats",
225
+ "total_member_count",
226
+ "delivered_member_count",
227
+ "read_member_count",
228
+ "completed_at",
229
+ "scheduled_at",
230
+ "performed_by",
231
+ "delivery_percentage",
232
+ "read_percentage"
233
+ ],
234
+ "view_chat_messages": [
235
+ "message_id",
236
+ "org_id",
237
+ "ack",
238
+ "author",
239
+ "body",
240
+ "from_me",
241
+ "invite_v4",
242
+ "links",
243
+ "location",
244
+ "mentioned_ids",
245
+ "message_type",
246
+ "vcards",
247
+ "chat_id",
248
+ "timestamp",
249
+ "org_phone",
250
+ "broadcast_id",
251
+ "is_deleted",
252
+ "media",
253
+ "performed_by",
254
+ "prev_body",
255
+ "quoted_message_id",
256
+ "sender_phone",
257
+ "sent_message_id",
258
+ "delivery_info",
259
+ "updated_at",
260
+ "message_ticket_id",
261
+ "unique_id"
262
+ ],
263
+ "view_chats": [
264
+ "org_id",
265
+ "chat_id",
266
+ "org_phone",
267
+ "chat_image",
268
+ "invite_link",
269
+ "label_ids",
270
+ "updated_at",
271
+ "chat_name",
272
+ "latest_message",
273
+ "message_unread_count",
274
+ "member_count",
275
+ "chat_type",
276
+ "chat_access",
277
+ "has_access",
278
+ "last_read_timestamp",
279
+ "chat_org_phones",
280
+ "active_phone"
281
+ ]
282
+ };
package/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './supabase.columns';
1
2
  export * from './supabase.types';
2
3
  export * from './types';
3
4
 
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "@periskope/types",
3
- "version": "0.6.45",
3
+ "version": "0.6.47",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "dependencies": {
8
+ "@types/pg": "8.11.2",
9
+ "pg": "^8.11.3",
8
10
  "ts-node": "^10.9.2",
9
11
  "type-fest": "^4.8.3",
10
12
  "whatsapp-web.js": "1.23.1-alpha.4"
11
13
  },
12
14
  "scripts": {
13
- "update-package": "npx ts-node extractColumnNames.ts \u0026\u0026 tsc \u0026\u0026 npm publish --access public"
15
+ "update-package": "node scripts/extractColumnNames.js \u0026\u0026 tsc \u0026\u0026 npm publish --access public"
14
16
  }
15
17
  }
@@ -0,0 +1,55 @@
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: Record<string, string[]> = ${JSON.stringify(
49
+ tableColumns,
50
+ null,
51
+ 2
52
+ )};`;
53
+
54
+ fs.writeFileSync(outputFile, tsContent, 'utf8'); // Write the TS content to file
55
+ });
@@ -1,14 +1,279 @@
1
- export const tbl_broadcast_messages_columns: string[] = ['broadcast_id', 'chat_ids', 'completed_at', 'created_at', 'message_payload', 'org_id', 'performed_by', 'scheduled_at'];
2
- export const tbl_broadcast_templates_columns: string[] = ['created_at', 'message_payload', 'org_id', 'template_id', 'template_name', 'updated_at'];
3
- export const tbl_chat_access_columns: string[] = ['active_phone', 'chat_id', 'email', 'has_access', 'last_read_timestamp', 'org_id'];
4
- export const tbl_chat_messages_columns: string[] = ['ack', 'author', 'body', 'broadcast', 'broadcast_id', 'chat_id', 'delivery_info', 'device_type', 'duration', 'forwarding_score', 'from', 'from_me', 'has_media', 'has_quoted_msg', 'has_reaction', 'id', 'invite_v4', 'is_deleted', 'is_ephemeral', 'is_forwarded', 'is_gif', 'is_starred', 'is_status', 'links', 'location', 'media', 'media_key', 'mentioned_ids', 'message_id', 'message_ticket_id', 'message_type', 'order_id', 'org_id', 'org_phone', 'performed_by', 'prev_body', 'quoted_message_id', 'raw_data', 'sender_phone', 'sent_message_id', 'timestamp', 'to', 'token', 'unique_id', 'updated_at', 'vcards'];
5
- export const tbl_chat_notifications_columns: string[] = ['author', 'body', 'chat_id', 'id', 'notification_id', 'org_id', 'org_phone', 'recipientids', 'timestamp', 'type', 'unique_id'];
6
- export const tbl_chat_participants_columns: string[] = ['chat_id', 'contact_id', 'id', 'is_admin', 'is_super_admin', 'org_id', 'org_phone'];
7
- export const tbl_chat_reactions_columns: string[] = ['ack', 'chat_id', 'id', 'message_id', 'msg_id', 'org_id', 'org_phone', 'orphan', 'orphan_reason', 'reaction', 'reaction_id', 'read', 'sender_id', 'timestamp', 'unique_id'];
8
- export const tbl_chat_tickets_columns: string[] = ['assigned_by', 'assignee', 'chat_id', 'created_at', 'due_date', 'label_ids', 'last_updated_at', 'org_id', 'priority', 'quoted_message_id', 'raised_by', 'status', 'subject', 'ticket_id'];
9
- export const tbl_chats_columns: string[] = ['archived', 'chat_id', 'chat_image', 'group_metadata', 'id', 'invite_link', 'is_group', 'is_muted', 'is_read_only', 'label_ids', 'mute_expiration', 'name', 'org_id', 'org_phone', 'pinned', 'timestamp', 'unread_count', 'updated_at'];
10
- export const tbl_contacts_columns: string[] = ['business_profile', 'contact_color', 'contact_id', 'contact_image', 'contact_name', 'contact_type', 'id', 'is_blocked', 'is_business', 'is_enterprise', 'is_group', 'is_internal', 'is_me', 'is_my_contact', 'is_user', 'is_wa_contact', 'label_ids', 'name', 'number', 'org_id', 'pushname', 'short_name', 'updated_at', 'verified_level', 'verified_name'];
11
- export const tbl_org_columns: string[] = ['created_at', 'org_id', 'org_image', 'org_metadata', 'org_name', 'org_plan', 'support_link'];
12
- export const tbl_org_labels_columns: string[] = ['color', 'created_at', 'label_id', 'name', 'org_id', 'type'];
13
- export const tbl_org_members_columns: string[] = ['created_at', 'email', 'invited_at', 'invited_by', 'is_active', 'member_color', 'member_image', 'member_name', 'org_id', 'role', 'user_id'];
14
- export const tbl_org_phones_columns: string[] = ['created_at', 'is_ready', 'org_id', 'org_phone', 'phone_id', 'phone_image', 'phone_name', 'qr_code', 'server_ip', 'updated_at', 'wa_state'];
1
+ export const TableColumns: Record<string, string[]> = {
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
+ ],
126
+ "tbl_chats": [
127
+ "org_id",
128
+ "chat_id",
129
+ "archived",
130
+ "id",
131
+ "is_group",
132
+ "is_muted",
133
+ "is_read_only",
134
+ "mute_expiration",
135
+ "name",
136
+ "pinned",
137
+ "unread_count",
138
+ "group_metadata",
139
+ "chat_image",
140
+ "timestamp",
141
+ "invite_link",
142
+ "org_phone",
143
+ "label_ids",
144
+ "updated_at"
145
+ ],
146
+ "tbl_contacts": [
147
+ "org_id",
148
+ "contact_id",
149
+ "id",
150
+ "number",
151
+ "is_business",
152
+ "is_enterprise",
153
+ "name",
154
+ "pushname",
155
+ "short_name",
156
+ "contact_type",
157
+ "is_me",
158
+ "is_user",
159
+ "is_group",
160
+ "is_wa_contact",
161
+ "is_my_contact",
162
+ "is_blocked",
163
+ "contact_image",
164
+ "contact_color",
165
+ "business_profile",
166
+ "verified_name",
167
+ "is_internal",
168
+ "label_ids",
169
+ "verified_level",
170
+ "updated_at"
171
+ ],
172
+ "tbl_org": [
173
+ "org_id",
174
+ "created_at",
175
+ "org_image",
176
+ "org_name",
177
+ "support_link",
178
+ "org_metadata",
179
+ "org_plan"
180
+ ],
181
+ "tbl_org_labels": [
182
+ "label_id",
183
+ "created_at",
184
+ "org_id",
185
+ "name",
186
+ "color",
187
+ "type"
188
+ ],
189
+ "tbl_org_members": [
190
+ "created_at",
191
+ "email",
192
+ "user_id",
193
+ "invited_at",
194
+ "invited_by",
195
+ "org_id",
196
+ "role",
197
+ "member_image",
198
+ "member_name",
199
+ "is_active",
200
+ "member_color"
201
+ ],
202
+ "tbl_org_phones": [
203
+ "org_id",
204
+ "org_phone",
205
+ "created_at",
206
+ "updated_at",
207
+ "wa_state",
208
+ "phone_id",
209
+ "qr_code",
210
+ "phone_image",
211
+ "phone_name",
212
+ "server_ip"
213
+ ],
214
+ "view_broadcast_logs": [
215
+ "broadcast_id",
216
+ "org_id",
217
+ "message_payload",
218
+ "created_at",
219
+ "total_chats",
220
+ "sent_chats",
221
+ "failed_chats",
222
+ "total_member_count",
223
+ "delivered_member_count",
224
+ "read_member_count",
225
+ "completed_at",
226
+ "scheduled_at",
227
+ "performed_by",
228
+ "delivery_percentage",
229
+ "read_percentage"
230
+ ],
231
+ "view_chat_messages": [
232
+ "message_id",
233
+ "org_id",
234
+ "ack",
235
+ "author",
236
+ "body",
237
+ "from_me",
238
+ "invite_v4",
239
+ "links",
240
+ "location",
241
+ "mentioned_ids",
242
+ "message_type",
243
+ "vcards",
244
+ "chat_id",
245
+ "timestamp",
246
+ "org_phone",
247
+ "broadcast_id",
248
+ "is_deleted",
249
+ "media",
250
+ "performed_by",
251
+ "prev_body",
252
+ "quoted_message_id",
253
+ "sender_phone",
254
+ "sent_message_id",
255
+ "delivery_info",
256
+ "updated_at",
257
+ "message_ticket_id",
258
+ "unique_id"
259
+ ],
260
+ "view_chats": [
261
+ "org_id",
262
+ "chat_id",
263
+ "org_phone",
264
+ "chat_image",
265
+ "invite_link",
266
+ "label_ids",
267
+ "updated_at",
268
+ "chat_name",
269
+ "latest_message",
270
+ "message_unread_count",
271
+ "member_count",
272
+ "chat_type",
273
+ "chat_access",
274
+ "has_access",
275
+ "last_read_timestamp",
276
+ "chat_org_phones",
277
+ "active_phone"
278
+ ]
279
+ };
package/tsconfig.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  /* Visit https://aka.ms/tsconfig to read more about this file */
4
-
5
4
  /* Projects */
6
5
  // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
6
  // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
@@ -9,9 +8,8 @@
9
8
  // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
9
  // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
10
  // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
11
  /* Language and Environment */
14
- "target": "ES2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
12
+ "target": "ES2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
13
  // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
14
  // "jsx": "preserve", /* Specify what JSX code is generated. */
17
15
  // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
@@ -23,9 +21,8 @@
23
21
  // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
22
  // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
23
  // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
-
27
24
  /* Modules */
28
- "module": "CommonJS", /* Specify what module code is generated. */
25
+ "module": "CommonJS", /* Specify what module code is generated. */
29
26
  // "rootDir": "./", /* Specify the root folder within your source files. */
30
27
  // "moduleResolution": "Node", /* Specify how TypeScript looks up a file from a given module specifier. */
31
28
  // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
@@ -42,20 +39,18 @@
42
39
  // "resolveJsonModule": true, /* Enable importing .json files. */
43
40
  // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
44
41
  // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
45
-
46
42
  /* JavaScript Support */
47
43
  // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
48
44
  // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
49
45
  // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
50
-
51
46
  /* Emit */
52
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
47
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
53
48
  // "declarationMap": true, /* Create sourcemaps for d.ts files. */
54
49
  // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
55
50
  // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
56
51
  // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57
52
  // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
58
- "outDir": "dist/", /* Specify an output folder for all emitted files. */
53
+ "outDir": "dist/", /* Specify an output folder for all emitted files. */
59
54
  // "removeComments": true, /* Disable emitting comments. */
60
55
  // "noEmit": true, /* Disable emitting files from a compilation. */
61
56
  // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
@@ -72,17 +67,15 @@
72
67
  // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
73
68
  // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
74
69
  // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
75
-
76
70
  /* Interop Constraints */
77
71
  // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
78
72
  // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
79
73
  // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
80
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
74
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
81
75
  // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
82
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
83
-
76
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
84
77
  /* Type Checking */
85
- "strict": true, /* Enable all strict type-checking options. */
78
+ "strict": true, /* Enable all strict type-checking options. */
86
79
  // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
87
80
  // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
88
81
  // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
@@ -101,9 +94,13 @@
101
94
  // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
102
95
  // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
103
96
  // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
104
-
105
97
  /* Completeness */
106
98
  // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
107
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
108
- }
109
- }
99
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
100
+ },
101
+ "exclude": [
102
+ "node_modules",
103
+ "dist",
104
+ "scripts"
105
+ ]
106
+ }
@@ -1 +0,0 @@
1
- export {};
@@ -1,93 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const fs = __importStar(require("fs"));
27
- const ts = __importStar(require("typescript"));
28
- const fileNames = ['supabase.types.ts']; // Adjust the path to your type definitions
29
- const options = {
30
- target: ts.ScriptTarget.ES5,
31
- module: ts.ModuleKind.CommonJS,
32
- };
33
- const outputFile = './supabase.columns.ts';
34
- let outputLines = [];
35
- const program = ts.createProgram(fileNames, options);
36
- for (const sourceFile of program.getSourceFiles()) {
37
- if (!fileNames.includes(sourceFile.fileName)) {
38
- continue;
39
- }
40
- ts.forEachChild(sourceFile, visit);
41
- }
42
- function visit(node) {
43
- // Look for the Database interface declaration
44
- if (ts.isInterfaceDeclaration(node) && node.name.escapedText === 'Database') {
45
- node.members.forEach((member) => {
46
- if (ts.isPropertySignature(member) && member.name && ts.isIdentifier(member.name) && member.name.escapedText === 'public') {
47
- // Get the type of the 'public' property if possible
48
- const publicTypeNode = member.type;
49
- if (publicTypeNode && ts.isTypeLiteralNode(publicTypeNode)) {
50
- publicTypeNode.members.forEach((publicMember) => {
51
- if (ts.isPropertySignature(publicMember) && publicMember.name && ts.isIdentifier(publicMember.name) &&
52
- publicMember.name.escapedText === 'Tables') {
53
- const tablesTypeNode = publicMember.type;
54
- if (tablesTypeNode && ts.isTypeLiteralNode(tablesTypeNode)) {
55
- tablesTypeNode.members.forEach((table) => {
56
- if (ts.isPropertySignature(table) &&
57
- table.type &&
58
- ts.isTypeLiteralNode(table.type) && ts.isIdentifier(table.name)) {
59
- const tableName = table.name.escapedText;
60
- table.type.members.forEach((column) => {
61
- if (ts.isPropertySignature(column)) {
62
- // Assuming you're interested in the Row type
63
- if (ts.isIdentifier(column.name) &&
64
- column.name.escapedText === 'Row' &&
65
- column.type &&
66
- ts.isTypeLiteralNode(column.type)) {
67
- const columns = column.type.members
68
- .map((col) => {
69
- if (ts.isPropertySignature(col) && col.name && ts.isIdentifier(col.name)) {
70
- return col.name.escapedText;
71
- }
72
- return null;
73
- })
74
- .filter(Boolean);
75
- const columnsDeclaration = `export const ${tableName}_columns: string[] = [${columns
76
- .map((column) => `'${column}'`)
77
- .join(', ')}];`;
78
- outputLines.push(columnsDeclaration);
79
- }
80
- }
81
- });
82
- }
83
- });
84
- }
85
- }
86
- });
87
- }
88
- }
89
- });
90
- }
91
- }
92
- fs.writeFileSync(outputFile, outputLines.join('\n'), 'utf8');
93
- console.log(`Column data written to ${outputFile}`);
@@ -1,82 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as ts from 'typescript';
3
-
4
- const fileNames = ['supabase.types.ts']; // Adjust the path to your type definitions
5
- const options: ts.CompilerOptions = {
6
- target: ts.ScriptTarget.ES5,
7
- module: ts.ModuleKind.CommonJS,
8
- };
9
- const outputFile = './supabase.columns.ts';
10
- let outputLines: string[] = [];
11
-
12
- const program = ts.createProgram(fileNames, options);
13
-
14
- for (const sourceFile of program.getSourceFiles()) {
15
- if (!fileNames.includes(sourceFile.fileName)) {
16
- continue;
17
- }
18
-
19
- ts.forEachChild(sourceFile, visit);
20
- }
21
-
22
- function visit(node: ts.Node) {
23
- // Look for the Database interface declaration
24
- if (ts.isInterfaceDeclaration(node) && node.name.escapedText === 'Database') {
25
- node.members.forEach((member) => {
26
- if (
27
- ts.isPropertySignature(member) && member.name && ts.isIdentifier(member.name) && member.name.escapedText === 'public'
28
- ) {
29
- // Get the type of the 'public' property if possible
30
- const publicTypeNode = member.type;
31
- if (publicTypeNode && ts.isTypeLiteralNode(publicTypeNode)) {
32
- publicTypeNode.members.forEach((publicMember) => {
33
- if (
34
- ts.isPropertySignature(publicMember) && publicMember.name && ts.isIdentifier(publicMember.name) &&
35
- publicMember.name.escapedText === 'Tables'
36
- ) {
37
- const tablesTypeNode = publicMember.type;
38
- if (tablesTypeNode && ts.isTypeLiteralNode(tablesTypeNode)) {
39
- tablesTypeNode.members.forEach((table) => {
40
- if (
41
- ts.isPropertySignature(table) &&
42
- table.type &&
43
- ts.isTypeLiteralNode(table.type) && ts.isIdentifier(table.name)
44
- ) {
45
- const tableName = table.name.escapedText;
46
- table.type.members.forEach((column) => {
47
- if (ts.isPropertySignature(column)) {
48
- // Assuming you're interested in the Row type
49
- if (
50
- ts.isIdentifier(column.name) &&
51
- column.name.escapedText === 'Row' &&
52
- column.type &&
53
- ts.isTypeLiteralNode(column.type)
54
- ) {
55
- const columns = column.type.members
56
- .map((col) => {
57
- if (ts.isPropertySignature(col) && col.name && ts.isIdentifier(col.name)) {
58
- return col.name.escapedText;
59
- }
60
- return null;
61
- })
62
- .filter(Boolean);
63
- const columnsDeclaration = `export const ${tableName}_columns: string[] = [${columns
64
- .map((column) => `'${column}'`)
65
- .join(', ')}];`;
66
- outputLines.push(columnsDeclaration);
67
- }
68
- }
69
- });
70
- }
71
- });
72
- }
73
- }
74
- });
75
- }
76
- }
77
- });
78
- }
79
- }
80
-
81
- fs.writeFileSync(outputFile, outputLines.join('\n'), 'utf8');
82
- console.log(`Column data written to ${outputFile}`);