@lssm/example.workflow-system 0.0.0-canary-20251217083314 → 1.41.1
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/dist/approval/approval.contracts.js +1 -250
- package/dist/approval/approval.enum.js +1 -29
- package/dist/approval/approval.event.js +1 -186
- package/dist/approval/approval.handler.js +1 -71
- package/dist/approval/approval.schema.js +1 -111
- package/dist/approval/index.js +1 -6
- package/dist/docs/index.js +1 -1
- package/dist/docs/workflow-system.docblock.js +5 -61
- package/dist/entities/approval.js +1 -128
- package/dist/entities/index.js +1 -31
- package/dist/entities/instance.js +1 -168
- package/dist/entities/step.js +1 -135
- package/dist/entities/workflow.js +1 -102
- package/dist/example.js +1 -50
- package/dist/index.js +1 -19
- package/dist/instance/index.js +1 -6
- package/dist/instance/instance.contracts.js +1 -334
- package/dist/instance/instance.enum.js +1 -20
- package/dist/instance/instance.event.js +1 -214
- package/dist/instance/instance.handler.js +1 -93
- package/dist/instance/instance.schema.js +1 -173
- package/dist/presentations/index.js +1 -291
- package/dist/shared/index.js +1 -3
- package/dist/shared/mock-data.js +1 -11
- package/dist/state-machine/index.js +1 -157
- package/dist/workflow/index.js +1 -6
- package/dist/workflow/workflow.contracts.js +1 -239
- package/dist/workflow/workflow.enum.js +1 -47
- package/dist/workflow/workflow.event.js +1 -116
- package/dist/workflow/workflow.handler.js +1 -65
- package/dist/workflow/workflow.schema.js +1 -250
- package/dist/workflow-system.feature.js +1 -337
- package/package.json +44 -44
- package/dist/approval/approval.contracts.d.ts +0 -534
- package/dist/approval/approval.enum.d.ts +0 -13
- package/dist/approval/approval.event.d.ts +0 -130
- package/dist/approval/approval.handler.d.ts +0 -22
- package/dist/approval/approval.schema.d.ts +0 -99
- package/dist/approval/index.d.ts +0 -5
- package/dist/docs/index.d.ts +0 -1
- package/dist/docs/workflow-system.docblock.d.ts +0 -1
- package/dist/entities/approval.d.ts +0 -57
- package/dist/entities/index.d.ts +0 -138
- package/dist/entities/instance.d.ts +0 -68
- package/dist/entities/step.d.ts +0 -49
- package/dist/entities/workflow.d.ts +0 -40
- package/dist/example.d.ts +0 -39
- package/dist/index.d.ts +0 -16
- package/dist/instance/index.d.ts +0 -5
- package/dist/instance/instance.contracts.d.ts +0 -1023
- package/dist/instance/instance.enum.d.ts +0 -9
- package/dist/instance/instance.event.d.ts +0 -355
- package/dist/instance/instance.handler.d.ts +0 -26
- package/dist/instance/instance.schema.d.ts +0 -222
- package/dist/libs/contracts/dist/capabilities/openbanking.js +0 -88
- package/dist/libs/contracts/dist/client/index.js +0 -5
- package/dist/libs/contracts/dist/client/react/feature-render.js +0 -2
- package/dist/libs/contracts/dist/client/react/form-render.js +0 -4
- package/dist/libs/contracts/dist/client/react/index.js +0 -4
- package/dist/libs/contracts/dist/contract-registry/index.js +0 -1
- package/dist/libs/contracts/dist/contract-registry/schemas.js +0 -60
- package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/index.js +0 -29
- package/dist/libs/contracts/dist/docs/presentations.js +0 -71
- package/dist/libs/contracts/dist/docs/registry.js +0 -44
- package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +0 -80
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +0 -57
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +0 -357
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +0 -37
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +0 -20
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +0 -48
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +0 -79
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +0 -84
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +0 -45
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +0 -67
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +0 -40
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +0 -69
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +0 -47
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +0 -62
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +0 -155
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +0 -20
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +0 -101
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +0 -20
- package/dist/libs/contracts/dist/events.js +0 -10
- package/dist/libs/contracts/dist/experiments/evaluator.js +0 -1
- package/dist/libs/contracts/dist/index.js +0 -71
- package/dist/libs/contracts/dist/install.js +0 -2
- package/dist/libs/contracts/dist/integrations/contracts.js +0 -377
- package/dist/libs/contracts/dist/integrations/index.js +0 -18
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +0 -228
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +0 -159
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +0 -3
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +0 -210
- package/dist/libs/contracts/dist/integrations/openbanking/models.js +0 -242
- package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +0 -13
- package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +0 -52
- package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +0 -75
- package/dist/libs/contracts/dist/integrations/providers/gmail.js +0 -87
- package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +0 -66
- package/dist/libs/contracts/dist/integrations/providers/index.js +0 -11
- package/dist/libs/contracts/dist/integrations/providers/mistral.js +0 -68
- package/dist/libs/contracts/dist/integrations/providers/postmark.js +0 -68
- package/dist/libs/contracts/dist/integrations/providers/powens.js +0 -116
- package/dist/libs/contracts/dist/integrations/providers/qdrant.js +0 -73
- package/dist/libs/contracts/dist/integrations/providers/registry.js +0 -10
- package/dist/libs/contracts/dist/integrations/providers/stripe.js +0 -83
- package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +0 -61
- package/dist/libs/contracts/dist/jsonschema.js +0 -1
- package/dist/libs/contracts/dist/knowledge/contracts.js +0 -306
- package/dist/libs/contracts/dist/knowledge/index.js +0 -7
- package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +0 -34
- package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +0 -34
- package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +0 -38
- package/dist/libs/contracts/dist/knowledge/spaces/index.js +0 -6
- package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +0 -34
- package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +0 -37
- package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +0 -34
- package/dist/libs/contracts/dist/llm/exporters.js +0 -19
- package/dist/libs/contracts/dist/llm/index.js +0 -2
- package/dist/libs/contracts/dist/llm/prompts.js +0 -1
- package/dist/libs/contracts/dist/onboarding-base.js +0 -196
- package/dist/libs/contracts/dist/openapi.js +0 -1
- package/dist/libs/contracts/dist/ownership.js +0 -21
- package/dist/libs/contracts/dist/presentations.js +0 -1
- package/dist/libs/contracts/dist/presentations.v2.js +0 -11
- package/dist/libs/contracts/dist/prompt.js +0 -1
- package/dist/libs/contracts/dist/promptRegistry.js +0 -1
- package/dist/libs/contracts/dist/regenerator/index.js +0 -1
- package/dist/libs/contracts/dist/regenerator/service.js +0 -6
- package/dist/libs/contracts/dist/registry.js +0 -2
- package/dist/libs/contracts/dist/resources.js +0 -1
- package/dist/libs/contracts/dist/schema/dist/EnumType.js +0 -2
- package/dist/libs/contracts/dist/schema/dist/FieldType.js +0 -49
- package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +0 -236
- package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +0 -39
- package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +0 -1
- package/dist/libs/contracts/dist/schema/dist/entity/index.js +0 -2
- package/dist/libs/contracts/dist/schema/dist/entity/types.js +0 -1
- package/dist/libs/contracts/dist/schema/dist/index.js +0 -6
- package/dist/libs/contracts/dist/server/graphql-pothos.js +0 -6
- package/dist/libs/contracts/dist/server/index.js +0 -8
- package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +0 -4
- package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +0 -2
- package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +0 -1
- package/dist/libs/contracts/dist/server/mcp/registerResources.js +0 -2
- package/dist/libs/contracts/dist/server/mcp/registerTools.js +0 -1
- package/dist/libs/contracts/dist/server/provider-mcp.js +0 -1
- package/dist/libs/contracts/dist/server/rest-elysia.js +0 -1
- package/dist/libs/contracts/dist/server/rest-express.js +0 -1
- package/dist/libs/contracts/dist/server/rest-generic.js +0 -1
- package/dist/libs/contracts/dist/server/rest-next-app.js +0 -1
- package/dist/libs/contracts/dist/server/rest-next-pages.js +0 -1
- package/dist/libs/contracts/dist/spec.js +0 -34
- package/dist/libs/contracts/dist/telemetry/index.js +0 -1
- package/dist/libs/contracts/dist/telemetry/tracker.js +0 -1
- package/dist/libs/contracts/dist/tests/index.js +0 -1
- package/dist/libs/contracts/dist/tests/runner.js +0 -2
- package/dist/libs/contracts/dist/workflow/index.js +0 -1
- package/dist/libs/contracts/dist/workflow/runner.js +0 -1
- package/dist/libs/schema/dist/EnumType.js +0 -56
- package/dist/libs/schema/dist/FieldType.js +0 -49
- package/dist/libs/schema/dist/ScalarTypeEnum.js +0 -236
- package/dist/libs/schema/dist/SchemaModel.js +0 -39
- package/dist/libs/schema/dist/entity/defineEntity.js +0 -236
- package/dist/libs/schema/dist/entity/index.js +0 -2
- package/dist/libs/schema/dist/entity/types.js +0 -1
- package/dist/libs/schema/dist/index.js +0 -6
- package/dist/presentations/index.d.ts +0 -63
- package/dist/shared/index.d.ts +0 -3
- package/dist/shared/mock-data.d.ts +0 -18
- package/dist/shared/types.d.ts +0 -80
- package/dist/state-machine/index.d.ts +0 -147
- package/dist/workflow/index.d.ts +0 -5
- package/dist/workflow/workflow.contracts.d.ts +0 -1010
- package/dist/workflow/workflow.enum.d.ts +0 -21
- package/dist/workflow/workflow.event.d.ts +0 -134
- package/dist/workflow/workflow.handler.d.ts +0 -28
- package/dist/workflow/workflow.schema.d.ts +0 -264
- package/dist/workflow-system.feature.d.ts +0 -11
|
@@ -1,214 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "../libs/schema/dist/index.js";
|
|
3
|
-
import { defineSchemaModel } from "../libs/contracts/dist/schema/dist/SchemaModel.js";
|
|
4
|
-
import { defineEvent } from "../libs/contracts/dist/events.js";
|
|
5
|
-
import "../libs/contracts/dist/index.js";
|
|
6
|
-
|
|
7
|
-
//#region src/instance/instance.event.ts
|
|
8
|
-
/**
|
|
9
|
-
* Base payload for instance events.
|
|
10
|
-
*/
|
|
11
|
-
const InstanceEventPayload = defineSchemaModel({
|
|
12
|
-
name: "InstanceEventPayload",
|
|
13
|
-
description: "Base payload for instance events",
|
|
14
|
-
fields: {
|
|
15
|
-
instanceId: {
|
|
16
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
17
|
-
isOptional: false
|
|
18
|
-
},
|
|
19
|
-
workflowId: {
|
|
20
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
21
|
-
isOptional: false
|
|
22
|
-
},
|
|
23
|
-
workflowKey: {
|
|
24
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
25
|
-
isOptional: false
|
|
26
|
-
},
|
|
27
|
-
status: {
|
|
28
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
29
|
-
isOptional: false
|
|
30
|
-
},
|
|
31
|
-
referenceId: {
|
|
32
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
33
|
-
isOptional: true
|
|
34
|
-
},
|
|
35
|
-
referenceType: {
|
|
36
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
37
|
-
isOptional: true
|
|
38
|
-
},
|
|
39
|
-
triggeredBy: {
|
|
40
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
41
|
-
isOptional: false
|
|
42
|
-
},
|
|
43
|
-
organizationId: {
|
|
44
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
45
|
-
isOptional: false
|
|
46
|
-
},
|
|
47
|
-
timestamp: {
|
|
48
|
-
type: ScalarTypeEnum.DateTime(),
|
|
49
|
-
isOptional: false
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
/**
|
|
54
|
-
* Payload for step transition events.
|
|
55
|
-
*/
|
|
56
|
-
const StepTransitionPayload = defineSchemaModel({
|
|
57
|
-
name: "StepTransitionEventPayload",
|
|
58
|
-
description: "Payload for step transition events",
|
|
59
|
-
fields: {
|
|
60
|
-
instanceId: {
|
|
61
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
62
|
-
isOptional: false
|
|
63
|
-
},
|
|
64
|
-
workflowId: {
|
|
65
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
66
|
-
isOptional: false
|
|
67
|
-
},
|
|
68
|
-
fromStepKey: {
|
|
69
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
70
|
-
isOptional: true
|
|
71
|
-
},
|
|
72
|
-
toStepKey: {
|
|
73
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
74
|
-
isOptional: false
|
|
75
|
-
},
|
|
76
|
-
action: {
|
|
77
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
78
|
-
isOptional: true
|
|
79
|
-
},
|
|
80
|
-
executedBy: {
|
|
81
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
82
|
-
isOptional: false
|
|
83
|
-
},
|
|
84
|
-
timestamp: {
|
|
85
|
-
type: ScalarTypeEnum.DateTime(),
|
|
86
|
-
isOptional: false
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
/**
|
|
91
|
-
* Payload when instance completes.
|
|
92
|
-
*/
|
|
93
|
-
const InstanceCompletedPayload = defineSchemaModel({
|
|
94
|
-
name: "InstanceCompletedEventPayload",
|
|
95
|
-
description: "Payload when instance completes",
|
|
96
|
-
fields: {
|
|
97
|
-
instanceId: {
|
|
98
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
99
|
-
isOptional: false
|
|
100
|
-
},
|
|
101
|
-
workflowId: {
|
|
102
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
103
|
-
isOptional: false
|
|
104
|
-
},
|
|
105
|
-
workflowKey: {
|
|
106
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
107
|
-
isOptional: false
|
|
108
|
-
},
|
|
109
|
-
outcome: {
|
|
110
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
111
|
-
isOptional: false
|
|
112
|
-
},
|
|
113
|
-
referenceId: {
|
|
114
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
115
|
-
isOptional: true
|
|
116
|
-
},
|
|
117
|
-
referenceType: {
|
|
118
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
119
|
-
isOptional: true
|
|
120
|
-
},
|
|
121
|
-
duration: {
|
|
122
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
123
|
-
isOptional: false
|
|
124
|
-
},
|
|
125
|
-
timestamp: {
|
|
126
|
-
type: ScalarTypeEnum.DateTime(),
|
|
127
|
-
isOptional: false
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
/**
|
|
132
|
-
* InstanceStartedEvent - A new workflow instance has been started.
|
|
133
|
-
*/
|
|
134
|
-
const InstanceStartedEvent = defineEvent({
|
|
135
|
-
name: "workflow.instance.started",
|
|
136
|
-
version: 1,
|
|
137
|
-
description: "A new workflow instance has been started.",
|
|
138
|
-
payload: InstanceEventPayload
|
|
139
|
-
});
|
|
140
|
-
/**
|
|
141
|
-
* StepEnteredEvent - A workflow instance has entered a new step.
|
|
142
|
-
*/
|
|
143
|
-
const StepEnteredEvent = defineEvent({
|
|
144
|
-
name: "workflow.step.entered",
|
|
145
|
-
version: 1,
|
|
146
|
-
description: "A workflow instance has entered a new step.",
|
|
147
|
-
payload: StepTransitionPayload
|
|
148
|
-
});
|
|
149
|
-
/**
|
|
150
|
-
* StepExitedEvent - A workflow instance has exited a step.
|
|
151
|
-
*/
|
|
152
|
-
const StepExitedEvent = defineEvent({
|
|
153
|
-
name: "workflow.step.exited",
|
|
154
|
-
version: 1,
|
|
155
|
-
description: "A workflow instance has exited a step.",
|
|
156
|
-
payload: StepTransitionPayload
|
|
157
|
-
});
|
|
158
|
-
/**
|
|
159
|
-
* InstanceCompletedEvent - A workflow instance has completed.
|
|
160
|
-
*/
|
|
161
|
-
const InstanceCompletedEvent = defineEvent({
|
|
162
|
-
name: "workflow.instance.completed",
|
|
163
|
-
version: 1,
|
|
164
|
-
description: "A workflow instance has completed.",
|
|
165
|
-
payload: InstanceCompletedPayload
|
|
166
|
-
});
|
|
167
|
-
/**
|
|
168
|
-
* InstanceCancelledEvent - A workflow instance has been cancelled.
|
|
169
|
-
*/
|
|
170
|
-
const InstanceCancelledEvent = defineEvent({
|
|
171
|
-
name: "workflow.instance.cancelled",
|
|
172
|
-
version: 1,
|
|
173
|
-
description: "A workflow instance has been cancelled.",
|
|
174
|
-
payload: InstanceEventPayload
|
|
175
|
-
});
|
|
176
|
-
/**
|
|
177
|
-
* InstancePausedEvent - A workflow instance has been paused.
|
|
178
|
-
*/
|
|
179
|
-
const InstancePausedEvent = defineEvent({
|
|
180
|
-
name: "workflow.instance.paused",
|
|
181
|
-
version: 1,
|
|
182
|
-
description: "A workflow instance has been paused.",
|
|
183
|
-
payload: InstanceEventPayload
|
|
184
|
-
});
|
|
185
|
-
/**
|
|
186
|
-
* InstanceResumedEvent - A workflow instance has been resumed.
|
|
187
|
-
*/
|
|
188
|
-
const InstanceResumedEvent = defineEvent({
|
|
189
|
-
name: "workflow.instance.resumed",
|
|
190
|
-
version: 1,
|
|
191
|
-
description: "A workflow instance has been resumed.",
|
|
192
|
-
payload: InstanceEventPayload
|
|
193
|
-
});
|
|
194
|
-
/**
|
|
195
|
-
* InstanceFailedEvent - A workflow instance has failed.
|
|
196
|
-
*/
|
|
197
|
-
const InstanceFailedEvent = defineEvent({
|
|
198
|
-
name: "workflow.instance.failed",
|
|
199
|
-
version: 1,
|
|
200
|
-
description: "A workflow instance has failed.",
|
|
201
|
-
payload: InstanceEventPayload
|
|
202
|
-
});
|
|
203
|
-
/**
|
|
204
|
-
* InstanceTimedOutEvent - A workflow instance has timed out.
|
|
205
|
-
*/
|
|
206
|
-
const InstanceTimedOutEvent = defineEvent({
|
|
207
|
-
name: "workflow.instance.timeout",
|
|
208
|
-
version: 1,
|
|
209
|
-
description: "A workflow instance has timed out.",
|
|
210
|
-
payload: InstanceEventPayload
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
//#endregion
|
|
214
|
-
export { InstanceCancelledEvent, InstanceCompletedEvent, InstanceFailedEvent, InstancePausedEvent, InstanceResumedEvent, InstanceStartedEvent, InstanceTimedOutEvent, StepEnteredEvent, StepExitedEvent };
|
|
1
|
+
import{ScalarTypeEnum as e}from"@lssm/lib.schema";import{defineEvent as t,defineSchemaModel as n}from"@lssm/lib.contracts";const r=n({name:`InstanceEventPayload`,description:`Base payload for instance events`,fields:{instanceId:{type:e.String_unsecure(),isOptional:!1},workflowId:{type:e.String_unsecure(),isOptional:!1},workflowKey:{type:e.String_unsecure(),isOptional:!1},status:{type:e.String_unsecure(),isOptional:!1},referenceId:{type:e.String_unsecure(),isOptional:!0},referenceType:{type:e.String_unsecure(),isOptional:!0},triggeredBy:{type:e.String_unsecure(),isOptional:!1},organizationId:{type:e.String_unsecure(),isOptional:!1},timestamp:{type:e.DateTime(),isOptional:!1}}}),i=n({name:`StepTransitionEventPayload`,description:`Payload for step transition events`,fields:{instanceId:{type:e.String_unsecure(),isOptional:!1},workflowId:{type:e.String_unsecure(),isOptional:!1},fromStepKey:{type:e.String_unsecure(),isOptional:!0},toStepKey:{type:e.String_unsecure(),isOptional:!1},action:{type:e.String_unsecure(),isOptional:!0},executedBy:{type:e.String_unsecure(),isOptional:!1},timestamp:{type:e.DateTime(),isOptional:!1}}}),a=n({name:`InstanceCompletedEventPayload`,description:`Payload when instance completes`,fields:{instanceId:{type:e.String_unsecure(),isOptional:!1},workflowId:{type:e.String_unsecure(),isOptional:!1},workflowKey:{type:e.String_unsecure(),isOptional:!1},outcome:{type:e.String_unsecure(),isOptional:!1},referenceId:{type:e.String_unsecure(),isOptional:!0},referenceType:{type:e.String_unsecure(),isOptional:!0},duration:{type:e.Int_unsecure(),isOptional:!1},timestamp:{type:e.DateTime(),isOptional:!1}}}),o=t({name:`workflow.instance.started`,version:1,description:`A new workflow instance has been started.`,payload:r}),s=t({name:`workflow.step.entered`,version:1,description:`A workflow instance has entered a new step.`,payload:i}),c=t({name:`workflow.step.exited`,version:1,description:`A workflow instance has exited a step.`,payload:i}),l=t({name:`workflow.instance.completed`,version:1,description:`A workflow instance has completed.`,payload:a}),u=t({name:`workflow.instance.cancelled`,version:1,description:`A workflow instance has been cancelled.`,payload:r}),d=t({name:`workflow.instance.paused`,version:1,description:`A workflow instance has been paused.`,payload:r}),f=t({name:`workflow.instance.resumed`,version:1,description:`A workflow instance has been resumed.`,payload:r}),p=t({name:`workflow.instance.failed`,version:1,description:`A workflow instance has failed.`,payload:r}),m=t({name:`workflow.instance.timeout`,version:1,description:`A workflow instance has timed out.`,payload:r});export{u as InstanceCancelledEvent,l as InstanceCompletedEvent,p as InstanceFailedEvent,d as InstancePausedEvent,f as InstanceResumedEvent,o as InstanceStartedEvent,m as InstanceTimedOutEvent,s as StepEnteredEvent,c as StepExitedEvent};
|
|
@@ -1,93 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { buildStateMachineDefinition, createStateMachineEngine } from "../state-machine/index.js";
|
|
3
|
-
import { createApprovalRequests } from "../approval/approval.handler.js";
|
|
4
|
-
|
|
5
|
-
//#region src/instance/instance.handler.ts
|
|
6
|
-
async function handleStartWorkflow(input, context) {
|
|
7
|
-
const workflow = Array.from(mockDataStore.workflows.values()).find((w) => w.key === input.workflowKey && w.status === "ACTIVE" && w.organizationId === context.organizationId);
|
|
8
|
-
if (!workflow) throw new Error(`Active workflow ${input.workflowKey} not found`);
|
|
9
|
-
const id = `inst_${Date.now()}`;
|
|
10
|
-
const now = /* @__PURE__ */ new Date();
|
|
11
|
-
const instance = {
|
|
12
|
-
id,
|
|
13
|
-
workflowDefinitionId: workflow.id,
|
|
14
|
-
referenceId: input.referenceId,
|
|
15
|
-
referenceType: input.referenceType,
|
|
16
|
-
status: "RUNNING",
|
|
17
|
-
currentStepId: workflow.initialStepId,
|
|
18
|
-
contextData: input.contextData ?? {},
|
|
19
|
-
triggeredBy: context.userId,
|
|
20
|
-
organizationId: context.organizationId,
|
|
21
|
-
priority: input.priority ?? 0,
|
|
22
|
-
dueAt: input.dueAt,
|
|
23
|
-
createdAt: now,
|
|
24
|
-
updatedAt: now,
|
|
25
|
-
startedAt: now
|
|
26
|
-
};
|
|
27
|
-
mockDataStore.instances.set(id, instance);
|
|
28
|
-
if (workflow.initialStepId) {
|
|
29
|
-
const firstStep = mockDataStore.steps.get(workflow.initialStepId);
|
|
30
|
-
if (firstStep?.type === "APPROVAL") {
|
|
31
|
-
instance.status = "WAITING";
|
|
32
|
-
await createApprovalRequests(instance, firstStep, context);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return instance;
|
|
36
|
-
}
|
|
37
|
-
async function handleTransitionWorkflow(input, context) {
|
|
38
|
-
const instance = mockDataStore.instances.get(input.instanceId);
|
|
39
|
-
if (!instance) throw new Error(`Instance ${input.instanceId} not found`);
|
|
40
|
-
const workflow = mockDataStore.workflows.get(instance.workflowDefinitionId);
|
|
41
|
-
if (!workflow) throw new Error(`Workflow ${instance.workflowDefinitionId} not found`);
|
|
42
|
-
const steps = Array.from(mockDataStore.steps.values()).filter((s) => s.workflowDefinitionId === workflow.id);
|
|
43
|
-
const definition = buildStateMachineDefinition({
|
|
44
|
-
key: workflow.key,
|
|
45
|
-
name: workflow.name,
|
|
46
|
-
version: workflow.version,
|
|
47
|
-
initialStepId: workflow.initialStepId ?? null
|
|
48
|
-
}, steps);
|
|
49
|
-
const currentStep = steps.find((s) => s.id === instance.currentStepId);
|
|
50
|
-
const state = {
|
|
51
|
-
currentStepKey: currentStep?.key ?? "",
|
|
52
|
-
status: instance.status,
|
|
53
|
-
contextData: instance.contextData,
|
|
54
|
-
history: []
|
|
55
|
-
};
|
|
56
|
-
const transitionContext = {
|
|
57
|
-
userId: context.userId,
|
|
58
|
-
userRoles: context.userRoles,
|
|
59
|
-
data: input.data
|
|
60
|
-
};
|
|
61
|
-
const result = createStateMachineEngine().transition(definition, state, input.action, transitionContext);
|
|
62
|
-
if (!result.success) return {
|
|
63
|
-
success: false,
|
|
64
|
-
instance,
|
|
65
|
-
message: result.error
|
|
66
|
-
};
|
|
67
|
-
const previousStepKey = currentStep?.key;
|
|
68
|
-
const newStep = steps.find((s) => s.key === result.currentStepKey);
|
|
69
|
-
instance.currentStepId = newStep?.id;
|
|
70
|
-
instance.status = result.status;
|
|
71
|
-
instance.contextData = {
|
|
72
|
-
...instance.contextData,
|
|
73
|
-
...input.data
|
|
74
|
-
};
|
|
75
|
-
instance.updatedAt = /* @__PURE__ */ new Date();
|
|
76
|
-
if (result.status === "COMPLETED") {
|
|
77
|
-
instance.completedAt = /* @__PURE__ */ new Date();
|
|
78
|
-
instance.outcome = input.action;
|
|
79
|
-
}
|
|
80
|
-
if (newStep?.type === "APPROVAL") {
|
|
81
|
-
instance.status = "WAITING";
|
|
82
|
-
await createApprovalRequests(instance, newStep, context);
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
success: true,
|
|
86
|
-
instance,
|
|
87
|
-
previousStepKey,
|
|
88
|
-
currentStepKey: result.currentStepKey ?? void 0
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
//#endregion
|
|
93
|
-
export { handleStartWorkflow, handleTransitionWorkflow };
|
|
1
|
+
import{mockDataStore as e}from"../shared/mock-data.js";import{buildStateMachineDefinition as t,createStateMachineEngine as n}from"../state-machine/index.js";import{createApprovalRequests as r}from"../approval/approval.handler.js";async function i(t,n){let i=Array.from(e.workflows.values()).find(e=>e.key===t.workflowKey&&e.status===`ACTIVE`&&e.organizationId===n.organizationId);if(!i)throw Error(`Active workflow ${t.workflowKey} not found`);let a=`inst_${Date.now()}`,o=new Date,s={id:a,workflowDefinitionId:i.id,referenceId:t.referenceId,referenceType:t.referenceType,status:`RUNNING`,currentStepId:i.initialStepId,contextData:t.contextData??{},triggeredBy:n.userId,organizationId:n.organizationId,priority:t.priority??0,dueAt:t.dueAt,createdAt:o,updatedAt:o,startedAt:o};if(e.instances.set(a,s),i.initialStepId){let t=e.steps.get(i.initialStepId);t?.type===`APPROVAL`&&(s.status=`WAITING`,await r(s,t,n))}return s}async function a(i,a){let o=e.instances.get(i.instanceId);if(!o)throw Error(`Instance ${i.instanceId} not found`);let s=e.workflows.get(o.workflowDefinitionId);if(!s)throw Error(`Workflow ${o.workflowDefinitionId} not found`);let c=Array.from(e.steps.values()).filter(e=>e.workflowDefinitionId===s.id),l=t({key:s.key,name:s.name,version:s.version,initialStepId:s.initialStepId??null},c),u=c.find(e=>e.id===o.currentStepId),d={currentStepKey:u?.key??``,status:o.status,contextData:o.contextData,history:[]},f={userId:a.userId,userRoles:a.userRoles,data:i.data},p=n().transition(l,d,i.action,f);if(!p.success)return{success:!1,instance:o,message:p.error};let m=u?.key,h=c.find(e=>e.key===p.currentStepKey);return o.currentStepId=h?.id,o.status=p.status,o.contextData={...o.contextData,...i.data},o.updatedAt=new Date,p.status===`COMPLETED`&&(o.completedAt=new Date,o.outcome=i.action),h?.type===`APPROVAL`&&(o.status=`WAITING`,await r(o,h,a)),{success:!0,instance:o,previousStepKey:m,currentStepKey:p.currentStepKey??void 0}}export{i as handleStartWorkflow,a as handleTransitionWorkflow};
|
|
@@ -1,173 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { defineSchemaModel } from "../libs/schema/dist/SchemaModel.js";
|
|
3
|
-
import "../libs/schema/dist/index.js";
|
|
4
|
-
import { InstanceStatusEnum } from "./instance.enum.js";
|
|
5
|
-
|
|
6
|
-
//#region src/instance/instance.schema.ts
|
|
7
|
-
/**
|
|
8
|
-
* A running workflow instance.
|
|
9
|
-
*/
|
|
10
|
-
const WorkflowInstanceModel = defineSchemaModel({
|
|
11
|
-
name: "WorkflowInstanceModel",
|
|
12
|
-
description: "A running workflow instance",
|
|
13
|
-
fields: {
|
|
14
|
-
id: {
|
|
15
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
16
|
-
isOptional: false
|
|
17
|
-
},
|
|
18
|
-
workflowDefinitionId: {
|
|
19
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
20
|
-
isOptional: false
|
|
21
|
-
},
|
|
22
|
-
referenceId: {
|
|
23
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
24
|
-
isOptional: true
|
|
25
|
-
},
|
|
26
|
-
referenceType: {
|
|
27
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
28
|
-
isOptional: true
|
|
29
|
-
},
|
|
30
|
-
status: {
|
|
31
|
-
type: InstanceStatusEnum,
|
|
32
|
-
isOptional: false
|
|
33
|
-
},
|
|
34
|
-
currentStepId: {
|
|
35
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
36
|
-
isOptional: true
|
|
37
|
-
},
|
|
38
|
-
contextData: {
|
|
39
|
-
type: ScalarTypeEnum.JSON(),
|
|
40
|
-
isOptional: true
|
|
41
|
-
},
|
|
42
|
-
triggeredBy: {
|
|
43
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
44
|
-
isOptional: false
|
|
45
|
-
},
|
|
46
|
-
organizationId: {
|
|
47
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
48
|
-
isOptional: false
|
|
49
|
-
},
|
|
50
|
-
priority: {
|
|
51
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
52
|
-
isOptional: false
|
|
53
|
-
},
|
|
54
|
-
dueAt: {
|
|
55
|
-
type: ScalarTypeEnum.DateTime(),
|
|
56
|
-
isOptional: true
|
|
57
|
-
},
|
|
58
|
-
outcome: {
|
|
59
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
60
|
-
isOptional: true
|
|
61
|
-
},
|
|
62
|
-
resultData: {
|
|
63
|
-
type: ScalarTypeEnum.JSON(),
|
|
64
|
-
isOptional: true
|
|
65
|
-
},
|
|
66
|
-
errorMessage: {
|
|
67
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
68
|
-
isOptional: true
|
|
69
|
-
},
|
|
70
|
-
createdAt: {
|
|
71
|
-
type: ScalarTypeEnum.DateTime(),
|
|
72
|
-
isOptional: false
|
|
73
|
-
},
|
|
74
|
-
startedAt: {
|
|
75
|
-
type: ScalarTypeEnum.DateTime(),
|
|
76
|
-
isOptional: true
|
|
77
|
-
},
|
|
78
|
-
completedAt: {
|
|
79
|
-
type: ScalarTypeEnum.DateTime(),
|
|
80
|
-
isOptional: true
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
/**
|
|
85
|
-
* Input for starting a workflow.
|
|
86
|
-
*/
|
|
87
|
-
const StartWorkflowInputModel = defineSchemaModel({
|
|
88
|
-
name: "StartWorkflowInput",
|
|
89
|
-
description: "Input for starting a workflow",
|
|
90
|
-
fields: {
|
|
91
|
-
workflowKey: {
|
|
92
|
-
type: ScalarTypeEnum.NonEmptyString(),
|
|
93
|
-
isOptional: false
|
|
94
|
-
},
|
|
95
|
-
contextData: {
|
|
96
|
-
type: ScalarTypeEnum.JSON(),
|
|
97
|
-
isOptional: true
|
|
98
|
-
},
|
|
99
|
-
referenceId: {
|
|
100
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
101
|
-
isOptional: true
|
|
102
|
-
},
|
|
103
|
-
referenceType: {
|
|
104
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
105
|
-
isOptional: true
|
|
106
|
-
},
|
|
107
|
-
priority: {
|
|
108
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
109
|
-
isOptional: true
|
|
110
|
-
},
|
|
111
|
-
dueAt: {
|
|
112
|
-
type: ScalarTypeEnum.DateTime(),
|
|
113
|
-
isOptional: true
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
/**
|
|
118
|
-
* Input for transitioning a workflow.
|
|
119
|
-
*/
|
|
120
|
-
const TransitionInputModel = defineSchemaModel({
|
|
121
|
-
name: "TransitionInput",
|
|
122
|
-
description: "Input for transitioning a workflow",
|
|
123
|
-
fields: {
|
|
124
|
-
instanceId: {
|
|
125
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
126
|
-
isOptional: false
|
|
127
|
-
},
|
|
128
|
-
action: {
|
|
129
|
-
type: ScalarTypeEnum.NonEmptyString(),
|
|
130
|
-
isOptional: false
|
|
131
|
-
},
|
|
132
|
-
data: {
|
|
133
|
-
type: ScalarTypeEnum.JSON(),
|
|
134
|
-
isOptional: true
|
|
135
|
-
},
|
|
136
|
-
comment: {
|
|
137
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
138
|
-
isOptional: true
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
/**
|
|
143
|
-
* Result of a workflow transition.
|
|
144
|
-
*/
|
|
145
|
-
const TransitionResultModel = defineSchemaModel({
|
|
146
|
-
name: "TransitionResult",
|
|
147
|
-
description: "Result of a workflow transition",
|
|
148
|
-
fields: {
|
|
149
|
-
success: {
|
|
150
|
-
type: ScalarTypeEnum.Boolean(),
|
|
151
|
-
isOptional: false
|
|
152
|
-
},
|
|
153
|
-
instance: {
|
|
154
|
-
type: WorkflowInstanceModel,
|
|
155
|
-
isOptional: false
|
|
156
|
-
},
|
|
157
|
-
previousStepKey: {
|
|
158
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
159
|
-
isOptional: true
|
|
160
|
-
},
|
|
161
|
-
currentStepKey: {
|
|
162
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
163
|
-
isOptional: true
|
|
164
|
-
},
|
|
165
|
-
message: {
|
|
166
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
167
|
-
isOptional: true
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
//#endregion
|
|
173
|
-
export { StartWorkflowInputModel, TransitionInputModel, TransitionResultModel, WorkflowInstanceModel };
|
|
1
|
+
import{InstanceStatusEnum as e}from"./instance.enum.js";import{ScalarTypeEnum as t,defineSchemaModel as n}from"@lssm/lib.schema";const r=n({name:`WorkflowInstanceModel`,description:`A running workflow instance`,fields:{id:{type:t.String_unsecure(),isOptional:!1},workflowDefinitionId:{type:t.String_unsecure(),isOptional:!1},referenceId:{type:t.String_unsecure(),isOptional:!0},referenceType:{type:t.String_unsecure(),isOptional:!0},status:{type:e,isOptional:!1},currentStepId:{type:t.String_unsecure(),isOptional:!0},contextData:{type:t.JSON(),isOptional:!0},triggeredBy:{type:t.String_unsecure(),isOptional:!1},organizationId:{type:t.String_unsecure(),isOptional:!1},priority:{type:t.Int_unsecure(),isOptional:!1},dueAt:{type:t.DateTime(),isOptional:!0},outcome:{type:t.String_unsecure(),isOptional:!0},resultData:{type:t.JSON(),isOptional:!0},errorMessage:{type:t.String_unsecure(),isOptional:!0},createdAt:{type:t.DateTime(),isOptional:!1},startedAt:{type:t.DateTime(),isOptional:!0},completedAt:{type:t.DateTime(),isOptional:!0}}}),i=n({name:`StartWorkflowInput`,description:`Input for starting a workflow`,fields:{workflowKey:{type:t.NonEmptyString(),isOptional:!1},contextData:{type:t.JSON(),isOptional:!0},referenceId:{type:t.String_unsecure(),isOptional:!0},referenceType:{type:t.String_unsecure(),isOptional:!0},priority:{type:t.Int_unsecure(),isOptional:!0},dueAt:{type:t.DateTime(),isOptional:!0}}}),a=n({name:`TransitionInput`,description:`Input for transitioning a workflow`,fields:{instanceId:{type:t.String_unsecure(),isOptional:!1},action:{type:t.NonEmptyString(),isOptional:!1},data:{type:t.JSON(),isOptional:!0},comment:{type:t.String_unsecure(),isOptional:!0}}}),o=n({name:`TransitionResult`,description:`Result of a workflow transition`,fields:{success:{type:t.Boolean(),isOptional:!1},instance:{type:r,isOptional:!1},previousStepKey:{type:t.String_unsecure(),isOptional:!0},currentStepKey:{type:t.String_unsecure(),isOptional:!0},message:{type:t.String_unsecure(),isOptional:!0}}});export{i as StartWorkflowInputModel,a as TransitionInputModel,o as TransitionResultModel,r as WorkflowInstanceModel};
|