BeechCMS / @beechcms/core / ISeedRepository
Interface: ISeedRepository
Persistence contract for runtime Seed definitions. Implemented by D1SeedRepository in apps/api/src/shared/seed.repository.d1.ts.
listActive() returns only status='active' rows — this is what the registry is hydrated from. getRegistryVersion / bumpRegistryVersion back the multi-isolate cache token (see docs/Sprints/runtime-seeds/00-overview.md).
Methods
applyAtomic()
applyAtomic(
input):Promise<SeedApplyResult>
Applies additive DDL, the definition upsert and the registry-version bump as ONE transactional batch, guarded by compare-and-swap on seed_meta.registry_version. All-or-nothing: a guard mismatch or a failing statement writes nothing. The DDL strings MUST come from the core planners — this method never generates SQL.
Parameters
input
Returns
Promise<SeedApplyResult>
applyDestructiveAtomic()
applyDestructiveAtomic(
input):Promise<SeedApplyResult>
Applies destructive DDL, the seed-row update or deletion, and the registry-version bump in one OCC-guarded batch. Kept separate from the additive apply contract.
Parameters
input
Returns
Promise<SeedApplyResult>
bumpRegistryVersion()
bumpRegistryVersion():
Promise<number>
Atomically increment and return the new token. Call after any write.
Returns
Promise<number>
get()
get(
slug):Promise<SeedRecord|null>
Single active-or-deleted record by slug, or null.
Parameters
slug
string
Returns
Promise<SeedRecord | null>
getRegistryVersion()
getRegistryVersion():
Promise<number>
Current cache token.
Returns
Promise<number>
hardDelete()
hardDelete(
slug):Promise<void>
Hard-delete (sprint 06): permanently remove the seeds row. The caller is responsible for dropping the backing tables first via ISchemaMutator.
Parameters
slug
string
Returns
Promise<void>
listActive()
listActive():
Promise<Seed[]>
All active seed definitions, ordered by created_at ASC.
Returns
Promise<Seed[]>
listAll()
listAll():
Promise<SeedRecord[]>
Every row including soft-deleted ones (for admin/diff use).
Returns
Promise<SeedRecord[]>
softDelete()
softDelete(
slug):Promise<void>
Soft-delete: set status='deleted'. Table is NOT dropped (additive-only).
Parameters
slug
string
Returns
Promise<void>
upsert()
upsert(
slug,definition,source?):Promise<void>
Insert or replace a definition. Sets source on insert; preserves it on update unless given.
Parameters
slug
string
definition
source?
"code" | "runtime"
Returns
Promise<void>