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.
| Naming | Value |
|---|
| Object | ConnectorMapping |
Resource type (JSON:API type) | connector_mapping |
| Collection / records root | β (not a records root) |
| REST base | /v1/connector-mappings |
| Entity class | ConnectorMapping |
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.
API operations
| Operation | Method & path | Status |
|---|
| List | GET /v1/connector-mappings | π‘ Planned |
| Retrieve | GET /v1/connector-mappings/{id} | π‘ Planned |
| Create | POST /v1/connector-mappings | π‘ Planned |
| Update | PATCH /v1/connector-mappings/{id} | π‘ Planned |
| Delete | DELETE /v1/connector-mappings/{id} | π‘ Planned |
Data model
Attributes
| Field | Type | Required | Constraints | Allowed values | Description |
|---|
| connector_mapping_id | π system β UUID string | β
Yes | unique | UUID v4 | Public stable identifier for the mapping row. Generated via gen_random_uuid() at insert time. |
| target_model | π system β enum (target_model_enum) | β
Yes | native Postgres enum type target_model_enum; NOT NULL | company | people | invoice | transaction | account | ledger_account | journal | journal_entry | email | payment_means | invoice_transaction | document | The 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 | β
Yes | NOT 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 | βͺ No | nullable | β | 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) | βͺ No | nullable; 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[]) | βͺ No | nullable; 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 | β
Yes | NOT NULL; default false | true | false | Flag 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 | β
Yes | NOT 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 | βͺ No | nullable; 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 | βͺ No | nullable; 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 | βͺ No | nullable; 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) | βͺ No | nullable; 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 | βͺ No | nullable; 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 | β
Yes | NOT NULL; set by onCreate hook | β | Row creation timestamp. Set once by the MikroORM onCreate lifecycle hook; never updated. |
| updated_at | π system β timestamptz | βͺ No | nullable; set by onUpdate hook | β | Row last-modification timestamp. Set by the MikroORM onUpdate hook on every flush. |
| deleted_at | π system β timestamptz | βͺ No | nullable | β | 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
| Name | Type | Required | Description |
|---|
| workspaceConnector | to-one (ManyToOne) | β
Yes | The 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. |
| workspace | to-one (ManyToOne) | β
Yes | The 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