Skip to content

Commit d10f652

Browse files
feat(spec, metadata-protocol): a seed dataset can declare dependsOn, the objects it loads after (#34276)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbKnsd8ZLsq9hBbRRm5JvJb2)_ Fixes #33812 Clause-②: yes (widening) Metadata-protocol: added Skills-docs: follow-up #34277 — `skills/objectstack-data/references/seeds.md` (its relationship section and its best-practice table tell the author to order seeds parent before child in the exported array, which orders nothing; `dependsOn` is not taught) ## 维护者速读 - 改了什么:种子数据集新增 `dependsOn`(填对象名),加载器把它当作依赖边并入与 lookup 字段同一张依赖图;声明成环、指向本次加载未装载的对象、或指向自身时,整次加载拒绝,一行不写。 - 为什么改:加载器只认 lookup 边,一个 beforeInsert 钩子要读另一种子对象的数据集没法排到它之后(blackcat-crm 的评分在评分档之前写入,全部算成 0 分)。维护者裁定「新增 dependsOn 显式声明」。 - 风险与回滚:不写 `dependsOn` 的应用顺序逐字节不变(有对照测试钉住);拒绝只发生在写了该键的数据集上。单租户启动种子被拒时,启动横幅 `Seeds:` 行标警告、`seed-settled` 消息报 `ok: false`,不再看似干净。单独发布的种子草稿是一次独立加载,其 `dependsOn` 指向别的条目时会被拒绝,需一起发布(见 Acceptance notes)。回滚即撤销本 PR。 - 先看:`packages/metadata-protocol/src/seed-loader.ts`(`collectDeclaredDependencies`、`findDeclaredEdgeCycles`、`orderByDeclaredEdges`、`loadDatasets` 中的拒绝分支);`packages/spec/src/data/seed.zod.ts`(新键与 `defineSeed` 自依赖拒绝);`packages/runtime/src/app-plugin.ts`(启动种子把整次被拒计入 rejected)。 - 两分钟验证:`pnpm --filter @objectstack/metadata-protocol exec vitest run src/seed-loader-depends-on-33812.test.ts`,预期 12 个用例全绿;其中声明 dependsOn 的评分钩子看到 2 个评分档,对照组看到 0 个。 - 需要你做的:无,席位落地(新 spec 键需 L2 契约复审,席位已申请)。 ## What changes - **`Seed.dependsOn: string[]`** (`packages/spec/src/data/seed.zod.ts`): the objects a dataset loads after, by object name, for an order no lookup field gives (most often a `beforeInsert` hook that reads another seeded object). Optional, no default; each item is held to the object machine-name pattern. `defineSeed` refuses a dataset that names its own object when it runs. - **The seed loader** (`packages/metadata-protocol/src/seed-loader.ts`): each name becomes an edge in the graph the lookup fields already feed (`buildDependencyGraph` gains an optional `declared` map; the `ISeedLoaderService` contract signature is unchanged), so `topologicalSort` and `orderDatasets` put the dataset after the named object. Declarations of several datasets of one object are pooled. Objects left over after the Kahn pass (behind a lookup cycle) are appended in an order that keeps the declared edges; with none declared the append order is the old one. - **Refusals, before any row is written.** A load whose declarations it cannot honour answers `success: false`, `results: []`, and one `errors[]` entry per refused declaration (`field: 'dependsOn'`, `sourceObject` the declaring object, `targetObject` the named one, `targetField: '(dataset)'`). Three cases: the dataset's own object; a name no dataset of the same load seeds (the message says when the named object's datasets were all scoped out by `env` or `locale`); and a declared edge that closes a cycle. The refusal is RETURNED, not thrown, so every caller reports it as a failed load; a throw would have sent the single-tenant boot seed into AppPlugin's basic-insert fallback, which writes every row in authored order. - **The cycle rule, precisely:** a declared edge `A dependsOn B` is refused when B already depends on A through any chain of edges, lookup or declared (self-references excluded, as the sort excludes them); equivalently, the edge lies on a cycle of the combined graph. A cycle made of lookup edges alone is untouched and still loads in deferred passes. - **A refused boot seed reads as a failed seed** (`packages/runtime/src/app-plugin.ts`). The single-tenant boot seed records its outcome for the banner's `Seeds:` line and the `objectstack:seed-settled` message (`recordSeedOutcome`). A refused load writes no row and leaves every row counter at zero, so from the counters alone the source was dropped from the `Seeds:` line and the message answered `ok: true`. The boot seed now counts each error of a load refused before any dataset ran (`success: false` with no results) as a rejected row, the same failure shape the marketplace heal already records (`rejected: summary.errors`); the CLI channels then show the source with a warning and answer `ok: false`. A load that ran keeps its per-dataset counts unchanged. - **CLI, no behaviour change:** `composeSeedSettledMessage` moves out of `packages/cli/src/commands/serve.ts` into `packages/cli/src/utils/seed-settled-message.ts` (re-exported from `serve.ts`), so the new test reaches it without importing the serve command; `packages/cli/src/commands` holds only command modules. - **Ledger, docs, generated artifacts:** `packages/spec/liveness/seed.json` gains a `live` `dependsOn` row (evidence anchored on the three loader symbols, the runtime proof named in its note); `content/docs/data-modeling/seed-data.mdx` gains a "Load Order — `dependsOn`" section and stops saying the array order is the load order, and says that the dev hot-reload seeder and a marketplace install load only part of an app's seeds and refuse the same way; the ObjectDependencyNode TSDoc names the declared edges; `check:generated --fix` regenerated the reference pages (`seed`, `seed-loader`, `package-api`, `manifest`), `authorable-surface/data.json` and `liveness/state-counts/seed.md`. ## Tests - `packages/metadata-protocol/src/seed-loader-depends-on-33812.test.ts` (12 cases): the card's shape (a rating that looks up its rule only, bands two master_detail hops below the rule, the fake engine stamping each rating with the band count it sees at insert time); the no-`dependsOn` control pinning today's exact order; pooled declarations; a dataset downstream of a lookup cycle; the four refusals (lookup-closed cycle, declared-only cycle, own object, unknown name, env-scoped-out name), a scoped-out dataset that is not judged, the lookup-only cycle control, and the dry run. - `packages/spec/src/data/seed.test.ts` (6 cases added beside the other `SeedSchema` pins): the key parses and is kept, stays absent when omitted, refuses a non-machine name and a bare string; `defineSeed` carries it and refuses the own-object case. - `packages/cli/src/commands/serve-seed-refused-load-33812.test.ts` (2 cases): AppPlugin's real boot seed and SeedLoaderService over an in-memory engine double, then the `seed-summary` service as the CLI reads it, the settled message and the banner line. A load refused by `dependsOn: ['no_such_object']` writes nothing, records `rejected > 0`, answers `ok: false` and prints `⚠ Seeds: … refused_load_app`; the control, the same boot with a load that succeeds, writes 2 rows, answers `ok: true` and prints `refused_load_app 2 rows` with no warning. - `packages/qa/dogfood/test/seed-depends-on-33812.dogfood.test.ts` (3 cases, ADR-0054 runtime proof): a real stack boot whose sandboxed `beforeInsert` hook counts seeded bands, read back over REST: the rating declaring `dependsOn` sees 2, the same rating without it sees 0. <details><summary>Red first, then green (head 4575480)</summary> - Red on the base loader (`aab8b3188a` blob of `seed-loader.ts` swapped in, restored to the HEAD blob `eb0ca78055f4`, hash-checked): `Tests 9 failed | 3 passed (12)`; the card case failed on `expected 3 to be less than 2` (bands inserted after the rating). The three that stayed green are the controls: no-`dependsOn` order, lookup-only cycle, scoped-out dataset not judged. - Green: `pnpm --filter @objectstack/metadata-protocol test` `Test Files 345 passed | 9 skipped (354)`, `Tests 22958 passed | 45 skipped`; `typecheck` exit 0. - `pnpm --filter @objectstack/spec test` `Test Files 845 passed (845)`, `Tests 27011 passed | 1 todo`; `typecheck` exit 0. - Dogfood: `seed-depends-on-33812.dogfood.test.ts` 3/3; with `seed-external-id-refusal`, `showcase-verify-seed`, `meta-types-create-seed` 4 files, 15/15 (at `0d4aeb9798`, before the main merge). - Not run locally, declared to CI: spec `test:repo`; the full dogfood battery (no `!`, no narrowing arm); the `cloud-connection` suite, a caller of the loader: the contract signature it compiles against is unchanged (the `runtime` suite ran in round 2, below). </details> <details><summary>Round 2: the refused boot seed (head a0e2353; code at b0cd771)</summary> - Head `a0e2353145` only adds `'@objectstack/cli': minor` to the changeset (the cli diff moves, and a non-`none` kind takes `minor` on every moved package); the code and tests are byte-identical to `b0cd771c69`, where CI was 58 success, 10 skipped. - New test green: `serve-seed-refused-load-33812.test.ts` `Tests 2 passed (2)`. - Red first and the one ablation, in one step: the new count was removed at `dist/` (`rejected: totalErrored + refusedLoad` swapped for a zero-length planted marker, which is the pre-fix count; `ablation-dist-preflight` marker present in `dist/index.js` and `index.cjs`). Result: `Tests 1 failed | 1 passed (2)`, the refused case red on `expected 0 to be greater than 0`, the control green. The source was restored to the HEAD blob `d8a3078d1c71` (`git diff HEAD` empty), runtime rebuilt, the marker `--absent` from all 12 built files, tree clean, and the test green again (2/2). - `pnpm --filter @objectstack/runtime test`: `Test Files 607 passed (607)`, `Tests 11089 passed | 19 skipped`; `typecheck` exit 0. - `pnpm --filter @objectstack/cli exec vitest run --project unit`: `Test Files 2 failed | 422 passed (424)`, `Tests 5983 passed | 29 skipped`. The two failed suites are `test/published-subpath-console.pin.test.ts` and `test/published-subpath-hook-body.pin.test.ts`, both at setup on `packages/cli is not built (./dist/index.js is absent)`: only the cli's dependency closure had been built, not the cli. They are NOT MEASURED locally; CI (which builds the cli) is green at `b0cd771c69`. The cli `typecheck` exit 0. The integration tier is declared to CI. - `pnpm --filter @objectstack/metadata-protocol test`: `Test Files 345 passed | 9 skipped (354)`, `Tests 22958 passed | 45 skipped`. - `packages/spec` `src/data/seed.test.ts`: `Tests 40 passed (40)`; spec `typecheck` exit 0. - `check:engine-double-contract`: on the first CI run the new cli test's double was not in the ledger. `--write` added its `findOne` and `update` rows to `scripts/engine-double-contract.pinned.json`, and the rerun exited 0. - `check:test-source-alias` exit 0 (the test reaches the helper through `utils/`, not through `serve.ts`). - `check:cli-command-ids` exit 0: `97 module(s) under packages/cli/src/commands examined`. - dispatch-gates at `b0cd771c69` derived 130 families. Local sweep: 112 of 130 families ran before it was stopped to hand this body over (the other 18 are NOT MEASURED locally; CI runs them); every one that ran exited 0 except five that exited 3 (`PREREQUISITE NOT MET`, NOT MEASURED, because their `dist` was not built locally): `check:i18n`, `check:i18n-coverage`, `check:i18n-walk-parity` (they need the cli `dist`), the spec `check:skill-examples` (needs the client `dist`), and `check:dual-build-cjs-loads` (needs a full build). The derivation warns that the tree is 22 commits behind origin/main. CI at `b0cd771c69` is 58 success, 10 skipped. </details> <details><summary>Ablations (each restored to the HEAD blob, `git diff HEAD` empty)</summary> All through `scripts/ablation-replace.mjs`: - Declared edges never join the graph: 4 red (the card, pooled declarations, downstream of a lookup cycle, declared-only cycle). - The same at `dist/` for the dogfood proof (`ablation-dist-preflight` marker present, then `--absent` after the restore and rebuild, tree clean): the card case red, `expected +0 to be 2`; the control stayed green. - Cycle refusal removed: 2 red (both cycle cases). - Unknown-name refusal removed: 3 red (unknown name, scoped-out name, dry run). - Leftover-node ordering removed: 1 red (downstream of a lookup cycle). - Own-object guard removed: stays GREEN. The case is still refused as a one-object cycle (see Acceptance notes). - `defineSeed` own-object refusal removed: 1 red. </details> <details><summary>Gate families (derived by dispatch-gates at 94efc9d, reconciled at 4575480)</summary> - `node scripts/pm/dispatch-gates.mjs --ran`: `123 derived famil(ies) accounted for — 122 run, 1 NOT-MEASURED`. - NOT MEASURED: `check:dual-build-cjs-loads`, reason: exit 3, it needs every package's `dist` (a full workspace build). CI runs it. - `check:engine-double-contract` exit 1 on the first pass: the new test's double was not in the pinned ledger. `--write` recorded it (`scripts/engine-double-contract.pinned.json`, 3 rows); rerun on 4575480: `OK — 1327 pinned`. - `check:generated` found `check:docs` and `check:liveness` stale; `--fix` regenerated both and re-checked them green. `check:authorable-surface` green. - Every other family: exit 0. `check:nul-bytes` exit 0. - `git merge-tree --write-tree HEAD origin/main` exit 0 (origin/main 9 commits ahead, no overlap). </details> ## Acceptance notes - **Files outside the claimed surface, added in round 2 for the L2 finding:** `packages/runtime/src/app-plugin.ts` (the refused-load count), `packages/cli/src/commands/serve.ts` and `packages/cli/src/utils/seed-settled-message.ts` (the helper move, no behaviour change), `packages/cli/src/commands/serve-seed-refused-load-33812.test.ts` (the pin and its control) and `scripts/engine-double-contract.pinned.json` (its double's ledger rows). The changeset names `@objectstack/runtime` minor for the visible change and `@objectstack/cli` minor for the moved helper. - **"Same load" is the request the loader is handed.** The boot seed and the per-organization replay load every dataset of the app (the replay, every installed package's), so a `dependsOn` across them resolves. A draft publish loads only the bodies being published, so a published seed whose `dependsOn` names an object seeded by another item is refused until both are published together; the changeset and the docs page say so. This is the ruling applied literally; whether a publish should judge against already-landed rows instead is raised as an open question in the report, not decided here. - **A declared edge that a deferred lookup could have satisfied is still refused.** Lookup edges are deferrable (the row is written and its reference filled in later), so `A dependsOn B` while B looks up A is orderable in principle; the ruling refuses any cycle a declared edge closes, and so does this PR. - **`errors[].recordIndex` is 0 on a refusal.** The error schema requires a non-negative row index and a refusal belongs to the dataset, not to a row; `field: 'dependsOn'` and `targetField: '(dataset)'` mark it. Widening the error shape is a contract change and not part of this card. - **The ledger row carries no `proof` field.** The ADR-0054 `proof` form needs the dogfood file's `@proof:` tag registered in `packages/spec/scripts/liveness/proof-registry.mts`, whose classes are the high-risk list of ADR-0054 §2a; seed ordering is in none of them and that file is outside this card's surface. The dogfood proof is named in the row's note. - **The own-object guard is redundant with the cycle rule** (observed by ablation: disabling it leaves the case refused, as a one-object cycle). It stays for its clearer message and because `defineSeed` refuses the same case at call time. - **Marketplace purge and sample-data scope** call `buildDependencyGraph(objectNames)` without declared edges, so their (reverse) order ignores `dependsOn`; that path deletes rows and the key is about insert-time reads, so nothing there is wrong today. Noted only. ## Verification Hypotheses from the dispatch, each measured: - H1 held: on the base loader the card shape is red (rating inserted at index 2, bands at 3; the hook saw 0 bands). - H2 held: the declared edge joins `buildDependencyGraph`'s node `dependsOn`, `topologicalSort` orders by it, and authored order stays the Kahn tie-break. - H3 held: lookup-only cycles still resolve by deferred passes. Rule as built: a declared edge is refused when its target already depends on its declarer through any chain of edges (it lies on a cycle of the combined graph). - H4: refusals sit at load time, plus `defineSeed` at call time for the one case a dataset can be judged on alone (its own object). The set of objects in the same load exists only at load time: `env` and `locale` filtering, several packages in one replay, and a draft publish's one-item load all change it after authoring. - H5: `Metadata-protocol: added` takes `minor` on every moved published package (`@objectstack/spec`, `@objectstack/metadata-protocol`, `@objectstack/runtime`, `@objectstack/cli`) per AGENTS.md Post-Task step 3; the private dogfood package carries no changeset. Session: https://claude.ai/code/session_01QsR2jUg7BKfRBcTPyMxbLh 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 803f909 commit d10f652

20 files changed

Lines changed: 1061 additions & 32 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/metadata-protocol': minor
4+
'@objectstack/runtime': minor
5+
'@objectstack/cli': minor
6+
---
7+
8+
feat(spec, metadata-protocol): a seed dataset can declare `dependsOn`, the objects it loads after, for an order no lookup field gives
9+
10+
Clause-②: yes (widening)
11+
Metadata-protocol: added
12+
Skills-docs: follow-up #34277 — `skills/objectstack-data/references/seeds.md` (its relationship section and its best-practice table tell the author to order seeds parent before child in the exported array, which orders nothing; `dependsOn` is not taught)
13+
14+
The seed loader orders a load's datasets by the `lookup`, `master_detail` and `user` fields between their objects; the order of the stack's `data` array only breaks ties. A dataset whose `beforeInsert` hook reads another seeded object had no way to say so, and its hook ran against whatever that object held at the moment, which an unrelated dataset could change. A rating scored from seeded bands, ordered by its one lookup to its rule, was written a wave before the bands and scored every row as if none existed.
15+
16+
- **`Seed.dependsOn: string[]` names objects.** Each name adds an edge to the same dependency graph the lookup fields feed, so the dataset's object loads after the named object's rows: `defineSeed(CustomerRating, { dependsOn: ['crm_rating_band'], records })`. The edges of several datasets of one object are pooled onto that object, and the returned `dependencyGraph.nodes[].dependsOn` lists them beside the lookup edges.
17+
- **A load that declares none keeps its order exactly.** Nothing changes for an app that does not write the key.
18+
- **A declaration the load cannot honour refuses the whole load, before any row is written.** The load answers `success: false` with one `errors[]` entry per refused declaration (`field: 'dependsOn'`, `sourceObject` the declaring object, `targetObject` the named one), and every caller reports it the way it reports any failed load. Three cases: a name that is the dataset's own object; a name no other dataset of the same load seeds (a misspelling, or an object whose datasets `env` or `locale` scoped out of this load, which the message says); and a declared edge that closes a cycle with the other edges, lookups included, with the cycle spelled out object by object. A cycle made of lookup fields alone still loads in deferred passes, as before.
19+
- **A refused boot seed reads as a failed seed.** The single-tenant boot seed (`AppPlugin`) counts each error of a load refused before any dataset ran as a rejected row in the outcome it records, so `os dev` / `os serve` print the source with a warning on the banner's `Seeds:` line and the `objectstack:seed-settled` message answers `ok: false`; before, a refused load wrote nothing and read clean on both.
20+
- **`defineSeed` refuses a dataset that names its own object** when it runs. The other two cases need the whole load, so only the loader can judge them.
21+
22+
A seed published on its own (a draft publish) is its own load, so a published seed whose `dependsOn` names an object seeded by another item is refused until the two are published together.

‎content/docs/data-modeling/seed-data.mdx‎

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ const contactsSeed = defineSeed(Contact, {
457457
],
458458
});
459459

460-
// Export in dependency order — parents before children
460+
// The loader puts accounts first because `contact.account` looks them up
461461
export const SeedData = [accountsSeed, contactsSeed];
462462
```
463463

@@ -539,6 +539,56 @@ duplicates on every replay boot ([#3434](https://github.com/objectstack-ai/objec
539539

540540
---
541541

542+
## Load Order — `dependsOn`
543+
544+
A load orders its datasets by the relationships between their objects: a `lookup`,
545+
`master_detail` or `user` field makes its object load after the object it points
546+
at, however the datasets are listed. The order of your `data` array only breaks
547+
ties between objects that are ready at the same moment.
548+
549+
Some dependencies are not fields. A `beforeInsert` hook that **reads** another
550+
seeded object while a row is written (a rating scored from seeded bands, a price
551+
computed from a seeded rate table) needs those rows to be there first, and no
552+
lookup says so. Declare it with `dependsOn`, naming the objects:
553+
554+
```typescript
555+
export const ratingBandsSeed = defineSeed(RatingBand, {
556+
externalId: 'code',
557+
records: [/* … */],
558+
});
559+
560+
// The rating's beforeInsert hook scores each row from crm_rating_band rows,
561+
// so this dataset must load after them.
562+
export const customerRatingsSeed = defineSeed(CustomerRating, {
563+
dependsOn: ['crm_rating_band'],
564+
records: [/* … */],
565+
});
566+
```
567+
568+
Each name adds an edge to the same dependency graph the lookup fields feed. A
569+
dataset that declares no `dependsOn` loads exactly where its lookups put it.
570+
571+
The loader refuses the **whole load**, writing no row, and reports why, when a
572+
`dependsOn`:
573+
574+
- names the dataset's own object (`defineSeed` also refuses this when it runs);
575+
- names an object no other dataset of the same load seeds: a misspelling, or a
576+
dataset that `env` or `locale` scoped out of this load. A seed published on its
577+
own is its own load, so publish it together with the seeds it depends on. Two
578+
more loads carry only part of an app's seeds and refuse the same way: the dev
579+
hot-reload seeder loads only the datasets of objects first seen in that reload,
580+
so restart the dev server after adding a seed that depends on an object seeded
581+
earlier, and a marketplace install loads one package's datasets, so name only
582+
objects your own package seeds;
583+
- closes a cycle with the other edges, lookups included: `crm_rating_rule`
584+
declaring `dependsOn: ['crm_customer_rating']` while the rating looks up its
585+
rule. No order can keep that edge.
586+
587+
A cycle made only of lookup fields is still loaded in several passes (each row is
588+
written first and its missing reference filled in afterwards), as before.
589+
590+
---
591+
542592
## File Fields — `seedFile(path)`
543593

544594
A `file`, `image`, `avatar`, `video` or `audio` field stores the id of a stored
@@ -705,11 +755,11 @@ import { contactsSeed } from './contacts.seed';
705755
import { leadsSeed } from './leads.seed';
706756
import { productsSeed } from './products.seed';
707757

708-
/** All seed datasets — order determines load sequence */
758+
/** All seed datasets — the loader orders them by their lookups and dependsOn */
709759
export const SeedData = [
710760
accountsSeed, // no dependencies
711761
productsSeed, // no dependencies
712-
contactsSeed, // depends on accounts
762+
contactsSeed, // looks up accounts, so it loads after them
713763
leadsSeed, // no dependencies
714764
];
715765
```
@@ -753,10 +803,12 @@ when the use case requires it — `upsert` for reference data the package keeps
753803
(with `applyOn: 'create'` on the columns the customer or a job owns), or `replace`
754804
for ephemeral cache tables.
755805

756-
### Seed in dependency order
806+
### Declare a dependency no field expresses
757807

758-
Always export parent datasets before child datasets. If `contact` has a lookup to
759-
`account`, `accountsSeed` must appear before `contactsSeed` in the exported array.
808+
Lookup fields order the load for you: if `contact` has a lookup to `account`,
809+
accounts load first wherever `accountsSeed` sits in the array. Listing parents
810+
first keeps the file readable, but it orders nothing. When a hook reads another
811+
seeded object, declare it with `dependsOn` (see "Load Order").
760812

761813
### Keep records realistic
762814

@@ -783,6 +835,7 @@ function defineSeed<
783835
columns?: { [field: string]: { applyOn?: 'create' | 'always' } }; // per-column write policy; default: 'always'
784836
env?: Array<'prod' | 'dev' | 'test'>; // default: ['prod','dev','test']
785837
locale?: string[]; // BCP-47 tags; omitted = every locale
838+
dependsOn?: string[]; // objects this dataset loads after (see "Load Order")
786839
records: Array<SeedRecord<TObj['fields']>>; // declared fields + injectable system columns
787840
}
788841
): Seed

‎content/docs/references/api/package-api.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ Package manifest installed through POST /api/v1/packages (AUTHORING stage; scope
247247
| **columns** | `Record<string, { applyOn?: Enum<'create' \| 'always'> }>` | optional | Per-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. |
248248
| **env** | `Enum<'prod' \| 'dev' \| 'test'>[]` | optional (default: `["prod","dev","test"]`) | Applicable environments |
249249
| **locale** | `string[]` | optional | Applicable 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 |
250+
| **dependsOn** | `string[]` | optional | Objects (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. |
250251
| **records** | `Record<string, any>[]` | ✅ | Data records |
251252
| **files** | `Record<string, { contentType: string; size: integer; sha256: string; data: string }>` | optional | Bytes 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. |
252253
| **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). |
@@ -355,6 +356,7 @@ Package manifest installed through POST /api/v1/packages (AUTHORING stage; scope
355356
| **columns** | `Record<string, { applyOn?: Enum<'create' \| 'always'> }>` | optional | Per-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. |
356357
| **env** | `Enum<'prod' \| 'dev' \| 'test'>[]` | optional (default: `["prod","dev","test"]`) | Applicable environments |
357358
| **locale** | `string[]` | optional | Applicable 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 |
359+
| **dependsOn** | `string[]` | optional | Objects (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. |
358360
| **records** | `Record<string, any>[]` | ✅ | Data records |
359361
| **files** | `Record<string, { contentType: string; size: integer; sha256: string; data: string }>` | optional | Bytes 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. |
360362
| **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). |

‎content/docs/references/data/seed-loader.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ Seed loader request with datasets and configuration
234234
| **columns** | `Record<string, { applyOn?: Enum<'create' \| 'always'> }>` | optional | Per-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. |
235235
| **env** | `Enum<'prod' \| 'dev' \| 'test'>[]` | optional (default: `["prod","dev","test"]`) | Applicable environments |
236236
| **locale** | `string[]` | optional | Applicable 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 |
237+
| **dependsOn** | `string[]` | optional | Objects (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. |
237238
| **records** | `Record<string, any>[]` | ✅ | Data records |
238239
| **files** | `Record<string, { contentType: string; size: integer; sha256: string; data: string }>` | optional | Bytes 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. |
239240
| **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). |

‎content/docs/references/data/seed.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const result = SeedSchema.parse(data);
3434
| **columns** | `Record<string, { applyOn?: Enum<'create' \| 'always'> }>` | optional | Per-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. |
3535
| **env** | `Enum<'prod' \| 'dev' \| 'test'>[]` | optional (default: `["prod","dev","test"]`) | Applicable environments |
3636
| **locale** | `string[]` | optional | Applicable 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 |
37+
| **dependsOn** | `string[]` | optional | Objects (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. |
3738
| **records** | `Record<string, any>[]` | ✅ | Data records |
3839
| **files** | `Record<string, { contentType: string; size: integer; sha256: string; data: string }>` | optional | Bytes 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. |
3940
| **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). |

‎content/docs/references/kernel/manifest.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ Install mode: managed (registered as code, upgradeable, sealed) | unmanaged (cop
101101
| **columns** | `Record<string, { applyOn?: Enum<'create' \| 'always'> }>` | optional | Per-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. |
102102
| **env** | `Enum<'prod' \| 'dev' \| 'test'>[]` | optional (default: `["prod","dev","test"]`) | Applicable environments |
103103
| **locale** | `string[]` | optional | Applicable 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 |
104+
| **dependsOn** | `string[]` | optional | Objects (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. |
104105
| **records** | `Record<string, any>[]` | ✅ | Data records |
105106
| **files** | `Record<string, { contentType: string; size: integer; sha256: string; data: string }>` | optional | Bytes 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. |
106107
| **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). |

0 commit comments

Comments
 (0)