Loading...
Loading...
Compare original and translation side by side
{
"id": "my-blueprint",
"title": "My Workflow",
"description": "A simple two-participant workflow (min 5 chars)",
"version": 1,
"metadata": { "category": "demo" },
"participants": [
{ "id": "sender", "name": "Sender", "description": "Initiates the workflow" },
{ "id": "receiver", "name": "Receiver", "description": "Receives and completes" }
],
"actions": [
{
"id": 0,
"title": "Submit",
"sender": "sender",
"isStartingAction": true,
"dataSchemas": [
{
"type": "object",
"properties": {
"message": { "type": "string", "minLength": 1 }
},
"required": ["message"]
}
],
"routes": [
{ "id": "to-receiver", "nextActionIds": [1], "isDefault": true }
]
},
{
"id": 1,
"title": "Complete",
"sender": "receiver",
"dataSchemas": [
{
"type": "object",
"properties": {
"status": { "type": "string", "enum": ["accepted", "rejected"] }
},
"required": ["status"]
}
],
"routes": []
}
]
}{
"id": "my-blueprint",
"title": "My Workflow",
"description": "A simple two-participant workflow (min 5 chars)",
"version": 1,
"metadata": { "category": "demo" },
"participants": [
{ "id": "sender", "name": "Sender", "description": "Initiates the workflow" },
{ "id": "receiver", "name": "Receiver", "description": "Receives and completes" }
],
"actions": [
{
"id": 0,
"title": "Submit",
"sender": "sender",
"isStartingAction": true,
"dataSchemas": [
{
"type": "object",
"properties": {
"message": { "type": "string", "minLength": 1 }
},
"required": [ "message" ]
}
],
"routes": [
{ "id": "to-receiver", "nextActionIds": [1], "isDefault": true }
]
},
{
"id": 1,
"title": "Complete",
"sender": "receiver",
"dataSchemas": [
{
"type": "object",
"properties": {
"status": { "type": "string", "enum": [ "accepted", "rejected" ] }
},
"required": [ "status" ]
}
],
"routes": []
}
]
}{
"metadata": { "hasCycles": "true" },
"actions": [
{
"id": 0, "title": "Ping", "sender": "ping", "isStartingAction": true,
"routes": [{ "id": "ping-to-pong", "nextActionIds": [1], "isDefault": true }]
},
{
"id": 1, "title": "Pong", "sender": "pong",
"routes": [{ "id": "pong-to-ping", "nextActionIds": [0], "isDefault": true }]
}
]
}metadata["hasCycles"] = "true"{
"metadata": { "hasCycles": "true" },
"actions": [
{
"id": 0, "title": "Ping", "sender": "ping", "isStartingAction": true,
"routes": [{ "id": "ping-to-pong", "nextActionIds": [1], "isDefault": true }]
},
{
"id": 1, "title": "Pong", "sender": "pong",
"routes": [{ "id": "pong-to-ping", "nextActionIds": [0], "isDefault": true }]
}
]
}metadata["hasCycles"] = "true"| Concept | Details |
|---|---|
| Participants | Min 2 required. Each has |
| Actions | Sequential IDs starting at 0. One must have |
| Routes | Define flow between actions. |
| DataSchemas | JSON Schema for action payload. |
| Conditions | JSON Logic expressions for conditional routing |
| Calculations | JSON Logic for computed values (e.g., |
| Cycles | Allowed with warning. Set |
| 概念 | 详情 |
|---|---|
| 参与者 | 至少需要2个。每个参与者包含 |
| 动作 | 从0开始的连续ID。必须有一个动作设置 |
| 路由 | 定义动作间的流转。 |
| DataSchemas | 动作负载的JSON Schema。对应C#中的 |
| 条件 | 用于条件路由的JSON Logic表达式 |
| 计算 | 用于计算值的JSON Logic(例如 |
| 循环 | 允许存在但会触发警告。需设置 |
action.senderparticipant.idBlueprintBuilder.Build()action.senderparticipant.idBlueprintBuilder.Build(){ "id": "always", "nextActionIds": [1], "isDefault": true }{ "id": "always", "nextActionIds": [1], "isDefault": true }{
"id": "approve-route",
"nextActionIds": [2],
"condition": { "==": [{ "var": "decision" }, "approved"] }
}{
"id": "approve-route",
"nextActionIds": [2],
"condition": { "==": [{ "var": "decision" }, "approved"] }
}{ "id": "complete", "nextActionIds": [], "isDefault": true }{ "id": "complete", "nextActionIds": [], "isDefault": true }{
"id": "parallel-review",
"nextActionIds": [2, 3],
"isDefault": true,
"branchDeadline": "P7D"
}{
"id": "parallel-review",
"nextActionIds": [2, 3],
"isDefault": true,
"branchDeadline": "P7D"
}Action.RoutesAction.ParticipantsroutesAction.RoutesAction.Participantsroutes{ "type": "string", "minLength": 1, "maxLength": 500, "title": "Message" }{ "type": "string", "minLength": 1, "maxLength": 500, "title": "Message" }{ "type": "integer", "minimum": 1, "title": "Counter" }{ "type": "integer", "minimum": 1, "title": "Counter" }{ "type": "string", "enum": ["approved", "rejected", "escalate"], "title": "Decision" }{ "type": "string", "enum": [ "approved", "rejected", "escalate" ], "title": "Decision" }{ "type": "number", "minimum": 0, "title": "Amount" }{ "type": "number", "minimum": 0, "title": "Amount" }{
"id": "template-id",
"title": "Template Title",
"description": "What this template does (min 5 chars)",
"version": 1,
"category": "demo|approval|finance|supply-chain",
"tags": ["tag1", "tag2"],
"author": "Sorcha Team",
"published": true,
"template": { /* raw blueprint JSON or JSON-e template */ },
"parameterSchema": null,
"defaultParameters": null,
"examples": []
}{
"id": "template-id",
"title": "Template Title",
"description": "What this template does (min 5 chars)",
"version": 1,
"category": "demo|approval|finance|supply-chain",
"tags": [ "tag1", "tag2" ],
"author": "Sorcha Team",
"published": true,
"template": { /* raw blueprint JSON or JSON-e template */ },
"parameterSchema": null,
"defaultParameters": null,
"examples": []
}parameterSchema: nulltemplateparameterSchema: nulltemplate$eval$if$flattenDeeptemplateparameterSchemadefaultParametersexamples{ "$eval": "paramName" }{ "$if": "condition", "then": ..., "else": ... }{ "$flattenDeep": [...] }template$eval$if$flattenDeepparameterSchemadefaultParametersexamples{ "$eval": "paramName" }{ "$if": "condition", "then": ..., "else": ... }{ "$flattenDeep": [...] }POST /api/blueprints/POST /api/blueprints/{id}/publishPOST /api/instances/POST /api/blueprints/POST /api/blueprints/{id}/publishPOST /api/instances/{
"blueprintId": "...",
"version": 1,
"publishedAt": "...",
"warnings": ["Cyclic route detected: action 0 → action 1 → action 0. This blueprint will loop indefinitely unless routing conditions provide a termination path."]
}{
"blueprintId": "...",
"version": 1,
"publishedAt": "...",
"warnings": [ "Cyclic route detected: action 0 → action 1 → action 0. This blueprint will loop indefinitely unless routing conditions provide a termination path." ]
}POST /api/instances/{id}/actions/{actionId}/execute
Headers: Authorization: Bearer <token>, X-Delegation-Token: <token>
Body: {
"blueprintId": "string",
"actionId": "string",
"instanceId": "string",
"senderWallet": "string",
"registerAddress": "string",
"payloadData": { "message": "hello", "counter": 1 }
}POST /api/instances/{id}/actions/{actionId}/execute
Headers: Authorization: Bearer <token>, X-Delegation-Token: <token>
Body: {
"blueprintId": "string",
"actionId": "string",
"instanceId": "string",
"senderWallet": "string",
"registerAddress": "string",
"payloadData": { "message": "hello", "counter": 1 }
}Submit(requester) → Review(manager) → Approve(director) → CompleteSubmit(requester) → Review(manager) → Approve(director) → CompletePing(A) → Pong(B) → Ping(A) → Pong(B) → ... (indefinite)Ping(A) → Pong(B) → Ping(A) → Pong(B) → ... (无限循环)Submit → [amount > 10000] → Director Approval
Submit → [amount <= 10000] → Manager Approval
Both → CompleteSubmit → [金额 > 10000] → 总监审批
Submit → [金额 <= 10000] → 经理审批
两者最终都指向 → 完成| File | Purpose |
|---|---|
| Built-in template JSON files |
| Blueprint, Action, Route, Participant models |
| Template model |
| Execution engine (validate/calculate/route/disclose) |
| Fluent API for programmatic blueprint creation |
| PublishService, ValidateBlueprint, DetectCycles |
| Startup seeding |
| 文件 | 用途 |
|---|---|
| 内置模板JSON文件 |
| 蓝图、动作、路由、参与者模型 |
| 模板模型 |
| 执行引擎(验证/计算/路由/披露) |
| 用于程序化创建蓝图的Fluent API |
| 发布服务、蓝图验证、循环检测 |
| 启动时的模板初始化服务 |