From 93360a8ef991b927be0d82398231c98aba8da574 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Fri, 17 Jul 2026 16:54:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(platform):=20=E6=96=B0=E5=A2=9E=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81=20JSON=20Schema=20=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 scripts/export-workflow-schema.ts - 输出 schemas/workflow-schema.json - package.json 新增 export:workflow-schema 脚本 - README.md 补充 typecheck 和 schema 导出命令 --- README.md | 15 +- schemas/workflow-schema.json | 3468 +++++++++++++++++++++++++++++ scripts/export-workflow-schema.ts | 31 + 3 files changed, 3512 insertions(+), 2 deletions(-) create mode 100644 schemas/workflow-schema.json create mode 100644 scripts/export-workflow-schema.ts diff --git a/README.md b/README.md index efd5438..cd1f78d 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,10 @@ bun install ## 运行 ```bash -bun run dev # 开发模式(热重载) -bun run start # 生产模式 +bun run dev # 开发模式(热重载) +bun run start # 生产模式 +bun run typecheck # TypeScript 类型检查 +bun run export:workflow-schema # 导出工作流 JSON Schema ``` ## 架构 @@ -75,6 +77,15 @@ src/ - [x] 工作流统计 (`platform_workflow_stats`) - [x] 工作流配额 (`platform_workflow_charge`) - [x] 工作流详情 (`platform_workflow_detail`) +- [x] 工作流启停 (`platform_workflow_toggle`) +- [x] 工作流运行任务 (`platform_workflow_jobs`) +- [x] 工作流 DSL 配置 (`platform_workflow_dsl`) +- [x] 企业员工列表 (`platform_workflow_staffs`) +- [x] 工作流 Webhook (`platform_workflow_webhook`) +- [x] 工作流采样数据 (`platform_workflow_sample`) +- [x] 跨应用汇总工作流 (`platform_workflow_list_all`) +- [x] 按节点类型递归查找工作流 (`platform_workflow_find_by_task`) +- [x] 工作流节点 JSON Schema 约束 ### Core - [x] 多企业切换 diff --git a/schemas/workflow-schema.json b/schemas/workflow-schema.json new file mode 100644 index 0000000..f3d26f6 --- /dev/null +++ b/schemas/workflow-schema.json @@ -0,0 +1,3468 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "EASO Workflow Schemas", + "schemas": { + "WorkflowDetail": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "label": { + "default": "", + "type": "string" + }, + "desc": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "customDesc": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "state": { + "default": 0, + "type": "number" + }, + "debugState": { + "default": 0, + "type": "number" + }, + "runTimes": { + "default": 0, + "type": "number" + }, + "errorTimes": { + "default": 0, + "type": "number" + }, + "updateTime": { + "default": "", + "type": "string" + }, + "updateUser": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "staffName": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "version": { + "default": "", + "type": "string" + }, + "dataLimit": { + "default": 20, + "type": "number" + }, + "source": { + "default": 0, + "type": "number" + }, + "queueJobs": { + "default": false, + "type": "boolean" + }, + "tasksVersion": { + "default": 0, + "type": "number" + }, + "tasks": { + "default": [], + "type": "array", + "items": { + "$ref": "#/$defs/__schema0" + } + }, + "alarm": { + "type": "object", + "properties": { + "alarmUser": { + "default": [], + "type": "array", + "items": {} + }, + "alarmType": { + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "active": { + "default": true, + "type": "boolean" + }, + "alarmScope": { + "default": "", + "type": "string" + } + }, + "required": [ + "alarmUser", + "alarmType", + "active", + "alarmScope" + ], + "additionalProperties": false + } + }, + "required": [ + "id", + "label", + "state", + "debugState", + "runTimes", + "errorTimes", + "updateTime", + "version", + "dataLimit", + "source", + "queueJobs", + "tasksVersion", + "tasks" + ], + "additionalProperties": false, + "$defs": { + "__schema0": { + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "webhook" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "sampleId": { + "type": "string" + }, + "params": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + }, + "urlPath": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "sampleId", + "params", + "urlPath" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "condition" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "tasksMaxLevel": { + "type": "number" + }, + "combineFilters": { + "$ref": "#/$defs/__schema1" + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#/$defs/__schema0" + } + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "tasksMaxLevel", + "combineFilters", + "tasks" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "every" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "batch": { + "type": "boolean" + }, + "batchSize": { + "type": "number" + }, + "mode": { + "type": "string" + }, + "list": { + "type": "string" + }, + "filters": { + "type": "array", + "items": {} + }, + "tasksMaxLevel": { + "type": "number" + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#/$defs/__schema0" + } + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "batch", + "mode", + "list", + "filters", + "tasksMaxLevel", + "tasks" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "stop" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "http" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "method": { + "type": "string" + }, + "url": { + "type": "string" + }, + "bodyType": { + "type": "string" + }, + "bodyRaw": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {} + }, + "header": { + "type": "array", + "items": {} + }, + "params": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + }, + "successCode": { + "type": "array", + "items": { + "type": "string" + } + }, + "sampleData": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {} + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "method", + "url", + "header", + "params", + "successCode" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "flow-detail" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "specificationId": { + "type": "string" + }, + "mapping": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + } + ] + }, + "flowCode": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "specificationId", + "mapping", + "flowCode" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "code" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "code": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "code" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "code-js2" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "code": { + "type": "string" + }, + "mapping": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + }, + "onError": { + "type": "object", + "properties": { + "defaultAction": { + "type": "string" + } + }, + "required": [ + "defaultAction" + ], + "additionalProperties": false + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "code" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "ekuaibao-datalink-filter" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "mode": { + "type": "string" + }, + "entityId": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "key": { + "type": "string" + } + }, + "required": [ + "key" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + ] + } + }, + "filters": { + "type": "array", + "items": {} + }, + "selectFields": { + "type": "array", + "items": {} + }, + "combineFilters": { + "$ref": "#/$defs/__schema1" + }, + "orderKey": { + "type": "string" + }, + "orderMode": { + "type": "string" + }, + "limitCount": { + "type": "string" + }, + "onError": { + "type": "object", + "properties": { + "defaultAction": { + "type": "string" + } + }, + "required": [ + "defaultAction" + ], + "additionalProperties": false + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "mode", + "entityId", + "fields", + "filters", + "selectFields", + "combineFilters", + "orderKey", + "orderMode", + "limitCount" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "ekuaibao-datalink-create" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "mode": { + "type": "string" + }, + "entityId": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "key": { + "type": "string" + } + }, + "required": [ + "key" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + ] + } + }, + "filters": { + "type": "array", + "items": {} + }, + "combineFilters": { + "$ref": "#/$defs/__schema1" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "mode", + "entityId", + "fields", + "filters", + "combineFilters" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "data-convert" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "mode": { + "type": "string" + }, + "path": { + "type": "array", + "items": { + "type": "string" + } + }, + "fields": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + }, + "onError": { + "type": "object", + "properties": { + "defaultAction": { + "type": "string" + } + }, + "required": [ + "defaultAction" + ], + "additionalProperties": false + }, + "subType": { + "type": "string" + }, + "itemType": { + "type": "string" + }, + "targetType": { + "type": "string" + }, + "feeFormType": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "mode", + "path", + "fields", + "subType", + "itemType", + "targetType", + "feeFormType" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "flow-create-task" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "specificationId": { + "type": "string" + }, + "formState": { + "type": "string" + }, + "form": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + }, + "details": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {} + }, + "onError": { + "type": "object", + "properties": { + "defaultAction": { + "type": "string" + } + }, + "required": [ + "defaultAction" + ], + "additionalProperties": false + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "specificationId", + "formState", + "form", + "details" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "groupName", + "orderIndex", + "levelIndex", + "status" + ], + "additionalProperties": {} + } + ] + }, + "__schema1": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": {}, + "compare": { + "type": "string" + } + }, + "required": [ + "key", + "compare" + ], + "additionalProperties": false + }, + { + "$ref": "#/$defs/__schema1" + } + ] + } + }, + "condition": { + "type": "string" + } + }, + "required": [ + "filters", + "condition" + ], + "additionalProperties": false + } + } + }, + "WorkflowTask": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "webhook" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "sampleId": { + "type": "string" + }, + "params": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + }, + "urlPath": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "sampleId", + "params", + "urlPath" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "condition" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "tasksMaxLevel": { + "type": "number" + }, + "combineFilters": { + "$ref": "#/$defs/__schema0" + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#" + } + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "tasksMaxLevel", + "combineFilters", + "tasks" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "every" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "batch": { + "type": "boolean" + }, + "batchSize": { + "type": "number" + }, + "mode": { + "type": "string" + }, + "list": { + "type": "string" + }, + "filters": { + "type": "array", + "items": {} + }, + "tasksMaxLevel": { + "type": "number" + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#" + } + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "batch", + "mode", + "list", + "filters", + "tasksMaxLevel", + "tasks" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "stop" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "http" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "method": { + "type": "string" + }, + "url": { + "type": "string" + }, + "bodyType": { + "type": "string" + }, + "bodyRaw": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {} + }, + "header": { + "type": "array", + "items": {} + }, + "params": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + }, + "successCode": { + "type": "array", + "items": { + "type": "string" + } + }, + "sampleData": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {} + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "method", + "url", + "header", + "params", + "successCode" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "flow-detail" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "specificationId": { + "type": "string" + }, + "mapping": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + } + ] + }, + "flowCode": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "specificationId", + "mapping", + "flowCode" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "code" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "code": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "code" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "code-js2" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "code": { + "type": "string" + }, + "mapping": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + }, + "onError": { + "type": "object", + "properties": { + "defaultAction": { + "type": "string" + } + }, + "required": [ + "defaultAction" + ], + "additionalProperties": false + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "code" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "ekuaibao-datalink-filter" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "mode": { + "type": "string" + }, + "entityId": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "key": { + "type": "string" + } + }, + "required": [ + "key" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + ] + } + }, + "filters": { + "type": "array", + "items": {} + }, + "selectFields": { + "type": "array", + "items": {} + }, + "combineFilters": { + "$ref": "#/$defs/__schema0" + }, + "orderKey": { + "type": "string" + }, + "orderMode": { + "type": "string" + }, + "limitCount": { + "type": "string" + }, + "onError": { + "type": "object", + "properties": { + "defaultAction": { + "type": "string" + } + }, + "required": [ + "defaultAction" + ], + "additionalProperties": false + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "mode", + "entityId", + "fields", + "filters", + "selectFields", + "combineFilters", + "orderKey", + "orderMode", + "limitCount" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "ekuaibao-datalink-create" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "mode": { + "type": "string" + }, + "entityId": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "key": { + "type": "string" + } + }, + "required": [ + "key" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + ] + } + }, + "filters": { + "type": "array", + "items": {} + }, + "combineFilters": { + "$ref": "#/$defs/__schema0" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "mode", + "entityId", + "fields", + "filters", + "combineFilters" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "data-convert" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "mode": { + "type": "string" + }, + "path": { + "type": "array", + "items": { + "type": "string" + } + }, + "fields": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + }, + "onError": { + "type": "object", + "properties": { + "defaultAction": { + "type": "string" + } + }, + "required": [ + "defaultAction" + ], + "additionalProperties": false + }, + "subType": { + "type": "string" + }, + "itemType": { + "type": "string" + }, + "targetType": { + "type": "string" + }, + "feeFormType": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "mode", + "path", + "fields", + "subType", + "itemType", + "targetType", + "feeFormType" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "flow-create-task" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "specificationId": { + "type": "string" + }, + "formState": { + "type": "string" + }, + "form": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + }, + "details": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {} + }, + "onError": { + "type": "object", + "properties": { + "defaultAction": { + "type": "string" + } + }, + "required": [ + "defaultAction" + ], + "additionalProperties": false + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "specificationId", + "formState", + "form", + "details" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "groupName", + "orderIndex", + "levelIndex", + "status" + ], + "additionalProperties": {} + } + ], + "$defs": { + "__schema0": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": {}, + "compare": { + "type": "string" + } + }, + "required": [ + "key", + "compare" + ], + "additionalProperties": false + }, + { + "$ref": "#/$defs/__schema0" + } + ] + } + }, + "condition": { + "type": "string" + } + }, + "required": [ + "filters", + "condition" + ], + "additionalProperties": false + } + } + }, + "Workflow": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "pipelineName": { + "default": "", + "type": "string" + }, + "state": { + "default": 0, + "type": "number" + }, + "runningCount": { + "default": 0, + "type": "number" + }, + "errorCount": { + "default": 0, + "type": "number" + }, + "updateTime": { + "default": "", + "type": "string" + }, + "updateUser": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "tasks": { + "default": [], + "type": "array", + "items": { + "$ref": "#/$defs/__schema0" + } + }, + "desc": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "customDesc": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "id", + "pipelineName", + "state", + "runningCount", + "errorCount", + "updateTime", + "tasks" + ], + "additionalProperties": false, + "$defs": { + "__schema0": { + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "webhook" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "sampleId": { + "type": "string" + }, + "params": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + }, + "urlPath": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "sampleId", + "params", + "urlPath" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "condition" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "tasksMaxLevel": { + "type": "number" + }, + "combineFilters": { + "$ref": "#/$defs/__schema1" + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#/$defs/__schema0" + } + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "tasksMaxLevel", + "combineFilters", + "tasks" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "every" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "batch": { + "type": "boolean" + }, + "batchSize": { + "type": "number" + }, + "mode": { + "type": "string" + }, + "list": { + "type": "string" + }, + "filters": { + "type": "array", + "items": {} + }, + "tasksMaxLevel": { + "type": "number" + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#/$defs/__schema0" + } + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "batch", + "mode", + "list", + "filters", + "tasksMaxLevel", + "tasks" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "stop" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "http" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "method": { + "type": "string" + }, + "url": { + "type": "string" + }, + "bodyType": { + "type": "string" + }, + "bodyRaw": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {} + }, + "header": { + "type": "array", + "items": {} + }, + "params": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + }, + "successCode": { + "type": "array", + "items": { + "type": "string" + } + }, + "sampleData": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {} + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "method", + "url", + "header", + "params", + "successCode" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "flow-detail" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "specificationId": { + "type": "string" + }, + "mapping": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + } + ] + }, + "flowCode": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "specificationId", + "mapping", + "flowCode" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "code" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "code": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "code" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "code-js2" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "code": { + "type": "string" + }, + "mapping": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + }, + "onError": { + "type": "object", + "properties": { + "defaultAction": { + "type": "string" + } + }, + "required": [ + "defaultAction" + ], + "additionalProperties": false + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "code" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "ekuaibao-datalink-filter" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "mode": { + "type": "string" + }, + "entityId": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "key": { + "type": "string" + } + }, + "required": [ + "key" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + ] + } + }, + "filters": { + "type": "array", + "items": {} + }, + "selectFields": { + "type": "array", + "items": {} + }, + "combineFilters": { + "$ref": "#/$defs/__schema1" + }, + "orderKey": { + "type": "string" + }, + "orderMode": { + "type": "string" + }, + "limitCount": { + "type": "string" + }, + "onError": { + "type": "object", + "properties": { + "defaultAction": { + "type": "string" + } + }, + "required": [ + "defaultAction" + ], + "additionalProperties": false + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "mode", + "entityId", + "fields", + "filters", + "selectFields", + "combineFilters", + "orderKey", + "orderMode", + "limitCount" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "ekuaibao-datalink-create" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "mode": { + "type": "string" + }, + "entityId": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "key": { + "type": "string" + } + }, + "required": [ + "key" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + ] + } + }, + "filters": { + "type": "array", + "items": {} + }, + "combineFilters": { + "$ref": "#/$defs/__schema1" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "mode", + "entityId", + "fields", + "filters", + "combineFilters" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "data-convert" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "mode": { + "type": "string" + }, + "path": { + "type": "array", + "items": { + "type": "string" + } + }, + "fields": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "key", + "value" + ], + "additionalProperties": false + } + }, + "onError": { + "type": "object", + "properties": { + "defaultAction": { + "type": "string" + } + }, + "required": [ + "defaultAction" + ], + "additionalProperties": false + }, + "subType": { + "type": "string" + }, + "itemType": { + "type": "string" + }, + "targetType": { + "type": "string" + }, + "feeFormType": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "mode", + "path", + "fields", + "subType", + "itemType", + "targetType", + "feeFormType" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "const": "flow-create-task" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "specificationId": { + "type": "string" + }, + "formState": { + "type": "string" + }, + "form": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + }, + "details": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {} + }, + "onError": { + "type": "object", + "properties": { + "defaultAction": { + "type": "string" + } + }, + "required": [ + "defaultAction" + ], + "additionalProperties": false + } + }, + "required": [ + "name", + "type", + "label", + "groupName", + "orderIndex", + "levelIndex", + "status", + "specificationId", + "formState", + "form", + "details" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "label": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "orderIndex": { + "type": "number" + }, + "levelIndex": { + "type": "array", + "items": { + "type": "number" + } + }, + "status": { + "type": "string" + }, + "displayName": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "groupName", + "orderIndex", + "levelIndex", + "status" + ], + "additionalProperties": {} + } + ] + }, + "__schema1": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": {}, + "compare": { + "type": "string" + } + }, + "required": [ + "key", + "compare" + ], + "additionalProperties": false + }, + { + "$ref": "#/$defs/__schema1" + } + ] + } + }, + "condition": { + "type": "string" + } + }, + "required": [ + "filters", + "condition" + ], + "additionalProperties": false + } + } + } + } +} \ No newline at end of file diff --git a/scripts/export-workflow-schema.ts b/scripts/export-workflow-schema.ts new file mode 100644 index 0000000..b42a311 --- /dev/null +++ b/scripts/export-workflow-schema.ts @@ -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(), "schemas"); +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}`);