ObjectStackObjectStack

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

PropertyTypeRequiredDescription
sourcestring | string[]✅Source column header(s)
targetstring | 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
transformEnum<'none' | 'constant' | 'lookup' | 'split' | 'join' | 'javascript' | 'map'>optional (default: "none")
params{ value?: any; valueMap?: Record<string, any>; separator?: string }optional

Mapping

Properties

PropertyTypeRequiredDescription
namestring✅Mapping unique name (lowercase snake_case)
labelstringoptionalDisplay label, shown where the mapping is offered by name (the import wizard); translated per locale at mappings.<name>.label in the translation bundle
sourceFormatEnum<'csv' | 'json' | 'xml' | 'sql'>optional (default: "csv")
targetObjectstring✅Target Object Name
fieldMapping{ source: string | string[]; target: string | string[]; transform?: Enum<'none' | 'constant' | 'lookup' | 'split' | 'join' | 'javascript' | 'map'>; params?: object }[]✅
modeEnum<'insert' | 'update' | 'upsert'>optional (default: "insert")
upsertKeystring[]optionalFields to match for upsert (e.g. email)
connectorSource{ connector: string; action: string; input?: Record<string, any>; recordsPath?: string; … }optionalPull 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'>; … }optionalPull 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
_lockEnum<'none' | 'no-overlay' | 'no-delete' | 'full'>optionalItem-level lock — controls overlay & delete (ADR-0010).
_lockReasonstringoptionalHuman-readable reason shown when a write is refused by _lock.
_lockSourceEnum<'artifact' | 'package' | 'env-forced'>optionalLayer that set _lock (artifact | package | env-forced).
_provenanceEnum<'package' | 'org' | 'env-forced' | 'platform'>optionalOrigin of the item (package | org | env-forced | platform).
_packageIdstringoptionalOwning package machine id.
_packageVersionstringoptionalOwning package version.
_lockDocsUrlstringoptionalOptional documentation link surfaced next to _lockReason.
overrides{ package: string; basedOn: string }optionalOverride 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]

PropertyTypeRequiredDescription
sourcestring | string[]✅Source column header(s)
targetstring | 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
transformEnum<'none' | 'constant' | 'lookup' | 'split' | 'join' | 'javascript' | 'map'>optional (default: "none")
params{ value?: any; valueMap?: Record<string, any>; separator?: string }optional

Nested Shape: Mapping.connectorSource

PropertyTypeRequiredDescription
connectorstring✅Name of the connector instance the rows are pulled from — a connectors[] entry whose provider is rest or openapi (version 1)
actionstring✅Key of the connector action that reads the records: request on a rest connector, an operation key on an openapi connector
inputRecord<string, any>optionalFixed 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
recordsPathstringoptionalDot 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 }optionalTimestamp-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 }optionalThe 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
deletePolicyEnum<'mark' | 'ignore'>optionalWhat 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
deletedFieldstringoptionalSource 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

PropertyTypeRequiredDescription
objectstring✅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
fullbooleanoptionalRe-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
deletePolicyEnum<'mark' | 'ignore'>optionalWhat 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
deletedFieldstringoptionalSource 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

PropertyTypeRequiredDescription
packagestring✅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.
basedOnstring✅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

  • none
  • constant
  • lookup
  • split
  • join
  • javascript
  • map

On this page