Skip to content

Add public API endpoints#323

Merged
realcodesiman merged 7 commits into
mainfrom
feat/add-public-apis
Apr 9, 2026
Merged

Add public API endpoints#323
realcodesiman merged 7 commits into
mainfrom
feat/add-public-apis

Conversation

@hoangle398
Copy link
Copy Markdown
Contributor

No description provided.

})
.output(chatbotResource.omit({ token: true }))
.handler(async ({ context }) => {
return await findChatbotOrFail({ id: context.workspace.id })
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lấy ra từ context.workspace, không cần query lại

summary: "Get workspace",
tags: ["Workspace"],
})
.output(chatbotResource.omit({ token: true }))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChatbotToken => WorkspaceToken
anh đổi hàng loạt giúp em


export type ListErrorLogsRequest = z.infer<typeof listErrorLogsRequest>

export const publicErrorLogResource = createSelectSchema(errorLogModel)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"]),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list thì nên truyền vào object luôn, sau đỡ sữa

listChannels({
  workspace: context.workspace.id
})

@realcodesiman realcodesiman merged commit eb7be15 into main Apr 9, 2026
6 checks passed
@realcodesiman realcodesiman deleted the feat/add-public-apis branch April 9, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants