Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt

Use this file to discover all available pages before exploring further.

This document provides a reference for all database tables in the Forms & Workflow (FW) module.

Table Naming Convention

All FW tables use the fw_ prefix following the platform convention.

Core Tables

Forms

TableDescription
fw_formsForm definitions with metadata, status, and settings
fw_form_fieldsField definitions for each form
fw_form_versionsVersion history for forms
fw_form_templatesReusable form templates

Submissions

TableDescription
fw_form_submissionsSubmitted form data
fw_submission_attachmentsFiles attached to submissions
fw_submission_notesNotes/comments on submissions

Workflow Definitions

TableDescription
fw_workflow_definitionsWorkflow structure and steps
fw_workflow_nodesIndividual nodes in a workflow
fw_workflow_edgesConnections between workflow nodes
fw_workflow_variablesVariables used in workflow expressions

Automation

TableDescription
fw_automation_rulesAutomation rule definitions with triggers and conditions
fw_workflow_executionsRuntime execution records
fw_workflow_execution_stepsIndividual step execution records
fw_workflow_approvalsApproval requests and decisions

Analytics & Testing

TableDescription
fw_automation_analyticsAggregated analytics view
fw_test_casesTest case definitions
fw_test_datasetsTest data for workflow testing
fw_test_scenariosEnd-to-end test scenarios

Common Query Patterns

Get Active Forms Count

const { count } = await supabase
  .from("fw_forms")
  .select("*", { count: "exact", head: true })
  .eq("organization_id", organizationId)
  .eq("status", "published");

Get Recent Submissions

const { data } = await supabase
  .from("fw_form_submissions")
  .select(`
    id,
    submitted_at,
    status,
    form:fw_forms(name),
    submitted_by_profile:pf_profiles!fw_form_submissions_submitted_by_fkey(display_name)
  `)
  .eq("organization_id", organizationId)
  .order("submitted_at", { ascending: false })
  .limit(5);

Get Active Automations

const { count } = await supabase
  .from("fw_automation_rules")
  .select("*", { count: "exact", head: true })
  .eq("organization_id", organizationId)
  .eq("is_active", true);

Get Pending Approvals

const { count } = await supabase
  .from("fw_workflow_approvals")
  .select("*", { count: "exact", head: true })
  .eq("organization_id", organizationId)
  .is("decision", null);

Get Workflow Executions (Last 24 Hours)

const oneDayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
const { count } = await supabase
  .from("fw_workflow_executions")
  .select("*", { count: "exact", head: true })
  .eq("organization_id", organizationId)
  .gte("started_at", oneDayAgo);

Important Notes

  1. Table Naming: Use fw_automation_rules for automation rules, NOT fw_workflows
  2. Workflow Definitions: Use fw_workflow_definitions for workflow structures
  3. Executions: Use fw_workflow_executions for runtime execution data
  4. Multi-tenancy: All queries must include organization_id filter