@fabrika/db 0.9.0-dev.5 → 0.9.0-dev.50

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.
Files changed (75) hide show
  1. package/package.json +9 -5
  2. package/src/authority.ts +560 -0
  3. package/src/builtins.ts +21 -0
  4. package/src/capability.ts +51 -2
  5. package/src/codegen-sqlite.ts +62 -22
  6. package/src/codegen.ts +181 -42
  7. package/src/condition-nodes.ts +119 -0
  8. package/src/conditions.ts +683 -0
  9. package/src/description.ts +37 -8
  10. package/src/errors.ts +8 -4
  11. package/src/file-columns.ts +52 -10
  12. package/src/framework.ts +5 -2
  13. package/src/guard.ts +365 -15
  14. package/src/index.ts +8 -0
  15. package/src/job-leases.ts +19 -2
  16. package/src/job-wakes.ts +183 -33
  17. package/src/json.ts +124 -0
  18. package/src/list-cursor.ts +82 -0
  19. package/src/migrations-sqlite.ts +93 -0
  20. package/src/migrations.ts +99 -0
  21. package/src/nodes.ts +21 -6
  22. package/src/notifications.ts +152 -0
  23. package/src/orm-types.ts +208 -74
  24. package/src/orm.ts +368 -146
  25. package/src/policy.ts +1973 -141
  26. package/src/push-subscriptions.ts +287 -0
  27. package/src/registry.ts +50 -1
  28. package/src/request-receipts.ts +107 -0
  29. package/src/sql.ts +39 -11
  30. package/src/sqlite-bun.ts +41 -14
  31. package/src/sqlite-migrate.ts +102 -1
  32. package/src/sqlite.ts +46 -1
  33. package/src/store.ts +1930 -167
  34. package/src/tables.ts +156 -6
  35. package/src/temporal.ts +8 -1
  36. package/src/testing-shared.ts +758 -140
  37. package/src/testing-sqlite.ts +212 -40
  38. package/src/testing.ts +151 -22
  39. package/src/vocabulary-tables.ts +159 -27
  40. package/types/src/authority.d.ts +147 -0
  41. package/types/src/builtins.d.ts +2 -0
  42. package/types/src/capability.d.ts +50 -2
  43. package/types/src/codegen-sqlite.d.ts +8 -1
  44. package/types/src/codegen.d.ts +54 -10
  45. package/types/src/condition-nodes.d.ts +9 -0
  46. package/types/src/conditions.d.ts +151 -0
  47. package/types/src/description.d.ts +26 -8
  48. package/types/src/errors.d.ts +7 -4
  49. package/types/src/file-columns.d.ts +6 -4
  50. package/types/src/framework.d.ts +5 -2
  51. package/types/src/guard.d.ts +24 -0
  52. package/types/src/index.d.ts +4 -3
  53. package/types/src/job-leases.d.ts +8 -1
  54. package/types/src/job-wakes.d.ts +28 -5
  55. package/types/src/json.d.ts +18 -0
  56. package/types/src/list-cursor.d.ts +13 -0
  57. package/types/src/migrations.d.ts +5 -0
  58. package/types/src/nodes.d.ts +4 -0
  59. package/types/src/notifications.d.ts +37 -0
  60. package/types/src/orm-types.d.ts +165 -73
  61. package/types/src/orm.d.ts +21 -0
  62. package/types/src/policy.d.ts +347 -23
  63. package/types/src/push-subscriptions.d.ts +49 -0
  64. package/types/src/registry.d.ts +36 -1
  65. package/types/src/request-receipts.d.ts +22 -0
  66. package/types/src/sql.d.ts +2 -2
  67. package/types/src/sqlite-bun.d.ts +11 -3
  68. package/types/src/sqlite-migrate.d.ts +32 -0
  69. package/types/src/store.d.ts +118 -31
  70. package/types/src/tables.d.ts +8 -2
  71. package/types/src/temporal.d.ts +4 -1
  72. package/types/src/testing-shared.d.ts +112 -23
  73. package/types/src/testing-sqlite.d.ts +17 -2
  74. package/types/src/testing.d.ts +1 -1
  75. package/types/src/vocabulary-tables.d.ts +169 -22
@@ -1,13 +1,21 @@
1
- import { Database } from 'bun:sqlite';
1
+ import { Database, type SQLQueryBindings } from 'bun:sqlite';
2
2
  import type { SqliteStorage } from './sqlite';
3
3
  export interface BunSqliteStorage extends SqliteStorage {
4
4
  /** Runs `fn` in one transaction of its own, as a Durable Object's `storage.transactionSync` does. */
5
5
  transactionSync<T>(fn: () => T): T;
6
6
  }
7
+ /**
8
+ * Runs each statement of `query` in turn and answers the rows of the last one, as a Durable Object's `sql.exec` does.
9
+ * bun:sqlite's `prepare` compiles only the first statement of a text, and its column count cannot tell a migration from a
10
+ * read (`ALTER TABLE … ADD COLUMN … CHECK (…)` reports one column), so the text is split at the end of each compiled
11
+ * statement. `bindings` belong to a text of one statement. Refuses what workerd's SQLite refuses: more than 100 result
12
+ * columns or parameters in one statement.
13
+ */
14
+ export declare function execStatements(database: Database, query: string, bindings?: readonly SQLQueryBindings[]): Record<string, unknown>[];
7
15
  /**
8
16
  * `database` (a fresh `:memory:` one by default) with foreign keys enforced, as a Durable Object enforces them. One
9
17
  * `transaction` runs at a time; one started inside a callback nests in a savepoint, as workerd nests it, and its
10
- * siblings wait for each other. A statement outside one runs at once. A text of several statements runs whole when its
11
- * first statement answers no rows, as a migration's does; otherwise only its first statement runs.
18
+ * siblings wait for each other. A statement outside one runs at once. A text of several statements runs each of them and
19
+ * answers the rows of the last (`execStatements`).
12
20
  */
13
21
  export declare function bunSqliteStorage(database?: Database): BunSqliteStorage;
@@ -26,3 +26,35 @@ export declare class SqliteMigrationError extends Error {
26
26
  export declare function migrateSqlite(target: SqliteMigrationTarget, bundles: readonly SqliteMigrationBundle[]): Promise<{
27
27
  readonly applied: readonly string[];
28
28
  }>;
29
+ /** One row of the ledger, as a migration record names it: the identity and the checksum, without the time it ran. */
30
+ export interface SqliteLedgerEntry {
31
+ readonly bundle: string;
32
+ readonly name: string;
33
+ readonly checksum: string;
34
+ }
35
+ /** The ledger's rows in `(bundle, name)` order, and their digest. */
36
+ export interface SqliteLedger {
37
+ readonly entries: readonly SqliteLedgerEntry[];
38
+ readonly digest: string;
39
+ }
40
+ /** The SHA-256 of the rows' `bundle name checksum` lines in `(bundle, name)` order: neither part holds a space or a newline. */
41
+ export declare function sqliteLedgerDigest(entries: readonly SqliteLedgerEntry[]): Promise<string>;
42
+ /** The ledger as it stands; empty while the table does not exist. */
43
+ export declare function readSqliteLedger(target: SqliteMigrationTarget): Promise<SqliteLedger>;
44
+ /** What the database needs to reach the bundles: nothing, a digest only, or pending files. */
45
+ export interface SqliteMigrationPlan {
46
+ /** The ledger the plan starts from; `null` when every bundle matched its digest and the ledger was not read. */
47
+ readonly ledger: SqliteLedger | null;
48
+ /** The files to apply, the bundles in the order given and each bundle's files in name order. */
49
+ readonly pending: readonly SqliteLedgerEntry[];
50
+ /** Whether `apply` writes anything: a pending file, or a bundle digest that is out of date. */
51
+ readonly writes: boolean;
52
+ /**
53
+ * Applies every pending file with its ledger row, and records every out-of-date bundle digest, in one transaction
54
+ * that ends with `PRAGMA foreign_key_check`: a failing file or a row the check returns rolls the whole set back.
55
+ * Answers the identities it applied.
56
+ */
57
+ apply(): readonly string[];
58
+ }
59
+ /** Plans the bundles against the ledger without writing; refuses what `migrateSqlite` refuses, before anything runs. */
60
+ export declare function planSqliteMigrations(target: SqliteMigrationTarget, bundles: readonly SqliteMigrationBundle[]): Promise<SqliteMigrationPlan>;
@@ -1,11 +1,13 @@
1
1
  import { type OperationNode, type ReturningNode } from 'kysely';
2
+ import { type MemberReveals, type PathRule, type RelationSources } from './authority';
2
3
  import { type NameSet } from './builtins';
3
- import { type AppGrant, type CapabilityAuthority, type Ref, type RefGrant, type Within, type WithinGrant } from './capability';
4
+ import { type AppGrant, type CapabilityAuthority, type CapabilityGrant, type Ref, type RefGrant, type Within, type WithinGrant } from './capability';
5
+ import { type ConditionModel } from './conditions';
4
6
  import { type Database, type Session, type SqlDialect } from './database';
5
- import { type Compare, type Contains, type NoColumns, type Primitive, type ScopedSelect, type TableShape } from './description';
7
+ import { type ComparableColumn, type Compare, type Contains, type NoColumns, type Primitive, type ScopedSelect, type TableShape } from './description';
6
8
  import { type FileBinding } from './file-columns';
7
- import type { ForeignKeyPair, GuardContext, RootKind } from './guard';
8
- import { type Acknowledgement, type ActionOf, type ChildTableName, type Container, type ContainerOf, type DimensionOf, type DimensionTableName, type InsertValues, type JoinableChildren, type ListDimensionOf, type MoveAcknowledgement, type Operation, type ParentOf, type PolicyRow, type TableModel, type TableModels, type Tables, type UpdateValues, type VersionArguments } from './policy';
9
+ import type { ForeignKeyPair, GuardContext, RootKind, ViewParentLink } from './guard';
10
+ import { type Acknowledgement, type ActionOf, type ChildTableName, type Container, type ContainerOf, type DimensionOf, type DimensionTableName, type InsertValues, type JoinableChildren, type ListDimensionOf, type MoveAcknowledgement, type Operation, type ParentOf, type PathWriter, type PolicyRow, type ReadReach, type SecondaryPath, type TableModel, type TableModels, type Tables, type UpdateValues, type VersionArguments } from './policy';
9
11
  import type { ScopeTerms, ScopeUse } from './sql';
10
12
  import { type TablePolicies } from './tables';
11
13
  import { type RowColumns } from './temporal';
@@ -34,6 +36,24 @@ export interface TableContext {
34
36
  /** The model of each child a select may join, by its table name. */
35
37
  readonly children: Readonly<Record<string, TableModel>>;
36
38
  readonly connection: Connection;
39
+ /** Every relation of the layer with its source table: what a relation term of any table reads. */
40
+ readonly relations: RelationSources;
41
+ /** Every member reveal of the layer, by the dimension whose grants it reveals to: what a `Within`'s read adds. */
42
+ readonly members: MemberReveals;
43
+ /** The tables a scope predicate's subqueries read, each with the column they select: what the guard admits. */
44
+ readonly subqueries: Readonly<Record<string, readonly string[]>>;
45
+ /** A child view's parent, which every capability reads the view's rows through; `undefined` for any other table. */
46
+ readonly through: ViewParent | undefined;
47
+ /** The path columns whose insert hands out actions, each with the table owning the node it names (`pathWriters`). */
48
+ readonly writers: readonly PathBound[];
49
+ }
50
+ /** A path column an insert writes under its bound, and the table that owns the dimension it names. */
51
+ export interface PathBound extends PathWriter {
52
+ readonly owner: TableModel;
53
+ }
54
+ /** A child view's parent link, with the parent's context: its model without conditions, as only the view's own narrow a read. */
55
+ export interface ViewParent extends ViewParentLink {
56
+ readonly context: TableContext;
37
57
  }
38
58
  /** The dialect of the database the layer is bound to: what a read answers and a write binds depends on it. */
39
59
  export declare function dialectOf(context: TableContext): SqlDialect;
@@ -63,23 +83,31 @@ export declare function requiredActions(context: TableContext, operation: Operat
63
83
  export declare function checkAction(context: TableContext, operation: Operation, action: string): void;
64
84
  /** The object a Ref of the model's own dimension names, with every link of its chain. */
65
85
  export declare function selfLinks(model: TableModel): readonly Container[];
66
- /** This object, over the whole chain the Ref carries. */
67
- export declare function objectPredicate(context: TableContext, capability: unknown, operation: Operation): OperationNode;
86
+ /** This object, over the whole chain the Ref carries; through the secondary paths `paths` admits, by default its action's. */
87
+ export declare function objectPredicate(context: TableContext, capability: unknown, operation: Operation, paths?: PathRule): OperationNode;
68
88
  /** Rows of a dimension table within the scope values of its list dimension. */
69
89
  export declare function dimensionListPredicate(context: TableContext, capability: unknown, operation: Operation): OperationNode | undefined;
70
- /** Rows of a child table that belong to the parent object the Ref names, over the whole chain. */
71
- export declare function parentPredicate(context: TableContext, grant: RefGrant): OperationNode;
90
+ /**
91
+ * Rows of a child table that belong to the parent object the Ref names, over the whole chain; with `key`, the one row
92
+ * of them it keys. The key's equality joins the chain's, so the action's condition narrows both.
93
+ */
94
+ export declare function parentPredicate(context: TableContext, grant: RefGrant, key?: string): OperationNode;
72
95
  export declare function childListPredicate(context: TableContext, capability: unknown, operation: Operation): OperationNode | undefined;
73
96
  /**
74
- * The column that places a row of `model` in `dimension`: the column of that link of its containment chain, or a
75
- * top-level table's own key; `undefined` when no `Within` of the dimension reaches the table.
97
+ * Whether a `Within` of `dimension` lists the table: a dimension table its own dimension's, then through its containment
98
+ * chain or a secondary path; a child view through its parent's.
76
99
  */
77
- export declare function reachColumn(model: TableModel, dimension: string): string | undefined;
100
+ export declare function reachedBy(context: TableContext, dimension: string): boolean;
101
+ /** The secondary read paths of `model` that reach `dimension`, a dimension outside its chain: at their node or above it. */
102
+ export declare function secondaryPathsOf(model: TableModel, dimension: string): readonly SecondaryPath[];
78
103
  /**
79
104
  * Rows of a table a `Within` of any dimension of its chain lists, by the table's read action: tasks under a `Within` of
80
- * `org` through their stamped `org_id`, as under one of `project` through `project_id`.
105
+ * `org` through their stamped `org_id`, as under one of `project` through `project_id`; a `Within` of a dimension the
106
+ * table reaches through a secondary path, through that path's column.
81
107
  */
82
108
  export declare function reachPredicate(context: TableContext, capability: unknown): OperationNode | undefined;
109
+ /** The actions a grant holds: an `app` grant's (several for an `anyOf` endpoint), or any other grant's one. */
110
+ export declare function grantActions(grant: CapabilityGrant): readonly string[];
83
111
  /**
84
112
  * `ctx.sql.scope`'s predicate: what the handles of `capability` match in the table for `use`, as column tests. A
85
113
  * fragment that reads (`'read'`) needs an action the handles read the table with: any action it names for a `Ref`,
@@ -101,18 +129,30 @@ export declare function updatingRef(context: TableContext, capability: unknown,
101
129
  * action or an action of `appRead`; its counts (`count`, `aggregate`) with those or an action of `appCount`.
102
130
  */
103
131
  export type AppReach = 'rows' | 'counts';
132
+ /** What an `app` capability reads of a table: the rows (`predicate`), and the reach whose columns it answers. */
133
+ export interface AppRead {
134
+ readonly predicate: OperationNode;
135
+ readonly reach: ReadReach;
136
+ }
104
137
  /**
105
- * Every row of a dimension or child table an `app` capability reads through `ctx.db.app`: `true`, for an action that
106
- * reaches `reach` (`checkRecordReach`).
138
+ * Every row of a dimension or child table an `app` capability reads through `ctx.db.app`, for its actions that reach
139
+ * `reach` (`recordReach`): each row within the condition of one of them, and the columns they read alone.
107
140
  */
141
+ export declare function appRecordRead(context: TableContext, capability: unknown, reach: AppReach): AppRead;
142
+ /** `appRecordRead`'s rows. */
108
143
  export declare function appRecordPredicate(context: TableContext, capability: unknown, reach: AppReach): OperationNode;
109
- /** Every row a capability of an `app` endpoint reads in `table`, by the table's read action: `true`. */
144
+ /**
145
+ * Every row a capability of an `app` endpoint reads in an application table, by the table's read actions it holds or
146
+ * `'any'`, and the reach whose columns it answers.
147
+ */
148
+ export declare function appListRead(context: TableContext, capability: unknown): AppRead;
149
+ /** `appListRead`'s rows. */
110
150
  export declare function appListPredicate(context: TableContext, capability: unknown): OperationNode;
111
151
  /**
112
152
  * Every row of an application table, for a `Ref` or a `Within` of its read action: what `ctx.db.app` of an `on`, `in`
113
153
  * or `over` endpoint reads, read-only, as a reference table is read. The table's read action decides who reads it.
114
154
  */
115
- export declare function scopedApplicationRead(context: TableContext, capability: unknown): OperationNode;
155
+ export declare function scopedApplicationRead(context: TableContext, capability: unknown, branch?: OperationNode | 'all'): OperationNode;
116
156
  /** One row of an application table by its key, for an `app` capability of `operation`'s action. */
117
157
  export declare function appRowPredicate(context: TableContext, capability: unknown, key: unknown, operation: Operation): OperationNode;
118
158
  /**
@@ -121,6 +161,7 @@ export declare function appRowPredicate(context: TableContext, capability: unkno
121
161
  */
122
162
  export declare function claimScope(context: TableContext, capability: unknown): {
123
163
  readonly grant: AppGrant | WithinGrant;
164
+ readonly action: string;
124
165
  readonly scope: OperationNode | undefined;
125
166
  };
126
167
  /**
@@ -128,13 +169,26 @@ export declare function claimScope(context: TableContext, capability: unknown):
128
169
  * it was claimed, so a row moved since is not reached.
129
170
  */
130
171
  export declare function claimedRowPredicate(context: TableContext, capability: unknown, operation: 'update' | 'delete'): OperationNode;
172
+ /** The row of an application table `key` names, as `actions` reach it: within their conditions, any one admitting it. */
173
+ export declare function appKeyScope(model: TableModel, actions: readonly string[], key: unknown): OperationNode;
174
+ /** The row `key` names, as a read by key with `actions` reaches it: unconditioned in a table read with `'any'`. */
175
+ export declare function appGetScope(model: TableModel, actions: readonly string[], key: unknown): OperationNode;
131
176
  /** The row of an application table `key` names. */
132
177
  export declare function appKeyPredicate(model: TableModel, key: unknown): OperationNode;
133
178
  /**
134
- * The capability of an `app` endpoint whose action updates columns of an application table: its update action, or a
135
- * column's own write action. Which columns it updates follows from the action (`updatableBy`).
179
+ * The actions of an `app` endpoint's capability that update columns of an application table, at least one: its update
180
+ * action, or a column's own write action. Which columns they update follows from them (`updatableByAny`).
181
+ */
182
+ export declare function updatingApp(context: TableContext, capability: unknown): readonly string[];
183
+ /**
184
+ * An `app` capability's update of the application table row `key`: `values`, read against the columns its update
185
+ * actions write, and the row's scope under only those actions that write every given column, any one's condition
186
+ * admitting the row. So several held actions never write one action's columns on rows only another one reaches.
136
187
  */
137
- export declare function updatingApp(context: TableContext, capability: unknown): AppGrant;
188
+ export declare function appUpdate(context: TableContext, capability: unknown, key: unknown, values: unknown): {
189
+ readonly scope: OperationNode;
190
+ readonly changes: Map<string, Primitive | null>;
191
+ };
138
192
  export declare function childObjectPredicate(context: TableContext, parent: unknown, key: unknown, operation: Operation): OperationNode;
139
193
  export declare function guard(context: TableContext, root: RootKind, scope: OperationNode | undefined): GuardContext;
140
194
  /**
@@ -154,7 +208,10 @@ export interface Runner {
154
208
  * lease (`fencedTransaction`): an attempt that lost it, or ran out of time, writes nothing.
155
209
  */
156
210
  export declare function fencedWork<T>(runtime: DataLayerRuntime, work: (transaction: Session) => Promise<T>): Promise<T>;
157
- /** The action a capability holds, which its operation's checks already admitted. */
211
+ /**
212
+ * The one action a capability holds, which its operation's checks already admitted. An `anyOf` endpoint's `app`
213
+ * capability that holds several is refused: it reads through `ctx.db.app`, which reads with every action it holds.
214
+ */
158
215
  export declare function heldAction(context: TableContext, capability: unknown): string;
159
216
  /**
160
217
  * Reads insert or update data through its own property descriptors, so no getter runs and no inherited or
@@ -165,12 +222,13 @@ export declare function readValues(values: unknown, allowed: NameSet, what: 'ins
165
222
  export declare function versionArgument(context: TableContext, options: readonly unknown[]): OperationNode | undefined;
166
223
  /**
167
224
  * One row by its scope predicate, with `visible` columns (the table's read action's, unless a capability reads its own).
168
- * `action` is what read it: each file column then answers a reference that reads the file only under a read action.
225
+ * `reach` is what read it: each file column then answers a reference that reads the file only under a read action.
169
226
  */
170
- export declare function selectOne<O>(context: TableContext, run: Runner, scope: OperationNode, visible?: readonly string[], action?: string): Promise<O>;
227
+ export declare function selectOne<O>(context: TableContext, run: Runner, scope: OperationNode, visible?: readonly string[], reach?: ReadReach): Promise<O>;
171
228
  export declare function answer(context: TableContext): ReturningNode;
172
229
  export declare function keyOf(model: TableModel): string;
173
- export declare function insertRow<O>(context: TableContext, run: Runner, given: ReadonlyMap<string, Primitive | null>, destination: RefGrant | undefined): Promise<O>;
230
+ /** An insert, in a transaction that first locks its destination and judges its writer's bounds and its condition. */
231
+ export declare function insertRow<O>(context: TableContext, run: Runner, given: ReadonlyMap<string, Primitive | null>, prepared: Pick<PreparedInsert, 'destination' | 'writer' | 'judged' | 'narrowed'> | undefined): Promise<O>;
174
232
  /**
175
233
  * `insert(values, { onConflict: { columns, do } })`: on a conflict of `columns` (a unique index of the table), `nothing`
176
234
  * writes nothing and `update` sets the columns the table's update action writes, from `updates`.
@@ -180,12 +238,14 @@ export interface OnConflict {
180
238
  readonly mode: 'nothing' | 'update';
181
239
  /** The values given for the table's update columns: what `update` sets on the conflicting row. */
182
240
  readonly updates: ReadonlyMap<string, Primitive | null>;
241
+ /** The capability's update actions, one of whose conditions the conflicting row must satisfy to be updated. */
242
+ readonly actions: readonly string[];
183
243
  }
184
244
  /**
185
245
  * The `onConflict` of an insert's options, read through own data properties; `undefined` without options. `'update'`
186
- * also needs the capability's action to be one of the table's update actions.
246
+ * also needs one of the capability's `actions` to be one of the table's update actions.
187
247
  */
188
- export declare function onConflictOf(context: TableContext, options: unknown, action: string, given: ReadonlyMap<string, Primitive | null>): OnConflict | undefined;
248
+ export declare function onConflictOf(context: TableContext, options: unknown, actions: readonly string[], given: ReadonlyMap<string, Primitive | null>): OnConflict | undefined;
189
249
  /**
190
250
  * The rows a write addresses: the scope predicate, and the caller's conditions beside it (an unscoped row's key, whose
191
251
  * scope predicate is `true`).
@@ -198,7 +258,17 @@ export interface Addressed {
198
258
  * Zero changed rows → one follow-up read in the same transaction → 404 when the object is gone, else 409. An update
199
259
  * that sets no column writes nothing, not even the version: it reads the acknowledgement under the same conditions.
200
260
  */
201
- export declare function updateRow<O>(context: TableContext, run: Runner, target: Addressed, given: ReadonlyMap<string, Primitive | null>, expectedVersion: OperationNode | undefined, destination?: RefGrant): Promise<O>;
261
+ export declare function updateRow<O>(context: TableContext, run: Runner, target: Addressed, given: ReadonlyMap<string, Primitive | null>, expectedVersion: OperationNode | undefined, moved?: MovedRow): Promise<O>;
262
+ /**
263
+ * A move's destination, locked before the write, and the destination's insert conditions, which judge the moved row
264
+ * after it as an insert into the destination judges its row: the insert action's (`judgeInserted`), and each one
265
+ * `relationWhen` puts on a relation the destination `Ref` holds through (`judgeNarrowed`).
266
+ */
267
+ export interface MovedRow {
268
+ readonly destination: RefGrant;
269
+ readonly judged: JudgedInsert | undefined;
270
+ readonly narrowed: readonly NarrowedInsert[];
271
+ }
202
272
  /** Like `updateRow`: under `expectVersion`, a row that changed is 409 and a missing one 404. */
203
273
  export declare function removeRow(context: TableContext, run: Runner, target: Addressed, expectedVersion?: OperationNode): Promise<void>;
204
274
  type Columns<Row> = keyof Row & string;
@@ -206,11 +276,11 @@ type NumericColumn<Row> = {
206
276
  [K in Columns<Row>]: Exclude<Row[K], null> extends number | bigint | string ? K : never;
207
277
  }[Columns<Row>];
208
278
  export interface AggregateSpec<Row> {
209
- readonly groupBy?: readonly Columns<Row>[];
279
+ readonly groupBy?: readonly ComparableColumn<Row>[];
210
280
  readonly count?: boolean;
211
281
  readonly sum?: readonly NumericColumn<Row>[];
212
- readonly min?: readonly Columns<Row>[];
213
- readonly max?: readonly Columns<Row>[];
282
+ readonly min?: readonly ComparableColumn<Row>[];
283
+ readonly max?: readonly ComparableColumn<Row>[];
214
284
  readonly where?: (q: ScopedSelect<Row, Row, NoColumns>) => ScopedSelect<Row, unknown, NoColumns>;
215
285
  }
216
286
  type Listed<S, K extends 'groupBy' | 'sum' | 'min' | 'max'> = S extends {
@@ -238,8 +308,23 @@ export declare function aggregateRows<Row, O>(context: TableContext, run: Runner
238
308
  /** An insert's row, stamped from its capability, the destination it locks, and what it does on a conflict. */
239
309
  export interface PreparedInsert {
240
310
  readonly row: Map<string, Primitive | null>;
311
+ /** The principal the insert acts for: the bound of a reveal through a secondary path is judged against it. */
312
+ readonly writer: string;
241
313
  readonly destination: RefGrant | undefined;
242
314
  readonly conflict: OnConflict | undefined;
315
+ /** The insert action's condition when it follows a path: judged in the insert's transaction, on the rows it names. */
316
+ readonly judged: JudgedInsert | undefined;
317
+ /** The destination's relations whose `relationWhen` for the insert follows a path: judged on the written row. */
318
+ readonly narrowed: readonly NarrowedInsert[];
319
+ }
320
+ export interface JudgedInsert {
321
+ readonly action: string;
322
+ readonly condition: ConditionModel;
323
+ }
324
+ /** A relation the destination `Ref` holds through, which the inserted table narrows for the insert by a condition with a path. */
325
+ export interface NarrowedInsert {
326
+ readonly relation: string;
327
+ readonly condition: ConditionModel;
243
328
  }
244
329
  /**
245
330
  * A dimension table's insert over a capability nobody type-checked: into a container (a new UUIDv7 key, the chain from
@@ -278,7 +363,9 @@ export declare class DimensionTable<DB, P, T extends string> {
278
363
  /**
279
364
  * Moves the object to another container: the delete action at the source, the insert action at the target,
280
365
  * whose chain is checked against the database. Every chain column changes; children that copy them follow
281
- * through `ON UPDATE CASCADE` on their composite foreign key. Answers the acknowledgement and the new chain.
366
+ * through `ON UPDATE CASCADE` on their composite foreign key. The moved row is judged by the insert action's
367
+ * condition and by the `relationWhen` of each relation the target holds through, as an insert into the target is.
368
+ * Answers the acknowledgement and the new chain.
282
369
  */
283
370
  move(ref: Ref<DimensionOf<P, T>, ActionOf<P, T, 'delete'>>, to: Ref<ContainerOf<P, T>, ActionOf<P, T, 'insert'>>): Promise<MoveAcknowledgement<P, T>>;
284
371
  aggregate<const S extends AggregateSpec<Row<DB, P, T>>>(within: Within<ListDimensionOf<P, T>, ReadAction<P, T>>, spec: S): Promise<AggregateRow<Row<DB, P, T>, S>[]>;
@@ -298,7 +385,7 @@ export declare class ChildTable<DB, P, T extends string> {
298
385
  aggregate<const S extends AggregateSpec<Row<DB, P, T>>>(scope: ChildListScope<P, T>, spec: S): Promise<AggregateRow<Row<DB, P, T>, S>[]>;
299
386
  }
300
387
  /**
301
- * One table's operations without the store types, for `@fabrika/db/testing` only: the generated isolation tests address
388
+ * One table's operations without the store types, for `@fabrika/db/testing` only: the policy isolation kit addresses
302
389
  * a table by name. Every runtime check of a store applies; a child row is addressed by its parent's capability and
303
390
  * `key`, a dimension row by its capability alone.
304
391
  */
@@ -5,9 +5,9 @@ export { applicationRowRefusalText } from './application-rows';
5
5
  export type { ApplicationRowRefusal, ApplicationRowsPlan } from './application-rows';
6
6
  export { PolicyError } from './errors';
7
7
  export type { FileReference } from './file-references';
8
- export type { AnyDbIndex, ApplicationRows, ApplicationTables, AppRecordRows, ChildRows, ClaimedRow, ClaimedRowHandle, ClaimOptions, ContainedRows, CountOptions, DataKind, DbIndex, FragmentTable, IndexedTable, InsertConflict, InsertMethod, ListOptions, ListPage, NoUnscoped, OrderTerm, OwnerRow, PublicApplicationRows, PublicApplicationTables, PublicInsertMethod, ReadOnlyUnscoped, ReferenceRows, ReferenceTables, RowFor, RowOf, Saved, ScopedApplicationRows, ScopedApplicationTables, ScopeTarget, TableNameOf, TargetForm, TargetRow, Unavailable, UnownedTarget, UnscopedDeclaration, UnscopedInsert, UnscopedMode, UnscopedRows, UnscopedTables, VersionArguments, WithinRows, WithinTables, } from './orm-types';
8
+ export type { AllOptions, AllQuery, AnyDbIndex, ApplicationRows, ApplicationTables, AppRecordRows, ChildRows, ClaimedRow, ClaimedRowHandle, ClaimOptions, ContainedRows, CountOptions, CountQuery, DataKind, DbIndex, FragmentTable, IndexedTable, InsertConflict, InsertMethod, ListOptions, ListPage, ListQuery, NoUnscoped, OrderTerm, OwnerRow, PublicApplicationRows, PublicApplicationTables, PublicInsertMethod, ReadOnlyUnscoped, ReferenceRows, ReferenceTables, RowFor, RowOf, Saved, ScopedApplicationRows, ScopedApplicationTables, ScopeTarget, TableNameOf, TargetForm, TargetRow, Unavailable, UnownedTarget, UnscopedDeclaration, UnscopedInsert, UnscopedMode, UnscopedRows, UnscopedTables, VersionArguments, WithinRows, WithinTables, } from './orm-types';
9
9
  export { type ApplicationPolicy, type ApplicationScope, type ChildPolicy, type ChildScope, type ColumnList, defineTables, type DimensionPolicy, type DimensionScope, type FilePolicies, isTables, type QueuePolicy, readTables, type RecordActions, type ReferencePolicy, type ReferenceScope, type TableAction, type TableActions, type TableInsert, Tables, type TableUpdate, type VersionColumn, type VocabularyTables, } from './policy';
10
- export type { ColumnTypes, DefineVocabularyPolicies, NormalizedPolicies, TableVocabulary, TypedColumnList, VocabularyAction, VocabularyChildScope, VocabularyContainer, VocabularyContainerOf, VocabularyDimension, VocabularyDimensionScope, VocabularyPolicyMap, VocabularyTablePolicy, } from './vocabulary-tables';
10
+ export type { ColumnTypes, ColumnViews, DefineVocabularyPolicies, NormalizedPolicies, TableVocabulary, TypedColumnList, VocabularyAction, VocabularyChildScope, VocabularyContainer, VocabularyContainerOf, VocabularyDimension, VocabularyDimensionScope, VocabularyPolicyMap, VocabularyTablePolicy, VocabularyViewPolicy, } from './vocabulary-tables';
11
11
  /**
12
12
  * The plan of seeding one row of each application table `rows` names (table → column → value), as an endpoint access
13
13
  * case seeds its `appRows`: the order, the foreign keys that link one given row to another, and every refusal.
@@ -15,6 +15,12 @@ export type { ColumnTypes, DefineVocabularyPolicies, NormalizedPolicies, TableVo
15
15
  * `applicationRowRefusalText`.
16
16
  */
17
17
  export declare function applicationRowsPlan<DB, P>(tables: Tables<DB, P>, rows: Readonly<Record<string, Readonly<Record<string, unknown>>>>): ApplicationRowsPlan;
18
+ /**
19
+ * The tables whose rows hand out access, lowercased: a relation source or a path reveal, a member-revealing table, and
20
+ * the tables a principal path or a relation's condition reads. Only the data layer writes them; the migration classifier
21
+ * refuses database code that does.
22
+ */
23
+ export declare function accessTables<DB, P>(tables: Tables<DB, P>): readonly string[];
18
24
  /** Every table's policy in the form the contract artifact carries, by table name. */
19
25
  export type TablePolicies = Readonly<Record<string, TablePolicyArtifact>>;
20
26
  /** The artifact form of every policy `defineTables` (or `readTables`) checked. */
@@ -25,9 +25,12 @@ export interface RowColumns {
25
25
  readonly timestamps: NameSet;
26
26
  /** Booleans: `true` or `false` (SQLite answers 1 or 0). */
27
27
  readonly booleans: NameSet;
28
+ /** JSON columns: the parsed value (SQLite answers its text). */
29
+ readonly json: NameSet;
28
30
  }
29
31
  /**
30
32
  * Every row of a read as the layer answers it, in place: each day as `YYYY-MM-DD` text, and on SQLite each timestamp as
31
- * a `Date` and each boolean as `true` or `false`, so a handler reads the same values on both dialects.
33
+ * a `Date`, each boolean as `true` or `false` and each JSON column as its parsed value, so a handler reads the same
34
+ * values on both dialects.
32
35
  */
33
36
  export declare function answerRows<R>(dialect: SqlDialect, table: string, columns: RowColumns, rows: R[]): R[];
@@ -4,6 +4,11 @@ import { type Tables } from './policy';
4
4
  import type { TableProbe } from './store';
5
5
  /** A value a test row holds in a column; `null` for a nullable column the fixture left empty. */
6
6
  export type SampleValue = Primitive | null;
7
+ /**
8
+ * A seeded value as a backend binds it: a JSON column's value as the JSON text the layer would write for it, so a
9
+ * seeded row and the kits' cases that write the same value through the layer hold the same JSON.
10
+ */
11
+ export declare function seedBinding(columns: readonly SeedColumn[], table: string, name: string, value: SampleValue): SampleValue;
7
12
  /** One seeded row and where it lies. */
8
13
  export interface WorldRow {
9
14
  /** The row's key: the dimension value of a dimension table's row, a child's own key. */
@@ -20,18 +25,23 @@ export interface WorldRow {
20
25
  readonly type: string;
21
26
  readonly value: string;
22
27
  }[];
23
- /** The row's values of the policy's update columns, as seeded. */
28
+ /** The row's values of the policy's update columns: as seeded, or as stored where the database filled them. */
24
29
  readonly updates: Readonly<Record<string, SampleValue>>;
25
30
  /**
26
31
  * The distinct value written into every text column the fixture filled itself, in this row and in its containers.
27
32
  * Each occurs in no other fixture, so one found in an answer to another scope is a leaked row.
28
33
  */
29
34
  readonly markers: readonly string[];
35
+ /**
36
+ * The values of the text columns of a row the table already held under a known scope value (`seedWorlds`' `scopes`),
37
+ * which no fixture wrote and other rows may share; empty for a row the fixture inserted.
38
+ */
39
+ readonly stored: readonly string[];
30
40
  }
31
41
  /** One seeded row of an application table, which lies in no dimension. */
32
42
  export interface ApplicationRow {
33
43
  readonly key: string;
34
- /** The row's values of the policy's update columns, as seeded. */
44
+ /** The row's values of the policy's update columns: as seeded, or as stored where the database filled them. */
35
45
  readonly updates: Readonly<Record<string, SampleValue>>;
36
46
  /** The distinct value written into every text column the fixture filled itself. */
37
47
  readonly markers: readonly string[];
@@ -51,15 +61,30 @@ export interface SeededApplicationRows {
51
61
  export interface SeededRow {
52
62
  readonly key: string;
53
63
  readonly markers: readonly string[];
64
+ /** Deletes the row, the rows its foreign keys made the fixture insert, and every row that refers to them. */
65
+ readonly remove: () => Promise<void>;
54
66
  }
55
67
  /**
56
- * What the isolation fixture cannot seed for a schema: a CHECK its values fail, a required foreign key to a scoped table
57
- * outside the containment chain. It is a limit of the generator, named with the constraint or the column, never a
58
- * failure of the handler or the policy a case is about.
68
+ * What the isolation fixture cannot seed for a schema: a CHECK or a unique index no row it tries passes, a required
69
+ * foreign key whose referenced row it cannot seed. It is a limit of the generator, named with the constraint or the
70
+ * column, never a failure of the handler or the policy a case is about.
59
71
  */
60
72
  export declare class SeedLimitError extends Error {
61
73
  readonly name = "SeedLimitError";
62
74
  }
75
+ /** The constraint a seeded row failed, as a backend reads it off the database's error. */
76
+ export interface Violation {
77
+ readonly kind: 'check' | 'unique' | 'foreign';
78
+ /** The constraint's name, or for an unnamed CHECK on SQLite its expression, as the database reports it. */
79
+ readonly name: string;
80
+ /** The columns the database names (SQLite's unique error); `undefined` where the seeding looks them up by `name`. */
81
+ readonly columns?: readonly string[];
82
+ }
83
+ /** A seed limit of a row the database refused, with the constraint it failed: the seeding tries another row. */
84
+ export declare class ConstraintLimitError extends SeedLimitError {
85
+ readonly violation: Violation;
86
+ constructor(message: string, violation: Violation);
87
+ }
63
88
  /** One row of a table in each of two containment chains that share no value. */
64
89
  export interface IsolationWorlds {
65
90
  /**
@@ -70,11 +95,20 @@ export interface IsolationWorlds {
70
95
  readonly own: WorldRow;
71
96
  readonly other: WorldRow;
72
97
  /**
73
- * Deletes both rows of the table and every row that refers to them, however deep; the containers stay. A case whose
74
- * rows hold pinned values removes them, so the next case can pin the same values again under a unique index.
98
+ * Deletes both rows of the table it inserted, every container row it inserted when it was given known scope values,
99
+ * and every row that refers to them, however deep; the other containers stay. A case whose rows hold pinned values or
100
+ * known scope values removes them, so the next case can seed the same values again under a unique index.
75
101
  */
76
102
  readonly remove: () => Promise<void>;
77
103
  }
104
+ /**
105
+ * Known values of dimensions, by dimension: the own world's and the other world's, which differ. A dimension whose values
106
+ * are a fixed set (an enum the input names it by) takes these instead of fresh ones.
107
+ */
108
+ export type ScopeValues = Readonly<Record<string, {
109
+ readonly own: string;
110
+ readonly other: string;
111
+ }>>;
78
112
  /** What a test kit seeds through, over its migrated schema. */
79
113
  export interface TestSeeding {
80
114
  /**
@@ -83,9 +117,12 @@ export interface TestSeeding {
83
117
  * marker, so a seed of one, or of a column that places the row, throws. `pins` (column → value) give a text column of
84
118
  * `table` a known value instead of its marker: the value in the own row, and `<value>-other` in the other row, which
85
119
  * counts among the other row's markers, so a leak of it is still found. A pin of a column that places the row, or of
86
- * no text column, throws.
120
+ * no text column, throws. `scopes` place each world in known values of a dimension instead of fresh ones: a row of
121
+ * the table that owns it with that key is used as it is stored (a migration wrote it), its containers' values with it,
122
+ * and is inserted otherwise. A stored row of `table` itself takes no `values` or `pins`: they throw. A seed that throws
123
+ * removes what it inserted.
87
124
  */
88
- seedWorlds<DB, P>(tables: Tables<DB, P>, table: string, values?: Readonly<Record<string, SampleValue>>, pins?: Readonly<Record<string, string>>): Promise<IsolationWorlds>;
125
+ seedWorlds<DB, P>(tables: Tables<DB, P>, table: string, values?: Readonly<Record<string, SampleValue>>, pins?: Readonly<Record<string, string>>, scopes?: ScopeValues): Promise<IsolationWorlds>;
89
126
  /**
90
127
  * Seeds one row of the application table `table`: its key, version and creator stamped, `values` (column → value)
91
128
  * as given, a text column too, every other column sampled. A value for a stamped column or a file column throws.
@@ -100,13 +137,19 @@ export interface TestSeeding {
100
137
  */
101
138
  seedApplicationRows<DB, P>(tables: Tables<DB, P>, rows: Readonly<Record<string, Readonly<Record<string, SampleValue>>>>): Promise<SeededApplicationRows>;
102
139
  /**
103
- * Seeds one row of `table`, a child or dimension table that lies in the object of `under` (a row `seedWorlds`
104
- * seeded), placed in that row's chain: the row a fixture names by id, such as a note's comment. Answers its key and
105
- * the markers it holds.
140
+ * Seeds one row of `table`, a child or dimension table that lies in the object `under`'s chain starts at (a row
141
+ * `seedWorlds` seeded, or a value of its chain with the values outside it), placed in that chain: the row a fixture
142
+ * names by id, such as a note's comment. Answers its key and the markers it holds.
106
143
  */
107
- seedUnder<DB, P>(tables: Tables<DB, P>, table: string, under: WorldRow): Promise<SeededRow>;
108
- /** Values for the policy's insert columns of `table` that its schema accepts: every required one, sampled; a file column a seeded file. */
109
- sampleInsert<DB, P>(tables: Tables<DB, P>, table: string): Promise<Readonly<Record<string, SampleValue>>>;
144
+ seedUnder<DB, P>(tables: Tables<DB, P>, table: string, under: Pick<WorldRow, 'chain'>): Promise<SeededRow>;
145
+ /**
146
+ * Values for the policy's insert columns of `table` that its schema accepts: every required one, sampled; a file
147
+ * column a seeded file. `beside` is a row `seedWorlds` seeded that the inserted row will lie beside, in the same
148
+ * containers. A number column a unique index covers takes the next number above the largest the table holds now in the
149
+ * row's group (the index's other columns as the row will have them, its containers' from `beside`), so insert the
150
+ * values before taking the next sample, or the two share it.
151
+ */
152
+ sampleInsert<DB, P>(tables: Tables<DB, P>, table: string, beside?: WorldRow): Promise<Readonly<Record<string, SampleValue>>>;
110
153
  /**
111
154
  * The object key of every file the fixture seeded into a file column, oldest first. Each stands for an empty object,
112
155
  * which a test's object store holds when a handler serves or opens the file.
@@ -134,8 +177,16 @@ export interface SeedColumn {
134
177
  readonly text: boolean;
135
178
  /** A uuid type: a key or containment column of it holds a random uuid as its scope value. */
136
179
  readonly uuid: boolean;
137
- /** A sample of the column's type for a required column the test does not care about; a `SeedLimitError` for a type it cannot fill. */
138
- readonly sample: () => Primitive;
180
+ /** A number type: where a unique index covers it, the fixture writes the next number of the row's group instead of its sample. */
181
+ readonly number: boolean;
182
+ /** A JSON column (`jsonb`, `JSONB`): its value is a JSON value, bound as the layer binds it (`seedBinding`). */
183
+ readonly json: boolean;
184
+ /**
185
+ * A sample of the column's type for a required column the test does not care about; a `SeedLimitError` for a type it
186
+ * cannot fill. `variant` 0 is the plain sample; a higher one differs from the lower ones where the type allows (another
187
+ * day, the other boolean, a larger number), for a unique index whose other columns the row cannot vary.
188
+ */
189
+ readonly sample: (variant: number) => Primitive;
139
190
  }
140
191
  /** A CHECK constraint of the schema, by the columns it names. */
141
192
  export interface CheckConstraint {
@@ -143,7 +194,22 @@ export interface CheckConstraint {
143
194
  readonly table: string;
144
195
  readonly columns: readonly string[];
145
196
  /** The values of a one-column `IN (…)` list the fixture writes in its place, first one first; empty for any other CHECK. */
146
- readonly values: readonly string[];
197
+ readonly values: readonly CheckLiteral[];
198
+ /** Every text and number literal of the expression: what the fixture tries in the columns it names when a row fails it. */
199
+ readonly literals: readonly CheckLiteral[];
200
+ }
201
+ /** A literal of a CHECK expression. */
202
+ export type CheckLiteral = string | number;
203
+ /**
204
+ * A unique index of the schema (a primary key's or a UNIQUE constraint's included), by its key columns. Only an index of
205
+ * plain columns with no predicate is one: the fixture cannot tell a partial index's rows or an expression's values.
206
+ */
207
+ export interface UniqueIndex {
208
+ readonly name: string;
209
+ readonly table: string;
210
+ readonly columns: readonly string[];
211
+ /** `NULLS NOT DISTINCT`: a null in a key column collides with another row's null there. */
212
+ readonly nullsNotDistinct: boolean;
147
213
  }
148
214
  /** A live, empty file of `kind`, as the framework's put leaves one once a reference claims it. */
149
215
  export interface SeededFile {
@@ -167,10 +233,21 @@ export interface SeedingBackend {
167
233
  readonly columns: readonly SeedColumn[];
168
234
  /** Every CHECK constraint of the schema's tables; read once, on the first column that needs them. */
169
235
  checks(): Promise<readonly CheckConstraint[]>;
170
- /** Inserts one row and answers it as stored; a CHECK or foreign key it fails is a `SeedLimitError` (`checkLimit`, `foreignKeyLimit`). */
236
+ /** Every unique index of plain columns and no predicate of the schema's tables; read once, on the first column that needs them. */
237
+ uniqueIndexes(): Promise<readonly UniqueIndex[]>;
238
+ /**
239
+ * The smallest whole number above every value `column` holds in the rows of `table` that match one of `groups`
240
+ * (`groupsWhere`), and at least 1, as the column's type holds it; `undefined` when the type holds no such number, or
241
+ * the largest is no finite number.
242
+ */
243
+ nextNumber(table: string, column: string, groups: readonly ReadonlyMap<string, SampleValue>[]): Promise<Primitive | undefined>;
244
+ /**
245
+ * Inserts one row and answers it as stored; a CHECK, foreign key or unique index it fails is a `SeedLimitError`
246
+ * (`checkLimit`, `foreignKeyLimit`, `uniqueValueLimit`).
247
+ */
171
248
  insert(table: string, values: ReadonlyMap<string, SampleValue>): Promise<Readonly<Record<string, unknown>>>;
172
- /** One row of `table`, of `columns`, or `undefined` when it has none. */
173
- firstRow(table: string, columns: readonly string[]): Promise<Readonly<Record<string, unknown>> | undefined>;
249
+ /** One row of `table` that holds `where` (column → value; every row when empty), of `columns`, or `undefined` when none does. */
250
+ firstRow(table: string, columns: readonly string[], where?: ReadonlyMap<string, SampleValue>): Promise<Readonly<Record<string, unknown>> | undefined>;
174
251
  insertFile(file: SeededFile): Promise<void>;
175
252
  /**
176
253
  * Deletes `rows` (each found by its `match`; one already gone is skipped) and every row that refers to one of them,
@@ -180,11 +257,23 @@ export interface SeedingBackend {
180
257
  remove(rows: readonly InsertedRow[]): Promise<void>;
181
258
  }
182
259
  /** The seed limit of a CHECK a seeded row fails. */
183
- export declare function checkLimit(constraint: string, table: string): SeedLimitError;
260
+ export declare function checkLimit(constraint: string, table: string): ConstraintLimitError;
184
261
  /** The seed limit of a foreign key a seeded row breaks. */
185
- export declare function foreignKeyLimit(constraint: string, table: string): SeedLimitError;
262
+ export declare function foreignKeyLimit(constraint: string, table: string): ConstraintLimitError;
263
+ /** The seed limit of a number column a unique index covers whose type holds no number above the largest of the row's group. */
264
+ export declare function uniqueLimit(index: string, table: string, column: string): SeedLimitError;
265
+ /** The seed limit of a row whose values another row of the table already holds under a unique index. */
266
+ export declare function uniqueValueLimit(index: string, table: string, columns?: readonly string[]): ConstraintLimitError;
186
267
  /** The seed limit of a required column whose type the fixture has no sample of. */
187
268
  export declare function typeLimit(table: string, column: string, type: string): SeedLimitError;
269
+ /**
270
+ * A condition that matches a row holding every value of one of `groups` (column → value, `null` matched by `IS NULL`; an
271
+ * empty group matches every row, no group none), in the dialect's quoting and placeholders, with the values it binds.
272
+ */
273
+ export declare function groupsWhere(groups: readonly ReadonlyMap<string, SampleValue>[], quote: (identifier: string) => string, placeholder: (position: number) => string): {
274
+ where: string;
275
+ values: SampleValue[];
276
+ };
188
277
  export declare function randomHex(): string;
189
278
  /**
190
279
  * The object version a seeded file was scanned at: whoever stocks its empty object (`seededObjects`) stores it under