Add public API endpoints#323
Conversation
2bee7ed to
6c6cd14
Compare
| }) | ||
| .output(chatbotResource.omit({ token: true })) | ||
| .handler(async ({ context }) => { | ||
| return await findChatbotOrFail({ id: context.workspace.id }) |
There was a problem hiding this comment.
lấy ra từ context.workspace, không cần query lại
| summary: "Get workspace", | ||
| tags: ["Workspace"], | ||
| }) | ||
| .output(chatbotResource.omit({ token: true })) |
There was a problem hiding this comment.
.omit({ token: true }
chuyển cái này vào trong resource luôn
| import { sequenceResource } from "../schema/resource" | ||
|
|
||
| export const chatbotTokenSequencesAPIs = { | ||
| listSequencesChatbotTokenAPI: workspaceTokenAuthAPI |
There was a problem hiding this comment.
ChatbotToken => WorkspaceToken
anh đổi hàng loạt giúp em
|
|
||
| export type ListErrorLogsRequest = z.infer<typeof listErrorLogsRequest> | ||
|
|
||
| export const publicErrorLogResource = createSelectSchema(errorLogModel) |
There was a problem hiding this comment.
resource thì nên để bên resource, để tránh circular dependencies
ví dụ thằng contact, cần publicErrorLogResource, sẽ import file này
file này cũng cần trả ra contactResource => file này lại import contact
=> import vòng
ngoài ra anh giúp em define lại ErrorLogResource cho giống mấy thằng khác
| export const channelResource = z.object({ | ||
| id: z.string(), | ||
| name: z.string(), | ||
| type: z.enum(["messenger", "whatsapp", "zalo", "webchat"]), |
There was a problem hiding this comment.
tạo channelTypes = z.enum(...) ở packages/database/src/partials/integration.ts để tái sử dụng
| import { findIntegrationZalo } from "@/features/integration-zalo/queries" | ||
| import type { ListChannelsResponse } from "../schema/resource" | ||
|
|
||
| export const listChannels = async ( |
There was a problem hiding this comment.
channel phải đọc ở table integrations
from integrations where integrationType in (${channelTypes.options})
anh nhớ thêm order,
hệ thống đang có thể add nhiều channels cùng loại vào chung 1 workspace, ví dụ 1 workspace có thể có nhiều channel whatsapp
| }) | ||
| .output(listChannelsResponse) | ||
| .handler(async ({ context }) => { | ||
| return await listChannels(context.workspace.id) |
There was a problem hiding this comment.
list thì nên truyền vào object luôn, sau đỡ sữa
listChannels({
workspace: context.workspace.id
})
4106d84 to
f9d3de8
Compare
f9d3de8 to
26af13a
Compare
No description provided.