@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,22 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "../libs/contracts/dist/docs/index.js";
|
|
3
|
-
|
|
4
|
-
//#region src/docs/workflow-system.docblock.ts
|
|
5
|
-
registerDocBlocks([
|
|
6
|
-
{
|
|
7
|
-
id: "docs.examples.workflow-system",
|
|
8
|
-
title: "Workflow / Approval System",
|
|
9
|
-
summary: "Reference app showing state-machine driven approvals with RBAC, audit trail, notifications, and jobs.",
|
|
10
|
-
kind: "reference",
|
|
11
|
-
visibility: "public",
|
|
12
|
-
route: "/docs/examples/workflow-system",
|
|
13
|
-
tags: [
|
|
14
|
-
"workflow",
|
|
15
|
-
"approval",
|
|
16
|
-
"state-machine",
|
|
17
|
-
"rbac"
|
|
18
|
-
],
|
|
19
|
-
body: `## Entities
|
|
1
|
+
import{registerDocBlocks as e}from"@lssm/lib.contracts/docs";e([{id:`docs.examples.workflow-system`,title:`Workflow / Approval System`,summary:`Reference app showing state-machine driven approvals with RBAC, audit trail, notifications, and jobs.`,kind:`reference`,visibility:`public`,route:`/docs/examples/workflow-system`,tags:[`workflow`,`approval`,`state-machine`,`rbac`],body:`## Entities
|
|
20
2
|
|
|
21
3
|
- WorkflowDefinition, WorkflowStep, WorkflowInstance, Approval.
|
|
22
4
|
- State machine expressed in \`src/state-machine\` with allowed transitions and role gates.
|
|
@@ -40,17 +22,7 @@ registerDocBlocks([
|
|
|
40
22
|
|
|
41
23
|
- Keep transitions declarative to enable safe regeneration; role guards live in spec.
|
|
42
24
|
- Use Notification Center for approval requests and outcomes; attach files via Files module if needed.
|
|
43
|
-
`
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: "docs.examples.workflow-system.goal",
|
|
47
|
-
title: "Workflow System — Goal",
|
|
48
|
-
summary: "Why the workflow/approval template exists and outcomes it targets.",
|
|
49
|
-
kind: "goal",
|
|
50
|
-
visibility: "public",
|
|
51
|
-
route: "/docs/examples/workflow-system/goal",
|
|
52
|
-
tags: ["workflow", "goal"],
|
|
53
|
-
body: `## Why it matters
|
|
25
|
+
`},{id:`docs.examples.workflow-system.goal`,title:`Workflow System — Goal`,summary:`Why the workflow/approval template exists and outcomes it targets.`,kind:`goal`,visibility:`public`,route:`/docs/examples/workflow-system/goal`,tags:[`workflow`,`goal`],body:`## Why it matters
|
|
54
26
|
- Provides a regenerable, role-gated approval engine using declarative state machines.
|
|
55
27
|
- Keeps workflow rules consistent across UI/API/events with auditability.
|
|
56
28
|
|
|
@@ -60,17 +32,7 @@ registerDocBlocks([
|
|
|
60
32
|
|
|
61
33
|
## Success criteria
|
|
62
34
|
- State changes are declarative and regenerate cleanly.
|
|
63
|
-
- Every transition emits auditable events and respects RBAC guards.`
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
id: "docs.examples.workflow-system.usage",
|
|
67
|
-
title: "Workflow System — Usage",
|
|
68
|
-
summary: "How to configure workflows, transitions, and regenerate safely.",
|
|
69
|
-
kind: "usage",
|
|
70
|
-
visibility: "public",
|
|
71
|
-
route: "/docs/examples/workflow-system/usage",
|
|
72
|
-
tags: ["workflow", "usage"],
|
|
73
|
-
body: `## Setup
|
|
35
|
+
- Every transition emits auditable events and respects RBAC guards.`},{id:`docs.examples.workflow-system.usage`,title:`Workflow System — Usage`,summary:`How to configure workflows, transitions, and regenerate safely.`,kind:`usage`,visibility:`public`,route:`/docs/examples/workflow-system/usage`,tags:[`workflow`,`usage`],body:`## Setup
|
|
74
36
|
1) Define WorkflowDefinition steps and allowed transitions with role gates in spec.
|
|
75
37
|
2) Seed sample workflows/instances (if provided) or create via UI; enable reminders via Jobs.
|
|
76
38
|
|
|
@@ -82,21 +44,7 @@ registerDocBlocks([
|
|
|
82
44
|
## Guardrails
|
|
83
45
|
- Emit events for every transition; log to Audit Trail.
|
|
84
46
|
- Use Notifications for approvals/rejections; schedule reminders for pending steps.
|
|
85
|
-
- Keep transitions declarative; avoid imperative branching in handlers.`
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
id: "docs.examples.workflow-system.constraints",
|
|
89
|
-
title: "Workflow System — Constraints & Safety",
|
|
90
|
-
summary: "Internal guardrails for state machines, RBAC, and regeneration semantics.",
|
|
91
|
-
kind: "reference",
|
|
92
|
-
visibility: "internal",
|
|
93
|
-
route: "/docs/examples/workflow-system/constraints",
|
|
94
|
-
tags: [
|
|
95
|
-
"workflow",
|
|
96
|
-
"constraints",
|
|
97
|
-
"internal"
|
|
98
|
-
],
|
|
99
|
-
body: `## Constraints
|
|
47
|
+
- Keep transitions declarative; avoid imperative branching in handlers.`},{id:`docs.examples.workflow-system.constraints`,title:`Workflow System — Constraints & Safety`,summary:`Internal guardrails for state machines, RBAC, and regeneration semantics.`,kind:`reference`,visibility:`internal`,route:`/docs/examples/workflow-system/constraints`,tags:[`workflow`,`constraints`,`internal`],body:`## Constraints
|
|
100
48
|
- State machine (steps/transitions) must stay declarative in spec; no hidden code paths.
|
|
101
49
|
- Events to emit: instance.started, step.completed/rejected, instance.finished.
|
|
102
50
|
- Regeneration must not change approval logic without explicit spec diff.
|
|
@@ -108,8 +56,4 @@ registerDocBlocks([
|
|
|
108
56
|
## Verification
|
|
109
57
|
- Add fixtures for transition changes and role gates.
|
|
110
58
|
- Validate reminders (Jobs) stay aligned with pending states after regeneration.
|
|
111
|
-
- Use Feature Flags for new transitions/escalation rules; default safe/off.`
|
|
112
|
-
}
|
|
113
|
-
]);
|
|
114
|
-
|
|
115
|
-
//#endregion
|
|
59
|
+
- Use Feature Flags for new transitions/escalation rules; default safe/off.`}]);
|
|
@@ -1,128 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "../libs/schema/dist/index.js";
|
|
3
|
-
|
|
4
|
-
//#region src/entities/approval.ts
|
|
5
|
-
/**
|
|
6
|
-
* Approval status enum.
|
|
7
|
-
*/
|
|
8
|
-
const ApprovalStatusEnum = defineEntityEnum({
|
|
9
|
-
name: "ApprovalStatus",
|
|
10
|
-
values: [
|
|
11
|
-
"PENDING",
|
|
12
|
-
"APPROVED",
|
|
13
|
-
"REJECTED",
|
|
14
|
-
"DELEGATED",
|
|
15
|
-
"ESCALATED",
|
|
16
|
-
"WITHDRAWN",
|
|
17
|
-
"EXPIRED"
|
|
18
|
-
],
|
|
19
|
-
schema: "workflow",
|
|
20
|
-
description: "Status of an approval request."
|
|
21
|
-
});
|
|
22
|
-
/**
|
|
23
|
-
* Approval decision enum.
|
|
24
|
-
*/
|
|
25
|
-
const ApprovalDecisionEnum = defineEntityEnum({
|
|
26
|
-
name: "ApprovalDecision",
|
|
27
|
-
values: [
|
|
28
|
-
"APPROVE",
|
|
29
|
-
"REJECT",
|
|
30
|
-
"REQUEST_CHANGES",
|
|
31
|
-
"DELEGATE",
|
|
32
|
-
"ABSTAIN"
|
|
33
|
-
],
|
|
34
|
-
schema: "workflow",
|
|
35
|
-
description: "Possible approval decisions."
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
* ApprovalRequest entity - a request for approval from a user.
|
|
39
|
-
*
|
|
40
|
-
* Created when a workflow reaches an APPROVAL step. Multiple requests
|
|
41
|
-
* may be created depending on the approval mode.
|
|
42
|
-
*/
|
|
43
|
-
const ApprovalRequestEntity = defineEntity({
|
|
44
|
-
name: "ApprovalRequest",
|
|
45
|
-
description: "A pending approval request for a workflow step.",
|
|
46
|
-
schema: "workflow",
|
|
47
|
-
map: "approval_request",
|
|
48
|
-
fields: {
|
|
49
|
-
id: field.id({ description: "Unique approval request ID" }),
|
|
50
|
-
workflowInstanceId: field.foreignKey(),
|
|
51
|
-
stepExecutionId: field.foreignKey(),
|
|
52
|
-
approverId: field.foreignKey({ description: "User requested to approve" }),
|
|
53
|
-
approverRole: field.string({
|
|
54
|
-
isOptional: true,
|
|
55
|
-
description: "Role of the approver"
|
|
56
|
-
}),
|
|
57
|
-
title: field.string({ description: "Approval request title" }),
|
|
58
|
-
description: field.string({ isOptional: true }),
|
|
59
|
-
status: field.enum("ApprovalStatus", { default: "PENDING" }),
|
|
60
|
-
decision: field.enum("ApprovalDecision", { isOptional: true }),
|
|
61
|
-
decisionComment: field.string({
|
|
62
|
-
isOptional: true,
|
|
63
|
-
description: "Comment explaining decision"
|
|
64
|
-
}),
|
|
65
|
-
decidedAt: field.dateTime({ isOptional: true }),
|
|
66
|
-
delegatedTo: field.string({
|
|
67
|
-
isOptional: true,
|
|
68
|
-
description: "User delegated to"
|
|
69
|
-
}),
|
|
70
|
-
delegationReason: field.string({ isOptional: true }),
|
|
71
|
-
escalationLevel: field.int({
|
|
72
|
-
default: 0,
|
|
73
|
-
description: "Current escalation level"
|
|
74
|
-
}),
|
|
75
|
-
escalatedAt: field.dateTime({ isOptional: true }),
|
|
76
|
-
dueAt: field.dateTime({
|
|
77
|
-
isOptional: true,
|
|
78
|
-
description: "When approval is due"
|
|
79
|
-
}),
|
|
80
|
-
reminderSentAt: field.dateTime({ isOptional: true }),
|
|
81
|
-
contextSnapshot: field.json({
|
|
82
|
-
isOptional: true,
|
|
83
|
-
description: "Snapshot of relevant data for review"
|
|
84
|
-
}),
|
|
85
|
-
sequenceOrder: field.int({
|
|
86
|
-
default: 0,
|
|
87
|
-
description: "Order in approval chain"
|
|
88
|
-
}),
|
|
89
|
-
createdAt: field.createdAt(),
|
|
90
|
-
updatedAt: field.updatedAt(),
|
|
91
|
-
workflowInstance: field.belongsTo("WorkflowInstance", ["workflowInstanceId"], ["id"], { onDelete: "Cascade" }),
|
|
92
|
-
stepExecution: field.belongsTo("StepExecution", ["stepExecutionId"], ["id"])
|
|
93
|
-
},
|
|
94
|
-
indexes: [
|
|
95
|
-
index.on(["approverId", "status"]),
|
|
96
|
-
index.on(["workflowInstanceId", "status"]),
|
|
97
|
-
index.on(["stepExecutionId"]),
|
|
98
|
-
index.on(["status", "dueAt"]),
|
|
99
|
-
index.on(["createdAt"])
|
|
100
|
-
],
|
|
101
|
-
enums: [ApprovalStatusEnum, ApprovalDecisionEnum]
|
|
102
|
-
});
|
|
103
|
-
/**
|
|
104
|
-
* ApprovalComment entity - comments on approval requests.
|
|
105
|
-
*/
|
|
106
|
-
const ApprovalCommentEntity = defineEntity({
|
|
107
|
-
name: "ApprovalComment",
|
|
108
|
-
description: "A comment on an approval request.",
|
|
109
|
-
schema: "workflow",
|
|
110
|
-
map: "approval_comment",
|
|
111
|
-
fields: {
|
|
112
|
-
id: field.id(),
|
|
113
|
-
approvalRequestId: field.foreignKey(),
|
|
114
|
-
authorId: field.foreignKey(),
|
|
115
|
-
content: field.string({ description: "Comment text" }),
|
|
116
|
-
isInternal: field.boolean({
|
|
117
|
-
default: false,
|
|
118
|
-
description: "Internal note vs public comment"
|
|
119
|
-
}),
|
|
120
|
-
createdAt: field.createdAt(),
|
|
121
|
-
updatedAt: field.updatedAt(),
|
|
122
|
-
approvalRequest: field.belongsTo("ApprovalRequest", ["approvalRequestId"], ["id"], { onDelete: "Cascade" })
|
|
123
|
-
},
|
|
124
|
-
indexes: [index.on(["approvalRequestId", "createdAt"])]
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
//#endregion
|
|
128
|
-
export { ApprovalCommentEntity, ApprovalDecisionEnum, ApprovalRequestEntity, ApprovalStatusEnum };
|
|
1
|
+
import{defineEntity as e,defineEntityEnum as t,field as n,index as r}from"@lssm/lib.schema";const i=t({name:`ApprovalStatus`,values:[`PENDING`,`APPROVED`,`REJECTED`,`DELEGATED`,`ESCALATED`,`WITHDRAWN`,`EXPIRED`],schema:`workflow`,description:`Status of an approval request.`}),a=t({name:`ApprovalDecision`,values:[`APPROVE`,`REJECT`,`REQUEST_CHANGES`,`DELEGATE`,`ABSTAIN`],schema:`workflow`,description:`Possible approval decisions.`}),o=e({name:`ApprovalRequest`,description:`A pending approval request for a workflow step.`,schema:`workflow`,map:`approval_request`,fields:{id:n.id({description:`Unique approval request ID`}),workflowInstanceId:n.foreignKey(),stepExecutionId:n.foreignKey(),approverId:n.foreignKey({description:`User requested to approve`}),approverRole:n.string({isOptional:!0,description:`Role of the approver`}),title:n.string({description:`Approval request title`}),description:n.string({isOptional:!0}),status:n.enum(`ApprovalStatus`,{default:`PENDING`}),decision:n.enum(`ApprovalDecision`,{isOptional:!0}),decisionComment:n.string({isOptional:!0,description:`Comment explaining decision`}),decidedAt:n.dateTime({isOptional:!0}),delegatedTo:n.string({isOptional:!0,description:`User delegated to`}),delegationReason:n.string({isOptional:!0}),escalationLevel:n.int({default:0,description:`Current escalation level`}),escalatedAt:n.dateTime({isOptional:!0}),dueAt:n.dateTime({isOptional:!0,description:`When approval is due`}),reminderSentAt:n.dateTime({isOptional:!0}),contextSnapshot:n.json({isOptional:!0,description:`Snapshot of relevant data for review`}),sequenceOrder:n.int({default:0,description:`Order in approval chain`}),createdAt:n.createdAt(),updatedAt:n.updatedAt(),workflowInstance:n.belongsTo(`WorkflowInstance`,[`workflowInstanceId`],[`id`],{onDelete:`Cascade`}),stepExecution:n.belongsTo(`StepExecution`,[`stepExecutionId`],[`id`])},indexes:[r.on([`approverId`,`status`]),r.on([`workflowInstanceId`,`status`]),r.on([`stepExecutionId`]),r.on([`status`,`dueAt`]),r.on([`createdAt`])],enums:[i,a]}),s=e({name:`ApprovalComment`,description:`A comment on an approval request.`,schema:`workflow`,map:`approval_comment`,fields:{id:n.id(),approvalRequestId:n.foreignKey(),authorId:n.foreignKey(),content:n.string({description:`Comment text`}),isInternal:n.boolean({default:!1,description:`Internal note vs public comment`}),createdAt:n.createdAt(),updatedAt:n.updatedAt(),approvalRequest:n.belongsTo(`ApprovalRequest`,[`approvalRequestId`],[`id`],{onDelete:`Cascade`})},indexes:[r.on([`approvalRequestId`,`createdAt`])]});export{s as ApprovalCommentEntity,a as ApprovalDecisionEnum,o as ApprovalRequestEntity,i as ApprovalStatusEnum};
|
package/dist/entities/index.js
CHANGED
|
@@ -1,31 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { WorkflowDefinitionEntity, WorkflowStatusEnum, WorkflowTriggerTypeEnum } from "./workflow.js";
|
|
3
|
-
import { ApprovalModeEnum, StepTypeEnum, WorkflowStepEntity } from "./step.js";
|
|
4
|
-
import { InstanceStatusEnum, StepExecutionEntity, StepExecutionStatusEnum, WorkflowInstanceEntity } from "./instance.js";
|
|
5
|
-
|
|
6
|
-
//#region src/entities/index.ts
|
|
7
|
-
const workflowSystemEntities = [
|
|
8
|
-
WorkflowDefinitionEntity,
|
|
9
|
-
WorkflowStepEntity,
|
|
10
|
-
WorkflowInstanceEntity,
|
|
11
|
-
StepExecutionEntity,
|
|
12
|
-
ApprovalRequestEntity,
|
|
13
|
-
ApprovalCommentEntity
|
|
14
|
-
];
|
|
15
|
-
const workflowSystemSchemaContribution = {
|
|
16
|
-
moduleId: "@lssm/example.workflow-system",
|
|
17
|
-
entities: workflowSystemEntities,
|
|
18
|
-
enums: [
|
|
19
|
-
WorkflowStatusEnum,
|
|
20
|
-
WorkflowTriggerTypeEnum,
|
|
21
|
-
StepTypeEnum,
|
|
22
|
-
ApprovalModeEnum,
|
|
23
|
-
InstanceStatusEnum,
|
|
24
|
-
StepExecutionStatusEnum,
|
|
25
|
-
ApprovalStatusEnum,
|
|
26
|
-
ApprovalDecisionEnum
|
|
27
|
-
]
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
export { ApprovalCommentEntity, ApprovalDecisionEnum, ApprovalModeEnum, ApprovalRequestEntity, ApprovalStatusEnum, InstanceStatusEnum, StepExecutionEntity, StepExecutionStatusEnum, StepTypeEnum, WorkflowDefinitionEntity, WorkflowInstanceEntity, WorkflowStatusEnum, WorkflowStepEntity, WorkflowTriggerTypeEnum, workflowSystemEntities, workflowSystemSchemaContribution };
|
|
1
|
+
import{ApprovalCommentEntity as e,ApprovalDecisionEnum as t,ApprovalRequestEntity as n,ApprovalStatusEnum as r}from"./approval.js";import{WorkflowDefinitionEntity as i,WorkflowStatusEnum as a,WorkflowTriggerTypeEnum as o}from"./workflow.js";import{ApprovalModeEnum as s,StepTypeEnum as c,WorkflowStepEntity as l}from"./step.js";import{InstanceStatusEnum as u,StepExecutionEntity as d,StepExecutionStatusEnum as f,WorkflowInstanceEntity as p}from"./instance.js";const m=[i,l,p,d,n,e],h={moduleId:`@lssm/example.workflow-system`,entities:m,enums:[a,o,c,s,u,f,r,t]};export{e as ApprovalCommentEntity,t as ApprovalDecisionEnum,s as ApprovalModeEnum,n as ApprovalRequestEntity,r as ApprovalStatusEnum,u as InstanceStatusEnum,d as StepExecutionEntity,f as StepExecutionStatusEnum,c as StepTypeEnum,i as WorkflowDefinitionEntity,p as WorkflowInstanceEntity,a as WorkflowStatusEnum,l as WorkflowStepEntity,o as WorkflowTriggerTypeEnum,m as workflowSystemEntities,h as workflowSystemSchemaContribution};
|
|
@@ -1,168 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../libs/schema/dist/index.js";
|
|
3
|
-
|
|
4
|
-
//#region src/entities/instance.ts
|
|
5
|
-
/**
|
|
6
|
-
* Instance status enum - lifecycle of a workflow instance.
|
|
7
|
-
*/
|
|
8
|
-
const InstanceStatusEnum = defineEntityEnum({
|
|
9
|
-
name: "InstanceStatus",
|
|
10
|
-
values: [
|
|
11
|
-
"PENDING",
|
|
12
|
-
"RUNNING",
|
|
13
|
-
"WAITING",
|
|
14
|
-
"PAUSED",
|
|
15
|
-
"COMPLETED",
|
|
16
|
-
"CANCELLED",
|
|
17
|
-
"FAILED",
|
|
18
|
-
"TIMEOUT"
|
|
19
|
-
],
|
|
20
|
-
schema: "workflow",
|
|
21
|
-
description: "Status of a workflow instance."
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* Step execution status enum.
|
|
25
|
-
*/
|
|
26
|
-
const StepExecutionStatusEnum = defineEntityEnum({
|
|
27
|
-
name: "StepExecutionStatus",
|
|
28
|
-
values: [
|
|
29
|
-
"PENDING",
|
|
30
|
-
"ACTIVE",
|
|
31
|
-
"COMPLETED",
|
|
32
|
-
"SKIPPED",
|
|
33
|
-
"FAILED",
|
|
34
|
-
"TIMEOUT"
|
|
35
|
-
],
|
|
36
|
-
schema: "workflow",
|
|
37
|
-
description: "Status of a step execution."
|
|
38
|
-
});
|
|
39
|
-
/**
|
|
40
|
-
* WorkflowInstance entity - a running instance of a workflow.
|
|
41
|
-
*
|
|
42
|
-
* When a workflow is triggered, an instance is created. The instance
|
|
43
|
-
* tracks the current state and all data associated with this execution.
|
|
44
|
-
*/
|
|
45
|
-
const WorkflowInstanceEntity = defineEntity({
|
|
46
|
-
name: "WorkflowInstance",
|
|
47
|
-
description: "A running instance of a workflow definition.",
|
|
48
|
-
schema: "workflow",
|
|
49
|
-
map: "workflow_instance",
|
|
50
|
-
fields: {
|
|
51
|
-
id: field.id({ description: "Unique instance ID" }),
|
|
52
|
-
workflowDefinitionId: field.foreignKey(),
|
|
53
|
-
referenceId: field.string({
|
|
54
|
-
isOptional: true,
|
|
55
|
-
description: "External reference (e.g., order ID)"
|
|
56
|
-
}),
|
|
57
|
-
referenceType: field.string({
|
|
58
|
-
isOptional: true,
|
|
59
|
-
description: "Type of reference (e.g., \"Order\")"
|
|
60
|
-
}),
|
|
61
|
-
status: field.enum("InstanceStatus", { default: "PENDING" }),
|
|
62
|
-
currentStepId: field.string({
|
|
63
|
-
isOptional: true,
|
|
64
|
-
description: "Current step being executed"
|
|
65
|
-
}),
|
|
66
|
-
contextData: field.json({ description: "Data context for this instance" }),
|
|
67
|
-
triggeredBy: field.foreignKey({ description: "User who triggered the workflow" }),
|
|
68
|
-
triggerSource: field.string({
|
|
69
|
-
isOptional: true,
|
|
70
|
-
description: "Source of trigger (e.g., \"api\", \"ui\")"
|
|
71
|
-
}),
|
|
72
|
-
organizationId: field.foreignKey(),
|
|
73
|
-
priority: field.int({
|
|
74
|
-
default: 0,
|
|
75
|
-
description: "Processing priority (higher = more urgent)"
|
|
76
|
-
}),
|
|
77
|
-
dueAt: field.dateTime({
|
|
78
|
-
isOptional: true,
|
|
79
|
-
description: "When this instance should complete"
|
|
80
|
-
}),
|
|
81
|
-
outcome: field.string({
|
|
82
|
-
isOptional: true,
|
|
83
|
-
description: "Final outcome (e.g., \"approved\", \"rejected\")"
|
|
84
|
-
}),
|
|
85
|
-
resultData: field.json({
|
|
86
|
-
isOptional: true,
|
|
87
|
-
description: "Final result data"
|
|
88
|
-
}),
|
|
89
|
-
errorMessage: field.string({
|
|
90
|
-
isOptional: true,
|
|
91
|
-
description: "Error message if failed"
|
|
92
|
-
}),
|
|
93
|
-
createdAt: field.createdAt(),
|
|
94
|
-
updatedAt: field.updatedAt(),
|
|
95
|
-
startedAt: field.dateTime({ isOptional: true }),
|
|
96
|
-
completedAt: field.dateTime({ isOptional: true }),
|
|
97
|
-
workflowDefinition: field.belongsTo("WorkflowDefinition", ["workflowDefinitionId"], ["id"]),
|
|
98
|
-
currentStep: field.belongsTo("WorkflowStep", ["currentStepId"], ["id"]),
|
|
99
|
-
stepExecutions: field.hasMany("StepExecution"),
|
|
100
|
-
approvalRequests: field.hasMany("ApprovalRequest")
|
|
101
|
-
},
|
|
102
|
-
indexes: [
|
|
103
|
-
index.on(["organizationId", "status"]),
|
|
104
|
-
index.on(["workflowDefinitionId", "status"]),
|
|
105
|
-
index.on(["referenceType", "referenceId"]),
|
|
106
|
-
index.on(["triggeredBy", "status"]),
|
|
107
|
-
index.on(["status", "dueAt"]),
|
|
108
|
-
index.on(["createdAt"])
|
|
109
|
-
],
|
|
110
|
-
enums: [InstanceStatusEnum]
|
|
111
|
-
});
|
|
112
|
-
/**
|
|
113
|
-
* StepExecution entity - tracks execution of a step within an instance.
|
|
114
|
-
*/
|
|
115
|
-
const StepExecutionEntity = defineEntity({
|
|
116
|
-
name: "StepExecution",
|
|
117
|
-
description: "Execution record of a step within a workflow instance.",
|
|
118
|
-
schema: "workflow",
|
|
119
|
-
map: "step_execution",
|
|
120
|
-
fields: {
|
|
121
|
-
id: field.id({ description: "Unique execution ID" }),
|
|
122
|
-
workflowInstanceId: field.foreignKey(),
|
|
123
|
-
workflowStepId: field.foreignKey(),
|
|
124
|
-
status: field.enum("StepExecutionStatus", { default: "PENDING" }),
|
|
125
|
-
executionOrder: field.int({
|
|
126
|
-
default: 0,
|
|
127
|
-
description: "Order of execution within instance"
|
|
128
|
-
}),
|
|
129
|
-
inputData: field.json({
|
|
130
|
-
isOptional: true,
|
|
131
|
-
description: "Data when entering step"
|
|
132
|
-
}),
|
|
133
|
-
outputData: field.json({
|
|
134
|
-
isOptional: true,
|
|
135
|
-
description: "Data when exiting step"
|
|
136
|
-
}),
|
|
137
|
-
actionTaken: field.string({
|
|
138
|
-
isOptional: true,
|
|
139
|
-
description: "Action that caused transition (e.g., \"approve\")"
|
|
140
|
-
}),
|
|
141
|
-
transitionedTo: field.string({
|
|
142
|
-
isOptional: true,
|
|
143
|
-
description: "Step key transitioned to"
|
|
144
|
-
}),
|
|
145
|
-
executedBy: field.string({
|
|
146
|
-
isOptional: true,
|
|
147
|
-
description: "User who completed this step"
|
|
148
|
-
}),
|
|
149
|
-
errorMessage: field.string({ isOptional: true }),
|
|
150
|
-
errorDetails: field.json({ isOptional: true }),
|
|
151
|
-
retryCount: field.int({ default: 0 }),
|
|
152
|
-
createdAt: field.createdAt(),
|
|
153
|
-
updatedAt: field.updatedAt(),
|
|
154
|
-
startedAt: field.dateTime({ isOptional: true }),
|
|
155
|
-
completedAt: field.dateTime({ isOptional: true }),
|
|
156
|
-
workflowInstance: field.belongsTo("WorkflowInstance", ["workflowInstanceId"], ["id"], { onDelete: "Cascade" }),
|
|
157
|
-
workflowStep: field.belongsTo("WorkflowStep", ["workflowStepId"], ["id"])
|
|
158
|
-
},
|
|
159
|
-
indexes: [
|
|
160
|
-
index.on(["workflowInstanceId", "executionOrder"]),
|
|
161
|
-
index.on(["workflowInstanceId", "workflowStepId"]),
|
|
162
|
-
index.on(["status"])
|
|
163
|
-
],
|
|
164
|
-
enums: [StepExecutionStatusEnum]
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
//#endregion
|
|
168
|
-
export { InstanceStatusEnum, StepExecutionEntity, StepExecutionStatusEnum, WorkflowInstanceEntity };
|
|
1
|
+
import{defineEntity as e,defineEntityEnum as t,field as n,index as r}from"@lssm/lib.schema";const i=t({name:`InstanceStatus`,values:[`PENDING`,`RUNNING`,`WAITING`,`PAUSED`,`COMPLETED`,`CANCELLED`,`FAILED`,`TIMEOUT`],schema:`workflow`,description:`Status of a workflow instance.`}),a=t({name:`StepExecutionStatus`,values:[`PENDING`,`ACTIVE`,`COMPLETED`,`SKIPPED`,`FAILED`,`TIMEOUT`],schema:`workflow`,description:`Status of a step execution.`}),o=e({name:`WorkflowInstance`,description:`A running instance of a workflow definition.`,schema:`workflow`,map:`workflow_instance`,fields:{id:n.id({description:`Unique instance ID`}),workflowDefinitionId:n.foreignKey(),referenceId:n.string({isOptional:!0,description:`External reference (e.g., order ID)`}),referenceType:n.string({isOptional:!0,description:`Type of reference (e.g., "Order")`}),status:n.enum(`InstanceStatus`,{default:`PENDING`}),currentStepId:n.string({isOptional:!0,description:`Current step being executed`}),contextData:n.json({description:`Data context for this instance`}),triggeredBy:n.foreignKey({description:`User who triggered the workflow`}),triggerSource:n.string({isOptional:!0,description:`Source of trigger (e.g., "api", "ui")`}),organizationId:n.foreignKey(),priority:n.int({default:0,description:`Processing priority (higher = more urgent)`}),dueAt:n.dateTime({isOptional:!0,description:`When this instance should complete`}),outcome:n.string({isOptional:!0,description:`Final outcome (e.g., "approved", "rejected")`}),resultData:n.json({isOptional:!0,description:`Final result data`}),errorMessage:n.string({isOptional:!0,description:`Error message if failed`}),createdAt:n.createdAt(),updatedAt:n.updatedAt(),startedAt:n.dateTime({isOptional:!0}),completedAt:n.dateTime({isOptional:!0}),workflowDefinition:n.belongsTo(`WorkflowDefinition`,[`workflowDefinitionId`],[`id`]),currentStep:n.belongsTo(`WorkflowStep`,[`currentStepId`],[`id`]),stepExecutions:n.hasMany(`StepExecution`),approvalRequests:n.hasMany(`ApprovalRequest`)},indexes:[r.on([`organizationId`,`status`]),r.on([`workflowDefinitionId`,`status`]),r.on([`referenceType`,`referenceId`]),r.on([`triggeredBy`,`status`]),r.on([`status`,`dueAt`]),r.on([`createdAt`])],enums:[i]}),s=e({name:`StepExecution`,description:`Execution record of a step within a workflow instance.`,schema:`workflow`,map:`step_execution`,fields:{id:n.id({description:`Unique execution ID`}),workflowInstanceId:n.foreignKey(),workflowStepId:n.foreignKey(),status:n.enum(`StepExecutionStatus`,{default:`PENDING`}),executionOrder:n.int({default:0,description:`Order of execution within instance`}),inputData:n.json({isOptional:!0,description:`Data when entering step`}),outputData:n.json({isOptional:!0,description:`Data when exiting step`}),actionTaken:n.string({isOptional:!0,description:`Action that caused transition (e.g., "approve")`}),transitionedTo:n.string({isOptional:!0,description:`Step key transitioned to`}),executedBy:n.string({isOptional:!0,description:`User who completed this step`}),errorMessage:n.string({isOptional:!0}),errorDetails:n.json({isOptional:!0}),retryCount:n.int({default:0}),createdAt:n.createdAt(),updatedAt:n.updatedAt(),startedAt:n.dateTime({isOptional:!0}),completedAt:n.dateTime({isOptional:!0}),workflowInstance:n.belongsTo(`WorkflowInstance`,[`workflowInstanceId`],[`id`],{onDelete:`Cascade`}),workflowStep:n.belongsTo(`WorkflowStep`,[`workflowStepId`],[`id`])},indexes:[r.on([`workflowInstanceId`,`executionOrder`]),r.on([`workflowInstanceId`,`workflowStepId`]),r.on([`status`])],enums:[a]});export{i as InstanceStatusEnum,s as StepExecutionEntity,a as StepExecutionStatusEnum,o as WorkflowInstanceEntity};
|
package/dist/entities/step.js
CHANGED
|
@@ -1,135 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "../libs/schema/dist/index.js";
|
|
3
|
-
|
|
4
|
-
//#region src/entities/step.ts
|
|
5
|
-
/**
|
|
6
|
-
* Step type enum - what kind of step this is.
|
|
7
|
-
*/
|
|
8
|
-
const StepTypeEnum = defineEntityEnum({
|
|
9
|
-
name: "StepType",
|
|
10
|
-
values: [
|
|
11
|
-
"START",
|
|
12
|
-
"APPROVAL",
|
|
13
|
-
"TASK",
|
|
14
|
-
"CONDITION",
|
|
15
|
-
"PARALLEL",
|
|
16
|
-
"WAIT",
|
|
17
|
-
"ACTION",
|
|
18
|
-
"END"
|
|
19
|
-
],
|
|
20
|
-
schema: "workflow",
|
|
21
|
-
description: "Type of workflow step."
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* Approval mode enum - how approvals are handled.
|
|
25
|
-
*/
|
|
26
|
-
const ApprovalModeEnum = defineEntityEnum({
|
|
27
|
-
name: "ApprovalMode",
|
|
28
|
-
values: [
|
|
29
|
-
"ANY",
|
|
30
|
-
"ALL",
|
|
31
|
-
"MAJORITY",
|
|
32
|
-
"SEQUENTIAL"
|
|
33
|
-
],
|
|
34
|
-
schema: "workflow",
|
|
35
|
-
description: "How multiple approvers are handled."
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
* WorkflowStep entity - defines a step in a workflow.
|
|
39
|
-
*
|
|
40
|
-
* Each step represents a state in the workflow state machine,
|
|
41
|
-
* with transitions defined by the `transitions` JSON field.
|
|
42
|
-
*/
|
|
43
|
-
const WorkflowStepEntity = defineEntity({
|
|
44
|
-
name: "WorkflowStep",
|
|
45
|
-
description: "A single step/state in a workflow definition.",
|
|
46
|
-
schema: "workflow",
|
|
47
|
-
map: "workflow_step",
|
|
48
|
-
fields: {
|
|
49
|
-
id: field.id({ description: "Unique step ID" }),
|
|
50
|
-
workflowDefinitionId: field.foreignKey(),
|
|
51
|
-
name: field.string({ description: "Human-readable step name" }),
|
|
52
|
-
key: field.string({ description: "Unique key within workflow (e.g., \"manager_approval\")" }),
|
|
53
|
-
description: field.string({ isOptional: true }),
|
|
54
|
-
type: field.enum("StepType", { default: "TASK" }),
|
|
55
|
-
position: field.int({
|
|
56
|
-
default: 0,
|
|
57
|
-
description: "Order for display"
|
|
58
|
-
}),
|
|
59
|
-
transitions: field.json({ description: "Map of action -> next step key" }),
|
|
60
|
-
approvalMode: field.enum("ApprovalMode", {
|
|
61
|
-
default: "ANY",
|
|
62
|
-
isOptional: true
|
|
63
|
-
}),
|
|
64
|
-
approverRoles: field.string({
|
|
65
|
-
isArray: true,
|
|
66
|
-
description: "Roles that can approve"
|
|
67
|
-
}),
|
|
68
|
-
approverUserIds: field.string({
|
|
69
|
-
isArray: true,
|
|
70
|
-
description: "Specific users that can approve"
|
|
71
|
-
}),
|
|
72
|
-
escalationConfig: field.json({
|
|
73
|
-
isOptional: true,
|
|
74
|
-
description: "Escalation rules"
|
|
75
|
-
}),
|
|
76
|
-
assigneeRoles: field.string({
|
|
77
|
-
isArray: true,
|
|
78
|
-
description: "Roles that can be assigned"
|
|
79
|
-
}),
|
|
80
|
-
taskTemplate: field.json({
|
|
81
|
-
isOptional: true,
|
|
82
|
-
description: "Template for task creation"
|
|
83
|
-
}),
|
|
84
|
-
conditionExpression: field.string({
|
|
85
|
-
isOptional: true,
|
|
86
|
-
description: "Expression for branching"
|
|
87
|
-
}),
|
|
88
|
-
waitDuration: field.int({
|
|
89
|
-
isOptional: true,
|
|
90
|
-
description: "Wait duration in seconds"
|
|
91
|
-
}),
|
|
92
|
-
waitForEvent: field.string({
|
|
93
|
-
isOptional: true,
|
|
94
|
-
description: "Event name to wait for"
|
|
95
|
-
}),
|
|
96
|
-
actionType: field.string({
|
|
97
|
-
isOptional: true,
|
|
98
|
-
description: "Action to execute"
|
|
99
|
-
}),
|
|
100
|
-
actionConfig: field.json({
|
|
101
|
-
isOptional: true,
|
|
102
|
-
description: "Action parameters"
|
|
103
|
-
}),
|
|
104
|
-
timeoutSeconds: field.int({
|
|
105
|
-
isOptional: true,
|
|
106
|
-
description: "Step timeout"
|
|
107
|
-
}),
|
|
108
|
-
slaSeconds: field.int({
|
|
109
|
-
isOptional: true,
|
|
110
|
-
description: "SLA deadline"
|
|
111
|
-
}),
|
|
112
|
-
notifyOnEnter: field.json({
|
|
113
|
-
isOptional: true,
|
|
114
|
-
description: "Notification config when entering step"
|
|
115
|
-
}),
|
|
116
|
-
notifyOnExit: field.json({
|
|
117
|
-
isOptional: true,
|
|
118
|
-
description: "Notification config when exiting step"
|
|
119
|
-
}),
|
|
120
|
-
metadata: field.json({ isOptional: true }),
|
|
121
|
-
createdAt: field.createdAt(),
|
|
122
|
-
updatedAt: field.updatedAt(),
|
|
123
|
-
workflowDefinition: field.belongsTo("WorkflowDefinition", ["workflowDefinitionId"], ["id"], { onDelete: "Cascade" }),
|
|
124
|
-
executions: field.hasMany("StepExecution")
|
|
125
|
-
},
|
|
126
|
-
indexes: [
|
|
127
|
-
index.unique(["workflowDefinitionId", "key"]),
|
|
128
|
-
index.on(["workflowDefinitionId", "position"]),
|
|
129
|
-
index.on(["type"])
|
|
130
|
-
],
|
|
131
|
-
enums: [StepTypeEnum, ApprovalModeEnum]
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
//#endregion
|
|
135
|
-
export { ApprovalModeEnum, StepTypeEnum, WorkflowStepEntity };
|
|
1
|
+
import{defineEntity as e,defineEntityEnum as t,field as n,index as r}from"@lssm/lib.schema";const i=t({name:`StepType`,values:[`START`,`APPROVAL`,`TASK`,`CONDITION`,`PARALLEL`,`WAIT`,`ACTION`,`END`],schema:`workflow`,description:`Type of workflow step.`}),a=t({name:`ApprovalMode`,values:[`ANY`,`ALL`,`MAJORITY`,`SEQUENTIAL`],schema:`workflow`,description:`How multiple approvers are handled.`}),o=e({name:`WorkflowStep`,description:`A single step/state in a workflow definition.`,schema:`workflow`,map:`workflow_step`,fields:{id:n.id({description:`Unique step ID`}),workflowDefinitionId:n.foreignKey(),name:n.string({description:`Human-readable step name`}),key:n.string({description:`Unique key within workflow (e.g., "manager_approval")`}),description:n.string({isOptional:!0}),type:n.enum(`StepType`,{default:`TASK`}),position:n.int({default:0,description:`Order for display`}),transitions:n.json({description:`Map of action -> next step key`}),approvalMode:n.enum(`ApprovalMode`,{default:`ANY`,isOptional:!0}),approverRoles:n.string({isArray:!0,description:`Roles that can approve`}),approverUserIds:n.string({isArray:!0,description:`Specific users that can approve`}),escalationConfig:n.json({isOptional:!0,description:`Escalation rules`}),assigneeRoles:n.string({isArray:!0,description:`Roles that can be assigned`}),taskTemplate:n.json({isOptional:!0,description:`Template for task creation`}),conditionExpression:n.string({isOptional:!0,description:`Expression for branching`}),waitDuration:n.int({isOptional:!0,description:`Wait duration in seconds`}),waitForEvent:n.string({isOptional:!0,description:`Event name to wait for`}),actionType:n.string({isOptional:!0,description:`Action to execute`}),actionConfig:n.json({isOptional:!0,description:`Action parameters`}),timeoutSeconds:n.int({isOptional:!0,description:`Step timeout`}),slaSeconds:n.int({isOptional:!0,description:`SLA deadline`}),notifyOnEnter:n.json({isOptional:!0,description:`Notification config when entering step`}),notifyOnExit:n.json({isOptional:!0,description:`Notification config when exiting step`}),metadata:n.json({isOptional:!0}),createdAt:n.createdAt(),updatedAt:n.updatedAt(),workflowDefinition:n.belongsTo(`WorkflowDefinition`,[`workflowDefinitionId`],[`id`],{onDelete:`Cascade`}),executions:n.hasMany(`StepExecution`)},indexes:[r.unique([`workflowDefinitionId`,`key`]),r.on([`workflowDefinitionId`,`position`]),r.on([`type`])],enums:[i,a]});export{a as ApprovalModeEnum,i as StepTypeEnum,o as WorkflowStepEntity};
|