Skip to main content

apps/gateway/src/services/workflow-repository.ts

Metadata

Indexed Symbols

  • persistWorkflowExecution (line 16, function) - Implements persist workflow execution for service-layer operations.
  • persistAuditCredential (line 41, function) - Implements persist audit credential for service-layer operations.
  • deriveCompletionMetadata (line 69, function) - Implements derive completion metadata for service-layer operations.
  • persistWorkflowCompletion (line 88, function) - Implements persist workflow completion for service-layer operations.
  • listWorkflowExecutions (line 128, function) - Implements list workflow executions for service-layer operations.
  • getWorkflowExecutionById (line 189, function) - Implements get workflow execution by id for service-layer operations.
  • listWorkflowCallbacks (line 253, function) - Implements list workflow callbacks for service-layer operations.
  • cancelWorkflowExecution (line 274, function) - Implements cancel workflow execution for service-layer operations.
  • listAuditCredentials (line 293, function) - Implements list audit credentials for service-layer operations.

Markdown Headings (if applicable)

No markdown headings detected.

Source Preview

import type { AuditCredential } from "@anchor/contracts";
import { query, withTransaction } from "./postgres.js";

type PersistExecutionInput = {
executionId: string;
workspaceId: string;
agent: string;
reasoner: string;
status: string;
correlationId: string;
acceptedAt: string;
inputRef?: string;
retryCount?: number;
};

export async function persistWorkflowExecution(input: PersistExecutionInput): Promise<void> {
await query(
`insert into workflow_executions (id, workspace_id, agent, reasoner, status, correlation_id, requested_at, input_ref, retry_count)
values ($1::uuid, $2::uuid, $3, $4, $5, $6::uuid, $7::timestamptz, $8, $9)
on conflict (id)
do update set status = excluded.status,
agent = excluded.agent,
reasoner = excluded.reasoner,
correlation_id = excluded.correlation_id,
input_ref = coalesce(excluded.input_ref, workflow_executions.input_ref),