(params: CreateBotRequestParams)
| 29 | * on this row existing, so a silent failure here would drop the result. |
| 30 | */ |
| 31 | export async function createBotRequest(params: CreateBotRequestParams): Promise<string> { |
| 32 | const [row] = await db |
| 33 | .insert(bot_requests) |
| 34 | .values({ |
| 35 | created_by: params.createdBy, |
| 36 | organization_id: params.organizationId, |
| 37 | platform_integration_id: params.platformIntegrationId, |
| 38 | platform: params.platform, |
| 39 | platform_thread_id: params.platformThreadId, |
| 40 | platform_message_id: params.platformMessageId, |
| 41 | user_message: params.userMessage, |
| 42 | model_used: params.modelUsed ?? null, |
| 43 | status: 'pending', |
| 44 | }) |
| 45 | .returning({ id: bot_requests.id }); |
| 46 | |
| 47 | if (!row) { |
| 48 | throw new Error('createBotRequest: insert returned no row'); |
| 49 | } |
| 50 | |
| 51 | return row.id; |
| 52 | } |
| 53 | |
| 54 | type UpdateBotRequestParams = { |
| 55 | status?: BotRequestStatus; |
no test coverage detected