@lssm/example.workflow-system 0.0.0-canary-20251210171026 → 0.0.0-canary-20251212004227
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/docs/index.js +1 -0
- package/dist/docs/workflow-system.docblock.js +59 -0
- package/dist/index.js +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./workflow-system.docblock.js";
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
|
2
|
+
|
|
3
|
+
- WorkflowDefinition, WorkflowStep, WorkflowInstance, Approval.
|
|
4
|
+
- State machine expressed in \`src/state-machine\` with allowed transitions and role gates.
|
|
5
|
+
|
|
6
|
+
## Contracts
|
|
7
|
+
|
|
8
|
+
- \`workflow.definition.create\`, \`workflow.instance.start\`, \`workflow.step.approve\`, \`workflow.step.reject\`, \`workflow.instance.comment\`.
|
|
9
|
+
- Policies enforced via Identity/RBAC module; audit trail emitted on each transition.
|
|
10
|
+
|
|
11
|
+
## Events & Jobs
|
|
12
|
+
|
|
13
|
+
- Emits \`workflow.instance.started\`, \`workflow.step.completed\`, \`workflow.step.rejected\`, \`workflow.instance.finished\`.
|
|
14
|
+
- Reminder jobs can be scheduled via @lssm/lib.jobs for pending approvals.
|
|
15
|
+
|
|
16
|
+
## UI / Presentations
|
|
17
|
+
|
|
18
|
+
- Dashboard, definition list/editor, instance detail with action buttons derived from state machine.
|
|
19
|
+
- Templates registered in Studio Template Registry under \`workflow-system\`.
|
|
20
|
+
|
|
21
|
+
## Notes
|
|
22
|
+
|
|
23
|
+
- Keep transitions declarative to enable safe regeneration; role guards live in spec.
|
|
24
|
+
- Use Notification Center for approval requests and outcomes; attach files via Files module if needed.
|
|
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
|
|
26
|
+
- Provides a regenerable, role-gated approval engine using declarative state machines.
|
|
27
|
+
- Keeps workflow rules consistent across UI/API/events with auditability.
|
|
28
|
+
|
|
29
|
+
## Business/Product goal
|
|
30
|
+
- Enable approvals with clear transitions, reminders, and notifications.
|
|
31
|
+
- Support compliance via Audit Trail and Feature Flags for staged changes.
|
|
32
|
+
|
|
33
|
+
## Success criteria
|
|
34
|
+
- State changes are declarative and regenerate cleanly.
|
|
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
|
|
36
|
+
1) Define WorkflowDefinition steps and allowed transitions with role gates in spec.
|
|
37
|
+
2) Seed sample workflows/instances (if provided) or create via UI; enable reminders via Jobs.
|
|
38
|
+
|
|
39
|
+
## Extend & regenerate
|
|
40
|
+
1) Add steps/transitions or approval conditions in spec; include PII paths if comments/files.
|
|
41
|
+
2) Regenerate to sync UI action buttons and API/state machine behavior.
|
|
42
|
+
3) Use Feature Flags to trial new transitions or escalation rules.
|
|
43
|
+
|
|
44
|
+
## Guardrails
|
|
45
|
+
- Emit events for every transition; log to Audit Trail.
|
|
46
|
+
- Use Notifications for approvals/rejections; schedule reminders for pending steps.
|
|
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
|
|
48
|
+
- State machine (steps/transitions) must stay declarative in spec; no hidden code paths.
|
|
49
|
+
- Events to emit: instance.started, step.completed/rejected, instance.finished.
|
|
50
|
+
- Regeneration must not change approval logic without explicit spec diff.
|
|
51
|
+
|
|
52
|
+
## PII & Compliance
|
|
53
|
+
- Mark any PII in comments/attachments; redact in markdown/JSON.
|
|
54
|
+
- Ensure Audit Trail captures every transition; Notifications for approvals/rejections.
|
|
55
|
+
|
|
56
|
+
## Verification
|
|
57
|
+
- Add fixtures for transition changes and role gates.
|
|
58
|
+
- Validate reminders (Jobs) stay aligned with pending states after regeneration.
|
|
59
|
+
- Use Feature Flags for new transitions/escalation rules; default safe/off.`}]);
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ApprovalDecidedEvent as ee,ApprovalDelegatedEvent as te,ApprovalEscalatedEvent as e,ApprovalRequestedEvent as t,InstanceCancelledEvent as n,InstanceCompletedEvent as r,InstanceFailedEvent as i,InstancePausedEvent as a,InstanceResumedEvent as o,InstanceStartedEvent as s,InstanceTimedOutEvent as c,StepAddedEvent as l,StepEnteredEvent as u,StepExitedEvent as d,WorkflowCreatedEvent as f,WorkflowPublishedEvent as p,WorkflowSystemEvents as m,WorkflowUpdatedEvent as h}from"./events.js";import{WorkflowSystemFeature as g}from"./feature.js";import{WorkflowDefinitionEntity as _,WorkflowStatusEnum as v,WorkflowTriggerTypeEnum as y}from"./entities/workflow.js";import{ApprovalModeEnum as b,StepTypeEnum as x,WorkflowStepEntity as S}from"./entities/step.js";import{InstanceStatusEnum as C,StepExecutionEntity as w,StepExecutionStatusEnum as T,WorkflowInstanceEntity as E}from"./entities/instance.js";import{ApprovalCommentEntity as D,ApprovalDecisionEnum as O,ApprovalRequestEntity as k,ApprovalStatusEnum as A}from"./entities/approval.js";import{workflowSystemEntities as j,workflowSystemSchemaContribution as M}from"./entities/index.js";import{AddStepContract as N,AddStepInputModel as P,CreateWorkflowContract as F,CreateWorkflowInputModel as I,GetWorkflowContract as L,GetWorkflowInputModel as R,ListWorkflowsContract as z,ListWorkflowsInputModel as B,ListWorkflowsOutputModel as V,PublishWorkflowContract as H,PublishWorkflowInputModel as U,UpdateWorkflowContract as W,UpdateWorkflowInputModel as G,WorkflowDefinitionModel as K,WorkflowStepModel as q}from"./contracts/workflow.js";import{CancelWorkflowContract as J,CancelWorkflowInputModel as Y,GetInstanceContract as X,GetInstanceInputModel as Z,ListInstancesContract as Q,ListInstancesInputModel as ne,ListInstancesOutputModel as $,PauseResumeInputModel as re,PauseWorkflowContract as ie,ResumeWorkflowContract as ae,StartWorkflowContract as oe,StartWorkflowInputModel as se,TransitionInputModel as ce,TransitionResultModel as le,TransitionWorkflowContract as ue,WorkflowInstanceModel as de}from"./contracts/instance.js";import{AddApprovalCommentContract as fe,AddCommentInputModel as pe,ApprovalCommentModel as me,ApprovalRequestModel as he,ApproveRejectInputModel as ge,DelegateApprovalContract as _e,DelegateInputModel as ve,GetApprovalContract as ye,GetApprovalInputModel as be,ListMyApprovalsContract as xe,ListMyApprovalsInputModel as Se,ListMyApprovalsOutputModel as Ce,SubmitDecisionContract as we}from"./contracts/approval.js";import"./contracts/index.js";import{BasicStateMachineEngine as Te,buildStateMachineDefinition as Ee,createInitialState as De,createStateMachineEngine as Oe}from"./state-machine/index.js";import{handleAddStep as ke,handleCreateWorkflow as Ae,handleListMyApprovals as je,handlePublishWorkflow as Me,handleStartWorkflow as Ne,handleSubmitDecision as Pe,handleTransitionWorkflow as Fe,mockDataStore as Ie}from"./handlers/index.js";import{ApprovalDetailPresentation as Le,ApprovalFormPresentation as Re,ApprovalInboxPresentation as ze,InstanceDetailPresentation as Be,InstanceListPresentation as Ve,PendingApprovalsBadgePresentation as He,ProgressTrackerPresentation as Ue,WorkflowDesignerPresentation as We,WorkflowDetailPresentation as Ge,WorkflowListPresentation as Ke,WorkflowMetricsPresentation as qe,WorkflowSystemPresentations as Je}from"./presentations/index.js";import{identityRbacSchemaContribution as Ye}from"@lssm/lib.identity-rbac";import{auditTrailSchemaContribution as Xe}from"@lssm/module.audit-trail";import{notificationsSchemaContribution as Ze}from"@lssm/module.notifications";import{featureFlagsSchemaContribution as Qe}from"@lssm/lib.feature-flags";const $e={modules:[Ye,Xe,Ze,Qe,M],provider:`postgresql`,outputPath:`./prisma/schema/generated.prisma`};export{fe as AddApprovalCommentContract,pe as AddCommentInputModel,N as AddStepContract,P as AddStepInputModel,D as ApprovalCommentEntity,me as ApprovalCommentModel,ee as ApprovalDecidedEvent,O as ApprovalDecisionEnum,te as ApprovalDelegatedEvent,Le as ApprovalDetailPresentation,e as ApprovalEscalatedEvent,Re as ApprovalFormPresentation,ze as ApprovalInboxPresentation,b as ApprovalModeEnum,k as ApprovalRequestEntity,he as ApprovalRequestModel,t as ApprovalRequestedEvent,A as ApprovalStatusEnum,ge as ApproveRejectInputModel,Te as BasicStateMachineEngine,J as CancelWorkflowContract,Y as CancelWorkflowInputModel,F as CreateWorkflowContract,I as CreateWorkflowInputModel,_e as DelegateApprovalContract,ve as DelegateInputModel,ye as GetApprovalContract,be as GetApprovalInputModel,X as GetInstanceContract,Z as GetInstanceInputModel,L as GetWorkflowContract,R as GetWorkflowInputModel,n as InstanceCancelledEvent,r as InstanceCompletedEvent,Be as InstanceDetailPresentation,i as InstanceFailedEvent,Ve as InstanceListPresentation,a as InstancePausedEvent,o as InstanceResumedEvent,s as InstanceStartedEvent,C as InstanceStatusEnum,c as InstanceTimedOutEvent,Q as ListInstancesContract,ne as ListInstancesInputModel,$ as ListInstancesOutputModel,xe as ListMyApprovalsContract,Se as ListMyApprovalsInputModel,Ce as ListMyApprovalsOutputModel,z as ListWorkflowsContract,B as ListWorkflowsInputModel,V as ListWorkflowsOutputModel,re as PauseResumeInputModel,ie as PauseWorkflowContract,He as PendingApprovalsBadgePresentation,Ue as ProgressTrackerPresentation,H as PublishWorkflowContract,U as PublishWorkflowInputModel,ae as ResumeWorkflowContract,oe as StartWorkflowContract,se as StartWorkflowInputModel,l as StepAddedEvent,u as StepEnteredEvent,w as StepExecutionEntity,T as StepExecutionStatusEnum,d as StepExitedEvent,x as StepTypeEnum,we as SubmitDecisionContract,ce as TransitionInputModel,le as TransitionResultModel,ue as TransitionWorkflowContract,W as UpdateWorkflowContract,G as UpdateWorkflowInputModel,f as WorkflowCreatedEvent,_ as WorkflowDefinitionEntity,K as WorkflowDefinitionModel,We as WorkflowDesignerPresentation,Ge as WorkflowDetailPresentation,E as WorkflowInstanceEntity,de as WorkflowInstanceModel,Ke as WorkflowListPresentation,qe as WorkflowMetricsPresentation,p as WorkflowPublishedEvent,v as WorkflowStatusEnum,S as WorkflowStepEntity,q as WorkflowStepModel,m as WorkflowSystemEvents,g as WorkflowSystemFeature,Je as WorkflowSystemPresentations,y as WorkflowTriggerTypeEnum,h as WorkflowUpdatedEvent,Ee as buildStateMachineDefinition,De as createInitialState,Oe as createStateMachineEngine,ke as handleAddStep,Ae as handleCreateWorkflow,je as handleListMyApprovals,Me as handlePublishWorkflow,Ne as handleStartWorkflow,Pe as handleSubmitDecision,Fe as handleTransitionWorkflow,Ie as mockDataStore,$e as schemaComposition,j as workflowSystemEntities,M as workflowSystemSchemaContribution};
|
|
1
|
+
import{ApprovalDecidedEvent as ee,ApprovalDelegatedEvent as te,ApprovalEscalatedEvent as e,ApprovalRequestedEvent as t,InstanceCancelledEvent as n,InstanceCompletedEvent as r,InstanceFailedEvent as i,InstancePausedEvent as a,InstanceResumedEvent as o,InstanceStartedEvent as s,InstanceTimedOutEvent as c,StepAddedEvent as l,StepEnteredEvent as u,StepExitedEvent as d,WorkflowCreatedEvent as f,WorkflowPublishedEvent as p,WorkflowSystemEvents as m,WorkflowUpdatedEvent as h}from"./events.js";import{WorkflowSystemFeature as g}from"./feature.js";import{WorkflowDefinitionEntity as _,WorkflowStatusEnum as v,WorkflowTriggerTypeEnum as y}from"./entities/workflow.js";import{ApprovalModeEnum as b,StepTypeEnum as x,WorkflowStepEntity as S}from"./entities/step.js";import{InstanceStatusEnum as C,StepExecutionEntity as w,StepExecutionStatusEnum as T,WorkflowInstanceEntity as E}from"./entities/instance.js";import{ApprovalCommentEntity as D,ApprovalDecisionEnum as O,ApprovalRequestEntity as k,ApprovalStatusEnum as A}from"./entities/approval.js";import{workflowSystemEntities as j,workflowSystemSchemaContribution as M}from"./entities/index.js";import{AddStepContract as N,AddStepInputModel as P,CreateWorkflowContract as F,CreateWorkflowInputModel as I,GetWorkflowContract as L,GetWorkflowInputModel as R,ListWorkflowsContract as z,ListWorkflowsInputModel as B,ListWorkflowsOutputModel as V,PublishWorkflowContract as H,PublishWorkflowInputModel as U,UpdateWorkflowContract as W,UpdateWorkflowInputModel as G,WorkflowDefinitionModel as K,WorkflowStepModel as q}from"./contracts/workflow.js";import{CancelWorkflowContract as J,CancelWorkflowInputModel as Y,GetInstanceContract as X,GetInstanceInputModel as Z,ListInstancesContract as Q,ListInstancesInputModel as ne,ListInstancesOutputModel as $,PauseResumeInputModel as re,PauseWorkflowContract as ie,ResumeWorkflowContract as ae,StartWorkflowContract as oe,StartWorkflowInputModel as se,TransitionInputModel as ce,TransitionResultModel as le,TransitionWorkflowContract as ue,WorkflowInstanceModel as de}from"./contracts/instance.js";import{AddApprovalCommentContract as fe,AddCommentInputModel as pe,ApprovalCommentModel as me,ApprovalRequestModel as he,ApproveRejectInputModel as ge,DelegateApprovalContract as _e,DelegateInputModel as ve,GetApprovalContract as ye,GetApprovalInputModel as be,ListMyApprovalsContract as xe,ListMyApprovalsInputModel as Se,ListMyApprovalsOutputModel as Ce,SubmitDecisionContract as we}from"./contracts/approval.js";import"./contracts/index.js";import{BasicStateMachineEngine as Te,buildStateMachineDefinition as Ee,createInitialState as De,createStateMachineEngine as Oe}from"./state-machine/index.js";import{handleAddStep as ke,handleCreateWorkflow as Ae,handleListMyApprovals as je,handlePublishWorkflow as Me,handleStartWorkflow as Ne,handleSubmitDecision as Pe,handleTransitionWorkflow as Fe,mockDataStore as Ie}from"./handlers/index.js";import{ApprovalDetailPresentation as Le,ApprovalFormPresentation as Re,ApprovalInboxPresentation as ze,InstanceDetailPresentation as Be,InstanceListPresentation as Ve,PendingApprovalsBadgePresentation as He,ProgressTrackerPresentation as Ue,WorkflowDesignerPresentation as We,WorkflowDetailPresentation as Ge,WorkflowListPresentation as Ke,WorkflowMetricsPresentation as qe,WorkflowSystemPresentations as Je}from"./presentations/index.js";import"./docs/index.js";import{identityRbacSchemaContribution as Ye}from"@lssm/lib.identity-rbac";import{auditTrailSchemaContribution as Xe}from"@lssm/module.audit-trail";import{notificationsSchemaContribution as Ze}from"@lssm/module.notifications";import{featureFlagsSchemaContribution as Qe}from"@lssm/lib.feature-flags";const $e={modules:[Ye,Xe,Ze,Qe,M],provider:`postgresql`,outputPath:`./prisma/schema/generated.prisma`};export{fe as AddApprovalCommentContract,pe as AddCommentInputModel,N as AddStepContract,P as AddStepInputModel,D as ApprovalCommentEntity,me as ApprovalCommentModel,ee as ApprovalDecidedEvent,O as ApprovalDecisionEnum,te as ApprovalDelegatedEvent,Le as ApprovalDetailPresentation,e as ApprovalEscalatedEvent,Re as ApprovalFormPresentation,ze as ApprovalInboxPresentation,b as ApprovalModeEnum,k as ApprovalRequestEntity,he as ApprovalRequestModel,t as ApprovalRequestedEvent,A as ApprovalStatusEnum,ge as ApproveRejectInputModel,Te as BasicStateMachineEngine,J as CancelWorkflowContract,Y as CancelWorkflowInputModel,F as CreateWorkflowContract,I as CreateWorkflowInputModel,_e as DelegateApprovalContract,ve as DelegateInputModel,ye as GetApprovalContract,be as GetApprovalInputModel,X as GetInstanceContract,Z as GetInstanceInputModel,L as GetWorkflowContract,R as GetWorkflowInputModel,n as InstanceCancelledEvent,r as InstanceCompletedEvent,Be as InstanceDetailPresentation,i as InstanceFailedEvent,Ve as InstanceListPresentation,a as InstancePausedEvent,o as InstanceResumedEvent,s as InstanceStartedEvent,C as InstanceStatusEnum,c as InstanceTimedOutEvent,Q as ListInstancesContract,ne as ListInstancesInputModel,$ as ListInstancesOutputModel,xe as ListMyApprovalsContract,Se as ListMyApprovalsInputModel,Ce as ListMyApprovalsOutputModel,z as ListWorkflowsContract,B as ListWorkflowsInputModel,V as ListWorkflowsOutputModel,re as PauseResumeInputModel,ie as PauseWorkflowContract,He as PendingApprovalsBadgePresentation,Ue as ProgressTrackerPresentation,H as PublishWorkflowContract,U as PublishWorkflowInputModel,ae as ResumeWorkflowContract,oe as StartWorkflowContract,se as StartWorkflowInputModel,l as StepAddedEvent,u as StepEnteredEvent,w as StepExecutionEntity,T as StepExecutionStatusEnum,d as StepExitedEvent,x as StepTypeEnum,we as SubmitDecisionContract,ce as TransitionInputModel,le as TransitionResultModel,ue as TransitionWorkflowContract,W as UpdateWorkflowContract,G as UpdateWorkflowInputModel,f as WorkflowCreatedEvent,_ as WorkflowDefinitionEntity,K as WorkflowDefinitionModel,We as WorkflowDesignerPresentation,Ge as WorkflowDetailPresentation,E as WorkflowInstanceEntity,de as WorkflowInstanceModel,Ke as WorkflowListPresentation,qe as WorkflowMetricsPresentation,p as WorkflowPublishedEvent,v as WorkflowStatusEnum,S as WorkflowStepEntity,q as WorkflowStepModel,m as WorkflowSystemEvents,g as WorkflowSystemFeature,Je as WorkflowSystemPresentations,y as WorkflowTriggerTypeEnum,h as WorkflowUpdatedEvent,Ee as buildStateMachineDefinition,De as createInitialState,Oe as createStateMachineEngine,ke as handleAddStep,Ae as handleCreateWorkflow,je as handleListMyApprovals,Me as handlePublishWorkflow,Ne as handleStartWorkflow,Pe as handleSubmitDecision,Fe as handleTransitionWorkflow,Ie as mockDataStore,$e as schemaComposition,j as workflowSystemEntities,M as workflowSystemSchemaContribution};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/example.workflow-system",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251212004227",
|
|
4
4
|
"description": "Workflow and approval system example for ContractSpec - State machine with role-based transitions",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
"./contracts/approval": "./src/contracts/approval.ts",
|
|
39
39
|
"./contracts/instance": "./src/contracts/instance.ts",
|
|
40
40
|
"./contracts/workflow": "./src/contracts/workflow.ts",
|
|
41
|
+
"./docs": "./src/docs/index.ts",
|
|
42
|
+
"./docs/workflow-system.docblock": "./src/docs/workflow-system.docblock.ts",
|
|
41
43
|
"./entities": "./src/entities/index.ts",
|
|
42
44
|
"./entities/approval": "./src/entities/approval.ts",
|
|
43
45
|
"./entities/instance": "./src/entities/instance.ts",
|
|
@@ -63,6 +65,8 @@
|
|
|
63
65
|
"./contracts/approval": "./dist/contracts/approval.js",
|
|
64
66
|
"./contracts/instance": "./dist/contracts/instance.js",
|
|
65
67
|
"./contracts/workflow": "./dist/contracts/workflow.js",
|
|
68
|
+
"./docs": "./dist/docs/index.js",
|
|
69
|
+
"./docs/workflow-system.docblock": "./dist/docs/workflow-system.docblock.js",
|
|
66
70
|
"./entities": "./dist/entities/index.js",
|
|
67
71
|
"./entities/approval": "./dist/entities/approval.js",
|
|
68
72
|
"./entities/instance": "./dist/entities/instance.js",
|