@lunora/seed 1.0.0-alpha.13 → 1.0.0-alpha.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,78 +0,0 @@
1
- import { Schema } from '@lunora/server';
2
- /**
3
- * The pure, I/O-free core of seeding. {@link seedPlan} introspects a schema,
4
- * generates rows table-by-table in foreign-key order, and resolves every
5
- * `v.id("parent")` column to a real id of an already-generated parent row. The
6
- * result feeds every adapter (test harness, CLI, studio) — none of them
7
- * re-implement generation.
8
- *
9
- * Determinism: a `seed` value selects the global copycat mapping, and each value
10
- * is hashed from `[seed, table, index, field]`, so the same `(schema, options)`
11
- * always yields byte-identical rows.
12
- */
13
- /** A row context handed to an override function. */
14
- interface OverrideContext {
15
- field: string;
16
- /** The row's absolute index (the `indexOffset` base plus its position in this batch). */
17
- index: number;
18
- /** The row built so far (system `_id` first, then earlier fields). */
19
- row: Record<string, unknown>;
20
- /**
21
- * A live, read-only view of every table's rows generated so far this run,
22
- * keyed by table name. Lets an override correlate across tables (e.g. copy a
23
- * field from the parent row a foreign key points at). Rows for the current
24
- * table accumulate as they are built, so only earlier rows are visible.
25
- */
26
- store: Readonly<Record<string, ReadonlyArray<Record<string, unknown>>>>;
27
- table: string;
28
- }
29
- /**
30
- * Per-table, per-field overrides. Each override is a static value or a function
31
- * of the row context; field `_id` overrides the generated primary key.
32
- */
33
- type SeedOverrides = Record<string, Record<string, unknown>>;
34
- /** Per-table row counts. */
35
- type SeedCounts = Record<string, number>;
36
- interface SeedOptions {
37
- /** Rows per table; falls back to {@link SeedOptions.defaultCount} when a table is absent. */
38
- counts?: SeedCounts;
39
- /** Count used for any selected table not present in `counts` (default `10`). */
40
- defaultCount?: number;
41
- /**
42
- * Ids of rows that already exist in the target store, keyed by table. Foreign
43
- * keys may resolve to these in addition to freshly-seeded parents, and a
44
- * parent table fully covered here is not re-seeded when it is only pulled in
45
- * as an FK dependency (it is when named explicitly in `only`).
46
- */
47
- existingIds?: Readonly<Record<string, ReadonlyArray<string>>>;
48
- /**
49
- * Per-table absolute index base for generation. Defaults to `0`. A client
50
- * seeding the same table across several calls passes the running total so
51
- * each batch hashes from fresh indices and never collides ids with an
52
- * earlier batch.
53
- */
54
- indexOffset?: Readonly<Record<string, number>>;
55
- /**
56
- * Restrict seeding to these tables. Transitive `v.id(...)` parents are added
57
- * automatically (unless already covered by `existingIds`) so child foreign
58
- * keys resolve to real rows. The result is still ordered by FK dependency.
59
- * Default: all tables.
60
- */
61
- only?: ReadonlyArray<string>;
62
- /** Static values or functions overriding generated columns. */
63
- overrides?: SeedOverrides;
64
- /** Deterministic mapping selector — same seed ⇒ same rows. Default `0`. */
65
- seed?: number;
66
- }
67
- /** One table's generated rows, in insert order. Each row carries an explicit `_id`. */
68
- interface TablePlan {
69
- rows: ReadonlyArray<Record<string, unknown>>;
70
- table: string;
71
- }
72
- /**
73
- * Build a deterministic, FK-consistent set of rows for `schema`.
74
- * @returns one {@link TablePlan} per seeded table, ordered so a table's FK
75
- * parents come before it.
76
- */
77
- declare const seedPlan: (schema: Schema, options?: SeedOptions) => ReadonlyArray<TablePlan>;
78
- export { OverrideContext as O, SeedCounts as S, TablePlan as T, SeedOptions as a, SeedOverrides as b, seedPlan as s };
@@ -1 +0,0 @@
1
- export { s as seedPlan } from './plan-DirmkctQ.mjs';