@lunora/server 1.0.0-alpha.28 → 1.0.0-alpha.280

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 (104) hide show
  1. package/LICENSE.md +414 -104
  2. package/README.md +21 -15
  3. package/dist/data-model.d.mts +323 -78
  4. package/dist/data-model.d.ts +323 -78
  5. package/dist/data-model.mjs +0 -1
  6. package/dist/drizzle.mjs +1 -1
  7. package/dist/in-process.d.mts +115 -0
  8. package/dist/in-process.d.ts +115 -0
  9. package/dist/in-process.mjs +1 -0
  10. package/dist/index.d.mts +3593 -1124
  11. package/dist/index.d.ts +3593 -1124
  12. package/dist/index.mjs +1 -29
  13. package/dist/otel.d.mts +597 -0
  14. package/dist/otel.d.ts +597 -0
  15. package/dist/otel.mjs +1 -0
  16. package/dist/packem_shared/ACTION_CACHE_DEFAULT_TTL_MS-Dv4DKrj0.mjs +1 -0
  17. package/dist/packem_shared/DEFAULT_LIMIT-pT_tV8R0.mjs +1 -0
  18. package/dist/packem_shared/DOCUMENT_HISTORY_REDACTED_FIELDS-BCa6sLSJ.mjs +1 -0
  19. package/dist/packem_shared/LunoraEnvError-06_Zc4yc.mjs +3 -0
  20. package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-aj9Ec70J.mjs +1 -0
  21. package/dist/packem_shared/PROCEDURE_META-DVzrXpfa.mjs +1 -0
  22. package/dist/packem_shared/allowAll-DkRAgItV.mjs +1 -0
  23. package/dist/packem_shared/apply-output-C5wZ5EAL.mjs +1 -0
  24. package/dist/packem_shared/asBucketStorage-DoGYOjq3.mjs +1 -0
  25. package/dist/packem_shared/assertShapesDeclareReadPolicies-C09SMvM4.mjs +1 -0
  26. package/dist/packem_shared/authorize-CVLZJxf_.mjs +1 -0
  27. package/dist/packem_shared/beginDeferredDeletes-DhwFBbvs.mjs +1 -0
  28. package/dist/packem_shared/beginDeferredSchedules-BTwq-NUO.mjs +1 -0
  29. package/dist/packem_shared/bindOrm-D5mVDvbi.mjs +1 -0
  30. package/dist/packem_shared/buildMaskRegistry-DpWMtalG.mjs +1 -0
  31. package/dist/packem_shared/compose-middleware-BK9FlblN.mjs +1 -0
  32. package/dist/packem_shared/composePluginMiddleware-3e7F9JIa.mjs +1 -0
  33. package/dist/packem_shared/context-identity-B2XYGA0B.mjs +1 -0
  34. package/dist/packem_shared/createPolicyDsl-BZa6SqLJ.mjs +1 -0
  35. package/dist/packem_shared/createSecrets-D6rLB42U.mjs +1 -0
  36. package/dist/packem_shared/createServices-IJvoqi0e.mjs +1 -0
  37. package/dist/packem_shared/defineAggregateIndex-C3xWV-Dr.mjs +1 -0
  38. package/dist/packem_shared/defineIdentity-DwkNKwYa.mjs +1 -0
  39. package/dist/packem_shared/defineIdentityGuard-Bt8N65Zs.mjs +1 -0
  40. package/dist/packem_shared/defineLiveStream-q9yO3wl6.mjs +1 -0
  41. package/dist/packem_shared/defineMigration-CXOS0Bvq.mjs +1 -0
  42. package/dist/packem_shared/defineModule-OecXWM3U.mjs +1 -0
  43. package/dist/packem_shared/defineMutator-DlLFSWbO.mjs +1 -0
  44. package/dist/packem_shared/defineRoom-CoGi-xwm.mjs +1 -0
  45. package/dist/packem_shared/defineShape-H-0IbZlb.mjs +1 -0
  46. package/dist/packem_shared/defineStorageRule-Dv4nJE0H.mjs +1 -0
  47. package/dist/packem_shared/defineWebSocket-BHoy6_ox.mjs +1 -0
  48. package/dist/packem_shared/fnv1a-D3ueNTWB.mjs +1 -0
  49. package/dist/packem_shared/functions-QFoBUe9t.mjs +1 -0
  50. package/dist/packem_shared/httpAction-Bfw3qwLG.mjs +1 -0
  51. package/dist/packem_shared/initLunora-DcvCGLL_.mjs +1 -0
  52. package/dist/packem_shared/isPerDispatchMiddleware-DDQPatSm.mjs +1 -0
  53. package/dist/packem_shared/isSafeHeaderValue-DswDADFy.mjs +6 -0
  54. package/dist/packem_shared/mask-DHJtsP7t.mjs +1 -0
  55. package/dist/packem_shared/middleware-CHYtnvZP.mjs +1 -0
  56. package/dist/packem_shared/onConnect-BLRoOpv2.mjs +1 -0
  57. package/dist/packem_shared/onQueryChange-iuLzmyPs.mjs +1 -0
  58. package/dist/packem_shared/onWhisper-CfDbFLQh.mjs +1 -0
  59. package/dist/packem_shared/platformAdmin-kczXQme8.mjs +1 -0
  60. package/dist/packem_shared/plugin-CyLqvCB9.mjs +1 -0
  61. package/dist/packem_shared/policy-tag-V0lqFzgS.mjs +1 -0
  62. package/dist/packem_shared/protectPublic-Bi5_95aP.mjs +1 -0
  63. package/dist/packem_shared/redact-secrets-BpatNz48.mjs +2 -0
  64. package/dist/packem_shared/redactSecrets-Dmh9pHZu.mjs +1 -0
  65. package/dist/packem_shared/rls-CvWnjgtq.mjs +1 -0
  66. package/dist/packem_shared/run-middleware-BefYq7Xd.mjs +1 -0
  67. package/dist/packem_shared/serveStorageObject-CLz3qhNI.mjs +1 -0
  68. package/dist/packem_shared/storageRules-BVIXkoRg.mjs +1 -0
  69. package/dist/packem_shared/{types.d-C4CMJK8x.d.mts → types.d-B7FLdYUD.d.mts} +15 -8
  70. package/dist/packem_shared/{types.d-DdYF8E18.d.ts → types.d-BCtjbIzl.d.ts} +15 -8
  71. package/dist/packem_shared/types.d-CJnJltzy.d.mts +3025 -0
  72. package/dist/packem_shared/types.d-CJnJltzy.d.ts +3025 -0
  73. package/dist/rls/testing.d.mts +13 -5
  74. package/dist/rls/testing.d.ts +13 -5
  75. package/dist/rls/testing.mjs +1 -49
  76. package/dist/types.d.mts +2 -1373
  77. package/dist/types.d.ts +2 -1373
  78. package/dist/types.mjs +0 -31
  79. package/package.json +28 -8
  80. package/dist/packem_shared/LunoraEnvError-BGmd1Qs0.mjs +0 -187
  81. package/dist/packem_shared/LunoraError-WbxmrpxR.mjs +0 -9
  82. package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-Cv1UPaJj.mjs +0 -114
  83. package/dist/packem_shared/asBucketStorage-Cnxd9y2q.mjs +0 -11
  84. package/dist/packem_shared/bindOrm-Bfgl7f-Q.mjs +0 -146
  85. package/dist/packem_shared/buildRlsReadRegistry-D54vUQe4.mjs +0 -107
  86. package/dist/packem_shared/composePluginMiddleware-z62dttBo.mjs +0 -103
  87. package/dist/packem_shared/createPolicyDsl-By3QB4he.mjs +0 -32
  88. package/dist/packem_shared/createSecrets-DwaR2rNG.mjs +0 -58
  89. package/dist/packem_shared/defineAggregateIndex-DTULzh09.mjs +0 -333
  90. package/dist/packem_shared/defineIdentity-DiX4zM9x.mjs +0 -35
  91. package/dist/packem_shared/defineMigration-Hx01yIht.mjs +0 -10
  92. package/dist/packem_shared/defineMutator-EIXAWhs9.mjs +0 -11
  93. package/dist/packem_shared/defineShape-C5scNOrf.mjs +0 -18
  94. package/dist/packem_shared/defineStorageRule-B5nL4Z1P.mjs +0 -23
  95. package/dist/packem_shared/functions-Di9FUNkf.mjs +0 -5
  96. package/dist/packem_shared/httpAction-DCXoYPIk.mjs +0 -355
  97. package/dist/packem_shared/initLunora-CmMVk4i7.mjs +0 -107
  98. package/dist/packem_shared/mask-CZuu9WAF.mjs +0 -331
  99. package/dist/packem_shared/onConnect-CIPXKPyw.mjs +0 -13
  100. package/dist/packem_shared/policy-tag-DvpVH2tv.mjs +0 -13
  101. package/dist/packem_shared/protectPublic-BlcGpiRc.mjs +0 -15
  102. package/dist/packem_shared/rls-B_ZWgslr.mjs +0 -595
  103. package/dist/packem_shared/run-middleware-I6EiQfxL.mjs +0 -20
  104. package/dist/packem_shared/storageRules-6QxzDOcx.mjs +0 -88
@@ -20,6 +20,125 @@
20
20
  * so this module needs no reference to the project-local `OneRelation` /
21
21
  * `ManyRelation` aliases the codegen still emits.
22
22
  */
23
+ /**
24
+ * A value stored as a plain JS object: not a scalar (an `Id<T>` is a branded string, which is an `object` to
25
+ * TypeScript but has no keys worth offering), an array, a date, bytes, a bigint or a function.
26
+ */
27
+ type IsPlainObject<V> = V extends string | number | boolean | bigint | symbol ? false : V extends ReadonlyArray<unknown> ? false : V extends Date | Uint8Array | ArrayBuffer | bigint | ((...arguments_: never[]) => unknown) ? false : V extends object ? true : false;
28
+ /** The dotted paths below an object, to three steps. */
29
+ type SubPaths<V, Depth extends unknown[]> = Depth["length"] extends 3 ? never : [IsPlainObject<V>] extends [true] ? { [K in keyof V & string]-?: K | `${K}.${SubPaths<NonNullable<V[K]>, [...Depth, 0]>}`; }[keyof V & string] : never;
30
+ /** The type at the end of dotted path `P` below `V`. */
31
+ type PathValue<V, P extends string> = P extends `${infer Head}.${infer Rest}` ? Head extends keyof V ? PathValue<NonNullable<V[Head]>, Rest> : never : P extends keyof V ? V[P] : never;
32
+ /**
33
+ * Every dotted path into an object-valued column of `Doc` (`"profile.address.city"`), at most four segments
34
+ * counting the column. A column that is not a plain object contributes none.
35
+ */
36
+ type ColumnPaths<Doc> = { [K in keyof Doc & string]-?: [IsPlainObject<NonNullable<Doc[K]>>] extends [true] ? `${K}.${SubPaths<NonNullable<Doc[K]>, []>}` : never; }[keyof Doc & string];
37
+ /** The type at the end of a {@link ColumnPaths} path. */
38
+ type DocPathValue<Doc, P extends string> = P extends `${infer Column}.${infer Rest}` ? Column extends keyof Doc ? PathValue<NonNullable<Doc[Column]>, Rest> : never : never;
39
+ type ScalarLeaf = boolean | number | string | null | undefined;
40
+ /** The dotted paths into an object column that end at a string, number or boolean. */
41
+ type ScalarPaths<Doc> = { [P in ColumnPaths<Doc>]: [DocPathValue<Doc, P>] extends [ScalarLeaf] ? P : never; }[ColumnPaths<Doc>];
42
+ /**
43
+ * `where` keys that reach into an object column: `{ "profile.plan": "pro" }`. Only paths that end at a string,
44
+ * number or boolean are offered — an object, array, date, bigint or bytes leaf has no single SQL comparison.
45
+ *
46
+ * `unknown` (the identity for `&`) when there are none, never `{}`: intersecting with an empty object type
47
+ * switches off the weak-type check that rejects a `where` key naming nothing.
48
+ */
49
+ type PathWhere<Doc, Paths extends string = ScalarPaths<Doc>> = [Paths] extends [never] ? unknown : { [P in Paths]?: DocPathValue<Doc, P> | WhereOperators<DocPathValue<Doc, P>>; };
50
+ /** `patch` keys that set one value inside an object column, keeping its siblings: `{ "profile.plan": "pro" }`. */
51
+ type PathPatch<Doc, Paths extends string = ColumnPaths<Doc>> = [Paths] extends [never] ? unknown : { [P in Paths]?: DocPathValue<Doc, P>; };
52
+ /**
53
+ * The relation-predicate portion of {@link WhereOf}: each declared relation on
54
+ * `T` contributes a kind-dispatched node — `one` → `{ is?; isNot? }`, `many` →
55
+ * `{ some?; none?; every? }` — whose inner type is the target table's own
56
+ * relation-aware `where` (so multi-hop predicates type-check inside-out).
57
+ */
58
+ type RelationWhere<DM, REL extends Record<keyof DM, object>, T extends keyof DM> = { [K in keyof REL[T]]?: REL[T][K] extends {
59
+ __relationKind: "one";
60
+ __target: infer Target extends keyof DM;
61
+ } ? OneRelationWhere<WhereOf<DM, REL, Target>> : REL[T][K] extends {
62
+ __relationKind: "many";
63
+ __target: infer Target extends keyof DM;
64
+ } ? ManyRelationWhere<WhereOf<DM, REL, Target>> : never; };
65
+ /** The nested `with` sub-argument inside a relation's with-value, or `{}`. */
66
+ type NestedWithArgument<WK> = WK extends {
67
+ with: infer NW;
68
+ } ? NW : {};
69
+ /** The nested `select` tuple inside a relation's with-value, or `undefined` (no projection). */
70
+ type NestedSelectArgument<WK> = WK extends {
71
+ select: infer S;
72
+ } ? S : undefined;
73
+ /**
74
+ * Resolve a single relation descriptor + its with-value to the loaded type,
75
+ * threading the nested `select` tuple into the projected child shape (the 5th
76
+ * `LoadWith` arg) so `with: { author: { select: ["name"] } }` narrows the loaded
77
+ * `author` to the selected columns + system fields.
78
+ */
79
+ type LoadRelation<DM, REL extends Record<keyof DM, object>, R, WK> = R extends {
80
+ __relationKind: "one";
81
+ __target: infer Target extends keyof DM;
82
+ } ? LoadWith<DM, REL, Target, NestedWithArgument<WK>, NestedSelectArgument<WK>> | null : R extends {
83
+ __relationKind: "many";
84
+ __target: infer Target extends keyof DM;
85
+ } ? LoadWith<DM, REL, Target, NestedWithArgument<WK>, NestedSelectArgument<WK>>[] : never;
86
+ /** The relation keys of `W` that were actually requested (not `false`/`undefined`). */
87
+ type LoadedRelations<DM, REL extends Record<keyof DM, object>, T extends keyof DM, W> = { [K in keyof W as K extends keyof REL[T] ? (W[K] extends false | undefined ? never : K) : never]: K extends keyof REL[T] ? LoadRelation<DM, REL, REL[T][K], W[K]> : never; };
88
+ /** The `_count` projection of `W`, if any. */
89
+ type LoadedCount<W> = W extends {
90
+ _count: infer C;
91
+ } ? {
92
+ _count: { [K in keyof C]: number; };
93
+ } : {};
94
+ /** System columns a `select` projection always retains, so cursors and by-id reuse keep working. */
95
+ type SelectAlwaysKeep<DM, T extends keyof DM> = ("_creationTime" | "_id") & keyof DM[T];
96
+ /**
97
+ * `DM[T]` narrowed to the columns named by a `select` tuple `S` (plus the system
98
+ * fields). `undefined` (the default — no `select`) keeps the full document.
99
+ */
100
+ type ProjectDoc<DM, T extends keyof DM, S> = S extends ReadonlyArray<infer K> ? (K extends keyof DM[T] ? Pick<DM[T], (K & keyof DM[T]) | SelectAlwaysKeep<DM, T>> : DM[T]) : DM[T];
101
+ /**
102
+ * An atomic update for a number column, applied to the value the row holds when the
103
+ * write runs: `{ increment: 1 }`, `{ decrement: 1 }`, `{ multiply: 2 }`, `{ divide: 2 }`.
104
+ * The column must already hold a finite number; a result that is not finite is rejected.
105
+ */
106
+ type NumberFieldOperator = {
107
+ decrement: number;
108
+ divide?: never;
109
+ increment?: never;
110
+ multiply?: never;
111
+ } | {
112
+ decrement?: never;
113
+ divide: number;
114
+ increment?: never;
115
+ multiply?: never;
116
+ } | {
117
+ decrement?: never;
118
+ divide?: never;
119
+ increment: number;
120
+ multiply?: never;
121
+ } | {
122
+ decrement?: never;
123
+ divide?: never;
124
+ increment?: never;
125
+ multiply: number;
126
+ };
127
+ /** An atomic update for a boolean column: `{ toggle: true }` flips the stored value. */
128
+ interface BooleanFieldOperator {
129
+ toggle: true;
130
+ }
131
+ /**
132
+ * The operator a column of type `T` takes: arithmetic when `T` is exactly `number` (so a literal union
133
+ * such as `1 | 2` is out — the result could leave the set — and so is `number | string`, which the
134
+ * store does not treat as a number column), `{ toggle: true }` when it is exactly `boolean`.
135
+ */
136
+ type OperatorFor<T> = [T] extends [number] ? [number] extends [T] ? NumberFieldOperator : never : [T] extends [boolean] ? [boolean] extends [T] ? BooleanFieldOperator : never : never;
137
+ /** The foreign-key columns of a table's to-one relations — the keys a nested `connect` supplies. */
138
+ type OneRelationFields<RelT> = { [K in keyof RelT]: RelT[K] extends {
139
+ __field: infer Field extends string;
140
+ __relationKind: "one";
141
+ } ? Field : never; }[keyof RelT];
23
142
  /** A branded id for table `TName`. Structurally a `string` at runtime. */
24
143
  type Id<TName extends string> = string & {
25
144
  readonly __table: TName;
@@ -38,13 +157,23 @@ interface WhereOperators<T> {
38
157
  notIn?: T[];
39
158
  }
40
159
  /** A typed `where` tree over a document's columns. */
41
- type Where<TDocument> = { [K in keyof TDocument]?: TDocument[K] | WhereOperators<TDocument[K]>; } & {
160
+ type Where<TDocument> = PathWhere<TDocument> & { [K in keyof TDocument]?: TDocument[K] | WhereOperators<TDocument[K]>; } & {
42
161
  AND?: Where<TDocument>[];
43
162
  NOT?: Where<TDocument>;
44
163
  OR?: Where<TDocument>[];
45
164
  };
46
- /** One `{ field: "asc" | "desc" }` ordering entry; `orderBy` is an ordered list. */
47
- type OrderBy<TDocument> = Partial<Record<keyof TDocument, "asc" | "desc">>;
165
+ /**
166
+ * One ordering entry; `orderBy` is an ordered list. `{ field: "asc" | "desc" }` sorts NULLs first
167
+ * ascending and last descending. `{ field: { sort: "desc", nulls: "first" } }` places them yourself.
168
+ *
169
+ * A placement other than the default can change the query plan (see Pagination in the docs), so
170
+ * measure a hot read. It has no effect on a column that cannot hold NULL. Keep the same `orderBy` for every page of a
171
+ * paginated read, as a cursor is only valid against the ordering that minted it.
172
+ */
173
+ type OrderBy<TDocument> = Partial<Record<keyof TDocument | ScalarPaths<TDocument>, "asc" | "desc" | {
174
+ nulls: "first" | "last";
175
+ sort: "asc" | "desc";
176
+ }>>;
48
177
  interface QueryArgs<TDocument> {
49
178
  cursor?: null | string;
50
179
  limit?: number;
@@ -77,33 +206,33 @@ interface ManyRelationWhere<W> {
77
206
  none?: W;
78
207
  some?: W;
79
208
  }
80
- /**
81
- * The relation-predicate portion of {@link WhereOf}: each declared relation on
82
- * `T` contributes a kind-dispatched node — `one` → `{ is?; isNot? }`, `many` →
83
- * `{ some?; none?; every? }` — whose inner type is the target table's own
84
- * relation-aware `where` (so multi-hop predicates type-check inside-out).
85
- */
86
- type RelationWhere<DM, REL extends Record<keyof DM, object>, T extends keyof DM> = { [K in keyof REL[T]]?: REL[T][K] extends {
87
- __relationKind: "one";
88
- __target: infer Target extends keyof DM;
89
- } ? OneRelationWhere<WhereOf<DM, REL, Target>> : REL[T][K] extends {
90
- __relationKind: "many";
91
- __target: infer Target extends keyof DM;
92
- } ? ManyRelationWhere<WhereOf<DM, REL, Target>> : never; };
93
209
  /**
94
210
  * Relation-aware `where` tree — the column predicates of {@link Where} plus
95
211
  * Prisma-style relation predicates resolved by the `@lunora/do` pre-resolver.
96
- * `Where&lt;DM[T]>` stays the column-only structural mirror for back-compat; the
212
+ * `Where<DM[T]>` stays the column-only structural mirror for back-compat; the
97
213
  * table facade threads `REL` through this richer form.
98
214
  */
99
- type WhereOf<DM, REL extends Record<keyof DM, object>, T extends keyof DM> = RelationWhere<DM, REL, T> & { [K in keyof DM[T]]?: DM[T][K] | WhereOperators<DM[T][K]>; } & {
215
+ type WhereOf<DM, REL extends Record<keyof DM, object>, T extends keyof DM> = PathWhere<DM[T]> & RelationWhere<DM, REL, T> & { [K in keyof DM[T]]?: DM[T][K] | WhereOperators<DM[T][K]>; } & {
100
216
  AND?: WhereOf<DM, REL, T>[];
101
217
  NOT?: WhereOf<DM, REL, T>;
102
218
  OR?: WhereOf<DM, REL, T>[];
103
219
  };
104
220
  /** {@link QueryArgs} with the relation-aware {@link WhereOf} `where` typing. */
105
221
  interface QueryArgsOf<DM, REL extends Record<keyof DM, object>, T extends keyof DM> {
222
+ /** Read the authoritative copy, not a replica. Only a `.global()` D1 table can lag; shard-local reads are already authoritative. */
223
+ consistency?: "primary";
106
224
  cursor?: null | string;
225
+ /**
226
+ * Pin the page's end to an earlier page's `continueCursor`, for reactive pagination: the read is
227
+ * the fixed range `(cursor, endCursor]` under this call's `orderBy`, so a row inserted inside it
228
+ * grows this page and the next page (starting at `endCursor`) is unchanged. The result is
229
+ * `isDone: true`, echoes `endCursor` as `continueCursor`, and carries `splitCursor`.
230
+ *
231
+ * `limit` still caps the read. A range it cuts short answers `splitRequired: true`, and the
232
+ * client splits it at `splitCursor`, so the rows past the cap come back in the second half. On
233
+ * a `.global()` table a read with no `limit` is capped at 4096 rows the same way.
234
+ */
235
+ endCursor?: null | string;
107
236
  /**
108
237
  * Include soft-deleted rows (`.softDelete()` tables only). Default hides them;
109
238
  * `true` returns deleted rows alongside live ones. No effect on a table
@@ -118,15 +247,17 @@ interface QueryPage<TDocument> {
118
247
  continueCursor: null | string;
119
248
  isDone: boolean;
120
249
  page: TDocument[];
250
+ /**
251
+ * Only on an `endCursor` read: the cursor of the page's midpoint row, `null` under two rows. Paging
252
+ * `(cursor, splitCursor]` and `(splitCursor, endCursor]` reproduces the range in two halves.
253
+ */
254
+ splitCursor?: null | string;
255
+ /**
256
+ * Only on an `endCursor` read that `limit` (or the global read cap) cut short: the page holds
257
+ * the first rows of its range, and splitting at `splitCursor` is the way to reach the rest.
258
+ */
259
+ splitRequired?: boolean;
121
260
  }
122
- /** The nested `with` sub-argument inside a relation's with-value, or `{}`. */
123
- type NestedWithArgument<WK> = WK extends {
124
- with: infer NW;
125
- } ? NW : {};
126
- /** The nested `select` tuple inside a relation's with-value, or `undefined` (no projection). */
127
- type NestedSelectArgument<WK> = WK extends {
128
- select: infer S;
129
- } ? S : undefined;
130
261
  /**
131
262
  * The `with` argument for table `T`: each relation can be `true` (load with no
132
263
  * refinements) or an object. `many` relations accept `where`/`orderBy`/`limit`/
@@ -148,35 +279,7 @@ type WithArg<DM, REL extends Record<keyof DM, object>, T extends keyof DM> = { [
148
279
  _count?: { [K in keyof REL[T]]?: true; };
149
280
  };
150
281
  /**
151
- * Resolve a single relation descriptor + its with-value to the loaded type,
152
- * threading the nested `select` tuple into the projected child shape (the 5th
153
- * `LoadWith` arg) so `with: { author: { select: ["name"] } }` narrows the loaded
154
- * `author` to the selected columns + system fields.
155
- */
156
- type LoadRelation<DM, REL extends Record<keyof DM, object>, R, WK> = R extends {
157
- __relationKind: "one";
158
- __target: infer Target extends keyof DM;
159
- } ? LoadWith<DM, REL, Target, NestedWithArgument<WK>, NestedSelectArgument<WK>> | null : R extends {
160
- __relationKind: "many";
161
- __target: infer Target extends keyof DM;
162
- } ? LoadWith<DM, REL, Target, NestedWithArgument<WK>, NestedSelectArgument<WK>>[] : never;
163
- /** The relation keys of `W` that were actually requested (not `false`/`undefined`). */
164
- type LoadedRelations<DM, REL extends Record<keyof DM, object>, T extends keyof DM, W> = { [K in keyof W as K extends keyof REL[T] ? (W[K] extends false | undefined ? never : K) : never]: K extends keyof REL[T] ? LoadRelation<DM, REL, REL[T][K], W[K]> : never; };
165
- /** The `_count` projection of `W`, if any. */
166
- type LoadedCount<W> = W extends {
167
- _count: infer C;
168
- } ? {
169
- _count: { [K in keyof C]: number; };
170
- } : {};
171
- /** System columns a `select` projection always retains, so cursors and by-id reuse keep working. */
172
- type SelectAlwaysKeep<DM, T extends keyof DM> = ("_creationTime" | "_id") & keyof DM[T];
173
- /**
174
- * `DM[T]` narrowed to the columns named by a `select` tuple `S` (plus the system
175
- * fields). `undefined` (the default — no `select`) keeps the full document.
176
- */
177
- type ProjectDoc<DM, T extends keyof DM, S> = S extends ReadonlyArray<infer K> ? (K extends keyof DM[T] ? Pick<DM[T], (K & keyof DM[T]) | SelectAlwaysKeep<DM, T>> : DM[T]) : DM[T];
178
- /**
179
- * `Doc&lt;T>` narrowed to exactly the relations requested in the with-arg `W` and,
282
+ * `Doc<T>` narrowed to exactly the relations requested in the with-arg `W` and,
180
283
  * when a `select` tuple `S` is supplied, to its projected columns. `S` defaults
181
284
  * to `undefined` so the 4-argument form (the codegen-emitted callers) keeps the
182
285
  * full document.
@@ -207,7 +310,7 @@ interface RestrictableQueryOptionsOf<DM, REL extends Record<keyof DM, object>, T
207
310
  restrictsCounts?: boolean;
208
311
  where?: WhereOf<DM, REL, T>;
209
312
  }
210
- /** Args for `ctx.db.&lt;table>.aggregate({ op, field?, where? })`. */
313
+ /** Args for `ctx.db.<table>.aggregate({ op, field?, where? })`. */
211
314
  interface TableAggregateOptions<TDocument> extends RestrictableQueryOptions<TDocument> {
212
315
  field?: keyof TDocument & string;
213
316
  op: AggregateOp;
@@ -217,7 +320,7 @@ interface TableAggregateOptionsOf<DM, REL extends Record<keyof DM, object>, T ex
217
320
  field?: keyof DM[T] & string;
218
321
  op: AggregateOp;
219
322
  }
220
- /** Args for `ctx.db.&lt;table>.groupBy({ by, agg?, where? })`. */
323
+ /** Args for `ctx.db.<table>.groupBy({ by, agg?, where? })`. */
221
324
  interface TableGroupByOptions<TDocument> extends RestrictableQueryOptions<TDocument> {
222
325
  agg?: {
223
326
  field?: keyof TDocument & string;
@@ -238,7 +341,7 @@ interface GroupByEntry<TDocument> {
238
341
  key: Partial<TDocument>;
239
342
  value: null | number;
240
343
  }
241
- /** Args for `ctx.db.&lt;table>.rank(name, args)`. `row` is either an id or a row doc. */
344
+ /** Args for `ctx.db.<table>.rank(name, args)`. `row` is either an id or a row doc. */
242
345
  interface TableRankOptions<TDocument> extends RestrictableQueryOptions<TDocument> {
243
346
  row: string | TDocument;
244
347
  }
@@ -247,7 +350,7 @@ interface RankResult {
247
350
  position: number;
248
351
  total: number;
249
352
  }
250
- /** Args for `ctx.db.&lt;table>.rankPage(name, args)`. */
353
+ /** Args for `ctx.db.<table>.rankPage(name, args)`. */
251
354
  interface TableRankPageOptions<TDocument> extends RestrictableQueryOptions<TDocument> {
252
355
  cursor?: null | string;
253
356
  take?: number;
@@ -275,12 +378,63 @@ interface SearchFilterBuilder<TDocument> {
275
378
  */
276
379
  interface SearchReader<TDocument> {
277
380
  collect: () => Promise<TDocument[]>;
381
+ /**
382
+ * Like `.collect()`, but pairs each matched document with the relevance
383
+ * score the FTS engine already computed to produce the descending order —
384
+ * `.collect()` throws it away after sorting by it, this surfaces it
385
+ * instead. Ordered by `score` descending, same order as `.collect()`.
386
+ */
387
+ collectWithScores: () => Promise<{
388
+ document: TDocument;
389
+ score: number;
390
+ }[]>;
278
391
  first: () => Promise<TDocument | null>;
279
392
  take: (limit: number) => Promise<TDocument[]>;
280
393
  unique: () => Promise<TDocument | null>;
281
394
  }
282
- /** Read-only typed table accessor exposed on `QueryCtx.db.&lt;table>`. */
283
- interface TableReaderFacade<DM, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, T extends keyof DM> {
395
+ /** A latitude/longitude point (WGS84 decimal degrees) accepted by geo queries. */
396
+ interface GeoPointInput {
397
+ lat: number;
398
+ lng: number;
399
+ }
400
+ /** An axis-aligned latitude/longitude bounding box (`sw`/`ne` corners). */
401
+ interface GeoBoundingBox {
402
+ ne: GeoPointInput;
403
+ sw: GeoPointInput;
404
+ }
405
+ /**
406
+ * Builder passed to `.withGeoIndex(name, q => …)`. Call exactly one of
407
+ * `.near(point, radiusMeters)` (proximity, nearest-first) or `.within(box)`
408
+ * (bounding-box).
409
+ */
410
+ interface GeoFilterBuilder {
411
+ near: (point: GeoPointInput, radiusMeters: number) => GeoFilterBuilder;
412
+ within: (box: GeoBoundingBox) => GeoFilterBuilder;
413
+ }
414
+ /**
415
+ * Chainable reader returned by `.withGeoIndex()`. `.near()` results come back
416
+ * ordered nearest-first; `.within()` results by row creation time. `.paginate()`
417
+ * is intentionally absent — cap the result set with `.take(n)`.
418
+ */
419
+ interface GeoReader<TDocument> {
420
+ collect: () => Promise<TDocument[]>;
421
+ /**
422
+ * Like `.collect()`, but pairs each matched document with the distance
423
+ * (in meters) from `.near()`'s point that the read already computed to
424
+ * produce the nearest-first order. `.within()` box matches have no
425
+ * point-distance metric, so `distanceMeters` is `null` for those rows
426
+ * rather than a misleading `0`.
427
+ */
428
+ collectWithScores: () => Promise<{
429
+ distanceMeters: null | number;
430
+ document: TDocument;
431
+ }[]>;
432
+ first: () => Promise<TDocument | null>;
433
+ take: (limit: number) => Promise<TDocument[]>;
434
+ unique: () => Promise<TDocument | null>;
435
+ }
436
+ /** Read-only typed table accessor exposed on `QueryCtx.db.<table>`. */
437
+ interface TableReaderFacade<DM, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, T extends keyof DM, GEO extends Record<keyof DM, string> = Record<keyof DM, never>> {
284
438
  /**
285
439
  * Reduce rows in this table to a scalar (`avg`/`max`/`min`/`sum` — `count`
286
440
  * lives on its own method). Routes through a declared `aggregateIndex` when
@@ -291,12 +445,26 @@ interface TableReaderFacade<DM, REL extends Record<keyof DM, object>, RANK exten
291
445
  * Count rows. The planner routes `where` keys that match a declared
292
446
  * `aggregateIndex.by` set to the indexed counter (no scan); otherwise
293
447
  * falls back to a SCAN. Accepts either a bare `where` tree or the broader
294
- * `RestrictableQueryOptions` shape; the latter is the seam the RLS layer
448
+ * RestrictableQueryOptions shape; the latter is the seam the RLS layer
295
449
  * uses to inject `baseWhere` and `restrictsCounts`.
296
450
  */
297
451
  count: (where?: RestrictableQueryOptionsOf<DM, REL, T> | WhereOf<DM, REL, T>) => Promise<number>;
298
452
  /** `true` when at least one row matches `where` (any row when omitted). RLS-filtered exactly like `findFirst`. */
299
453
  exists: (where?: WhereOf<DM, REL, T>) => Promise<boolean>;
454
+ /**
455
+ * Describe how this table would run `findMany(args)` without running it: the SQL, its bound
456
+ * parameters, and the database's own plan, one line per step. Use it to check that a filter is
457
+ * served by an index (`SEARCH … USING INDEX by_room`) rather than a scan (`SCAN …`).
458
+ *
459
+ * Honors RLS and soft delete exactly like the read, so the plan is the one your caller would get.
460
+ * Explaining does not subscribe a live query to this table. A relation filter in `where` is resolved
461
+ * first with an ordinary read of the related table, which does subscribe to that table, since the ids
462
+ * it matched are part of `params`. Takes no `with` or `select`: neither changes the statement.
463
+ *
464
+ * `params` carries values your RLS policies injected and, for a relation filter, the ids it matched.
465
+ * Keep the result on the server rather than returning it to a client.
466
+ */
467
+ explain: (args?: QueryArgsOf<DM, REL, T>) => Promise<QueryPlan>;
300
468
  findFirst: <W extends WithArg<DM, REL, T> = {}, S extends ReadonlyArray<keyof DM[T] & string> | undefined = undefined>(args?: QueryArgsOf<DM, REL, T> & {
301
469
  select?: S;
302
470
  with?: W;
@@ -309,6 +477,19 @@ interface TableReaderFacade<DM, REL extends Record<keyof DM, object>, RANK exten
309
477
  select?: S;
310
478
  with?: W;
311
479
  }) => Promise<QueryPage<LoadWith<DM, REL, T, W, S>>>;
480
+ /**
481
+ * The one row matching `where`, or `null` when none does — and a `NOT_UNIQUE`
482
+ * error when a SECOND one matches, so a broken uniqueness invariant surfaces at
483
+ * the read rather than as a wrong answer downstream. `findFirst` drops that
484
+ * assertion; this is the ORM spelling of the fluent reader's `.unique()`.
485
+ *
486
+ * `limit`/`cursor`/`endCursor` are not accepted rather than silently ignored: paging a read
487
+ * that must match at most one row is the assertion being dropped again.
488
+ */
489
+ findUnique: <W extends WithArg<DM, REL, T> = {}, S extends ReadonlyArray<keyof DM[T] & string> | undefined = undefined>(args?: Omit<QueryArgsOf<DM, REL, T>, "cursor" | "endCursor" | "limit"> & {
490
+ select?: S;
491
+ with?: W;
492
+ }) => Promise<LoadWith<DM, REL, T, W, S> | null>;
312
493
  get: (id: Id<string & T>) => Promise<DM[T] | null>;
313
494
  /**
314
495
  * Group rows by the named keys and apply `agg` per group (defaults to
@@ -329,6 +510,13 @@ interface TableReaderFacade<DM, REL extends Record<keyof DM, object>, RANK exten
329
510
  * follow the Convex-style keyset shape.
330
511
  */
331
512
  rankPage: (indexName: RANK[T], options?: TableRankPageOptions<DM[T]>) => Promise<RankPage<DM[T]>>;
513
+ /**
514
+ * Restrict the query to a declared `.geoIndex()` and run a proximity /
515
+ * bounding-box match. `indexName` is constrained to this table's geo indexes
516
+ * (`never` when it declares none). Returns a distance-ordered reader —
517
+ * finish with `.take(n)` / `.collect()`.
518
+ */
519
+ withGeoIndex: (indexName: GEO[T], build: (q: GeoFilterBuilder) => GeoFilterBuilder) => GeoReader<DM[T]>;
332
520
  /**
333
521
  * Restrict the query to a declared `.searchIndex()` and run a full-text
334
522
  * match. `indexName` is constrained to this table's search indexes
@@ -337,8 +525,8 @@ interface TableReaderFacade<DM, REL extends Record<keyof DM, object>, RANK exten
337
525
  */
338
526
  withSearchIndex: (indexName: SEARCH[T], search: (q: SearchFilterBuilder<DM[T]>) => SearchFilterBuilder<DM[T]>) => SearchReader<DM[T]>;
339
527
  }
340
- /** Read-write typed table accessor exposed on `MutationCtx.db.&lt;table>` / `ActionCtx.db.&lt;table>`. */
341
- interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, T extends keyof DM> extends TableReaderFacade<DM, REL, RANK, SEARCH, T> {
528
+ /** Read-write typed table accessor exposed on `MutationCtx.db.<table>` / `ActionCtx.db.<table>`. */
529
+ interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, T extends keyof DM, GEO extends Record<keyof DM, string> = Record<keyof DM, never>> extends TableReaderFacade<DM, REL, RANK, SEARCH, T, GEO> {
342
530
  /**
343
531
  * Delete a row by id. On a `.softDelete()` table this flips the marker column
344
532
  * (and cascades as a soft delete) instead of removing the row; use
@@ -371,10 +559,10 @@ interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends
371
559
  * instead of throwing — the return type widens to `Id | null` on that overload.
372
560
  */
373
561
  insert: {
374
- (values: IM[T], options: {
562
+ (values: InsertValues<DM, IM, REL, T>, options: {
375
563
  skipDuplicates: true;
376
564
  }): Promise<Id<string & T> | null>;
377
- (values: IM[T], options?: {
565
+ (values: InsertValues<DM, IM, REL, T>, options?: {
378
566
  skipDuplicates?: boolean;
379
567
  }): Promise<Id<string & T>>;
380
568
  };
@@ -393,7 +581,7 @@ interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends
393
581
  skipDuplicates?: boolean;
394
582
  }): Promise<Id<string & T>[]>;
395
583
  };
396
- patch: (id: Id<string & T>, values: Partial<IM[T]>) => Promise<void>;
584
+ patch: (id: Id<string & T>, values: PatchValues<IM[T]> & RelationWrites<DM, REL, T>) => Promise<void>;
397
585
  /**
398
586
  * Patch many rows in this table. Pass an array of `{ id, values }` or
399
587
  * `{ where, values }` to patch matching rows with the same values. Returns
@@ -402,7 +590,7 @@ interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends
402
590
  patchMany: {
403
591
  (patches: ReadonlyArray<{
404
592
  id: Id<string & T>;
405
- values: Partial<IM[T]>;
593
+ values: PatchValues<IM[T]>;
406
594
  }>, options?: {
407
595
  limit?: number;
408
596
  }): Promise<{
@@ -410,7 +598,7 @@ interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends
410
598
  }>;
411
599
  (args: {
412
600
  limit?: number;
413
- values: Partial<IM[T]>;
601
+ values: PatchValues<IM[T]>;
414
602
  where: Partial<DM[T]>;
415
603
  }): Promise<{
416
604
  patched: number;
@@ -426,9 +614,9 @@ interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends
426
614
  * Composes `findFirst` + `insert`/`patch`, so RLS gates each step.
427
615
  */
428
616
  upsert: (args: {
429
- create: IM[T];
617
+ create: InsertValues<DM, IM, REL, T>;
430
618
  target: UpsertTargetOf<DM, T>;
431
- update?: Partial<IM[T]>;
619
+ update?: PatchValues<IM[T]> & RelationWrites<DM, REL, T>;
432
620
  }) => Promise<{
433
621
  created: boolean;
434
622
  id: Id<string & T>;
@@ -436,8 +624,8 @@ interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends
436
624
  /** Sequential {@link TableWriterFacade.upsert} over many rows sharing one `target`; one result per input row, in order. */
437
625
  upsertMany: (args: {
438
626
  rows: ReadonlyArray<{
439
- create: IM[T];
440
- update?: Partial<IM[T]>;
627
+ create: InsertValues<DM, IM, REL, T>;
628
+ update?: PatchValues<IM[T]> & RelationWrites<DM, REL, T>;
441
629
  }>;
442
630
  target: UpsertTargetOf<DM, T>;
443
631
  }) => Promise<{
@@ -447,8 +635,65 @@ interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends
447
635
  }
448
636
  /** Conflict target for `upsert`/`upsertMany`: one column of table `T`, or a tuple of them. */
449
637
  type UpsertTargetOf<DM, T extends keyof DM> = ReadonlyArray<keyof DM[T] & string> | (keyof DM[T] & string);
450
- /** Per-table read facade — `ctx.db.&lt;table>` on a `QueryCtx`. */
451
- type DatabaseReaderFacade<DM, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>> = { readonly [T in keyof DM]: TableReaderFacade<DM, REL, RANK, SEARCH, T>; };
452
- /** Per-table read-write facade — `ctx.db.&lt;table>` on a `MutationCtx` / `ActionCtx`. */
453
- type DatabaseWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>> = { readonly [T in keyof DM]: TableWriterFacade<DM, IM, REL, RANK, SEARCH, T>; };
454
- export { AggregateOp, DatabaseReaderFacade, DatabaseWriterFacade, GroupByEntry, Id, LoadWith, ManyRelationWhere, OneRelationWhere, OrderBy, QueryArgs, QueryArgsOf, QueryPage, RankPage, RankResult, RestrictableQueryOptions, RestrictableQueryOptionsOf, SearchFilterBuilder, SearchReader, TableAggregateOptions, TableAggregateOptionsOf, TableGroupByOptions, TableGroupByOptionsOf, TableRankOptions, TableRankPageOptions, TableReaderFacade, TableWriterFacade, UpsertTargetOf, Where, WhereOf, WhereOperators, WithArg };
638
+ /**
639
+ * The values a `patch` accepts: any column's own type, and for a number or boolean
640
+ * column also an atomic operator ({@link NumberFieldOperator}, {@link BooleanFieldOperator}).
641
+ */
642
+ type PatchValues<Row> = PathPatch<Row> & { [K in keyof Row]?: Row[K] | OperatorFor<NonNullable<Row[K]>>; };
643
+ /** What `explain` returns: the SQL a read compiles to, its bound parameters, and the database's plan for it. */
644
+ interface QueryPlan {
645
+ /** The bound parameters, in order. */
646
+ params: unknown[];
647
+ /** One line per plan step, as the database reports it. */
648
+ plan: string[];
649
+ /** The statement the read compiles to. */
650
+ sql: string;
651
+ }
652
+ /**
653
+ * Nested write for a to-one relation: point the row at `Target` (`connect`), or clear the link (`disconnect`, which
654
+ * needs a foreign key that can be empty). One or the other, not both.
655
+ */
656
+ type ToOneRelationWrite<TargetId> = {
657
+ connect: TargetId;
658
+ disconnect?: never;
659
+ } | {
660
+ connect?: never;
661
+ disconnect: true;
662
+ };
663
+ /**
664
+ * Nested write for a to-many relation: point `Target` rows at this one (`connect`), release them (`disconnect`, which
665
+ * needs a foreign key that can be empty), or replace the whole list (`set`: rows not named are released). `set`
666
+ * cannot be combined with the other two.
667
+ */
668
+ type ToManyRelationWrite<TargetId> = {
669
+ connect?: never;
670
+ disconnect?: never;
671
+ set: ReadonlyArray<TargetId>;
672
+ } | {
673
+ connect?: ReadonlyArray<TargetId>;
674
+ disconnect?: ReadonlyArray<TargetId>;
675
+ set?: never;
676
+ };
677
+ /**
678
+ * Nested relation writes accepted by `insert`, `patch` and `upsert`, keyed by relation name:
679
+ * `{ author: { connect: userId } }`, `{ posts: { set: [a, b] } }`. A table with no relations contributes none
680
+ * (`unknown`, the identity for `&`, never `{}`: an empty object type would switch off the weak-type check).
681
+ */
682
+ type RelationWrites<DM, REL extends Record<keyof DM, object>, T extends keyof DM> = [keyof REL[T]] extends [never] ? unknown : { [K in keyof REL[T]]?: REL[T][K] extends {
683
+ __relationKind: "one";
684
+ __target: infer Target extends keyof DM;
685
+ } ? ToOneRelationWrite<Id<string & Target>> : REL[T][K] extends {
686
+ __relationKind: "many";
687
+ __target: infer Target extends keyof DM;
688
+ } ? ToManyRelationWrite<Id<string & Target>> : never; };
689
+ /**
690
+ * What `insert` accepts: the row as it is, or the row without its to-one foreign keys plus the nested writes that
691
+ * supply them. Leaving a key out with no `connect` to supply it is not caught by the type — the store's own
692
+ * validation rejects the missing field.
693
+ */
694
+ type InsertValues<DM, IM extends Record<keyof DM, object>, REL extends Record<keyof DM, object>, T extends keyof DM> = IM[T] | (Omit<IM[T], OneRelationFields<REL[T]>> & RelationWrites<DM, REL, T>);
695
+ /** Per-table read facade — `ctx.db.<table>` on a `QueryCtx`. */
696
+ type DatabaseReaderFacade<DM, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, GEO extends Record<keyof DM, string> = Record<keyof DM, never>> = { readonly [T in keyof DM]: TableReaderFacade<DM, REL, RANK, SEARCH, T, GEO>; };
697
+ /** Per-table read-write facade — `ctx.db.<table>` on a `MutationCtx` / `ActionCtx`. */
698
+ type DatabaseWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, GEO extends Record<keyof DM, string> = Record<keyof DM, never>> = { readonly [T in keyof DM]: TableWriterFacade<DM, IM, REL, RANK, SEARCH, T, GEO>; };
699
+ export { AggregateOp, DatabaseReaderFacade, DatabaseWriterFacade, GeoBoundingBox, GeoFilterBuilder, GeoPointInput, GeoReader, GroupByEntry, Id, InsertValues, LoadWith, ManyRelationWhere, OneRelationWhere, OrderBy, PatchValues, QueryArgs, QueryArgsOf, QueryPage, QueryPlan, RankPage, RankResult, RelationWrites, RestrictableQueryOptions, RestrictableQueryOptionsOf, SearchFilterBuilder, SearchReader, TableAggregateOptions, TableAggregateOptionsOf, TableGroupByOptions, TableGroupByOptionsOf, TableRankOptions, TableRankPageOptions, TableReaderFacade, TableWriterFacade, ToManyRelationWrite, ToOneRelationWrite, UpsertTargetOf, Where, WhereOf, WhereOperators, WithArg };