Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.wellapp.ai/llms.txt

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

A ConnectorMapping row is the compiled JSONata expression that the connector sync pipeline uses to transform one MCP tool’s response payload into one of twelve Well financial-graph entity types (company, invoice, transaction, account, etc.). One row is produced per unique (workspace_connector, target_model, tool_name) triple; the triple is enforced by a partial unique index on non-deleted rows. The record is entirely pipeline-owned: it is created, regenerated, and soft-deleted by SyncConfigService during each MCP sync cycle, and is never written by a user. It is associated upward to a WorkspaceConnector (the authenticated provider instance) and to a Workspace.
NamingValue
ObjectConnectorMapping
Resource type (JSON:API type)connector_mapping
Collection / records rootβ€” (not a records root)
REST base/v1/connector-mappings
Entity classConnectorMapping
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.

API operations

OperationMethod & pathStatus
ListGET /v1/connector-mappings🟑 Planned
RetrieveGET /v1/connector-mappings/{id}🟑 Planned
CreatePOST /v1/connector-mappings🟑 Planned
UpdatePATCH /v1/connector-mappings/{id}🟑 Planned
DeleteDELETE /v1/connector-mappings/{id}🟑 Planned

Data model

Attributes

FieldTypeRequiredConstraintsAllowed valuesDescription
connector_mapping_idπŸ”’ system β€” UUID stringβœ… YesuniqueUUID v4Public stable identifier for the mapping row. Generated via gen_random_uuid() at insert time.
target_modelπŸ”’ system β€” enum (target_model_enum)βœ… Yesnative Postgres enum type target_model_enum; NOT NULLcompany | people | invoice | transaction | account | ledger_account | journal | journal_entry | email | payment_means | invoice_transaction | documentThe Well financial-graph entity type this mapping expression produces. Part of the partial-unique triple (workspace_connector_pk, target_model, tool_name) WHERE deleted_at IS NULL.
expressionπŸ”’ system β€” textβœ… YesNOT NULL; text (unbounded)β€”JSONata expression produced by the structured-slot-decision jury pipeline (SyncConfigService). Transforms a single MCP tool response payload into an array of Well entities matching target_model. Never written directly by a user.
user_instructionsπŸ”’ system β€” textβšͺ Nonullableβ€”Optional free-text hints stored alongside the mapping at generation time to guide re-generation prompts. Written by the sync pipeline, not directly by end users.
schema_fingerprintπŸ”’ system β€” varchar(128)βšͺ Nonullable; max length 128β€”Hash of the provider tool’s schema at the time this mapping was generated. Compared on subsequent syncs via compareSchemaFingerprints(); a β€˜drift’ result triggers needs_regeneration = true.
schema_key_pathsπŸ”’ system β€” jsonb (string[])βšͺ Nonullable; jsonbβ€”Ordered list of dotted key-paths extracted from the provider schema sample used during jury generation. Used by the panelists for vocab-bound source_path validation.
needs_regenerationπŸ”’ system β€” booleanβœ… YesNOT NULL; default falsetrue | falseFlag set to true by the sync pipeline when schema drift is detected or last_persist_count is 0 after a sync. When true, the next sync attempt regenerates the JSONata expression before executing.
tool_nameπŸ”’ system β€” textβœ… YesNOT NULL; part of partial-unique index (workspace_connector_pk, target_model, tool_name) WHERE deleted_at IS NULLβ€”Name of the MCP tool whose response this mapping expression consumes. Added in Migration20260420100000; rows pre-dating multi-tool support were backfilled with β€˜legacy’.
tool_argsπŸ”’ system β€” jsonbβšͺ Nonullable; CHECK pg_column_size(tool_args) < 65536 (64 KB); added in Migration20260420100000β€”Tool invocation arguments captured at AI tool-selection time. Rehydrated by the sync orchestrator to replay the exact MCP call. Read-only; never mutated post-creation.
selected_atπŸ”’ system β€” timestamptzβšͺ Nonullable; timestamptzβ€”Timestamp recorded when the AI tool-selection phase picked this tool. Serves as an anchor for TTL-based re-selection logic in the sync pipeline.
audit_trailπŸ”’ system β€” jsonbβšͺ Nonullable; jsonbβ€”Latest jury-run audit verdict for this mapping row. Written by JuryService after each jury run. Shape: { jury_name, panelists[], judge_reasoning, disagreement_score, duration_ms, synthesized? }. Null on legacy rows predating the structured pipeline.
pagination_specπŸ”’ system β€” jsonb (ToolPagination)βšͺ Nonullable; jsonb; added in Migration20260513110000β€”LLM-discovered pagination specification for the tool. Null means single-page tool (no pagination). Discovered at mapping-generation time using the same schema sample as the JSONata jury. Shape is ToolPagination from services/mcp/pagination.types.
last_persist_countπŸ”’ system β€” intβšͺ Nonullable; intβ€”Count of entities successfully persisted in the most recent sync that used this mapping. Stamped by SyncConfigService.recordPersistCount after each sync. Zero triggers auto-regeneration (needs_regeneration = true) on the next sync. Non-zero enables the regression-revert guard.
created_atπŸ”’ system β€” timestamptzβœ… YesNOT NULL; set by onCreate hookβ€”Row creation timestamp. Set once by the MikroORM onCreate lifecycle hook; never updated.
updated_atπŸ”’ system β€” timestamptzβšͺ Nonullable; set by onUpdate hookβ€”Row last-modification timestamp. Set by the MikroORM onUpdate hook on every flush.
deleted_atπŸ”’ system β€” timestamptzβšͺ Nonullableβ€”Soft-delete timestamp. When non-null the row is logically deleted and excluded from the partial-unique index on (workspace_connector_pk, target_model, tool_name). Allows a replacement row to be inserted under the same triple after re-generation.

Relationships

NameTypeRequiredDescription
workspaceConnectorto-one (ManyToOne)βœ… YesThe authenticated provider instance (WorkspaceConnector) this mapping belongs to. FK column: workspace_connector_pk. All active mappings for a connector are soft-deleted when the connector is disconnected.
workspaceto-one (ManyToOne)βœ… YesThe owning workspace. FK column: workspace_pk. Used for tenant scoping β€” every query against connector_mappings filters by workspace_pk.

System-computed

  • connector_mapping_id β€” generated via gen_random_uuid() at insert; unique constraint enforced at DB level
  • created_at β€” set once by MikroORM onCreate lifecycle hook
  • updated_at β€” set on every flush by MikroORM onUpdate lifecycle hook
  • deleted_at β€” soft-delete; when set, the row is excluded from the partial unique index on (workspace_connector_pk, target_model, tool_name) WHERE deleted_at IS NULL, allowing a fresh row to be inserted under the same triple
  • needs_regeneration β€” auto-flipped to true by SyncConfigService when schema drift (β€˜drift’ result from compareSchemaFingerprints) is detected or last_persist_count == 0 after a sync
  • last_persist_count β€” stamped by SyncConfigService.recordPersistCount after each sync completes; zero value is the signal for automatic re-generation on the next sync cycle
  • expression β€” produced by the structured slot-decision jury pipeline (3-panelist OpenAI strict json_schema β†’ reconcileJuryDecisions β†’ mergeSlotDecisions with YAML-pinned slots β†’ compileSlotDecisionsToJsonata); regenerated when needs_regeneration is true; subject to three-tier graceful degradation (reuse prior working expression β†’ legacy jury β†’ hard fail)
  • schema_fingerprint β€” computed from the provider tool schema sample at generation time; compareSchemaFingerprints returns identical | additive_only | drift; only β€˜drift’ triggers regeneration
  • schema_key_paths β€” extracted from the provider schema sample during jury generation; used for vocab-bound source_path validation by jury panelists
  • audit_trail β€” written by JuryService after each jury run; null on rows predating the structured pipeline
  • pagination_spec β€” discovered by the same schema-sample pass as the JSONata jury at generation time; null means single-page tool
  • tool_args β€” captured once at AI tool-selection time (selected_at anchor); never mutated post-creation; bounded to 64 KB by a CHECK constraint (Migration20260420100000)
  • Partial-unique index connector_mappings_wc_target_tool_unique on (workspace_connector_pk, target_model, tool_name) WHERE deleted_at IS NULL β€” enforces one active mapping per tool-per-target-per-connector; added in Migration20260420100000 replacing the legacy (workspace_connector_pk, target_model) unique index

Example

{
  "data": {
    "type": "connector_mapping",
    "id": "a3f8c1d2-7b4e-4f2a-9c01-3e5d8f2a6b19",
    "attributes": {
      "connector_mapping_id": "a3f8c1d2-7b4e-4f2a-9c01-3e5d8f2a6b19",
      "target_model": "invoice",
      "expression": "$map(result.invoices, function($v) { { 'reference_number': $v.invoice_number, 'grand_total': $number($v.total_amount), 'issue_date': $v.created_at } })",
      "user_instructions": "Map invoice totals from EUR cents to decimal euros.",
      "schema_fingerprint": "sha256:3a9c1e7f2b4d",
      "schema_key_paths": ["result.invoices[].invoice_number", "result.invoices[].total_amount", "result.invoices[].created_at"],
      "needs_regeneration": false,
      "tool_name": "pennylane_list_invoices",
      "tool_args": { "page": 1, "per_page": 100 },
      "selected_at": "2026-05-01T14:32:00.000Z",
      "audit_trail": {
        "jury_name": "slot-decision-v2",
        "panelists": ["gpt-5.4-0.4", "gpt-5.4-0.7", "gpt-5.4-1.0"],
        "disagreement_score": 0.12,
        "duration_ms": 4320,
        "synthesized": false
      },
      "pagination_spec": { "type": "page_number", "page_param": "page", "per_page_param": "per_page", "per_page": 100 },
      "last_persist_count": 87,
      "created_at": "2026-04-20T10:00:00.000Z",
      "updated_at": "2026-05-01T14:32:05.000Z",
      "deleted_at": null
    },
    "relationships": {
      "workspace_connector": {
        "data": { "type": "workspace_connector", "id": "c7d4a2f1-1e3b-4a2c-8f01-9b2e7c3d5a11" }
      },
      "workspace": {
        "data": { "type": "workspace", "id": "9f3e2b1a-4c7d-4f8e-b3a1-2c5d9e7f3b08" }
      }
    }
  }
}
Source: /Users/maximechampoux/platform/apps/api/src/database/entities/ConnectorMapping.ts Β· domain: ingestion Β· tier: Infrastructure