Files
ai_site/platform/internal/handler/openapi.yaml
whm 76cdcd760e feat: ship loose-offline dbsync (validate, agent push, LWW audit)
Add UUID/FK channel checks, agent whitelist/push APIs, bindings, super-admin LWW audit with rollback, reconcile rate limits, and sync docs. Default customers stay opt-in; company conflict UI is removed.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-31 17:54:14 +08:00

462 lines
14 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
openapi: 3.0.3
info:
title: AI建站 Platform API
version: 1.0.0
description: |
通用中台契约。业务行数据仅通过 apps/{slug}/{resource} CRUD 传输;
行业字段由蓝图定义,不在此增加行业专用路由。
动词约定GET 读 / POST 创建或动作 / PUT 更新 / DELETE 删除。
servers:
- url: http://127.0.0.1:8180
paths:
/api/v1/meta/apis:
get:
operationId: listApis
summary: API 目录
responses:
"200":
description: OK
/api/v1/meta/openapi.yaml:
get:
operationId: getOpenAPI
summary: OpenAPI 原文
responses:
"200":
description: YAML
/api/v1/auth/register:
post:
operationId: authRegister
summary: 注册
responses:
"201": { description: Created }
/api/v1/auth/login:
post:
operationId: authLogin
summary: 登录
responses:
"200": { description: OK }
/api/v1/auth/token:
post:
operationId: authToken
summary: 服务签发 JWT
responses:
"200": { description: OK }
/api/v1/apps/{slug}/publish:
post:
operationId: publishApp
summary: 发布蓝图
parameters:
- $ref: "#/components/parameters/Slug"
- $ref: "#/components/parameters/Authorization"
responses:
"200": { description: OK }
/api/v1/apps/{slug}/blueprint:
get:
operationId: getBlueprint
summary: 读取蓝图
parameters:
- $ref: "#/components/parameters/Slug"
- $ref: "#/components/parameters/Authorization"
responses:
"200": { description: OK }
/api/v1/apps/{slug}/agent-capsule:
get:
operationId: getAgentCapsule
summary: 智能体胶囊
parameters:
- $ref: "#/components/parameters/Slug"
- $ref: "#/components/parameters/Authorization"
responses:
"200": { description: OK }
/api/v1/apps/{slug}/{resource}:
parameters:
- $ref: "#/components/parameters/Slug"
- $ref: "#/components/parameters/Resource"
- $ref: "#/components/parameters/Authorization"
get:
operationId: listRows
summary: 列表
parameters:
- name: page
in: query
schema: { type: integer, minimum: 1, default: 1 }
- name: page_size
in: query
schema: { type: integer, minimum: 1, maximum: 100, default: 20 }
- name: sort
in: query
schema: { type: string }
- name: filter.*
in: query
description: 如 filter.status=在售,键须在蓝图 allowed_filters
schema: { type: string }
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/PageResult"
post:
operationId: createRow
summary: 创建
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: true
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: "#/components/schemas/Row"
/api/v1/apps/{slug}/{resource}/{id}:
parameters:
- $ref: "#/components/parameters/Slug"
- $ref: "#/components/parameters/Resource"
- $ref: "#/components/parameters/Id"
- $ref: "#/components/parameters/Authorization"
get:
operationId: getRow
summary: 详情
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Row"
"404":
$ref: "#/components/responses/NotFound"
put:
operationId: updateRow
summary: 更新
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: true
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Row"
delete:
operationId: deleteRow
summary: 删除
responses:
"204": { description: No Content }
/api/v1/apps/{slug}/{resource}/import:
post:
operationId: importRows
summary: 导入
parameters:
- $ref: "#/components/parameters/Slug"
- $ref: "#/components/parameters/Resource"
- $ref: "#/components/parameters/Authorization"
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required: [file]
properties:
file: { type: string, format: binary }
responses:
"200": { description: OK }
/api/v1/apps/{slug}/{resource}/export:
get:
operationId: exportRows
summary: 导出
parameters:
- $ref: "#/components/parameters/Slug"
- $ref: "#/components/parameters/Resource"
- $ref: "#/components/parameters/Authorization"
- name: format
in: query
schema: { type: string, enum: [xlsx, csv], default: xlsx }
responses:
"200": { description: 文件流 }
/api/v1/apps/{slug}/{resource}/aggregate:
get:
operationId: aggregateRows
summary: 聚合
parameters:
- $ref: "#/components/parameters/Slug"
- $ref: "#/components/parameters/Resource"
- $ref: "#/components/parameters/Authorization"
- name: group_by
in: query
schema: { type: string }
- name: sum
in: query
schema: { type: string }
responses:
"200": { description: OK }
/api/v1/audit/logs:
get:
operationId: listAuditLogs
summary: 审计日志
parameters:
- $ref: "#/components/parameters/Authorization"
responses:
"200": { description: OK }
/api/v1/storage:
post:
operationId: uploadObject
summary: 上传
parameters:
- $ref: "#/components/parameters/Authorization"
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required: [file]
properties:
file: { type: string, format: binary }
responses:
"200": { description: OK }
/api/v1/storage/{tenant}/{day}/{name}:
get:
operationId: downloadObject
summary: 下载
parameters:
- $ref: "#/components/parameters/Authorization"
- name: tenant
in: path
required: true
schema: { type: string }
- name: day
in: path
required: true
schema: { type: string }
- name: name
in: path
required: true
schema: { type: string }
responses:
"200": { description: 文件流 }
/api/v1/apps/generate:
post:
operationId: generateBlueprint
summary: 生成蓝图AI 服务,经网关 /ai 前缀)
description: 实际请求 /ai/api/v1/apps/generate勿在 platform 重复实现。
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
prompt: { type: string }
excel: { type: string, format: binary }
images: { type: string, format: binary }
responses:
"200": { description: OK }
/api/v1/llm/providers:
get:
operationId: listLlmProviders
summary: LLM 厂商AI 服务)
responses:
"200": { description: OK }
/api/v1/admin/sync/channels:
get:
operationId: listSyncChannels
summary: 列出同步通道
parameters: [{ $ref: "#/components/parameters/Authorization" }]
responses: { "200": { description: OK } }
post:
operationId: createSyncChannel
summary: 创建同步通道UUID PK + FK 闭包校验)
parameters: [{ $ref: "#/components/parameters/Authorization" }]
responses: { "200": { description: OK }, "400": { description: Bad Request } }
/api/v1/admin/sync/channels/{id}:
get:
operationId: getSyncChannel
summary: 获取同步通道
parameters:
- { $ref: "#/components/parameters/Authorization" }
- { $ref: "#/components/parameters/Id" }
responses: { "200": { description: OK } }
put:
operationId: updateSyncChannel
summary: 更新同步通道
parameters:
- { $ref: "#/components/parameters/Authorization" }
- { $ref: "#/components/parameters/Id" }
responses: { "200": { description: OK } }
delete:
operationId: deleteSyncChannel
summary: 删除同步通道
parameters:
- { $ref: "#/components/parameters/Authorization" }
- { $ref: "#/components/parameters/Id" }
responses: { "200": { description: OK } }
/api/v1/admin/sync/test:
post:
operationId: testSyncEndpoints
summary: 测试本地/线上库连接
parameters: [{ $ref: "#/components/parameters/Authorization" }]
responses: { "200": { description: OK } }
/api/v1/admin/sync/channels/{id}/prepare:
post:
operationId: prepareSyncChannel
summary: 准备同步outbox/触发器)
parameters:
- { $ref: "#/components/parameters/Authorization" }
- { $ref: "#/components/parameters/Id" }
responses: { "200": { description: OK } }
/api/v1/admin/sync/channels/{id}/start:
post:
operationId: startSyncChannel
summary: 启动同步
parameters:
- { $ref: "#/components/parameters/Authorization" }
- { $ref: "#/components/parameters/Id" }
responses: { "200": { description: OK } }
/api/v1/admin/sync/channels/{id}/stop:
post:
operationId: stopSyncChannel
summary: 停止同步
parameters:
- { $ref: "#/components/parameters/Authorization" }
- { $ref: "#/components/parameters/Id" }
responses: { "200": { description: OK } }
/api/v1/admin/sync/channels/{id}/reconcile:
post:
operationId: reconcileSyncChannel
summary: 同步修复(对账,有限流)
parameters:
- { $ref: "#/components/parameters/Authorization" }
- { $ref: "#/components/parameters/Id" }
responses: { "200": { description: OK }, "429": { description: Too Many Requests } }
/api/v1/admin/sync/channels/{id}/ingest:
post:
operationId: ingestSyncRows
summary: 外部行写入通道 local
parameters:
- { $ref: "#/components/parameters/Authorization" }
- { $ref: "#/components/parameters/Id" }
responses: { "200": { description: OK } }
/api/v1/admin/sync/bindings:
get:
operationId: listSyncBindings
summary: 列出本机库↔线上库绑定
parameters: [{ $ref: "#/components/parameters/Authorization" }]
responses: { "200": { description: OK } }
post:
operationId: ensureSyncBinding
summary: 登记/更新绑定
parameters: [{ $ref: "#/components/parameters/Authorization" }]
responses: { "200": { description: OK } }
/api/v1/admin/sync/conflicts:
get:
operationId: listSyncConflicts
summary: 已废弃(公司侧 403
parameters: [{ $ref: "#/components/parameters/Authorization" }]
responses: { "403": { description: Forbidden } }
/api/v1/agent/sync/channels/{id}/whitelist:
get:
operationId: agentSyncWhitelist
summary: 本机 agent 拉取表白名单
parameters:
- { $ref: "#/components/parameters/Authorization" }
- { $ref: "#/components/parameters/Id" }
responses: { "200": { description: OK } }
/api/v1/agent/sync/channels/{id}/push:
post:
operationId: agentSyncPush
summary: 本机 agent 推变更到线上 A
parameters:
- { $ref: "#/components/parameters/Authorization" }
- { $ref: "#/components/parameters/Id" }
responses: { "200": { description: OK } }
/api/v1/agent/sync/channels/{id}/push/batch:
post:
operationId: agentSyncPushBatch
summary: 本机 agent 批量推送
parameters:
- { $ref: "#/components/parameters/Authorization" }
- { $ref: "#/components/parameters/Id" }
responses: { "200": { description: OK } }
/api/v1/platform/dbsync/lww-overrides:
get:
operationId: platformLwwOverrides
summary: 超管 LWW 覆盖审计
parameters: [{ $ref: "#/components/parameters/Authorization" }]
responses: { "200": { description: OK }, "403": { description: Forbidden } }
/api/v1/platform/dbsync/lww-overrides/{id}/rollback:
post:
operationId: platformLwwRollback
summary: 超管按落败快照回滚线上单行
parameters:
- { $ref: "#/components/parameters/Authorization" }
- { $ref: "#/components/parameters/Id" }
responses: { "200": { description: OK }, "400": { description: Bad Request } }
components:
parameters:
Authorization:
name: Authorization
in: header
required: true
schema: { type: string }
description: Bearer JWT
Slug:
name: slug
in: path
required: true
schema: { type: string, pattern: "^[a-z][a-z0-9_]{1,47}$" }
Resource:
name: resource
in: path
required: true
schema: { type: string }
description: 蓝图 apis.resources.path无前导 /);不可为保留名
Id:
name: id
in: path
required: true
schema: { type: string }
schemas:
PageResult:
type: object
properties:
items: { type: array, items: { $ref: "#/components/schemas/Row" } }
total: { type: integer }
Row:
type: object
additionalProperties: true
responses:
NotFound:
description: Not Found
content:
application/json:
schema:
type: object
properties:
code: { type: integer }
message: { type: string }