Skip to content

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.

  • 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
RoutePurpose
/business/apps/workflowsWorkflow list with active/inactive badges
/business/apps/workflows/newCreate a new workflow (name and description)
/business/apps/workflows/[id]Workflow detail with steps and transitions management
/business/apps/workflows/instancesList of all workflow instances with status
/business/apps/workflows/instances/[instanceId]Instance detail with current step and available transitions

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.

A simple form with name (required) and description (optional) fields. Uses createWorkflowSchema for validation. On success, redirects to the workflow detail page.

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.

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:

StatusBadge Variant
completeddefault
in_progress / initiatedsecondary
cancelleddestructive
TableDescription
ext_workflows.workflowsWorkflow definition (name, description, is_active)
ext_workflows.workflow_stepsOrdered steps within a workflow
ext_workflows.workflow_transitionsNamed transitions between steps (with color and order)
ext_workflows.workflow_transition_permissionsPer-transition access control (user or role based)
ext_workflows.workflow_instancesRunning workflow instances tied to a target
ext_workflows.workflow_logsAudit log entries for instance state changes
  • Workflow — id, user_id, name, description, is_active
  • WorkflowWithSteps — Workflow with nested steps and transitions arrays
  • WorkflowStep — id, workflow_id, name, order
  • WorkflowTransition — id, workflow_id, from_step_id, to_step_id, name, color, order, is_first
  • WorkflowTransitionPermission — id, transition_id, permitted_user_id, permitted_role
  • WorkflowInstance — id, workflow_id, target_id, target_type, current_step_id, status (initiated | in_progress | completed | cancelled), started_by
  • WorkflowInstanceWithDetails — Instance with nested workflow, current_step, available_transitions, and logs
  • WorkflowLog — id, instance_id, transition_id, user_id, action (initiated | transition | cancelled), comment
  • WorkflowTargetType"document" | "invoice" | "quotation"
ComponentLocation
Workflow listsrc/routes/(app)/business/apps/workflows/+page.svelte
Create workflow formsrc/routes/(app)/business/apps/workflows/new/+page.svelte
Workflow detail (steps + transitions)src/routes/(app)/business/apps/workflows/[id]/+page.svelte
Instance listsrc/routes/(app)/business/apps/workflows/instances/+page.svelte

Server-side logic lives in $lib/apps/workflows/services/index.js:

  • listWorkflows(userId) — list all workflows for a user
  • getWorkflow(id) — fetch workflow with steps and transitions
  • addStep(workflowId, data) / updateStep(stepId, data) / deleteStep(stepId) — step CRUD
  • addTransition(workflowId, data) / updateTransition(transitionId, data) / deleteTransition(transitionId) — transition CRUD
  • deleteWorkflow(id) — delete a workflow
ActionDescription
add-stepAdd a new step with name and order
update-stepUpdate step name and/or order
delete-stepRemove a step
add-transitionCreate a transition between two steps
update-transitionUpdate transition name and color
delete-transitionRemove a transition
delete-workflowDelete the entire workflow and redirect to list
  • createStepSchema from $lib/apps/workflows/modules/steps/index.js
  • createTransitionSchema from $lib/apps/workflows/modules/transitions/index.js
  • createWorkflowSchema from $lib/apps/workflows/modules/workflows/index.js