@ajna-inc/workflow 0.5.38 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmvc/attestations.jsonld +43 -0
- package/.npmvc/sbom.cdx.json +23758 -0
- package/LICENSE +202 -0
- package/build/WorkflowEvents.d.mts +40 -0
- package/build/WorkflowEvents.d.mts.map +1 -0
- package/build/WorkflowEvents.mjs +11 -0
- package/build/WorkflowEvents.mjs.map +1 -0
- package/build/WorkflowModule.d.mts +17 -0
- package/build/WorkflowModule.d.mts.map +1 -0
- package/build/WorkflowModule.mjs +446 -0
- package/build/WorkflowModule.mjs.map +1 -0
- package/build/WorkflowModuleConfig.d.mts +39 -0
- package/build/WorkflowModuleConfig.d.mts.map +1 -0
- package/build/WorkflowModuleConfig.mjs +19 -0
- package/build/WorkflowModuleConfig.mjs.map +1 -0
- package/build/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs +14 -0
- package/build/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateMetadata.mjs +11 -0
- package/build/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateParam.mjs +9 -0
- package/build/_virtual/rolldown_runtime.mjs +41 -0
- package/build/actions/ActionRegistry.d.mts +64 -0
- package/build/actions/ActionRegistry.d.mts.map +1 -0
- package/build/actions/ActionRegistry.mjs +304 -0
- package/build/actions/ActionRegistry.mjs.map +1 -0
- package/build/api/WorkflowApi.d.mts +99 -0
- package/build/api/WorkflowApi.d.mts.map +1 -0
- package/build/api/WorkflowApi.mjs +228 -0
- package/build/api/WorkflowApi.mjs.map +1 -0
- package/build/engine/AttributePlanner.d.mts +12 -0
- package/build/engine/AttributePlanner.d.mts.map +1 -0
- package/build/engine/AttributePlanner.mjs +58 -0
- package/build/engine/AttributePlanner.mjs.map +1 -0
- package/build/engine/GuardEvaluator.d.mts +16 -0
- package/build/engine/GuardEvaluator.d.mts.map +1 -0
- package/build/engine/GuardEvaluator.mjs +38 -0
- package/build/engine/GuardEvaluator.mjs.map +1 -0
- package/build/index.d.mts +46 -0
- package/build/index.mjs +53 -0
- package/build/index.mjs.map +1 -0
- package/build/model/TemplateValidation.d.mts +8 -0
- package/build/model/TemplateValidation.d.mts.map +1 -0
- package/build/model/TemplateValidation.mjs +278 -0
- package/build/model/TemplateValidation.mjs.map +1 -0
- package/build/model/types.d.mts +120 -0
- package/build/model/types.d.mts.map +1 -0
- package/build/model/types.mjs +11 -0
- package/build/model/types.mjs.map +1 -0
- package/build/protocol/WorkflowMessageTypes.d.mts +19 -0
- package/build/protocol/WorkflowMessageTypes.d.mts.map +1 -0
- package/build/protocol/WorkflowMessageTypes.mjs +20 -0
- package/build/protocol/WorkflowMessageTypes.mjs.map +1 -0
- package/build/protocol/handlers/AdvanceHandler.d.mts +16 -0
- package/build/protocol/handlers/AdvanceHandler.d.mts.map +1 -0
- package/build/protocol/handlers/AdvanceHandler.mjs +148 -0
- package/build/protocol/handlers/AdvanceHandler.mjs.map +1 -0
- package/build/protocol/handlers/CancelHandler.d.mts +16 -0
- package/build/protocol/handlers/CancelHandler.d.mts.map +1 -0
- package/build/protocol/handlers/CancelHandler.mjs +103 -0
- package/build/protocol/handlers/CancelHandler.mjs.map +1 -0
- package/build/protocol/handlers/CompleteHandler.d.mts +16 -0
- package/build/protocol/handlers/CompleteHandler.d.mts.map +1 -0
- package/build/protocol/handlers/CompleteHandler.mjs +103 -0
- package/build/protocol/handlers/CompleteHandler.mjs.map +1 -0
- package/build/protocol/handlers/DiscoverHandler.d.mts +15 -0
- package/build/protocol/handlers/DiscoverHandler.d.mts.map +1 -0
- package/build/protocol/handlers/DiscoverHandler.mjs +73 -0
- package/build/protocol/handlers/DiscoverHandler.mjs.map +1 -0
- package/build/protocol/handlers/FetchTemplateHandler.d.mts +16 -0
- package/build/protocol/handlers/FetchTemplateHandler.d.mts.map +1 -0
- package/build/protocol/handlers/FetchTemplateHandler.mjs +64 -0
- package/build/protocol/handlers/FetchTemplateHandler.mjs.map +1 -0
- package/build/protocol/handlers/PauseHandler.d.mts +16 -0
- package/build/protocol/handlers/PauseHandler.d.mts.map +1 -0
- package/build/protocol/handlers/PauseHandler.mjs +103 -0
- package/build/protocol/handlers/PauseHandler.mjs.map +1 -0
- package/build/protocol/handlers/ProblemReportHandler.d.mts +11 -0
- package/build/protocol/handlers/ProblemReportHandler.d.mts.map +1 -0
- package/build/protocol/handlers/ProblemReportHandler.mjs +26 -0
- package/build/protocol/handlers/ProblemReportHandler.mjs.map +1 -0
- package/build/protocol/handlers/PublishTemplateHandler.d.mts +15 -0
- package/build/protocol/handlers/PublishTemplateHandler.d.mts.map +1 -0
- package/build/protocol/handlers/PublishTemplateHandler.mjs +47 -0
- package/build/protocol/handlers/PublishTemplateHandler.mjs.map +1 -0
- package/build/protocol/handlers/ResumeHandler.d.mts +16 -0
- package/build/protocol/handlers/ResumeHandler.d.mts.map +1 -0
- package/build/protocol/handlers/ResumeHandler.mjs +103 -0
- package/build/protocol/handlers/ResumeHandler.mjs.map +1 -0
- package/build/protocol/handlers/StartHandler.d.mts +16 -0
- package/build/protocol/handlers/StartHandler.d.mts.map +1 -0
- package/build/protocol/handlers/StartHandler.mjs +238 -0
- package/build/protocol/handlers/StartHandler.mjs.map +1 -0
- package/build/protocol/handlers/StatusHandler.d.mts +16 -0
- package/build/protocol/handlers/StatusHandler.d.mts.map +1 -0
- package/build/protocol/handlers/StatusHandler.mjs +169 -0
- package/build/protocol/handlers/StatusHandler.mjs.map +1 -0
- package/build/protocol/handlers/TemplateHandler.d.mts +14 -0
- package/build/protocol/handlers/TemplateHandler.d.mts.map +1 -0
- package/build/protocol/handlers/TemplateHandler.mjs +66 -0
- package/build/protocol/handlers/TemplateHandler.mjs.map +1 -0
- package/build/protocol/messages/AdvanceMessage.d.mts +22 -0
- package/build/protocol/messages/AdvanceMessage.d.mts.map +1 -0
- package/build/protocol/messages/AdvanceMessage.mjs +25 -0
- package/build/protocol/messages/AdvanceMessage.mjs.map +1 -0
- package/build/protocol/messages/CancelMessage.d.mts +20 -0
- package/build/protocol/messages/CancelMessage.d.mts.map +1 -0
- package/build/protocol/messages/CancelMessage.mjs +25 -0
- package/build/protocol/messages/CancelMessage.mjs.map +1 -0
- package/build/protocol/messages/CompleteMessage.d.mts +20 -0
- package/build/protocol/messages/CompleteMessage.d.mts.map +1 -0
- package/build/protocol/messages/CompleteMessage.mjs +25 -0
- package/build/protocol/messages/CompleteMessage.mjs.map +1 -0
- package/build/protocol/messages/DiscoverMessage.d.mts +29 -0
- package/build/protocol/messages/DiscoverMessage.d.mts.map +1 -0
- package/build/protocol/messages/DiscoverMessage.mjs +25 -0
- package/build/protocol/messages/DiscoverMessage.mjs.map +1 -0
- package/build/protocol/messages/FetchTemplateMessage.d.mts +21 -0
- package/build/protocol/messages/FetchTemplateMessage.d.mts.map +1 -0
- package/build/protocol/messages/FetchTemplateMessage.mjs +31 -0
- package/build/protocol/messages/FetchTemplateMessage.mjs.map +1 -0
- package/build/protocol/messages/PauseMessage.d.mts +20 -0
- package/build/protocol/messages/PauseMessage.d.mts.map +1 -0
- package/build/protocol/messages/PauseMessage.mjs +25 -0
- package/build/protocol/messages/PauseMessage.mjs.map +1 -0
- package/build/protocol/messages/ProblemReportMessage.d.mts +21 -0
- package/build/protocol/messages/ProblemReportMessage.d.mts.map +1 -0
- package/build/protocol/messages/ProblemReportMessage.mjs +25 -0
- package/build/protocol/messages/ProblemReportMessage.mjs.map +1 -0
- package/build/protocol/messages/PublishTemplateMessage.d.mts +23 -0
- package/build/protocol/messages/PublishTemplateMessage.d.mts.map +1 -0
- package/build/protocol/messages/PublishTemplateMessage.mjs +24 -0
- package/build/protocol/messages/PublishTemplateMessage.mjs.map +1 -0
- package/build/protocol/messages/ResumeMessage.d.mts +20 -0
- package/build/protocol/messages/ResumeMessage.d.mts.map +1 -0
- package/build/protocol/messages/ResumeMessage.mjs +25 -0
- package/build/protocol/messages/ResumeMessage.mjs.map +1 -0
- package/build/protocol/messages/StartMessage.d.mts +27 -0
- package/build/protocol/messages/StartMessage.d.mts.map +1 -0
- package/build/protocol/messages/StartMessage.mjs +25 -0
- package/build/protocol/messages/StartMessage.mjs.map +1 -0
- package/build/protocol/messages/StatusMessage.d.mts +35 -0
- package/build/protocol/messages/StatusMessage.d.mts.map +1 -0
- package/build/protocol/messages/StatusMessage.mjs +25 -0
- package/build/protocol/messages/StatusMessage.mjs.map +1 -0
- package/build/protocol/messages/StatusRequestMessage.d.mts +29 -0
- package/build/protocol/messages/StatusRequestMessage.d.mts.map +1 -0
- package/build/protocol/messages/StatusRequestMessage.mjs +25 -0
- package/build/protocol/messages/StatusRequestMessage.mjs.map +1 -0
- package/build/protocol/messages/TemplateMessage.d.mts +20 -0
- package/build/protocol/messages/TemplateMessage.d.mts.map +1 -0
- package/build/protocol/messages/TemplateMessage.mjs +25 -0
- package/build/protocol/messages/TemplateMessage.mjs.map +1 -0
- package/build/protocol/messages/WorkflowsMessage.d.mts +28 -0
- package/build/protocol/messages/WorkflowsMessage.d.mts.map +1 -0
- package/build/protocol/messages/WorkflowsMessage.mjs +25 -0
- package/build/protocol/messages/WorkflowsMessage.mjs.map +1 -0
- package/build/queue/CommandQueue.d.mts +22 -0
- package/build/queue/CommandQueue.d.mts.map +1 -0
- package/build/queue/CommandQueue.mjs +6 -0
- package/build/queue/CommandQueue.mjs.map +1 -0
- package/build/queue/PersistentCommandQueue.d.mts +56 -0
- package/build/queue/PersistentCommandQueue.d.mts.map +1 -0
- package/build/queue/PersistentCommandQueue.mjs +273 -0
- package/build/queue/PersistentCommandQueue.mjs.map +1 -0
- package/build/repository/WorkflowCommandRecord.d.mts +50 -0
- package/build/repository/WorkflowCommandRecord.d.mts.map +1 -0
- package/build/repository/WorkflowCommandRecord.mjs +48 -0
- package/build/repository/WorkflowCommandRecord.mjs.map +1 -0
- package/build/repository/WorkflowCommandRepository.d.mts +59 -0
- package/build/repository/WorkflowCommandRepository.d.mts.map +1 -0
- package/build/repository/WorkflowCommandRepository.mjs +136 -0
- package/build/repository/WorkflowCommandRepository.mjs.map +1 -0
- package/build/repository/WorkflowInstanceRecord.d.mts +65 -0
- package/build/repository/WorkflowInstanceRecord.d.mts.map +1 -0
- package/build/repository/WorkflowInstanceRecord.mjs +44 -0
- package/build/repository/WorkflowInstanceRecord.mjs.map +1 -0
- package/build/repository/WorkflowInstanceRepository.d.mts +15 -0
- package/build/repository/WorkflowInstanceRepository.d.mts.map +1 -0
- package/build/repository/WorkflowInstanceRepository.mjs +48 -0
- package/build/repository/WorkflowInstanceRepository.mjs.map +1 -0
- package/build/repository/WorkflowTemplateRecord.d.mts +27 -0
- package/build/repository/WorkflowTemplateRecord.d.mts.map +1 -0
- package/build/repository/WorkflowTemplateRecord.mjs +29 -0
- package/build/repository/WorkflowTemplateRecord.mjs.map +1 -0
- package/build/repository/WorkflowTemplateRepository.d.mts +11 -0
- package/build/repository/WorkflowTemplateRepository.d.mts.map +1 -0
- package/build/repository/WorkflowTemplateRepository.mjs +43 -0
- package/build/repository/WorkflowTemplateRepository.mjs.map +1 -0
- package/build/services/WorkflowService.d.mts +107 -0
- package/build/services/WorkflowService.d.mts.map +1 -0
- package/build/services/WorkflowService.mjs +582 -0
- package/build/services/WorkflowService.mjs.map +1 -0
- package/build/ui/UiFilter.mjs +85 -0
- package/build/ui/UiFilter.mjs.map +1 -0
- package/package.json +27 -33
- package/build/WorkflowEvents.d.ts +0 -35
- package/build/WorkflowEvents.js +0 -10
- package/build/WorkflowEvents.js.map +0 -1
- package/build/WorkflowModule.d.ts +0 -13
- package/build/WorkflowModule.js +0 -647
- package/build/WorkflowModule.js.map +0 -1
- package/build/WorkflowModuleConfig.d.ts +0 -35
- package/build/WorkflowModuleConfig.js +0 -19
- package/build/WorkflowModuleConfig.js.map +0 -1
- package/build/actions/ActionRegistry.d.ts +0 -59
- package/build/actions/ActionRegistry.js +0 -367
- package/build/actions/ActionRegistry.js.map +0 -1
- package/build/api/WorkflowApi.d.ts +0 -94
- package/build/api/WorkflowApi.js +0 -241
- package/build/api/WorkflowApi.js.map +0 -1
- package/build/engine/AttributePlanner.d.ts +0 -7
- package/build/engine/AttributePlanner.js +0 -81
- package/build/engine/AttributePlanner.js.map +0 -1
- package/build/engine/GuardEvaluator.d.ts +0 -11
- package/build/engine/GuardEvaluator.js +0 -40
- package/build/engine/GuardEvaluator.js.map +0 -1
- package/build/index.d.ts +0 -45
- package/build/index.js +0 -69
- package/build/index.js.map +0 -1
- package/build/model/TemplateValidation.d.ts +0 -3
- package/build/model/TemplateValidation.js +0 -231
- package/build/model/TemplateValidation.js.map +0 -1
- package/build/model/types.d.ts +0 -116
- package/build/model/types.js +0 -15
- package/build/model/types.js.map +0 -1
- package/build/protocol/WorkflowMessageTypes.d.ts +0 -15
- package/build/protocol/WorkflowMessageTypes.js +0 -22
- package/build/protocol/WorkflowMessageTypes.js.map +0 -1
- package/build/protocol/handlers/AdvanceHandler.d.ts +0 -12
- package/build/protocol/handlers/AdvanceHandler.js +0 -149
- package/build/protocol/handlers/AdvanceHandler.js.map +0 -1
- package/build/protocol/handlers/CancelHandler.d.ts +0 -12
- package/build/protocol/handlers/CancelHandler.js +0 -124
- package/build/protocol/handlers/CancelHandler.js.map +0 -1
- package/build/protocol/handlers/CompleteHandler.d.ts +0 -12
- package/build/protocol/handlers/CompleteHandler.js +0 -125
- package/build/protocol/handlers/CompleteHandler.js.map +0 -1
- package/build/protocol/handlers/DiscoverHandler.d.ts +0 -11
- package/build/protocol/handlers/DiscoverHandler.js +0 -71
- package/build/protocol/handlers/DiscoverHandler.js.map +0 -1
- package/build/protocol/handlers/FetchTemplateHandler.d.ts +0 -12
- package/build/protocol/handlers/FetchTemplateHandler.js +0 -71
- package/build/protocol/handlers/FetchTemplateHandler.js.map +0 -1
- package/build/protocol/handlers/PauseHandler.d.ts +0 -12
- package/build/protocol/handlers/PauseHandler.js +0 -124
- package/build/protocol/handlers/PauseHandler.js.map +0 -1
- package/build/protocol/handlers/ProblemReportHandler.d.ts +0 -6
- package/build/protocol/handlers/ProblemReportHandler.js +0 -28
- package/build/protocol/handlers/ProblemReportHandler.js.map +0 -1
- package/build/protocol/handlers/PublishTemplateHandler.d.ts +0 -11
- package/build/protocol/handlers/PublishTemplateHandler.js +0 -53
- package/build/protocol/handlers/PublishTemplateHandler.js.map +0 -1
- package/build/protocol/handlers/ResumeHandler.d.ts +0 -12
- package/build/protocol/handlers/ResumeHandler.js +0 -124
- package/build/protocol/handlers/ResumeHandler.js.map +0 -1
- package/build/protocol/handlers/StartHandler.d.ts +0 -12
- package/build/protocol/handlers/StartHandler.js +0 -274
- package/build/protocol/handlers/StartHandler.js.map +0 -1
- package/build/protocol/handlers/StatusHandler.d.ts +0 -12
- package/build/protocol/handlers/StatusHandler.js +0 -202
- package/build/protocol/handlers/StatusHandler.js.map +0 -1
- package/build/protocol/handlers/TemplateHandler.d.ts +0 -9
- package/build/protocol/handlers/TemplateHandler.js +0 -83
- package/build/protocol/handlers/TemplateHandler.js.map +0 -1
- package/build/protocol/messages/AdvanceMessage.d.ts +0 -16
- package/build/protocol/messages/AdvanceMessage.js +0 -33
- package/build/protocol/messages/AdvanceMessage.js.map +0 -1
- package/build/protocol/messages/CancelMessage.d.ts +0 -14
- package/build/protocol/messages/CancelMessage.js +0 -33
- package/build/protocol/messages/CancelMessage.js.map +0 -1
- package/build/protocol/messages/CompleteMessage.d.ts +0 -14
- package/build/protocol/messages/CompleteMessage.js +0 -33
- package/build/protocol/messages/CompleteMessage.js.map +0 -1
- package/build/protocol/messages/DiscoverMessage.d.ts +0 -23
- package/build/protocol/messages/DiscoverMessage.js +0 -33
- package/build/protocol/messages/DiscoverMessage.js.map +0 -1
- package/build/protocol/messages/FetchTemplateMessage.d.ts +0 -15
- package/build/protocol/messages/FetchTemplateMessage.js +0 -33
- package/build/protocol/messages/FetchTemplateMessage.js.map +0 -1
- package/build/protocol/messages/PauseMessage.d.ts +0 -14
- package/build/protocol/messages/PauseMessage.js +0 -33
- package/build/protocol/messages/PauseMessage.js.map +0 -1
- package/build/protocol/messages/ProblemReportMessage.d.ts +0 -15
- package/build/protocol/messages/ProblemReportMessage.js +0 -33
- package/build/protocol/messages/ProblemReportMessage.js.map +0 -1
- package/build/protocol/messages/PublishTemplateMessage.d.ts +0 -17
- package/build/protocol/messages/PublishTemplateMessage.js +0 -31
- package/build/protocol/messages/PublishTemplateMessage.js.map +0 -1
- package/build/protocol/messages/ResumeMessage.d.ts +0 -14
- package/build/protocol/messages/ResumeMessage.js +0 -33
- package/build/protocol/messages/ResumeMessage.js.map +0 -1
- package/build/protocol/messages/StartMessage.d.ts +0 -21
- package/build/protocol/messages/StartMessage.js +0 -33
- package/build/protocol/messages/StartMessage.js.map +0 -1
- package/build/protocol/messages/StatusMessage.d.ts +0 -29
- package/build/protocol/messages/StatusMessage.js +0 -33
- package/build/protocol/messages/StatusMessage.js.map +0 -1
- package/build/protocol/messages/StatusRequestMessage.d.ts +0 -23
- package/build/protocol/messages/StatusRequestMessage.js +0 -33
- package/build/protocol/messages/StatusRequestMessage.js.map +0 -1
- package/build/protocol/messages/TemplateMessage.d.ts +0 -14
- package/build/protocol/messages/TemplateMessage.js +0 -33
- package/build/protocol/messages/TemplateMessage.js.map +0 -1
- package/build/protocol/messages/WorkflowsMessage.d.ts +0 -22
- package/build/protocol/messages/WorkflowsMessage.js +0 -33
- package/build/protocol/messages/WorkflowsMessage.js.map +0 -1
- package/build/queue/CommandQueue.d.ts +0 -18
- package/build/queue/CommandQueue.js +0 -8
- package/build/queue/CommandQueue.js.map +0 -1
- package/build/queue/PersistentCommandQueue.d.ts +0 -51
- package/build/queue/PersistentCommandQueue.js +0 -348
- package/build/queue/PersistentCommandQueue.js.map +0 -1
- package/build/repository/WorkflowCommandRecord.d.ts +0 -46
- package/build/repository/WorkflowCommandRecord.js +0 -52
- package/build/repository/WorkflowCommandRecord.js.map +0 -1
- package/build/repository/WorkflowCommandRepository.d.ts +0 -55
- package/build/repository/WorkflowCommandRepository.js +0 -149
- package/build/repository/WorkflowCommandRepository.js.map +0 -1
- package/build/repository/WorkflowInstanceRecord.d.ts +0 -61
- package/build/repository/WorkflowInstanceRecord.js +0 -43
- package/build/repository/WorkflowInstanceRecord.js.map +0 -1
- package/build/repository/WorkflowInstanceRepository.d.ts +0 -10
- package/build/repository/WorkflowInstanceRepository.js +0 -52
- package/build/repository/WorkflowInstanceRepository.js.map +0 -1
- package/build/repository/WorkflowTemplateRecord.d.ts +0 -23
- package/build/repository/WorkflowTemplateRecord.js +0 -28
- package/build/repository/WorkflowTemplateRecord.js.map +0 -1
- package/build/repository/WorkflowTemplateRepository.d.ts +0 -6
- package/build/repository/WorkflowTemplateRepository.js +0 -56
- package/build/repository/WorkflowTemplateRepository.js.map +0 -1
- package/build/services/WorkflowService.d.ts +0 -102
- package/build/services/WorkflowService.js +0 -712
- package/build/services/WorkflowService.js.map +0 -1
- package/build/ui/UiFilter.d.ts +0 -5
- package/build/ui/UiFilter.js +0 -104
- package/build/ui/UiFilter.js.map +0 -1
- package/build/ui/UiTypes.d.ts +0 -28
- package/build/ui/UiTypes.js +0 -3
- package/build/ui/UiTypes.js.map +0 -1
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import Ajv from "ajv";
|
|
2
|
+
import addFormats from "ajv-formats";
|
|
3
|
+
|
|
4
|
+
//#region src/model/TemplateValidation.ts
|
|
5
|
+
const ajv = new Ajv({
|
|
6
|
+
allErrors: true,
|
|
7
|
+
strict: false
|
|
8
|
+
});
|
|
9
|
+
addFormats(ajv);
|
|
10
|
+
const validate = ajv.compile({
|
|
11
|
+
type: "object",
|
|
12
|
+
required: [
|
|
13
|
+
"template_id",
|
|
14
|
+
"version",
|
|
15
|
+
"title",
|
|
16
|
+
"instance_policy",
|
|
17
|
+
"states",
|
|
18
|
+
"transitions",
|
|
19
|
+
"catalog",
|
|
20
|
+
"actions"
|
|
21
|
+
],
|
|
22
|
+
properties: {
|
|
23
|
+
template_id: {
|
|
24
|
+
type: "string",
|
|
25
|
+
minLength: 1
|
|
26
|
+
},
|
|
27
|
+
version: {
|
|
28
|
+
type: "string",
|
|
29
|
+
minLength: 1
|
|
30
|
+
},
|
|
31
|
+
title: {
|
|
32
|
+
type: "string",
|
|
33
|
+
minLength: 1
|
|
34
|
+
},
|
|
35
|
+
instance_policy: {
|
|
36
|
+
type: "object",
|
|
37
|
+
required: ["mode"],
|
|
38
|
+
properties: {
|
|
39
|
+
mode: { enum: ["singleton_per_connection", "multi_per_connection"] },
|
|
40
|
+
multiplicity_key: { type: "string" }
|
|
41
|
+
},
|
|
42
|
+
additionalProperties: false
|
|
43
|
+
},
|
|
44
|
+
sections: {
|
|
45
|
+
type: "array",
|
|
46
|
+
items: {
|
|
47
|
+
type: "object",
|
|
48
|
+
required: ["name"],
|
|
49
|
+
properties: {
|
|
50
|
+
name: { type: "string" },
|
|
51
|
+
order: { type: "number" },
|
|
52
|
+
icon: { type: "string" }
|
|
53
|
+
},
|
|
54
|
+
additionalProperties: true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
states: {
|
|
58
|
+
type: "array",
|
|
59
|
+
minItems: 1,
|
|
60
|
+
items: {
|
|
61
|
+
type: "object",
|
|
62
|
+
required: ["name", "type"],
|
|
63
|
+
properties: {
|
|
64
|
+
name: { type: "string" },
|
|
65
|
+
type: { enum: [
|
|
66
|
+
"start",
|
|
67
|
+
"normal",
|
|
68
|
+
"final"
|
|
69
|
+
] },
|
|
70
|
+
section: { type: "string" }
|
|
71
|
+
},
|
|
72
|
+
additionalProperties: true
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
transitions: {
|
|
76
|
+
type: "array",
|
|
77
|
+
items: {
|
|
78
|
+
type: "object",
|
|
79
|
+
required: [
|
|
80
|
+
"from",
|
|
81
|
+
"to",
|
|
82
|
+
"on"
|
|
83
|
+
],
|
|
84
|
+
properties: {
|
|
85
|
+
from: { type: "string" },
|
|
86
|
+
to: { type: "string" },
|
|
87
|
+
on: { type: "string" },
|
|
88
|
+
guard: { type: "string" },
|
|
89
|
+
action: { type: "string" }
|
|
90
|
+
},
|
|
91
|
+
additionalProperties: false
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
catalog: {
|
|
95
|
+
type: "object",
|
|
96
|
+
properties: {
|
|
97
|
+
credential_profiles: {
|
|
98
|
+
type: "object",
|
|
99
|
+
additionalProperties: {
|
|
100
|
+
type: "object",
|
|
101
|
+
required: [
|
|
102
|
+
"cred_def_id",
|
|
103
|
+
"attribute_plan",
|
|
104
|
+
"to_ref"
|
|
105
|
+
],
|
|
106
|
+
properties: {
|
|
107
|
+
cred_def_id: { type: "string" },
|
|
108
|
+
attribute_plan: {
|
|
109
|
+
type: "object",
|
|
110
|
+
additionalProperties: { anyOf: [
|
|
111
|
+
{
|
|
112
|
+
type: "object",
|
|
113
|
+
required: ["source", "path"],
|
|
114
|
+
properties: {
|
|
115
|
+
source: { const: "context" },
|
|
116
|
+
path: { type: "string" },
|
|
117
|
+
required: { type: "boolean" }
|
|
118
|
+
},
|
|
119
|
+
additionalProperties: false
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: "object",
|
|
123
|
+
required: ["source", "value"],
|
|
124
|
+
properties: {
|
|
125
|
+
source: { const: "static" },
|
|
126
|
+
value: {},
|
|
127
|
+
required: { type: "boolean" }
|
|
128
|
+
},
|
|
129
|
+
additionalProperties: false
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
type: "object",
|
|
133
|
+
required: ["source", "expr"],
|
|
134
|
+
properties: {
|
|
135
|
+
source: { const: "compute" },
|
|
136
|
+
expr: { type: "string" },
|
|
137
|
+
required: { type: "boolean" }
|
|
138
|
+
},
|
|
139
|
+
additionalProperties: false
|
|
140
|
+
}
|
|
141
|
+
] }
|
|
142
|
+
},
|
|
143
|
+
to_ref: { type: "string" },
|
|
144
|
+
options: {
|
|
145
|
+
type: "object",
|
|
146
|
+
additionalProperties: true
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
additionalProperties: false
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
proof_profiles: {
|
|
153
|
+
type: "object",
|
|
154
|
+
additionalProperties: {
|
|
155
|
+
type: "object",
|
|
156
|
+
required: ["to_ref"],
|
|
157
|
+
properties: {
|
|
158
|
+
schema_id: { type: "string" },
|
|
159
|
+
cred_def_id: { type: "string" },
|
|
160
|
+
requested_attributes: {
|
|
161
|
+
type: "array",
|
|
162
|
+
items: { type: "string" }
|
|
163
|
+
},
|
|
164
|
+
requested_predicates: {
|
|
165
|
+
type: "array",
|
|
166
|
+
items: {
|
|
167
|
+
type: "object",
|
|
168
|
+
required: [
|
|
169
|
+
"name",
|
|
170
|
+
"p_type",
|
|
171
|
+
"p_value"
|
|
172
|
+
],
|
|
173
|
+
properties: {
|
|
174
|
+
name: { type: "string" },
|
|
175
|
+
p_type: { type: "string" },
|
|
176
|
+
p_value: { type: "number" }
|
|
177
|
+
},
|
|
178
|
+
additionalProperties: false
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
to_ref: { type: "string" },
|
|
182
|
+
options: {
|
|
183
|
+
type: "object",
|
|
184
|
+
additionalProperties: true
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
additionalProperties: false
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
defaults: { type: "object" }
|
|
191
|
+
},
|
|
192
|
+
additionalProperties: true
|
|
193
|
+
},
|
|
194
|
+
actions: {
|
|
195
|
+
type: "array",
|
|
196
|
+
items: {
|
|
197
|
+
type: "object",
|
|
198
|
+
required: ["key", "typeURI"],
|
|
199
|
+
properties: {
|
|
200
|
+
key: { type: "string" },
|
|
201
|
+
typeURI: { type: "string" },
|
|
202
|
+
profile_ref: {
|
|
203
|
+
type: "string",
|
|
204
|
+
pattern: "^(cp|pp)\\."
|
|
205
|
+
},
|
|
206
|
+
staticInput: {}
|
|
207
|
+
},
|
|
208
|
+
additionalProperties: true
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
display_hints: { type: "object" }
|
|
212
|
+
},
|
|
213
|
+
additionalProperties: false
|
|
214
|
+
});
|
|
215
|
+
function validateTemplateJson(tpl) {
|
|
216
|
+
if (!validate(tpl)) {
|
|
217
|
+
const msg = (validate.errors || []).map((e) => `${e.instancePath || "template"} ${e.message}`).join("; ");
|
|
218
|
+
const err = new Error(msg);
|
|
219
|
+
err.code = "invalid_template";
|
|
220
|
+
throw err;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function validateTemplateRefs(t) {
|
|
224
|
+
const stateNames = new Set(t.states.map((s) => s.name));
|
|
225
|
+
if (![...t.states].some((s) => s.type === "start")) {
|
|
226
|
+
const err = /* @__PURE__ */ new Error("start state required");
|
|
227
|
+
err.code = "invalid_template";
|
|
228
|
+
throw err;
|
|
229
|
+
}
|
|
230
|
+
for (const s of t.states) if (s.section && !t.sections?.some((sec) => sec.name === s.section)) {
|
|
231
|
+
const err = /* @__PURE__ */ new Error(`state.section not found: ${s.section}`);
|
|
232
|
+
err.code = "invalid_template";
|
|
233
|
+
throw err;
|
|
234
|
+
}
|
|
235
|
+
for (const tr of t.transitions) {
|
|
236
|
+
if (!stateNames.has(tr.from)) {
|
|
237
|
+
const err = /* @__PURE__ */ new Error(`transition.from unknown: ${tr.from}`);
|
|
238
|
+
err.code = "invalid_template";
|
|
239
|
+
throw err;
|
|
240
|
+
}
|
|
241
|
+
if (!stateNames.has(tr.to)) {
|
|
242
|
+
const err = /* @__PURE__ */ new Error(`transition.to unknown: ${tr.to}`);
|
|
243
|
+
err.code = "invalid_template";
|
|
244
|
+
throw err;
|
|
245
|
+
}
|
|
246
|
+
if (tr.action && !t.actions.some((a) => a.key === tr.action)) {
|
|
247
|
+
const err = /* @__PURE__ */ new Error(`transition.action unknown: ${tr.action}`);
|
|
248
|
+
err.code = "invalid_template";
|
|
249
|
+
throw err;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
for (const a of t.actions) if ("profile_ref" in a) {
|
|
253
|
+
const pr = a.profile_ref;
|
|
254
|
+
if (pr.startsWith("cp.")) {
|
|
255
|
+
const key = pr.slice(3);
|
|
256
|
+
if (!t.catalog?.credential_profiles || !t.catalog.credential_profiles[key]) {
|
|
257
|
+
const err = /* @__PURE__ */ new Error(`catalog.cp missing: ${key}`);
|
|
258
|
+
err.code = "invalid_template";
|
|
259
|
+
throw err;
|
|
260
|
+
}
|
|
261
|
+
} else if (pr.startsWith("pp.")) {
|
|
262
|
+
const key = pr.slice(3);
|
|
263
|
+
if (!t.catalog?.proof_profiles || !t.catalog.proof_profiles[key]) {
|
|
264
|
+
const err = /* @__PURE__ */ new Error(`catalog.pp missing: ${key}`);
|
|
265
|
+
err.code = "invalid_template";
|
|
266
|
+
throw err;
|
|
267
|
+
}
|
|
268
|
+
} else if (typeof pr === "string") {
|
|
269
|
+
const err = /* @__PURE__ */ new Error(`invalid profile_ref: ${pr}`);
|
|
270
|
+
err.code = "invalid_template";
|
|
271
|
+
throw err;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
//#endregion
|
|
277
|
+
export { validateTemplateJson, validateTemplateRefs };
|
|
278
|
+
//# sourceMappingURL=TemplateValidation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateValidation.mjs","names":[],"sources":["../../src/model/TemplateValidation.ts"],"sourcesContent":["import type { WorkflowTemplate } from './types'\n\nimport Ajv from 'ajv'\nimport addFormats from 'ajv-formats'\n\nconst ajv = new Ajv({ allErrors: true, strict: false })\naddFormats(ajv)\n\nconst schema = {\n type: 'object',\n required: ['template_id', 'version', 'title', 'instance_policy', 'states', 'transitions', 'catalog', 'actions'],\n properties: {\n template_id: { type: 'string', minLength: 1 },\n version: { type: 'string', minLength: 1 },\n title: { type: 'string', minLength: 1 },\n instance_policy: {\n type: 'object',\n required: ['mode'],\n properties: {\n mode: { enum: ['singleton_per_connection', 'multi_per_connection'] },\n multiplicity_key: { type: 'string' },\n },\n additionalProperties: false,\n },\n sections: {\n type: 'array',\n items: {\n type: 'object',\n required: ['name'],\n properties: { name: { type: 'string' }, order: { type: 'number' }, icon: { type: 'string' } },\n additionalProperties: true,\n },\n },\n states: {\n type: 'array',\n minItems: 1,\n items: {\n type: 'object',\n required: ['name', 'type'],\n properties: {\n name: { type: 'string' },\n type: { enum: ['start', 'normal', 'final'] },\n section: { type: 'string' },\n },\n additionalProperties: true,\n },\n },\n transitions: {\n type: 'array',\n items: {\n type: 'object',\n required: ['from', 'to', 'on'],\n properties: {\n from: { type: 'string' },\n to: { type: 'string' },\n on: { type: 'string' },\n guard: { type: 'string' },\n action: { type: 'string' },\n },\n additionalProperties: false,\n },\n },\n catalog: {\n type: 'object',\n properties: {\n credential_profiles: {\n type: 'object',\n additionalProperties: {\n type: 'object',\n required: ['cred_def_id', 'attribute_plan', 'to_ref'],\n properties: {\n cred_def_id: { type: 'string' },\n attribute_plan: {\n type: 'object',\n additionalProperties: {\n anyOf: [\n {\n type: 'object',\n required: ['source', 'path'],\n properties: {\n source: { const: 'context' },\n path: { type: 'string' },\n required: { type: 'boolean' },\n },\n additionalProperties: false,\n },\n {\n type: 'object',\n required: ['source', 'value'],\n properties: { source: { const: 'static' }, value: {}, required: { type: 'boolean' } },\n additionalProperties: false,\n },\n {\n type: 'object',\n required: ['source', 'expr'],\n properties: {\n source: { const: 'compute' },\n expr: { type: 'string' },\n required: { type: 'boolean' },\n },\n additionalProperties: false,\n },\n ],\n },\n },\n to_ref: { type: 'string' },\n options: { type: 'object', additionalProperties: true },\n },\n additionalProperties: false,\n },\n },\n proof_profiles: {\n type: 'object',\n additionalProperties: {\n type: 'object',\n required: ['to_ref'],\n properties: {\n schema_id: { type: 'string' },\n cred_def_id: { type: 'string' },\n requested_attributes: { type: 'array', items: { type: 'string' } },\n requested_predicates: {\n type: 'array',\n items: {\n type: 'object',\n required: ['name', 'p_type', 'p_value'],\n properties: { name: { type: 'string' }, p_type: { type: 'string' }, p_value: { type: 'number' } },\n additionalProperties: false,\n },\n },\n to_ref: { type: 'string' },\n options: { type: 'object', additionalProperties: true },\n },\n additionalProperties: false,\n },\n },\n defaults: { type: 'object' },\n },\n additionalProperties: true,\n },\n actions: {\n type: 'array',\n items: {\n type: 'object',\n required: ['key', 'typeURI'],\n properties: {\n key: { type: 'string' },\n typeURI: { type: 'string' },\n profile_ref: { type: 'string', pattern: '^(cp|pp)\\\\.' },\n staticInput: {},\n },\n additionalProperties: true,\n },\n },\n display_hints: { type: 'object' },\n },\n additionalProperties: false,\n}\n\nconst validate = ajv.compile(schema as unknown as object)\n\nexport function validateTemplateJson(tpl: unknown) {\n const ok = validate(tpl)\n if (!ok) {\n const errs = (validate.errors || []) as Array<{ instancePath?: string; message?: string }>\n const msg = errs.map((e) => `${e.instancePath || 'template'} ${e.message}`).join('; ')\n const err = new Error(msg) as Error & { code: string }\n err.code = 'invalid_template'\n throw err\n }\n}\n\nexport function validateTemplateRefs(t: WorkflowTemplate) {\n // Structural checks beyond schema\n const stateNames = new Set(t.states.map((s) => s.name))\n if (![...t.states].some((s) => s.type === 'start')) {\n const err = new Error('start state required') as Error & { code?: string }\n err.code = 'invalid_template'\n throw err\n }\n for (const s of t.states) {\n if (s.section && !t.sections?.some((sec) => sec.name === s.section)) {\n const err = new Error(`state.section not found: ${s.section}`) as Error & { code?: string }\n err.code = 'invalid_template'\n throw err\n }\n }\n for (const tr of t.transitions) {\n if (!stateNames.has(tr.from)) {\n const err = new Error(`transition.from unknown: ${tr.from}`) as Error & { code?: string }\n err.code = 'invalid_template'\n throw err\n }\n if (!stateNames.has(tr.to)) {\n const err = new Error(`transition.to unknown: ${tr.to}`) as Error & { code?: string }\n err.code = 'invalid_template'\n throw err\n }\n if (tr.action && !t.actions.some((a) => a.key === tr.action)) {\n const err = new Error(`transition.action unknown: ${tr.action}`) as Error & { code?: string }\n err.code = 'invalid_template'\n throw err\n }\n }\n for (const a of t.actions) {\n if ('profile_ref' in a) {\n const pr = (a as { profile_ref: string }).profile_ref\n if (pr.startsWith('cp.')) {\n const key = pr.slice(3)\n if (!t.catalog?.credential_profiles || !t.catalog.credential_profiles[key]) {\n const err = new Error(`catalog.cp missing: ${key}`)\n ;(err as Error & { code?: string }).code = 'invalid_template'\n throw err\n }\n } else if (pr.startsWith('pp.')) {\n const key = pr.slice(3)\n if (!t.catalog?.proof_profiles || !t.catalog.proof_profiles[key]) {\n const err = new Error(`catalog.pp missing: ${key}`)\n ;(err as Error & { code?: string }).code = 'invalid_template'\n throw err\n }\n } else if (typeof pr === 'string') {\n const err = new Error(`invalid profile_ref: ${pr}`)\n ;(err as Error & { code?: string }).code = 'invalid_template'\n throw err\n }\n }\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
//#region src/model/types.d.ts
|
|
2
|
+
type InstancePolicy = {
|
|
3
|
+
mode: 'singleton_per_connection' | 'multi_per_connection';
|
|
4
|
+
multiplicity_key?: string;
|
|
5
|
+
};
|
|
6
|
+
type SectionDef = {
|
|
7
|
+
name: string;
|
|
8
|
+
order?: number;
|
|
9
|
+
icon?: string;
|
|
10
|
+
};
|
|
11
|
+
type StateDef = {
|
|
12
|
+
name: string;
|
|
13
|
+
type: 'start' | 'normal' | 'final';
|
|
14
|
+
section?: string;
|
|
15
|
+
};
|
|
16
|
+
type TransitionDef = {
|
|
17
|
+
from: string;
|
|
18
|
+
to: string;
|
|
19
|
+
on: string;
|
|
20
|
+
guard?: string;
|
|
21
|
+
action?: string;
|
|
22
|
+
};
|
|
23
|
+
type AttributeSpec = {
|
|
24
|
+
source: 'context';
|
|
25
|
+
path: string;
|
|
26
|
+
required?: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
source: 'static';
|
|
29
|
+
value: unknown;
|
|
30
|
+
required?: boolean;
|
|
31
|
+
} | {
|
|
32
|
+
source: 'compute';
|
|
33
|
+
expr: string;
|
|
34
|
+
required?: boolean;
|
|
35
|
+
};
|
|
36
|
+
type CredentialProfile = {
|
|
37
|
+
cred_def_id: string;
|
|
38
|
+
attribute_plan: Record<string, AttributeSpec>;
|
|
39
|
+
to_ref: string;
|
|
40
|
+
options?: Record<string, unknown>;
|
|
41
|
+
};
|
|
42
|
+
type ProofProfile = {
|
|
43
|
+
cred_def_id?: string;
|
|
44
|
+
schema_id?: string;
|
|
45
|
+
requested_attributes?: string[];
|
|
46
|
+
requested_predicates?: Array<{
|
|
47
|
+
name: string;
|
|
48
|
+
p_type: string;
|
|
49
|
+
p_value: number;
|
|
50
|
+
}>;
|
|
51
|
+
to_ref: string;
|
|
52
|
+
options?: Record<string, unknown>;
|
|
53
|
+
};
|
|
54
|
+
type Catalog = {
|
|
55
|
+
credential_profiles?: Record<string, CredentialProfile>;
|
|
56
|
+
proof_profiles?: Record<string, ProofProfile>;
|
|
57
|
+
defaults?: Record<string, unknown>;
|
|
58
|
+
};
|
|
59
|
+
type ActionDef = {
|
|
60
|
+
key: string;
|
|
61
|
+
typeURI: string;
|
|
62
|
+
profile_ref: string;
|
|
63
|
+
} | {
|
|
64
|
+
key: string;
|
|
65
|
+
typeURI: string;
|
|
66
|
+
staticInput?: unknown;
|
|
67
|
+
};
|
|
68
|
+
type UiItem = {
|
|
69
|
+
type?: string;
|
|
70
|
+
label?: string;
|
|
71
|
+
event?: string;
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
};
|
|
74
|
+
type DisplayHints = {
|
|
75
|
+
states?: Record<string, UiItem[]>;
|
|
76
|
+
};
|
|
77
|
+
type WorkflowTemplate = {
|
|
78
|
+
template_id: string;
|
|
79
|
+
version: string;
|
|
80
|
+
title: string;
|
|
81
|
+
instance_policy: InstancePolicy;
|
|
82
|
+
sections?: SectionDef[];
|
|
83
|
+
states: StateDef[];
|
|
84
|
+
transitions: TransitionDef[];
|
|
85
|
+
catalog: Catalog;
|
|
86
|
+
actions: ActionDef[];
|
|
87
|
+
display_hints?: DisplayHints;
|
|
88
|
+
};
|
|
89
|
+
type Participants = Record<string, {
|
|
90
|
+
did: string;
|
|
91
|
+
}>;
|
|
92
|
+
type InstanceHistoryItem = {
|
|
93
|
+
ts: string;
|
|
94
|
+
event: string;
|
|
95
|
+
from: string;
|
|
96
|
+
to: string;
|
|
97
|
+
actionKey?: string;
|
|
98
|
+
msg_id?: string;
|
|
99
|
+
};
|
|
100
|
+
type WorkflowInstanceData = {
|
|
101
|
+
instance_id: string;
|
|
102
|
+
template_id: string;
|
|
103
|
+
template_version: string;
|
|
104
|
+
connection_id?: string;
|
|
105
|
+
participants: Participants;
|
|
106
|
+
state: string;
|
|
107
|
+
section?: string;
|
|
108
|
+
context: Record<string, unknown>;
|
|
109
|
+
artifacts: Record<string, unknown>;
|
|
110
|
+
status: 'active' | 'paused' | 'canceled' | 'completed' | 'error';
|
|
111
|
+
history: InstanceHistoryItem[];
|
|
112
|
+
multiplicityKeyValue?: string;
|
|
113
|
+
idempotencyKeys?: string[];
|
|
114
|
+
};
|
|
115
|
+
declare const findSectionForState: (tpl: WorkflowTemplate, stateName?: string) => string | undefined;
|
|
116
|
+
declare const transitionsFromState: (tpl: WorkflowTemplate, state: string) => TransitionDef[];
|
|
117
|
+
declare const ensureArray: <T>(arr?: T[]) => T[];
|
|
118
|
+
//#endregion
|
|
119
|
+
export { ActionDef, AttributeSpec, Catalog, CredentialProfile, DisplayHints, InstanceHistoryItem, InstancePolicy, Participants, ProofProfile, SectionDef, StateDef, TransitionDef, UiItem, WorkflowInstanceData, WorkflowTemplate, ensureArray, findSectionForState, transitionsFromState };
|
|
120
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/model/types.ts"],"sourcesContent":[],"mappings":";KAAY,cAAA;EAAA,IAAA,EAAA,0BAAc,GAAA,sBAAA;EAKd,gBAAU,CAAA,EAAA,MAAA;AAEtB,CAAA;AAEY,KAJA,UAAA,GAIa;EAQb,IAAA,EAAA,MAAA;EAKA,KAAA,CAAA,EAAA,MAAA;EAEqB,IAAA,CAAA,EAAA,MAAA;CAAf;AAEN,KAnBA,QAAA,GAmBA;EAAM,IAAA,EAAA,MAAA;EAGN,IAAA,EAAA,OAAA,GAAY,QAAA,GAKC,OAEb;EAGA,OAAA,CAAA,EAAO,MAAA;CACoB;AAAf,KA/BZ,aAAA,GA+BY;EACU,IAAA,EAAA,MAAA;EAAf,EAAA,EAAA,MAAA;EACN,EAAA,EAAA,MAAA;EAAM,KAAA,CAAA,EAAA,MAAA;EAGP,MAAA,CAAA,EAAA,MAAS;AAIrB,CAAA;AAOY,KAvCA,aAAA,GAuCY;EAIZ,MAAA,EAAA,SAAA;EAIO,IAAA,EAAA,MAAA;EACN,QAAA,CAAA,EAAA,OAAA;CACH,GAAA;EACK,MAAA,EAAA,QAAA;EACJ,KAAA,EAAA,OAAA;EACA,QAAA,CAAA,EAAA,OAAA;CACO,GAAA;EAAY,MAAA,EAAA,SAAA;EAGlB,IAAA,EAAA,MAAA;EAEA,QAAA,CAAA,EAAA,OAAA;AASZ,CAAA;AAKgB,KAnEJ,iBAAA,GAmEI;EAGL,WAAA,EAAA,MAAA;EACE,cAAA,EArEK,MAqEL,CAAA,MAAA,EArEoB,aAqEpB,CAAA;EAEF,MAAA,EAAA,MAAA;EAAmB,OAAA,CAAA,EArElB,MAqEkB,CAAA,MAAA,EAAA,OAAA,CAAA;AAK9B,CAAA;AAMa,KA7ED,YAAA,GA8EqC;EAEpC,WAAA,CAAA,EAAoE,MAAA;;;yBA3ExD;;;;;;YAEb;;KAGA,OAAA;wBACY,eAAe;mBACpB,eAAe;aACrB;;KAGD,SAAA;;;;;;;;;KAIA,MAAA;;;;;;KAOA,YAAA;WACD,eAAe;;KAGd,gBAAA;;;;mBAIO;aACN;UACH;eACK;WACJ;WACA;kBACO;;KAGN,YAAA,GAAe;;;KAEf,mBAAA;;;;;;;;KASA,oBAAA;;;;;gBAKI;;;WAGL;aACE;;WAEF;;;;cAKE,2BAA4B;cAM5B,4BAA6B,oCAA+B;cAG5D,uBAAwB,QAAM"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/model/types.ts
|
|
2
|
+
const findSectionForState = (tpl, stateName) => {
|
|
3
|
+
if (!stateName) return void 0;
|
|
4
|
+
return tpl.states.find((s) => s.name === stateName)?.section;
|
|
5
|
+
};
|
|
6
|
+
const transitionsFromState = (tpl, state) => tpl.transitions.filter((t) => t.from === state);
|
|
7
|
+
const ensureArray = (arr) => Array.isArray(arr) ? arr : [];
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ensureArray, findSectionForState, transitionsFromState };
|
|
11
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","names":[],"sources":["../../src/model/types.ts"],"sourcesContent":["export type InstancePolicy = {\n mode: 'singleton_per_connection' | 'multi_per_connection'\n multiplicity_key?: string\n}\n\nexport type SectionDef = { name: string; order?: number; icon?: string }\n\nexport type StateDef = { name: string; type: 'start' | 'normal' | 'final'; section?: string }\n\nexport type TransitionDef = {\n from: string\n to: string\n on: string\n guard?: string\n action?: string\n}\n\nexport type AttributeSpec =\n | { source: 'context'; path: string; required?: boolean }\n | { source: 'static'; value: unknown; required?: boolean }\n | { source: 'compute'; expr: string; required?: boolean }\n\nexport type CredentialProfile = {\n cred_def_id: string\n attribute_plan: Record<string, AttributeSpec>\n to_ref: string\n options?: Record<string, unknown>\n}\n\nexport type ProofProfile = {\n // Either cred_def_id or schema_id may be provided to scope restrictions\n cred_def_id?: string\n schema_id?: string\n requested_attributes?: string[]\n requested_predicates?: Array<{ name: string; p_type: string; p_value: number }>\n to_ref: string\n options?: Record<string, unknown>\n}\n\nexport type Catalog = {\n credential_profiles?: Record<string, CredentialProfile>\n proof_profiles?: Record<string, ProofProfile>\n defaults?: Record<string, unknown>\n}\n\nexport type ActionDef =\n | { key: string; typeURI: string; profile_ref: string }\n | { key: string; typeURI: string; staticInput?: unknown }\n\nexport type UiItem = {\n type?: string\n label?: string\n event?: string\n [key: string]: unknown\n}\n\nexport type DisplayHints = {\n states?: Record<string, UiItem[]>\n}\n\nexport type WorkflowTemplate = {\n template_id: string\n version: string\n title: string\n instance_policy: InstancePolicy\n sections?: SectionDef[]\n states: StateDef[]\n transitions: TransitionDef[]\n catalog: Catalog\n actions: ActionDef[]\n display_hints?: DisplayHints\n}\n\nexport type Participants = Record<string, { did: string }>\n\nexport type InstanceHistoryItem = {\n ts: string\n event: string\n from: string\n to: string\n actionKey?: string\n msg_id?: string\n}\n\nexport type WorkflowInstanceData = {\n instance_id: string\n template_id: string\n template_version: string\n connection_id?: string\n participants: Participants\n state: string\n section?: string\n context: Record<string, unknown>\n artifacts: Record<string, unknown>\n status: 'active' | 'paused' | 'canceled' | 'completed' | 'error'\n history: InstanceHistoryItem[]\n multiplicityKeyValue?: string\n idempotencyKeys?: string[]\n}\n\nexport const findSectionForState = (tpl: WorkflowTemplate, stateName?: string): string | undefined => {\n if (!stateName) return undefined\n const st = tpl.states.find((s) => s.name === stateName)\n return st?.section\n}\n\nexport const transitionsFromState = (tpl: WorkflowTemplate, state: string) =>\n tpl.transitions.filter((t) => t.from === state)\n\nexport const ensureArray = <T>(arr?: T[]): T[] => (Array.isArray(arr) ? arr : [])\n"],"mappings":";AAoGA,MAAa,uBAAuB,KAAuB,cAA2C;AACpG,KAAI,CAAC,UAAW,QAAO;AAEvB,QADW,IAAI,OAAO,MAAM,MAAM,EAAE,SAAS,UAAU,EAC5C;;AAGb,MAAa,wBAAwB,KAAuB,UAC1D,IAAI,YAAY,QAAQ,MAAM,EAAE,SAAS,MAAM;AAEjD,MAAa,eAAkB,QAAoB,MAAM,QAAQ,IAAI,GAAG,MAAM,EAAE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/protocol/WorkflowMessageTypes.d.ts
|
|
2
|
+
declare const WorkflowMessageType: {
|
|
3
|
+
readonly PublishTemplate: "https://didcomm.org/workflow/1.0/publish-template";
|
|
4
|
+
readonly Start: "https://didcomm.org/workflow/1.0/start";
|
|
5
|
+
readonly Advance: "https://didcomm.org/workflow/1.0/advance";
|
|
6
|
+
readonly Status: "https://didcomm.org/workflow/1.0/status";
|
|
7
|
+
readonly ProblemReport: "https://didcomm.org/workflow/1.0/problem-report";
|
|
8
|
+
readonly Pause: "https://didcomm.org/workflow/1.0/pause";
|
|
9
|
+
readonly Resume: "https://didcomm.org/workflow/1.0/resume";
|
|
10
|
+
readonly Cancel: "https://didcomm.org/workflow/1.0/cancel";
|
|
11
|
+
readonly Complete: "https://didcomm.org/workflow/1.0/complete";
|
|
12
|
+
readonly Discover: "https://didcomm.org/workflow/1.0/discover";
|
|
13
|
+
readonly Workflows: "https://didcomm.org/workflow/1.0/workflows";
|
|
14
|
+
readonly FetchTemplate: "https://didcomm.org/workflow/1.0/fetch-template";
|
|
15
|
+
readonly Template: "https://didcomm.org/workflow/1.0/template";
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { WorkflowMessageType };
|
|
19
|
+
//# sourceMappingURL=WorkflowMessageTypes.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkflowMessageTypes.d.mts","names":[],"sources":["../../src/protocol/WorkflowMessageTypes.ts"],"sourcesContent":[],"mappings":";cAAa;EAAA,SAAA,eAiBH,EAAA,mDAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/protocol/WorkflowMessageTypes.ts
|
|
2
|
+
const WorkflowMessageType = {
|
|
3
|
+
PublishTemplate: "https://didcomm.org/workflow/1.0/publish-template",
|
|
4
|
+
Start: "https://didcomm.org/workflow/1.0/start",
|
|
5
|
+
Advance: "https://didcomm.org/workflow/1.0/advance",
|
|
6
|
+
Status: "https://didcomm.org/workflow/1.0/status",
|
|
7
|
+
ProblemReport: "https://didcomm.org/workflow/1.0/problem-report",
|
|
8
|
+
Pause: "https://didcomm.org/workflow/1.0/pause",
|
|
9
|
+
Resume: "https://didcomm.org/workflow/1.0/resume",
|
|
10
|
+
Cancel: "https://didcomm.org/workflow/1.0/cancel",
|
|
11
|
+
Complete: "https://didcomm.org/workflow/1.0/complete",
|
|
12
|
+
Discover: "https://didcomm.org/workflow/1.0/discover",
|
|
13
|
+
Workflows: "https://didcomm.org/workflow/1.0/workflows",
|
|
14
|
+
FetchTemplate: "https://didcomm.org/workflow/1.0/fetch-template",
|
|
15
|
+
Template: "https://didcomm.org/workflow/1.0/template"
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { WorkflowMessageType };
|
|
20
|
+
//# sourceMappingURL=WorkflowMessageTypes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkflowMessageTypes.mjs","names":[],"sources":["../../src/protocol/WorkflowMessageTypes.ts"],"sourcesContent":["export const WorkflowMessageType = {\n PublishTemplate: 'https://didcomm.org/workflow/1.0/publish-template',\n // edit workflow\n // discover workflows based on connection / other filters workflow unlocked discovery of workflow changes\n Start: 'https://didcomm.org/workflow/1.0/start',\n Advance: 'https://didcomm.org/workflow/1.0/advance',\n Status: 'https://didcomm.org/workflow/1.0/status',\n ProblemReport: 'https://didcomm.org/workflow/1.0/problem-report',\n Pause: 'https://didcomm.org/workflow/1.0/pause',\n Resume: 'https://didcomm.org/workflow/1.0/resume',\n Cancel: 'https://didcomm.org/workflow/1.0/cancel',\n Complete: 'https://didcomm.org/workflow/1.0/complete',\n // discovery & fetch extension\n Discover: 'https://didcomm.org/workflow/1.0/discover',\n Workflows: 'https://didcomm.org/workflow/1.0/workflows',\n FetchTemplate: 'https://didcomm.org/workflow/1.0/fetch-template',\n Template: 'https://didcomm.org/workflow/1.0/template',\n} as const\n"],"mappings":";AAAA,MAAa,sBAAsB;CACjC,iBAAiB;CAGjB,OAAO;CACP,SAAS;CACT,QAAQ;CACR,eAAe;CACf,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,UAAU;CAEV,UAAU;CACV,WAAW;CACX,eAAe;CACf,UAAU;CACX"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WorkflowService } from "../../services/WorkflowService.mjs";
|
|
2
|
+
import { AdvanceMessage } from "../messages/AdvanceMessage.mjs";
|
|
3
|
+
import { StatusMessage } from "../messages/StatusMessage.mjs";
|
|
4
|
+
import { ProblemReportMessage } from "../messages/ProblemReportMessage.mjs";
|
|
5
|
+
import { DidCommMessageHandler, DidCommMessageHandlerInboundMessage, DidCommOutboundMessageContext } from "@credo-ts/didcomm";
|
|
6
|
+
|
|
7
|
+
//#region src/protocol/handlers/AdvanceHandler.d.ts
|
|
8
|
+
declare class AdvanceHandler implements DidCommMessageHandler {
|
|
9
|
+
private readonly service;
|
|
10
|
+
supportedMessages: (typeof AdvanceMessage)[];
|
|
11
|
+
constructor(service: WorkflowService);
|
|
12
|
+
handle(messageContext: DidCommMessageHandlerInboundMessage<AdvanceHandler>): Promise<DidCommOutboundMessageContext<ProblemReportMessage> | DidCommOutboundMessageContext<StatusMessage>>;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { AdvanceHandler };
|
|
16
|
+
//# sourceMappingURL=AdvanceHandler.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdvanceHandler.d.mts","names":[],"sources":["../../../src/protocol/handlers/AdvanceHandler.ts"],"sourcesContent":[],"mappings":";;;;;;;cAea,cAAA,YAA0B;EAA1B,iBAAe,OAAA;EACF,iBAAA,EAAA,CAAA,OAAA,cAAA,CAAA,EAAA;EACqB,WAAA,CAAA,OAAA,EAAA,eAAA;EAC2B,MAAA,CAAA,cAAA,EAApC,mCAAoC,CAAA,cAAA,CAAA,CAAA,EAAe,OAAf,CAAe,6BAAf,CAAe,oBAAf,CAAA,GAAe,6BAAf,CAAe,aAAf,CAAA,CAAA"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { WorkflowModuleConfig } from "../../WorkflowModuleConfig.mjs";
|
|
2
|
+
import { CommandQueueService } from "../../queue/CommandQueue.mjs";
|
|
3
|
+
import { __decorateMetadata, init_decorateMetadata } from "../../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateMetadata.mjs";
|
|
4
|
+
import { __decorate, init_decorate } from "../../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs";
|
|
5
|
+
import { WorkflowInstanceRepository } from "../../repository/WorkflowInstanceRepository.mjs";
|
|
6
|
+
import { AdvanceMessage } from "../messages/AdvanceMessage.mjs";
|
|
7
|
+
import { WorkflowService } from "../../services/WorkflowService.mjs";
|
|
8
|
+
import { ProblemReportMessage } from "../messages/ProblemReportMessage.mjs";
|
|
9
|
+
import { StatusMessage } from "../messages/StatusMessage.mjs";
|
|
10
|
+
import { AgentConfig, injectable } from "@credo-ts/core";
|
|
11
|
+
import { DidCommOutboundMessageContext } from "@credo-ts/didcomm";
|
|
12
|
+
|
|
13
|
+
//#region src/protocol/handlers/AdvanceHandler.ts
|
|
14
|
+
init_decorateMetadata();
|
|
15
|
+
init_decorate();
|
|
16
|
+
var _ref;
|
|
17
|
+
let AdvanceHandler = class AdvanceHandler$1 {
|
|
18
|
+
constructor(service) {
|
|
19
|
+
this.service = service;
|
|
20
|
+
this.supportedMessages = [AdvanceMessage];
|
|
21
|
+
}
|
|
22
|
+
async handle(messageContext) {
|
|
23
|
+
const dm = messageContext.agentContext.dependencyManager;
|
|
24
|
+
const logger = dm.resolve(AgentConfig).logger;
|
|
25
|
+
const config = dm.resolve(WorkflowModuleConfig);
|
|
26
|
+
const thid = messageContext.message.threadId || messageContext.message.id;
|
|
27
|
+
const { instance_id, event } = messageContext.message.body || {};
|
|
28
|
+
logger.info("[Workflow] advance received", {
|
|
29
|
+
instance_id,
|
|
30
|
+
event,
|
|
31
|
+
thid
|
|
32
|
+
});
|
|
33
|
+
try {
|
|
34
|
+
const _id = messageContext.message.body?.instance_id;
|
|
35
|
+
if (_id && thid && _id !== thid) throw Object.assign(/* @__PURE__ */ new Error("threadId does not match instance_id"), { code: "correlation_mismatch" });
|
|
36
|
+
} catch (_e) {}
|
|
37
|
+
try {
|
|
38
|
+
const inboundConnId = messageContext.connection?.id;
|
|
39
|
+
const instId = messageContext.message.body?.instance_id;
|
|
40
|
+
if (!inboundConnId || !instId) {
|
|
41
|
+
try {
|
|
42
|
+
logger.warn("[Workflow] advance rejected (missing inbound connection or instance_id)", {
|
|
43
|
+
thid,
|
|
44
|
+
inboundConnId,
|
|
45
|
+
instId
|
|
46
|
+
});
|
|
47
|
+
} catch {}
|
|
48
|
+
throw Object.assign(/* @__PURE__ */ new Error("missing inbound connection"), { code: "forbidden" });
|
|
49
|
+
}
|
|
50
|
+
const inst = await messageContext.agentContext.dependencyManager.resolve(WorkflowInstanceRepository).getByInstanceId(messageContext.agentContext, instId);
|
|
51
|
+
if (!inst) {
|
|
52
|
+
try {
|
|
53
|
+
logger.warn("[Workflow] advance: instance not found", {
|
|
54
|
+
thid,
|
|
55
|
+
instId
|
|
56
|
+
});
|
|
57
|
+
} catch {}
|
|
58
|
+
throw Object.assign(/* @__PURE__ */ new Error("instance not found"), { code: "invalid_event" });
|
|
59
|
+
}
|
|
60
|
+
if (inst.connectionId && inst.connectionId !== inboundConnId) {
|
|
61
|
+
try {
|
|
62
|
+
logger.warn("[Workflow] advance rejected (connection mismatch)", {
|
|
63
|
+
thid,
|
|
64
|
+
inboundConnId,
|
|
65
|
+
instanceConnId: inst.connectionId
|
|
66
|
+
});
|
|
67
|
+
} catch {}
|
|
68
|
+
throw Object.assign(/* @__PURE__ */ new Error("connection mismatch"), { code: "forbidden" });
|
|
69
|
+
}
|
|
70
|
+
const queue = dm.resolve(CommandQueueService);
|
|
71
|
+
if (queue && typeof queue.enqueue === "function" && typeof queue.isReady === "function") {
|
|
72
|
+
const ready = await queue.isReady();
|
|
73
|
+
try {
|
|
74
|
+
logger.info("[Workflow] advance: queue resolved", {
|
|
75
|
+
thid: instId,
|
|
76
|
+
ready
|
|
77
|
+
});
|
|
78
|
+
} catch {}
|
|
79
|
+
if (ready) {
|
|
80
|
+
await queue.enqueue(messageContext.agentContext, {
|
|
81
|
+
cmd: "advance",
|
|
82
|
+
thid: instId,
|
|
83
|
+
connectionId: inboundConnId,
|
|
84
|
+
idempotency_key: messageContext.message.body?.idempotency_key,
|
|
85
|
+
payload: messageContext.message.body,
|
|
86
|
+
contextCorrelationId: messageContext.agentContext.contextCorrelationId
|
|
87
|
+
});
|
|
88
|
+
try {
|
|
89
|
+
logger.info("[Workflow] advance: enqueued command", {
|
|
90
|
+
thid: instId,
|
|
91
|
+
event
|
|
92
|
+
});
|
|
93
|
+
} catch {}
|
|
94
|
+
return new DidCommOutboundMessageContext(new StatusMessage({
|
|
95
|
+
thid,
|
|
96
|
+
body: await this.service.status(messageContext.agentContext, { instance_id: instId }, inst)
|
|
97
|
+
}), {
|
|
98
|
+
agentContext: messageContext.agentContext,
|
|
99
|
+
inboundMessageContext: messageContext,
|
|
100
|
+
connection: messageContext.connection
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
logger.warn("[Workflow] Queue not available, processing synchronously");
|
|
105
|
+
const updated = await this.service.advance(messageContext.agentContext, messageContext.message.body, inst);
|
|
106
|
+
return new DidCommOutboundMessageContext(new StatusMessage({
|
|
107
|
+
thid,
|
|
108
|
+
body: await this.service.status(messageContext.agentContext, { instance_id: instId }, updated)
|
|
109
|
+
}), {
|
|
110
|
+
agentContext: messageContext.agentContext,
|
|
111
|
+
inboundMessageContext: messageContext,
|
|
112
|
+
connection: messageContext.connection
|
|
113
|
+
});
|
|
114
|
+
} catch (e) {
|
|
115
|
+
if (config.enableProblemReport && messageContext.connection) {
|
|
116
|
+
const code = e.code;
|
|
117
|
+
const normalize = (c) => c === "queue_unavailable" ? "temporary_unavailable" : c || "action_error";
|
|
118
|
+
const body = {
|
|
119
|
+
code: normalize(code),
|
|
120
|
+
comment: e.message
|
|
121
|
+
};
|
|
122
|
+
if (code === "queue_unavailable") body.args = { subcode: "queue_unavailable" };
|
|
123
|
+
const pr = new ProblemReportMessage({
|
|
124
|
+
thid: messageContext.message.threadId || messageContext.message.id,
|
|
125
|
+
body
|
|
126
|
+
});
|
|
127
|
+
try {
|
|
128
|
+
logger.warn("[Workflow] advance failed, sending problem-report", {
|
|
129
|
+
thid,
|
|
130
|
+
code: body.code,
|
|
131
|
+
error: e.message
|
|
132
|
+
});
|
|
133
|
+
} catch {}
|
|
134
|
+
return new DidCommOutboundMessageContext(pr, {
|
|
135
|
+
agentContext: messageContext.agentContext,
|
|
136
|
+
inboundMessageContext: messageContext,
|
|
137
|
+
connection: messageContext.connection
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
throw e;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
AdvanceHandler = __decorate([injectable(), __decorateMetadata("design:paramtypes", [WorkflowService])], AdvanceHandler);
|
|
145
|
+
|
|
146
|
+
//#endregion
|
|
147
|
+
export { AdvanceHandler };
|
|
148
|
+
//# sourceMappingURL=AdvanceHandler.mjs.map
|