Add bridge-whatsapp

This commit is contained in:
Darren Clarke 2024-05-07 14:16:01 +02:00
parent 0d09ad1b7e
commit 0499287555
21 changed files with 3485 additions and 47 deletions

View file

@ -42,7 +42,7 @@ export const migrate = async (arg: string) => {
}),
});
let error = null;
let error: any = null;
let results: MigrationResult[] = [];
if (arg === "up:all") {

View file

@ -11,10 +11,8 @@ export async function up(db: Kysely<any>): Promise<void> {
.addColumn("user_id", "uuid")
.addColumn("name", "text")
.addColumn("description", "text")
.addColumn("auth_info", "text")
.addColumn("is_verified", "boolean", (col) =>
col.notNull().defaultTo(false),
)
.addColumn("qr_code", "text")
.addColumn("verified", "boolean", (col) => col.notNull().defaultTo(false))
.addColumn("created_at", "timestamptz", (col) =>
col.notNull().defaultTo(sql`now()`),
)

View file

@ -15,9 +15,7 @@ export async function up(db: Kysely<any>): Promise<void> {
.addColumn("page_id", "text")
.addColumn("app_id", "text")
.addColumn("user_id", "uuid")
.addColumn("is_verified", "boolean", (col) =>
col.notNull().defaultTo(false),
)
.addColumn("verified", "boolean", (col) => col.notNull().defaultTo(false))
.addColumn("created_at", "timestamptz", (col) =>
col.notNull().defaultTo(sql`now()`),
)

View file

@ -1,2 +1,11 @@
export { db, type Database } from "./lib/database";
export { db } from "./lib/database";
export type {
Database,
FacebookBot,
SignalBot,
WhatsappBot,
VoiceLine,
Webhook,
User,
} from "./lib/database";
export { getWorkerUtils } from "./lib/utils";

View file

@ -4,8 +4,6 @@ import type {
Generated,
ColumnType,
Selectable,
Insertable,
Updateable,
} from "kysely";
import pg from "pg";
import { KyselyAuth } from "@auth/kysely-adapter";
@ -72,6 +70,10 @@ export interface Database {
name: string;
description: string;
phoneNumber: string;
token: string;
qrCode: string;
verified: boolean;
userId: string;
createdBy: string;
createdAt: Date;
updatedAt: Date;
@ -88,7 +90,7 @@ export interface Database {
pageId: string | null;
appId: string | null;
userId: string | null;
isVerified: Generated<boolean>;
verified: Generated<boolean>;
createdAt: GeneratedAlways<Timestamp>;
updatedAt: GeneratedAlways<Timestamp>;
};

View file

@ -1,12 +1,16 @@
{
"name": "bridge-common",
"version": "1.0.0",
"main": "index.js",
"main": "build/main/index.js",
"type": "module",
"author": "Darren Clarke <darren@redaranj.com>",
"license": "AGPL-3.0-or-later",
"scripts": {
"build": "tsc -p tsconfig.json"
"build": "tsc -p tsconfig.json",
"migrate:up:all": "tsx database/migrate.ts up:all",
"migrate:up:one": "tsx database/migrate.ts up:one",
"migrate:down:all": "tsx database/migrate.ts down:all",
"migrate:down:one": "tsx database/migrate.ts down:one"
},
"dependencies": {
"@auth/kysely-adapter": "^1.0.0",
@ -20,6 +24,7 @@
"eslint": "^9.0.0",
"prettier": "^3.2.5",
"ts-config": "*",
"tsx": "^4.9.3",
"typescript": "^5.4.5"
}
}

View file

@ -1,29 +1,12 @@
{
"extends": "ts-config",
"compilerOptions": {
"target": "esnext",
"lib": ["esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"outDir": "build/main",
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"baseUrl": ".",
"paths": {
"@/*": ["./*", "../../node_modules/*"]
},
"plugins": [
{
"name": "next"
}
]
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["**.d.ts", "**/*.ts", "**/*.tsx", "**/*.png, **/*.svg"],
"exclude": ["node_modules", "babel__core"]
"include": ["**/*.ts", "**/.*.ts"],
"exclude": ["node_modules", "build", "database"]
}

File diff suppressed because one or more lines are too long