百积木文档
开发指南后端应用开发Hosted Service Capability

bundle-runtime

bundle-runtime 方法列表与请求响应合同。

返回能力列表

bundle-runtime 的已发布 Bundle 业务接口。路径相对于所连接环境的平台 API 根地址,使用 Bundle Capability Token;无需创建配置绑定。检查 CModel errorCode 后读取 data。

协议:HTTP。合同:2.0.0。

方法列表

方法用途HTTP
queryBundleResources查询当前 Bundle 的已验证资源POST /capability/bundle-runtime/bundle/resources/query

queryBundleResources

查询当前 Bundle 的已验证资源

POST /capability/bundle-runtime/bundle/resources/query

{
  "operationId": "queryBundleResources",
  "summary": "查询当前 Bundle 的已验证资源",
  "x-baijimu-scope": "bundle.resources.read",
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/QueryBundleResourcesRequest"
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "检查 errorCode;HTTP 200 也可能是业务失败。",
      "content": {
        "application/json": {
          "schema": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "errorCode": {
                    "const": "0"
                  },
                  "data": {
                    "$ref": "#/components/schemas/BundleResources"
                  },
                  "contractVersion": {
                    "const": "1.0.0"
                  }
                },
                "required": [
                  "errorCode",
                  "data"
                ],
                "additionalProperties": true
              },
              {
                "$ref": "#/components/schemas/CapabilityError"
              }
            ]
          },
          "examples": {}
        }
      }
    },
    "default": {
      "description": "认证、参数、资源状态或服务失败。",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/CapabilityError"
          }
        }
      }
    }
  },
  "x-baijimu-side-effect": "read",
  "x-baijimu-response-data-schema": {
    "$ref": "#/components/schemas/BundleResources"
  },
  "description": "查询当前 Bundle 的已验证资源",
  "parameters": [],
  "security": [
    {
      "bundleCapabilityToken": []
    }
  ]
}

Schema 定义

所有 $ref 引用均来自同一提供方合同的 components。

{
  "securitySchemes": {
    "bundleCapabilityToken": {
      "type": "http",
      "scheme": "bearer",
      "description": "通过自有 Bundle 的 Capability Client 签发;明文只返回一次。"
    }
  },
  "requestBodies": {
    "ApplicationRuntimeRequest": {
      "required": true,
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ApplicationRuntimeRequest"
          }
        }
      }
    },
    "ResourceRequest": {
      "required": true,
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ResourceRequest"
          }
        }
      }
    },
    "WorkflowInstanceRequest": {
      "required": true,
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/WorkflowInstanceRequest"
          }
        }
      }
    }
  },
  "schemas": {
    "ApplicationRuntimeId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "description": "目标 Application Runtime 的稳定 ID。"
    },
    "ResourceLocator": {
      "type": "string",
      "minLength": 1,
      "description": "由资源查询返回的稳定 Locator;调用方不得自行构造。"
    },
    "ApplicationRuntimeRequest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "applicationRuntimeId"
      ],
      "properties": {
        "applicationRuntimeId": {
          "$ref": "#/components/schemas/ApplicationRuntimeId"
        }
      }
    },
    "ResourceRequest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "applicationRuntimeId",
        "resourceLocator"
      ],
      "properties": {
        "applicationRuntimeId": {
          "$ref": "#/components/schemas/ApplicationRuntimeId"
        },
        "resourceLocator": {
          "$ref": "#/components/schemas/ResourceLocator"
        }
      }
    },
    "WorkflowInstanceRequest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "applicationRuntimeId",
        "resourceLocator",
        "instanceId"
      ],
      "properties": {
        "applicationRuntimeId": {
          "$ref": "#/components/schemas/ApplicationRuntimeId"
        },
        "resourceLocator": {
          "$ref": "#/components/schemas/ResourceLocator"
        },
        "instanceId": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "QueryBundleResourcesRequest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "applicationRuntimeId"
      ],
      "properties": {
        "applicationRuntimeId": {
          "$ref": "#/components/schemas/ApplicationRuntimeId"
        },
        "resourceType": {
          "type": "string",
          "minLength": 1,
          "description": "资源类型来自当前环境目录;新增类型无需更新客户端。"
        }
      }
    },
    "StartWorkflowRequest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "applicationRuntimeId",
        "resourceLocator",
        "requestId"
      ],
      "properties": {
        "applicationRuntimeId": {
          "$ref": "#/components/schemas/ApplicationRuntimeId"
        },
        "resourceLocator": {
          "$ref": "#/components/schemas/ResourceLocator"
        },
        "input": {
          "type": "object",
          "additionalProperties": true
        },
        "metadata": {
          "type": "object",
          "additionalProperties": true
        },
        "requestId": {
          "type": "string",
          "minLength": 1,
          "description": "同一次启动请求的稳定幂等标识,必填;与 metadata.requestId 无关。"
        }
      }
    },
    "QueryWorkflowInstancesRequest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "applicationRuntimeId",
        "resourceLocator"
      ],
      "properties": {
        "applicationRuntimeId": {
          "$ref": "#/components/schemas/ApplicationRuntimeId"
        },
        "resourceLocator": {
          "$ref": "#/components/schemas/ResourceLocator"
        },
        "status": {
          "type": "string",
          "minLength": 1
        },
        "pageNum": {
          "type": "integer",
          "minimum": 1,
          "default": 1
        },
        "pageSize": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 20
        }
      }
    },
    "QueryTimerExecutionsRequest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "applicationRuntimeId",
        "resourceLocator"
      ],
      "properties": {
        "applicationRuntimeId": {
          "$ref": "#/components/schemas/ApplicationRuntimeId"
        },
        "resourceLocator": {
          "$ref": "#/components/schemas/ResourceLocator"
        },
        "status": {
          "type": "string",
          "minLength": 1
        },
        "limit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000,
          "default": 50
        },
        "offset": {
          "type": "integer",
          "minimum": 0,
          "default": 0
        }
      }
    },
    "ResourceVersion": {
      "type": "object",
      "properties": {
        "resourceLocator": {
          "$ref": "#/components/schemas/ResourceLocator"
        },
        "semanticVersion": {
          "type": "string"
        }
      },
      "required": [
        "resourceLocator",
        "semanticVersion"
      ],
      "additionalProperties": true
    },
    "BundleIdentity": {
      "type": "object",
      "properties": {
        "environmentKey": {
          "type": "string"
        },
        "bundleId": {
          "type": "string"
        }
      },
      "required": [
        "environmentKey",
        "bundleId"
      ],
      "additionalProperties": true
    },
    "BundleResources": {
      "type": "object",
      "properties": {
        "contractVersion": {
          "type": "string"
        },
        "workspaceId": {
          "type": "integer"
        },
        "applicationRuntimeId": {
          "$ref": "#/components/schemas/ApplicationRuntimeId"
        },
        "bundle": {
          "$ref": "#/components/schemas/BundleIdentity"
        },
        "resources": {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/ResourceVersion"
          }
        }
      },
      "required": [
        "contractVersion",
        "workspaceId",
        "applicationRuntimeId",
        "bundle",
        "resources"
      ],
      "additionalProperties": true
    },
    "WorkflowDefinition": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "workspaceId": {
          "type": "string"
        },
        "code": {
          "type": "string",
          "description": "工作流定义的稳定编码。查询定义时读取此字段;definitionCode 属于执行实例等其他对象。"
        },
        "name": {
          "type": "string"
        },
        "revision": {
          "type": "integer"
        },
        "currentPlanId": {
          "type": "string"
        },
        "recompilationRequired": {
          "type": "boolean"
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "draft",
            "active",
            "disabled"
          ]
        },
        "startNodeId": {
          "type": "string"
        },
        "inputSchema": {
          "type": "array",
          "items": {
            "type": "object",
            "description": "平台低代码参数定义。"
          }
        },
        "outputSchema": {
          "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
        },
        "nodes": {
          "type": "array",
          "items": {
            "type": "object",
            "description": "已安装资源版本的工作流节点定义。"
          }
        },
        "edges": {
          "type": "array",
          "items": {
            "type": "object"
          }
        },
        "graphLayout": {
          "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "workspaceId",
        "code",
        "name",
        "revision",
        "status",
        "startNodeId",
        "nodes",
        "edges",
        "recompilationRequired",
        "description",
        "inputSchema",
        "outputSchema",
        "graphLayout",
        "tags",
        "createdAt",
        "updatedAt"
      ],
      "additionalProperties": true,
      "description": "已安装的 Workflow 定义,直接位于 data(单项)或 data[](列表)。不包含编译计划外层 definitionCode/planId/definition;resourceLocator 与 semanticVersion 从 Bundle 资源账本取得。"
    },
    "WorkflowInstance": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "workspaceId": {
          "type": [
            "string",
            "null"
          ]
        },
        "applicationRuntimeId": {
          "type": [
            "string",
            "null"
          ]
        },
        "executionSnapshotId": {
          "type": "string"
        },
        "definitionId": {
          "type": "string"
        },
        "definitionCode": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "resourceVersion": {
          "$ref": "#/components/schemas/ResourceVersion"
        },
        "input": {
          "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
        },
        "output": {
          "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
        },
        "context": {
          "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
        },
        "metadata": {
          "type": "object"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "completedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "tenantId": {
          "type": "string"
        },
        "concurrencyGroupKey": {
          "type": "string"
        },
        "partitionKey": {
          "type": "string"
        },
        "runtimeProjectionId": {
          "type": "string"
        },
        "planId": {
          "type": [
            "string",
            "null"
          ]
        },
        "failedNodeId": {
          "type": [
            "string",
            "null"
          ]
        },
        "lastError": {
          "type": [
            "string",
            "null"
          ]
        },
        "currentNodeIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "waitingNodeIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "executionSubjectUserId": {
          "type": "integer"
        },
        "definitionSnapshot": {
          "$ref": "#/components/schemas/WorkflowDefinition"
        },
        "nodeStates": {
          "type": "object",
          "additionalProperties": {
            "type": "object"
          }
        }
      },
      "required": [
        "id",
        "tenantId",
        "concurrencyGroupKey",
        "executionSnapshotId",
        "definitionId",
        "definitionCode",
        "status",
        "input",
        "context",
        "output",
        "metadata",
        "currentNodeIds",
        "waitingNodeIds",
        "nodeStates",
        "createdAt",
        "updatedAt"
      ],
      "additionalProperties": true
    },
    "WorkflowInstanceDetail": {
      "allOf": [
        {
          "$ref": "#/components/schemas/WorkflowInstance"
        },
        {
          "type": "object",
          "properties": {
            "plan": {
              "type": [
                "object",
                "null"
              ],
              "description": "该执行冻结的运行计划,可能为空。"
            },
            "synchronization": {
              "$ref": "#/components/schemas/ExecutionSynchronization"
            }
          },
          "required": [
            "plan",
            "synchronization"
          ],
          "additionalProperties": true
        }
      ]
    },
    "WorkflowInstancePage": {
      "type": "object",
      "properties": {
        "list": {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/WorkflowInstanceSummary"
          }
        },
        "total": {
          "type": "integer",
          "minimum": 0
        },
        "statusCounts": {
          "type": "object",
          "additionalProperties": {
            "type": "integer"
          }
        },
        "synchronization": {
          "$ref": "#/components/schemas/ExecutionSynchronization"
        }
      },
      "required": [
        "list",
        "total",
        "statusCounts",
        "synchronization"
      ],
      "additionalProperties": true
    },
    "NodeExecution": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "instanceId": {
          "type": "string"
        },
        "nodeId": {
          "type": "string"
        },
        "nodeType": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "input": {
          "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
        },
        "output": {
          "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
        },
        "error": {
          "type": [
            "string",
            "null"
          ]
        },
        "metadata": {
          "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
        },
        "startedAt": {
          "type": "string",
          "format": "date-time"
        },
        "finishedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "trigger": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "instanceId",
        "nodeId",
        "nodeType",
        "status",
        "trigger",
        "startedAt"
      ],
      "additionalProperties": true
    },
    "WorkflowNodeHistory": {
      "type": "object",
      "properties": {
        "list": {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/NodeExecution"
          }
        },
        "synchronization": {
          "$ref": "#/components/schemas/ExecutionSynchronization"
        }
      },
      "required": [
        "list",
        "synchronization"
      ],
      "additionalProperties": true
    },
    "TimerDefinition": {
      "type": "object",
      "properties": {
        "resourceVersion": {
          "$ref": "#/components/schemas/ResourceVersion"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "enabled": {
          "type": "boolean"
        },
        "schedule": {
          "type": "object",
          "description": "Timer 版本自己的调度合同。"
        },
        "target": {
          "type": "object",
          "description": "Timer 版本自己的执行目标合同。"
        },
        "nextFireAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "resourceVersion",
        "name",
        "description",
        "enabled",
        "schedule",
        "target",
        "nextFireAt",
        "createdAt",
        "updatedAt"
      ],
      "additionalProperties": true
    },
    "TimerExecution": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "executionId": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "attemptNumber": {
          "type": "integer"
        },
        "requestBody": {
          "type": [
            "string",
            "null"
          ]
        },
        "responseBody": {
          "type": [
            "string",
            "null"
          ]
        },
        "errorMessage": {
          "type": [
            "string",
            "null"
          ]
        },
        "errorType": {
          "type": [
            "string",
            "null"
          ]
        },
        "traceId": {
          "type": [
            "string",
            "null"
          ]
        },
        "responseStatusCode": {
          "type": [
            "integer",
            "null"
          ]
        },
        "responseSizeBytes": {
          "type": [
            "integer",
            "null"
          ]
        },
        "durationMs": {
          "type": [
            "integer",
            "null"
          ]
        },
        "scheduledAt": {
          "type": "string",
          "format": "date-time"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "startedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "completedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "executionId",
        "status",
        "attemptNumber",
        "requestBody",
        "responseBody",
        "errorMessage",
        "errorType",
        "traceId",
        "responseStatusCode",
        "responseSizeBytes",
        "durationMs",
        "scheduledAt",
        "createdAt",
        "startedAt",
        "completedAt"
      ],
      "additionalProperties": true
    },
    "TimerTriggerReceipt": {
      "type": "object",
      "properties": {
        "applicationRuntimeId": {
          "type": "string"
        },
        "resourceLocator": {
          "$ref": "#/components/schemas/ResourceLocator"
        },
        "mode": {
          "const": "trigger"
        },
        "triggeredAt": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "applicationRuntimeId",
        "resourceLocator",
        "mode",
        "triggeredAt"
      ],
      "additionalProperties": true
    },
    "CapabilityError": {
      "type": "object",
      "required": [
        "errorCode",
        "data"
      ],
      "properties": {
        "contractVersion": {
          "const": "1.0.0"
        },
        "errorCode": {
          "type": "string",
          "maxLength": 128,
          "pattern": "^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$"
        },
        "data": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/components/schemas/CapabilityFailureData"
            }
          ]
        }
      },
      "additionalProperties": true
    },
    "ExecutionSynchronization": {
      "type": "object",
      "properties": {
        "generation": {
          "type": "integer",
          "minimum": 1
        },
        "rebuilding": {
          "type": "boolean"
        },
        "sourceObservedAt": {
          "type": "string",
          "format": "date-time"
        },
        "appliedAt": {
          "type": "string",
          "format": "date-time"
        },
        "caughtUpAt": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "generation",
        "rebuilding",
        "sourceObservedAt",
        "appliedAt",
        "caughtUpAt"
      ],
      "additionalProperties": true
    },
    "WorkflowInstanceSummary": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "workspaceId": {
          "type": "string"
        },
        "runtimeProjectionId": {
          "type": [
            "string",
            "null"
          ]
        },
        "executionSnapshotId": {
          "type": "string"
        },
        "applicationRuntimeId": {
          "type": [
            "string",
            "null"
          ]
        },
        "resourceVersion": {
          "$ref": "#/components/schemas/ResourceVersion"
        },
        "planId": {
          "type": [
            "string",
            "null"
          ]
        },
        "definitionId": {
          "type": "string"
        },
        "definitionCode": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "currentNodeIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "waitingNodeIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "failedNodeId": {
          "type": [
            "string",
            "null"
          ]
        },
        "lastError": {
          "type": [
            "string",
            "null"
          ]
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "completedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "hasOutput": {
          "type": "boolean"
        }
      },
      "required": [
        "id",
        "workspaceId",
        "runtimeProjectionId",
        "executionSnapshotId",
        "applicationRuntimeId",
        "planId",
        "definitionId",
        "definitionCode",
        "status",
        "currentNodeIds",
        "waitingNodeIds",
        "failedNodeId",
        "lastError",
        "createdAt",
        "updatedAt",
        "completedAt",
        "hasOutput"
      ],
      "additionalProperties": true
    },
    "CapabilityFailureData": {
      "type": "object",
      "required": [
        "message",
        "retryable"
      ],
      "properties": {
        "message": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        },
        "retryable": {
          "type": "boolean"
        }
      },
      "additionalProperties": true
    }
  }
}

本页内容