跳到内容
CADCAMFUN
文档

文档

申请服务

桌面集成路线、跟踪的项目操作、通知和推送订阅记录。

从英文自动翻译。 查看英文原文

调试台

将这些请求发送到您自己正在运行的 sidecar。值保留在此浏览器中。

未连接
这是如何运作的

sidecar 侦听启动时选择的环回端口并将其打印在其中 ready 线;使用该 URL 和 CADCAMFUN_TOKEN 它是从开始的。请求直接从该页面发送到该地址。

sidecar 仅将 CORS 标头发送到 Tauri 源并发送到 http://localhost 或 http://127.0.0.1 在任何端口上。浏览器会阻止托管文档的响应,因此请在本地运行文档(bun run dev 中 packages/web) 使用游乐场,或将请求复制为curl。要在不接触真实数据的情况下进行实验,请使用以下命令启动 sidecar CADCAMFUN_DATA_DIR 指向一个一次性目录 - 请参阅 aPI 演练.

运营

10 个端点,位于 misc 组,由 sidecar 自己生成 开放API文档。受保护的操作需要 Authorization: Bearer $CADCAMFUN_TOKEN;看 验证。行为和限制在 子系统指南.

邮政 /api/push-subscription misc.pushSubscribe
删除 /api/push-subscription misc.pushUnsubscribe
邮政 /api/app-control/notify misc.notify
邮政 /api/desktop/auth/signin misc.desktopSignin
得到 /api/desktop/projects misc.desktopProjects
邮政 /api/desktop/projects misc.desktopCreateProject
得到 /api/desktop/user/by-email misc.desktopUserByEmail
得到 /api/projects/tracked/{id} misc.trackedGet
放 /api/projects/tracked/{id} misc.trackedUpdate
删除 /api/projects/tracked/{id} misc.trackedRemove
3D 中的应用程序服务操作 拖动进行轨道旋转·滚动进行缩放·右键拖动进行平移
每个操作一个块 (10),按此页面的每个资源部分堆叠,并按方法着色:绿色 GET、橙色 POST、蓝色 PUT、紫色 PATCH、红色 DELETE。在构建时从 OpenAPI 文档生成。

/api/push-subscription

邮政 /api/push-subscription # misc.pushSubscribe

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  endpoint?: string | null
  keys?: {
    p256dh?: string | null
    auth?: string | null
  } | null
}
回应
200 目的 application/json
{
  success: true
  id: string
}
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK示例
misc.pushSubscribe
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// MiscPushSubscribeInput
const result = await client.misc.pushSubscribe({
  endpoint: "",
  keys: {}
})
curl
POST /api/推送订阅
curl --request POST "${CADCAMFUN_URL}/api/push-subscription" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下
删除 /api/push-subscription # misc.pushUnsubscribe

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  endpoint?: string | null
}
回应
200 目的 application/json
{
  success: true
}
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK示例
misc.pushUnsubscribe
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// MiscPushUnsubscribeInput
const result = await client.misc.pushUnsubscribe({
  endpoint: ""
})
curl
删除 /api/push-subscription
curl --request DELETE "${CADCAMFUN_URL}/api/push-subscription" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下

/api/app-control/notify

邮政 /api/app-control/notify # misc.notify

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  userId?: string | null
  message?: unknown | null
}
回应
200 目的 application/json
{
  success: true
  message: string
}
400 NotifyBadRequestEncoded application/json
NotifyBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 NotifyInternalEncoded application/json
NotifyInternalEncoded
SDK示例
misc.notify
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// MiscNotifyInput
const result = await client.misc.notify({
  userId: "",
  message: null
})
curl
POST /api/应用程序控制/通知
curl --request POST "${CADCAMFUN_URL}/api/app-control/notify" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下

/api/desktop/auth

邮政 /api/desktop/auth/signin # misc.desktopSignin

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  email?: string | null
  password?: string | null
  deviceId?: string | null
  platform?: string | null
}
回应
200 目的 application/json
{
  success: true
  token: string
  user: {
    id: string
    name: string | null
    email: string | null
    image: string | null
  }
  syncData: {
    lastSync: string
    version: string
  }
}
400 DesktopBadRequestEncoded application/json
DesktopBadRequestEncoded
401 桌面未经授权编码|未经授权的编码 application/json
DesktopUnauthorizedEncoded | UnauthorizedEncoded
500 DesktopInternalEncoded application/json
DesktopInternalEncoded
SDK示例
misc.desktopSignin
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// MiscDesktopSigninInput
const result = await client.misc.desktopSignin({
  email: "",
  password: "",
  deviceId: "",
  platform: ""
})
curl
POST /api/desktop/auth/signin
curl --request POST "${CADCAMFUN_URL}/api/desktop/auth/signin" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下

/api/desktop/projects

得到 /api/desktop/projects # misc.desktopProjects

需要 Authorization: Bearer <token>.

回应
200 目的 application/json
{
  success: true
  data: Array<{
    id: string
    name: string
    description: string | null
    owner_id: string
    organization_id: string | null
    is_public: boolean
    created_at: string
    updated_at: string
  }>
  message: string
}
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 DesktopInternalEncoded application/json
DesktopInternalEncoded
响应示例 捕获·200
获取/api/桌面/项目
{
  "success": true,
  "data": [],
  "message": "Retrieved 0 projects"
}
SDK示例
misc.desktopProjects
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// no input
const result = await client.misc.desktopProjects()
curl
获取/api/桌面/项目
curl --request GET "${CADCAMFUN_URL}/api/desktop/projects" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}"
尝试一下
邮政 /api/desktop/projects # misc.desktopCreateProject

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  name?: unknown | null
  description?: string | null
  organization_id?: string | null
  is_public?: boolean | null
}
回应
201 目的 application/json
{
  success: true
  data: {
    id: string
    name: string
    description: string | null
    owner_id: string
    organization_id: string | null
    is_public: boolean
    created_at: string
    updated_at: string
  }
  message: string
}
400 DesktopBadRequestEncoded application/json
DesktopBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
409 DesktopConflictEncoded application/json
DesktopConflictEncoded
500 DesktopInternalEncoded application/json
DesktopInternalEncoded
SDK示例
misc.desktopCreateProject
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// MiscDesktopCreateProjectInput
const result = await client.misc.desktopCreateProject({
  name: null,
  description: "",
  organization_id: "",
  is_public: false
})
curl
POST /api/桌面/项目
curl --request POST "${CADCAMFUN_URL}/api/desktop/projects" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下

/api/desktop/user

得到 /api/desktop/user/by-email # misc.desktopUserByEmail

需要 Authorization: Bearer <token>.

参数
姓名在类型必需的
电子邮件 询问 细绳 | null 选修的
回应
200 目的 application/json
{
  success: true
  data: {
    id: string
    name: string | null
    email: string | null
    image: string | null
    created_at: string
    updated_at: string
  }
  message: string
}
400 DesktopBadRequestEncoded application/json
DesktopBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 DesktopNotFoundEncoded application/json
DesktopNotFoundEncoded
500 DesktopInternalEncoded application/json
DesktopInternalEncoded
响应示例 捕获·400
GET /api/desktop/user/通过电子邮件
{
  "_tag": "DesktopBadRequest",
  "success": false,
  "error": "Email parameter is required"
}
SDK示例
misc.desktopUserByEmail
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// MiscDesktopUserByEmailInput
const result = await client.misc.desktopUserByEmail({})
curl
GET /api/desktop/user/通过电子邮件
curl --request GET "${CADCAMFUN_URL}/api/desktop/user/by-email" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}"
尝试一下

/api/projects/tracked

得到 /api/projects/tracked/{id} # misc.trackedGet

需要 Authorization: Bearer <token>.

参数
姓名在类型必需的
iD 小路 细绳 必需的
回应
200 目的 application/json
{
  id: string
  name: string
  description: string | null
  createdAt: string
  updatedAt: string
  ownerId: string
  organizationId: string | null
  isPublic: boolean
  owner: {
    id: string
    name: string | null
    email: string | null
  }
  organization: {
    id: string
    name: string
  } | null
  _count: {
    drawings: number | "Infinity" | "-Infinity" | "NaN"
    components: number | "Infinity" | "-Infinity" | "NaN"
  }
}
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK示例
misc.trackedGet
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// MiscTrackedGetInput
const result = await client.misc.trackedGet({
  id: "<id>"
})
curl
获取 /api/projects/tracked/{id}
curl --request GET "${CADCAMFUN_URL}/api/projects/tracked/<id>" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}"
尝试一下
放 /api/projects/tracked/{id} # misc.trackedUpdate

需要 Authorization: Bearer <token>.

参数
姓名在类型必需的
iD 小路 细绳 必需的
请求正文 · 必填 · application/json
{
  name?: string | null
  description?: string | null
  organizationId?: string | null
}
回应
200 目的 application/json
{
  id: string
  name: string
  description: string | null
  createdAt: string
  updatedAt: string
  ownerId: string
  organizationId: string | null
  isPublic: boolean
  owner: {
    id: string
    name: string | null
    email: string | null
  }
  organization: {
    id: string
    name: string
  } | null
  _count: {
    drawings: number | "Infinity" | "-Infinity" | "NaN"
    components: number | "Infinity" | "-Infinity" | "NaN"
  }
}
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
403 ForbiddenEncoded application/json
ForbiddenEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK示例
misc.trackedUpdate
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// MiscTrackedUpdateInput
const result = await client.misc.trackedUpdate({
  id: "<id>",
  name: "",
  description: "",
  organizationId: ""
})
curl
PUT /api/projects/tracked/{id}
curl --request PUT "${CADCAMFUN_URL}/api/projects/tracked/<id>" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下
删除 /api/projects/tracked/{id} # misc.trackedRemove

需要 Authorization: Bearer <token>.

参数
姓名在类型必需的
iD 小路 细绳 必需的
回应
200 目的 application/json
{
  message: string
}
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
403 ForbiddenEncoded application/json
ForbiddenEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK示例
misc.trackedRemove
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// MiscTrackedRemoveInput
const result = await client.misc.trackedRemove({
  id: "<id>"
})
curl
删除 /api/projects/tracked/{id}
curl --request DELETE "${CADCAMFUN_URL}/api/projects/tracked/<id>" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}"
尝试一下

模式

可从该组的参数、主体和响应访问命名模式。一个 ? 标记可选字段; | null 标记可能存在空值的字段。

BadRequestEncoded
{
  _tag: "BadRequest"
  message: string
}
DesktopBadRequestEncoded
{
  _tag: "DesktopBadRequest"
  success: false
  error: string
}
DesktopConflictEncoded
{
  _tag: "DesktopConflict"
  success: false
  error: string
}
DesktopInternalEncoded
{
  _tag: "DesktopInternal"
  success: false
  error: string
}
DesktopNotFoundEncoded
{
  _tag: "DesktopNotFound"
  success: false
  error: string
}
DesktopUnauthorizedEncoded
{
  _tag: "DesktopUnauthorized"
  success: false
  error: string
}
ForbiddenEncoded
{
  _tag: "Forbidden"
  message: string
}
InternalErrorEncoded
{
  _tag: "InternalError"
  message: string
}
NotFoundEncoded
{
  _tag: "NotFound"
  message: string
}
NotifyBadRequestEncoded
{
  _tag: "NotifyBadRequest"
  success: false
  error: string
}
NotifyInternalEncoded
{
  _tag: "NotifyInternal"
  success: false
  error: string
}
UnauthorizedEncoded
{
  _tag: "Unauthorized"
  message: string
}

呼叫该群组

操作 ID 的形式为 misc.<name>。生成的Promise SDK(@cadcamfun/api/sdk)将其中大部分暴露为 client.<namespace>.<method>(input), 在哪里 input 是路径参数和主体字段的一个平面对象;每张卡的 SDK 示例显示了确切的访问器和输入类型。不会生成分段上传、二进制或 JavaScript 响应以及原始 Webhook;这些卡片显示 fetch 改为。

Promise SDK 的错误
import { CadCam, ClientError } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

try {
  await client.projects.list()
} catch (error) {
  if (error instanceof ClientError) {
    // Transport | UnexpectedStatus | UnsupportedContentType | MalformedResponse | SseEventTooLarge
  } else {
    // a declared error body: switch on error._tag
  }
}

故障排除

症状可能的原因使固定
每次调用 401上次启动的令牌或丢失 Bearer 前缀发送 Authorization: Bearer <token> 使用边车启动时的令牌。
在任何事情发生之前的 400主体或参数与架构不匹配将有效负载与卡上的请求架构进行比较。
在别处可见的记录上出现 403 或 404代理账户不同发送正确的 x-session-token,或使用拥有该记录的本地配置文件。
409状态冲突,例如重复的名称或过时的分支头重新读取资源并使用当前数据重试。
尝试显示“被 CORS 阻止”这些文档是从非环回源提供的在本地运行文档或将请求复制为curl。
连接被拒绝Sidecar 在新端口上重新启动从新读取端口 ready 行。