This commit is contained in:
bipproduction
2025-10-21 16:56:18 +08:00
parent f50198ced9
commit 7d5bf004da
11 changed files with 151 additions and 35 deletions

File diff suppressed because one or more lines are too long

View File

@@ -172,6 +172,8 @@ exports.Prisma.ChatFlowsScalarFieldEnum = {
active: 'active', active: 'active',
flowUrl: 'flowUrl', flowUrl: 'flowUrl',
flowToken: 'flowToken', flowToken: 'flowToken',
waPhoneNumberId: 'waPhoneNumberId',
waToken: 'waToken',
createdAt: 'createdAt', createdAt: 'createdAt',
updatedAt: 'updatedAt' updatedAt: 'updatedAt'
}; };

View File

@@ -5593,6 +5593,8 @@ export namespace Prisma {
active: boolean | null active: boolean | null
flowUrl: string | null flowUrl: string | null
flowToken: string | null flowToken: string | null
waPhoneNumberId: string | null
waToken: string | null
createdAt: Date | null createdAt: Date | null
updatedAt: Date | null updatedAt: Date | null
} }
@@ -5603,6 +5605,8 @@ export namespace Prisma {
active: boolean | null active: boolean | null
flowUrl: string | null flowUrl: string | null
flowToken: string | null flowToken: string | null
waPhoneNumberId: string | null
waToken: string | null
createdAt: Date | null createdAt: Date | null
updatedAt: Date | null updatedAt: Date | null
} }
@@ -5615,6 +5619,8 @@ export namespace Prisma {
active: number active: number
flowUrl: number flowUrl: number
flowToken: number flowToken: number
waPhoneNumberId: number
waToken: number
createdAt: number createdAt: number
updatedAt: number updatedAt: number
_all: number _all: number
@@ -5627,6 +5633,8 @@ export namespace Prisma {
active?: true active?: true
flowUrl?: true flowUrl?: true
flowToken?: true flowToken?: true
waPhoneNumberId?: true
waToken?: true
createdAt?: true createdAt?: true
updatedAt?: true updatedAt?: true
} }
@@ -5637,6 +5645,8 @@ export namespace Prisma {
active?: true active?: true
flowUrl?: true flowUrl?: true
flowToken?: true flowToken?: true
waPhoneNumberId?: true
waToken?: true
createdAt?: true createdAt?: true
updatedAt?: true updatedAt?: true
} }
@@ -5649,6 +5659,8 @@ export namespace Prisma {
active?: true active?: true
flowUrl?: true flowUrl?: true
flowToken?: true flowToken?: true
waPhoneNumberId?: true
waToken?: true
createdAt?: true createdAt?: true
updatedAt?: true updatedAt?: true
_all?: true _all?: true
@@ -5734,6 +5746,8 @@ export namespace Prisma {
active: boolean active: boolean
flowUrl: string | null flowUrl: string | null
flowToken: string | null flowToken: string | null
waPhoneNumberId: string | null
waToken: string | null
createdAt: Date createdAt: Date
updatedAt: Date updatedAt: Date
_count: ChatFlowsCountAggregateOutputType | null _count: ChatFlowsCountAggregateOutputType | null
@@ -5763,6 +5777,8 @@ export namespace Prisma {
active?: boolean active?: boolean
flowUrl?: boolean flowUrl?: boolean
flowToken?: boolean flowToken?: boolean
waPhoneNumberId?: boolean
waToken?: boolean
createdAt?: boolean createdAt?: boolean
updatedAt?: boolean updatedAt?: boolean
}, ExtArgs["result"]["chatFlows"]> }, ExtArgs["result"]["chatFlows"]>
@@ -5775,6 +5791,8 @@ export namespace Prisma {
active?: boolean active?: boolean
flowUrl?: boolean flowUrl?: boolean
flowToken?: boolean flowToken?: boolean
waPhoneNumberId?: boolean
waToken?: boolean
createdAt?: boolean createdAt?: boolean
updatedAt?: boolean updatedAt?: boolean
}, ExtArgs["result"]["chatFlows"]> }, ExtArgs["result"]["chatFlows"]>
@@ -5787,6 +5805,8 @@ export namespace Prisma {
active?: boolean active?: boolean
flowUrl?: boolean flowUrl?: boolean
flowToken?: boolean flowToken?: boolean
waPhoneNumberId?: boolean
waToken?: boolean
createdAt?: boolean createdAt?: boolean
updatedAt?: boolean updatedAt?: boolean
}, ExtArgs["result"]["chatFlows"]> }, ExtArgs["result"]["chatFlows"]>
@@ -5799,11 +5819,13 @@ export namespace Prisma {
active?: boolean active?: boolean
flowUrl?: boolean flowUrl?: boolean
flowToken?: boolean flowToken?: boolean
waPhoneNumberId?: boolean
waToken?: boolean
createdAt?: boolean createdAt?: boolean
updatedAt?: boolean updatedAt?: boolean
} }
export type ChatFlowsOmit<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = $Extensions.GetOmit<"id" | "flows" | "defaultFlow" | "defaultData" | "active" | "flowUrl" | "flowToken" | "createdAt" | "updatedAt", ExtArgs["result"]["chatFlows"]> export type ChatFlowsOmit<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = $Extensions.GetOmit<"id" | "flows" | "defaultFlow" | "defaultData" | "active" | "flowUrl" | "flowToken" | "waPhoneNumberId" | "waToken" | "createdAt" | "updatedAt", ExtArgs["result"]["chatFlows"]>
export type $ChatFlowsPayload<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = { export type $ChatFlowsPayload<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
name: "ChatFlows" name: "ChatFlows"
@@ -5816,6 +5838,8 @@ export namespace Prisma {
active: boolean active: boolean
flowUrl: string | null flowUrl: string | null
flowToken: string | null flowToken: string | null
waPhoneNumberId: string | null
waToken: string | null
createdAt: Date createdAt: Date
updatedAt: Date updatedAt: Date
}, ExtArgs["result"]["chatFlows"]> }, ExtArgs["result"]["chatFlows"]>
@@ -6248,6 +6272,8 @@ export namespace Prisma {
readonly active: FieldRef<"ChatFlows", 'Boolean'> readonly active: FieldRef<"ChatFlows", 'Boolean'>
readonly flowUrl: FieldRef<"ChatFlows", 'String'> readonly flowUrl: FieldRef<"ChatFlows", 'String'>
readonly flowToken: FieldRef<"ChatFlows", 'String'> readonly flowToken: FieldRef<"ChatFlows", 'String'>
readonly waPhoneNumberId: FieldRef<"ChatFlows", 'String'>
readonly waToken: FieldRef<"ChatFlows", 'String'>
readonly createdAt: FieldRef<"ChatFlows", 'DateTime'> readonly createdAt: FieldRef<"ChatFlows", 'DateTime'>
readonly updatedAt: FieldRef<"ChatFlows", 'DateTime'> readonly updatedAt: FieldRef<"ChatFlows", 'DateTime'>
} }
@@ -6694,6 +6720,8 @@ export namespace Prisma {
active: 'active', active: 'active',
flowUrl: 'flowUrl', flowUrl: 'flowUrl',
flowToken: 'flowToken', flowToken: 'flowToken',
waPhoneNumberId: 'waPhoneNumberId',
waToken: 'waToken',
createdAt: 'createdAt', createdAt: 'createdAt',
updatedAt: 'updatedAt' updatedAt: 'updatedAt'
}; };
@@ -7114,6 +7142,8 @@ export namespace Prisma {
active?: BoolFilter<"ChatFlows"> | boolean active?: BoolFilter<"ChatFlows"> | boolean
flowUrl?: StringNullableFilter<"ChatFlows"> | string | null flowUrl?: StringNullableFilter<"ChatFlows"> | string | null
flowToken?: StringNullableFilter<"ChatFlows"> | string | null flowToken?: StringNullableFilter<"ChatFlows"> | string | null
waPhoneNumberId?: StringNullableFilter<"ChatFlows"> | string | null
waToken?: StringNullableFilter<"ChatFlows"> | string | null
createdAt?: DateTimeFilter<"ChatFlows"> | Date | string createdAt?: DateTimeFilter<"ChatFlows"> | Date | string
updatedAt?: DateTimeFilter<"ChatFlows"> | Date | string updatedAt?: DateTimeFilter<"ChatFlows"> | Date | string
} }
@@ -7126,6 +7156,8 @@ export namespace Prisma {
active?: SortOrder active?: SortOrder
flowUrl?: SortOrderInput | SortOrder flowUrl?: SortOrderInput | SortOrder
flowToken?: SortOrderInput | SortOrder flowToken?: SortOrderInput | SortOrder
waPhoneNumberId?: SortOrderInput | SortOrder
waToken?: SortOrderInput | SortOrder
createdAt?: SortOrder createdAt?: SortOrder
updatedAt?: SortOrder updatedAt?: SortOrder
} }
@@ -7141,6 +7173,8 @@ export namespace Prisma {
defaultData?: JsonNullableFilter<"ChatFlows"> defaultData?: JsonNullableFilter<"ChatFlows">
active?: BoolFilter<"ChatFlows"> | boolean active?: BoolFilter<"ChatFlows"> | boolean
flowToken?: StringNullableFilter<"ChatFlows"> | string | null flowToken?: StringNullableFilter<"ChatFlows"> | string | null
waPhoneNumberId?: StringNullableFilter<"ChatFlows"> | string | null
waToken?: StringNullableFilter<"ChatFlows"> | string | null
createdAt?: DateTimeFilter<"ChatFlows"> | Date | string createdAt?: DateTimeFilter<"ChatFlows"> | Date | string
updatedAt?: DateTimeFilter<"ChatFlows"> | Date | string updatedAt?: DateTimeFilter<"ChatFlows"> | Date | string
}, "id" | "flowUrl"> }, "id" | "flowUrl">
@@ -7153,6 +7187,8 @@ export namespace Prisma {
active?: SortOrder active?: SortOrder
flowUrl?: SortOrderInput | SortOrder flowUrl?: SortOrderInput | SortOrder
flowToken?: SortOrderInput | SortOrder flowToken?: SortOrderInput | SortOrder
waPhoneNumberId?: SortOrderInput | SortOrder
waToken?: SortOrderInput | SortOrder
createdAt?: SortOrder createdAt?: SortOrder
updatedAt?: SortOrder updatedAt?: SortOrder
_count?: ChatFlowsCountOrderByAggregateInput _count?: ChatFlowsCountOrderByAggregateInput
@@ -7171,6 +7207,8 @@ export namespace Prisma {
active?: BoolWithAggregatesFilter<"ChatFlows"> | boolean active?: BoolWithAggregatesFilter<"ChatFlows"> | boolean
flowUrl?: StringNullableWithAggregatesFilter<"ChatFlows"> | string | null flowUrl?: StringNullableWithAggregatesFilter<"ChatFlows"> | string | null
flowToken?: StringNullableWithAggregatesFilter<"ChatFlows"> | string | null flowToken?: StringNullableWithAggregatesFilter<"ChatFlows"> | string | null
waPhoneNumberId?: StringNullableWithAggregatesFilter<"ChatFlows"> | string | null
waToken?: StringNullableWithAggregatesFilter<"ChatFlows"> | string | null
createdAt?: DateTimeWithAggregatesFilter<"ChatFlows"> | Date | string createdAt?: DateTimeWithAggregatesFilter<"ChatFlows"> | Date | string
updatedAt?: DateTimeWithAggregatesFilter<"ChatFlows"> | Date | string updatedAt?: DateTimeWithAggregatesFilter<"ChatFlows"> | Date | string
} }
@@ -7494,6 +7532,8 @@ export namespace Prisma {
active?: boolean active?: boolean
flowUrl?: string | null flowUrl?: string | null
flowToken?: string | null flowToken?: string | null
waPhoneNumberId?: string | null
waToken?: string | null
createdAt?: Date | string createdAt?: Date | string
updatedAt?: Date | string updatedAt?: Date | string
} }
@@ -7506,6 +7546,8 @@ export namespace Prisma {
active?: boolean active?: boolean
flowUrl?: string | null flowUrl?: string | null
flowToken?: string | null flowToken?: string | null
waPhoneNumberId?: string | null
waToken?: string | null
createdAt?: Date | string createdAt?: Date | string
updatedAt?: Date | string updatedAt?: Date | string
} }
@@ -7518,6 +7560,8 @@ export namespace Prisma {
active?: BoolFieldUpdateOperationsInput | boolean active?: BoolFieldUpdateOperationsInput | boolean
flowUrl?: NullableStringFieldUpdateOperationsInput | string | null flowUrl?: NullableStringFieldUpdateOperationsInput | string | null
flowToken?: NullableStringFieldUpdateOperationsInput | string | null flowToken?: NullableStringFieldUpdateOperationsInput | string | null
waPhoneNumberId?: NullableStringFieldUpdateOperationsInput | string | null
waToken?: NullableStringFieldUpdateOperationsInput | string | null
createdAt?: DateTimeFieldUpdateOperationsInput | Date | string createdAt?: DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string
} }
@@ -7530,6 +7574,8 @@ export namespace Prisma {
active?: BoolFieldUpdateOperationsInput | boolean active?: BoolFieldUpdateOperationsInput | boolean
flowUrl?: NullableStringFieldUpdateOperationsInput | string | null flowUrl?: NullableStringFieldUpdateOperationsInput | string | null
flowToken?: NullableStringFieldUpdateOperationsInput | string | null flowToken?: NullableStringFieldUpdateOperationsInput | string | null
waPhoneNumberId?: NullableStringFieldUpdateOperationsInput | string | null
waToken?: NullableStringFieldUpdateOperationsInput | string | null
createdAt?: DateTimeFieldUpdateOperationsInput | Date | string createdAt?: DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string
} }
@@ -7542,6 +7588,8 @@ export namespace Prisma {
active?: boolean active?: boolean
flowUrl?: string | null flowUrl?: string | null
flowToken?: string | null flowToken?: string | null
waPhoneNumberId?: string | null
waToken?: string | null
createdAt?: Date | string createdAt?: Date | string
updatedAt?: Date | string updatedAt?: Date | string
} }
@@ -7554,6 +7602,8 @@ export namespace Prisma {
active?: BoolFieldUpdateOperationsInput | boolean active?: BoolFieldUpdateOperationsInput | boolean
flowUrl?: NullableStringFieldUpdateOperationsInput | string | null flowUrl?: NullableStringFieldUpdateOperationsInput | string | null
flowToken?: NullableStringFieldUpdateOperationsInput | string | null flowToken?: NullableStringFieldUpdateOperationsInput | string | null
waPhoneNumberId?: NullableStringFieldUpdateOperationsInput | string | null
waToken?: NullableStringFieldUpdateOperationsInput | string | null
createdAt?: DateTimeFieldUpdateOperationsInput | Date | string createdAt?: DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string
} }
@@ -7566,6 +7616,8 @@ export namespace Prisma {
active?: BoolFieldUpdateOperationsInput | boolean active?: BoolFieldUpdateOperationsInput | boolean
flowUrl?: NullableStringFieldUpdateOperationsInput | string | null flowUrl?: NullableStringFieldUpdateOperationsInput | string | null
flowToken?: NullableStringFieldUpdateOperationsInput | string | null flowToken?: NullableStringFieldUpdateOperationsInput | string | null
waPhoneNumberId?: NullableStringFieldUpdateOperationsInput | string | null
waToken?: NullableStringFieldUpdateOperationsInput | string | null
createdAt?: DateTimeFieldUpdateOperationsInput | Date | string createdAt?: DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string
} }
@@ -7941,6 +7993,8 @@ export namespace Prisma {
active?: SortOrder active?: SortOrder
flowUrl?: SortOrder flowUrl?: SortOrder
flowToken?: SortOrder flowToken?: SortOrder
waPhoneNumberId?: SortOrder
waToken?: SortOrder
createdAt?: SortOrder createdAt?: SortOrder
updatedAt?: SortOrder updatedAt?: SortOrder
} }
@@ -7951,6 +8005,8 @@ export namespace Prisma {
active?: SortOrder active?: SortOrder
flowUrl?: SortOrder flowUrl?: SortOrder
flowToken?: SortOrder flowToken?: SortOrder
waPhoneNumberId?: SortOrder
waToken?: SortOrder
createdAt?: SortOrder createdAt?: SortOrder
updatedAt?: SortOrder updatedAt?: SortOrder
} }
@@ -7961,6 +8017,8 @@ export namespace Prisma {
active?: SortOrder active?: SortOrder
flowUrl?: SortOrder flowUrl?: SortOrder
flowToken?: SortOrder flowToken?: SortOrder
waPhoneNumberId?: SortOrder
waToken?: SortOrder
createdAt?: SortOrder createdAt?: SortOrder
updatedAt?: SortOrder updatedAt?: SortOrder
} }

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
{ {
"name": "prisma-client-0c787597671925c5dbd90480bfc5d45c3aa9b494d0bff63e2482cd62c5107b7b", "name": "prisma-client-367ce2b98f2d22a81f03cae26bb7a0a6a88cb7e151779032b6f03e46b11c7d82",
"main": "index.js", "main": "index.js",
"types": "index.d.ts", "types": "index.d.ts",
"browser": "default.js", "browser": "default.js",

View File

@@ -55,13 +55,15 @@ model WaHook {
} }
model ChatFlows { model ChatFlows {
id String @id @default(cuid()) id String @id @default(cuid())
flows Json? flows Json?
defaultFlow String? defaultFlow String?
defaultData Json? defaultData Json?
active Boolean @default(true) active Boolean @default(true)
flowUrl String? @unique flowUrl String? @unique
flowToken String? flowToken String?
createdAt DateTime @default(now()) waPhoneNumberId String?
updatedAt DateTime @updatedAt waToken String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
} }

View File

@@ -144,6 +144,8 @@ exports.Prisma.ChatFlowsScalarFieldEnum = {
active: 'active', active: 'active',
flowUrl: 'flowUrl', flowUrl: 'flowUrl',
flowToken: 'flowToken', flowToken: 'flowToken',
waPhoneNumberId: 'waPhoneNumberId',
waToken: 'waToken',
createdAt: 'createdAt', createdAt: 'createdAt',
updatedAt: 'updatedAt' updatedAt: 'updatedAt'
}; };
@@ -229,13 +231,13 @@ const config = {
} }
} }
}, },
"inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n output = \"../generated/prisma\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n\nmodel User {\n id String @id @default(cuid())\n name String?\n email String? @unique\n password String?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n ApiKey ApiKey[]\n}\n\nmodel ApiKey {\n id String @id @default(cuid())\n User User? @relation(fields: [userId], references: [id])\n userId String\n name String\n key String @unique @db.Text\n description String?\n expiredAt DateTime?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel WebHook {\n id String @id @default(cuid())\n name String?\n description String?\n url String\n payload String? @default(\"{}\")\n method String @default(\"POST\")\n headers String? @default(\"{}\")\n apiToken String?\n retries Int? @default(3)\n enabled Boolean @default(true)\n replay Boolean @default(false)\n replayKey String?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel WaHook {\n id String @id @default(cuid())\n data Json? @db.Json\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel ChatFlows {\n id String @id @default(cuid())\n flows Json?\n defaultFlow String?\n defaultData Json?\n active Boolean @default(true)\n flowUrl String? @unique\n flowToken String?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n", "inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n output = \"../generated/prisma\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n\nmodel User {\n id String @id @default(cuid())\n name String?\n email String? @unique\n password String?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n ApiKey ApiKey[]\n}\n\nmodel ApiKey {\n id String @id @default(cuid())\n User User? @relation(fields: [userId], references: [id])\n userId String\n name String\n key String @unique @db.Text\n description String?\n expiredAt DateTime?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel WebHook {\n id String @id @default(cuid())\n name String?\n description String?\n url String\n payload String? @default(\"{}\")\n method String @default(\"POST\")\n headers String? @default(\"{}\")\n apiToken String?\n retries Int? @default(3)\n enabled Boolean @default(true)\n replay Boolean @default(false)\n replayKey String?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel WaHook {\n id String @id @default(cuid())\n data Json? @db.Json\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel ChatFlows {\n id String @id @default(cuid())\n flows Json?\n defaultFlow String?\n defaultData Json?\n active Boolean @default(true)\n flowUrl String? @unique\n flowToken String?\n waPhoneNumberId String?\n waToken String?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n",
"inlineSchemaHash": "853d49417068ff1819c3dbb60ac7aeea59288f307f7939669c83fdd63bb495e3", "inlineSchemaHash": "87e5fa08d8dfb23ff2953e71db406dec620f344cf7ca8626bf267c670e09a411",
"copyEngine": true "copyEngine": true
} }
config.dirname = '/' config.dirname = '/'
config.runtimeDataModel = JSON.parse("{\"models\":{\"User\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"password\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"ApiKey\",\"kind\":\"object\",\"type\":\"ApiKey\",\"relationName\":\"ApiKeyToUser\"}],\"dbName\":null},\"ApiKey\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"User\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"ApiKeyToUser\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"key\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"expiredAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"WebHook\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"url\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"payload\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"method\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"headers\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"apiToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"retries\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"enabled\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"replay\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"replayKey\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"WaHook\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"data\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"ChatFlows\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"flows\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"defaultFlow\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"defaultData\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"active\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"flowUrl\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"flowToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null}},\"enums\":{},\"types\":{}}") config.runtimeDataModel = JSON.parse("{\"models\":{\"User\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"password\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"ApiKey\",\"kind\":\"object\",\"type\":\"ApiKey\",\"relationName\":\"ApiKeyToUser\"}],\"dbName\":null},\"ApiKey\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"User\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"ApiKeyToUser\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"key\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"expiredAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"WebHook\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"url\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"payload\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"method\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"headers\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"apiToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"retries\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"enabled\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"replay\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"replayKey\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"WaHook\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"data\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"ChatFlows\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"flows\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"defaultFlow\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"defaultData\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"active\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"flowUrl\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"flowToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"waPhoneNumberId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"waToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null}},\"enums\":{},\"types\":{}}")
defineDmmfProperty(exports.Prisma, config.runtimeDataModel) defineDmmfProperty(exports.Prisma, config.runtimeDataModel)
config.engineWasm = { config.engineWasm = {
getRuntime: async () => require('./query_engine_bg.js'), getRuntime: async () => require('./query_engine_bg.js'),

View File

@@ -55,13 +55,15 @@ model WaHook {
} }
model ChatFlows { model ChatFlows {
id String @id @default(cuid()) id String @id @default(cuid())
flows Json? flows Json?
defaultFlow String? defaultFlow String?
defaultData Json? defaultData Json?
active Boolean @default(true) active Boolean @default(true)
flowUrl String? @unique flowUrl String? @unique
flowToken String? flowToken String?
createdAt DateTime @default(now()) waPhoneNumberId String?
updatedAt DateTime @updatedAt waToken String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
} }

View File

@@ -132,6 +132,8 @@ function FlowWaHookForm() {
const [flowUrl, setFlowUrl] = useState(""); const [flowUrl, setFlowUrl] = useState("");
const [flowToken, setFlowToken] = useState(""); const [flowToken, setFlowToken] = useState("");
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [waPhoneNumberId, setWaPhoneNumberId] = useState("");
const [waToken, setWaToken] = useState("");
useShallowEffect(() => { useShallowEffect(() => {
const loadCredentials = async () => { const loadCredentials = async () => {
@@ -141,6 +143,8 @@ function FlowWaHookForm() {
} else { } else {
setFlowUrl(data?.data?.flowUrl || ""); setFlowUrl(data?.data?.flowUrl || "");
setFlowToken(data?.data?.flowToken || ""); setFlowToken(data?.data?.flowToken || "");
setWaPhoneNumberId(data?.data?.waPhoneNumberId || "");
setWaToken(data?.data?.waToken || "");
} }
}; };
loadCredentials(); loadCredentials();
@@ -152,7 +156,7 @@ function FlowWaHookForm() {
return; return;
} }
setLoading(true); setLoading(true);
const { error } = await apiFetch.api.chatflows["url-token"].put({ flowUrl, flowToken }); const { error } = await apiFetch.api.chatflows["url-token"].put({ flowUrl, flowToken, waPhoneNumberId, waToken });
if (error) { if (error) {
showNotification({ title: "Error", message: "Failed to update credentials", color: "red" }); showNotification({ title: "Error", message: "Failed to update credentials", color: "red" });
} else { } else {
@@ -184,6 +188,21 @@ function FlowWaHookForm() {
} }
/> />
</Stack> </Stack>
<Title order={3}>WhatsApp Credentials</Title>
<Stack gap="md">
<TextInput label="WhatsApp Phone Number ID" placeholder="Enter WhatsApp Phone Number ID" value={waPhoneNumberId} onChange={(e) => setWaPhoneNumberId(e.currentTarget.value)} />
<PasswordInput
label="WhatsApp Token"
placeholder="Enter WhatsApp Token"
value={waToken}
onChange={(e) => setWaToken(e.currentTarget.value)}
rightSection={
<ActionIcon onClick={copyToken}>
<IconCopy size={16} />
</ActionIcon>
}
/>
</Stack>
<Group justify="flex-end"> <Group justify="flex-end">
<Button leftSection={<IconCheck size={16} />} onClick={saveCredentials} loading={loading}> <Button leftSection={<IconCheck size={16} />} onClick={saveCredentials} loading={loading}>
Save Changes Save Changes

View File

@@ -157,12 +157,14 @@ const FlowRoute = new Elysia({
select: { select: {
flowUrl: true, flowUrl: true,
flowToken: true, flowToken: true,
waPhoneNumberId: true,
waToken: true,
}, },
}) })
if (!result) { if (!result) {
return { data: { flowUrl: null, flowToken: null } } return { data: { flowUrl: null, flowToken: null, waPhoneNumberId: null, waToken: null } }
} }
return { data: { flowUrl: result.flowUrl, flowToken: result.flowToken } } return { data: { flowUrl: result.flowUrl, flowToken: result.flowToken, waPhoneNumberId: result.waPhoneNumberId, waToken: result.waToken } }
}, { }, {
detail: { detail: {
summary: "Get flow url and token", summary: "Get flow url and token",
@@ -172,7 +174,7 @@ const FlowRoute = new Elysia({
.put( .put(
'/url-token', '/url-token',
async ctx => { async ctx => {
const { flowUrl, flowToken } = ctx.body const { flowUrl, flowToken, waPhoneNumberId, waToken } = ctx.body
const result = await prisma.chatFlows.upsert({ const result = await prisma.chatFlows.upsert({
where: { where: {
id: "1", id: "1",
@@ -180,11 +182,15 @@ const FlowRoute = new Elysia({
update: { update: {
flowUrl: flowUrl, flowUrl: flowUrl,
flowToken: flowToken, flowToken: flowToken,
waPhoneNumberId: waPhoneNumberId,
waToken: waToken,
}, },
create: { create: {
id: "1", id: "1",
flowUrl: flowUrl, flowUrl: flowUrl,
flowToken: flowToken, flowToken: flowToken,
waPhoneNumberId: waPhoneNumberId,
waToken: waToken,
}, },
}) })
return { data: result } return { data: result }
@@ -193,6 +199,8 @@ const FlowRoute = new Elysia({
body: t.Object({ body: t.Object({
flowUrl: t.String(), flowUrl: t.String(),
flowToken: t.String(), flowToken: t.String(),
waPhoneNumberId: t.String(),
waToken: t.String(),
}), }),
detail: { detail: {
summary: "Update flow url and token", summary: "Update flow url and token",

View File

@@ -2,7 +2,6 @@ import Elysia, { t } from "elysia";
import { prisma } from "../lib/prisma"; import { prisma } from "../lib/prisma";
import type { WAHookMessage } from "types/wa_messages"; import type { WAHookMessage } from "types/wa_messages";
import _ from "lodash"; import _ from "lodash";
import dayjs from "dayjs";
async function fetchWithTimeout(input: RequestInfo, init: RequestInit, timeoutMs = 120_000) { async function fetchWithTimeout(input: RequestInfo, init: RequestInit, timeoutMs = 120_000) {
const controller = new AbortController() const controller = new AbortController()
@@ -14,6 +13,22 @@ async function fetchWithTimeout(input: RequestInfo, init: RequestInit, timeoutMs
} }
} }
async function sendReplyMessage(to: string, message: string, phoneNumberId: string, token: string) {
return await fetch(`https://graph.facebook.com/v21.0/${phoneNumberId}/messages`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({
messaging_product: "whatsapp",
to,
text: { body: message }
})
});
}
const WaHookRoute = new Elysia({ const WaHookRoute = new Elysia({
prefix: "/wa-hook", prefix: "/wa-hook",
tags: ["WhatsApp Hook"], tags: ["WhatsApp Hook"],
@@ -118,7 +133,11 @@ const WaHookRoute = new Elysia({
data: createData, data: createData,
}, },
}) })
if (flow?.waPhoneNumberId && flow?.waToken && number) {
await sendReplyMessage(number, result.text, flow.waPhoneNumberId, flow.waToken)
}
} catch (error) { } catch (error) {
console.log(error) console.log(error)
console.log(responseText) console.log(responseText)