chore: 按用途整理工程脚本与验证入口
将内部脚本归入 build、release、generate、dev 和 checks,保留公开安装脚本路径。 同步命令、CI、发布流程、脚本间调用及根目录定位,补齐脚本说明与完成报告。 验证:929 项测试、类型与版本检查通过;二进制及插件构建、冒烟与打包通过。 OpenAPI 产物不变;工作流 Schema 导出存在基线即可复现的 Zod transform 错误,单独记录。
This commit is contained in:
1 parent
b1e9c7eed3
commit
c71b20c25b
24 files changed
+133
-44
No files matched your search
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import YAML from "yaml";
|
||||
|
||||
type Json = null | boolean | number | string | Json[] | { [key: string]: Json };
|
||||
|
||||
const inputFile = resolve("specs/hose-open-api/openapi.yaml");
|
||||
const outputFile = resolve("specs/openapi.json");
|
||||
|
||||
const bundled = bundle(inputFile, new Set());
|
||||
|
||||
mkdirSync(dirname(outputFile), { recursive: true });
|
||||
writeFileSync(outputFile, `${JSON.stringify(bundled, null, 2)}\n`);
|
||||
console.log(`✓ Bundled wrapped OpenAPI: ${outputFile}`);
|
||||
|
||||
function bundle(filePath: string, seen: Set<string>): Json {
|
||||
const absolutePath = resolve(filePath);
|
||||
if (seen.has(absolutePath)) {
|
||||
throw new Error(`Circular OpenAPI reference: ${absolutePath}`);
|
||||
}
|
||||
|
||||
const parsed = YAML.parse(readFileSync(absolutePath, "utf8")) as Json;
|
||||
return resolveReferences(parsed, absolutePath, new Set([...seen, absolutePath]));
|
||||
}
|
||||
|
||||
function resolveReferences(value: Json, currentFile: string, seen: Set<string>): Json {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((item) => resolveReferences(item, currentFile, seen));
|
||||
}
|
||||
|
||||
if (!isObject(value)) return value;
|
||||
|
||||
if (typeof value.$ref === "string" && isFileReference(value.$ref)) {
|
||||
const [refPath, pointer = ""] = value.$ref.split("#");
|
||||
const refFile = refPath ? resolve(dirname(currentFile), refPath) : currentFile;
|
||||
const target = pointer ? resolvePointer(bundle(refFile, seen), pointer) : bundle(refFile, seen);
|
||||
return resolveReferences(target, refFile, seen);
|
||||
}
|
||||
|
||||
return Object.fromEntries(
|
||||
Object.entries(value).map(([key, item]) => [
|
||||
key,
|
||||
resolveReferences(item as Json, currentFile, seen),
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
function isFileReference(ref: string) {
|
||||
return !ref.startsWith("#") && !/^[a-z][a-z0-9+.-]*:/i.test(ref);
|
||||
}
|
||||
|
||||
function resolvePointer(document: Json, pointer: string): Json {
|
||||
const path = pointer.replace(/^#/, "");
|
||||
if (!path) return document;
|
||||
|
||||
return path
|
||||
.split("/")
|
||||
.filter(Boolean)
|
||||
.map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~"))
|
||||
.reduce((target: Json, key) => {
|
||||
if (!isObject(target) && !Array.isArray(target)) {
|
||||
throw new Error(`Invalid JSON pointer segment "${key}" in ${pointer}`);
|
||||
}
|
||||
|
||||
const next = (target as Record<string, Json>)[key];
|
||||
if (next === undefined) {
|
||||
throw new Error(`Missing JSON pointer segment "${key}" in ${pointer}`);
|
||||
}
|
||||
|
||||
return next;
|
||||
}, document);
|
||||
}
|
||||
|
||||
function isObject(value: Json): value is { [key: string]: Json } {
|
||||
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { writeFileSync, mkdirSync } from "fs";
|
||||
import { join, dirname } from "path";
|
||||
import {
|
||||
WorkflowDetailSchema,
|
||||
WorkflowTaskSchema,
|
||||
WorkflowSchema,
|
||||
} from "../../src/domains/platform/types.js";
|
||||
|
||||
const OUTPUT_DIR = join(process.cwd(), "specs");
|
||||
const OUTPUT_FILE = join(OUTPUT_DIR, "workflow-schema.json");
|
||||
|
||||
function writeJson(path: string, data: unknown): void {
|
||||
mkdirSync(dirname(path), { recursive: true });
|
||||
writeFileSync(path, JSON.stringify(data, null, 2));
|
||||
}
|
||||
|
||||
const workflowDetailJsonSchema = (WorkflowDetailSchema as any).toJSONSchema();
|
||||
const workflowTaskJsonSchema = (WorkflowTaskSchema as any).toJSONSchema();
|
||||
const workflowJsonSchema = (WorkflowSchema as any).toJSONSchema();
|
||||
|
||||
writeJson(OUTPUT_FILE, {
|
||||
$schema: "https://json-schema.org/draft/2020-12/schema",
|
||||
title: "EASO Workflow Schemas",
|
||||
schemas: {
|
||||
WorkflowDetail: workflowDetailJsonSchema,
|
||||
WorkflowTask: workflowTaskJsonSchema,
|
||||
Workflow: workflowJsonSchema,
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`Workflow schema written to ${OUTPUT_FILE}`);
|
||||
@@ -0,0 +1,768 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
import { mkdirSync, writeFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
|
||||
const outputFile = resolve("specs/openapi.raw.json");
|
||||
|
||||
function standardResponse(description: string, dataSchema: any) {
|
||||
return {
|
||||
"200": {
|
||||
description,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
data: dataSchema,
|
||||
code: { type: "string", example: "SUCCESS" },
|
||||
message: { type: "string", example: "成功" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"401": {
|
||||
description: "未授权或 Token 已失效",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: { $ref: "#/components/schemas/ErrorResponse" },
|
||||
},
|
||||
},
|
||||
},
|
||||
"400": {
|
||||
description: "请求参数错误或鉴权异常",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: { $ref: "#/components/schemas/ErrorResponse" },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const spec = {
|
||||
openapi: "3.1.0",
|
||||
info: {
|
||||
title: "Hose / Ekuaibao Downstream Native API",
|
||||
version: "1.0.0",
|
||||
description: "Raw downstream Ekuaibao (合思/易快报), EASO, and Piper business API contracts.",
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
url: "https://app.ekuaibao.com",
|
||||
description: "合思/易快报主站与统一认证中心",
|
||||
},
|
||||
{
|
||||
url: "https://easo.ekuaibao.com",
|
||||
description: "合思 EASO 开放平台网关",
|
||||
},
|
||||
{
|
||||
url: "https://piper.ekuaibao.com",
|
||||
description: "合思 Piper 工作流与集成网关",
|
||||
},
|
||||
],
|
||||
tags: [
|
||||
{ name: "SSO & Security", description: "统一认证中心、RSA 公钥密码加密与多企业身份切换" },
|
||||
{ name: "EASO & Piper Auth", description: "开放平台 OAuth2 免登握手、换票与 Token 自动刷新" },
|
||||
{ name: "Platforms & Apps", description: "自建应用列表与集成检索" },
|
||||
{ name: "Workflows & Pipelines", description: "跨应用工作流聚合、运行日志、节点详情与启停" },
|
||||
{ name: "Bills & Invoices", description: "费控单据、报销单、借款单、发票与 DataLink 实体字典" },
|
||||
{ name: "Jobs & Execution", description: "工作流任务运行实例与调试" },
|
||||
{ name: "Staffs & Webhooks", description: "企业通讯录人员与 Webhook 触发配置" },
|
||||
],
|
||||
paths: {
|
||||
"/api/v2/invoice/search": {
|
||||
post: {
|
||||
tags: ["Bills & Invoices"],
|
||||
summary: "检索企业费用单据与发票池",
|
||||
description: "检索企业名下的费用单据、报销借款单、发票与审批流记录,支持分页与阶段过滤。",
|
||||
operationId: "rawSearchInvoices",
|
||||
parameters: [
|
||||
{ name: "corporationId", in: "query", required: true, schema: { type: "string" } },
|
||||
],
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
limit: {
|
||||
type: "object",
|
||||
properties: {
|
||||
start: { type: "integer", default: 0 },
|
||||
count: { type: "integer", default: 50 },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "单据列表响应",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
count: { type: "integer" },
|
||||
items: { type: "array", items: { type: "object" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/v2/invoice": {
|
||||
post: {
|
||||
tags: ["Bills & Invoices"],
|
||||
summary: "批量按 ID 精确获取单据详情",
|
||||
description: "根据单据物理 ID 列表批量拉取完整的表单数据与状态。",
|
||||
operationId: "rawGetInvoicesByIds",
|
||||
parameters: [
|
||||
{ name: "corporationId", in: "query", required: true, schema: { type: "string" } },
|
||||
],
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["ids"],
|
||||
properties: {
|
||||
ids: { type: "array", items: { type: "string" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "单据详情列表",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
items: { type: "array", items: { type: "object" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/v2/datalink/entity/search": {
|
||||
post: {
|
||||
tags: ["Bills & Invoices"],
|
||||
summary: "查询 DataLink 实体定义与字段字典",
|
||||
description: "获取企业全部单据实体模型、字段 Label 中文映射与类型定义。",
|
||||
operationId: "rawSearchEntities",
|
||||
parameters: [
|
||||
{ name: "corporationId", in: "query", required: true, schema: { type: "string" } },
|
||||
],
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
limit: {
|
||||
type: "object",
|
||||
properties: {
|
||||
start: { type: "integer", default: 0 },
|
||||
count: { type: "integer", default: 100 },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "实体定义字典",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
items: { type: "array", items: { type: "object" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/common/security/getPublicKey": {
|
||||
post: {
|
||||
tags: ["SSO & Security"],
|
||||
summary: "获取统一认证中心 RSA 公钥",
|
||||
description: "获取用于登录密码加密的 RSA Public Key 模数与指数 (PKCS#1)。",
|
||||
operationId: "getPublicKey",
|
||||
responses: {
|
||||
"200": {
|
||||
description: "RSA 公钥响应",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
value: {
|
||||
type: "object",
|
||||
properties: {
|
||||
publicKey: { type: "string", description: "RSA 公钥字符串" },
|
||||
modulus: { type: "string", description: "RSA Modulus" },
|
||||
exponent: { type: "string", description: "RSA Exponent" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/common/login/verifyPhone": {
|
||||
post: {
|
||||
tags: ["SSO & Security"],
|
||||
summary: "手机号与加密密码纯 API 登录",
|
||||
description: "使用 RSA 加密后的密码和手机号发起统一认证,换取全企业 AccessToken 与 Session Cookie。",
|
||||
operationId: "loginVerifyPhone",
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["phone", "password"],
|
||||
properties: {
|
||||
phone: { type: "string", description: "手机号" },
|
||||
password: { type: "string", description: "RSA 加密后的密码密文" },
|
||||
countryCode: { type: "string", default: "+86" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "登录成功并下发凭证",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
value: {
|
||||
type: "object",
|
||||
properties: {
|
||||
accessToken: { type: "string", description: "全局访问令牌" },
|
||||
user: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "string" },
|
||||
name: { type: "string" },
|
||||
phone: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/common/user/corporations": {
|
||||
get: {
|
||||
tags: ["SSO & Security"],
|
||||
summary: "获取账号名下可访问企业列表",
|
||||
description: "拉取当前已登录账号授权的所有企业租户及其 Staff 身份。",
|
||||
operationId: "listCorporations",
|
||||
responses: {
|
||||
"200": {
|
||||
description: "企业与身份列表",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
items: {
|
||||
type: "array",
|
||||
items: { $ref: "#/components/schemas/CorporationItem" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/common/user/corporations/{corpId}/switch": {
|
||||
post: {
|
||||
tags: ["SSO & Security"],
|
||||
summary: "切换工作企业上下文",
|
||||
description: "切换当前会话至指定企业租户,并签发该企业的专属 Session。",
|
||||
operationId: "switchCorporation",
|
||||
parameters: [
|
||||
{ name: "corpId", in: "path", required: true, schema: { type: "string" }, description: "目标企业 ID" },
|
||||
],
|
||||
responses: {
|
||||
"200": {
|
||||
description: "切换结果",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
value: {
|
||||
type: "object",
|
||||
properties: {
|
||||
activeCorpId: { type: "string" },
|
||||
staffId: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/open/oauth2/auth": {
|
||||
post: {
|
||||
tags: ["EASO & Piper Auth"],
|
||||
summary: "EASO 换票 Step 1: 获取授权码",
|
||||
description: "使用主站会话 Cookie 和 appKey 获取临时 code。",
|
||||
operationId: "easoGetAuthCode",
|
||||
responses: {
|
||||
"200": {
|
||||
description: "临时授权码",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
code: { type: "string", description: "临时授权码" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/open/oauth2/token": {
|
||||
post: {
|
||||
tags: ["EASO & Piper Auth"],
|
||||
summary: "EASO 换票 Step 2: 换取 AccessToken",
|
||||
description: "使用授权码 code 换取平台接口访问 Token 与 RefreshToken。",
|
||||
operationId: "easoGetToken",
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["code", "appKey", "appSecret"],
|
||||
properties: {
|
||||
code: { type: "string" },
|
||||
appKey: { type: "string" },
|
||||
appSecret: { type: "string" },
|
||||
grant_type: { type: "string", default: "authorization_code" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "平台 Token 响应",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
access_token: { type: "string" },
|
||||
refresh_token: { type: "string" },
|
||||
expires_in: { type: "integer" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/open/oauth2/user_info": {
|
||||
get: {
|
||||
tags: ["EASO & Piper Auth"],
|
||||
summary: "EASO 换票 Step 3: 获取当前开放平台用户信息",
|
||||
description: "使用 AccessToken 获取当前用户的 openId 与企业绑定身份。",
|
||||
operationId: "easoGetUserInfo",
|
||||
responses: {
|
||||
"200": {
|
||||
description: "用户信息",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
openId: { type: "string" },
|
||||
corpId: { type: "string" },
|
||||
name: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/open/oauth2/token/refresh": {
|
||||
post: {
|
||||
tags: ["EASO & Piper Auth"],
|
||||
summary: "EASO 令牌无感刷新",
|
||||
description: "使用 refresh_token 换取新的 30 天 accessToken。",
|
||||
operationId: "easoRefreshToken",
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["refresh_token"],
|
||||
properties: {
|
||||
refresh_token: { type: "string" },
|
||||
grant_type: { type: "string", default: "refresh_token" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
"200": {
|
||||
description: "新 Token",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
access_token: { type: "string" },
|
||||
refresh_token: { type: "string" },
|
||||
expires_in: { type: "integer" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/v2/datalink/platform/search": {
|
||||
get: {
|
||||
tags: ["Platforms & Apps"],
|
||||
summary: "获取企业自建应用列表",
|
||||
description: "查询指定企业下已启用的自建应用与平台实例列表。",
|
||||
operationId: "searchPlatforms",
|
||||
parameters: [
|
||||
{ name: "corpId", in: "query", required: true, schema: { type: "string" }, description: "企业 ID" },
|
||||
{ name: "scope", in: "query", schema: { type: "string", default: "enable" } },
|
||||
],
|
||||
responses: {
|
||||
"200": {
|
||||
description: "应用列表",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
items: {
|
||||
type: "array",
|
||||
items: { $ref: "#/components/schemas/PlatformItem" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/easo/pipelines/logs": {
|
||||
get: {
|
||||
tags: ["Workflows & Pipelines"],
|
||||
summary: "获取应用下的工作流列表与日志",
|
||||
description: "按自建应用 ID 分页查询名下的工作流及最近执行日志。",
|
||||
operationId: "listWorkflowsByPlatform",
|
||||
parameters: [
|
||||
{ name: "platformId", in: "query", required: true, schema: { type: "string" } },
|
||||
{ name: "number", in: "query", schema: { type: "integer", default: 1 } },
|
||||
{ name: "pageSize", in: "query", schema: { type: "integer", default: 20 } },
|
||||
],
|
||||
responses: standardResponse("工作流分页列表", { $ref: "#/components/schemas/WorkflowPageData" }),
|
||||
},
|
||||
},
|
||||
"/api/easo/stats": {
|
||||
get: {
|
||||
tags: ["Workflows & Pipelines"],
|
||||
summary: "获取工作流运行统计",
|
||||
description: "统计指定应用下工作流的成功、失败及总触发次数。",
|
||||
operationId: "getWorkflowStats",
|
||||
parameters: [
|
||||
{ name: "platformId", in: "query", required: true, schema: { type: "string" } },
|
||||
],
|
||||
responses: standardResponse("工作流运行统计", { $ref: "#/components/schemas/WorkflowStatsData" }),
|
||||
},
|
||||
},
|
||||
"/api/easo/charge": {
|
||||
get: {
|
||||
tags: ["Workflows & Pipelines"],
|
||||
summary: "获取工作流配额与计费信息",
|
||||
description: "查询当前企业工作流运行调用次数与配额剩余。",
|
||||
operationId: "getWorkflowCharge",
|
||||
responses: standardResponse("配额信息", { $ref: "#/components/schemas/WorkflowChargeData" }),
|
||||
},
|
||||
},
|
||||
"/api/easo/pipelines/{pipelineId}": {
|
||||
get: {
|
||||
tags: ["Workflows & Pipelines"],
|
||||
summary: "获取工作流详情与 DSL 节点图",
|
||||
description: "查询指定工作流的完整配置、触发器与节点链路图谱(code-js2, loop, sql 等)。",
|
||||
operationId: "getWorkflowDetail",
|
||||
parameters: [
|
||||
{ name: "pipelineId", in: "path", required: true, schema: { type: "string" } },
|
||||
],
|
||||
responses: standardResponse("工作流完整详情", { $ref: "#/components/schemas/WorkflowDetailData" }),
|
||||
},
|
||||
},
|
||||
"/api/easo/pipelines/state/{pipelineId}": {
|
||||
put: {
|
||||
tags: ["Workflows & Pipelines"],
|
||||
summary: "启用或停用工作流",
|
||||
description: "切换工作流运行状态(1: 启用, 0: 停用)。",
|
||||
operationId: "toggleWorkflowState",
|
||||
parameters: [
|
||||
{ name: "pipelineId", in: "path", required: true, schema: { type: "string" } },
|
||||
{ name: "state", in: "query", required: true, schema: { type: "integer", enum: [0, 1] } },
|
||||
],
|
||||
responses: {
|
||||
"200": {
|
||||
description: "状态更新成功",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/easo/jobs/running": {
|
||||
get: {
|
||||
tags: ["Jobs & Execution"],
|
||||
summary: "获取运行中的任务实例",
|
||||
description: "查询工作流正在执行的调试(DEBUG)或生产(PROD)任务列表。",
|
||||
operationId: "listRunningJobs",
|
||||
parameters: [
|
||||
{ name: "pipelineId", in: "query", required: true, schema: { type: "string" } },
|
||||
{ name: "runType", in: "query", schema: { type: "string", enum: ["DEBUG", "PROD"], default: "DEBUG" } },
|
||||
],
|
||||
responses: standardResponse("任务实例列表", {
|
||||
type: "array",
|
||||
items: { $ref: "#/components/schemas/WorkflowJobItem" },
|
||||
}),
|
||||
},
|
||||
},
|
||||
"/api/easo/dsl/all": {
|
||||
get: {
|
||||
tags: ["Workflows & Pipelines"],
|
||||
summary: "获取企业全部 DSL 规则配置",
|
||||
description: "查询企业下所有生效的 DSL 脚本规则。",
|
||||
operationId: "listAllDsl",
|
||||
responses: standardResponse("DSL 规则列表", {
|
||||
type: "array",
|
||||
items: { $ref: "#/components/schemas/WorkflowDslItem" },
|
||||
}),
|
||||
},
|
||||
},
|
||||
"/api/easo/common/staffs": {
|
||||
get: {
|
||||
tags: ["Staffs & Webhooks"],
|
||||
summary: "获取企业员工通讯录列表",
|
||||
description: "查询企业内部或外部员工名单,用于工作流执行人与节点通知映射。",
|
||||
operationId: "listCommonStaffs",
|
||||
parameters: [
|
||||
{ name: "external", in: "query", schema: { type: "boolean", default: false } },
|
||||
],
|
||||
responses: standardResponse("员工列表", {
|
||||
type: "array",
|
||||
items: { $ref: "#/components/schemas/StaffItem" },
|
||||
}),
|
||||
},
|
||||
},
|
||||
"/api/webhook/{pipelineId}": {
|
||||
get: {
|
||||
tags: ["Staffs & Webhooks"],
|
||||
summary: "获取工作流 Webhook 触发配置",
|
||||
description: "查询指定工作流的 Webhook URL 入口与密钥配置。",
|
||||
operationId: "getWebhookInfo",
|
||||
parameters: [
|
||||
{ name: "pipelineId", in: "path", required: true, schema: { type: "string" } },
|
||||
],
|
||||
responses: standardResponse("Webhook 配置", { $ref: "#/components/schemas/WebhookInfoData" }),
|
||||
},
|
||||
},
|
||||
"/api/easo/pipelines/{pipelineId}/sampleData": {
|
||||
post: {
|
||||
tags: ["Workflows & Pipelines"],
|
||||
summary: "提取工作流调试/采样数据",
|
||||
description: "触发工作流节点采样数据提取,用于脚本调试与输入校验。",
|
||||
operationId: "sampleWorkflowData",
|
||||
parameters: [
|
||||
{ name: "pipelineId", in: "path", required: true, schema: { type: "string" } },
|
||||
],
|
||||
responses: {
|
||||
"200": {
|
||||
description: "采样数据",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
data: { type: "object" },
|
||||
type: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
components: {
|
||||
schemas: {
|
||||
ErrorResponse: {
|
||||
type: "object",
|
||||
properties: {
|
||||
code: { type: "string" },
|
||||
message: { type: "string" },
|
||||
details: { type: "object" },
|
||||
},
|
||||
},
|
||||
CorporationItem: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "string", description: "企业 ID" },
|
||||
name: { type: "string", description: "企业名称" },
|
||||
staffId: { type: "string", description: "员工 ID" },
|
||||
role: { type: "string", description: "角色权限" },
|
||||
},
|
||||
},
|
||||
PlatformItem: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "string", description: "自建应用 ID" },
|
||||
name: { type: "string", description: "应用名称" },
|
||||
code: { type: "string", description: "应用标识 Code" },
|
||||
icon: { type: "string" },
|
||||
status: { type: "string" },
|
||||
},
|
||||
},
|
||||
WorkflowPageData: {
|
||||
type: "object",
|
||||
properties: {
|
||||
items: {
|
||||
type: "array",
|
||||
items: { $ref: "#/components/schemas/WorkflowItem" },
|
||||
},
|
||||
total: { type: "integer" },
|
||||
number: { type: "integer" },
|
||||
pageSize: { type: "integer" },
|
||||
},
|
||||
},
|
||||
WorkflowItem: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "string" },
|
||||
name: { type: "string" },
|
||||
description: { type: "string" },
|
||||
state: { type: "integer", description: "1: 启用, 0: 停用" },
|
||||
platformId: { type: "string" },
|
||||
updatedAt: { type: "string" },
|
||||
},
|
||||
},
|
||||
WorkflowStatsData: {
|
||||
type: "object",
|
||||
properties: {
|
||||
totalCount: { type: "integer" },
|
||||
successCount: { type: "integer" },
|
||||
failCount: { type: "integer" },
|
||||
},
|
||||
},
|
||||
WorkflowChargeData: {
|
||||
type: "object",
|
||||
properties: {
|
||||
used: { type: "integer" },
|
||||
total: { type: "integer" },
|
||||
remaining: { type: "integer" },
|
||||
},
|
||||
},
|
||||
WorkflowDetailData: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "string" },
|
||||
name: { type: "string" },
|
||||
state: { type: "integer" },
|
||||
nodes: { type: "array", items: { type: "object" }, description: "节点列表 (含 code-js2, loop, sql 等)" },
|
||||
links: { type: "array", items: { type: "object" }, description: "节点连线" },
|
||||
},
|
||||
},
|
||||
WorkflowJobItem: {
|
||||
type: "object",
|
||||
properties: {
|
||||
jobId: { type: "string" },
|
||||
pipelineId: { type: "string" },
|
||||
status: { type: "string" },
|
||||
startTime: { type: "string" },
|
||||
},
|
||||
},
|
||||
WorkflowDslItem: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "string" },
|
||||
name: { type: "string" },
|
||||
content: { type: "string" },
|
||||
},
|
||||
},
|
||||
StaffItem: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "string" },
|
||||
name: { type: "string" },
|
||||
email: { type: "string" },
|
||||
cellphone: { type: "string" },
|
||||
},
|
||||
},
|
||||
WebhookInfoData: {
|
||||
type: "object",
|
||||
properties: {
|
||||
webhookUrl: { type: "string" },
|
||||
token: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
mkdirSync(dirname(outputFile), { recursive: true });
|
||||
writeFileSync(outputFile, `${JSON.stringify(spec, null, 2)}\n`);
|
||||
console.log(`✓ Generated raw downstream OpenAPI: ${outputFile}`);
|
||||
Reference in new issue
Block a user