Workflows
The Workflows app provides a visual workflow definition system where users create multi-step processes with named transitions between steps. Workflows can be applied to targets (documents, invoices, quotations) and tracked through execution instances with full audit logging.
Key Features
Section titled “Key Features”- Named workflows with active/inactive status
- Ordered steps that define the stages of a process
- Named, color-coded transitions between steps
- Workflow instances that track a target through the process
- Instance status tracking: Initiated, In Progress, Completed, Cancelled
- Transition permissions (per-user or per-role)
- Full audit log for every state change
- Target type support: Document, Invoice, Quotation
Page Structure
Section titled “Page Structure”| Route | Purpose |
|---|---|
/business/apps/workflows | Workflow list with active/inactive badges |
/business/apps/workflows/new | Create a new workflow (name and description) |
/business/apps/workflows/[id] | Workflow detail with steps and transitions management |
/business/apps/workflows/instances | List of all workflow instances with status |
/business/apps/workflows/instances/[instanceId] | Instance detail with current step and available transitions |
Workflow List
Section titled “Workflow List”The main page shows a two-column grid of workflow cards. Each card displays the workflow name, optional description, active/inactive badge, and creation date. Links to the Instances list and New Workflow form are in the header.
Create Workflow
Section titled “Create Workflow”A simple form with name (required) and description (optional) fields. Uses createWorkflowSchema for validation. On success, redirects to the workflow detail page.
Workflow Detail
Section titled “Workflow Detail”The detail page is the primary configuration interface, divided into two sections:
Steps section — Ordered list of workflow steps. Each step shows its order number and name. Steps can be added via a dialog (name + order fields) and deleted inline.
Transitions section — List of connections between steps. Each transition shows the source step, an arrow, the destination step, the transition name, and an optional color indicator. Transitions can be added via a dialog (from step, to step, name, color picker) and deleted inline.
Workflow Instances
Section titled “Workflow Instances”The instances page lists all running and completed workflow instances. Each entry shows a truncated workflow ID, target type and ID, start date, and status badge. Instance statuses use distinct badge variants:
| Status | Badge Variant |
|---|---|
completed | default |
in_progress / initiated | secondary |
cancelled | destructive |
Data Model
Section titled “Data Model”| Table | Description |
|---|---|
ext_workflows.workflows | Workflow definition (name, description, is_active) |
ext_workflows.workflow_steps | Ordered steps within a workflow |
ext_workflows.workflow_transitions | Named transitions between steps (with color and order) |
ext_workflows.workflow_transition_permissions | Per-transition access control (user or role based) |
ext_workflows.workflow_instances | Running workflow instances tied to a target |
ext_workflows.workflow_logs | Audit log entries for instance state changes |
Key Types
Section titled “Key Types”Workflow— id, user_id, name, description, is_activeWorkflowWithSteps— Workflow with nested steps and transitions arraysWorkflowStep— id, workflow_id, name, orderWorkflowTransition— id, workflow_id, from_step_id, to_step_id, name, color, order, is_firstWorkflowTransitionPermission— id, transition_id, permitted_user_id, permitted_roleWorkflowInstance— id, workflow_id, target_id, target_type, current_step_id, status (initiated|in_progress|completed|cancelled), started_byWorkflowInstanceWithDetails— Instance with nested workflow, current_step, available_transitions, and logsWorkflowLog— id, instance_id, transition_id, user_id, action (initiated|transition|cancelled), commentWorkflowTargetType—"document"|"invoice"|"quotation"
Key Components
Section titled “Key Components”| Component | Location |
|---|---|
| Workflow list | src/routes/(app)/business/apps/workflows/+page.svelte |
| Create workflow form | src/routes/(app)/business/apps/workflows/new/+page.svelte |
| Workflow detail (steps + transitions) | src/routes/(app)/business/apps/workflows/[id]/+page.svelte |
| Instance list | src/routes/(app)/business/apps/workflows/instances/+page.svelte |
Services
Section titled “Services”Server-side logic lives in $lib/apps/workflows/services/index.js:
listWorkflows(userId)— list all workflows for a usergetWorkflow(id)— fetch workflow with steps and transitionsaddStep(workflowId, data)/updateStep(stepId, data)/deleteStep(stepId)— step CRUDaddTransition(workflowId, data)/updateTransition(transitionId, data)/deleteTransition(transitionId)— transition CRUDdeleteWorkflow(id)— delete a workflow
Form Actions
Section titled “Form Actions”Workflow Detail ([id])
Section titled “Workflow Detail ([id])”| Action | Description |
|---|---|
add-step | Add a new step with name and order |
update-step | Update step name and/or order |
delete-step | Remove a step |
add-transition | Create a transition between two steps |
update-transition | Update transition name and color |
delete-transition | Remove a transition |
delete-workflow | Delete the entire workflow and redirect to list |
Schemas
Section titled “Schemas”createStepSchemafrom$lib/apps/workflows/modules/steps/index.jscreateTransitionSchemafrom$lib/apps/workflows/modules/transitions/index.jscreateWorkflowSchemafrom$lib/apps/workflows/modules/workflows/index.js