@periskope/types 0.6.43 → 0.6.45
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/extractColumnNames.d.ts +1 -0
- package/dist/extractColumnNames.js +93 -0
- package/dist/supabase.columns.d.ts +14 -0
- package/dist/supabase.columns.js +17 -0
- package/dist/types.d.ts +1 -0
- package/extractColumnNames.ts +82 -0
- package/package.json +3 -2
- package/supabase.columns.ts +14 -0
- package/types.ts +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
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}`);
|
|
@@ -0,0 +1,14 @@
|
|
|
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[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
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'];
|
package/dist/types.d.ts
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
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}`);
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@periskope/types",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.45",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"ts-node": "^10.9.2",
|
|
8
9
|
"type-fest": "^4.8.3",
|
|
9
10
|
"whatsapp-web.js": "1.23.1-alpha.4"
|
|
10
11
|
},
|
|
11
12
|
"scripts": {
|
|
12
|
-
"update-package": "tsc \u0026\u0026 npm publish --access public"
|
|
13
|
+
"update-package": "npx ts-node extractColumnNames.ts \u0026\u0026 tsc \u0026\u0026 npm publish --access public"
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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'];
|