diff --git a/generated/prisma/edge.js b/generated/prisma/edge.js index ed936f2..f2365ad 100644 --- a/generated/prisma/edge.js +++ b/generated/prisma/edge.js @@ -136,6 +136,18 @@ exports.Prisma.WaHookScalarFieldEnum = { updatedAt: 'updatedAt' }; +exports.Prisma.ChatFlowsScalarFieldEnum = { + id: 'id', + flows: 'flows', + defaultFlow: 'defaultFlow', + defaultData: 'defaultData', + active: 'active', + flowUrl: 'flowUrl', + flowToken: 'flowToken', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +}; + exports.Prisma.SortOrder = { asc: 'asc', desc: 'desc' @@ -167,7 +179,8 @@ exports.Prisma.ModelName = { User: 'User', ApiKey: 'ApiKey', WebHook: 'WebHook', - WaHook: 'WaHook' + WaHook: 'WaHook', + ChatFlows: 'ChatFlows' }; /** * Create the Client @@ -216,13 +229,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", - "inlineSchemaHash": "f672201c199f0f043f3266324775af184d82ebd00379f5c23166510b25c889d0", + "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", + "inlineSchemaHash": "853d49417068ff1819c3dbb60ac7aeea59288f307f7939669c83fdd63bb495e3", "copyEngine": true } config.dirname = '/' -config.runtimeDataModel = JSON.parse("{\"models\":{\"User\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"name\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"email\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"password\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true},{\"name\":\"ApiKey\",\"kind\":\"object\",\"isList\":true,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"ApiKey\",\"nativeType\":null,\"relationName\":\"ApiKeyToUser\",\"relationFromFields\":[],\"relationToFields\":[],\"isGenerated\":false,\"isUpdatedAt\":false}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"ApiKey\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"User\",\"kind\":\"object\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"User\",\"nativeType\":null,\"relationName\":\"ApiKeyToUser\",\"relationFromFields\":[\"userId\"],\"relationToFields\":[\"id\"],\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"userId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":true,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"name\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"key\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":[\"Text\",[]],\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"description\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"expiredAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"WebHook\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"name\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"description\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"url\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"payload\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":\"{}\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"method\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":\"POST\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"headers\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":\"{}\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"apiToken\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"retries\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Int\",\"nativeType\":null,\"default\":3,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"enabled\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"nativeType\":null,\"default\":true,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"replay\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"nativeType\":null,\"default\":false,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"replayKey\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"WaHook\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"data\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Json\",\"nativeType\":[\"Json\",[]],\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false}},\"enums\":{},\"types\":{}}") +config.runtimeDataModel = JSON.parse("{\"models\":{\"User\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"name\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"email\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"password\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true},{\"name\":\"ApiKey\",\"kind\":\"object\",\"isList\":true,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"ApiKey\",\"nativeType\":null,\"relationName\":\"ApiKeyToUser\",\"relationFromFields\":[],\"relationToFields\":[],\"isGenerated\":false,\"isUpdatedAt\":false}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"ApiKey\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"User\",\"kind\":\"object\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"User\",\"nativeType\":null,\"relationName\":\"ApiKeyToUser\",\"relationFromFields\":[\"userId\"],\"relationToFields\":[\"id\"],\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"userId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":true,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"name\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"key\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":[\"Text\",[]],\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"description\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"expiredAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"WebHook\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"name\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"description\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"url\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"payload\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":\"{}\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"method\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":\"POST\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"headers\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":\"{}\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"apiToken\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"retries\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Int\",\"nativeType\":null,\"default\":3,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"enabled\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"nativeType\":null,\"default\":true,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"replay\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"nativeType\":null,\"default\":false,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"replayKey\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"WaHook\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"data\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Json\",\"nativeType\":[\"Json\",[]],\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"ChatFlows\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"flows\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Json\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"defaultFlow\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"defaultData\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Json\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"active\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"nativeType\":null,\"default\":true,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"flowUrl\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"flowToken\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false}},\"enums\":{},\"types\":{}}") defineDmmfProperty(exports.Prisma, config.runtimeDataModel) config.engineWasm = undefined config.compilerWasm = undefined diff --git a/generated/prisma/index-browser.js b/generated/prisma/index-browser.js index 16e208b..50d59a2 100644 --- a/generated/prisma/index-browser.js +++ b/generated/prisma/index-browser.js @@ -164,6 +164,18 @@ exports.Prisma.WaHookScalarFieldEnum = { updatedAt: 'updatedAt' }; +exports.Prisma.ChatFlowsScalarFieldEnum = { + id: 'id', + flows: 'flows', + defaultFlow: 'defaultFlow', + defaultData: 'defaultData', + active: 'active', + flowUrl: 'flowUrl', + flowToken: 'flowToken', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +}; + exports.Prisma.SortOrder = { asc: 'asc', desc: 'desc' @@ -195,7 +207,8 @@ exports.Prisma.ModelName = { User: 'User', ApiKey: 'ApiKey', WebHook: 'WebHook', - WaHook: 'WaHook' + WaHook: 'WaHook', + ChatFlows: 'ChatFlows' }; /** diff --git a/generated/prisma/index.d.ts b/generated/prisma/index.d.ts index d1682dd..26de402 100644 --- a/generated/prisma/index.d.ts +++ b/generated/prisma/index.d.ts @@ -33,6 +33,11 @@ export type WebHook = $Result.DefaultSelection * */ export type WaHook = $Result.DefaultSelection +/** + * Model ChatFlows + * + */ +export type ChatFlows = $Result.DefaultSelection /** * ## Prisma Client ʲˢ @@ -191,6 +196,16 @@ export class PrismaClient< * ``` */ get waHook(): Prisma.WaHookDelegate; + + /** + * `prisma.chatFlows`: Exposes CRUD operations for the **ChatFlows** model. + * Example usage: + * ```ts + * // Fetch zero or more ChatFlows + * const chatFlows = await prisma.chatFlows.findMany() + * ``` + */ + get chatFlows(): Prisma.ChatFlowsDelegate; } export namespace Prisma { @@ -634,7 +649,8 @@ export namespace Prisma { User: 'User', ApiKey: 'ApiKey', WebHook: 'WebHook', - WaHook: 'WaHook' + WaHook: 'WaHook', + ChatFlows: 'ChatFlows' }; export type ModelName = (typeof ModelName)[keyof typeof ModelName] @@ -653,7 +669,7 @@ export namespace Prisma { omit: GlobalOmitOptions } meta: { - modelProps: "user" | "apiKey" | "webHook" | "waHook" + modelProps: "user" | "apiKey" | "webHook" | "waHook" | "chatFlows" txIsolationLevel: Prisma.TransactionIsolationLevel } model: { @@ -953,6 +969,80 @@ export namespace Prisma { } } } + ChatFlows: { + payload: Prisma.$ChatFlowsPayload + fields: Prisma.ChatFlowsFieldRefs + operations: { + findUnique: { + args: Prisma.ChatFlowsFindUniqueArgs + result: $Utils.PayloadToResult | null + } + findUniqueOrThrow: { + args: Prisma.ChatFlowsFindUniqueOrThrowArgs + result: $Utils.PayloadToResult + } + findFirst: { + args: Prisma.ChatFlowsFindFirstArgs + result: $Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.ChatFlowsFindFirstOrThrowArgs + result: $Utils.PayloadToResult + } + findMany: { + args: Prisma.ChatFlowsFindManyArgs + result: $Utils.PayloadToResult[] + } + create: { + args: Prisma.ChatFlowsCreateArgs + result: $Utils.PayloadToResult + } + createMany: { + args: Prisma.ChatFlowsCreateManyArgs + result: BatchPayload + } + createManyAndReturn: { + args: Prisma.ChatFlowsCreateManyAndReturnArgs + result: $Utils.PayloadToResult[] + } + delete: { + args: Prisma.ChatFlowsDeleteArgs + result: $Utils.PayloadToResult + } + update: { + args: Prisma.ChatFlowsUpdateArgs + result: $Utils.PayloadToResult + } + deleteMany: { + args: Prisma.ChatFlowsDeleteManyArgs + result: BatchPayload + } + updateMany: { + args: Prisma.ChatFlowsUpdateManyArgs + result: BatchPayload + } + updateManyAndReturn: { + args: Prisma.ChatFlowsUpdateManyAndReturnArgs + result: $Utils.PayloadToResult[] + } + upsert: { + args: Prisma.ChatFlowsUpsertArgs + result: $Utils.PayloadToResult + } + aggregate: { + args: Prisma.ChatFlowsAggregateArgs + result: $Utils.Optional + } + groupBy: { + args: Prisma.ChatFlowsGroupByArgs + result: $Utils.Optional[] + } + count: { + args: Prisma.ChatFlowsCountArgs + result: $Utils.Optional | number + } + } + } } } & { other: { @@ -1053,6 +1143,7 @@ export namespace Prisma { apiKey?: ApiKeyOmit webHook?: WebHookOmit waHook?: WaHookOmit + chatFlows?: ChatFlowsOmit } /* Types for Logging */ @@ -5486,6 +5577,1045 @@ export namespace Prisma { } + /** + * Model ChatFlows + */ + + export type AggregateChatFlows = { + _count: ChatFlowsCountAggregateOutputType | null + _min: ChatFlowsMinAggregateOutputType | null + _max: ChatFlowsMaxAggregateOutputType | null + } + + export type ChatFlowsMinAggregateOutputType = { + id: string | null + defaultFlow: string | null + active: boolean | null + flowUrl: string | null + flowToken: string | null + createdAt: Date | null + updatedAt: Date | null + } + + export type ChatFlowsMaxAggregateOutputType = { + id: string | null + defaultFlow: string | null + active: boolean | null + flowUrl: string | null + flowToken: string | null + createdAt: Date | null + updatedAt: Date | null + } + + export type ChatFlowsCountAggregateOutputType = { + id: number + flows: number + defaultFlow: number + defaultData: number + active: number + flowUrl: number + flowToken: number + createdAt: number + updatedAt: number + _all: number + } + + + export type ChatFlowsMinAggregateInputType = { + id?: true + defaultFlow?: true + active?: true + flowUrl?: true + flowToken?: true + createdAt?: true + updatedAt?: true + } + + export type ChatFlowsMaxAggregateInputType = { + id?: true + defaultFlow?: true + active?: true + flowUrl?: true + flowToken?: true + createdAt?: true + updatedAt?: true + } + + export type ChatFlowsCountAggregateInputType = { + id?: true + flows?: true + defaultFlow?: true + defaultData?: true + active?: true + flowUrl?: true + flowToken?: true + createdAt?: true + updatedAt?: true + _all?: true + } + + export type ChatFlowsAggregateArgs = { + /** + * Filter which ChatFlows to aggregate. + */ + where?: ChatFlowsWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of ChatFlows to fetch. + */ + orderBy?: ChatFlowsOrderByWithRelationInput | ChatFlowsOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + */ + cursor?: ChatFlowsWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` ChatFlows from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` ChatFlows. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned ChatFlows + **/ + _count?: true | ChatFlowsCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: ChatFlowsMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: ChatFlowsMaxAggregateInputType + } + + export type GetChatFlowsAggregateType = { + [P in keyof T & keyof AggregateChatFlows]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : GetScalarType + : GetScalarType + } + + + + + export type ChatFlowsGroupByArgs = { + where?: ChatFlowsWhereInput + orderBy?: ChatFlowsOrderByWithAggregationInput | ChatFlowsOrderByWithAggregationInput[] + by: ChatFlowsScalarFieldEnum[] | ChatFlowsScalarFieldEnum + having?: ChatFlowsScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: ChatFlowsCountAggregateInputType | true + _min?: ChatFlowsMinAggregateInputType + _max?: ChatFlowsMaxAggregateInputType + } + + export type ChatFlowsGroupByOutputType = { + id: string + flows: JsonValue | null + defaultFlow: string | null + defaultData: JsonValue | null + active: boolean + flowUrl: string | null + flowToken: string | null + createdAt: Date + updatedAt: Date + _count: ChatFlowsCountAggregateOutputType | null + _min: ChatFlowsMinAggregateOutputType | null + _max: ChatFlowsMaxAggregateOutputType | null + } + + type GetChatFlowsGroupByPayload = Prisma.PrismaPromise< + Array< + PickEnumerable & + { + [P in ((keyof T) & (keyof ChatFlowsGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : GetScalarType + : GetScalarType + } + > + > + + + export type ChatFlowsSelect = $Extensions.GetSelect<{ + id?: boolean + flows?: boolean + defaultFlow?: boolean + defaultData?: boolean + active?: boolean + flowUrl?: boolean + flowToken?: boolean + createdAt?: boolean + updatedAt?: boolean + }, ExtArgs["result"]["chatFlows"]> + + export type ChatFlowsSelectCreateManyAndReturn = $Extensions.GetSelect<{ + id?: boolean + flows?: boolean + defaultFlow?: boolean + defaultData?: boolean + active?: boolean + flowUrl?: boolean + flowToken?: boolean + createdAt?: boolean + updatedAt?: boolean + }, ExtArgs["result"]["chatFlows"]> + + export type ChatFlowsSelectUpdateManyAndReturn = $Extensions.GetSelect<{ + id?: boolean + flows?: boolean + defaultFlow?: boolean + defaultData?: boolean + active?: boolean + flowUrl?: boolean + flowToken?: boolean + createdAt?: boolean + updatedAt?: boolean + }, ExtArgs["result"]["chatFlows"]> + + export type ChatFlowsSelectScalar = { + id?: boolean + flows?: boolean + defaultFlow?: boolean + defaultData?: boolean + active?: boolean + flowUrl?: boolean + flowToken?: boolean + createdAt?: boolean + updatedAt?: boolean + } + + export type ChatFlowsOmit = $Extensions.GetOmit<"id" | "flows" | "defaultFlow" | "defaultData" | "active" | "flowUrl" | "flowToken" | "createdAt" | "updatedAt", ExtArgs["result"]["chatFlows"]> + + export type $ChatFlowsPayload = { + name: "ChatFlows" + objects: {} + scalars: $Extensions.GetPayloadResult<{ + id: string + flows: Prisma.JsonValue | null + defaultFlow: string | null + defaultData: Prisma.JsonValue | null + active: boolean + flowUrl: string | null + flowToken: string | null + createdAt: Date + updatedAt: Date + }, ExtArgs["result"]["chatFlows"]> + composites: {} + } + + type ChatFlowsGetPayload = $Result.GetResult + + type ChatFlowsCountArgs = + Omit & { + select?: ChatFlowsCountAggregateInputType | true + } + + export interface ChatFlowsDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['ChatFlows'], meta: { name: 'ChatFlows' } } + /** + * Find zero or one ChatFlows that matches the filter. + * @param {ChatFlowsFindUniqueArgs} args - Arguments to find a ChatFlows + * @example + * // Get one ChatFlows + * const chatFlows = await prisma.chatFlows.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUnique(args: SelectSubset>): Prisma__ChatFlowsClient<$Result.GetResult, T, "findUnique", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find one ChatFlows that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {ChatFlowsFindUniqueOrThrowArgs} args - Arguments to find a ChatFlows + * @example + * // Get one ChatFlows + * const chatFlows = await prisma.chatFlows.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUniqueOrThrow(args: SelectSubset>): Prisma__ChatFlowsClient<$Result.GetResult, T, "findUniqueOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find the first ChatFlows that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {ChatFlowsFindFirstArgs} args - Arguments to find a ChatFlows + * @example + * // Get one ChatFlows + * const chatFlows = await prisma.chatFlows.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirst(args?: SelectSubset>): Prisma__ChatFlowsClient<$Result.GetResult, T, "findFirst", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find the first ChatFlows that matches the filter or + * throw `PrismaKnownClientError` with `P2025` code if no matches were found. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {ChatFlowsFindFirstOrThrowArgs} args - Arguments to find a ChatFlows + * @example + * // Get one ChatFlows + * const chatFlows = await prisma.chatFlows.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirstOrThrow(args?: SelectSubset>): Prisma__ChatFlowsClient<$Result.GetResult, T, "findFirstOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find zero or more ChatFlows that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {ChatFlowsFindManyArgs} args - Arguments to filter and select certain fields only. + * @example + * // Get all ChatFlows + * const chatFlows = await prisma.chatFlows.findMany() + * + * // Get first 10 ChatFlows + * const chatFlows = await prisma.chatFlows.findMany({ take: 10 }) + * + * // Only select the `id` + * const chatFlowsWithIdOnly = await prisma.chatFlows.findMany({ select: { id: true } }) + * + */ + findMany(args?: SelectSubset>): Prisma.PrismaPromise<$Result.GetResult, T, "findMany", GlobalOmitOptions>> + + /** + * Create a ChatFlows. + * @param {ChatFlowsCreateArgs} args - Arguments to create a ChatFlows. + * @example + * // Create one ChatFlows + * const ChatFlows = await prisma.chatFlows.create({ + * data: { + * // ... data to create a ChatFlows + * } + * }) + * + */ + create(args: SelectSubset>): Prisma__ChatFlowsClient<$Result.GetResult, T, "create", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Create many ChatFlows. + * @param {ChatFlowsCreateManyArgs} args - Arguments to create many ChatFlows. + * @example + * // Create many ChatFlows + * const chatFlows = await prisma.chatFlows.createMany({ + * data: [ + * // ... provide data here + * ] + * }) + * + */ + createMany(args?: SelectSubset>): Prisma.PrismaPromise + + /** + * Create many ChatFlows and returns the data saved in the database. + * @param {ChatFlowsCreateManyAndReturnArgs} args - Arguments to create many ChatFlows. + * @example + * // Create many ChatFlows + * const chatFlows = await prisma.chatFlows.createManyAndReturn({ + * data: [ + * // ... provide data here + * ] + * }) + * + * // Create many ChatFlows and only return the `id` + * const chatFlowsWithIdOnly = await prisma.chatFlows.createManyAndReturn({ + * select: { id: true }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + createManyAndReturn(args?: SelectSubset>): Prisma.PrismaPromise<$Result.GetResult, T, "createManyAndReturn", GlobalOmitOptions>> + + /** + * Delete a ChatFlows. + * @param {ChatFlowsDeleteArgs} args - Arguments to delete one ChatFlows. + * @example + * // Delete one ChatFlows + * const ChatFlows = await prisma.chatFlows.delete({ + * where: { + * // ... filter to delete one ChatFlows + * } + * }) + * + */ + delete(args: SelectSubset>): Prisma__ChatFlowsClient<$Result.GetResult, T, "delete", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Update one ChatFlows. + * @param {ChatFlowsUpdateArgs} args - Arguments to update one ChatFlows. + * @example + * // Update one ChatFlows + * const chatFlows = await prisma.chatFlows.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + update(args: SelectSubset>): Prisma__ChatFlowsClient<$Result.GetResult, T, "update", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Delete zero or more ChatFlows. + * @param {ChatFlowsDeleteManyArgs} args - Arguments to filter ChatFlows to delete. + * @example + * // Delete a few ChatFlows + * const { count } = await prisma.chatFlows.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + */ + deleteMany(args?: SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more ChatFlows. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {ChatFlowsUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many ChatFlows + * const chatFlows = await prisma.chatFlows.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + updateMany(args: SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more ChatFlows and returns the data updated in the database. + * @param {ChatFlowsUpdateManyAndReturnArgs} args - Arguments to update many ChatFlows. + * @example + * // Update many ChatFlows + * const chatFlows = await prisma.chatFlows.updateManyAndReturn({ + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * + * // Update zero or more ChatFlows and only return the `id` + * const chatFlowsWithIdOnly = await prisma.chatFlows.updateManyAndReturn({ + * select: { id: true }, + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + updateManyAndReturn(args: SelectSubset>): Prisma.PrismaPromise<$Result.GetResult, T, "updateManyAndReturn", GlobalOmitOptions>> + + /** + * Create or update one ChatFlows. + * @param {ChatFlowsUpsertArgs} args - Arguments to update or create a ChatFlows. + * @example + * // Update or create a ChatFlows + * const chatFlows = await prisma.chatFlows.upsert({ + * create: { + * // ... data to create a ChatFlows + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the ChatFlows we want to update + * } + * }) + */ + upsert(args: SelectSubset>): Prisma__ChatFlowsClient<$Result.GetResult, T, "upsert", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + + /** + * Count the number of ChatFlows. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {ChatFlowsCountArgs} args - Arguments to filter ChatFlows to count. + * @example + * // Count the number of ChatFlows + * const count = await prisma.chatFlows.count({ + * where: { + * // ... the filter for the ChatFlows we want to count + * } + * }) + **/ + count( + args?: Subset, + ): Prisma.PrismaPromise< + T extends $Utils.Record<'select', any> + ? T['select'] extends true + ? number + : GetScalarType + : number + > + + /** + * Allows you to perform aggregations operations on a ChatFlows. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {ChatFlowsAggregateArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * _avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ + aggregate(args: Subset): Prisma.PrismaPromise> + + /** + * Group by ChatFlows. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {ChatFlowsGroupByArgs} args - Group by arguments. + * @example + * // Group by city, order by createdAt, get count + * const result = await prisma.user.groupBy({ + * by: ['city', 'createdAt'], + * orderBy: { + * createdAt: true + * }, + * _count: { + * _all: true + * }, + * }) + * + **/ + groupBy< + T extends ChatFlowsGroupByArgs, + HasSelectOrTake extends Or< + Extends<'skip', Keys>, + Extends<'take', Keys> + >, + OrderByArg extends True extends HasSelectOrTake + ? { orderBy: ChatFlowsGroupByArgs['orderBy'] } + : { orderBy?: ChatFlowsGroupByArgs['orderBy'] }, + OrderFields extends ExcludeUnderscoreKeys>>, + ByFields extends MaybeTupleToUnion, + ByValid extends Has, + HavingFields extends GetHavingFields, + HavingValid extends Has, + ByEmpty extends T['by'] extends never[] ? True : False, + InputErrors extends ByEmpty extends True + ? `Error: "by" must not be empty.` + : HavingValid extends False + ? { + [P in HavingFields]: P extends ByFields + ? never + : P extends string + ? `Error: Field "${P}" used in "having" needs to be provided in "by".` + : [ + Error, + 'Field ', + P, + ` in "having" needs to be provided in "by"`, + ] + }[HavingFields] + : 'take' extends Keys + ? 'orderBy' extends Keys + ? ByValid extends True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "take", you also need to provide "orderBy"' + : 'skip' extends Keys + ? 'orderBy' extends Keys + ? ByValid extends True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "skip", you also need to provide "orderBy"' + : ByValid extends True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + >(args: SubsetIntersection & InputErrors): {} extends InputErrors ? GetChatFlowsGroupByPayload : Prisma.PrismaPromise + /** + * Fields of the ChatFlows model + */ + readonly fields: ChatFlowsFieldRefs; + } + + /** + * The delegate class that acts as a "Promise-like" for ChatFlows. + * Why is this prefixed with `Prisma__`? + * Because we want to prevent naming conflicts as mentioned in + * https://github.com/prisma/prisma-client-js/issues/707 + */ + export interface Prisma__ChatFlowsClient extends Prisma.PrismaPromise { + readonly [Symbol.toStringTag]: "PrismaPromise" + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): $Utils.JsPromise + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): $Utils.JsPromise + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The + * resolved value cannot be modified from the callback. + * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @returns A Promise for the completion of the callback. + */ + finally(onfinally?: (() => void) | undefined | null): $Utils.JsPromise + } + + + + + /** + * Fields of the ChatFlows model + */ + interface ChatFlowsFieldRefs { + readonly id: FieldRef<"ChatFlows", 'String'> + readonly flows: FieldRef<"ChatFlows", 'Json'> + readonly defaultFlow: FieldRef<"ChatFlows", 'String'> + readonly defaultData: FieldRef<"ChatFlows", 'Json'> + readonly active: FieldRef<"ChatFlows", 'Boolean'> + readonly flowUrl: FieldRef<"ChatFlows", 'String'> + readonly flowToken: FieldRef<"ChatFlows", 'String'> + readonly createdAt: FieldRef<"ChatFlows", 'DateTime'> + readonly updatedAt: FieldRef<"ChatFlows", 'DateTime'> + } + + + // Custom InputTypes + /** + * ChatFlows findUnique + */ + export type ChatFlowsFindUniqueArgs = { + /** + * Select specific fields to fetch from the ChatFlows + */ + select?: ChatFlowsSelect | null + /** + * Omit specific fields from the ChatFlows + */ + omit?: ChatFlowsOmit | null + /** + * Filter, which ChatFlows to fetch. + */ + where: ChatFlowsWhereUniqueInput + } + + /** + * ChatFlows findUniqueOrThrow + */ + export type ChatFlowsFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the ChatFlows + */ + select?: ChatFlowsSelect | null + /** + * Omit specific fields from the ChatFlows + */ + omit?: ChatFlowsOmit | null + /** + * Filter, which ChatFlows to fetch. + */ + where: ChatFlowsWhereUniqueInput + } + + /** + * ChatFlows findFirst + */ + export type ChatFlowsFindFirstArgs = { + /** + * Select specific fields to fetch from the ChatFlows + */ + select?: ChatFlowsSelect | null + /** + * Omit specific fields from the ChatFlows + */ + omit?: ChatFlowsOmit | null + /** + * Filter, which ChatFlows to fetch. + */ + where?: ChatFlowsWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of ChatFlows to fetch. + */ + orderBy?: ChatFlowsOrderByWithRelationInput | ChatFlowsOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for ChatFlows. + */ + cursor?: ChatFlowsWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` ChatFlows from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` ChatFlows. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of ChatFlows. + */ + distinct?: ChatFlowsScalarFieldEnum | ChatFlowsScalarFieldEnum[] + } + + /** + * ChatFlows findFirstOrThrow + */ + export type ChatFlowsFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the ChatFlows + */ + select?: ChatFlowsSelect | null + /** + * Omit specific fields from the ChatFlows + */ + omit?: ChatFlowsOmit | null + /** + * Filter, which ChatFlows to fetch. + */ + where?: ChatFlowsWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of ChatFlows to fetch. + */ + orderBy?: ChatFlowsOrderByWithRelationInput | ChatFlowsOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for ChatFlows. + */ + cursor?: ChatFlowsWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` ChatFlows from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` ChatFlows. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of ChatFlows. + */ + distinct?: ChatFlowsScalarFieldEnum | ChatFlowsScalarFieldEnum[] + } + + /** + * ChatFlows findMany + */ + export type ChatFlowsFindManyArgs = { + /** + * Select specific fields to fetch from the ChatFlows + */ + select?: ChatFlowsSelect | null + /** + * Omit specific fields from the ChatFlows + */ + omit?: ChatFlowsOmit | null + /** + * Filter, which ChatFlows to fetch. + */ + where?: ChatFlowsWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of ChatFlows to fetch. + */ + orderBy?: ChatFlowsOrderByWithRelationInput | ChatFlowsOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing ChatFlows. + */ + cursor?: ChatFlowsWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` ChatFlows from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` ChatFlows. + */ + skip?: number + distinct?: ChatFlowsScalarFieldEnum | ChatFlowsScalarFieldEnum[] + } + + /** + * ChatFlows create + */ + export type ChatFlowsCreateArgs = { + /** + * Select specific fields to fetch from the ChatFlows + */ + select?: ChatFlowsSelect | null + /** + * Omit specific fields from the ChatFlows + */ + omit?: ChatFlowsOmit | null + /** + * The data needed to create a ChatFlows. + */ + data: XOR + } + + /** + * ChatFlows createMany + */ + export type ChatFlowsCreateManyArgs = { + /** + * The data used to create many ChatFlows. + */ + data: ChatFlowsCreateManyInput | ChatFlowsCreateManyInput[] + skipDuplicates?: boolean + } + + /** + * ChatFlows createManyAndReturn + */ + export type ChatFlowsCreateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the ChatFlows + */ + select?: ChatFlowsSelectCreateManyAndReturn | null + /** + * Omit specific fields from the ChatFlows + */ + omit?: ChatFlowsOmit | null + /** + * The data used to create many ChatFlows. + */ + data: ChatFlowsCreateManyInput | ChatFlowsCreateManyInput[] + skipDuplicates?: boolean + } + + /** + * ChatFlows update + */ + export type ChatFlowsUpdateArgs = { + /** + * Select specific fields to fetch from the ChatFlows + */ + select?: ChatFlowsSelect | null + /** + * Omit specific fields from the ChatFlows + */ + omit?: ChatFlowsOmit | null + /** + * The data needed to update a ChatFlows. + */ + data: XOR + /** + * Choose, which ChatFlows to update. + */ + where: ChatFlowsWhereUniqueInput + } + + /** + * ChatFlows updateMany + */ + export type ChatFlowsUpdateManyArgs = { + /** + * The data used to update ChatFlows. + */ + data: XOR + /** + * Filter which ChatFlows to update + */ + where?: ChatFlowsWhereInput + /** + * Limit how many ChatFlows to update. + */ + limit?: number + } + + /** + * ChatFlows updateManyAndReturn + */ + export type ChatFlowsUpdateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the ChatFlows + */ + select?: ChatFlowsSelectUpdateManyAndReturn | null + /** + * Omit specific fields from the ChatFlows + */ + omit?: ChatFlowsOmit | null + /** + * The data used to update ChatFlows. + */ + data: XOR + /** + * Filter which ChatFlows to update + */ + where?: ChatFlowsWhereInput + /** + * Limit how many ChatFlows to update. + */ + limit?: number + } + + /** + * ChatFlows upsert + */ + export type ChatFlowsUpsertArgs = { + /** + * Select specific fields to fetch from the ChatFlows + */ + select?: ChatFlowsSelect | null + /** + * Omit specific fields from the ChatFlows + */ + omit?: ChatFlowsOmit | null + /** + * The filter to search for the ChatFlows to update in case it exists. + */ + where: ChatFlowsWhereUniqueInput + /** + * In case the ChatFlows found by the `where` argument doesn't exist, create a new ChatFlows with this data. + */ + create: XOR + /** + * In case the ChatFlows was found with the provided `where` argument, update it with this data. + */ + update: XOR + } + + /** + * ChatFlows delete + */ + export type ChatFlowsDeleteArgs = { + /** + * Select specific fields to fetch from the ChatFlows + */ + select?: ChatFlowsSelect | null + /** + * Omit specific fields from the ChatFlows + */ + omit?: ChatFlowsOmit | null + /** + * Filter which ChatFlows to delete. + */ + where: ChatFlowsWhereUniqueInput + } + + /** + * ChatFlows deleteMany + */ + export type ChatFlowsDeleteManyArgs = { + /** + * Filter which ChatFlows to delete + */ + where?: ChatFlowsWhereInput + /** + * Limit how many ChatFlows to delete. + */ + limit?: number + } + + /** + * ChatFlows without action + */ + export type ChatFlowsDefaultArgs = { + /** + * Select specific fields to fetch from the ChatFlows + */ + select?: ChatFlowsSelect | null + /** + * Omit specific fields from the ChatFlows + */ + omit?: ChatFlowsOmit | null + } + + /** * Enums */ @@ -5556,6 +6686,21 @@ export namespace Prisma { export type WaHookScalarFieldEnum = (typeof WaHookScalarFieldEnum)[keyof typeof WaHookScalarFieldEnum] + export const ChatFlowsScalarFieldEnum: { + id: 'id', + flows: 'flows', + defaultFlow: 'defaultFlow', + defaultData: 'defaultData', + active: 'active', + flowUrl: 'flowUrl', + flowToken: 'flowToken', + createdAt: 'createdAt', + updatedAt: 'updatedAt' + }; + + export type ChatFlowsScalarFieldEnum = (typeof ChatFlowsScalarFieldEnum)[keyof typeof ChatFlowsScalarFieldEnum] + + export const SortOrder: { asc: 'asc', desc: 'desc' @@ -5958,6 +7103,78 @@ export namespace Prisma { updatedAt?: DateTimeWithAggregatesFilter<"WaHook"> | Date | string } + export type ChatFlowsWhereInput = { + AND?: ChatFlowsWhereInput | ChatFlowsWhereInput[] + OR?: ChatFlowsWhereInput[] + NOT?: ChatFlowsWhereInput | ChatFlowsWhereInput[] + id?: StringFilter<"ChatFlows"> | string + flows?: JsonNullableFilter<"ChatFlows"> + defaultFlow?: StringNullableFilter<"ChatFlows"> | string | null + defaultData?: JsonNullableFilter<"ChatFlows"> + active?: BoolFilter<"ChatFlows"> | boolean + flowUrl?: StringNullableFilter<"ChatFlows"> | string | null + flowToken?: StringNullableFilter<"ChatFlows"> | string | null + createdAt?: DateTimeFilter<"ChatFlows"> | Date | string + updatedAt?: DateTimeFilter<"ChatFlows"> | Date | string + } + + export type ChatFlowsOrderByWithRelationInput = { + id?: SortOrder + flows?: SortOrderInput | SortOrder + defaultFlow?: SortOrderInput | SortOrder + defaultData?: SortOrderInput | SortOrder + active?: SortOrder + flowUrl?: SortOrderInput | SortOrder + flowToken?: SortOrderInput | SortOrder + createdAt?: SortOrder + updatedAt?: SortOrder + } + + export type ChatFlowsWhereUniqueInput = Prisma.AtLeast<{ + id?: string + flowUrl?: string + AND?: ChatFlowsWhereInput | ChatFlowsWhereInput[] + OR?: ChatFlowsWhereInput[] + NOT?: ChatFlowsWhereInput | ChatFlowsWhereInput[] + flows?: JsonNullableFilter<"ChatFlows"> + defaultFlow?: StringNullableFilter<"ChatFlows"> | string | null + defaultData?: JsonNullableFilter<"ChatFlows"> + active?: BoolFilter<"ChatFlows"> | boolean + flowToken?: StringNullableFilter<"ChatFlows"> | string | null + createdAt?: DateTimeFilter<"ChatFlows"> | Date | string + updatedAt?: DateTimeFilter<"ChatFlows"> | Date | string + }, "id" | "flowUrl"> + + export type ChatFlowsOrderByWithAggregationInput = { + id?: SortOrder + flows?: SortOrderInput | SortOrder + defaultFlow?: SortOrderInput | SortOrder + defaultData?: SortOrderInput | SortOrder + active?: SortOrder + flowUrl?: SortOrderInput | SortOrder + flowToken?: SortOrderInput | SortOrder + createdAt?: SortOrder + updatedAt?: SortOrder + _count?: ChatFlowsCountOrderByAggregateInput + _max?: ChatFlowsMaxOrderByAggregateInput + _min?: ChatFlowsMinOrderByAggregateInput + } + + export type ChatFlowsScalarWhereWithAggregatesInput = { + AND?: ChatFlowsScalarWhereWithAggregatesInput | ChatFlowsScalarWhereWithAggregatesInput[] + OR?: ChatFlowsScalarWhereWithAggregatesInput[] + NOT?: ChatFlowsScalarWhereWithAggregatesInput | ChatFlowsScalarWhereWithAggregatesInput[] + id?: StringWithAggregatesFilter<"ChatFlows"> | string + flows?: JsonNullableWithAggregatesFilter<"ChatFlows"> + defaultFlow?: StringNullableWithAggregatesFilter<"ChatFlows"> | string | null + defaultData?: JsonNullableWithAggregatesFilter<"ChatFlows"> + active?: BoolWithAggregatesFilter<"ChatFlows"> | boolean + flowUrl?: StringNullableWithAggregatesFilter<"ChatFlows"> | string | null + flowToken?: StringNullableWithAggregatesFilter<"ChatFlows"> | string | null + createdAt?: DateTimeWithAggregatesFilter<"ChatFlows"> | Date | string + updatedAt?: DateTimeWithAggregatesFilter<"ChatFlows"> | Date | string + } + export type UserCreateInput = { id?: string name?: string | null @@ -6269,6 +7486,90 @@ export namespace Prisma { updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string } + export type ChatFlowsCreateInput = { + id?: string + flows?: NullableJsonNullValueInput | InputJsonValue + defaultFlow?: string | null + defaultData?: NullableJsonNullValueInput | InputJsonValue + active?: boolean + flowUrl?: string | null + flowToken?: string | null + createdAt?: Date | string + updatedAt?: Date | string + } + + export type ChatFlowsUncheckedCreateInput = { + id?: string + flows?: NullableJsonNullValueInput | InputJsonValue + defaultFlow?: string | null + defaultData?: NullableJsonNullValueInput | InputJsonValue + active?: boolean + flowUrl?: string | null + flowToken?: string | null + createdAt?: Date | string + updatedAt?: Date | string + } + + export type ChatFlowsUpdateInput = { + id?: StringFieldUpdateOperationsInput | string + flows?: NullableJsonNullValueInput | InputJsonValue + defaultFlow?: NullableStringFieldUpdateOperationsInput | string | null + defaultData?: NullableJsonNullValueInput | InputJsonValue + active?: BoolFieldUpdateOperationsInput | boolean + flowUrl?: NullableStringFieldUpdateOperationsInput | string | null + flowToken?: NullableStringFieldUpdateOperationsInput | string | null + createdAt?: DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string + } + + export type ChatFlowsUncheckedUpdateInput = { + id?: StringFieldUpdateOperationsInput | string + flows?: NullableJsonNullValueInput | InputJsonValue + defaultFlow?: NullableStringFieldUpdateOperationsInput | string | null + defaultData?: NullableJsonNullValueInput | InputJsonValue + active?: BoolFieldUpdateOperationsInput | boolean + flowUrl?: NullableStringFieldUpdateOperationsInput | string | null + flowToken?: NullableStringFieldUpdateOperationsInput | string | null + createdAt?: DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string + } + + export type ChatFlowsCreateManyInput = { + id?: string + flows?: NullableJsonNullValueInput | InputJsonValue + defaultFlow?: string | null + defaultData?: NullableJsonNullValueInput | InputJsonValue + active?: boolean + flowUrl?: string | null + flowToken?: string | null + createdAt?: Date | string + updatedAt?: Date | string + } + + export type ChatFlowsUpdateManyMutationInput = { + id?: StringFieldUpdateOperationsInput | string + flows?: NullableJsonNullValueInput | InputJsonValue + defaultFlow?: NullableStringFieldUpdateOperationsInput | string | null + defaultData?: NullableJsonNullValueInput | InputJsonValue + active?: BoolFieldUpdateOperationsInput | boolean + flowUrl?: NullableStringFieldUpdateOperationsInput | string | null + flowToken?: NullableStringFieldUpdateOperationsInput | string | null + createdAt?: DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string + } + + export type ChatFlowsUncheckedUpdateManyInput = { + id?: StringFieldUpdateOperationsInput | string + flows?: NullableJsonNullValueInput | InputJsonValue + defaultFlow?: NullableStringFieldUpdateOperationsInput | string | null + defaultData?: NullableJsonNullValueInput | InputJsonValue + active?: BoolFieldUpdateOperationsInput | boolean + flowUrl?: NullableStringFieldUpdateOperationsInput | string | null + flowToken?: NullableStringFieldUpdateOperationsInput | string | null + createdAt?: DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string + } + export type StringFilter<$PrismaModel = never> = { equals?: string | StringFieldRefInput<$PrismaModel> in?: string[] | ListStringFieldRefInput<$PrismaModel> @@ -6632,6 +7933,38 @@ export namespace Prisma { _max?: NestedJsonNullableFilter<$PrismaModel> } + export type ChatFlowsCountOrderByAggregateInput = { + id?: SortOrder + flows?: SortOrder + defaultFlow?: SortOrder + defaultData?: SortOrder + active?: SortOrder + flowUrl?: SortOrder + flowToken?: SortOrder + createdAt?: SortOrder + updatedAt?: SortOrder + } + + export type ChatFlowsMaxOrderByAggregateInput = { + id?: SortOrder + defaultFlow?: SortOrder + active?: SortOrder + flowUrl?: SortOrder + flowToken?: SortOrder + createdAt?: SortOrder + updatedAt?: SortOrder + } + + export type ChatFlowsMinOrderByAggregateInput = { + id?: SortOrder + defaultFlow?: SortOrder + active?: SortOrder + flowUrl?: SortOrder + flowToken?: SortOrder + createdAt?: SortOrder + updatedAt?: SortOrder + } + export type ApiKeyCreateNestedManyWithoutUserInput = { create?: XOR | ApiKeyCreateWithoutUserInput[] | ApiKeyUncheckedCreateWithoutUserInput[] connectOrCreate?: ApiKeyCreateOrConnectWithoutUserInput | ApiKeyCreateOrConnectWithoutUserInput[] diff --git a/generated/prisma/index.js b/generated/prisma/index.js index 16019ba..9fe24e1 100644 --- a/generated/prisma/index.js +++ b/generated/prisma/index.js @@ -137,6 +137,18 @@ exports.Prisma.WaHookScalarFieldEnum = { updatedAt: 'updatedAt' }; +exports.Prisma.ChatFlowsScalarFieldEnum = { + id: 'id', + flows: 'flows', + defaultFlow: 'defaultFlow', + defaultData: 'defaultData', + active: 'active', + flowUrl: 'flowUrl', + flowToken: 'flowToken', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +}; + exports.Prisma.SortOrder = { asc: 'asc', desc: 'desc' @@ -168,7 +180,8 @@ exports.Prisma.ModelName = { User: 'User', ApiKey: 'ApiKey', WebHook: 'WebHook', - WaHook: 'WaHook' + WaHook: 'WaHook', + ChatFlows: 'ChatFlows' }; /** * Create the Client @@ -217,8 +230,8 @@ 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", - "inlineSchemaHash": "f672201c199f0f043f3266324775af184d82ebd00379f5c23166510b25c889d0", + "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", + "inlineSchemaHash": "853d49417068ff1819c3dbb60ac7aeea59288f307f7939669c83fdd63bb495e3", "copyEngine": true } @@ -239,7 +252,7 @@ if (!fs.existsSync(path.join(__dirname, 'schema.prisma'))) { config.isBundled = true } -config.runtimeDataModel = JSON.parse("{\"models\":{\"User\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"name\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"email\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"password\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true},{\"name\":\"ApiKey\",\"kind\":\"object\",\"isList\":true,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"ApiKey\",\"nativeType\":null,\"relationName\":\"ApiKeyToUser\",\"relationFromFields\":[],\"relationToFields\":[],\"isGenerated\":false,\"isUpdatedAt\":false}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"ApiKey\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"User\",\"kind\":\"object\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"User\",\"nativeType\":null,\"relationName\":\"ApiKeyToUser\",\"relationFromFields\":[\"userId\"],\"relationToFields\":[\"id\"],\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"userId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":true,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"name\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"key\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":[\"Text\",[]],\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"description\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"expiredAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"WebHook\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"name\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"description\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"url\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"payload\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":\"{}\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"method\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":\"POST\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"headers\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":\"{}\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"apiToken\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"retries\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Int\",\"nativeType\":null,\"default\":3,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"enabled\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"nativeType\":null,\"default\":true,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"replay\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"nativeType\":null,\"default\":false,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"replayKey\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"WaHook\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"data\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Json\",\"nativeType\":[\"Json\",[]],\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false}},\"enums\":{},\"types\":{}}") +config.runtimeDataModel = JSON.parse("{\"models\":{\"User\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"name\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"email\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"password\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true},{\"name\":\"ApiKey\",\"kind\":\"object\",\"isList\":true,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"ApiKey\",\"nativeType\":null,\"relationName\":\"ApiKeyToUser\",\"relationFromFields\":[],\"relationToFields\":[],\"isGenerated\":false,\"isUpdatedAt\":false}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"ApiKey\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"User\",\"kind\":\"object\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"User\",\"nativeType\":null,\"relationName\":\"ApiKeyToUser\",\"relationFromFields\":[\"userId\"],\"relationToFields\":[\"id\"],\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"userId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":true,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"name\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"key\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":[\"Text\",[]],\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"description\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"expiredAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"WebHook\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"name\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"description\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"url\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"payload\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":\"{}\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"method\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":\"POST\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"headers\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":\"{}\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"apiToken\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"retries\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Int\",\"nativeType\":null,\"default\":3,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"enabled\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"nativeType\":null,\"default\":true,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"replay\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"nativeType\":null,\"default\":false,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"replayKey\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"WaHook\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"data\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Json\",\"nativeType\":[\"Json\",[]],\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"ChatFlows\":{\"dbName\":null,\"schema\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"nativeType\":null,\"default\":{\"name\":\"cuid\",\"args\":[1]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"flows\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Json\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"defaultFlow\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"defaultData\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Json\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"active\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"Boolean\",\"nativeType\":null,\"default\":true,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"flowUrl\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"flowToken\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"nativeType\":null,\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"nativeType\":null,\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false}},\"enums\":{},\"types\":{}}") defineDmmfProperty(exports.Prisma, config.runtimeDataModel) config.engineWasm = undefined config.compilerWasm = undefined diff --git a/generated/prisma/package.json b/generated/prisma/package.json index 82fa135..79025a3 100644 --- a/generated/prisma/package.json +++ b/generated/prisma/package.json @@ -1,5 +1,5 @@ { - "name": "prisma-client-b7159a5a3af13766d165b3bf5d09869b273a4102920455b6b9bd965ee512be7e", + "name": "prisma-client-0c787597671925c5dbd90480bfc5d45c3aa9b494d0bff63e2482cd62c5107b7b", "main": "index.js", "types": "index.d.ts", "browser": "default.js", diff --git a/generated/prisma/schema.prisma b/generated/prisma/schema.prisma index 07cef3a..33ad8da 100644 --- a/generated/prisma/schema.prisma +++ b/generated/prisma/schema.prisma @@ -53,3 +53,15 @@ model WaHook { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } + +model ChatFlows { + id String @id @default(cuid()) + flows Json? + defaultFlow String? + defaultData Json? + active Boolean @default(true) + flowUrl String? @unique + flowToken String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} diff --git a/generated/prisma/wasm.js b/generated/prisma/wasm.js index 36fcf74..c1510f9 100644 --- a/generated/prisma/wasm.js +++ b/generated/prisma/wasm.js @@ -136,6 +136,18 @@ exports.Prisma.WaHookScalarFieldEnum = { updatedAt: 'updatedAt' }; +exports.Prisma.ChatFlowsScalarFieldEnum = { + id: 'id', + flows: 'flows', + defaultFlow: 'defaultFlow', + defaultData: 'defaultData', + active: 'active', + flowUrl: 'flowUrl', + flowToken: 'flowToken', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +}; + exports.Prisma.SortOrder = { asc: 'asc', desc: 'desc' @@ -167,7 +179,8 @@ exports.Prisma.ModelName = { User: 'User', ApiKey: 'ApiKey', WebHook: 'WebHook', - WaHook: 'WaHook' + WaHook: 'WaHook', + ChatFlows: 'ChatFlows' }; /** * Create the Client @@ -216,13 +229,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", - "inlineSchemaHash": "f672201c199f0f043f3266324775af184d82ebd00379f5c23166510b25c889d0", + "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", + "inlineSchemaHash": "853d49417068ff1819c3dbb60ac7aeea59288f307f7939669c83fdd63bb495e3", "copyEngine": true } 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}},\"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\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null}},\"enums\":{},\"types\":{}}") defineDmmfProperty(exports.Prisma, config.runtimeDataModel) config.engineWasm = { getRuntime: async () => require('./query_engine_bg.js'), diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 1de3c6e..c8e9eeb 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -48,8 +48,20 @@ model WebHook { } model WaHook { - id String @id @default(cuid()) - data Json? @db.Json + id String @id @default(cuid()) + data Json? @db.Json createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } + +model ChatFlows { + id String @id @default(cuid()) + flows Json? + defaultFlow String? + defaultData Json? + active Boolean @default(true) + flowUrl String? @unique + flowToken String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} diff --git a/src/App.tsx b/src/App.tsx index 9bf5309..f0ca892 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,7 +7,7 @@ import AppRoutes from "./AppRoutes"; export function App() { return ( - + diff --git a/src/AppRoutes.tsx b/src/AppRoutes.tsx index 6dc28f7..4e1e3c0 100644 --- a/src/AppRoutes.tsx +++ b/src/AppRoutes.tsx @@ -7,6 +7,9 @@ import WebhookHome from "./pages/sq/dashboard/webhook/webhook_home"; import WebhookLayout from "./pages/sq/dashboard/webhook/webhook_layout"; import WajsHome from "./pages/sq/dashboard/wajs/wajs_home"; import WajsLayout from "./pages/sq/dashboard/wajs/wajs_layout"; +import WaHookHome from "./pages/sq/dashboard/wa-hook/wa_hook_home"; +import FlowWaHook from "./pages/sq/dashboard/wa-hook/flow_wa_hook"; +import WaHookLayout from "./pages/sq/dashboard/wa-hook/wa_hook_layout"; import ApikeyPage from "./pages/sq/dashboard/apikey/apikey_page"; import DashboardPage from "./pages/sq/dashboard/dashboard_page"; import DashboardLayout from "./pages/sq/dashboard/dashboard_layout"; @@ -48,6 +51,19 @@ export default function AppRoutes() { element={} /> + + }> + } /> + + } + /> + } + /> + } diff --git a/src/clientRoutes.ts b/src/clientRoutes.ts index e2a70c4..336462c 100644 --- a/src/clientRoutes.ts +++ b/src/clientRoutes.ts @@ -9,6 +9,9 @@ const clientRoutes = { "/sq/dashboard/webhook/webhook-home": "/sq/dashboard/webhook/webhook-home", "/sq/dashboard/wajs": "/sq/dashboard/wajs", "/sq/dashboard/wajs/wajs-home": "/sq/dashboard/wajs/wajs-home", + "/sq/dashboard/wa-hook": "/sq/dashboard/wa-hook", + "/sq/dashboard/wa-hook/wa-hook-home": "/sq/dashboard/wa-hook/wa-hook-home", + "/sq/dashboard/wa-hook/flow-wa-hook": "/sq/dashboard/wa-hook/flow-wa-hook", "/sq/dashboard/apikey/apikey": "/sq/dashboard/apikey/apikey", "/sq/dashboard/dashboard": "/sq/dashboard/dashboard", "/login": "/login", diff --git a/src/index.tsx b/src/index.tsx index b3f2875..f706738 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -10,6 +10,7 @@ import WaRoute from "./server/routes/wa_route"; import WebhookRoute from "./server/routes/webhook_route"; import cors from "@elysiajs/cors"; import WaHookRoute from "./server/routes/wa_hook_route"; +import FlowRoute from "./server/routes/flow_route"; const Docs = new Elysia().use( Swagger({ @@ -35,7 +36,7 @@ const Api = new Elysia({ .use(ApiUser) .use(WaRoute) .use(WebhookRoute) - + .use(FlowRoute); const app = new Elysia() .use(cors()) diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 3afe659..3077f69 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -1,7 +1,15 @@ +import clientRoutes from "@/clientRoutes"; +import { Button, Container } from "@mantine/core"; +import { useNavigate } from "react-router-dom"; + export default function Home() { + const navigate = useNavigate(); return ( -
+

Home

-
+ + ); } diff --git a/src/pages/sq/dashboard/apikey/apikey_page.tsx b/src/pages/sq/dashboard/apikey/apikey_page.tsx index a0d2a62..38fa504 100644 --- a/src/pages/sq/dashboard/apikey/apikey_page.tsx +++ b/src/pages/sq/dashboard/apikey/apikey_page.tsx @@ -254,25 +254,17 @@ function ListApiKey({ refresh }: { refresh: boolean }) { }} > {apiKey.name} - - {apiKey.description || "—"} - + {apiKey.description || "—"} {apiKey.expiredAt - ? new Date(apiKey.expiredAt) - .toISOString() - .split("T")[0] + ? new Date(apiKey.expiredAt).toISOString().split("T")[0] : "—"} - {new Date(apiKey.createdAt) - .toISOString() - .split("T")[0]} + {new Date(apiKey.createdAt).toISOString().split("T")[0]} - {new Date(apiKey.updatedAt) - .toISOString() - .split("T")[0]} + {new Date(apiKey.updatedAt).toISOString().split("T")[0]} @@ -301,7 +293,7 @@ function ListApiKey({ refresh }: { refresh: boolean }) { id: apiKey.id, }); setApiKeys((prev) => - prev.filter((a) => a.id !== apiKey.id) + prev.filter((a) => a.id !== apiKey.id), ); showNotification({ title: "Deleted", diff --git a/src/pages/sq/dashboard/dashboard_layout.tsx b/src/pages/sq/dashboard/dashboard_layout.tsx index 658cc2b..fecdc34 100644 --- a/src/pages/sq/dashboard/dashboard_layout.tsx +++ b/src/pages/sq/dashboard/dashboard_layout.tsx @@ -258,6 +258,12 @@ function NavigationDashboard() { icon: , desc: "Incoming and outgoing event handlers", }, + { + path: clientRoutes["/sq/dashboard/wa-hook/wa-hook-home"], + label: "WA Hook", + icon: , + desc: "WA Hook", + }, ]; return ( diff --git a/src/pages/sq/dashboard/wa-hook/flow_wa_hook.tsx b/src/pages/sq/dashboard/wa-hook/flow_wa_hook.tsx new file mode 100644 index 0000000..aed3211 --- /dev/null +++ b/src/pages/sq/dashboard/wa-hook/flow_wa_hook.tsx @@ -0,0 +1,195 @@ +import { useState, useCallback } from "react"; +import { + Container, + Stack, + Card, + Group, + Button, + Table, + TextInput, + PasswordInput, + ActionIcon, + Checkbox, + Text, + Title, + Flex, + Loader, +} from "@mantine/core"; +import { IconReload, IconCheck, IconCopy } from "@tabler/icons-react"; +import { showNotification } from "@mantine/notifications"; +import { useShallowEffect } from "@mantine/hooks"; +import apiFetch from "@/lib/apiFetch"; + +export default function FlowWaHook() { + return ( + + + + + + + ); +} + +function FlowWaHookList() { + const [flows, setFlows] = useState<{ id: string; name: string; type: string }[]>([]); + const [loading, setLoading] = useState(false); + const [defaultFlow, setDefaultFlow] = useState(""); + + const loadFlows = useCallback(async () => { + setLoading(true); + const { data, error } = await apiFetch.api.chatflows.find.get(); + if (error) { + showNotification({ title: "Error", message: "Failed to load flows", color: "red" }); + } else { + setFlows(data?.flows || []); + setDefaultFlow(data?.defaultFlow || ""); + } + setLoading(false); + }, []); + + useShallowEffect(() => { + loadFlows(); + }, [loadFlows]); + + const syncFlows = async () => { + setLoading(true); + const { error } = await apiFetch.api.chatflows.sync.get(); + if (error) { + showNotification({ title: "Error", message: "Sync failed", color: "red" }); + } else { + await loadFlows(); + showNotification({ title: "Success", message: "Flows synchronized", color: "green" }); + } + setLoading(false); + }; + + const setAsDefault = async (id: string) => { + setLoading(true); + const { error } = await apiFetch.api.chatflows.default.put({ id, defaultData: {} }); + if (error) { + showNotification({ title: "Error", message: "Failed to set default flow", color: "red" }); + } else { + await loadFlows(); + showNotification({ title: "Success", message: "Default flow updated", color: "green" }); + } + setLoading(false); + }; + + return ( + + + + Flow Management + + + + + + Name + Type + Default + + + + {flows.map((flow) => ( + + {flow.name} + {flow.type} + + setAsDefault(flow.id)} /> + + + ))} + {!loading && flows.length === 0 && ( + + + + No flows available + + + + )} + {loading && ( + + + + + + + + )} + +
+
+
+ ); +} + +function FlowWaHookForm() { + const [flowUrl, setFlowUrl] = useState(""); + const [flowToken, setFlowToken] = useState(""); + const [loading, setLoading] = useState(false); + + useShallowEffect(() => { + const loadCredentials = async () => { + const { data, error } = await apiFetch.api.chatflows["url-token"].get(); + if (error) { + showNotification({ title: "Error", message: "Failed to load credentials", color: "red" }); + } else { + setFlowUrl(data?.data?.flowUrl || ""); + setFlowToken(data?.data?.flowToken || ""); + } + }; + loadCredentials(); + }, []); + + const saveCredentials = async () => { + if (!flowUrl || !flowToken) { + showNotification({ title: "Error", message: "URL and token are required", color: "red" }); + return; + } + setLoading(true); + const { error } = await apiFetch.api.chatflows["url-token"].put({ flowUrl, flowToken }); + if (error) { + showNotification({ title: "Error", message: "Failed to update credentials", color: "red" }); + } else { + showNotification({ title: "Success", message: "Credentials updated", color: "green" }); + } + setLoading(false); + }; + + const copyToken = () => { + navigator.clipboard.writeText(flowToken); + showNotification({ title: "Copied", message: "Token copied to clipboard", color: "green" }); + }; + + return ( + + + Flow Credentials + + setFlowUrl(e.currentTarget.value)} /> + setFlowToken(e.currentTarget.value)} + rightSection={ + + + + } + /> + + + + + + + ); +} diff --git a/src/pages/sq/dashboard/wa-hook/wa_hook_home.tsx b/src/pages/sq/dashboard/wa-hook/wa_hook_home.tsx new file mode 100644 index 0000000..154a51e --- /dev/null +++ b/src/pages/sq/dashboard/wa-hook/wa_hook_home.tsx @@ -0,0 +1,29 @@ +import apiFetch from "@/lib/apiFetch"; +import { Skeleton, Stack, Text, Title } from "@mantine/core"; +import { useShallowEffect } from "@mantine/hooks"; +import useSWR from "swr"; + +export default function WaHookHome() { + const { data, error, isLoading, mutate } = useSWR("/wa-hook", apiFetch["wa-hook"].list.get,{ + refreshInterval: 3000, + revalidateOnFocus: true, + revalidateOnReconnect: true, + revalidateIfStale: true, + refreshWhenHidden: true, + refreshWhenOffline: true, + dedupingInterval: 3000, + }) + + useShallowEffect(() => { + mutate() + }, []) + + if (isLoading) return + if (error) return
Error: {error.message}
+ return ( + + WaHookHome +
{JSON.stringify(data?.data?.list, null, 2)}
+
+ ); +} diff --git a/src/pages/sq/dashboard/wa-hook/wa_hook_layout.tsx b/src/pages/sq/dashboard/wa-hook/wa_hook_layout.tsx new file mode 100644 index 0000000..318361f --- /dev/null +++ b/src/pages/sq/dashboard/wa-hook/wa_hook_layout.tsx @@ -0,0 +1,23 @@ +import clientRoutes from "@/clientRoutes"; +import { Button, Container, Group, Stack } from "@mantine/core"; +import { Outlet, useNavigate } from "react-router-dom"; + +export default function WaHookLayout() { + const navigate = useNavigate(); + return ( + + + + + + + ); +} diff --git a/src/pages/sq/dashboard/webhook/webhook_create.tsx b/src/pages/sq/dashboard/webhook/webhook_create.tsx index 7e5a267..068df52 100644 --- a/src/pages/sq/dashboard/webhook/webhook_create.tsx +++ b/src/pages/sq/dashboard/webhook/webhook_create.tsx @@ -1,15 +1,15 @@ import { useState, useMemo } from "react"; import { - Button, - Card, - Checkbox, - Group, - Stack, - Text, - TextInput, - Select, - Divider, - Title, + Button, + Card, + Checkbox, + Group, + Stack, + Text, + TextInput, + Select, + Divider, + Title, } from "@mantine/core"; import { notifications } from "@mantine/notifications"; import { IconCode, IconCheck, IconX } from "@tabler/icons-react"; @@ -38,279 +38,273 @@ Available variables: `; export default function WebhookCreate() { - const navigate = useNavigate(); - const [name, setName] = useState(""); - const [description, setDescription] = useState(""); - const [url, setUrl] = useState(""); - const [method, setMethod] = useState("POST"); - const [headers, setHeaders] = useState( - JSON.stringify({ "Content-Type": "application/json" }, null, 2), - ); - const [payload, setPayload] = useState("{}"); - const [apiToken, setApiToken] = useState(""); - const [enabled, setEnabled] = useState(true); - const [replay, setReplay] = useState(false); - const [replayKey, setReplayKey] = useState(""); + const navigate = useNavigate(); + const [name, setName] = useState(""); + const [description, setDescription] = useState(""); + const [url, setUrl] = useState(""); + const [method, setMethod] = useState("POST"); + const [headers, setHeaders] = useState( + JSON.stringify({ "Content-Type": "application/json" }, null, 2), + ); + const [payload, setPayload] = useState("{}"); + const [apiToken, setApiToken] = useState(""); + const [enabled, setEnabled] = useState(true); + const [replay, setReplay] = useState(false); + const [replayKey, setReplayKey] = useState(""); - const safeJson = (value: string) => { - try { - return JSON.stringify(JSON.parse(value || "{}"), null, 2); - } catch { - return value || "{}"; - } - }; + const safeJson = (value: string) => { + try { + return JSON.stringify(JSON.parse(value || "{}"), null, 2); + } catch { + return value || "{}"; + } + }; - const previewCode = useMemo(() => { - let headerObj: Record = {}; - try { - headerObj = JSON.parse(headers); - } catch { } - if (apiToken) headerObj["Authorization"] = `Bearer ${apiToken}`; - const prettyHeaders = safeJson(JSON.stringify(headerObj)); - const prettyPayload = safeJson(payload); - const includeBody = ["POST", "PUT", "PATCH"].includes(method.toUpperCase()); + const previewCode = useMemo(() => { + let headerObj: Record = {}; + try { + headerObj = JSON.parse(headers); + } catch {} + if (apiToken) headerObj["Authorization"] = `Bearer ${apiToken}`; + const prettyHeaders = safeJson(JSON.stringify(headerObj)); + const prettyPayload = safeJson(payload); + const includeBody = ["POST", "PUT", "PATCH"].includes(method.toUpperCase()); - return `fetch("${url || "https://example.com/webhook"}", { + return `fetch("${url || "https://example.com/webhook"}", { method: "${method}", headers: ${prettyHeaders},${includeBody ? `\n body: ${prettyPayload},` : ""} }) .then(res => res.json()) .then(console.log) .catch(console.error);`; - }, [url, method, headers, payload, apiToken]); + }, [url, method, headers, payload, apiToken]); - async function onSubmit() { - const { data } = await apiFetch.api.webhook.create.post({ - name, - description, - apiToken, - url, - method, - headers, - payload, - enabled, - replay, - replayKey, - }); + async function onSubmit() { + const { data } = await apiFetch.api.webhook.create.post({ + name, + description, + apiToken, + url, + method, + headers, + payload, + enabled, + replay, + replayKey, + }); - if (data?.success) { - notifications.show({ - title: "Webhook Created", - message: data.message, - color: "teal", - icon: , - }); + if (data?.success) { + notifications.show({ + title: "Webhook Created", + message: data.message, + color: "teal", + icon: , + }); - navigate(clientRoutes["/sq/dashboard/webhook"]); - } else { - notifications.show({ - title: "Creation Failed", - message: data?.message || "Unable to create webhook", - color: "red", - icon: , - }); - } + navigate(clientRoutes["/sq/dashboard/webhook"]); + } else { + notifications.show({ + title: "Creation Failed", + message: data?.message || "Unable to create webhook", + color: "red", + icon: , + }); } + } - return ( - - - - - Create Webhook - - - + return ( + + + + + Create Webhook + + + - + - setName(e.target.value)} - - /> + setName(e.target.value)} + /> - setDescription(e.target.value)} - - /> + setDescription(e.target.value)} + /> - setUrl(e.target.value)} - - /> + setUrl(e.target.value)} + /> - setMethod(v || "POST")} + data={["POST", "GET", "PUT", "PATCH", "DELETE"].map((v) => ({ + value: v, + label: v, + }))} + /> - { - setApiToken(e.target.value); - try { - const current = JSON.parse(headers); - if (!e.target.value) { - delete current["Authorization"]; - } else { - current["Authorization"] = `Bearer ${e.target.value}`; - } - setHeaders(JSON.stringify(current, null, 2)); - } catch { } - }} - - /> + { + setApiToken(e.target.value); + try { + const current = JSON.parse(headers); + if (!e.target.value) { + delete current["Authorization"]; + } else { + current["Authorization"] = `Bearer ${e.target.value}`; + } + setHeaders(JSON.stringify(current, null, 2)); + } catch {} + }} + /> - - - Headers (JSON) - - setHeaders(val ?? "{}")} - options={{ - minimap: { enabled: false }, - fontSize: 13, - scrollBeyondLastLine: false, - lineNumbers: "off", - automaticLayout: true, - }} - /> - - - - - Payload - - - {templateData} - - setPayload(val ?? "{}")} - options={{ - minimap: { enabled: false }, - fontSize: 13, - scrollBeyondLastLine: false, - automaticLayout: true, - }} - /> - - - setEnabled(e.currentTarget.checked)} - color="teal" - styles={{ - label: { color: "#EAEAEA" }, - }} - /> - setReplay(e.currentTarget.checked)} - color="teal" - styles={{ - label: { color: "#EAEAEA" }, - }} - /> - setReplayKey(e.target.value)} - - /> - - - - - Request Preview - - - - - - - - - - + + + Headers (JSON) + + setHeaders(val ?? "{}")} + options={{ + minimap: { enabled: false }, + fontSize: 13, + scrollBeyondLastLine: false, + lineNumbers: "off", + automaticLayout: true, + }} + /> - ); + + + + Payload + + + {templateData} + + setPayload(val ?? "{}")} + options={{ + minimap: { enabled: false }, + fontSize: 13, + scrollBeyondLastLine: false, + automaticLayout: true, + }} + /> + + + setEnabled(e.currentTarget.checked)} + color="teal" + styles={{ + label: { color: "#EAEAEA" }, + }} + /> + setReplay(e.currentTarget.checked)} + color="teal" + styles={{ + label: { color: "#EAEAEA" }, + }} + /> + setReplayKey(e.target.value)} + /> + + + + + Request Preview + + + + + + + + + + + + ); } diff --git a/src/pages/sq/dashboard/webhook/webhook_edit.tsx b/src/pages/sq/dashboard/webhook/webhook_edit.tsx index 630206b..59b683f 100644 --- a/src/pages/sq/dashboard/webhook/webhook_edit.tsx +++ b/src/pages/sq/dashboard/webhook/webhook_edit.tsx @@ -7,7 +7,18 @@ import { useMemo } from "react"; import { notifications } from "@mantine/notifications"; import { IconCode, IconCheck, IconX } from "@tabler/icons-react"; import Editor from "@monaco-editor/react"; -import { Stack, Group, Title, Divider, TextInput, Select, Checkbox, Card, Button, Text } from "@mantine/core"; +import { + Stack, + Group, + Title, + Divider, + TextInput, + Select, + Checkbox, + Card, + Button, + Text, +} from "@mantine/core"; import { modals } from "@mantine/modals"; import clientRoutes from "@/clientRoutes"; import { useShallowEffect } from "@mantine/hooks"; @@ -18,344 +29,359 @@ Available variables: `; export default function WebhookEdit() { - const [searchParams] = useSearchParams(); - const id = searchParams.get("id"); - const { data, error, isLoading, mutate } = useSWR("/", () => apiFetch.api.webhook.find({ - id: id! - }).get(), {dedupingInterval: 3000}) - const navigate = useNavigate(); + const [searchParams] = useSearchParams(); + const id = searchParams.get("id"); + const { data, error, isLoading, mutate } = useSWR( + "/", + () => + apiFetch.api.webhook + .find({ + id: id!, + }) + .get(), + { dedupingInterval: 3000 }, + ); + const navigate = useNavigate(); - useShallowEffect(() => { - mutate(); - }, [data]); + useShallowEffect(() => { + mutate(); + }, [data]); - if (isLoading) return
Loading...
; - if (error) return
Error: {error}
; - if (!data?.data?.webhook) return
No data
; + if (isLoading) return
Loading...
; + if (error) return
Error: {error}
; + if (!data?.data?.webhook) return
No data
; - return ( - - - - Edit Webhook - - - - - ); + return ( + + + Edit Webhook + + + + + ); } function EditView({ webhook }: { webhook: WebHook | null }) { - const navigate = useNavigate(); - const [name, setName] = useState(webhook?.name || ""); - const [description, setDescription] = useState(webhook?.description || ""); - const [url, setUrl] = useState(webhook?.url || ""); - const [method, setMethod] = useState(webhook?.method || "POST"); - const [headers, setHeaders] = useState(webhook?.headers || "{}"); - const [payload, setPayload] = useState(webhook?.payload || "{}"); - const [apiToken, setApiToken] = useState(webhook?.apiToken || ""); - const [enabled, setEnabled] = useState(webhook?.enabled || true); - const [replay, setReplay] = useState(webhook?.replay || false); - const [replayKey, setReplayKey] = useState(webhook?.replayKey || ""); + const navigate = useNavigate(); + const [name, setName] = useState(webhook?.name || ""); + const [description, setDescription] = useState(webhook?.description || ""); + const [url, setUrl] = useState(webhook?.url || ""); + const [method, setMethod] = useState(webhook?.method || "POST"); + const [headers, setHeaders] = useState(webhook?.headers || "{}"); + const [payload, setPayload] = useState(webhook?.payload || "{}"); + const [apiToken, setApiToken] = useState(webhook?.apiToken || ""); + const [enabled, setEnabled] = useState(webhook?.enabled || true); + const [replay, setReplay] = useState(webhook?.replay || false); + const [replayKey, setReplayKey] = useState(webhook?.replayKey || ""); - const safeJson = (value: string) => { - try { - return JSON.stringify(JSON.parse(value || "{}"), null, 2); - } catch { - return value || "{}"; - } - }; + const safeJson = (value: string) => { + try { + return JSON.stringify(JSON.parse(value || "{}"), null, 2); + } catch { + return value || "{}"; + } + }; - // useShallowEffect(() => { - // let headerObj: Record = {}; - // try { - // headerObj = JSON.parse(headers); - // } catch { } - // if (apiToken) headerObj["Authorization"] = `Bearer ${apiToken}`; - // setHeaders(JSON.stringify(headerObj, null, 2)); - // }, [apiToken]); + // useShallowEffect(() => { + // let headerObj: Record = {}; + // try { + // headerObj = JSON.parse(headers); + // } catch { } + // if (apiToken) headerObj["Authorization"] = `Bearer ${apiToken}`; + // setHeaders(JSON.stringify(headerObj, null, 2)); + // }, [apiToken]); - const previewCode = useMemo(() => { - let headerObj: Record = {}; - try { - headerObj = JSON.parse(headers); - } catch { } - if (apiToken) headerObj["Authorization"] = `Bearer ${apiToken}`; - const prettyHeaders = safeJson(JSON.stringify(headerObj)); - const prettyPayload = safeJson(payload); - const includeBody = ["POST", "PUT", "PATCH"].includes(method.toUpperCase()); + const previewCode = useMemo(() => { + let headerObj: Record = {}; + try { + headerObj = JSON.parse(headers); + } catch {} + if (apiToken) headerObj["Authorization"] = `Bearer ${apiToken}`; + const prettyHeaders = safeJson(JSON.stringify(headerObj)); + const prettyPayload = safeJson(payload); + const includeBody = ["POST", "PUT", "PATCH"].includes(method.toUpperCase()); - return `fetch("${url || "https://example.com/webhook"}", { + return `fetch("${url || "https://example.com/webhook"}", { method: "${method}", headers: ${prettyHeaders},${includeBody ? `\n body: ${prettyPayload},` : ""} }) .then(res => res.json()) .then(console.log) .catch(console.error);`; - }, [url, method, headers, payload, apiToken]); + }, [url, method, headers, payload, apiToken]); - async function onSubmit() { - if (!webhook?.id) { - return notifications.show({ - title: "Webhook ID Not Found", - message: "Unable to update webhook", - color: "red", - icon: , - }); - } - const { data } = await apiFetch.api.webhook.update({ - id: webhook?.id, - }).put({ - name, - description, - apiToken, - url, - method, - headers, - payload, - enabled, - replay, - replayKey, - }); - - if (data?.success) { - notifications.show({ - title: "Webhook Created", - message: data.message, - color: "teal", - icon: , - }); - navigate(clientRoutes["/sq/dashboard/webhook"]); - } else { - notifications.show({ - title: "Creation Failed", - message: data?.message || "Unable to create webhook", - color: "red", - icon: , - }); - } + async function onSubmit() { + if (!webhook?.id) { + return notifications.show({ + title: "Webhook ID Not Found", + message: "Unable to update webhook", + color: "red", + icon: , + }); } + const { data } = await apiFetch.api.webhook + .update({ + id: webhook?.id, + }) + .put({ + name, + description, + apiToken, + url, + method, + headers, + payload, + enabled, + replay, + replayKey, + }); - return ( - - - - - Create Webhook - - - + if (data?.success) { + notifications.show({ + title: "Webhook Created", + message: data.message, + color: "teal", + icon: , + }); + navigate(clientRoutes["/sq/dashboard/webhook"]); + } else { + notifications.show({ + title: "Creation Failed", + message: data?.message || "Unable to create webhook", + color: "red", + icon: , + }); + } + } - + return ( + + + + + Create Webhook + + + - setName(e.target.value)} - - /> + - setDescription(e.target.value)} - - /> + setName(e.target.value)} + /> - setUrl(e.target.value)} - - /> + setDescription(e.target.value)} + /> - setMethod(v || "POST")} + data={["POST", "GET", "PUT", "PATCH", "DELETE"].map((v) => ({ + value: v, + label: v, + }))} + /> - - - Headers (JSON) - - setHeaders(val ?? "{}")} - options={{ - minimap: { enabled: false }, - fontSize: 13, - scrollBeyondLastLine: false, - lineNumbers: "off", - automaticLayout: true, - }} - /> - + { + setApiToken(e.target.value); + try { + const current = JSON.parse(headers); + if (!e.target.value) { + delete current["Authorization"]; + } else { + current["Authorization"] = `Bearer ${e.target.value}`; + } + setHeaders(JSON.stringify(current, null, 2)); + } catch {} + }} + /> - - - Payload - - - {templateData} - - setPayload(val ?? "{}")} - options={{ - minimap: { enabled: false }, - fontSize: 13, - scrollBeyondLastLine: false, - automaticLayout: true, - }} - /> - - - setEnabled(e.target.checked as any)} - color="teal" - styles={{ - label: { color: "#EAEAEA" }, - }} - /> - - setReplay(e.target.checked as any)} - color="teal" - styles={{ - label: { color: "#EAEAEA" }, - }} - /> - - setReplayKey(e.target.value)} - - /> - - - - - Request Preview - - - - - - - - - - + + + Headers (JSON) + + setHeaders(val ?? "{}")} + options={{ + minimap: { enabled: false }, + fontSize: 13, + scrollBeyondLastLine: false, + lineNumbers: "off", + automaticLayout: true, + }} + /> - ); + + + + Payload + + + {templateData} + + setPayload(val ?? "{}")} + options={{ + minimap: { enabled: false }, + fontSize: 13, + scrollBeyondLastLine: false, + automaticLayout: true, + }} + /> + + + setEnabled(e.target.checked as any)} + color="teal" + styles={{ + label: { color: "#EAEAEA" }, + }} + /> + + setReplay(e.target.checked as any)} + color="teal" + styles={{ + label: { color: "#EAEAEA" }, + }} + /> + + setReplayKey(e.target.value)} + /> + + + + + Request Preview + + + + + + + + + + + + ); } diff --git a/src/pages/sq/dashboard/webhook/webhook_home.tsx b/src/pages/sq/dashboard/webhook/webhook_home.tsx index a57da82..219c80d 100644 --- a/src/pages/sq/dashboard/webhook/webhook_home.tsx +++ b/src/pages/sq/dashboard/webhook/webhook_home.tsx @@ -1,28 +1,28 @@ import { useMemo } from "react"; import { - Card, - Group, - Text, - Title, - Badge, - Loader, - Center, - Tooltip, - ActionIcon, - Stack, - Divider, - Button, + Card, + Group, + Text, + Title, + Badge, + Loader, + Center, + Tooltip, + ActionIcon, + Stack, + Divider, + Button, } from "@mantine/core"; import { - IconLink, - IconCode, - IconKey, - IconCheck, - IconX, - IconRefresh, - IconEdit, - IconPlus, - IconMessageReply, + IconLink, + IconCode, + IconKey, + IconCheck, + IconX, + IconRefresh, + IconEdit, + IconPlus, + IconMessageReply, } from "@tabler/icons-react"; import { notifications } from "@mantine/notifications"; import useSWR from "swr"; @@ -32,218 +32,228 @@ import clientRoutes from "@/clientRoutes"; import { useShallowEffect } from "@mantine/hooks"; export default function WebhookHome() { - const navigate = useNavigate(); - const { data, error, isLoading, mutate } = useSWR( - "/", - apiFetch.api.webhook.list.get, { dedupingInterval: 3000, refreshInterval: 3000 }); + const navigate = useNavigate(); + const { data, error, isLoading, mutate } = useSWR( + "/", + apiFetch.api.webhook.list.get, + { dedupingInterval: 3000, refreshInterval: 3000 }, + ); - const webhooks = useMemo(() => data?.data?.list ?? [], [data]); + const webhooks = useMemo(() => data?.data?.list ?? [], [data]); - useShallowEffect(() => { - mutate(); - }, []); - - - function ButtonCreate() { - return - - - } - - if (isLoading) - return ( -
- -
- ); - - if (error) - return ( -
- - Failed to load webhooks. Please try again. - -
- ); - - if (!webhooks.length) - return ( -
- - - No webhooks found - - - Connect your first webhook to start managing events - - - -
- ); + useShallowEffect(() => { + mutate(); + }, []); + function ButtonCreate() { return ( - - - - Webhook Manager - - - - { - mutate(); - notifications.show({ - title: "Refreshing data", - message: "Webhook list is being updated...", - color: "teal", - }); - }} - > - - - + + + + ); + } + + if (isLoading) + return ( +
+ +
+ ); + + if (error) + return ( +
+ + Failed to load webhooks. Please try again. + +
+ ); + + if (!webhooks.length) + return ( +
+ + + No webhooks found + + + Connect your first webhook to start managing events + + + +
+ ); + + return ( + + + + Webhook Manager + + + + { + mutate(); + notifications.show({ + title: "Refreshing data", + message: "Webhook list is being updated...", + color: "teal", + }); + }} + > + + + + + + + {webhooks.map((webhook) => ( + + + + + + {webhook.name} + + + + + navigate( + `${clientRoutes["/sq/dashboard/webhook/webhook-edit"]}?id=${webhook.id}`, + ) + } + > + + - - {webhooks.map((webhook) => ( - - - - - - {webhook.name} - - - - navigate(`${clientRoutes["/sq/dashboard/webhook/webhook-edit"]}?id=${webhook.id}`)} - > - - - - - - - - ) : ( - - ) - } - > - {webhook.enabled ? "Active" : "Disabled"} - - }> - {webhook.replay ? "Replay" : "Not Replay"} - - - {webhook.description} - - - - - - - - Method: - - - {webhook.method} - - - - - - - URL: - - - {webhook.url} - - - - - - - API Token: - - - {webhook.apiToken?.slice(0, 6) + "..." || "—"} - - - - - - Headers: - - - {Object.keys(webhook.headers || {}).length - ? webhook.headers - : "No headers configured"} - - - - - - Payload: - - - {Object.keys(webhook.payload || {}).length - ? webhook.payload - : "Empty payload"} - - - - - ))} + + + + ) : ( + + ) + } + > + {webhook.enabled ? "Active" : "Disabled"} + + } + > + {webhook.replay ? "Replay" : "Not Replay"} + + + + {webhook.description} + - - ); + + + + + + + Method: + + + {webhook.method} + + + + + + + URL: + + + {webhook.url} + + + + + + + API Token: + + + {webhook.apiToken?.slice(0, 6) + "..." || "—"} + + + + + + Headers: + + + {Object.keys(webhook.headers || {}).length + ? webhook.headers + : "No headers configured"} + + + + + + Payload: + + + {Object.keys(webhook.payload || {}).length + ? webhook.payload + : "Empty payload"} + + + + + ))} + + + ); } diff --git a/src/pages/sq/dashboard/webhook/webhook_layout.tsx b/src/pages/sq/dashboard/webhook/webhook_layout.tsx index fa758e2..b2bcbd1 100644 --- a/src/pages/sq/dashboard/webhook/webhook_layout.tsx +++ b/src/pages/sq/dashboard/webhook/webhook_layout.tsx @@ -1,20 +1,18 @@ import { - Button, - Group, - Stack, - Title, - Tooltip, - Divider, - Container, - Paper, + Button, + Group, + Stack, + Title, + Tooltip, + Divider, + Container, + Paper, } from "@mantine/core"; import { IconPlus } from "@tabler/icons-react"; import { useNavigate, Outlet } from "react-router-dom"; export default function WebhookLayout() { - const navigate = useNavigate(); + const navigate = useNavigate(); - return ( - - ); + return ; } diff --git a/src/server/routes/flow_route.ts b/src/server/routes/flow_route.ts new file mode 100644 index 0000000..a9af7da --- /dev/null +++ b/src/server/routes/flow_route.ts @@ -0,0 +1,247 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import Elysia, { t } from 'elysia' +import { prisma } from '../lib/prisma' +import _ from 'lodash' + +const getUrlToken = async () => await prisma.chatFlows.findUnique({ where: { id: "1" }, select: { flowUrl: true, flowToken: true } }) + +const FlowRoute = new Elysia({ + prefix: '/chatflows', + detail: { tags: ['chatflows'] }, +}) + .get('/sync', async ctx => { + const result = await getUrlToken() + if (!result) { + return { error: 'Flow URL and Token not found' } + } + const { flowUrl, flowToken } = result + const response = await fetch(flowUrl + '/chatflows', { + method: 'GET', + headers: { + Authorization: 'Bearer ' + flowToken, + Accept: '*/*', + }, + }) + + if (!response.ok) { + return { error: 'Failed to fetch flows' } + } + + const data = await response.json() + + const chatflows = await prisma.chatFlows.upsert({ + where: { + id: "1", + }, + update: { + flows: data, + }, + create: { + flows: data, + }, + }) + return { data: chatflows } + }, { + detail: { + summary: "Sync chatflows", + description: "Sync chatflows", + } + }) + .get('/find', async ctx => { + const result = await prisma.chatFlows.findUnique({ + where: { id: "1" }, + }) + if (!result) { + return { flows: [], defaultFlow: null, flowUrl: null, flowToken: null } + } + const flows = _.orderBy(result?.flows as any[], ['type'], ['asc']) + const defaultFlow = result?.defaultFlow + const flowUrl = result?.flowUrl + const flowToken = result?.flowToken + return { flows, defaultFlow, flowUrl, flowToken } + }, { + detail: { + summary: "Find chatflows", + description: "Find chatflows", + } + }) + .get("/default", async ctx => { + const result = await prisma.chatFlows.findUnique({ + where: { id: "1" }, + }) + if (!result) { + return { defaultFlow: null, defaultData: null } + } + const defaultFlow = result?.defaultFlow + const defaultData = result?.defaultData + return { defaultFlow, defaultData } + }, { + detail: { + summary: "Get default chatflows", + description: "Get default chatflows", + } + }) + .put( + '/default', + async ctx => { + const { id, defaultData } = ctx.body + + const result = await prisma.chatFlows.update({ + where: { + id: "1", + }, + data: { + defaultFlow: id, + defaultData: defaultData, + }, + }) + return { data: result } + }, + { + body: t.Object({ + id: t.String(), + defaultData: t.Optional(t.Any()), + }), + detail: { + summary: "Update default chatflows", + description: "Update default chatflows", + } + } + ) + .post( + '/query', + async ctx => { + const { flowId, question } = ctx.body + const result = await chatFlowQuery({ flowId, question }) + return { data: result } + }, + { + body: t.Object({ + flowId: t.String(), + question: t.String(), + }), + detail: { + summary: "Query chatflows", + description: "Query chatflows", + } + } + ) + .put( + '/flow-active', + async ctx => { + const { active } = ctx.body + const result = await prisma.chatFlows.upsert({ + where: { + id: "1", + }, + update: { + active: active, + }, + create: { + active: active, + }, + }) + return { data: result } + }, + { + body: t.Object({ + active: t.Boolean(), + }), + detail: { + summary: "Update flow active", + description: "Update flow active", + } + } + ) + .get('/url-token', async ctx => { + const result = await prisma.chatFlows.findUnique({ + where: { id: "1" }, + select: { + flowUrl: true, + flowToken: true, + }, + }) + if (!result) { + return { data: { flowUrl: null, flowToken: null } } + } + return { data: { flowUrl: result.flowUrl, flowToken: result.flowToken } } + }, { + detail: { + summary: "Get flow url and token", + description: "Get flow url and token", + } + }) + .put( + '/url-token', + async ctx => { + const { flowUrl, flowToken } = ctx.body + const result = await prisma.chatFlows.upsert({ + where: { + id: "1", + }, + update: { + flowUrl: flowUrl, + flowToken: flowToken, + }, + create: { + id: "1", + flowUrl: flowUrl, + flowToken: flowToken, + }, + }) + return { data: result } + }, + { + body: t.Object({ + flowUrl: t.String(), + flowToken: t.String(), + }), + detail: { + summary: "Update flow url and token", + description: "Update flow url and token", + } + } + ) + .on('error', ctx => { + console.log(ctx.error) + return { error: ctx.error } + }) + +export default FlowRoute + +async function chatFlowQuery({ + flowId, + question, +}: { + flowId: string + question: string +}) { + try { + const resultUrlToken = await prisma.chatFlows.findUnique({ where: { id: "1" }, select: { flowUrl: true, flowToken: true } }) + if (!resultUrlToken) { + return { error: 'Flow URL and Token not found' } + } + const { flowUrl, flowToken } = resultUrlToken + if (!flowUrl || !flowToken) { + return { error: 'Flow URL and Token not found' } + } + const response = await fetch(`${flowUrl}/prediction/${flowId}`, { + headers: { + Authorization: `Bearer ${flowToken}`, + 'Content-Type': 'application/json', + }, + method: 'POST', + body: JSON.stringify({ + question, + overrideConfig: { + sessionId: "1", + }, + }), + }) + const result = await response.text() + return JSON.parse(result).text + } catch (error) { + console.log(error) + return 'Failed to fetch response' + } +} diff --git a/x.sh b/x.sh index bb80b7b..7fcf91c 100644 --- a/x.sh +++ b/x.sh @@ -1,8 +1,7 @@ +TOKEN="EAALP22EWyC4BPnZCfcPQNmD5pGLKV6Ao3GIeWZCc81aPivDFc2FXGA1ZBgrRGcB60LaZCdAr1sbnfP1ufrH3dGthxQzpf18BTjDZBkgG3vBiYZAMpHa7MEZBiRIUZCBe4BDXe8KV0r7DsDmQHJqhA3yZBDKPOL1PKJPEqIq40tLxPwMqWYg4o7xf0sBmZCzx2wI1KtJL8I20MV1ggldngHZCIcnOKDL0uPzDAhc2LAQuI7ZBsgZDZD" +MEDIA_ID="24893686766920074" +BUSINESS_PHONE_NUMBER_ID="783866307805501" -#!/bin/bash -TOKEN="EAALP22EWyC4BPv7XnK1xSaZCWccblEoJFbHzPZAf5mlp4678lSM7cqhQl1ExATf8abrOpinvvFF6U6ruK2FsJqIk8wg6DiUz2fc0NYfcwjon3ng7I3C5HSDQHecgTiJLUBxfZAcvE4IIlhks722jakXaJpojlByo8QJ0CEURtzwEU1guFq7YTX3Et0ZCkbhkdftZCOGmpUKFjL5w5nUdd26Nd58YrLVZCoT8NKhxpWFQZDZD" -curl -i -X POST \ - https://graph.facebook.com/v22.0/838757782652201/messages \ - -H 'Authorization: Bearer $TOKEN' \ - -H 'Content-Type: application/json' \ - -d '{ "messaging_product": "whatsapp", "to": "6289505046093", "type": "template", "template": { "name": "hello_world", "language": { "code": "en_US" } } }' \ No newline at end of file +curl 'https://graph.facebook.com/v19.0/$MEDIA_ID?phone_number_id=$BUSINESS_PHONE_NUMBER_ID' \ +-H 'Authorization: Bearer $TOKEN' \ +-H 'Content-Type: application/json' \ No newline at end of file diff --git a/xx.ts b/xx.ts new file mode 100644 index 0000000..5cc580c --- /dev/null +++ b/xx.ts @@ -0,0 +1,24 @@ +import fetch from "node-fetch"; +import fs from "fs"; + +const token = "EAALP22EWyC4BPrjshjjYBbPVKWp4Gp2ljkb7hCmgpZArLigB8XNmRoXBomDJm6aWnjpKpqehdVatbfFAHeGaQftGkNBp4Oyds9apr4lOQjG2YWYEzZC05ZAo7MARnfXn7FVua0iaeNMh2gunMZBd6pO58wjAUP3gqLiUrwASeOnJu5pW3tKg6fHubALBlQZDZD"; // dari Meta Developer > App > Access Token +const mediaId = "838467435201133"; // dari webhook + +// 1. Dapatkan URL file asli +const mediaInfo = await fetch( + `https://graph.facebook.com/v19.0/${mediaId}?access_token=${token}` +).then(res => res.json()) as any; + +// mediaInfo.url berisi link unduhan sementara +const fileUrl = mediaInfo.url; + +const fileResponse = await fetch(fileUrl, { + headers: { + Authorization: `Bearer ${token}`, // wajib! + }, +}); + +const buffer = await fileResponse.arrayBuffer(); +fs.writeFileSync("sticker.webp", Buffer.from(buffer)); + +console.log("Sticker berhasil diunduh!");