@fabrika/db 0.9.0-dev.29 → 0.9.0-dev.30

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/db",
3
- "version": "0.9.0-dev.29",
3
+ "version": "0.9.0-dev.30",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "./src/testing.ts",
@@ -96,9 +96,9 @@
96
96
  "test": "bun test"
97
97
  },
98
98
  "dependencies": {
99
- "@fabrika/auth-core": "0.9.0-dev.29",
100
- "@fabrika/platform": "0.9.0-dev.29",
101
- "@fabrika/platform-node": "0.9.0-dev.29",
99
+ "@fabrika/auth-core": "0.9.0-dev.30",
100
+ "@fabrika/platform": "0.9.0-dev.30",
101
+ "@fabrika/platform-node": "0.9.0-dev.30",
102
102
  "kysely": "0.29.6",
103
103
  "kysely-postgres-js": "5.0.1",
104
104
  "zod": "^3.25.76"
package/src/index.ts CHANGED
@@ -49,15 +49,18 @@ export {
49
49
  export type { JsonColumnValue, JsonValue } from './json'
50
50
  export type {
51
51
  AllOptions,
52
+ AllQuery,
52
53
  AnyDbIndex,
53
54
  ChildRows,
54
55
  ContainedRows,
55
56
  CountOptions,
57
+ CountQuery,
56
58
  DataKind,
57
59
  DbIndex,
58
60
  IndexedTable,
59
61
  ListOptions,
60
62
  ListPage,
63
+ ListQuery,
61
64
  NoUnscoped,
62
65
  OrderTerm,
63
66
  OwnerRow,
package/src/orm-types.ts CHANGED
@@ -56,6 +56,9 @@ type ColumnReadsOf<P, T> = PolicyOf<P, T> extends { readonly columns: infer C }
56
56
  }
57
57
  : Record<never, never>
58
58
 
59
+ /** The actions the table's `when` narrows; every action of a policy typed wider than its literal, which may hold one. */
60
+ type ConditionedOf<P, T> = PolicyOf<P, T> extends { readonly when?: infer W } ? keyof NonNullable<W> & string : never
61
+
59
62
  type ColumnPoliciesOf<P, T> = PolicyOf<P, T> extends { readonly columns: infer C } ? C : never
60
63
 
61
64
  /** The columns that declare `A` as their own write action. */
@@ -96,6 +99,8 @@ export interface IndexedTable {
96
99
  readonly row: object
97
100
  /** The columns that declare their own read action. */
98
101
  readonly reads: object
102
+ /** The actions whose `when` narrows the rows they reach. */
103
+ readonly conditioned: string
99
104
  readonly insert: object
100
105
  readonly update: object
101
106
  /** Each action that updates the table, with the values it updates (`columns: { assignee: { write: 'tasks.assign' } }`). */
@@ -129,6 +134,7 @@ type IndexedTableOf<DB, P, T extends keyof P & keyof DB & string, V = unknown> =
129
134
  readonly appCount: AppActionsOf<P, T, 'appCount'>
130
135
  readonly row: WithFiles<RowType<DB[T]>, FileColumnsOf<P, T>>
131
136
  readonly reads: ColumnReadsOf<P, T>
137
+ readonly conditioned: ConditionedOf<P, T>
132
138
  readonly insert: WithFiles<InsertValues<DB, P, T>, FileColumnsOf<P, T>>
133
139
  readonly update: WithFiles<UpdateValues<DB, P, T>, FileColumnsOf<P, T>>
134
140
  readonly writes: { readonly [A in keyof UpdatesOf<DB, P, T>]: WithFiles<UpdatesOf<DB, P, T>[A], FileColumnsOf<P, T>> }
@@ -237,21 +243,27 @@ type ListedIn<Ix extends AnyDbIndex, D> = Lookup<Ix['listed'], D>
237
243
  type WithinIn<Ix extends AnyDbIndex, D> = Lookup<Ix['within'], D>
238
244
 
239
245
  /**
240
- * The columns a capability of action `A` cannot read: each whose own read actions do not include `A`. A union `A` (a
241
- * widened capability type) holds no single action provably, so it reads none of them.
246
+ * The columns a capability of `A` cannot read: each whose own read actions do not include every action of `A`. A union
247
+ * `A` (an `anyOf` endpoint's, or a widened capability type) reads one only where no action of it is `Conditioned`: the
248
+ * runtime answers it where every reaching action reads every row alone (`readsAsAction`), and the held ones are known
249
+ * only per request.
242
250
  */
243
- type HiddenFor<Reads, A> = { [C in keyof Reads]: IsSingle<A> extends true ? ([A] extends [Reads[C]] ? never : C) : C }[keyof Reads]
251
+ type HiddenFor<Reads, A, Conditioned> = {
252
+ [C in keyof Reads]: [A] extends [never] ? C
253
+ : [A] extends [Reads[C]] ? (IsSingle<A> extends true ? never : [Extract<A, Conditioned>] extends [never] ? never : C)
254
+ : C
255
+ }[keyof Reads]
244
256
 
245
257
  /** Whether `A` is one literal, not a union of several. */
246
258
  type IsSingle<A, All = A> = [A] extends [never] ? false : A extends unknown ? ([All] extends [A] ? true : false) : never
247
259
 
248
260
  /**
249
- * A row as a capability of action `A` reads, filters and sorts it: a column that declares another read action is
250
- * absent. The type keeps the generated row's name, so a read of a hidden column reports
251
- * `Property 'margin' does not exist on type 'Omit<Selectable<DealsTable>, "margin">'`.
261
+ * A row as a capability of `A` reads, filters and sorts it: a column whose own read actions leave out an action of `A`
262
+ * is absent, and so is one a union `A` with a `when` may not read (`HiddenFor`). The type keeps the generated row's
263
+ * name, so a read of a hidden column reports `Property 'margin' does not exist on type 'Omit<Selectable<DealsTable>, "margin">'`.
252
264
  */
253
- export type RowFor<E extends IndexedTable, A extends string> = [HiddenFor<E['reads'], A>] extends [never] ? E['row']
254
- : Omit<E['row'], HiddenFor<E['reads'], A>>
265
+ export type RowFor<E extends IndexedTable, A extends string> = [HiddenFor<E['reads'], A, E['conditioned']>] extends [never] ? E['row']
266
+ : Omit<E['row'], HiddenFor<E['reads'], A, E['conditioned']>>
255
267
 
256
268
  /** What a paved-road write answers: the key, and the new version of a versioned table. */
257
269
  export type Saved<E extends IndexedTable> = E['versioned'] extends true ? { readonly id: string; readonly version: number } : { readonly id: string }
@@ -390,22 +402,33 @@ export interface ListPage<Row> {
390
402
 
391
403
  export type OrderTerm<Row> = { [C in ComparableColumn<Row>]: readonly [C, 'asc' | 'desc'] }[ComparableColumn<Row>]
392
404
 
393
- export interface ListOptions<Row> {
394
- readonly where?: readonly ConditionTuple<Row>[]
395
- readonly orderBy?: readonly OrderTerm<Row>[]
405
+ /**
406
+ * What `list()` takes, by the conditions and order terms of its row. It is generic in those unions, not the row, so a
407
+ * handle that reads more columns, whose options take more, passes where one that reads fewer is expected.
408
+ */
409
+ export interface ListQuery<Condition, Order> {
410
+ readonly where?: readonly Condition[]
411
+ readonly orderBy?: readonly Order[]
396
412
  readonly limit?: number
397
413
  readonly after?: string
398
414
  }
415
+ /** `ListQuery` over the columns of `Row`. */
416
+ export type ListOptions<Row> = ListQuery<ConditionTuple<Row>, OrderTerm<Row>>
399
417
 
400
418
  /** What `all()` takes: a list's filter and order, and no page; it answers every row or refuses past `MAX_ALL_ROWS`. */
401
- export interface AllOptions<Row> {
402
- readonly where?: readonly ConditionTuple<Row>[]
403
- readonly orderBy?: readonly OrderTerm<Row>[]
419
+ export interface AllQuery<Condition, Order> {
420
+ readonly where?: readonly Condition[]
421
+ readonly orderBy?: readonly Order[]
404
422
  }
423
+ /** `AllQuery` over the columns of `Row`. */
424
+ export type AllOptions<Row> = AllQuery<ConditionTuple<Row>, OrderTerm<Row>>
405
425
 
406
- export interface CountOptions<Row> {
407
- readonly where?: readonly ConditionTuple<Row>[]
426
+ /** What `count()` takes: a list's filter. */
427
+ export interface CountQuery<Condition> {
428
+ readonly where?: readonly Condition[]
408
429
  }
430
+ /** `CountQuery` over the columns of `Row`. */
431
+ export type CountOptions<Row> = CountQuery<ConditionTuple<Row>>
409
432
 
410
433
  /** The target's own row: `ctx.db.target` (or `ctx.db.created`) of an `on`, `in` or `creates` endpoint. */
411
434
  export interface TargetRow<T extends string, E extends IndexedTable, A extends string, K extends DataKind, F extends TargetForm> {
@@ -485,15 +508,20 @@ export type ScopeTarget<Ix extends AnyDbIndex, D extends string, A extends strin
485
508
  /** A table listed in an `over` endpoint's dimension, read through its `Within`; a job claims a queue table's rows through it. */
486
509
  export interface WithinRows<T extends string, E extends IndexedTable, A extends string, K extends DataKind> {
487
510
  readonly claim: Claim<T, E, A, K>
488
- readonly list: A extends E['actions']['read'] ? (options?: ListOptions<RowFor<E, A>>) => Promise<ListPage<RowFor<E, A>>>
489
- : Unavailable<ListRefusal<T, E, A>>
490
- readonly all: A extends E['actions']['read'] ? (options?: AllOptions<RowFor<E, A>>) => Promise<RowFor<E, A>[]> : Unavailable<ListRefusal<T, E, A>>
491
- readonly count: A extends E['actions']['read'] ? (options?: CountOptions<RowFor<E, A>>) => Promise<number> : Unavailable<ListRefusal<T, E, A>>
492
- readonly aggregate: A extends E['actions']['read']
493
- ? <const S extends AggregateSpec<RowFor<E, A>>>(spec: S) => Promise<AggregateRow<RowFor<E, A>, S>[]>
494
- : Unavailable<ListRefusal<T, E, A>>
511
+ readonly list: WithinRead<T, E, A, (options?: ListOptions<RowFor<E, A>>) => Promise<ListPage<RowFor<E, A>>>>
512
+ readonly all: WithinRead<T, E, A, (options?: AllOptions<RowFor<E, A>>) => Promise<RowFor<E, A>[]>>
513
+ readonly count: WithinRead<T, E, A, (options?: CountOptions<RowFor<E, A>>) => Promise<number>>
514
+ readonly aggregate: WithinRead<T, E, A, <const S extends AggregateSpec<RowFor<E, A>>>(spec: S) => Promise<AggregateRow<RowFor<E, A>, S>[]>>
495
515
  }
496
516
 
517
+ /**
518
+ * `Member` where a `Within` of `A` lists the table by its read action. An alias, not inline in `WithinRows`: inline, a
519
+ * `Pick` of a handle that reads more columns is refused where one of fewer is expected. A `Within` typed for a union of
520
+ * actions reads its row by the union rule (`HiddenFor`), stricter than the one action it holds at run time.
521
+ */
522
+ type WithinRead<T extends string, E extends IndexedTable, A extends string, Member> = A extends E['actions']['read'] ? Member
523
+ : Unavailable<ListRefusal<T, E, A>>
524
+
497
525
  /** Inlined where used: an alias of its own would be printed by name, with the table's index entry spelled out. */
498
526
  type ListRefusal<T extends string, E extends IndexedTable, A extends string> = `a list of ${T} needs its read action '${
499
527
  & E['actions']['read']
@@ -528,8 +556,9 @@ type PublicRead<T extends string, E extends IndexedTable, A extends string, Memb
528
556
 
529
557
  /**
530
558
  * An application table under the capability of an `app` endpoint of action `A`, in a site of kind `K`; an `anyOf`
531
- * endpoint's `A` is its listed actions, and an operation any of them allows is typed. A column with its own read action
532
- * stays hidden there (`RowFor`): which listed actions the caller holds is known only at run time.
559
+ * endpoint's `A` is its listed actions, and an operation any of them allows is typed. A column with its own read actions
560
+ * shows only where every listed action is one of them and none has a `when` (`RowFor`): which listed actions the
561
+ * caller holds is known only at run time.
533
562
  */
534
563
  export interface ApplicationRows<T extends string, E extends IndexedTable, A extends string, K extends DataKind> {
535
564
  readonly list: AppList<T, E, A, (options?: ListOptions<RowFor<E, A>>) => Promise<ListPage<RowFor<E, A>>>>
package/src/tables.ts CHANGED
@@ -36,6 +36,7 @@ export { PolicyError } from './errors'
36
36
  export type { FileReference } from './file-references'
37
37
  export type {
38
38
  AllOptions,
39
+ AllQuery,
39
40
  AnyDbIndex,
40
41
  ApplicationRows,
41
42
  ApplicationTables,
@@ -46,6 +47,7 @@ export type {
46
47
  ClaimOptions,
47
48
  ContainedRows,
48
49
  CountOptions,
50
+ CountQuery,
49
51
  DataKind,
50
52
  DbIndex,
51
53
  FragmentTable,
@@ -54,6 +56,7 @@ export type {
54
56
  InsertMethod,
55
57
  ListOptions,
56
58
  ListPage,
59
+ ListQuery,
57
60
  NoUnscoped,
58
61
  OrderTerm,
59
62
  OwnerRow,
@@ -4,7 +4,7 @@ export { applicationSchema, Database, type DatabaseEngine, type Executor, type S
4
4
  export type { AllowedOperator, ComparisonOperator, ConditionTuple, ListOperator, NoColumns, NullOperator, PatternOperator, Primitive, ScopedSelect, } from './description';
5
5
  export { CAPABILITY_ERRORS, CapabilityError, type CapabilityErrorReason, DatabaseError, LeaseLostError, PolicyError, QUERY_REFUSALS, type QueryRefusal, QueryRefusedError, } from './errors';
6
6
  export type { JsonColumnValue, JsonValue } from './json';
7
- export type { AllOptions, AnyDbIndex, ChildRows, ContainedRows, CountOptions, DataKind, DbIndex, IndexedTable, ListOptions, ListPage, NoUnscoped, OrderTerm, OwnerRow, ReadOnlyUnscoped, ReferenceRows, ReferenceTables, RowFor, Saved, ScopeTarget, TargetForm, TargetRow, Unavailable, UnownedTarget, UnscopedDeclaration, UnscopedInsert, UnscopedMode, UnscopedRows, UnscopedTables, VersionArguments, WithinRows, WithinTables, } from './orm-types';
7
+ export type { AllOptions, AllQuery, AnyDbIndex, ChildRows, ContainedRows, CountOptions, CountQuery, DataKind, DbIndex, IndexedTable, ListOptions, ListPage, ListQuery, NoUnscoped, OrderTerm, OwnerRow, ReadOnlyUnscoped, ReferenceRows, ReferenceTables, RowFor, Saved, ScopeTarget, TargetForm, TargetRow, Unavailable, UnownedTarget, UnscopedDeclaration, UnscopedInsert, UnscopedMode, UnscopedRows, UnscopedTables, VersionArguments, WithinRows, WithinTables, } from './orm-types';
8
8
  export { type ChildPolicy, type ChildScope, type ColumnList, defineTables, type DimensionPolicy, type DimensionScope, type InsertValues, isTables, readTables, type RecordActions, type ReferencePolicy, type ReferenceScope, type RowOf, type TableActions, type TableInsert, Tables, type TableUpdate, type UpdateValues, type VersionColumn, type VocabularyTables, } from './policy';
9
9
  export { type AggregateRow, type AggregateSpec, type ChildListScope, type DataLayer, type DataLayerRuntime, scoped, type ScopedDatabase, } from './store';
10
10
  export { type TablePolicies, tablePolicies } from './tables';
@@ -42,6 +42,10 @@ type ColumnReadsOf<P, T> = PolicyOf<P, T> extends {
42
42
  readonly read: infer A extends string | readonly string[];
43
43
  } ? A extends readonly (infer L extends string)[] ? L : A : never;
44
44
  } : Record<never, never>;
45
+ /** The actions the table's `when` narrows; every action of a policy typed wider than its literal, which may hold one. */
46
+ type ConditionedOf<P, T> = PolicyOf<P, T> extends {
47
+ readonly when?: infer W;
48
+ } ? keyof NonNullable<W> & string : never;
45
49
  type ColumnPoliciesOf<P, T> = PolicyOf<P, T> extends {
46
50
  readonly columns: infer C;
47
51
  } ? C : never;
@@ -91,6 +95,8 @@ export interface IndexedTable {
91
95
  readonly row: object;
92
96
  /** The columns that declare their own read action. */
93
97
  readonly reads: object;
98
+ /** The actions whose `when` narrows the rows they reach. */
99
+ readonly conditioned: string;
94
100
  readonly insert: object;
95
101
  readonly update: object;
96
102
  /** Each action that updates the table, with the values it updates (`columns: { assignee: { write: 'tasks.assign' } }`). */
@@ -123,6 +129,7 @@ type IndexedTableOf<DB, P, T extends keyof P & keyof DB & string, V = unknown> =
123
129
  readonly appCount: AppActionsOf<P, T, 'appCount'>;
124
130
  readonly row: WithFiles<RowType<DB[T]>, FileColumnsOf<P, T>>;
125
131
  readonly reads: ColumnReadsOf<P, T>;
132
+ readonly conditioned: ConditionedOf<P, T>;
126
133
  readonly insert: WithFiles<InsertValues<DB, P, T>, FileColumnsOf<P, T>>;
127
134
  readonly update: WithFiles<UpdateValues<DB, P, T>, FileColumnsOf<P, T>>;
128
135
  readonly writes: {
@@ -263,20 +270,22 @@ type ChildrenOf<Ix extends AnyDbIndex, T> = Lookup<Ix['children'], T>;
263
270
  type ListedIn<Ix extends AnyDbIndex, D> = Lookup<Ix['listed'], D>;
264
271
  type WithinIn<Ix extends AnyDbIndex, D> = Lookup<Ix['within'], D>;
265
272
  /**
266
- * The columns a capability of action `A` cannot read: each whose own read actions do not include `A`. A union `A` (a
267
- * widened capability type) holds no single action provably, so it reads none of them.
273
+ * The columns a capability of `A` cannot read: each whose own read actions do not include every action of `A`. A union
274
+ * `A` (an `anyOf` endpoint's, or a widened capability type) reads one only where no action of it is `Conditioned`: the
275
+ * runtime answers it where every reaching action reads every row alone (`readsAsAction`), and the held ones are known
276
+ * only per request.
268
277
  */
269
- type HiddenFor<Reads, A> = {
270
- [C in keyof Reads]: IsSingle<A> extends true ? ([A] extends [Reads[C]] ? never : C) : C;
278
+ type HiddenFor<Reads, A, Conditioned> = {
279
+ [C in keyof Reads]: [A] extends [never] ? C : [A] extends [Reads[C]] ? (IsSingle<A> extends true ? never : [Extract<A, Conditioned>] extends [never] ? never : C) : C;
271
280
  }[keyof Reads];
272
281
  /** Whether `A` is one literal, not a union of several. */
273
282
  type IsSingle<A, All = A> = [A] extends [never] ? false : A extends unknown ? ([All] extends [A] ? true : false) : never;
274
283
  /**
275
- * A row as a capability of action `A` reads, filters and sorts it: a column that declares another read action is
276
- * absent. The type keeps the generated row's name, so a read of a hidden column reports
277
- * `Property 'margin' does not exist on type 'Omit<Selectable<DealsTable>, "margin">'`.
284
+ * A row as a capability of `A` reads, filters and sorts it: a column whose own read actions leave out an action of `A`
285
+ * is absent, and so is one a union `A` with a `when` may not read (`HiddenFor`). The type keeps the generated row's
286
+ * name, so a read of a hidden column reports `Property 'margin' does not exist on type 'Omit<Selectable<DealsTable>, "margin">'`.
278
287
  */
279
- export type RowFor<E extends IndexedTable, A extends string> = [HiddenFor<E['reads'], A>] extends [never] ? E['row'] : Omit<E['row'], HiddenFor<E['reads'], A>>;
288
+ export type RowFor<E extends IndexedTable, A extends string> = [HiddenFor<E['reads'], A, E['conditioned']>] extends [never] ? E['row'] : Omit<E['row'], HiddenFor<E['reads'], A, E['conditioned']>>;
280
289
  /** What a paved-road write answers: the key, and the new version of a versioned table. */
281
290
  export type Saved<E extends IndexedTable> = E['versioned'] extends true ? {
282
291
  readonly id: string;
@@ -383,20 +392,31 @@ export interface ListPage<Row> {
383
392
  export type OrderTerm<Row> = {
384
393
  [C in ComparableColumn<Row>]: readonly [C, 'asc' | 'desc'];
385
394
  }[ComparableColumn<Row>];
386
- export interface ListOptions<Row> {
387
- readonly where?: readonly ConditionTuple<Row>[];
388
- readonly orderBy?: readonly OrderTerm<Row>[];
395
+ /**
396
+ * What `list()` takes, by the conditions and order terms of its row. It is generic in those unions, not the row, so a
397
+ * handle that reads more columns, whose options take more, passes where one that reads fewer is expected.
398
+ */
399
+ export interface ListQuery<Condition, Order> {
400
+ readonly where?: readonly Condition[];
401
+ readonly orderBy?: readonly Order[];
389
402
  readonly limit?: number;
390
403
  readonly after?: string;
391
404
  }
405
+ /** `ListQuery` over the columns of `Row`. */
406
+ export type ListOptions<Row> = ListQuery<ConditionTuple<Row>, OrderTerm<Row>>;
392
407
  /** What `all()` takes: a list's filter and order, and no page; it answers every row or refuses past `MAX_ALL_ROWS`. */
393
- export interface AllOptions<Row> {
394
- readonly where?: readonly ConditionTuple<Row>[];
395
- readonly orderBy?: readonly OrderTerm<Row>[];
408
+ export interface AllQuery<Condition, Order> {
409
+ readonly where?: readonly Condition[];
410
+ readonly orderBy?: readonly Order[];
396
411
  }
397
- export interface CountOptions<Row> {
398
- readonly where?: readonly ConditionTuple<Row>[];
412
+ /** `AllQuery` over the columns of `Row`. */
413
+ export type AllOptions<Row> = AllQuery<ConditionTuple<Row>, OrderTerm<Row>>;
414
+ /** What `count()` takes: a list's filter. */
415
+ export interface CountQuery<Condition> {
416
+ readonly where?: readonly Condition[];
399
417
  }
418
+ /** `CountQuery` over the columns of `Row`. */
419
+ export type CountOptions<Row> = CountQuery<ConditionTuple<Row>>;
400
420
  /** The target's own row: `ctx.db.target` (or `ctx.db.created`) of an `on`, `in` or `creates` endpoint. */
401
421
  export interface TargetRow<T extends string, E extends IndexedTable, A extends string, K extends DataKind, F extends TargetForm> {
402
422
  /** The row; a column that declares another read action than `A` is hidden. */
@@ -454,11 +474,17 @@ export type ScopeTarget<Ix extends AnyDbIndex, D extends string, A extends strin
454
474
  /** A table listed in an `over` endpoint's dimension, read through its `Within`; a job claims a queue table's rows through it. */
455
475
  export interface WithinRows<T extends string, E extends IndexedTable, A extends string, K extends DataKind> {
456
476
  readonly claim: Claim<T, E, A, K>;
457
- readonly list: A extends E['actions']['read'] ? (options?: ListOptions<RowFor<E, A>>) => Promise<ListPage<RowFor<E, A>>> : Unavailable<ListRefusal<T, E, A>>;
458
- readonly all: A extends E['actions']['read'] ? (options?: AllOptions<RowFor<E, A>>) => Promise<RowFor<E, A>[]> : Unavailable<ListRefusal<T, E, A>>;
459
- readonly count: A extends E['actions']['read'] ? (options?: CountOptions<RowFor<E, A>>) => Promise<number> : Unavailable<ListRefusal<T, E, A>>;
460
- readonly aggregate: A extends E['actions']['read'] ? <const S extends AggregateSpec<RowFor<E, A>>>(spec: S) => Promise<AggregateRow<RowFor<E, A>, S>[]> : Unavailable<ListRefusal<T, E, A>>;
477
+ readonly list: WithinRead<T, E, A, (options?: ListOptions<RowFor<E, A>>) => Promise<ListPage<RowFor<E, A>>>>;
478
+ readonly all: WithinRead<T, E, A, (options?: AllOptions<RowFor<E, A>>) => Promise<RowFor<E, A>[]>>;
479
+ readonly count: WithinRead<T, E, A, (options?: CountOptions<RowFor<E, A>>) => Promise<number>>;
480
+ readonly aggregate: WithinRead<T, E, A, <const S extends AggregateSpec<RowFor<E, A>>>(spec: S) => Promise<AggregateRow<RowFor<E, A>, S>[]>>;
461
481
  }
482
+ /**
483
+ * `Member` where a `Within` of `A` lists the table by its read action. An alias, not inline in `WithinRows`: inline, a
484
+ * `Pick` of a handle that reads more columns is refused where one of fewer is expected. A `Within` typed for a union of
485
+ * actions reads its row by the union rule (`HiddenFor`), stricter than the one action it holds at run time.
486
+ */
487
+ type WithinRead<T extends string, E extends IndexedTable, A extends string, Member> = A extends E['actions']['read'] ? Member : Unavailable<ListRefusal<T, E, A>>;
462
488
  /** Inlined where used: an alias of its own would be printed by name, with the table's index entry spelled out. */
463
489
  type ListRefusal<T extends string, E extends IndexedTable, A extends string> = `a list of ${T} needs its read action '${E['actions']['read'] & string}', and this endpoint holds '${A}'`;
464
490
  /**
@@ -479,8 +505,9 @@ type AppGet<T extends string, E extends IndexedTable, A extends string, Member>
479
505
  type PublicRead<T extends string, E extends IndexedTable, A extends string, Member> = [E['readsAny']] extends [true] ? Unavailable<`a public procedure does not read ${T}: it is read with 'any', which an app endpoint, a job and a webhook hold`> : A extends E['actions']['read'] ? Member : Unavailable<ListRefusal<T, E, A>>;
480
506
  /**
481
507
  * An application table under the capability of an `app` endpoint of action `A`, in a site of kind `K`; an `anyOf`
482
- * endpoint's `A` is its listed actions, and an operation any of them allows is typed. A column with its own read action
483
- * stays hidden there (`RowFor`): which listed actions the caller holds is known only at run time.
508
+ * endpoint's `A` is its listed actions, and an operation any of them allows is typed. A column with its own read actions
509
+ * shows only where every listed action is one of them and none has a `when` (`RowFor`): which listed actions the
510
+ * caller holds is known only at run time.
484
511
  */
485
512
  export interface ApplicationRows<T extends string, E extends IndexedTable, A extends string, K extends DataKind> {
486
513
  readonly list: AppList<T, E, A, (options?: ListOptions<RowFor<E, A>>) => Promise<ListPage<RowFor<E, A>>>>;
@@ -5,7 +5,7 @@ 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 { AllOptions, 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
10
  export type { ColumnTypes, ColumnViews, DefineVocabularyPolicies, NormalizedPolicies, TableVocabulary, TypedColumnList, VocabularyAction, VocabularyChildScope, VocabularyContainer, VocabularyContainerOf, VocabularyDimension, VocabularyDimensionScope, VocabularyPolicyMap, VocabularyTablePolicy, VocabularyViewPolicy, } from './vocabulary-tables';
11
11
  /**