@atscript/db 0.1.152 → 0.1.154

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 (45) hide show
  1. package/dist/agg.cjs +1 -1
  2. package/dist/agg.d.cts +1 -1
  3. package/dist/agg.d.mts +1 -1
  4. package/dist/agg.mjs +1 -1
  5. package/dist/{aggregate-fns-CyaZyb9I.mjs → aggregate-fns-B_sgl4mB.mjs} +1 -1
  6. package/dist/{aggregate-fns-C-UJRobm.cjs → aggregate-fns-DFtKAv7Q.cjs} +1 -1
  7. package/dist/{buckets-Cb0zmhDc.d.mts → buckets-CBKL_ZWE.d.mts} +205 -7
  8. package/dist/{buckets-tzd8iIM2.d.cts → buckets-jy8BfswO.d.cts} +205 -7
  9. package/dist/{column-diff-CnyLjbQ8.mjs → column-diff-DAIAq6XR.mjs} +728 -29
  10. package/dist/{column-diff-CU7KHj9-.cjs → column-diff-qnzx1o3c.cjs} +727 -28
  11. package/dist/{db-error-DRQH4sLY.cjs → db-error-JcfJqqpk.cjs} +29 -0
  12. package/dist/{db-error-Az85UhTX.mjs → db-error-eSsQX7rt.mjs} +24 -1
  13. package/dist/{fk-diff-Bw26lwSc.d.cts → fk-diff-BIJ8l_hF.d.mts} +1 -1
  14. package/dist/{fk-diff-lcAnwvm9.d.mts → fk-diff-D1mrLMjU.d.cts} +1 -1
  15. package/dist/index.cjs +93 -5
  16. package/dist/index.d.cts +29 -5
  17. package/dist/index.d.mts +29 -5
  18. package/dist/index.mjs +92 -6
  19. package/dist/{nested-writer-cvbVAkNo.mjs → nested-writer-BOj_c_lI.mjs} +1 -1
  20. package/dist/{nested-writer-BzbOPSUp.cjs → nested-writer-Bl1SZS7x.cjs} +1 -1
  21. package/dist/ops.cjs +1 -1
  22. package/dist/ops.mjs +1 -1
  23. package/dist/plugin.cjs +48 -1
  24. package/dist/plugin.mjs +48 -1
  25. package/dist/rel.cjs +2 -2
  26. package/dist/rel.d.cts +2 -2
  27. package/dist/rel.d.mts +2 -2
  28. package/dist/rel.mjs +2 -2
  29. package/dist/{relation-helpers-Bdo4NHPC.d.mts → relation-helpers-BUsxNNGU.d.mts} +1 -1
  30. package/dist/{relation-helpers-DxIZKvnJ.d.cts → relation-helpers-D_8bydc2.d.cts} +1 -1
  31. package/dist/{relation-loader-DYab07lw.mjs → relation-loader-CNBMPfRr.mjs} +2 -1
  32. package/dist/{relation-loader-fNjHgBMs.cjs → relation-loader-DeulLrAw.cjs} +2 -1
  33. package/dist/sync.cjs +2 -2
  34. package/dist/sync.d.cts +2 -2
  35. package/dist/sync.d.mts +2 -2
  36. package/dist/sync.mjs +2 -2
  37. package/dist/{validator-tBNvM1qc.d.cts → validator-B3xlbrWf.d.cts} +36 -2
  38. package/dist/{validator-tBNvM1qc.d.mts → validator-B3xlbrWf.d.mts} +36 -2
  39. package/dist/{validator-BTiIOTKP.mjs → validator-BACewoRj.mjs} +51 -7
  40. package/dist/{validator-UcuJxHNT.cjs → validator-BxWwh3wf.cjs} +50 -6
  41. package/dist/validator.cjs +2 -2
  42. package/dist/validator.d.cts +1 -1
  43. package/dist/validator.d.mts +1 -1
  44. package/dist/validator.mjs +2 -2
  45. package/package.json +8 -8
@@ -1,4 +1,10 @@
1
1
  //#region src/db-error.ts
2
+ /** Codes whose operation may succeed when the whole transaction is retried. */
3
+ const RETRYABLE_CODES = new Set([
4
+ "DEADLOCK",
5
+ "LOCK_TIMEOUT",
6
+ "SERIALIZATION_FAILURE"
7
+ ]);
2
8
  var DbError = class extends Error {
3
9
  code;
4
10
  errors;
@@ -9,7 +15,24 @@ var DbError = class extends Error {
9
15
  this.errors = errors;
10
16
  this.stack = void 0;
11
17
  }
18
+ /**
19
+ * `true` when retrying the whole transaction may succeed — a transient
20
+ * concurrency condition (`DEADLOCK`, `LOCK_TIMEOUT`,
21
+ * `SERIALIZATION_FAILURE`), not a fault of the
22
+ * request. @since 0.1.153
23
+ */
24
+ get retryable() {
25
+ return RETRYABLE_CODES.has(this.code);
26
+ }
12
27
  };
28
+ /**
29
+ * Whether `error` is a retryable `DbError` (`DEADLOCK` / `LOCK_TIMEOUT` /
30
+ * `SERIALIZATION_FAILURE`):
31
+ * re-running the whole transaction may succeed. @since 0.1.153
32
+ */
33
+ function isRetryableDbError(error) {
34
+ return error instanceof DbError && error.retryable;
35
+ }
13
36
  /** Whether `error` is a `DbError` with code `CONFLICT` (unique / primary-key violation). */
14
37
  function isConflict(error) {
15
38
  return error instanceof DbError && error.code === "CONFLICT";
@@ -163,6 +186,12 @@ Object.defineProperty(exports, "isConflict", {
163
186
  return isConflict;
164
187
  }
165
188
  });
189
+ Object.defineProperty(exports, "isRetryableDbError", {
190
+ enumerable: true,
191
+ get: function() {
192
+ return isRetryableDbError;
193
+ }
194
+ });
166
195
  Object.defineProperty(exports, "spaceClosedError", {
167
196
  enumerable: true,
168
197
  get: function() {
@@ -1,4 +1,10 @@
1
1
  //#region src/db-error.ts
2
+ /** Codes whose operation may succeed when the whole transaction is retried. */
3
+ const RETRYABLE_CODES = new Set([
4
+ "DEADLOCK",
5
+ "LOCK_TIMEOUT",
6
+ "SERIALIZATION_FAILURE"
7
+ ]);
2
8
  var DbError = class extends Error {
3
9
  code;
4
10
  errors;
@@ -9,7 +15,24 @@ var DbError = class extends Error {
9
15
  this.errors = errors;
10
16
  this.stack = void 0;
11
17
  }
18
+ /**
19
+ * `true` when retrying the whole transaction may succeed — a transient
20
+ * concurrency condition (`DEADLOCK`, `LOCK_TIMEOUT`,
21
+ * `SERIALIZATION_FAILURE`), not a fault of the
22
+ * request. @since 0.1.153
23
+ */
24
+ get retryable() {
25
+ return RETRYABLE_CODES.has(this.code);
26
+ }
12
27
  };
28
+ /**
29
+ * Whether `error` is a retryable `DbError` (`DEADLOCK` / `LOCK_TIMEOUT` /
30
+ * `SERIALIZATION_FAILURE`):
31
+ * re-running the whole transaction may succeed. @since 0.1.153
32
+ */
33
+ function isRetryableDbError(error) {
34
+ return error instanceof DbError && error.retryable;
35
+ }
13
36
  /** Whether `error` is a `DbError` with code `CONFLICT` (unique / primary-key violation). */
14
37
  function isConflict(error) {
15
38
  return error instanceof DbError && error.code === "CONFLICT";
@@ -115,4 +138,4 @@ function aggregateExpressionsNotSupported() {
115
138
  }]);
116
139
  }
117
140
  //#endregion
118
- export { aggregateExpressionsNotSupported as a, isConflict as c, DepthLimitExceededError as i, spaceClosedError as l, CasMismatchError as n, aggregateFailure as o, DbError as r, bucketTimeZoneUnavailable as s, CasExhaustedError as t };
141
+ export { aggregateExpressionsNotSupported as a, isConflict as c, DepthLimitExceededError as i, isRetryableDbError as l, CasMismatchError as n, aggregateFailure as o, DbError as r, bucketTimeZoneUnavailable as s, CasExhaustedError as t, spaceClosedError as u };
@@ -1,4 +1,4 @@
1
- import { B as TDbDefaultValue, H as TDbFieldMeta, R as TDbCollation, U as TDbForeignKey, _t as TExistingTableOption, bn as AtscriptDbReadable, cn as AtscriptQueryFieldRef, en as AtscriptDbView, ht as TExistingColumn, k as TColumnDiff, ln as AtscriptQueryNode, pt as TDerivedColumn, rt as TDbStorageType } from "./buckets-tzd8iIM2.cjs";
1
+ import { A as TColumnDiff, Cn as AtscriptDbReadable, U as TDbFieldMeta, V as TDbDefaultValue, W as TDbForeignKey, _t as TExistingColumn, at as TDbStorageType, dn as AtscriptQueryFieldRef, fn as AtscriptQueryNode, ht as TDerivedColumn, nn as AtscriptDbView, yt as TExistingTableOption, z as TDbCollation } from "./buckets-CBKL_ZWE.mjs";
2
2
 
3
3
  //#region src/schema/schema-hash.d.ts
4
4
  interface TFieldSnapshot {
@@ -1,4 +1,4 @@
1
- import { B as TDbDefaultValue, H as TDbFieldMeta, R as TDbCollation, U as TDbForeignKey, _t as TExistingTableOption, bn as AtscriptDbReadable, cn as AtscriptQueryFieldRef, en as AtscriptDbView, ht as TExistingColumn, k as TColumnDiff, ln as AtscriptQueryNode, pt as TDerivedColumn, rt as TDbStorageType } from "./buckets-Cb0zmhDc.mjs";
1
+ import { A as TColumnDiff, Cn as AtscriptDbReadable, U as TDbFieldMeta, V as TDbDefaultValue, W as TDbForeignKey, _t as TExistingColumn, at as TDbStorageType, dn as AtscriptQueryFieldRef, fn as AtscriptQueryNode, ht as TDerivedColumn, nn as AtscriptDbView, yt as TExistingTableOption, z as TDbCollation } from "./buckets-jy8BfswO.cjs";
2
2
 
3
3
  //#region src/schema/schema-hash.d.ts
4
4
  interface TFieldSnapshot {
package/dist/index.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_db_error = require("./db-error-DRQH4sLY.cjs");
3
- const require_column_diff = require("./column-diff-CU7KHj9-.cjs");
4
- const require_aggregate_fns = require("./aggregate-fns-C-UJRobm.cjs");
5
- const require_nested_writer = require("./nested-writer-BzbOPSUp.cjs");
2
+ const require_db_error = require("./db-error-JcfJqqpk.cjs");
3
+ const require_column_diff = require("./column-diff-qnzx1o3c.cjs");
4
+ const require_aggregate_fns = require("./aggregate-fns-DFtKAv7Q.cjs");
5
+ const require_nested_writer = require("./nested-writer-Bl1SZS7x.cjs");
6
6
  const require_search_fields = require("./search-fields-DwrsJUC1.cjs");
7
7
  const require_object = require("./object-Djg28csK.cjs");
8
8
  const require_consts = require("./consts-BzRfCcH2.cjs");
9
9
  const require_ops = require("./ops.cjs");
10
- const require_validator = require("./validator-UcuJxHNT.cjs");
10
+ const require_validator = require("./validator-BxWwh3wf.cjs");
11
11
  let _atscript_typescript_utils = require("@atscript/typescript/utils");
12
12
  let _uniqu_core = require("@uniqu/core");
13
13
  let node_crypto = require("node:crypto");
@@ -204,6 +204,92 @@ async function withOptimisticRetry(table, filter, mutator, opts) {
204
204
  throw new require_db_error.CasExhaustedError(maxAttempts, lastSeenVersion);
205
205
  }
206
206
  //#endregion
207
+ //#region src/query/read-columns.ts
208
+ /** Logical connectives whose operands are sub-filters. */
209
+ const CONNECTIVES = new Set([
210
+ "$and",
211
+ "$or",
212
+ "$nor"
213
+ ]);
214
+ /**
215
+ * Adds every PHYSICAL column a translated filter reads to `out`: comparison
216
+ * keys, and — for a resolved relational predicate (`$some` / `$none`) — the
217
+ * source-side columns it correlates on. Returns `false` when the filter holds
218
+ * a top-level operator this walker does not know (then every column must be
219
+ * assumed read).
220
+ */
221
+ function collectFilter(filter, out) {
222
+ if (!filter || typeof filter !== "object") return true;
223
+ for (const [key, value] of Object.entries(filter)) {
224
+ if (CONNECTIVES.has(key)) {
225
+ if (!Array.isArray(value)) return false;
226
+ for (const child of value) if (!collectFilter(child, out)) return false;
227
+ continue;
228
+ }
229
+ if (key === "$not") {
230
+ if (!collectFilter(value, out)) return false;
231
+ continue;
232
+ }
233
+ if (key.startsWith("$")) return false;
234
+ out.add(key);
235
+ if (value && typeof value === "object" && !Array.isArray(value)) {
236
+ for (const operand of Object.values(value)) if (require_nested_writer.isResolvedRelationFilter(operand)) {
237
+ for (const pair of operand.pairs) out.add(pair.source);
238
+ for (const pair of operand.junction?.toSource ?? []) out.add(pair.source);
239
+ } else if (operand && typeof operand === "object" && "$field" in operand) {
240
+ const other = operand.$field;
241
+ if (typeof other !== "string") return false;
242
+ out.add(other);
243
+ }
244
+ }
245
+ }
246
+ return true;
247
+ }
248
+ /**
249
+ * The PHYSICAL columns of the queried table (or view) that a read of `kind`
250
+ * renders — filter keys and relational-predicate correlation columns, sort
251
+ * keys, `partitionBy`, the projection, and for an aggregate the group keys,
252
+ * bucket / aggregate / expression / `first`-`last` sources and `$having`
253
+ * keys. Names that are not columns (aggregate aliases) may be included — a
254
+ * consumer ignores names it does not know.
255
+ *
256
+ * `undefined` means EVERY column: the read projects all columns (no
257
+ * `$select`, so `SELECT *`), or its filter holds an operator this collector
258
+ * does not recognise. A view read may drop a left join only when no returned
259
+ * column reads it, so over-inclusion is always safe.
260
+ * @since 0.1.153
261
+ */
262
+ function queryReadColumns(query, kind, partitionBy) {
263
+ const out = /* @__PURE__ */ new Set();
264
+ if (!collectFilter(query.filter, out)) return void 0;
265
+ if (kind === "count") return out;
266
+ const controls = query.controls ?? {};
267
+ for (const key of Object.keys(controls.$sort ?? {})) out.add(key);
268
+ for (const key of Object.keys(controls.$nulls ?? {})) out.add(key);
269
+ for (const column of partitionBy ?? []) out.add(column);
270
+ const select = controls.$select;
271
+ const fields = select?.asArray;
272
+ if (kind === "rows") {
273
+ if (!fields || fields.length === 0) return void 0;
274
+ for (const field of fields) out.add(field);
275
+ return out;
276
+ }
277
+ const groupBy = controls.$groupBy ?? [];
278
+ const computed = select?.computedAliases.length ?? 0;
279
+ if (!fields?.length && !select?.buckets?.length && computed === 0) return;
280
+ for (const field of fields ?? []) out.add(field);
281
+ for (const key of groupBy) out.add(key);
282
+ for (const bucket of select?.buckets ?? []) out.add(bucket.field);
283
+ for (const expr of select?.aggregates ?? []) if (expr.$field !== "*") out.add(expr.$field);
284
+ for (const e of select?.exprAggregates ?? []) for (const name of e.names) out.add(name);
285
+ for (const e of select?.exprs ?? []) for (const name of e.names) out.add(name);
286
+ for (const fl of select?.firstLast ?? []) out.add(fl.column);
287
+ for (const key of select?.rowOrder ?? []) out.add(key.column);
288
+ for (const column of select?.sources.keys() ?? []) out.add(column);
289
+ if (controls.$having && !collectFilter(controls.$having, out)) return void 0;
290
+ return out;
291
+ }
292
+ //#endregion
207
293
  //#region src/table/db-space.ts
208
294
  /**
209
295
  * A `@db.alias` type only names a join scope inside a view definition — it
@@ -588,12 +674,14 @@ Object.defineProperty(exports, "isRelationOp", {
588
674
  }
589
675
  });
590
676
  exports.isResolvedRelationFilter = require_nested_writer.isResolvedRelationFilter;
677
+ exports.isRetryableDbError = require_db_error.isRetryableDbError;
591
678
  exports.isVersionExemptPatch = require_column_diff.isVersionExemptPatch;
592
679
  exports.isViewType = require_column_diff.isViewType;
593
680
  exports.jsonValueAncestor = require_column_diff.jsonValueAncestor;
594
681
  exports.narrowerFilterOps = require_column_diff.narrowerFilterOps;
595
682
  exports.normalizeComputedSelect = require_column_diff.normalizeComputedSelect;
596
683
  exports.numericOperandProblem = require_column_diff.numericOperandProblem;
684
+ exports.queryReadColumns = queryReadColumns;
597
685
  exports.reconcileCas = require_ops.reconcileCas;
598
686
  exports.relationStaticFilter = require_nested_writer.relationStaticFilter;
599
687
  exports.resolveCalendarBuckets = require_column_diff.resolveCalendarBuckets;
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
- import { $ as TDbReferentialAction, $t as TDbSpaceOptions, A as TCrudOp, An as andFilters, At as TRowResolveOptions, B as TDbDefaultValue, Bn as TReadControls, Bt as TypedWithRelation, C as NavPropsOf, Cn as REL_FILTER_MAX_DEPTH, Ct as TIdentification, D as TCascadeResolver, Dn as TRelationFilterJunction, Dt as TPrimaryKeyChange, E as PrimaryKeyOf, En as TRelGuardState, Et as TMetadataOverrides, F as TDbActionProcessor, Fn as relationStaticFilter, Ft as TTouchManyOptions, G as TDbIndexField, Gn as TRowOrderKey, Gt as isGeoIndexableType, H as TDbFieldMeta, Hn as TGenericLogger, Ht as UniqueryControls, I as TDbActionTargetSummary, In as DbEncryption, It as TValueFormatterPair, J as TDbInsertIgnoreSlot, Jt as ALL_VIEW_CAPABILITIES, K as TDbIndexType, Kn as UniquSelect, Kt as isGeoPointType, L as TDbAvailableActions, Ln as TDbEncryptionOptions, Lt as TViewJsonType, M as TDbActionInfo, Mn as forEachResolvedRelation, Mt as TSyncColumnResult, N as TDbActionIntent, Nn as hasRelationOp, Nt as TTableOptionDiff, O as TCascadeTarget, On as TRelationFilterTable, Ot as TReferencingForeignKey, P as TDbActionLevel, Pn as isResolvedRelationFilter, Pt as TTableResolver, Q as TDbObjectKind, Qt as TAdapterFactory, R as TDbCollation, Rn as DocumentFieldMapper, Rt as TWriteOptions, S as FlatOf, Sn as resolveDesignType, St as TIdResolveOptions, T as OwnPropsOf, Tn as ResolvedRelationFilter, Tt as TMetaResponse, U as TDbForeignKey, Un as TExprAggregate, Ut as WithRelation, V as TDbDeleteResult, Vn as NoopLogger, Vt as Uniquery, W as TDbIndex, Wn as TFirstLast, Wt as TableMetadata, X as TDbInsertManyResult, Xt as TViewCapability, Y as TDbInsertManyIgnoreResult, Yt as BaseDbAdapter, Z as TDbInsertResult, Zt as DbSpace, _ as DbPatch, _n as IntegrityStrategy, _t as TExistingTableOption, a as isJsonValueField, an as AtscriptExprNode, at as TDbUpdateResult, b as FieldOpsFor, bn as AtscriptDbReadable, bt as TFkLookupTarget, c as resolveCalendarBuckets, cn as AtscriptQueryFieldRef, ct as TDbWriteCheckContext, d as AggregateFn, dn as TViewJoin, dt as TDeleteOptions, en as AtscriptDbView, et as TDbRelation, f as AggregateQuery, fn as TViewPlan, ft as TDerivedChangeReason, g as DbControls, gn as AtscriptDbTable, gt as TExistingForeignKey, h as AtscriptDbWritable, hn as translateQueryTree, ht as TExistingColumn, i as isBucketableField, in as aliasTargetOf, it as TDbUpdateOptions, j as TCrudPermissions, jn as containsRelationFilter, jt as TSearchIndexInfo, k as TColumnDiff, kn as TRelationStaticFilter, kt as TRelationInfo, l as AggregateControls, ln as AtscriptQueryNode, lt as TDbWriteGuard, mn as isFieldRef, mt as TEnsureTableOptions, n as TComputedSelect, nn as isAtscriptDbView, nt as TDbRemoveGuardContext, o as jsonValueAncestor, on as AtscriptOrderItem, ot as TDbWriteAction, p as AggregateResult, pn as evaluateExpr, pt as TDerivedColumn, q as TDbInsertIgnoreResult, qt as ALL_BUCKET_UNITS, r as TResolvedBucket, rn as isViewType, rt as TDbStorageType, s as normalizeComputedSelect, sn as AtscriptQueryComparison, st as TDbWriteCheck, t as TBucketFieldSource, tn as TViewColumnMapping, tt as TDbRemoveGuard, u as AggregateExpr, un as AtscriptRef, ut as TDbWriteGuardContext, v as DbQuery, vn as NativeIntegrity, vt as TFieldMeta, w as NullableOptional, wn as REL_FILTER_MAX_NODES, wt as TInsertOptions, x as FilterExpr, xn as DbResponse, xt as TIdDescriptor, y as DbRow, yn as TCascadePin, yt as TFkLookupResolver, z as TDbDefaultFn, zn as FieldMappingStrategy, zt as TWriteTableResolver } from "./buckets-tzd8iIM2.cjs";
1
+ import { $ as TDbInsertResult, $t as DbSpace, A as TColumnDiff, An as TRelationFilterJunction, At as TReferencingForeignKey, B as TDbDefaultFn, Bn as TDbEncryptionOptions, Bt as TWriteOptions, C as NavPropsOf, Cn as AtscriptDbReadable, Ct as TIdDescriptor, D as PrimaryKeyOf, Dn as REL_FILTER_MAX_NODES, Dt as TMetaResponse, E as OwnPropsOf, En as REL_FILTER_MAX_DEPTH, Et as TInsertOptions, F as TDbActionLevel, Fn as forEachResolvedRelation, Ft as TTableOptionDiff, G as TDbIndex, Gn as TGenericLogger, Gt as WithRelation, H as TDbDeleteResult, Hn as FieldMappingStrategy, Ht as TypedWithRelation, I as TDbActionProcessor, In as hasRelationOp, It as TTableResolver, J as TDbInsertIgnoreOptions, Jn as TRowOrderKey, Jt as isGeoPointType, K as TDbIndexField, Kn as TExprAggregate, Kt as TableMetadata, L as TDbActionTargetSummary, Ln as isResolvedRelationFilter, Lt as TTouchManyOptions, M as TCrudPermissions, Mn as TRelationStaticFilter, Mt as TRowResolveOptions, N as TDbActionInfo, Nn as andFilters, Nt as TSearchIndexInfo, O as TCascadeResolver, On as ResolvedRelationFilter, Ot as TMetadataOverrides, P as TDbActionIntent, Pn as containsRelationFilter, Pt as TSyncColumnResult, Q as TDbInsertManyResult, Qt as TViewCapability, R as TDbAvailableActions, Rn as relationStaticFilter, Rt as TValueFormatterPair, S as FlatOf, Sn as TCascadePin, St as TFkLookupTarget, T as NullsPlacement, Tn as resolveDesignType, Tt as TIdentification, U as TDbFieldMeta, Un as TReadControls, Ut as Uniquery, V as TDbDefaultValue, Vn as DocumentFieldMapper, Vt as TWriteTableResolver, W as TDbForeignKey, Wn as NoopLogger, Wt as UniqueryControls, X as TDbInsertIgnoreSlot, Xt as ALL_VIEW_CAPABILITIES, Y as TDbInsertIgnoreResult, Yn as UniquSelect, Yt as ALL_BUCKET_UNITS, Z as TDbInsertManyIgnoreResult, Zt as BaseDbAdapter, _ as DbPatch, _n as isFieldRef, _t as TExistingColumn, a as isJsonValueField, an as isViewType, at as TDbStorageType, b as FieldOpsFor, bn as IntegrityStrategy, bt as TFieldMeta, c as resolveCalendarBuckets, cn as AtscriptExprNode, ct as TDbWriteAction, d as AggregateFn, dn as AtscriptQueryFieldRef, dt as TDbWriteGuard, en as TAdapterFactory, et as TDbObjectKind, f as AggregateQuery, fn as AtscriptQueryNode, ft as TDbWriteGuardContext, g as DbControls, gn as evaluateExpr, gt as TEnsureTableOptions, h as AtscriptDbWritable, hn as TViewPlan, ht as TDerivedColumn, i as isBucketableField, in as isAtscriptDbView, it as TDbRemoveGuardContext, j as TCrudOp, jn as TRelationFilterTable, jt as TRelationInfo, k as TCascadeTarget, kn as TRelGuardState, kt as TPrimaryKeyChange, l as AggregateControls, ln as AtscriptOrderItem, lt as TDbWriteCheck, mn as TViewJoin, mt as TDerivedChangeReason, n as TComputedSelect, nn as AtscriptDbView, nt as TDbRelation, o as jsonValueAncestor, on as TViewReadPlan, ot as TDbUpdateOptions, p as AggregateResult, pn as AtscriptRef, pt as TDeleteOptions, q as TDbIndexType, qn as TFirstLast, qt as isGeoIndexableType, r as TResolvedBucket, rn as TViewColumnMapping, rt as TDbRemoveGuard, s as normalizeComputedSelect, sn as aliasTargetOf, st as TDbUpdateResult, t as TBucketFieldSource, tn as TDbSpaceOptions, tt as TDbReferentialAction, u as AggregateExpr, un as AtscriptQueryComparison, ut as TDbWriteCheckContext, v as DbQuery, vn as translateQueryTree, vt as TExistingForeignKey, w as NullableOptional, wn as DbResponse, wt as TIdResolveOptions, x as FilterExpr, xn as NativeIntegrity, xt as TFkLookupResolver, y as DbRow, yn as AtscriptDbTable, yt as TExistingTableOption, z as TDbCollation, zn as DbEncryption, zt as TViewJsonType } from "./buckets-jy8BfswO.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
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";
5
+ import { _ as aggregateFailure, a as buildValidationContext, b as isRetryableDbError, 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-B3xlbrWf.cjs";
6
6
  import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.cjs";
7
- import { r as fkColumns, s as isColumnTypeChanged } from "./fk-diff-Bw26lwSc.cjs";
8
- import { i as tableNameOf } from "./relation-helpers-DxIZKvnJ.cjs";
7
+ import { r as fkColumns, s as isColumnTypeChanged } from "./fk-diff-D1mrLMjU.cjs";
8
+ import { i as tableNameOf } from "./relation-helpers-D_8bydc2.cjs";
9
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
10
  import { AtscriptExprNode as AtscriptExprNode$1, TAtscriptAnnotatedType } from "@atscript/typescript/utils";
11
11
 
@@ -149,6 +149,7 @@ interface TGuardedQuery {
149
149
  $groupBy?: unknown;
150
150
  $having?: unknown;
151
151
  $rowOrder?: unknown;
152
+ $nulls?: unknown;
152
153
  };
153
154
  }
154
155
  /**
@@ -563,6 +564,29 @@ declare function searchMemberKind(type: TAtscriptAnnotatedType | undefined): TSe
563
564
  problem: string;
564
565
  };
565
566
  //#endregion
567
+ //#region src/query/read-columns.d.ts
568
+ /**
569
+ * What a read renders: rows (`findOne` / `findMany` / per-partition pages),
570
+ * a row count, or an aggregate (`aggregate`, with or without `$count`).
571
+ * @since 0.1.153
572
+ */
573
+ type TReadColumnsKind = "rows" | "count" | "aggregate";
574
+ /**
575
+ * The PHYSICAL columns of the queried table (or view) that a read of `kind`
576
+ * renders — filter keys and relational-predicate correlation columns, sort
577
+ * keys, `partitionBy`, the projection, and for an aggregate the group keys,
578
+ * bucket / aggregate / expression / `first`-`last` sources and `$having`
579
+ * keys. Names that are not columns (aggregate aliases) may be included — a
580
+ * consumer ignores names it does not know.
581
+ *
582
+ * `undefined` means EVERY column: the read projects all columns (no
583
+ * `$select`, so `SELECT *`), or its filter holds an operator this collector
584
+ * does not recognise. A view read may drop a left join only when no returned
585
+ * column reads it, so over-inclusion is always safe.
586
+ * @since 0.1.153
587
+ */
588
+ declare function queryReadColumns(query: DbQuery, kind: TReadColumnsKind, partitionBy?: readonly string[]): Set<string> | undefined;
589
+ //#endregion
566
590
  //#region src/patch/patch-decomposer.d.ts
567
591
  /**
568
592
  * Decomposes a patch payload into a flat update object for adapters
@@ -662,4 +686,4 @@ declare function createFailureCollector(what: string): {
662
686
  */
663
687
  declare function numericOperandProblem(fd: TDbFieldMeta): string | undefined;
664
688
  //#endregion
665
- 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, INTEGER_REGEX_OP, 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 TDbUpdateOptions, 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 TSearchMemberKind, 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, defaultFulltextIndex, deletePath, describeFulltext, 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, isVersionExemptPatch, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, numericOperandProblem, reconcileCas, relationStaticFilter, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, searchMemberKind, searchTermInteger, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, splitFulltextFields, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
689
+ 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, INTEGER_REGEX_OP, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type NullsPlacement, 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 TDbInsertIgnoreOptions, 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 TDbUpdateOptions, 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 TReadColumnsKind, type TReadControls, type TReferencingForeignKey, type TRelationFilterJunction, type TRelationFilterTable, type TRelationInfo, type TRelationStaticFilter, type TResolvedBucket, type TRowOrderKey, type TRowResolveOptions, type TSearchIndexInfo, type TSearchMemberKind, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewCapability, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TViewReadPlan, 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, defaultFulltextIndex, deletePath, describeFulltext, 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, isRetryableDbError, isVersionExemptPatch, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, numericOperandProblem, queryReadColumns, reconcileCas, relationStaticFilter, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, searchMemberKind, searchTermInteger, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, splitFulltextFields, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
package/dist/index.d.mts CHANGED
@@ -1,11 +1,11 @@
1
- import { $ as TDbReferentialAction, $t as TDbSpaceOptions, A as TCrudOp, An as andFilters, At as TRowResolveOptions, B as TDbDefaultValue, Bn as TReadControls, Bt as TypedWithRelation, C as NavPropsOf, Cn as REL_FILTER_MAX_DEPTH, Ct as TIdentification, D as TCascadeResolver, Dn as TRelationFilterJunction, Dt as TPrimaryKeyChange, E as PrimaryKeyOf, En as TRelGuardState, Et as TMetadataOverrides, F as TDbActionProcessor, Fn as relationStaticFilter, Ft as TTouchManyOptions, G as TDbIndexField, Gn as TRowOrderKey, Gt as isGeoIndexableType, H as TDbFieldMeta, Hn as TGenericLogger, Ht as UniqueryControls, I as TDbActionTargetSummary, In as DbEncryption, It as TValueFormatterPair, J as TDbInsertIgnoreSlot, Jt as ALL_VIEW_CAPABILITIES, K as TDbIndexType, Kn as UniquSelect, Kt as isGeoPointType, L as TDbAvailableActions, Ln as TDbEncryptionOptions, Lt as TViewJsonType, M as TDbActionInfo, Mn as forEachResolvedRelation, Mt as TSyncColumnResult, N as TDbActionIntent, Nn as hasRelationOp, Nt as TTableOptionDiff, O as TCascadeTarget, On as TRelationFilterTable, Ot as TReferencingForeignKey, P as TDbActionLevel, Pn as isResolvedRelationFilter, Pt as TTableResolver, Q as TDbObjectKind, Qt as TAdapterFactory, R as TDbCollation, Rn as DocumentFieldMapper, Rt as TWriteOptions, S as FlatOf, Sn as resolveDesignType, St as TIdResolveOptions, T as OwnPropsOf, Tn as ResolvedRelationFilter, Tt as TMetaResponse, U as TDbForeignKey, Un as TExprAggregate, Ut as WithRelation, V as TDbDeleteResult, Vn as NoopLogger, Vt as Uniquery, W as TDbIndex, Wn as TFirstLast, Wt as TableMetadata, X as TDbInsertManyResult, Xt as TViewCapability, Y as TDbInsertManyIgnoreResult, Yt as BaseDbAdapter, Z as TDbInsertResult, Zt as DbSpace, _ as DbPatch, _n as IntegrityStrategy, _t as TExistingTableOption, a as isJsonValueField, an as AtscriptExprNode, at as TDbUpdateResult, b as FieldOpsFor, bn as AtscriptDbReadable, bt as TFkLookupTarget, c as resolveCalendarBuckets, cn as AtscriptQueryFieldRef, ct as TDbWriteCheckContext, d as AggregateFn, dn as TViewJoin, dt as TDeleteOptions, en as AtscriptDbView, et as TDbRelation, f as AggregateQuery, fn as TViewPlan, ft as TDerivedChangeReason, g as DbControls, gn as AtscriptDbTable, gt as TExistingForeignKey, h as AtscriptDbWritable, hn as translateQueryTree, ht as TExistingColumn, i as isBucketableField, in as aliasTargetOf, it as TDbUpdateOptions, j as TCrudPermissions, jn as containsRelationFilter, jt as TSearchIndexInfo, k as TColumnDiff, kn as TRelationStaticFilter, kt as TRelationInfo, l as AggregateControls, ln as AtscriptQueryNode, lt as TDbWriteGuard, mn as isFieldRef, mt as TEnsureTableOptions, n as TComputedSelect, nn as isAtscriptDbView, nt as TDbRemoveGuardContext, o as jsonValueAncestor, on as AtscriptOrderItem, ot as TDbWriteAction, p as AggregateResult, pn as evaluateExpr, pt as TDerivedColumn, q as TDbInsertIgnoreResult, qt as ALL_BUCKET_UNITS, r as TResolvedBucket, rn as isViewType, rt as TDbStorageType, s as normalizeComputedSelect, sn as AtscriptQueryComparison, st as TDbWriteCheck, t as TBucketFieldSource, tn as TViewColumnMapping, tt as TDbRemoveGuard, u as AggregateExpr, un as AtscriptRef, ut as TDbWriteGuardContext, v as DbQuery, vn as NativeIntegrity, vt as TFieldMeta, w as NullableOptional, wn as REL_FILTER_MAX_NODES, wt as TInsertOptions, x as FilterExpr, xn as DbResponse, xt as TIdDescriptor, y as DbRow, yn as TCascadePin, yt as TFkLookupResolver, z as TDbDefaultFn, zn as FieldMappingStrategy, zt as TWriteTableResolver } from "./buckets-Cb0zmhDc.mjs";
1
+ import { $ as TDbInsertResult, $t as DbSpace, A as TColumnDiff, An as TRelationFilterJunction, At as TReferencingForeignKey, B as TDbDefaultFn, Bn as TDbEncryptionOptions, Bt as TWriteOptions, C as NavPropsOf, Cn as AtscriptDbReadable, Ct as TIdDescriptor, D as PrimaryKeyOf, Dn as REL_FILTER_MAX_NODES, Dt as TMetaResponse, E as OwnPropsOf, En as REL_FILTER_MAX_DEPTH, Et as TInsertOptions, F as TDbActionLevel, Fn as forEachResolvedRelation, Ft as TTableOptionDiff, G as TDbIndex, Gn as TGenericLogger, Gt as WithRelation, H as TDbDeleteResult, Hn as FieldMappingStrategy, Ht as TypedWithRelation, I as TDbActionProcessor, In as hasRelationOp, It as TTableResolver, J as TDbInsertIgnoreOptions, Jn as TRowOrderKey, Jt as isGeoPointType, K as TDbIndexField, Kn as TExprAggregate, Kt as TableMetadata, L as TDbActionTargetSummary, Ln as isResolvedRelationFilter, Lt as TTouchManyOptions, M as TCrudPermissions, Mn as TRelationStaticFilter, Mt as TRowResolveOptions, N as TDbActionInfo, Nn as andFilters, Nt as TSearchIndexInfo, O as TCascadeResolver, On as ResolvedRelationFilter, Ot as TMetadataOverrides, P as TDbActionIntent, Pn as containsRelationFilter, Pt as TSyncColumnResult, Q as TDbInsertManyResult, Qt as TViewCapability, R as TDbAvailableActions, Rn as relationStaticFilter, Rt as TValueFormatterPair, S as FlatOf, Sn as TCascadePin, St as TFkLookupTarget, T as NullsPlacement, Tn as resolveDesignType, Tt as TIdentification, U as TDbFieldMeta, Un as TReadControls, Ut as Uniquery, V as TDbDefaultValue, Vn as DocumentFieldMapper, Vt as TWriteTableResolver, W as TDbForeignKey, Wn as NoopLogger, Wt as UniqueryControls, X as TDbInsertIgnoreSlot, Xt as ALL_VIEW_CAPABILITIES, Y as TDbInsertIgnoreResult, Yn as UniquSelect, Yt as ALL_BUCKET_UNITS, Z as TDbInsertManyIgnoreResult, Zt as BaseDbAdapter, _ as DbPatch, _n as isFieldRef, _t as TExistingColumn, a as isJsonValueField, an as isViewType, at as TDbStorageType, b as FieldOpsFor, bn as IntegrityStrategy, bt as TFieldMeta, c as resolveCalendarBuckets, cn as AtscriptExprNode, ct as TDbWriteAction, d as AggregateFn, dn as AtscriptQueryFieldRef, dt as TDbWriteGuard, en as TAdapterFactory, et as TDbObjectKind, f as AggregateQuery, fn as AtscriptQueryNode, ft as TDbWriteGuardContext, g as DbControls, gn as evaluateExpr, gt as TEnsureTableOptions, h as AtscriptDbWritable, hn as TViewPlan, ht as TDerivedColumn, i as isBucketableField, in as isAtscriptDbView, it as TDbRemoveGuardContext, j as TCrudOp, jn as TRelationFilterTable, jt as TRelationInfo, k as TCascadeTarget, kn as TRelGuardState, kt as TPrimaryKeyChange, l as AggregateControls, ln as AtscriptOrderItem, lt as TDbWriteCheck, mn as TViewJoin, mt as TDerivedChangeReason, n as TComputedSelect, nn as AtscriptDbView, nt as TDbRelation, o as jsonValueAncestor, on as TViewReadPlan, ot as TDbUpdateOptions, p as AggregateResult, pn as AtscriptRef, pt as TDeleteOptions, q as TDbIndexType, qn as TFirstLast, qt as isGeoIndexableType, r as TResolvedBucket, rn as TViewColumnMapping, rt as TDbRemoveGuard, s as normalizeComputedSelect, sn as aliasTargetOf, st as TDbUpdateResult, t as TBucketFieldSource, tn as TDbSpaceOptions, tt as TDbReferentialAction, u as AggregateExpr, un as AtscriptQueryComparison, ut as TDbWriteCheckContext, v as DbQuery, vn as translateQueryTree, vt as TExistingForeignKey, w as NullableOptional, wn as DbResponse, wt as TIdResolveOptions, x as FilterExpr, xn as NativeIntegrity, xt as TFkLookupResolver, y as DbRow, yn as AtscriptDbTable, yt as TExistingTableOption, z as TDbCollation, zn as DbEncryption, zt as TViewJsonType } from "./buckets-CBKL_ZWE.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
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";
5
+ import { _ as aggregateFailure, a as buildValidationContext, b as isRetryableDbError, 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-B3xlbrWf.mjs";
6
6
  import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.mjs";
7
- import { r as fkColumns, s as isColumnTypeChanged } from "./fk-diff-lcAnwvm9.mjs";
8
- import { i as tableNameOf } from "./relation-helpers-Bdo4NHPC.mjs";
7
+ import { r as fkColumns, s as isColumnTypeChanged } from "./fk-diff-BIJ8l_hF.mjs";
8
+ import { i as tableNameOf } from "./relation-helpers-BUsxNNGU.mjs";
9
9
  import { AtscriptExprNode as AtscriptExprNode$1, TAtscriptAnnotatedType } from "@atscript/typescript/utils";
10
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
 
@@ -149,6 +149,7 @@ interface TGuardedQuery {
149
149
  $groupBy?: unknown;
150
150
  $having?: unknown;
151
151
  $rowOrder?: unknown;
152
+ $nulls?: unknown;
152
153
  };
153
154
  }
154
155
  /**
@@ -563,6 +564,29 @@ declare function searchMemberKind(type: TAtscriptAnnotatedType | undefined): TSe
563
564
  problem: string;
564
565
  };
565
566
  //#endregion
567
+ //#region src/query/read-columns.d.ts
568
+ /**
569
+ * What a read renders: rows (`findOne` / `findMany` / per-partition pages),
570
+ * a row count, or an aggregate (`aggregate`, with or without `$count`).
571
+ * @since 0.1.153
572
+ */
573
+ type TReadColumnsKind = "rows" | "count" | "aggregate";
574
+ /**
575
+ * The PHYSICAL columns of the queried table (or view) that a read of `kind`
576
+ * renders — filter keys and relational-predicate correlation columns, sort
577
+ * keys, `partitionBy`, the projection, and for an aggregate the group keys,
578
+ * bucket / aggregate / expression / `first`-`last` sources and `$having`
579
+ * keys. Names that are not columns (aggregate aliases) may be included — a
580
+ * consumer ignores names it does not know.
581
+ *
582
+ * `undefined` means EVERY column: the read projects all columns (no
583
+ * `$select`, so `SELECT *`), or its filter holds an operator this collector
584
+ * does not recognise. A view read may drop a left join only when no returned
585
+ * column reads it, so over-inclusion is always safe.
586
+ * @since 0.1.153
587
+ */
588
+ declare function queryReadColumns(query: DbQuery, kind: TReadColumnsKind, partitionBy?: readonly string[]): Set<string> | undefined;
589
+ //#endregion
566
590
  //#region src/patch/patch-decomposer.d.ts
567
591
  /**
568
592
  * Decomposes a patch payload into a flat update object for adapters
@@ -662,4 +686,4 @@ declare function createFailureCollector(what: string): {
662
686
  */
663
687
  declare function numericOperandProblem(fd: TDbFieldMeta): string | undefined;
664
688
  //#endregion
665
- 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, INTEGER_REGEX_OP, 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 TDbUpdateOptions, 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 TSearchMemberKind, 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, defaultFulltextIndex, deletePath, describeFulltext, 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, isVersionExemptPatch, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, numericOperandProblem, reconcileCas, relationStaticFilter, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, searchMemberKind, searchTermInteger, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, splitFulltextFields, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
689
+ 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, INTEGER_REGEX_OP, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type NullsPlacement, 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 TDbInsertIgnoreOptions, 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 TDbUpdateOptions, 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 TReadColumnsKind, type TReadControls, type TReferencingForeignKey, type TRelationFilterJunction, type TRelationFilterTable, type TRelationInfo, type TRelationStaticFilter, type TResolvedBucket, type TRowOrderKey, type TRowResolveOptions, type TSearchIndexInfo, type TSearchMemberKind, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewCapability, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TViewReadPlan, 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, defaultFulltextIndex, deletePath, describeFulltext, 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, isRetryableDbError, isVersionExemptPatch, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, numericOperandProblem, queryReadColumns, reconcileCas, relationStaticFilter, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, searchMemberKind, searchTermInteger, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, splitFulltextFields, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { a as aggregateExpressionsNotSupported, c as isConflict, l as spaceClosedError, n as CasMismatchError, o as aggregateFailure, r as DbError, s as bucketTimeZoneUnavailable, t as CasExhaustedError } from "./db-error-Az85UhTX.mjs";
2
- import { $ as DocumentFieldMapper, A as resolveDesignType, B as checkHavingKeys, C as ALL_BUCKET_UNITS, D as IntegrityStrategy, E as createFailureCollector, F as ENCRYPTED_REASON, G as guardFilter, H as collectQueryPaths, I as acceptedOperatorsHint, J as guardQuery, K as guardPath, L as assertGeoPoint, M as searchIndexNotFoundMessage, N as vectorIndexNotFoundMessage, O as NativeIntegrity, P as ADAPTER_FILTER_REASON, Q as RelationalFieldMapper, R as bucketSourceVerdict, S as ApplicationIntegrity, T as BaseDbAdapter, U as groupSourceVerdict, V as classifyQueryPath, W as guardAggregate, X as sortFieldNames, Y as narrowerFilterOps, Z as unsupportedOperatorMessage, _ as isViewType, _t as NoopLogger, at as describeFulltext, b as assertNoVersionWrites, ct as TableMetadata, dt as aliasTargetOf, et as FieldMappingStrategy, f as fkColumns, ft as isBucketableField, g as isAtscriptDbView, gt as resolveCalendarBuckets, h as AtscriptDbView, ht as normalizeComputedSelect, it as defaultFulltextIndex, j as geoIndexNotFoundMessage, k as AtscriptDbReadable, lt as isGeoIndexableType, mt as jsonValueAncestor, n as isColumnTypeChanged, nt as numericOperandProblem, ot as searchTermInteger, pt as isJsonValueField, q as guardPaths, rt as INTEGER_REGEX_OP, st as splitFulltextFields, tt as UniquSelect, ut as isGeoPointType, v as AtscriptDbTable, w as ALL_VIEW_CAPABILITIES, x as decomposePatch, y as isVersionExemptPatch, z as canFilterLeaf } from "./column-diff-CnyLjbQ8.mjs";
3
- import { n as ALL_AGGREGATE_FNS } from "./aggregate-fns-CyaZyb9I.mjs";
4
- import { A as hasRelationOp, C as REL_FILTER_MAX_DEPTH, D as containsRelationFilter, E as andFilters, G as evaluateExpr, H as tableNameOf, K as isFieldRef, P as relationStaticFilter, S as uniqueKeyTuple, T as ResolvedRelationFilter, j as isResolvedRelationFilter, k as forEachResolvedRelation, q as translateQueryTree, w as REL_FILTER_MAX_NODES } from "./nested-writer-cvbVAkNo.mjs";
1
+ import { a as aggregateExpressionsNotSupported, c as isConflict, l as isRetryableDbError, n as CasMismatchError, o as aggregateFailure, r as DbError, s as bucketTimeZoneUnavailable, t as CasExhaustedError, u as spaceClosedError } from "./db-error-eSsQX7rt.mjs";
2
+ import { $ as DocumentFieldMapper, A as resolveDesignType, B as checkHavingKeys, C as ALL_BUCKET_UNITS, D as IntegrityStrategy, E as createFailureCollector, F as ENCRYPTED_REASON, G as guardFilter, H as collectQueryPaths, I as acceptedOperatorsHint, J as guardQuery, K as guardPath, L as assertGeoPoint, M as searchIndexNotFoundMessage, N as vectorIndexNotFoundMessage, O as NativeIntegrity, P as ADAPTER_FILTER_REASON, Q as RelationalFieldMapper, R as bucketSourceVerdict, S as ApplicationIntegrity, T as BaseDbAdapter, U as groupSourceVerdict, V as classifyQueryPath, W as guardAggregate, X as sortFieldNames, Y as narrowerFilterOps, Z as unsupportedOperatorMessage, _ as isViewType, _t as NoopLogger, at as describeFulltext, b as assertNoVersionWrites, ct as TableMetadata, dt as aliasTargetOf, et as FieldMappingStrategy, f as fkColumns, ft as isBucketableField, g as isAtscriptDbView, gt as resolveCalendarBuckets, h as AtscriptDbView, ht as normalizeComputedSelect, it as defaultFulltextIndex, j as geoIndexNotFoundMessage, k as AtscriptDbReadable, lt as isGeoIndexableType, mt as jsonValueAncestor, n as isColumnTypeChanged, nt as numericOperandProblem, ot as searchTermInteger, pt as isJsonValueField, q as guardPaths, rt as INTEGER_REGEX_OP, st as splitFulltextFields, tt as UniquSelect, ut as isGeoPointType, v as AtscriptDbTable, w as ALL_VIEW_CAPABILITIES, x as decomposePatch, y as isVersionExemptPatch, z as canFilterLeaf } from "./column-diff-DAIAq6XR.mjs";
3
+ import { n as ALL_AGGREGATE_FNS } from "./aggregate-fns-B_sgl4mB.mjs";
4
+ import { A as hasRelationOp, C as REL_FILTER_MAX_DEPTH, D as containsRelationFilter, E as andFilters, G as evaluateExpr, H as tableNameOf, K as isFieldRef, P as relationStaticFilter, S as uniqueKeyTuple, T as ResolvedRelationFilter, j as isResolvedRelationFilter, k as forEachResolvedRelation, q as translateQueryTree, w as REL_FILTER_MAX_NODES } from "./nested-writer-BOj_c_lI.mjs";
5
5
  import { i as DB_ENTITY_ANNOTATIONS, n as searchMemberKind } from "./search-fields-DBIZKwyb.mjs";
6
6
  import { a as isPlainObject, i as isEmptyObject, n as findAncestorInSet, o as selfOrAncestor, r as getPath, t as deletePath } from "./object-TkiJQ-Dp.mjs";
7
7
  import { t as DEFAULT_DB_SPACE } from "./consts-C_-5_pFq.mjs";
8
8
  import { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, getDbFieldOp, isDbFieldOp, reconcileCas, separateCas, separateFieldOps } from "./ops.mjs";
9
- import { a as forceNavNonOptional, c as getKeyProps, o as isNavRelation, r as buildValidationContext, s as createDbValidatorPlugin, t as buildDbValidator } from "./validator-BTiIOTKP.mjs";
9
+ import { a as forceNavNonOptional, c as getKeyProps, o as isNavRelation, r as buildValidationContext, s as createDbValidatorPlugin, t as buildDbValidator } from "./validator-BACewoRj.mjs";
10
10
  import { isAnnotatedType } from "@atscript/typescript/utils";
11
11
  import { RELATION_OPS, computeInsights, isPrimitive, isRelationOp, walkFilter } from "@uniqu/core";
12
12
  import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
@@ -203,6 +203,92 @@ async function withOptimisticRetry(table, filter, mutator, opts) {
203
203
  throw new CasExhaustedError(maxAttempts, lastSeenVersion);
204
204
  }
205
205
  //#endregion
206
+ //#region src/query/read-columns.ts
207
+ /** Logical connectives whose operands are sub-filters. */
208
+ const CONNECTIVES = new Set([
209
+ "$and",
210
+ "$or",
211
+ "$nor"
212
+ ]);
213
+ /**
214
+ * Adds every PHYSICAL column a translated filter reads to `out`: comparison
215
+ * keys, and — for a resolved relational predicate (`$some` / `$none`) — the
216
+ * source-side columns it correlates on. Returns `false` when the filter holds
217
+ * a top-level operator this walker does not know (then every column must be
218
+ * assumed read).
219
+ */
220
+ function collectFilter(filter, out) {
221
+ if (!filter || typeof filter !== "object") return true;
222
+ for (const [key, value] of Object.entries(filter)) {
223
+ if (CONNECTIVES.has(key)) {
224
+ if (!Array.isArray(value)) return false;
225
+ for (const child of value) if (!collectFilter(child, out)) return false;
226
+ continue;
227
+ }
228
+ if (key === "$not") {
229
+ if (!collectFilter(value, out)) return false;
230
+ continue;
231
+ }
232
+ if (key.startsWith("$")) return false;
233
+ out.add(key);
234
+ if (value && typeof value === "object" && !Array.isArray(value)) {
235
+ for (const operand of Object.values(value)) if (isResolvedRelationFilter(operand)) {
236
+ for (const pair of operand.pairs) out.add(pair.source);
237
+ for (const pair of operand.junction?.toSource ?? []) out.add(pair.source);
238
+ } else if (operand && typeof operand === "object" && "$field" in operand) {
239
+ const other = operand.$field;
240
+ if (typeof other !== "string") return false;
241
+ out.add(other);
242
+ }
243
+ }
244
+ }
245
+ return true;
246
+ }
247
+ /**
248
+ * The PHYSICAL columns of the queried table (or view) that a read of `kind`
249
+ * renders — filter keys and relational-predicate correlation columns, sort
250
+ * keys, `partitionBy`, the projection, and for an aggregate the group keys,
251
+ * bucket / aggregate / expression / `first`-`last` sources and `$having`
252
+ * keys. Names that are not columns (aggregate aliases) may be included — a
253
+ * consumer ignores names it does not know.
254
+ *
255
+ * `undefined` means EVERY column: the read projects all columns (no
256
+ * `$select`, so `SELECT *`), or its filter holds an operator this collector
257
+ * does not recognise. A view read may drop a left join only when no returned
258
+ * column reads it, so over-inclusion is always safe.
259
+ * @since 0.1.153
260
+ */
261
+ function queryReadColumns(query, kind, partitionBy) {
262
+ const out = /* @__PURE__ */ new Set();
263
+ if (!collectFilter(query.filter, out)) return void 0;
264
+ if (kind === "count") return out;
265
+ const controls = query.controls ?? {};
266
+ for (const key of Object.keys(controls.$sort ?? {})) out.add(key);
267
+ for (const key of Object.keys(controls.$nulls ?? {})) out.add(key);
268
+ for (const column of partitionBy ?? []) out.add(column);
269
+ const select = controls.$select;
270
+ const fields = select?.asArray;
271
+ if (kind === "rows") {
272
+ if (!fields || fields.length === 0) return void 0;
273
+ for (const field of fields) out.add(field);
274
+ return out;
275
+ }
276
+ const groupBy = controls.$groupBy ?? [];
277
+ const computed = select?.computedAliases.length ?? 0;
278
+ if (!fields?.length && !select?.buckets?.length && computed === 0) return;
279
+ for (const field of fields ?? []) out.add(field);
280
+ for (const key of groupBy) out.add(key);
281
+ for (const bucket of select?.buckets ?? []) out.add(bucket.field);
282
+ for (const expr of select?.aggregates ?? []) if (expr.$field !== "*") out.add(expr.$field);
283
+ for (const e of select?.exprAggregates ?? []) for (const name of e.names) out.add(name);
284
+ for (const e of select?.exprs ?? []) for (const name of e.names) out.add(name);
285
+ for (const fl of select?.firstLast ?? []) out.add(fl.column);
286
+ for (const key of select?.rowOrder ?? []) out.add(key.column);
287
+ for (const column of select?.sources.keys() ?? []) out.add(column);
288
+ if (controls.$having && !collectFilter(controls.$having, out)) return void 0;
289
+ return out;
290
+ }
291
+ //#endregion
206
292
  //#region src/table/db-space.ts
207
293
  /**
208
294
  * A `@db.alias` type only names a join scope inside a view definition — it
@@ -474,4 +560,4 @@ function isDbEntityType(value) {
474
560
  return DB_ENTITY_ANNOTATIONS.some((name) => value.metadata.has(name));
475
561
  }
476
562
  //#endregion
477
- export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_VIEW_CAPABILITIES, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, BaseDbAdapter, CasExhaustedError, CasMismatchError, DEFAULT_DB_SPACE, DbEncryption, DbError, DbSpace, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, INTEGER_REGEX_OP, IntegrityStrategy, NativeIntegrity, NoopLogger, RELATION_OPS, REL_FILTER_MAX_DEPTH, REL_FILTER_MAX_NODES, RelationalFieldMapper, ResolvedRelationFilter, TableMetadata, UniquSelect, acceptedOperatorsHint, aggregateExpressionsNotSupported, aggregateFailure, aliasTargetOf, andFilters, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, containsRelationFilter, createDbValidatorPlugin, createFailureCollector, decomposePatch, defaultFulltextIndex, deletePath, describeFulltext, 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, isVersionExemptPatch, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, numericOperandProblem, reconcileCas, relationStaticFilter, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, searchMemberKind, searchTermInteger, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, splitFulltextFields, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
563
+ export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_VIEW_CAPABILITIES, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, BaseDbAdapter, CasExhaustedError, CasMismatchError, DEFAULT_DB_SPACE, DbEncryption, DbError, DbSpace, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, INTEGER_REGEX_OP, IntegrityStrategy, NativeIntegrity, NoopLogger, RELATION_OPS, REL_FILTER_MAX_DEPTH, REL_FILTER_MAX_NODES, RelationalFieldMapper, ResolvedRelationFilter, TableMetadata, UniquSelect, acceptedOperatorsHint, aggregateExpressionsNotSupported, aggregateFailure, aliasTargetOf, andFilters, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, containsRelationFilter, createDbValidatorPlugin, createFailureCollector, decomposePatch, defaultFulltextIndex, deletePath, describeFulltext, 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, isRetryableDbError, isVersionExemptPatch, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, numericOperandProblem, queryReadColumns, reconcileCas, relationStaticFilter, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, searchMemberKind, searchTermInteger, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, splitFulltextFields, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
@@ -1,4 +1,4 @@
1
- import { i as DepthLimitExceededError, r as DbError } from "./db-error-Az85UhTX.mjs";
1
+ import { i as DepthLimitExceededError, r as DbError } from "./db-error-eSsQX7rt.mjs";
2
2
  import { a as isPlainObject, r as getPath } from "./object-TkiJQ-Dp.mjs";
3
3
  import { ValidatorError } from "@atscript/typescript/utils";
4
4
  import { isRelationOp } from "@uniqu/core";
@@ -1,4 +1,4 @@
1
- const require_db_error = require("./db-error-DRQH4sLY.cjs");
1
+ const require_db_error = require("./db-error-JcfJqqpk.cjs");
2
2
  const require_object = require("./object-Djg28csK.cjs");
3
3
  let _atscript_typescript_utils = require("@atscript/typescript/utils");
4
4
  let _uniqu_core = require("@uniqu/core");
package/dist/ops.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_db_error = require("./db-error-DRQH4sLY.cjs");
2
+ const require_db_error = require("./db-error-JcfJqqpk.cjs");
3
3
  //#region src/ops.ts
4
4
  /** Increment a numeric field by `value` (default 1). */
5
5
  function $inc(value = 1) {
package/dist/ops.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { r as DbError } from "./db-error-Az85UhTX.mjs";
1
+ import { r as DbError } from "./db-error-eSsQX7rt.mjs";
2
2
  //#region src/ops.ts
3
3
  /** Increment a numeric field by `value` (default 1). */
4
4
  function $inc(value = 1) {