ObjectStackObjectStack

Seed schema — Data Protocol property reference

Seed schemas of the ObjectStack Data Protocol: Seed, SeedColumn, SeedMode — each property with its type, default and a TypeScript example.

Source: packages/spec/src/data/seed.zod.ts

TypeScript Usage

import { SeedSchema, SeedColumnSchema, SeedMode } from '@objectstack/spec/data';
import type { Seed, SeedColumn } from '@objectstack/spec/data';

// Validate data
const result = SeedSchema.parse(data);

Seed

Properties

PropertyTypeRequiredDescription
objectstring✅Target Object Name
externalIdstring | string[]optional (default: "name")Field (or composite list of fields) matched for the uniqueness check
modeEnum<'insert' | 'update' | 'upsert' | 'replace' | 'ignore'>optional (default: "ignore")What a load does with a record whose externalId matches an existing row. ignore (default) is create-only: a missing row is inserted and an existing row is left as it is, so a replay (every boot, a package install or upgrade, a publish) never writes a seeded value back over a later edit. upsert also writes every declared column back onto the matched row on each replay; declare it for reference data the package keeps current. update writes matched rows only, insert inserts every record with no match, so each replay inserts them again, and replace does the same and deletes nothing: it is for a table the caller cleared. On the loads AppPlugin runs for an organization (the boot seed, the seed-replayer replay, the dev hot reload), an ignore or upsert row that landed once and was later deleted is not inserted again; a publish or package install keeps no such record, and seed-replayer called with { reseed: true } inserts every missing row.
columnsRecord<string, { applyOn?: Enum<'create' | 'always'> }>optionalPer-column write policy, keyed by field name: { status: { applyOn: 'create' } } writes status only when the seed creates the row. Omitted, every column is written on create and update.
envEnum<'prod' | 'dev' | 'test'>[]optional (default: ["prod","dev","test"])Applicable environments
localestring[]optionalApplicable locales (BCP-47 tags); omitted applies to every locale. The boot seed filters on the app's i18n.defaultLocale; the marketplace install, sample-data reseed, restart heal and per-organization replay filter on the locale resolved for the load (the localization.locale setting when set, then the locale of the installing, reseeding or founding user, then the app's i18n.defaultLocale where the load names one); package apply and draft publish do not filter by locale — they load every dataset and warn
recordsRecord<string, any>[]✅Data records
filesRecord<string, { contentType: string; size: integer; sha256: string; data: string }>optionalBytes of the package files the records name with seedFile(path), keyed by path. Written by os build, which reads each path relative to the package root; the loader stores each one as a file the written record owns.
_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: Seed.columns[string]

PropertyTypeRequiredDescription
applyOnEnum<'create' | 'always'>optional (default: "always")When a seed load writes this column. always (default) writes it on every row the load creates or updates. create writes it only when the load creates the row: an upsert replay that matches an existing row leaves the row's value as it is, and an update dataset never writes it, so replaying the seed refreshes the always columns without reverting state the app wrote since the first load. A column of the dataset's externalId is still matched on and stays in the matched row's update. The same values and meaning as an import mapping entry's applyOn.

Nested Shape: Seed.files[string]

One bundled seed file: its bytes and what they must hash to

PropertyTypeRequiredDescription
contentTypestring✅MIME type the stored file carries
sizeinteger✅Byte length of the file
sha256string✅SHA-256 of the bytes, lowercase hex — the loader refuses bytes that do not match it
datastring✅The bytes, base64-encoded

SeedColumn

Properties

PropertyTypeRequiredDescription
applyOnEnum<'create' | 'always'>optional (default: "always")When a seed load writes this column. always (default) writes it on every row the load creates or updates. create writes it only when the load creates the row: an upsert replay that matches an existing row leaves the row's value as it is, and an update dataset never writes it, so replaying the seed refreshes the always columns without reverting state the app wrote since the first load. A column of the dataset's externalId is still matched on and stays in the matched row's update. The same values and meaning as an import mapping entry's applyOn.

SeedMode

Allowed Values

  • insert
  • update
  • upsert
  • replace
  • ignore

On this page