@atscript/db 0.1.146 → 0.1.148

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 (59) hide show
  1. package/dist/{agg-CV7y8nC6.d.cts → agg-42CSpGDR.d.cts} +2 -2
  2. package/dist/{agg-D5DHsAby.d.mts → agg-Wo-smrYV.d.mts} +3 -3
  3. package/dist/agg.cjs +1 -1
  4. package/dist/agg.d.cts +2 -2
  5. package/dist/agg.d.mts +2 -2
  6. package/dist/agg.mjs +1 -1
  7. package/dist/{aggregate-fns-CGBv3E8S.cjs → aggregate-fns-C-UJRobm.cjs} +52 -5
  8. package/dist/{aggregate-fns-CfsveE1w.mjs → aggregate-fns-CyaZyb9I.mjs} +35 -6
  9. package/dist/aggregate-rules-D_bsCpUI.cjs +26 -0
  10. package/dist/aggregate-rules-jdPrxqWa.mjs +15 -0
  11. package/dist/{buckets-DRycmhOW.d.mts → buckets-CNdTOnei.d.mts} +832 -33
  12. package/dist/{buckets-DYFu0eZ8.d.cts → buckets-DJiYlMXc.d.cts} +832 -33
  13. package/dist/{column-diff-D_Kyuh0S.cjs → column-diff-CUU4GvYg.cjs} +1546 -193
  14. package/dist/{column-diff-e2oHc71_.mjs → column-diff-Cp6ZoyRE.mjs} +1529 -200
  15. package/dist/{db-error-D5uilS_A.mjs → db-error-Az85UhTX.mjs} +32 -1
  16. package/dist/{db-error-DTkkeu5b.cjs → db-error-DRQH4sLY.cjs} +55 -0
  17. package/dist/{column-diff-Q9UmWn5x.d.mts → fk-diff-BQ4krij8.d.cts} +48 -2
  18. package/dist/{column-diff-w-Mym_3w.d.cts → fk-diff-DsaIijVX.d.mts} +48 -2
  19. package/dist/index.cjs +95 -35
  20. package/dist/index.d.cts +92 -22
  21. package/dist/index.d.mts +92 -22
  22. package/dist/index.mjs +65 -35
  23. package/dist/{nested-writer-xfQwxplL.cjs → nested-writer-BUQvk6QT.cjs} +734 -2
  24. package/dist/{nested-writer-CnOOAehr.mjs → nested-writer-CUBoq1ZO.mjs} +598 -4
  25. package/dist/numeric-operand-B1jKH7x5.mjs +21 -0
  26. package/dist/numeric-operand-DKfiRLYp.cjs +26 -0
  27. package/dist/ops.cjs +1 -1
  28. package/dist/ops.mjs +1 -1
  29. package/dist/plugin.cjs +293 -5
  30. package/dist/plugin.mjs +294 -6
  31. package/dist/rel.cjs +2 -2
  32. package/dist/rel.d.cts +2 -2
  33. package/dist/rel.d.mts +2 -2
  34. package/dist/rel.mjs +2 -2
  35. package/dist/{relation-helpers-B-0NRKat.d.mts → relation-helpers-Ba0v49sn.d.mts} +1 -1
  36. package/dist/{relation-helpers-BOMm_HUI.d.cts → relation-helpers-kX7jjgME.d.cts} +1 -1
  37. package/dist/relation-loader-ByY1Byrl.mjs +370 -0
  38. package/dist/relation-loader-D8OrdH-r.cjs +369 -0
  39. package/dist/shared.cjs +4 -1
  40. package/dist/shared.d.cts +16 -4
  41. package/dist/shared.d.mts +16 -4
  42. package/dist/shared.mjs +3 -2
  43. package/dist/sync.cjs +11 -7
  44. package/dist/sync.d.cts +2 -25
  45. package/dist/sync.d.mts +2 -25
  46. package/dist/sync.mjs +11 -7
  47. package/dist/{validation-utils-DOsB4e6G.cjs → validation-utils-Da2GjobR.cjs} +35 -24
  48. package/dist/{validation-utils-CMR4fe2M.mjs → validation-utils-Dq0uZ7ef.mjs} +35 -24
  49. package/dist/{validator-Clu2q_7z.mjs → validator-BTiIOTKP.mjs} +9 -3
  50. package/dist/{validator-CVS-onRg.cjs → validator-UcuJxHNT.cjs} +8 -2
  51. package/dist/{validator-Bw6ks9Hy.d.mts → validator-tBNvM1qc.d.cts} +31 -7
  52. package/dist/{validator-Bw6ks9Hy.d.cts → validator-tBNvM1qc.d.mts} +31 -7
  53. package/dist/validator.cjs +2 -2
  54. package/dist/validator.d.cts +1 -1
  55. package/dist/validator.d.mts +1 -1
  56. package/dist/validator.mjs +2 -2
  57. package/package.json +8 -8
  58. package/dist/relation-loader-CBPY6kM7.cjs +0 -461
  59. package/dist/relation-loader-D9XuXaMv.mjs +0 -462
package/dist/index.d.cts CHANGED
@@ -1,13 +1,13 @@
1
- import { $ as TDbUpdateResult, $t as AtscriptRef, A as TCrudPermissions, At as TViewJsonType, B as TDbFieldMeta, Bt as ALL_BUCKET_UNITS, C as NullableOptional, Ct as TRowResolveOptions, D as TCascadeTarget, Dt as TTableResolver, E as TCascadeResolver, Et as TTableOptionDiff, F as TDbAvailableActions, Ft as UniqueryControls, G as TDbInsertManyResult, Gt as AtscriptDbView, H as TDbIndex, Ht as DbSpace, I as TDbCollation, It as WithRelation, J as TDbReferentialAction, Jt as isViewType, K as TDbInsertResult, Kt as TViewColumnMapping, L as TDbDefaultFn, Lt as TableMetadata, M as TDbActionIntent, Mt as TWriteTableResolver, N as TDbActionLevel, Nt as TypedWithRelation, O as TColumnDiff, Ot as TTouchManyOptions, P as TDbActionProcessor, Pt as Uniquery, Q as TDbStorageType, Qt as AtscriptQueryNode, R as TDbDefaultValue, Rt as isGeoIndexableType, S as NavPropsOf, St as TRelationInfo, T as PrimaryKeyOf, Tt as TSyncColumnResult, U as TDbIndexField, Ut as TAdapterFactory, V as TDbForeignKey, Vt as BaseDbAdapter, W as TDbIndexType, Wt as TDbSpaceOptions, X as TDbRemoveGuard, Xt as AtscriptQueryComparison, Y as TDbRelation, Yt as aliasTargetOf, Z as TDbRemoveGuardContext, Zt as AtscriptQueryFieldRef, _ as DbQuery, _n as UniquSelect, _t as TIdentification, a as jsonValueAncestor, an as IntegrityStrategy, at as TDeleteOptions, b as FilterExpr, bt as TPrimaryKeyChange, c as AggregateControls, cn as DbResponse, ct as TEnsureTableOptions, d as AggregateQuery, dn as TDbEncryptionOptions, dt as TExistingTableOption, en as TViewJoin, et as TDbWriteAction, f as AggregateResult, fn as DocumentFieldMapper, ft as TFieldMeta, g as DbPatch, gn as TGenericLogger, gt as TIdResolveOptions, h as DbControls, hn as NoopLogger, ht as TIdDescriptor, i as isJsonValueField, in as AtscriptDbTable, it as TDbWriteGuardContext, j as TDbActionInfo, jt as TWriteOptions, k as TCrudOp, kt as TValueFormatterPair, l as AggregateExpr, ln as resolveDesignType, lt as TExistingColumn, m as AtscriptDbWritable, mn as TReadControls, mt as TFkLookupTarget, n as TResolvedBucket, nn as isFieldRef, nt as TDbWriteCheckContext, o as normalizeComputedSelect, on as NativeIntegrity, ot as TDerivedChangeReason, pn as FieldMappingStrategy, pt as TFkLookupResolver, q as TDbObjectKind, qt as isAtscriptDbView, r as isBucketableField, rn as translateQueryTree, rt as TDbWriteGuard, s as resolveCalendarBuckets, sn as AtscriptDbReadable, st as TDerivedColumn, t as TBucketFieldSource, tn as TViewPlan, tt as TDbWriteCheck, u as AggregateFn, un as DbEncryption, ut as TExistingForeignKey, v as DbRow, vt as TMetaResponse, w as OwnPropsOf, wt as TSearchIndexInfo, x as FlatOf, xt as TReferencingForeignKey, y as FieldOpsFor, yt as TMetadataOverrides, z as TDbDeleteResult, zt as isGeoPointType } from "./buckets-DYFu0eZ8.cjs";
1
+ import { $ as TDbReferentialAction, $t as AtscriptDbView, A as TCrudOp, An as containsRelationFilter, At as TSearchIndexInfo, B as TDbDefaultValue, Bn as NoopLogger, Bt as Uniquery, C as NavPropsOf, Cn as REL_FILTER_MAX_NODES, Ct as TInsertOptions, D as TCascadeResolver, Dn as TRelationFilterTable, Dt as TReferencingForeignKey, E as PrimaryKeyOf, En as TRelationFilterJunction, Et as TPrimaryKeyChange, F as TDbActionProcessor, Fn as DbEncryption, Ft as TValueFormatterPair, G as TDbIndexField, Gn as UniquSelect, Gt as isGeoPointType, H as TDbFieldMeta, Hn as TExprAggregate, Ht as WithRelation, I as TDbActionTargetSummary, In as TDbEncryptionOptions, It as TViewJsonType, J as TDbInsertIgnoreSlot, Jt as BaseDbAdapter, K as TDbIndexType, Kt as ALL_BUCKET_UNITS, L as TDbAvailableActions, Ln as DocumentFieldMapper, Lt as TWriteOptions, M as TDbActionInfo, Mn as hasRelationOp, Mt as TTableOptionDiff, N as TDbActionIntent, Nn as isResolvedRelationFilter, Nt as TTableResolver, O as TCascadeTarget, On as TRelationStaticFilter, Ot as TRelationInfo, P as TDbActionLevel, Pn as relationStaticFilter, Pt as TTouchManyOptions, Q as TDbObjectKind, Qt as TDbSpaceOptions, R as TDbCollation, Rn as FieldMappingStrategy, Rt as TWriteTableResolver, S as FlatOf, Sn as REL_FILTER_MAX_DEPTH, St as TIdentification, T as OwnPropsOf, Tn as TRelGuardState, Tt as TMetadataOverrides, U as TDbForeignKey, Un as TFirstLast, Ut as TableMetadata, V as TDbDeleteResult, Vn as TGenericLogger, Vt as UniqueryControls, W as TDbIndex, Wn as TRowOrderKey, Wt as isGeoIndexableType, X as TDbInsertManyResult, Xt as DbSpace, Y as TDbInsertManyIgnoreResult, Yt as TViewCapability, Z as TDbInsertResult, Zt as TAdapterFactory, _ as DbPatch, _n as NativeIntegrity, _t as TFieldMeta, a as isJsonValueField, an as AtscriptOrderItem, at as TDbWriteAction, b as FieldOpsFor, bn as DbResponse, bt as TIdDescriptor, c as resolveCalendarBuckets, cn as AtscriptQueryNode, ct as TDbWriteGuard, d as AggregateFn, dn as TViewPlan, dt as TDerivedChangeReason, en as TViewColumnMapping, et as TDbRelation, f as AggregateQuery, fn as evaluateExpr, ft as TDerivedColumn, g as DbControls, gn as IntegrityStrategy, gt as TExistingTableOption, h as AtscriptDbWritable, hn as AtscriptDbTable, ht as TExistingForeignKey, i as isBucketableField, in as AtscriptExprNode, it as TDbUpdateResult, j as TCrudPermissions, jn as forEachResolvedRelation, jt as TSyncColumnResult, k as TColumnDiff, kn as andFilters, kt as TRowResolveOptions, l as AggregateControls, ln as AtscriptRef, lt as TDbWriteGuardContext, mn as translateQueryTree, mt as TExistingColumn, n as TComputedSelect, nn as isViewType, nt as TDbRemoveGuardContext, o as jsonValueAncestor, on as AtscriptQueryComparison, ot as TDbWriteCheck, p as AggregateResult, pn as isFieldRef, pt as TEnsureTableOptions, q as TDbInsertIgnoreResult, qt as ALL_VIEW_CAPABILITIES, r as TResolvedBucket, rn as aliasTargetOf, rt as TDbStorageType, s as normalizeComputedSelect, sn as AtscriptQueryFieldRef, st as TDbWriteCheckContext, t as TBucketFieldSource, tn as isAtscriptDbView, tt as TDbRemoveGuard, u as AggregateExpr, un as TViewJoin, ut as TDeleteOptions, v as DbQuery, vn as TCascadePin, vt as TFkLookupResolver, w as NullableOptional, wn as ResolvedRelationFilter, wt as TMetaResponse, x as FilterExpr, xn as resolveDesignType, xt as TIdResolveOptions, y as DbRow, yn as AtscriptDbReadable, yt as TFkLookupTarget, z as TDbDefaultFn, zn as TReadControls, zt as TypedWithRelation } from "./buckets-DJiYlMXc.cjs";
2
2
  import { _ as separateFieldOps, a as $mul, c as $update, d as TDbFieldOp, f as TFieldOps, g as separateCas, h as reconcileCas, i as $insert, l as $upsert, m as isDbFieldOp, n as $dec, o as $remove, p as getDbFieldOp, r as $inc, s as $replace, t as $cas, u as TDbCas } from "./ops-AqhV7s9o.cjs";
3
3
  import { a as isPlainObject, i as isEmptyObject, n as findAncestorInSet, o as selfOrAncestor, r as getPath, t as deletePath } from "./object-CtPYTIvy.cjs";
4
- import { c as CalendarBucketLabel, d as WeekStart, g as ALL_AGGREGATE_FNS, l as ComputedExpr, o as BucketExpr, s as BucketUnit, u as ResolvedBucket } from "./agg-CV7y8nC6.cjs";
5
- import { a as buildValidationContext, c as isNavRelation, d as getKeyProps, f as CasExhaustedError, g as bucketTimeZoneUnavailable, h as DbErrorCode, l as TArrayPatch, m as DbError, n as ValidatorMode, p as CasMismatchError, r as buildDbValidator, s as forceNavNonOptional, t as ValidationContext, u as TDbPatch } from "./validator-Bw6ks9Hy.cjs";
4
+ import { c as CalendarBucketLabel, d as WeekStart, g as ALL_AGGREGATE_FNS, l as ComputedExpr, o as BucketExpr, s as BucketUnit, u as ResolvedBucket } from "./agg-42CSpGDR.cjs";
5
+ import { _ as aggregateFailure, a as buildValidationContext, c as isNavRelation, d as getKeyProps, f as CasExhaustedError, g as aggregateExpressionsNotSupported, h as DbErrorCode, l as TArrayPatch, m as DbError, n as ValidatorMode, p as CasMismatchError, r as buildDbValidator, s as forceNavNonOptional, t as ValidationContext, u as TDbPatch, v as bucketTimeZoneUnavailable, y as isConflict } from "./validator-tBNvM1qc.cjs";
6
6
  import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.cjs";
7
- import { n as isColumnTypeChanged } from "./column-diff-w-Mym_3w.cjs";
8
- import { i as tableNameOf } from "./relation-helpers-BOMm_HUI.cjs";
9
- import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, ResolvedBucket as ResolvedBucket$1, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
10
- import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
7
+ import { r as fkColumns, s as isColumnTypeChanged } from "./fk-diff-BQ4krij8.cjs";
8
+ import { i as tableNameOf } from "./relation-helpers-kX7jjgME.cjs";
9
+ import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, RELATION_OPS, RelationOp, RelationOp as RelationOp$1, ResolvedRowOrderKey, ResolvedSelectExpr, Uniquery as Uniquery$1, computeInsights, isPrimitive, isRelationOp, walkFilter } from "@uniqu/core";
10
+ import { AtscriptExprNode as AtscriptExprNode$1, TAtscriptAnnotatedType } from "@atscript/typescript/utils";
11
11
 
12
12
  //#region src/shared/consts.d.ts
13
13
  /**
@@ -30,14 +30,16 @@ declare class RelationalFieldMapper extends FieldMappingStrategy {
30
30
  /** The flattened column of a logical path (`contact.email` → `contact__email`). */
31
31
  protected physicalPath(logical: string, meta: TableMetadata): string;
32
32
  /**
33
- * Overrides the base `translateFilter` to use `leafByLogical` for key resolution
33
+ * Overrides the base `translateResolvedFilter` to use `leafByLogical` for key resolution
34
34
  * (handles flattened nested paths like `contact.email` → `contact__email`).
35
35
  */
36
- translateFilter(filter: FilterExpr$1, meta: TableMetadata): FilterExpr$1;
36
+ protected translateResolvedFilter(filter: FilterExpr$1, meta: TableMetadata): FilterExpr$1;
37
37
  /**
38
38
  * Translates filter with key renaming from logical to physical names.
39
39
  * Used by the relational query path where field paths must be mapped
40
- * to `__`-separated column names.
40
+ * to `__`-separated column names. Relational predicates must already be
41
+ * resolved (`translateFilter` / `translateQuery` do it); a resolved
42
+ * predicate passes through under its navigation-field key.
41
43
  */
42
44
  translateFilterWithRename(filter: FilterExpr$1, meta: TableMetadata): FilterExpr$1;
43
45
  prepareForWrite(payload: Record<string, unknown>, meta: TableMetadata, adapter: BaseDbAdapter): Record<string, unknown>;
@@ -83,8 +85,14 @@ declare class ApplicationIntegrity extends IntegrityStrategy {
83
85
  * - `restrict`: throws if any children exist
84
86
  * - `cascade`: recursively deletes child records
85
87
  * - `setNull`: sets FK fields to null
88
+ *
89
+ * When `filter` holds a relational predicate, returns the matched rows
90
+ * PINNED by primary key (see {@link TCascadePin}): the caller deletes those
91
+ * rows, never re-evaluating `filter` on data the cascade just changed (a
92
+ * `$some` over a cascaded child relation would otherwise stop matching and
93
+ * leave the parent behind). Any other filter → `undefined`.
86
94
  */
87
- cascadeBeforeDelete(filter: FilterExpr$1, tableName: string, meta: TableMetadata, cascadeResolver: TCascadeResolver, translateFilter: (f: FilterExpr$1) => FilterExpr$1, adapter: BaseDbAdapter): Promise<void>;
95
+ cascadeBeforeDelete(filter: FilterExpr$1, tableName: string, meta: TableMetadata, cascadeResolver: TCascadeResolver, translateFilter: (f: FilterExpr$1) => FilterExpr$1, adapter: BaseDbAdapter): Promise<TCascadePin>;
88
96
  needsCascade(cascadeResolver: TCascadeResolver | undefined): boolean;
89
97
  private recordKey;
90
98
  /**
@@ -119,6 +127,9 @@ declare class ApplicationIntegrity extends IntegrityStrategy {
119
127
  * {@link canFilterLeaf}) needs → `INVALID_QUERY` (see {@link guardPaths}).
120
128
  * Runs after the checks above so `ENC_*` codes keep firing first for
121
129
  * encrypted subtrees.
130
+ * - every filter / `$having` comparison value must be able to denote its
131
+ * field's declared type (`?n='x'` on a number) → `INVALID_QUERY`, after
132
+ * the path guard (see `guardFilterValues`, since 0.1.147).
122
133
  */
123
134
  /** Validates a `[lng, lat]` tuple (GeoJSON coordinate order). */
124
135
  declare function assertGeoPoint(point: unknown, path: string): asserts point is [number, number];
@@ -138,6 +149,7 @@ interface TGuardedQuery {
138
149
  $select?: unknown;
139
150
  $groupBy?: unknown;
140
151
  $having?: unknown;
152
+ $rowOrder?: unknown;
141
153
  };
142
154
  }
143
155
  /**
@@ -156,13 +168,23 @@ declare function sortFieldNames(sort: unknown): string[];
156
168
  * The operator class a filter entry needs from its field (since 0.1.132):
157
169
  * - `compare` — value comparison (bare values, `$eq`, `$gt`, `$in`, `$regex`, any mix);
158
170
  * - `geo` — a `$geoWithin` entry;
159
- * - `exists` — an entry whose sole operator is `$exists`.
171
+ * - `exists` — an entry whose sole operator is `$exists`;
172
+ * - `relation` — a relational predicate (`$some` / `$none` only) on a
173
+ * navigation field (since 0.1.147).
160
174
  */
161
- type TFilterPredicate = "compare" | "geo" | "exists";
175
+ type TFilterPredicate = "compare" | "geo" | "exists" | "relation";
162
176
  /** One filter entry, collected per occurrence: its key and the predicate class its operators need. */
163
177
  interface TFilterRef {
164
178
  path: string;
165
179
  predicate: TFilterPredicate;
180
+ /**
181
+ * `relation` entries: each operator with its operand (a filter on the
182
+ * related table, not walked here). @since 0.1.147
183
+ */
184
+ relation?: Array<{
185
+ op: RelationOp$1;
186
+ filter: FilterExpr$1;
187
+ }>;
166
188
  }
167
189
  /**
168
190
  * The reason clause for a leaf the adapter cannot filter (value comparison).
@@ -223,6 +245,28 @@ type TBucketSourceVerdict = {
223
245
  code: "encrypted" | "jsonDescendant" | "notTimestamp" | "notFilterable" | "notDimension" | "noBuckets";
224
246
  reason: string;
225
247
  };
248
+ /** {@link groupSourceVerdict}'s answer — the `reason` clause has no trailing period. */
249
+ type TGroupSourceVerdict = {
250
+ ok: true;
251
+ } | {
252
+ ok: false;
253
+ code: "encrypted" | "notFilterable" | "notDimension";
254
+ reason: string;
255
+ };
256
+ /**
257
+ * Whether the stored leaf `fd` may be a `$groupBy` key (since 0.1.148) — the
258
+ * one rule for the core's strict-table check and moost-db's capability index
259
+ * (`/meta.fields[P].groupable` and the HTTP gate). First failing rule wins:
260
+ *
261
+ * 1. `encrypted` — `@db.encrypted`;
262
+ * 2. `notFilterable` — the adapter cannot filter (so cannot group) the storage;
263
+ * 3. `notDimension` — a strict table ({@link isStrictTable}) and the field is
264
+ * not a dimension.
265
+ *
266
+ * A calendar-bucket alias is not a field: it groups by its source, whose
267
+ * dimension rule is {@link bucketSourceVerdict}'s (callers skip aliases).
268
+ */
269
+ declare function groupSourceVerdict(fd: TDbFieldMeta, table: Pick<TBucketSourceTable, "dimensions" | "measures">, adapter: Pick<BaseDbAdapter, "canFilterField">): TGroupSourceVerdict;
226
270
  /**
227
271
  * Whether the stored leaf `fd` may be the source of a calendar bucket
228
272
  * (since 0.1.133) — every schema and adapter rule, once, for the core path
@@ -281,8 +325,9 @@ interface TQueryPathRefs {
281
325
  *
282
326
  * Aggregate mode is `aggregate` when given, else the presence of `$groupBy`.
283
327
  * In aggregate mode `$select` computed entries are collected by kind — an
284
- * aggregate's `$field` into `aggregate`, a calendar bucket's into `bucket` —
285
- * and their aliases (`$as`, else uniqu's `resolveAlias`) are exempted from
328
+ * aggregate's `$field` (a row-level expression's names, a `first` / `last`
329
+ * field) into `aggregate`, a calendar bucket's into `bucket`, a `$rowOrder`
330
+ * key into `sort` — and their aliases (`$as`, else uniqu's `resolveAlias`) are exempted from
286
331
  * `$sort` / `$having`; a bucket alias is also dropped from `groupBy`, which
287
332
  * lists grouped fields only.
288
333
  *
@@ -357,16 +402,20 @@ declare function guardPath(meta: TableMetadata, adapter: BaseDbAdapter, path: st
357
402
  * `bucket`), `$groupBy` fields are checked, and computed aliases (`$as` or
358
403
  * the default) are exempt in `$sort` / `$having`.
359
404
  *
405
+ * Then every filter comparison value must be able to denote its field's
406
+ * declared type (`guardFilterValues`, since 0.1.147) — after the paths, so
407
+ * an unknown or unfilterable field keeps its own rejection.
408
+ *
360
409
  * Returns the collected refs so callers can run further structural rules
361
410
  * (see {@link checkHavingKeys}) without walking the query again.
362
411
  */
363
- declare function guardPaths(meta: TableMetadata, adapter: BaseDbAdapter, query: TGuardedQuery | undefined, aggregate?: boolean): TQueryPathRefs | undefined;
412
+ declare function guardPaths(meta: TableMetadata, adapter: BaseDbAdapter, query: TGuardedQuery | undefined, aggregate?: boolean, state?: TRelGuardState): TQueryPathRefs | undefined;
364
413
  /**
365
414
  * Shared read-path guard: filter + $sort encryption checks, the `$select`
366
415
  * normalizer (a calendar bucket is invalid outside a grouped query), then
367
416
  * the path guard.
368
417
  */
369
- declare function guardQuery(meta: TableMetadata, adapter: BaseDbAdapter, query: TGuardedQuery | undefined): void;
418
+ declare function guardQuery(meta: TableMetadata, adapter: BaseDbAdapter, query: TGuardedQuery | undefined, state?: TRelGuardState): void;
370
419
  /**
371
420
  * `$having` is a post-aggregation filter, so a key is either a computed
372
421
  * alias (aggregate or calendar bucket — already exempt in
@@ -387,12 +436,13 @@ declare function checkHavingKeys(refs: TQueryPathRefs): {
387
436
  * (`AGG_FN_NOT_SUPPORTED`) and calendar-bucket units
388
437
  * (`BUCKET_NOT_SUPPORTED`), then the `$having` key rule
389
438
  * ({@link checkHavingKeys} — after the path guard so an unknown key still
390
- * reads `Unknown field`).
439
+ * reads `Unknown field`), then the `$having` values (`guardHavingValues`).
391
440
  *
392
- * `buckets` are the query's resolved calendar buckets when the caller already
393
- * ran `normalizeComputedSelect` (resolved here otherwise).
441
+ * `resolved` is the query's normalized computed `$select`
442
+ * (`resolveComputedSelect`) when the caller already ran it (resolved here
443
+ * otherwise).
394
444
  */
395
- declare function guardAggregate(meta: TableMetadata, adapter: BaseDbAdapter, query: AggregateQuery$1, resolved?: readonly ResolvedBucket$1[]): void;
445
+ declare function guardAggregate(meta: TableMetadata, adapter: BaseDbAdapter, query: AggregateQuery$1, resolved?: TComputedSelect): void;
396
446
  //#endregion
397
447
  //#region src/with-optimistic-retry.d.ts
398
448
  interface WithOptimisticRetryOptions {
@@ -433,6 +483,14 @@ interface WithOptimisticRetryOptions {
433
483
  */
434
484
  declare function withOptimisticRetry<TRow extends Record<string, unknown>>(table: AtscriptDbTable, filter: Record<string, unknown>, mutator: (row: TRow) => Promise<Record<string, unknown> | undefined> | Record<string, unknown> | undefined, opts?: WithOptimisticRetryOptions): Promise<TDbUpdateResult>;
435
485
  //#endregion
486
+ //#region src/shared/keys.d.ts
487
+ /**
488
+ * Identity of the key tuple `fields` of `row` for uniqueness checks, or
489
+ * `undefined` when any component is null / missing (a NULL never collides).
490
+ * Equal across driver representations (see {@link keyString}).
491
+ */
492
+ declare function uniqueKeyTuple(row: Record<string, unknown>, fields: readonly string[]): string | undefined;
493
+ //#endregion
436
494
  //#region src/shared/index-messages.d.ts
437
495
  /**
438
496
  * Wording of the "index not found" errors — one source for the core, every
@@ -531,4 +589,16 @@ declare function createFailureCollector(what: string): {
531
589
  throwIfAny: () => void;
532
590
  };
533
591
  //#endregion
534
- export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type BucketExpr, type BucketUnit, type CalendarBucketLabel, CasExhaustedError, CasMismatchError, type ComputedExpr, DEFAULT_DB_SPACE, type DbControls, DbEncryption, DbError, type DbErrorCode, type DbPatch, type DbQuery, type DbResponse, type DbRow, DbSpace, type DbValidationContext, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, type FlatOf, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type OwnPropsOf, type PrimaryKeyOf, RelationalFieldMapper, type ResolvedBucket, type TAdapterFactory, type TArrayPatch, type TBucketFieldSource, type TBucketSourceTable, type TBucketSourceVerdict, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbAvailableActions, type TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateResult, type TDbWriteAction, type TDbWriteCheck, type TDbWriteCheckContext, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TDerivedChangeReason, type TDerivedColumn, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TMetaResponse, type TMetadataOverrides, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReadControls, type TReferencingForeignKey, type TRelationInfo, type TResolvedBucket, type TRowResolveOptions, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, aliasTargetOf, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, deletePath, findAncestorInSet, forceNavNonOptional, geoIndexNotFoundMessage, getDbFieldOp, getKeyProps, getPath, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isDbEntityType, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, reconcileCas, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, tableNameOf, translateQueryTree, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
592
+ //#region src/query/aggregate-expr.d.ts
593
+ /**
594
+ * Why a field cannot be an arithmetic operand, or `undefined` when it can: it
595
+ * must be a `number` (not a decimal — those are exact, an expression is IEEE
596
+ * double — and not a timestamp-tagged number) with plain column storage. The
597
+ * runtime twin of `@db.compute`'s operand rule, so declared and query-time
598
+ * arithmetic accept the same fields.
599
+ *
600
+ * @since 0.1.148
601
+ */
602
+ declare function numericOperandProblem(fd: TDbFieldMeta): string | undefined;
603
+ //#endregion
604
+ export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_VIEW_CAPABILITIES, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptExprNode, type AtscriptOrderItem, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type BucketExpr, type BucketUnit, type CalendarBucketLabel, CasExhaustedError, CasMismatchError, type ComputedExpr, DEFAULT_DB_SPACE, type DbControls, DbEncryption, DbError, type DbErrorCode, type DbPatch, type DbQuery, type DbResponse, type DbRow, DbSpace, type DbValidationContext, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, type FlatOf, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type OwnPropsOf, type PrimaryKeyOf, RELATION_OPS, REL_FILTER_MAX_DEPTH, REL_FILTER_MAX_NODES, type RelationOp, RelationalFieldMapper, type ResolvedBucket, ResolvedRelationFilter, type TAdapterFactory, type TArrayPatch, type TBucketFieldSource, type TBucketSourceTable, type TBucketSourceVerdict, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbActionTargetSummary, type TDbAvailableActions, type TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertIgnoreResult, type TDbInsertIgnoreSlot, type TDbInsertManyIgnoreResult, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateResult, type TDbWriteAction, type TDbWriteCheck, type TDbWriteCheckContext, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TDerivedChangeReason, type TDerivedColumn, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TExprAggregate, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFirstLast, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGroupSourceVerdict, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TInsertOptions, type TMetaResponse, type TMetadataOverrides, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReadControls, type TReferencingForeignKey, type TRelationFilterJunction, type TRelationFilterTable, type TRelationInfo, type TRelationStaticFilter, type TResolvedBucket, type TRowOrderKey, type TRowResolveOptions, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewCapability, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, aggregateExpressionsNotSupported, aggregateFailure, aliasTargetOf, andFilters, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, containsRelationFilter, createDbValidatorPlugin, createFailureCollector, decomposePatch, deletePath, evaluateExpr, findAncestorInSet, fkColumns, forEachResolvedRelation, forceNavNonOptional, geoIndexNotFoundMessage, getDbFieldOp, getKeyProps, getPath, groupSourceVerdict, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, hasRelationOp, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isConflict, isDbEntityType, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, isRelationOp, isResolvedRelationFilter, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, numericOperandProblem, reconcileCas, relationStaticFilter, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
package/dist/index.d.mts CHANGED
@@ -1,13 +1,13 @@
1
- import { $ as TDbUpdateResult, $t as AtscriptRef, A as TCrudPermissions, At as TViewJsonType, B as TDbFieldMeta, Bt as ALL_BUCKET_UNITS, C as NullableOptional, Ct as TRowResolveOptions, D as TCascadeTarget, Dt as TTableResolver, E as TCascadeResolver, Et as TTableOptionDiff, F as TDbAvailableActions, Ft as UniqueryControls, G as TDbInsertManyResult, Gt as AtscriptDbView, H as TDbIndex, Ht as DbSpace, I as TDbCollation, It as WithRelation, J as TDbReferentialAction, Jt as isViewType, K as TDbInsertResult, Kt as TViewColumnMapping, L as TDbDefaultFn, Lt as TableMetadata, M as TDbActionIntent, Mt as TWriteTableResolver, N as TDbActionLevel, Nt as TypedWithRelation, O as TColumnDiff, Ot as TTouchManyOptions, P as TDbActionProcessor, Pt as Uniquery, Q as TDbStorageType, Qt as AtscriptQueryNode, R as TDbDefaultValue, Rt as isGeoIndexableType, S as NavPropsOf, St as TRelationInfo, T as PrimaryKeyOf, Tt as TSyncColumnResult, U as TDbIndexField, Ut as TAdapterFactory, V as TDbForeignKey, Vt as BaseDbAdapter, W as TDbIndexType, Wt as TDbSpaceOptions, X as TDbRemoveGuard, Xt as AtscriptQueryComparison, Y as TDbRelation, Yt as aliasTargetOf, Z as TDbRemoveGuardContext, Zt as AtscriptQueryFieldRef, _ as DbQuery, _n as UniquSelect, _t as TIdentification, a as jsonValueAncestor, an as IntegrityStrategy, at as TDeleteOptions, b as FilterExpr, bt as TPrimaryKeyChange, c as AggregateControls, cn as DbResponse, ct as TEnsureTableOptions, d as AggregateQuery, dn as TDbEncryptionOptions, dt as TExistingTableOption, en as TViewJoin, et as TDbWriteAction, f as AggregateResult, fn as DocumentFieldMapper, ft as TFieldMeta, g as DbPatch, gn as TGenericLogger, gt as TIdResolveOptions, h as DbControls, hn as NoopLogger, ht as TIdDescriptor, i as isJsonValueField, in as AtscriptDbTable, it as TDbWriteGuardContext, j as TDbActionInfo, jt as TWriteOptions, k as TCrudOp, kt as TValueFormatterPair, l as AggregateExpr, ln as resolveDesignType, lt as TExistingColumn, m as AtscriptDbWritable, mn as TReadControls, mt as TFkLookupTarget, n as TResolvedBucket, nn as isFieldRef, nt as TDbWriteCheckContext, o as normalizeComputedSelect, on as NativeIntegrity, ot as TDerivedChangeReason, pn as FieldMappingStrategy, pt as TFkLookupResolver, q as TDbObjectKind, qt as isAtscriptDbView, r as isBucketableField, rn as translateQueryTree, rt as TDbWriteGuard, s as resolveCalendarBuckets, sn as AtscriptDbReadable, st as TDerivedColumn, t as TBucketFieldSource, tn as TViewPlan, tt as TDbWriteCheck, u as AggregateFn, un as DbEncryption, ut as TExistingForeignKey, v as DbRow, vt as TMetaResponse, w as OwnPropsOf, wt as TSearchIndexInfo, x as FlatOf, xt as TReferencingForeignKey, y as FieldOpsFor, yt as TMetadataOverrides, z as TDbDeleteResult, zt as isGeoPointType } from "./buckets-DRycmhOW.mjs";
1
+ import { $ as TDbReferentialAction, $t as AtscriptDbView, A as TCrudOp, An as containsRelationFilter, At as TSearchIndexInfo, B as TDbDefaultValue, Bn as NoopLogger, Bt as Uniquery, C as NavPropsOf, Cn as REL_FILTER_MAX_NODES, Ct as TInsertOptions, D as TCascadeResolver, Dn as TRelationFilterTable, Dt as TReferencingForeignKey, E as PrimaryKeyOf, En as TRelationFilterJunction, Et as TPrimaryKeyChange, F as TDbActionProcessor, Fn as DbEncryption, Ft as TValueFormatterPair, G as TDbIndexField, Gn as UniquSelect, Gt as isGeoPointType, H as TDbFieldMeta, Hn as TExprAggregate, Ht as WithRelation, I as TDbActionTargetSummary, In as TDbEncryptionOptions, It as TViewJsonType, J as TDbInsertIgnoreSlot, Jt as BaseDbAdapter, K as TDbIndexType, Kt as ALL_BUCKET_UNITS, L as TDbAvailableActions, Ln as DocumentFieldMapper, Lt as TWriteOptions, M as TDbActionInfo, Mn as hasRelationOp, Mt as TTableOptionDiff, N as TDbActionIntent, Nn as isResolvedRelationFilter, Nt as TTableResolver, O as TCascadeTarget, On as TRelationStaticFilter, Ot as TRelationInfo, P as TDbActionLevel, Pn as relationStaticFilter, Pt as TTouchManyOptions, Q as TDbObjectKind, Qt as TDbSpaceOptions, R as TDbCollation, Rn as FieldMappingStrategy, Rt as TWriteTableResolver, S as FlatOf, Sn as REL_FILTER_MAX_DEPTH, St as TIdentification, T as OwnPropsOf, Tn as TRelGuardState, Tt as TMetadataOverrides, U as TDbForeignKey, Un as TFirstLast, Ut as TableMetadata, V as TDbDeleteResult, Vn as TGenericLogger, Vt as UniqueryControls, W as TDbIndex, Wn as TRowOrderKey, Wt as isGeoIndexableType, X as TDbInsertManyResult, Xt as DbSpace, Y as TDbInsertManyIgnoreResult, Yt as TViewCapability, Z as TDbInsertResult, Zt as TAdapterFactory, _ as DbPatch, _n as NativeIntegrity, _t as TFieldMeta, a as isJsonValueField, an as AtscriptOrderItem, at as TDbWriteAction, b as FieldOpsFor, bn as DbResponse, bt as TIdDescriptor, c as resolveCalendarBuckets, cn as AtscriptQueryNode, ct as TDbWriteGuard, d as AggregateFn, dn as TViewPlan, dt as TDerivedChangeReason, en as TViewColumnMapping, et as TDbRelation, f as AggregateQuery, fn as evaluateExpr, ft as TDerivedColumn, g as DbControls, gn as IntegrityStrategy, gt as TExistingTableOption, h as AtscriptDbWritable, hn as AtscriptDbTable, ht as TExistingForeignKey, i as isBucketableField, in as AtscriptExprNode, it as TDbUpdateResult, j as TCrudPermissions, jn as forEachResolvedRelation, jt as TSyncColumnResult, k as TColumnDiff, kn as andFilters, kt as TRowResolveOptions, l as AggregateControls, ln as AtscriptRef, lt as TDbWriteGuardContext, mn as translateQueryTree, mt as TExistingColumn, n as TComputedSelect, nn as isViewType, nt as TDbRemoveGuardContext, o as jsonValueAncestor, on as AtscriptQueryComparison, ot as TDbWriteCheck, p as AggregateResult, pn as isFieldRef, pt as TEnsureTableOptions, q as TDbInsertIgnoreResult, qt as ALL_VIEW_CAPABILITIES, r as TResolvedBucket, rn as aliasTargetOf, rt as TDbStorageType, s as normalizeComputedSelect, sn as AtscriptQueryFieldRef, st as TDbWriteCheckContext, t as TBucketFieldSource, tn as isAtscriptDbView, tt as TDbRemoveGuard, u as AggregateExpr, un as TViewJoin, ut as TDeleteOptions, v as DbQuery, vn as TCascadePin, vt as TFkLookupResolver, w as NullableOptional, wn as ResolvedRelationFilter, wt as TMetaResponse, x as FilterExpr, xn as resolveDesignType, xt as TIdResolveOptions, y as DbRow, yn as AtscriptDbReadable, yt as TFkLookupTarget, z as TDbDefaultFn, zn as TReadControls, zt as TypedWithRelation } from "./buckets-CNdTOnei.mjs";
2
2
  import { _ as separateFieldOps, a as $mul, c as $update, d as TDbFieldOp, f as TFieldOps, g as separateCas, h as reconcileCas, i as $insert, l as $upsert, m as isDbFieldOp, n as $dec, o as $remove, p as getDbFieldOp, r as $inc, s as $replace, t as $cas, u as TDbCas } from "./ops-AqhV7s9o.mjs";
3
3
  import { a as isPlainObject, i as isEmptyObject, n as findAncestorInSet, o as selfOrAncestor, r as getPath, t as deletePath } from "./object-CtPYTIvy.mjs";
4
- import { c as CalendarBucketLabel, d as WeekStart, g as ALL_AGGREGATE_FNS, l as ComputedExpr, o as BucketExpr, s as BucketUnit, u as ResolvedBucket } from "./agg-D5DHsAby.mjs";
5
- import { a as buildValidationContext, c as isNavRelation, d as getKeyProps, f as CasExhaustedError, g as bucketTimeZoneUnavailable, h as DbErrorCode, l as TArrayPatch, m as DbError, n as ValidatorMode, p as CasMismatchError, r as buildDbValidator, s as forceNavNonOptional, t as ValidationContext, u as TDbPatch } from "./validator-Bw6ks9Hy.mjs";
4
+ import { c as CalendarBucketLabel, d as WeekStart, g as ALL_AGGREGATE_FNS, l as ComputedExpr, o as BucketExpr, s as BucketUnit, u as ResolvedBucket } from "./agg-Wo-smrYV.mjs";
5
+ import { _ as aggregateFailure, a as buildValidationContext, c as isNavRelation, d as getKeyProps, f as CasExhaustedError, g as aggregateExpressionsNotSupported, h as DbErrorCode, l as TArrayPatch, m as DbError, n as ValidatorMode, p as CasMismatchError, r as buildDbValidator, s as forceNavNonOptional, t as ValidationContext, u as TDbPatch, v as bucketTimeZoneUnavailable, y as isConflict } from "./validator-tBNvM1qc.mjs";
6
6
  import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.mjs";
7
- import { n as isColumnTypeChanged } from "./column-diff-Q9UmWn5x.mjs";
8
- import { i as tableNameOf } from "./relation-helpers-B-0NRKat.mjs";
9
- import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
10
- import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, ResolvedBucket as ResolvedBucket$1, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
7
+ import { r as fkColumns, s as isColumnTypeChanged } from "./fk-diff-DsaIijVX.mjs";
8
+ import { i as tableNameOf } from "./relation-helpers-Ba0v49sn.mjs";
9
+ import { AtscriptExprNode as AtscriptExprNode$1, TAtscriptAnnotatedType } from "@atscript/typescript/utils";
10
+ import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, RELATION_OPS, RelationOp, RelationOp as RelationOp$1, ResolvedRowOrderKey, ResolvedSelectExpr, Uniquery as Uniquery$1, computeInsights, isPrimitive, isRelationOp, walkFilter } from "@uniqu/core";
11
11
 
12
12
  //#region src/shared/consts.d.ts
13
13
  /**
@@ -30,14 +30,16 @@ declare class RelationalFieldMapper extends FieldMappingStrategy {
30
30
  /** The flattened column of a logical path (`contact.email` → `contact__email`). */
31
31
  protected physicalPath(logical: string, meta: TableMetadata): string;
32
32
  /**
33
- * Overrides the base `translateFilter` to use `leafByLogical` for key resolution
33
+ * Overrides the base `translateResolvedFilter` to use `leafByLogical` for key resolution
34
34
  * (handles flattened nested paths like `contact.email` → `contact__email`).
35
35
  */
36
- translateFilter(filter: FilterExpr$1, meta: TableMetadata): FilterExpr$1;
36
+ protected translateResolvedFilter(filter: FilterExpr$1, meta: TableMetadata): FilterExpr$1;
37
37
  /**
38
38
  * Translates filter with key renaming from logical to physical names.
39
39
  * Used by the relational query path where field paths must be mapped
40
- * to `__`-separated column names.
40
+ * to `__`-separated column names. Relational predicates must already be
41
+ * resolved (`translateFilter` / `translateQuery` do it); a resolved
42
+ * predicate passes through under its navigation-field key.
41
43
  */
42
44
  translateFilterWithRename(filter: FilterExpr$1, meta: TableMetadata): FilterExpr$1;
43
45
  prepareForWrite(payload: Record<string, unknown>, meta: TableMetadata, adapter: BaseDbAdapter): Record<string, unknown>;
@@ -83,8 +85,14 @@ declare class ApplicationIntegrity extends IntegrityStrategy {
83
85
  * - `restrict`: throws if any children exist
84
86
  * - `cascade`: recursively deletes child records
85
87
  * - `setNull`: sets FK fields to null
88
+ *
89
+ * When `filter` holds a relational predicate, returns the matched rows
90
+ * PINNED by primary key (see {@link TCascadePin}): the caller deletes those
91
+ * rows, never re-evaluating `filter` on data the cascade just changed (a
92
+ * `$some` over a cascaded child relation would otherwise stop matching and
93
+ * leave the parent behind). Any other filter → `undefined`.
86
94
  */
87
- cascadeBeforeDelete(filter: FilterExpr$1, tableName: string, meta: TableMetadata, cascadeResolver: TCascadeResolver, translateFilter: (f: FilterExpr$1) => FilterExpr$1, adapter: BaseDbAdapter): Promise<void>;
95
+ cascadeBeforeDelete(filter: FilterExpr$1, tableName: string, meta: TableMetadata, cascadeResolver: TCascadeResolver, translateFilter: (f: FilterExpr$1) => FilterExpr$1, adapter: BaseDbAdapter): Promise<TCascadePin>;
88
96
  needsCascade(cascadeResolver: TCascadeResolver | undefined): boolean;
89
97
  private recordKey;
90
98
  /**
@@ -119,6 +127,9 @@ declare class ApplicationIntegrity extends IntegrityStrategy {
119
127
  * {@link canFilterLeaf}) needs → `INVALID_QUERY` (see {@link guardPaths}).
120
128
  * Runs after the checks above so `ENC_*` codes keep firing first for
121
129
  * encrypted subtrees.
130
+ * - every filter / `$having` comparison value must be able to denote its
131
+ * field's declared type (`?n='x'` on a number) → `INVALID_QUERY`, after
132
+ * the path guard (see `guardFilterValues`, since 0.1.147).
122
133
  */
123
134
  /** Validates a `[lng, lat]` tuple (GeoJSON coordinate order). */
124
135
  declare function assertGeoPoint(point: unknown, path: string): asserts point is [number, number];
@@ -138,6 +149,7 @@ interface TGuardedQuery {
138
149
  $select?: unknown;
139
150
  $groupBy?: unknown;
140
151
  $having?: unknown;
152
+ $rowOrder?: unknown;
141
153
  };
142
154
  }
143
155
  /**
@@ -156,13 +168,23 @@ declare function sortFieldNames(sort: unknown): string[];
156
168
  * The operator class a filter entry needs from its field (since 0.1.132):
157
169
  * - `compare` — value comparison (bare values, `$eq`, `$gt`, `$in`, `$regex`, any mix);
158
170
  * - `geo` — a `$geoWithin` entry;
159
- * - `exists` — an entry whose sole operator is `$exists`.
171
+ * - `exists` — an entry whose sole operator is `$exists`;
172
+ * - `relation` — a relational predicate (`$some` / `$none` only) on a
173
+ * navigation field (since 0.1.147).
160
174
  */
161
- type TFilterPredicate = "compare" | "geo" | "exists";
175
+ type TFilterPredicate = "compare" | "geo" | "exists" | "relation";
162
176
  /** One filter entry, collected per occurrence: its key and the predicate class its operators need. */
163
177
  interface TFilterRef {
164
178
  path: string;
165
179
  predicate: TFilterPredicate;
180
+ /**
181
+ * `relation` entries: each operator with its operand (a filter on the
182
+ * related table, not walked here). @since 0.1.147
183
+ */
184
+ relation?: Array<{
185
+ op: RelationOp$1;
186
+ filter: FilterExpr$1;
187
+ }>;
166
188
  }
167
189
  /**
168
190
  * The reason clause for a leaf the adapter cannot filter (value comparison).
@@ -223,6 +245,28 @@ type TBucketSourceVerdict = {
223
245
  code: "encrypted" | "jsonDescendant" | "notTimestamp" | "notFilterable" | "notDimension" | "noBuckets";
224
246
  reason: string;
225
247
  };
248
+ /** {@link groupSourceVerdict}'s answer — the `reason` clause has no trailing period. */
249
+ type TGroupSourceVerdict = {
250
+ ok: true;
251
+ } | {
252
+ ok: false;
253
+ code: "encrypted" | "notFilterable" | "notDimension";
254
+ reason: string;
255
+ };
256
+ /**
257
+ * Whether the stored leaf `fd` may be a `$groupBy` key (since 0.1.148) — the
258
+ * one rule for the core's strict-table check and moost-db's capability index
259
+ * (`/meta.fields[P].groupable` and the HTTP gate). First failing rule wins:
260
+ *
261
+ * 1. `encrypted` — `@db.encrypted`;
262
+ * 2. `notFilterable` — the adapter cannot filter (so cannot group) the storage;
263
+ * 3. `notDimension` — a strict table ({@link isStrictTable}) and the field is
264
+ * not a dimension.
265
+ *
266
+ * A calendar-bucket alias is not a field: it groups by its source, whose
267
+ * dimension rule is {@link bucketSourceVerdict}'s (callers skip aliases).
268
+ */
269
+ declare function groupSourceVerdict(fd: TDbFieldMeta, table: Pick<TBucketSourceTable, "dimensions" | "measures">, adapter: Pick<BaseDbAdapter, "canFilterField">): TGroupSourceVerdict;
226
270
  /**
227
271
  * Whether the stored leaf `fd` may be the source of a calendar bucket
228
272
  * (since 0.1.133) — every schema and adapter rule, once, for the core path
@@ -281,8 +325,9 @@ interface TQueryPathRefs {
281
325
  *
282
326
  * Aggregate mode is `aggregate` when given, else the presence of `$groupBy`.
283
327
  * In aggregate mode `$select` computed entries are collected by kind — an
284
- * aggregate's `$field` into `aggregate`, a calendar bucket's into `bucket` —
285
- * and their aliases (`$as`, else uniqu's `resolveAlias`) are exempted from
328
+ * aggregate's `$field` (a row-level expression's names, a `first` / `last`
329
+ * field) into `aggregate`, a calendar bucket's into `bucket`, a `$rowOrder`
330
+ * key into `sort` — and their aliases (`$as`, else uniqu's `resolveAlias`) are exempted from
286
331
  * `$sort` / `$having`; a bucket alias is also dropped from `groupBy`, which
287
332
  * lists grouped fields only.
288
333
  *
@@ -357,16 +402,20 @@ declare function guardPath(meta: TableMetadata, adapter: BaseDbAdapter, path: st
357
402
  * `bucket`), `$groupBy` fields are checked, and computed aliases (`$as` or
358
403
  * the default) are exempt in `$sort` / `$having`.
359
404
  *
405
+ * Then every filter comparison value must be able to denote its field's
406
+ * declared type (`guardFilterValues`, since 0.1.147) — after the paths, so
407
+ * an unknown or unfilterable field keeps its own rejection.
408
+ *
360
409
  * Returns the collected refs so callers can run further structural rules
361
410
  * (see {@link checkHavingKeys}) without walking the query again.
362
411
  */
363
- declare function guardPaths(meta: TableMetadata, adapter: BaseDbAdapter, query: TGuardedQuery | undefined, aggregate?: boolean): TQueryPathRefs | undefined;
412
+ declare function guardPaths(meta: TableMetadata, adapter: BaseDbAdapter, query: TGuardedQuery | undefined, aggregate?: boolean, state?: TRelGuardState): TQueryPathRefs | undefined;
364
413
  /**
365
414
  * Shared read-path guard: filter + $sort encryption checks, the `$select`
366
415
  * normalizer (a calendar bucket is invalid outside a grouped query), then
367
416
  * the path guard.
368
417
  */
369
- declare function guardQuery(meta: TableMetadata, adapter: BaseDbAdapter, query: TGuardedQuery | undefined): void;
418
+ declare function guardQuery(meta: TableMetadata, adapter: BaseDbAdapter, query: TGuardedQuery | undefined, state?: TRelGuardState): void;
370
419
  /**
371
420
  * `$having` is a post-aggregation filter, so a key is either a computed
372
421
  * alias (aggregate or calendar bucket — already exempt in
@@ -387,12 +436,13 @@ declare function checkHavingKeys(refs: TQueryPathRefs): {
387
436
  * (`AGG_FN_NOT_SUPPORTED`) and calendar-bucket units
388
437
  * (`BUCKET_NOT_SUPPORTED`), then the `$having` key rule
389
438
  * ({@link checkHavingKeys} — after the path guard so an unknown key still
390
- * reads `Unknown field`).
439
+ * reads `Unknown field`), then the `$having` values (`guardHavingValues`).
391
440
  *
392
- * `buckets` are the query's resolved calendar buckets when the caller already
393
- * ran `normalizeComputedSelect` (resolved here otherwise).
441
+ * `resolved` is the query's normalized computed `$select`
442
+ * (`resolveComputedSelect`) when the caller already ran it (resolved here
443
+ * otherwise).
394
444
  */
395
- declare function guardAggregate(meta: TableMetadata, adapter: BaseDbAdapter, query: AggregateQuery$1, resolved?: readonly ResolvedBucket$1[]): void;
445
+ declare function guardAggregate(meta: TableMetadata, adapter: BaseDbAdapter, query: AggregateQuery$1, resolved?: TComputedSelect): void;
396
446
  //#endregion
397
447
  //#region src/with-optimistic-retry.d.ts
398
448
  interface WithOptimisticRetryOptions {
@@ -433,6 +483,14 @@ interface WithOptimisticRetryOptions {
433
483
  */
434
484
  declare function withOptimisticRetry<TRow extends Record<string, unknown>>(table: AtscriptDbTable, filter: Record<string, unknown>, mutator: (row: TRow) => Promise<Record<string, unknown> | undefined> | Record<string, unknown> | undefined, opts?: WithOptimisticRetryOptions): Promise<TDbUpdateResult>;
435
485
  //#endregion
486
+ //#region src/shared/keys.d.ts
487
+ /**
488
+ * Identity of the key tuple `fields` of `row` for uniqueness checks, or
489
+ * `undefined` when any component is null / missing (a NULL never collides).
490
+ * Equal across driver representations (see {@link keyString}).
491
+ */
492
+ declare function uniqueKeyTuple(row: Record<string, unknown>, fields: readonly string[]): string | undefined;
493
+ //#endregion
436
494
  //#region src/shared/index-messages.d.ts
437
495
  /**
438
496
  * Wording of the "index not found" errors — one source for the core, every
@@ -531,4 +589,16 @@ declare function createFailureCollector(what: string): {
531
589
  throwIfAny: () => void;
532
590
  };
533
591
  //#endregion
534
- export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type BucketExpr, type BucketUnit, type CalendarBucketLabel, CasExhaustedError, CasMismatchError, type ComputedExpr, DEFAULT_DB_SPACE, type DbControls, DbEncryption, DbError, type DbErrorCode, type DbPatch, type DbQuery, type DbResponse, type DbRow, DbSpace, type DbValidationContext, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, type FlatOf, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type OwnPropsOf, type PrimaryKeyOf, RelationalFieldMapper, type ResolvedBucket, type TAdapterFactory, type TArrayPatch, type TBucketFieldSource, type TBucketSourceTable, type TBucketSourceVerdict, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbAvailableActions, type TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateResult, type TDbWriteAction, type TDbWriteCheck, type TDbWriteCheckContext, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TDerivedChangeReason, type TDerivedColumn, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TMetaResponse, type TMetadataOverrides, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReadControls, type TReferencingForeignKey, type TRelationInfo, type TResolvedBucket, type TRowResolveOptions, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, aliasTargetOf, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, deletePath, findAncestorInSet, forceNavNonOptional, geoIndexNotFoundMessage, getDbFieldOp, getKeyProps, getPath, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isDbEntityType, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, reconcileCas, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, tableNameOf, translateQueryTree, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
592
+ //#region src/query/aggregate-expr.d.ts
593
+ /**
594
+ * Why a field cannot be an arithmetic operand, or `undefined` when it can: it
595
+ * must be a `number` (not a decimal — those are exact, an expression is IEEE
596
+ * double — and not a timestamp-tagged number) with plain column storage. The
597
+ * runtime twin of `@db.compute`'s operand rule, so declared and query-time
598
+ * arithmetic accept the same fields.
599
+ *
600
+ * @since 0.1.148
601
+ */
602
+ declare function numericOperandProblem(fd: TDbFieldMeta): string | undefined;
603
+ //#endregion
604
+ export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_VIEW_CAPABILITIES, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptExprNode, type AtscriptOrderItem, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type BucketExpr, type BucketUnit, type CalendarBucketLabel, CasExhaustedError, CasMismatchError, type ComputedExpr, DEFAULT_DB_SPACE, type DbControls, DbEncryption, DbError, type DbErrorCode, type DbPatch, type DbQuery, type DbResponse, type DbRow, DbSpace, type DbValidationContext, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, type FlatOf, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type OwnPropsOf, type PrimaryKeyOf, RELATION_OPS, REL_FILTER_MAX_DEPTH, REL_FILTER_MAX_NODES, type RelationOp, RelationalFieldMapper, type ResolvedBucket, ResolvedRelationFilter, type TAdapterFactory, type TArrayPatch, type TBucketFieldSource, type TBucketSourceTable, type TBucketSourceVerdict, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbActionTargetSummary, type TDbAvailableActions, type TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertIgnoreResult, type TDbInsertIgnoreSlot, type TDbInsertManyIgnoreResult, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateResult, type TDbWriteAction, type TDbWriteCheck, type TDbWriteCheckContext, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TDerivedChangeReason, type TDerivedColumn, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TExprAggregate, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFirstLast, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGroupSourceVerdict, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TInsertOptions, type TMetaResponse, type TMetadataOverrides, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReadControls, type TReferencingForeignKey, type TRelationFilterJunction, type TRelationFilterTable, type TRelationInfo, type TRelationStaticFilter, type TResolvedBucket, type TRowOrderKey, type TRowResolveOptions, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewCapability, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, aggregateExpressionsNotSupported, aggregateFailure, aliasTargetOf, andFilters, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, containsRelationFilter, createDbValidatorPlugin, createFailureCollector, decomposePatch, deletePath, evaluateExpr, findAncestorInSet, fkColumns, forEachResolvedRelation, forceNavNonOptional, geoIndexNotFoundMessage, getDbFieldOp, getKeyProps, getPath, groupSourceVerdict, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, hasRelationOp, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isConflict, isDbEntityType, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, isRelationOp, isResolvedRelationFilter, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, numericOperandProblem, reconcileCas, relationStaticFilter, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };