Seeds
A seed is a file in a Frond's seeds/ directory, run at startup after migration. It
receives resolve and calls the same façades as the application.
// fronds/blog/seeds/Post.seed.ts
type Facade = Record<string, (inv?: Record<string, unknown>) => Promise<any>>;
export default async (resolve: <T>(name: string) => T) => {
const posts = resolve<Facade>('post');
// This seed runs only when the database is empty.
const existing = await posts.list();
if (existing.length > 0) return [];
const created = await posts.create({
params: {}, query: {},
body: { slug: 'hello', title: 'Hello', body: '…' },
state: { user: { id: 'seed-author' } }, // identity used by the seed
});
// The transition uses the publish operation.
await posts.publish({ params: { id: created.id }, query: {}, body: undefined,
state: { user: { id: 'seed-author' } } });
return []; // nothing left for the boot loop
};
The contract
- Export:
default async (resolve) => rows[]. Returning[]means "done here". resolve('<entity>')returns the entity's façade — each operation takes a full invocation{ params, query, body, state }.stateis set by the seed: because it runs server-side, it can provide the identity expected by operations. Thepublishcall above therefore still performs its author check.- Idempotence is the seed's responsibility; the guard is one
list()+ early return.
Going through the façade applies the same validation, lifecycle rules, and errors used by application calls.
Next: Queries & commands — the client couple.