Mapping schema — Data Protocol reference
Mapping schemas of the ObjectStack Data Protocol: ImportFieldMapping, Mapping, TransformType — each property with its type, default and a TypeScript example.
Source: packages/spec/src/data/mapping.zod.ts
TypeScript Usage
import { ImportFieldMappingSchema, MappingSchema, TransformType } from '@objectstack/spec/data';
import type { ImportFieldMapping, Mapping, TransformType } from '@objectstack/spec/data';
// Validate data
const result = ImportFieldMappingSchema.parse(data);ImportFieldMapping
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| source | string | string[] | ✅ | Source column header(s) |
| target | string | string[] | ✅ | Target object field(s); a declared part of a compound field is written field.part (e.g. mailing_address.street), and the parts one row maps are assembled into that field's value |
| transform | Enum<'none' | 'constant' | 'lookup' | 'split' | 'join' | 'javascript' | 'map'> | optional (default: "none") | |
| params | { value?: any; valueMap?: Record<string, any>; separator?: string } | optional |
Mapping
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Mapping unique name (lowercase snake_case) |
| label | string | optional | Display label, shown where the mapping is offered by name (the import wizard); translated per locale at mappings.<name>.label in the translation bundle |
| sourceFormat | Enum<'csv' | 'json' | 'xml' | 'sql'> | optional (default: "csv") | |
| targetObject | string | ✅ | Target Object Name |
| fieldMapping | { source: string | string[]; target: string | string[]; transform?: Enum<'none' | 'constant' | 'lookup' | 'split' | 'join' | 'javascript' | 'map'>; params?: object }[] | ✅ | |
| mode | Enum<'insert' | 'update' | 'upsert'> | optional (default: "insert") | |
| upsertKey | string[] | optional | Fields to match for upsert (e.g. email) |
| connectorSource | { connector: string; action: string; input?: Record<string, any>; recordsPath?: string; … } | optional | Pull binding: the rest/openapi connector this mapping pulls rows from (one-way, full or timestamp-incremental; a job sets the cadence). Pulled when a job drives it — a job whose pull: { mapping } names this mapping, on the job's schedule; the binding alone moves no rows |
| datasourceSource | { object: string; watermark: object; full?: boolean; deletePolicy?: Enum<'mark' | 'ignore'>; … } | optional | Pull binding: the federated object this mapping pulls rows from (one-way; a job sets the cadence), read in windows cut on watermark.field. Exclusive with connectorSource. Pulled when a job drives it — a job whose pull: { mapping } names this mapping; the binding alone moves no rows |
| _lock | Enum<'none' | 'no-overlay' | 'no-delete' | 'full'> | optional | Item-level lock — controls overlay & delete (ADR-0010). |
| _lockReason | string | optional | Human-readable reason shown when a write is refused by _lock. |
| _lockSource | Enum<'artifact' | 'package' | 'env-forced'> | optional | Layer that set _lock (artifact | package | env-forced). |
| _provenance | Enum<'package' | 'org' | 'env-forced' | 'platform'> | optional | Origin of the item (package | org | env-forced | platform). |
| _packageId | string | optional | Owning package machine id. |
| _packageVersion | string | optional | Owning package version. |
| _lockDocsUrl | string | optional | Optional documentation link surfaced next to _lockReason. |
| overrides | { package: string; basedOn: string } | optional | Override declaration (ADR-0146 D2): { package, basedOn } — this item of "<base>.custom" replaces the base package's same-named item whole. basedOn is recorded and never gates; a base's upgrade plan reads it only as advice. |
Nested Shape: Mapping.fieldMapping[number]
| Property | Type | Required | Description |
|---|---|---|---|
| source | string | string[] | ✅ | Source column header(s) |
| target | string | string[] | ✅ | Target object field(s); a declared part of a compound field is written field.part (e.g. mailing_address.street), and the parts one row maps are assembled into that field's value |
| transform | Enum<'none' | 'constant' | 'lookup' | 'split' | 'join' | 'javascript' | 'map'> | optional (default: "none") | |
| params | { value?: any; valueMap?: Record<string, any>; separator?: string } | optional |
Nested Shape: Mapping.connectorSource
| Property | Type | Required | Description |
|---|---|---|---|
| connector | string | ✅ | Name of the connector instance the rows are pulled from — a connectors[] entry whose provider is rest or openapi (version 1) |
| action | string | ✅ | Key of the connector action that reads the records: request on a rest connector, an operation key on an openapi connector |
| input | Record<string, any> | optional | Fixed input passed to the action on every pull (e.g. { method: 'GET', path: '/contacts' } for rest). Judged against the action's inputSchema before the call, as a connector_action node's input is: a key the action does not declare is refused, never sent — the watermark parameter the pull adds to query included, so an openapi operation that declares any parameter or a body must declare it in its OpenAPI document. An operation that declares neither has no inputSchema and is not judged, until the day it gains its first parameter or a body |
| recordsPath | string | optional | Dot path, within the action's result, to the array of records (e.g. body.results); omitted ⇒ the result's body is the array |
| watermark | { field: string; param: string } | optional | Timestamp-incremental pull; omitted ⇒ every pull reads the full set. Either way a pull makes ONE action call and reads ONE response: the connector's paging is not followed, so a paged endpoint yields its first page only — and an incremental pull over a newest-first paged endpoint moves its starting point past the pages it never read |
| paging | { style: Enum<'page' | 'cursor' | 'offset' | 'none'>; param?: string; nextPath?: string } | optional | The connector's paging convention: page, cursor or offset, or none for a source whose one response is the whole set. Omitted ⇒ a pull reads one response and does not treat it as complete |
| deletePolicy | Enum<'mark' | 'ignore'> | optional | What a pull does with a row the source no longer has: 'mark' stamps the row's source-deleted mark and clears it if the row comes back, 'ignore' leaves the row as it is. Absent reads as 'mark'. A pull never deletes a row physically. A full pull marks only when its read was complete; an incremental pull sees a delete only through deletedField |
| deletedField | string | optional | Source field whose truthy value means the row was deleted at the source — how an incremental pull, which cannot see an absent row, learns of a delete |
Nested Shape: Mapping.datasourceSource
| Property | Type | Required | Description |
|---|---|---|---|
| object | string | ✅ | Name of the federated object (ADR-0015) whose rows the pull reads — an object whose own external binding addresses the remote table, and whose external.columnMap maps the source key onto id |
| watermark | { field: string; start: string | integer } | ✅ | The field the read windows are cut on, and where the first read starts |
| full | boolean | optional | Re-read from watermark.start on every run (a full pull, the one that can mark deletes by absence); omitted ⇒ each run reads on from the position the last run committed |
| deletePolicy | Enum<'mark' | 'ignore'> | optional | What a pull does with a row the source no longer has: 'mark' stamps the row's source-deleted mark and clears it if the row comes back, 'ignore' leaves the row as it is. Absent reads as 'mark'. A pull never deletes a row physically. A full pull marks only when its read was complete; an incremental pull sees a delete only through deletedField |
| deletedField | string | optional | Source field whose truthy value means the row was deleted at the source — how an incremental pull, which cannot see an absent row, learns of a delete |
Nested Shape: Mapping.overrides
| Property | Type | Required | Description |
|---|---|---|---|
| package | string | ✅ | The base package id whose same-named item this item replaces whole (e.g. "com.acme.crm"). Only an item of the base's paired "<base>.custom" package declares an override. |
| basedOn | string | ✅ | Recorded, never a gate: the base package's manifest.version this override was taken from (e.g. "3.2.0"), not a history version of the item. Nothing is refused, merged or rebased on it; it tells a person re-basing the override where it started. One reader, as advice: a base's upgrade plan lists an override whose basedOn is not the installed base version as stale, beside each override whose base item the upgrade changes (ADR-0146 D2, as amended). |
TransformType
Allowed Values
noneconstantlookupsplitjoinjavascriptmap
Hook Body
Hook Body schemas of the ObjectStack Data Protocol: ExpressionBody, HookBody and 2 more — each property with its type, default and a TypeScript example.
Object
Object schemas of the ObjectStack Data Protocol: ApiMethod, ApiOperation, Index and 21 more — each property with its type, default and a TypeScript example.