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<'update' | 'upsert' | '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. Every mode matches on externalId, so a replay finds the row an earlier load wrote instead of inserting it again. On the loads that seed an organization (the boot seed, a seed-replayer replay, the dev hot reload, a package install or upgrade), an ignore or upsert row that landed once and was later deleted is not inserted again; a publish, or a load that names no organization and finds no sole one, keeps no such record, and seed-replayer called with { reseed: true } or the sample-data reseed 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. A locale no dataset of the object names gets none of its locale-scoped rows, unless one is marked fallback: true
fallbacktrueoptionalMarks this locale-scoped dataset as its object's fallback: it also loads for a resolved locale that no other locale-scoped dataset of the same object lists. Requires locale: a dataset with no locale already loads everywhere, and the pair is refused. At most one dataset per object in a load may be marked; with two different marked datasets of one object, none is used as the fallback and the load reports the object, while each still loads for the locales it lists, as an unmarked dataset would (identical copies count once). A load with no locale loads it like every other dataset. Omitted, the dataset loads only for the locales it lists.
dependsOnstring[]optionalObjects (by name) this dataset loads after, for an order no lookup field gives — e.g. a beforeInsert hook that reads another seeded object. Each name adds an edge to the load's dependency graph. The load is refused, writing nothing, when a name is the dataset's own object, is not seeded by another dataset of the same load, or closes a cycle with the other edges. Omitted, the order comes from lookup fields alone.
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' | 'platform'>optionalOrigin of the item (package | org | env-forced | platform).
_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

  • update
  • upsert
  • ignore

On this page