Catalogs

Manage status, priority, and maintenance type catalogs per tenant. These catalogs power workflows and dashboards. Set tenant context before calling these methods.

List catalogs

List catalogs for the current tenant.

List status, priority, and maintenance type catalogs

await client.setTenant(tenantId)

const statuses = await client.catalogs.listStatuses()
// StatusCatalogRow[]

const priorities = await client.catalogs.listPriorities()
// PriorityCatalogRow[]

const maintenanceTypes = await client.catalogs.listMaintenanceTypes()
// MaintenanceTypeCatalogRow[]

const transitions = await client.catalogs.listStatusTransitions()
// StatusTransitionRow[]

Create status

Create a status for an entity type (e.g. work order). Requires tenant.admin. Returns the status key.

client.catalogs.createStatus(params)

const statusKey = await client.catalogs.createStatus({
  tenantId,
  entityType: 'work_order',
  key: 'in_progress',
  name: 'In progress',
  category: 'active',
  color: '#fbbf24',
  displayOrder: 20,
  icon: 'play',
})
// Returns string (status key)

Create status transition

Create an allowed transition between two statuses. Requires tenant.admin. Returns the transition ID.

client.catalogs.createStatusTransition(params)

const transitionId = await client.catalogs.createStatusTransition({
  tenantId,
  entityType: 'work_order',
  fromStatusKey: 'open',
  toStatusKey: 'in_progress',
  requiredPermission: 'workorder.edit',
  guardCondition: null,
})
// Returns string (transition id)

Create priority

Create a priority definition. Requires tenant.admin. Returns the priority key.

client.catalogs.createPriority(params)

const priorityKey = await client.catalogs.createPriority({
  tenantId,
  entityType: 'work_order',
  key: 'high',
  name: 'High',
  weight: 100,
  displayOrder: 10,
  color: '#ef4444',
})
// Returns string (priority key)

Create maintenance type

Create a maintenance type. Requires tenant.admin. Returns the maintenance type key.

client.catalogs.createMaintenanceType(params)

const maintenanceTypeKey = await client.catalogs.createMaintenanceType({
  tenantId,
  key: 'pm_inspection',
  name: 'PM inspection',
  category: 'preventive',
  description: 'Scheduled preventive maintenance inspection',
  displayOrder: 10,
  color: '#22c55e',
  icon: 'clipboard',
})
// Returns string (maintenance type key)

Get workflow graph

Fetch the workflow graph for an entity type as JSON. This is useful for building UI around allowed status transitions.

client.catalogs.getWorkflowGraph(tenantId, entityType)

await client.setTenant(tenantId)

const graph = await client.catalogs.getWorkflowGraph(tenantId, 'work_order')
// WorkflowGraph (JSONB) with entity_type, tenant_id, and transitions[]

Was this page helpful?