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)
labelstringoptional
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
_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'>optionalOrigin of the item (package | org | env-forced).
_packageIdstringoptionalOwning package machine id.
_packageVersionstringoptionalOwning package version.
_lockDocsUrlstringoptionalOptional documentation link surfaced next to _lockReason.

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)
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

TransformType

Allowed Values

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

On this page