@atscript/db 0.1.161 → 0.1.162

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 (63) 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-B_sgl4mB.mjs → aggregate-fns-DsS9UQVB.mjs} +1 -1
  6. package/dist/{aggregate-fns-DFtKAv7Q.cjs → aggregate-fns-DupYzFD7.cjs} +1 -1
  7. package/dist/{buckets-8mG67Mtw.d.mts → buckets-DUTcrT4Z.d.mts} +475 -57
  8. package/dist/{buckets-B4T_alUe.d.cts → buckets-_iZV39Z3.d.cts} +475 -57
  9. package/dist/{column-diff-DpeUbhEI.cjs → column-diff-CZsMGQ_w.cjs} +846 -232
  10. package/dist/{column-diff-DR1glykD.mjs → column-diff-pdn53AIj.mjs} +829 -233
  11. package/dist/{validator-B3xlbrWf.d.cts → db-error-B_DRL1E9.d.cts} +18 -89
  12. package/dist/{validator-B3xlbrWf.d.mts → db-error-B_DRL1E9.d.mts} +18 -89
  13. package/dist/{db-error-JcfJqqpk.cjs → db-error-DmF1_xrz.cjs} +13 -0
  14. package/dist/{db-error-eSsQX7rt.mjs → db-error-hraC12B9.mjs} +8 -1
  15. package/dist/{db-validator-plugin-BWy60OvG.d.cts → db-validator-plugin-wRqMYNBI.d.cts} +6 -0
  16. package/dist/{db-validator-plugin-BWy60OvG.d.mts → db-validator-plugin-wRqMYNBI.d.mts} +6 -0
  17. package/dist/{fk-diff-5gX42hBt.d.mts → fk-diff-B5jW68T3.d.cts} +34 -10
  18. package/dist/{fk-diff-BWdQ7kRZ.d.cts → fk-diff-PhVBYohc.d.mts} +34 -10
  19. package/dist/index.cjs +12 -11
  20. package/dist/index.d.cts +24 -21
  21. package/dist/index.d.mts +24 -21
  22. package/dist/index.mjs +9 -12
  23. package/dist/{nested-writer-BOj_c_lI.mjs → nested-writer-ClUX0DB0.mjs} +16 -22
  24. package/dist/{nested-writer-Bl1SZS7x.cjs → nested-writer-yCy6wGuN.cjs} +16 -22
  25. package/dist/{object-CtPYTIvy.d.cts → object-Czia_qD4.d.cts} +7 -1
  26. package/dist/{object-CtPYTIvy.d.mts → object-Czia_qD4.d.mts} +7 -1
  27. package/dist/{object-Djg28csK.cjs → object-GjsuPNqo.cjs} +19 -0
  28. package/dist/{object-TkiJQ-Dp.mjs → object-PQ1J8jri.mjs} +14 -1
  29. package/dist/ops.cjs +6 -21
  30. package/dist/ops.mjs +6 -21
  31. package/dist/plugin.cjs +263 -323
  32. package/dist/plugin.mjs +163 -223
  33. package/dist/rel.cjs +2 -2
  34. package/dist/rel.d.cts +3 -3
  35. package/dist/rel.d.mts +3 -3
  36. package/dist/rel.mjs +2 -2
  37. package/dist/{relation-helpers-17_2f5hX.d.mts → relation-helpers-BAEkP4bH.d.cts} +1 -1
  38. package/dist/{relation-helpers-BLBrLQYi.d.cts → relation-helpers-BSYwxOSA.d.mts} +1 -1
  39. package/dist/{relation-loader-DeulLrAw.cjs → relation-loader-DujL_Mh9.cjs} +1 -1
  40. package/dist/{relation-loader-CNBMPfRr.mjs → relation-loader-Qv3LrQ42.mjs} +1 -1
  41. package/dist/{search-fields-CE8cmj9X.mjs → search-fields-0U0FAFGj.mjs} +47 -1
  42. package/dist/{search-fields-CT_UZ9fg.cjs → search-fields-Bi1n-pB1.cjs} +64 -0
  43. package/dist/search-fields-CHqqcC3W.d.cts +30 -0
  44. package/dist/search-fields-CHqqcC3W.d.mts +30 -0
  45. package/dist/shared.cjs +42 -26
  46. package/dist/shared.d.cts +98 -4
  47. package/dist/shared.d.mts +98 -4
  48. package/dist/shared.mjs +4 -2
  49. package/dist/sync.cjs +228 -65
  50. package/dist/sync.d.cts +41 -5
  51. package/dist/sync.d.mts +41 -5
  52. package/dist/sync.mjs +228 -66
  53. package/dist/validator-BcBtg8yW.d.cts +88 -0
  54. package/dist/validator-BcBtg8yW.d.mts +88 -0
  55. package/dist/{validator-B4YDLUkj.cjs → validator-DK9Ijpo7.cjs} +3 -2
  56. package/dist/{validator-B3fPJjS1.mjs → validator-DuDWsIdQ.mjs} +3 -2
  57. package/dist/validator.cjs +3 -3
  58. package/dist/validator.d.cts +4 -3
  59. package/dist/validator.d.mts +4 -3
  60. package/dist/validator.mjs +3 -3
  61. package/dist/{validation-utils-CtLNlBtB.cjs → view-validation-D50KWU7O.cjs} +452 -18
  62. package/dist/{validation-utils-BGjqc2jU.mjs → view-validation-QbqqXEAM.mjs} +364 -20
  63. package/package.json +6 -6
package/dist/index.d.cts CHANGED
@@ -1,11 +1,13 @@
1
- import { $ as TDbInsertResult, $t as ALL_VIEW_CAPABILITIES, A as TColumnDiff, An as REL_FILTER_MAX_NODES, At as TPrimaryKeyChange, B as TDbDefaultFn, Bn as isResolvedRelationFilter, Bt as TValueFormatterPair, C as NavPropsOf, Cn as IntegrityStrategy, Ct as TIdDescriptor, D as PrimaryKeyOf, Dn as DbResponse, Dt as TJsonCopyTarget, E as OwnPropsOf, En as AtscriptDbReadable, Et as TInsertOptions, F as TDbActionLevel, Fn as TRelationStaticFilter, Ft as TSyncColumnResult, G as TDbIndex, Gn as FieldMappingStrategy, Gt as Uniquery, H as TDbDeleteResult, Hn as DbEncryption, Ht as TWriteOptions, I as TDbActionProcessor, In as andFilters, It as TSyncIndexesOptions, J as TDbInsertIgnoreOptions, Jn as TGenericLogger, Jt as TableMetadata, K as TDbIndexField, Kn as TReadControls, Kt as UniqueryControls, L as TDbActionTargetSummary, Ln as containsRelationFilter, Lt as TTableOptionDiff, M as TCrudPermissions, Mn as TRelGuardState, Mt as TRelationInfo, N as TDbActionInfo, Nn as TRelationFilterJunction, Nt as TRowResolveOptions, O as TCascadeResolver, On as resolveDesignType, Ot as TMetaResponse, P as TDbActionIntent, Pn as TRelationFilterTable, Pt as TSearchIndexInfo, Q as TDbInsertManyResult, Qn as UniquSelect, Qt as ALL_BUCKET_UNITS, R as TDbAvailableActions, Rn as forEachResolvedRelation, Rt as TTableResolver, S as FlatOf, Sn as AtscriptDbTable, St as TFkLookupTarget, T as NullsPlacement, Tn as TCascadePin, Tt as TIdentification, U as TDbFieldMeta, Un as TDbEncryptionOptions, Ut as TWriteTableResolver, V as TDbDefaultValue, Vn as relationStaticFilter, Vt as TViewJsonType, W as TDbForeignKey, Wn as DocumentFieldMapper, Wt as TypedWithRelation, X as TDbInsertIgnoreSlot, Xn as TFirstLast, Xt as isGeoPointType, Y as TDbInsertIgnoreResult, Yn as TExprAggregate, Yt as isGeoIndexableType, Z as TDbInsertManyIgnoreResult, Zn as TRowOrderKey, Zt as TPathPresence, _ as DbPatch, _n as TViewJoin, _t as TExistingColumn, a as isJsonValueField, an as AtscriptDbView, at as TDbStorageType, b as FieldOpsFor, bn as isFieldRef, bt as TFieldMeta, c as resolveCalendarBuckets, cn as isViewType, ct as TDbWriteAction, d as AggregateFn, dn as AtscriptExprNode, dt as TDbWriteGuard, en as BaseDbAdapter, et as TDbObjectKind, f as AggregateQuery, fn as AtscriptOrderItem, ft as TDbWriteGuardContext, g as DbControls, gn as AtscriptRef, gt as TEnsureTableOptions, h as AtscriptDbWritable, hn as AtscriptQueryNode, ht as TDerivedColumn, i as isBucketableField, in as TDbSpaceOptions, it as TDbRemoveGuardContext, j as TCrudOp, jn as ResolvedRelationFilter, jt as TReferencingForeignKey, k as TCascadeTarget, kn as REL_FILTER_MAX_DEPTH, kt as TMetadataOverrides, l as AggregateControls, ln as TViewReadPlan, lt as TDbWriteCheck, mn as AtscriptQueryFieldRef, mt as TDerivedChangeReason, n as TComputedSelect, nn as DbSpace, nt as TDbRelation, o as jsonValueAncestor, on as TViewColumnMapping, ot as TDbUpdateOptions, p as AggregateResult, pn as AtscriptQueryComparison, pt as TDeleteOptions, q as TDbIndexType, qn as NoopLogger, qt as WithRelation, r as TResolvedBucket, rn as TAdapterFactory, rt as TDbRemoveGuard, s as normalizeComputedSelect, sn as isAtscriptDbView, st as TDbUpdateResult, t as TBucketFieldSource, tn as TViewCapability, tt as TDbReferentialAction, u as AggregateExpr, un as aliasTargetOf, ut as TDbWriteCheckContext, v as DbQuery, vn as TViewPlan, vt as TExistingForeignKey, w as NullableOptional, wn as NativeIntegrity, wt as TIdResolveOptions, x as FilterExpr, xn as translateQueryTree, xt as TFkLookupResolver, y as DbRow, yn as evaluateExpr, yt as TExistingTableOption, z as TDbCollation, zn as hasRelationOp, zt as TTouchManyOptions } from "./buckets-B4T_alUe.cjs";
1
+ import { $ as TDbInsertManyIgnoreResult, $n as hasRelationOp, $t as TWriteOptions, A as TCascadeTarget, An as AtscriptRef, At as TForeignKeyChange, B as TDbCollation, Bn as AtscriptDbReadable, Bt as TReadLockOptions, C as NavPropsOf, Cn as TViewReadPlan, Ct as TEnsureTableOptions, D as PrimaryKeyOf, Dn as AtscriptQueryComparison, Dt as TFieldMeta, E as OwnPropsOf, En as AtscriptOrderItem, Et as TExistingTableOption, F as TDbActionIntent, Fn as translateQueryTree, Ft as TInsertOptions, G as TDbFieldMeta, Gn as ResolvedRelationFilter, Gt as TSyncColumnResult, H as TDbDefaultValue, Hn as resolveDesignType, Ht as TRelationInfo, I as TDbActionLevel, In as AtscriptDbTable, It as TJsonCopyTarget, J as TDbIndexField, Jn as TRelationFilterTable, Jt as TTableResolver, K as TDbForeignKey, Kn as TRelGuardState, Kt as TSyncIndexesOptions, L as TDbActionProcessor, Ln as IntegrityStrategy, Lt as TMetaResponse, M as TCrudOp, Mn as TViewPlan, Mt as TIdResolveOptions, N as TCrudPermissions, Nn as evaluateExpr, Nt as TIdentification, O as TBulkWriteOptions, On as AtscriptQueryFieldRef, Ot as TFkLookupResolver, P as TDbActionInfo, Pn as isFieldRef, Pt as TIndexChange, Q as TDbInsertIgnoreSlot, Qn as forEachResolvedRelation, Qt as TViewJsonType, R as TDbActionTargetSummary, Rn as NativeIntegrity, Rt as TMetadataOverrides, S as FlatOf, Sn as isViewType, St as TDerivedColumn, T as NullsPlacement, Tn as AtscriptExprNode, Tt as TExistingForeignKey, U as TDbDeleteManyOptions, Un as REL_FILTER_MAX_DEPTH, Ut as TRowResolveOptions, V as TDbDefaultFn, Vn as DbResponse, Vt as TReferencingForeignKey, W as TDbDeleteResult, Wn as REL_FILTER_MAX_NODES, Wt as TSearchIndexInfo, X as TDbInsertIgnoreOptions, Xn as andFilters, Xt as TTransactionOptions, Y as TDbIndexType, Yn as TRelationStaticFilter, Yt as TTouchManyOptions, Z as TDbInsertIgnoreResult, Zn as containsRelationFilter, Zt as TValueFormatterPair, _ as DbPatch, _n as TAdapterFactory, _t as TDbWriteGuard, a as isJsonValueField, an as TableMetadata, ar as FieldMappingStrategy, at as TDbObjectKind, b as FieldOpsFor, bn as TViewColumnMapping, bt as TDeleteOptions, c as resolveCalendarBuckets, cn as TPathPresence, cr as TGenericLogger, ct as TDbRelation, d as AggregateFn, dn as ALL_VIEW_CAPABILITIES, dr as TRowOrderKey, dt as TDbStorageType, en as TWriteTableResolver, er as isResolvedRelationFilter, et as TDbInsertManyResult, f as AggregateQuery, fn as BaseDbAdapter, fr as UniquSelect, ft as TDbUpdateOptions, g as DbControls, gn as DbSpace, gt as TDbWriteCheckContext, h as AtscriptDbWritable, hn as TViewCapability, ht as TDbWriteCheck, i as isBucketableField, in as WithRelation, ir as DocumentFieldMapper, it as TDbLockWait, j as TColumnDiff, jn as TViewJoin, jt as TIdDescriptor, k as TCascadeResolver, kn as AtscriptQueryNode, kt as TFkLookupTarget, l as AggregateControls, ln as ALL_BUCKET_UNITS, lr as TExprAggregate, lt as TDbRemoveGuard, mn as TIndexDiffOptions, mt as TDbWriteAction, n as TComputedSelect, nn as Uniquery, nr as DbEncryption, nt as TDbIsolationLevel, o as jsonValueAncestor, on as isGeoIndexableType, or as TReadControls, ot as TDbReadLock, p as AggregateResult, pn as TForeignKeyDiffOptions, pt as TDbUpdateResult, q as TDbIndex, qn as TRelationFilterJunction, qt as TTableOptionDiff, r as TResolvedBucket, rn as UniqueryControls, rr as TDbEncryptionOptions, rt as TDbLockMode, s as normalizeComputedSelect, sn as isGeoPointType, sr as NoopLogger, st as TDbReferentialAction, t as TBucketFieldSource, tn as TypedWithRelation, tr as relationStaticFilter, tt as TDbInsertResult, u as AggregateExpr, un as ALL_ISOLATION_LEVELS, ur as TFirstLast, ut as TDbRemoveGuardContext, v as DbQuery, vn as TDbSpaceOptions, vt as TDbWriteGuardContext, w as NullableOptional, wn as aliasTargetOf, wt as TExistingColumn, x as FilterExpr, xn as isAtscriptDbView, xt as TDerivedChangeReason, y as DbRow, yn as AtscriptDbView, yt as TDbWriteLimit, z as TDbAvailableActions, zn as TCascadePin, zt as TPrimaryKeyChange } from "./buckets-_iZV39Z3.cjs";
2
+ import { a as aggregateExpressionsNotSupported, c as isConflict, i as DbErrorCode, l as isRetryableDbError, n as CasMismatchError, o as aggregateFailure, r as DbError, s as bucketTimeZoneUnavailable, t as CasExhaustedError } from "./db-error-B_DRL1E9.cjs";
2
3
  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
- 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 { a as isPlainObject, i as isEmptyObject, n as findAncestorInSet, o as selfOrAncestor, r as getPath, s as stableJson, t as deletePath } from "./object-Czia_qD4.cjs";
4
5
  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, 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
- import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.cjs";
7
- import { r as fkColumns, s as isColumnTypeChanged } from "./fk-diff-BWdQ7kRZ.cjs";
8
- import { i as tableNameOf } from "./relation-helpers-BLBrLQYi.cjs";
6
+ import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-wRqMYNBI.cjs";
7
+ import { a as buildValidationContext, c as isNavRelation, d as getKeyProps, l as TArrayPatch, n as ValidatorMode, r as buildDbValidator, s as forceNavNonOptional, t as ValidationContext, u as TDbPatch } from "./validator-BcBtg8yW.cjs";
8
+ import { i as searchMemberKind, r as TSearchMemberKind } from "./search-fields-CHqqcC3W.cjs";
9
+ import { c as isColumnTypeChanged, i as fkKey, r as fkColumns } from "./fk-diff-B5jW68T3.cjs";
10
+ import { i as tableNameOf } from "./relation-helpers-BAEkP4bH.cjs";
9
11
  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
12
  import { AtscriptExprNode as AtscriptExprNode$1, TAtscriptAnnotatedType } from "@atscript/typescript/utils";
11
13
 
@@ -557,18 +559,6 @@ declare function describeFulltext(index: Pick<TDbIndex, "fields">, textLabel: (n
557
559
  */
558
560
  declare function defaultFulltextIndex<T extends Pick<TDbIndex, "fields">>(indexes: readonly T[]): T | undefined;
559
561
  //#endregion
560
- //#region src/shared/search-fields.d.ts
561
- /** How a field takes part in `$search`: matched as text, or by whole-number equality / decimal text. */
562
- type TSearchMemberKind = "text" | "integer";
563
- /**
564
- * Runtime mirror of the plugin's verdict: how the annotated type takes part
565
- * in `$search`. Structures, arrays, unions and unresolved types keep their
566
- * legacy `"text"` treatment.
567
- */
568
- declare function searchMemberKind(type: TAtscriptAnnotatedType | undefined): TSearchMemberKind | {
569
- problem: string;
570
- };
571
- //#endregion
572
562
  //#region src/query/read-columns.d.ts
573
563
  /**
574
564
  * What a read renders: rows (`findOne` / `findMany` / per-partition pages),
@@ -641,7 +631,7 @@ declare function assertNoVersionWrites(data: Record<string, unknown>, versionCol
641
631
  * Whether a logical (pre-decomposition) patch writes ONLY version-exempt
642
632
  * fields (`@db.column.version.exempt`). `data` has nav fields, filter keys and
643
633
  * derived fields removed and `$cas` separated. Mirrors `flattenPatchPayload`
644
- * (keep the two side by side): PK keys and `@db.onUpdate.now` fields are
634
+ * (keep the two side by side): PK keys and `@db.onUpdate.now` / `.inc` fields are
645
635
  * skipped; an exempt path (or one under an exempt ancestor) is covered
646
636
  * whatever its value (scalar, field op, array ops, object); a non-exempt
647
637
  * merge-strategy object recurses (only the supplied children are written);
@@ -676,9 +666,22 @@ declare function isDbEntityType(value: unknown): value is TAtscriptAnnotatedType
676
666
  * hash, and the next boot retries.
677
667
  */
678
668
  declare function createFailureCollector(what: string): {
679
- attempt: (label: string, op: () => Promise<unknown>) => Promise<void>;
669
+ /** Runs `op`; `true` when it succeeded, `false` when its failure was collected. */attempt: (label: string, op: () => Promise<unknown>) => Promise<boolean>;
680
670
  throwIfAny: () => void;
681
671
  };
672
+ /**
673
+ * Records the changes a sync pass makes — or, in a dry run, would make — so
674
+ * planning and syncing share one code path. `apply(change, label, op)`
675
+ * records `change` straight away in a dry run; otherwise it runs `op` first:
676
+ * through `attempt` when given (a {@link createFailureCollector} collector —
677
+ * a failure is collected and the change not recorded), else directly (a
678
+ * failure throws).
679
+ * @since 0.1.162
680
+ */
681
+ declare function createChangeRecorder<C>(dryRun: boolean, attempt?: (label: string, op: () => Promise<unknown>) => Promise<boolean>): {
682
+ /** The changes recorded so far, in order. */changes: C[];
683
+ apply: (change: C, label: string, op: () => unknown) => Promise<void>;
684
+ };
682
685
  //#endregion
683
686
  //#region src/query/aggregate-expr.d.ts
684
687
  /**
@@ -692,4 +695,4 @@ declare function createFailureCollector(what: string): {
692
695
  */
693
696
  declare function numericOperandProblem(fd: TDbFieldMeta): string | undefined;
694
697
  //#endregion
695
- 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 TJsonCopyTarget, type TMetaResponse, type TMetadataOverrides, type TPathPresence, 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 TSyncIndexesOptions, 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 };
698
+ export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_ISOLATION_LEVELS, 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 TBulkWriteOptions, 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 TDbDeleteManyOptions, 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 TDbIsolationLevel, type TDbLockMode, type TDbLockWait, type TDbObjectKind, type TDbPatch, type TDbReadLock, 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 TDbWriteLimit, 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 TForeignKeyChange, type TForeignKeyDiffOptions, type TGenericLogger, type TGroupSourceVerdict, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TIndexChange, type TIndexDiffOptions, type TInsertOptions, type TJsonCopyTarget, type TMetaResponse, type TMetadataOverrides, type TPathPresence, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReadColumnsKind, type TReadControls, type TReadLockOptions, type TReferencingForeignKey, type TRelationFilterJunction, type TRelationFilterTable, type TRelationInfo, type TRelationStaticFilter, type TResolvedBucket, type TRowOrderKey, type TRowResolveOptions, type TSearchIndexInfo, type TSearchMemberKind, type TSyncColumnResult, type TSyncIndexesOptions, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TTransactionOptions, 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, createChangeRecorder, createDbValidatorPlugin, createFailureCollector, decomposePatch, defaultFulltextIndex, deletePath, describeFulltext, evaluateExpr, findAncestorInSet, fkColumns, fkKey, 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, stableJson, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
package/dist/index.d.mts CHANGED
@@ -1,11 +1,13 @@
1
- import { $ as TDbInsertResult, $t as ALL_VIEW_CAPABILITIES, A as TColumnDiff, An as REL_FILTER_MAX_NODES, At as TPrimaryKeyChange, B as TDbDefaultFn, Bn as isResolvedRelationFilter, Bt as TValueFormatterPair, C as NavPropsOf, Cn as IntegrityStrategy, Ct as TIdDescriptor, D as PrimaryKeyOf, Dn as DbResponse, Dt as TJsonCopyTarget, E as OwnPropsOf, En as AtscriptDbReadable, Et as TInsertOptions, F as TDbActionLevel, Fn as TRelationStaticFilter, Ft as TSyncColumnResult, G as TDbIndex, Gn as FieldMappingStrategy, Gt as Uniquery, H as TDbDeleteResult, Hn as DbEncryption, Ht as TWriteOptions, I as TDbActionProcessor, In as andFilters, It as TSyncIndexesOptions, J as TDbInsertIgnoreOptions, Jn as TGenericLogger, Jt as TableMetadata, K as TDbIndexField, Kn as TReadControls, Kt as UniqueryControls, L as TDbActionTargetSummary, Ln as containsRelationFilter, Lt as TTableOptionDiff, M as TCrudPermissions, Mn as TRelGuardState, Mt as TRelationInfo, N as TDbActionInfo, Nn as TRelationFilterJunction, Nt as TRowResolveOptions, O as TCascadeResolver, On as resolveDesignType, Ot as TMetaResponse, P as TDbActionIntent, Pn as TRelationFilterTable, Pt as TSearchIndexInfo, Q as TDbInsertManyResult, Qn as UniquSelect, Qt as ALL_BUCKET_UNITS, R as TDbAvailableActions, Rn as forEachResolvedRelation, Rt as TTableResolver, S as FlatOf, Sn as AtscriptDbTable, St as TFkLookupTarget, T as NullsPlacement, Tn as TCascadePin, Tt as TIdentification, U as TDbFieldMeta, Un as TDbEncryptionOptions, Ut as TWriteTableResolver, V as TDbDefaultValue, Vn as relationStaticFilter, Vt as TViewJsonType, W as TDbForeignKey, Wn as DocumentFieldMapper, Wt as TypedWithRelation, X as TDbInsertIgnoreSlot, Xn as TFirstLast, Xt as isGeoPointType, Y as TDbInsertIgnoreResult, Yn as TExprAggregate, Yt as isGeoIndexableType, Z as TDbInsertManyIgnoreResult, Zn as TRowOrderKey, Zt as TPathPresence, _ as DbPatch, _n as TViewJoin, _t as TExistingColumn, a as isJsonValueField, an as AtscriptDbView, at as TDbStorageType, b as FieldOpsFor, bn as isFieldRef, bt as TFieldMeta, c as resolveCalendarBuckets, cn as isViewType, ct as TDbWriteAction, d as AggregateFn, dn as AtscriptExprNode, dt as TDbWriteGuard, en as BaseDbAdapter, et as TDbObjectKind, f as AggregateQuery, fn as AtscriptOrderItem, ft as TDbWriteGuardContext, g as DbControls, gn as AtscriptRef, gt as TEnsureTableOptions, h as AtscriptDbWritable, hn as AtscriptQueryNode, ht as TDerivedColumn, i as isBucketableField, in as TDbSpaceOptions, it as TDbRemoveGuardContext, j as TCrudOp, jn as ResolvedRelationFilter, jt as TReferencingForeignKey, k as TCascadeTarget, kn as REL_FILTER_MAX_DEPTH, kt as TMetadataOverrides, l as AggregateControls, ln as TViewReadPlan, lt as TDbWriteCheck, mn as AtscriptQueryFieldRef, mt as TDerivedChangeReason, n as TComputedSelect, nn as DbSpace, nt as TDbRelation, o as jsonValueAncestor, on as TViewColumnMapping, ot as TDbUpdateOptions, p as AggregateResult, pn as AtscriptQueryComparison, pt as TDeleteOptions, q as TDbIndexType, qn as NoopLogger, qt as WithRelation, r as TResolvedBucket, rn as TAdapterFactory, rt as TDbRemoveGuard, s as normalizeComputedSelect, sn as isAtscriptDbView, st as TDbUpdateResult, t as TBucketFieldSource, tn as TViewCapability, tt as TDbReferentialAction, u as AggregateExpr, un as aliasTargetOf, ut as TDbWriteCheckContext, v as DbQuery, vn as TViewPlan, vt as TExistingForeignKey, w as NullableOptional, wn as NativeIntegrity, wt as TIdResolveOptions, x as FilterExpr, xn as translateQueryTree, xt as TFkLookupResolver, y as DbRow, yn as evaluateExpr, yt as TExistingTableOption, z as TDbCollation, zn as hasRelationOp, zt as TTouchManyOptions } from "./buckets-8mG67Mtw.mjs";
1
+ import { $ as TDbInsertManyIgnoreResult, $n as hasRelationOp, $t as TWriteOptions, A as TCascadeTarget, An as AtscriptRef, At as TForeignKeyChange, B as TDbCollation, Bn as AtscriptDbReadable, Bt as TReadLockOptions, C as NavPropsOf, Cn as TViewReadPlan, Ct as TEnsureTableOptions, D as PrimaryKeyOf, Dn as AtscriptQueryComparison, Dt as TFieldMeta, E as OwnPropsOf, En as AtscriptOrderItem, Et as TExistingTableOption, F as TDbActionIntent, Fn as translateQueryTree, Ft as TInsertOptions, G as TDbFieldMeta, Gn as ResolvedRelationFilter, Gt as TSyncColumnResult, H as TDbDefaultValue, Hn as resolveDesignType, Ht as TRelationInfo, I as TDbActionLevel, In as AtscriptDbTable, It as TJsonCopyTarget, J as TDbIndexField, Jn as TRelationFilterTable, Jt as TTableResolver, K as TDbForeignKey, Kn as TRelGuardState, Kt as TSyncIndexesOptions, L as TDbActionProcessor, Ln as IntegrityStrategy, Lt as TMetaResponse, M as TCrudOp, Mn as TViewPlan, Mt as TIdResolveOptions, N as TCrudPermissions, Nn as evaluateExpr, Nt as TIdentification, O as TBulkWriteOptions, On as AtscriptQueryFieldRef, Ot as TFkLookupResolver, P as TDbActionInfo, Pn as isFieldRef, Pt as TIndexChange, Q as TDbInsertIgnoreSlot, Qn as forEachResolvedRelation, Qt as TViewJsonType, R as TDbActionTargetSummary, Rn as NativeIntegrity, Rt as TMetadataOverrides, S as FlatOf, Sn as isViewType, St as TDerivedColumn, T as NullsPlacement, Tn as AtscriptExprNode, Tt as TExistingForeignKey, U as TDbDeleteManyOptions, Un as REL_FILTER_MAX_DEPTH, Ut as TRowResolveOptions, V as TDbDefaultFn, Vn as DbResponse, Vt as TReferencingForeignKey, W as TDbDeleteResult, Wn as REL_FILTER_MAX_NODES, Wt as TSearchIndexInfo, X as TDbInsertIgnoreOptions, Xn as andFilters, Xt as TTransactionOptions, Y as TDbIndexType, Yn as TRelationStaticFilter, Yt as TTouchManyOptions, Z as TDbInsertIgnoreResult, Zn as containsRelationFilter, Zt as TValueFormatterPair, _ as DbPatch, _n as TAdapterFactory, _t as TDbWriteGuard, a as isJsonValueField, an as TableMetadata, ar as FieldMappingStrategy, at as TDbObjectKind, b as FieldOpsFor, bn as TViewColumnMapping, bt as TDeleteOptions, c as resolveCalendarBuckets, cn as TPathPresence, cr as TGenericLogger, ct as TDbRelation, d as AggregateFn, dn as ALL_VIEW_CAPABILITIES, dr as TRowOrderKey, dt as TDbStorageType, en as TWriteTableResolver, er as isResolvedRelationFilter, et as TDbInsertManyResult, f as AggregateQuery, fn as BaseDbAdapter, fr as UniquSelect, ft as TDbUpdateOptions, g as DbControls, gn as DbSpace, gt as TDbWriteCheckContext, h as AtscriptDbWritable, hn as TViewCapability, ht as TDbWriteCheck, i as isBucketableField, in as WithRelation, ir as DocumentFieldMapper, it as TDbLockWait, j as TColumnDiff, jn as TViewJoin, jt as TIdDescriptor, k as TCascadeResolver, kn as AtscriptQueryNode, kt as TFkLookupTarget, l as AggregateControls, ln as ALL_BUCKET_UNITS, lr as TExprAggregate, lt as TDbRemoveGuard, mn as TIndexDiffOptions, mt as TDbWriteAction, n as TComputedSelect, nn as Uniquery, nr as DbEncryption, nt as TDbIsolationLevel, o as jsonValueAncestor, on as isGeoIndexableType, or as TReadControls, ot as TDbReadLock, p as AggregateResult, pn as TForeignKeyDiffOptions, pt as TDbUpdateResult, q as TDbIndex, qn as TRelationFilterJunction, qt as TTableOptionDiff, r as TResolvedBucket, rn as UniqueryControls, rr as TDbEncryptionOptions, rt as TDbLockMode, s as normalizeComputedSelect, sn as isGeoPointType, sr as NoopLogger, st as TDbReferentialAction, t as TBucketFieldSource, tn as TypedWithRelation, tr as relationStaticFilter, tt as TDbInsertResult, u as AggregateExpr, un as ALL_ISOLATION_LEVELS, ur as TFirstLast, ut as TDbRemoveGuardContext, v as DbQuery, vn as TDbSpaceOptions, vt as TDbWriteGuardContext, w as NullableOptional, wn as aliasTargetOf, wt as TExistingColumn, x as FilterExpr, xn as isAtscriptDbView, xt as TDerivedChangeReason, y as DbRow, yn as AtscriptDbView, yt as TDbWriteLimit, z as TDbAvailableActions, zn as TCascadePin, zt as TPrimaryKeyChange } from "./buckets-DUTcrT4Z.mjs";
2
+ import { a as aggregateExpressionsNotSupported, c as isConflict, i as DbErrorCode, l as isRetryableDbError, n as CasMismatchError, o as aggregateFailure, r as DbError, s as bucketTimeZoneUnavailable, t as CasExhaustedError } from "./db-error-B_DRL1E9.mjs";
2
3
  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
- 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 { a as isPlainObject, i as isEmptyObject, n as findAncestorInSet, o as selfOrAncestor, r as getPath, s as stableJson, t as deletePath } from "./object-Czia_qD4.mjs";
4
5
  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, 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
- import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.mjs";
7
- import { r as fkColumns, s as isColumnTypeChanged } from "./fk-diff-5gX42hBt.mjs";
8
- import { i as tableNameOf } from "./relation-helpers-17_2f5hX.mjs";
6
+ import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-wRqMYNBI.mjs";
7
+ import { a as buildValidationContext, c as isNavRelation, d as getKeyProps, l as TArrayPatch, n as ValidatorMode, r as buildDbValidator, s as forceNavNonOptional, t as ValidationContext, u as TDbPatch } from "./validator-BcBtg8yW.mjs";
8
+ import { i as searchMemberKind, r as TSearchMemberKind } from "./search-fields-CHqqcC3W.mjs";
9
+ import { c as isColumnTypeChanged, i as fkKey, r as fkColumns } from "./fk-diff-PhVBYohc.mjs";
10
+ import { i as tableNameOf } from "./relation-helpers-BSYwxOSA.mjs";
9
11
  import { AtscriptExprNode as AtscriptExprNode$1, TAtscriptAnnotatedType } from "@atscript/typescript/utils";
10
12
  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
13
 
@@ -557,18 +559,6 @@ declare function describeFulltext(index: Pick<TDbIndex, "fields">, textLabel: (n
557
559
  */
558
560
  declare function defaultFulltextIndex<T extends Pick<TDbIndex, "fields">>(indexes: readonly T[]): T | undefined;
559
561
  //#endregion
560
- //#region src/shared/search-fields.d.ts
561
- /** How a field takes part in `$search`: matched as text, or by whole-number equality / decimal text. */
562
- type TSearchMemberKind = "text" | "integer";
563
- /**
564
- * Runtime mirror of the plugin's verdict: how the annotated type takes part
565
- * in `$search`. Structures, arrays, unions and unresolved types keep their
566
- * legacy `"text"` treatment.
567
- */
568
- declare function searchMemberKind(type: TAtscriptAnnotatedType | undefined): TSearchMemberKind | {
569
- problem: string;
570
- };
571
- //#endregion
572
562
  //#region src/query/read-columns.d.ts
573
563
  /**
574
564
  * What a read renders: rows (`findOne` / `findMany` / per-partition pages),
@@ -641,7 +631,7 @@ declare function assertNoVersionWrites(data: Record<string, unknown>, versionCol
641
631
  * Whether a logical (pre-decomposition) patch writes ONLY version-exempt
642
632
  * fields (`@db.column.version.exempt`). `data` has nav fields, filter keys and
643
633
  * derived fields removed and `$cas` separated. Mirrors `flattenPatchPayload`
644
- * (keep the two side by side): PK keys and `@db.onUpdate.now` fields are
634
+ * (keep the two side by side): PK keys and `@db.onUpdate.now` / `.inc` fields are
645
635
  * skipped; an exempt path (or one under an exempt ancestor) is covered
646
636
  * whatever its value (scalar, field op, array ops, object); a non-exempt
647
637
  * merge-strategy object recurses (only the supplied children are written);
@@ -676,9 +666,22 @@ declare function isDbEntityType(value: unknown): value is TAtscriptAnnotatedType
676
666
  * hash, and the next boot retries.
677
667
  */
678
668
  declare function createFailureCollector(what: string): {
679
- attempt: (label: string, op: () => Promise<unknown>) => Promise<void>;
669
+ /** Runs `op`; `true` when it succeeded, `false` when its failure was collected. */attempt: (label: string, op: () => Promise<unknown>) => Promise<boolean>;
680
670
  throwIfAny: () => void;
681
671
  };
672
+ /**
673
+ * Records the changes a sync pass makes — or, in a dry run, would make — so
674
+ * planning and syncing share one code path. `apply(change, label, op)`
675
+ * records `change` straight away in a dry run; otherwise it runs `op` first:
676
+ * through `attempt` when given (a {@link createFailureCollector} collector —
677
+ * a failure is collected and the change not recorded), else directly (a
678
+ * failure throws).
679
+ * @since 0.1.162
680
+ */
681
+ declare function createChangeRecorder<C>(dryRun: boolean, attempt?: (label: string, op: () => Promise<unknown>) => Promise<boolean>): {
682
+ /** The changes recorded so far, in order. */changes: C[];
683
+ apply: (change: C, label: string, op: () => unknown) => Promise<void>;
684
+ };
682
685
  //#endregion
683
686
  //#region src/query/aggregate-expr.d.ts
684
687
  /**
@@ -692,4 +695,4 @@ declare function createFailureCollector(what: string): {
692
695
  */
693
696
  declare function numericOperandProblem(fd: TDbFieldMeta): string | undefined;
694
697
  //#endregion
695
- 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 TJsonCopyTarget, type TMetaResponse, type TMetadataOverrides, type TPathPresence, 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 TSyncIndexesOptions, 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 };
698
+ export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_ISOLATION_LEVELS, 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 TBulkWriteOptions, 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 TDbDeleteManyOptions, 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 TDbIsolationLevel, type TDbLockMode, type TDbLockWait, type TDbObjectKind, type TDbPatch, type TDbReadLock, 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 TDbWriteLimit, 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 TForeignKeyChange, type TForeignKeyDiffOptions, type TGenericLogger, type TGroupSourceVerdict, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TIndexChange, type TIndexDiffOptions, type TInsertOptions, type TJsonCopyTarget, type TMetaResponse, type TMetadataOverrides, type TPathPresence, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReadColumnsKind, type TReadControls, type TReadLockOptions, type TReferencingForeignKey, type TRelationFilterJunction, type TRelationFilterTable, type TRelationInfo, type TRelationStaticFilter, type TResolvedBucket, type TRowOrderKey, type TRowResolveOptions, type TSearchIndexInfo, type TSearchMemberKind, type TSyncColumnResult, type TSyncIndexesOptions, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TTransactionOptions, 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, createChangeRecorder, createDbValidatorPlugin, createFailureCollector, decomposePatch, defaultFulltextIndex, deletePath, describeFulltext, evaluateExpr, findAncestorInSet, fkColumns, fkKey, 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, stableJson, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
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 RelationalFieldMapper, A as AtscriptDbReadable, B as canFilterLeaf, C as ApplicationIntegrity, D as createFailureCollector, E as BaseDbAdapter, F as ADAPTER_FILTER_REASON, G as guardAggregate, H as classifyQueryPath, I as ENCRYPTED_REASON, J as guardPaths, K as guardFilter, L as acceptedOperatorsHint, M as geoIndexNotFoundMessage, N as searchIndexNotFoundMessage, O as IntegrityStrategy, P as vectorIndexNotFoundMessage, Q as unsupportedOperatorMessage, R as assertGeoPoint, S as decomposePatch, T as ALL_VIEW_CAPABILITIES, U as collectQueryPaths, V as checkHavingKeys, W as groupSourceVerdict, X as narrowerFilterOps, Y as guardQuery, Z as sortFieldNames, _ as isAtscriptDbView, _t as normalizeComputedSelect, at as defaultFulltextIndex, b as isVersionExemptPatch, ct as splitFulltextFields, dt as isGeoPointType, et as DocumentFieldMapper, g as AtscriptDbView, gt as jsonValueAncestor, ht as isJsonValueField, it as INTEGER_REGEX_OP, j as resolveDesignType, k as NativeIntegrity, lt as TableMetadata, mt as isBucketableField, n as isColumnTypeChanged, nt as UniquSelect, ot as describeFulltext, p as fkColumns, pt as aliasTargetOf, q as guardPath, rt as numericOperandProblem, st as searchTermInteger, tt as FieldMappingStrategy, ut as isGeoIndexableType, v as isViewType, vt as resolveCalendarBuckets, w as ALL_BUCKET_UNITS, x as assertNoVersionWrites, y as AtscriptDbTable, yt as NoopLogger, z as bucketSourceVerdict } from "./column-diff-DR1glykD.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
- import { a as forceNavNonOptional, c as getKeyProps, o as isNavRelation, r as buildValidationContext, s as createDbValidatorPlugin, t as buildDbValidator } from "./validator-B3fPJjS1.mjs";
6
- import { i as DB_ENTITY_ANNOTATIONS, n as searchMemberKind } from "./search-fields-CE8cmj9X.mjs";
7
- import { a as isPlainObject, i as isEmptyObject, n as findAncestorInSet, o as selfOrAncestor, r as getPath, t as deletePath } from "./object-TkiJQ-Dp.mjs";
1
+ import { a as aggregateExpressionsNotSupported, c as invalidQuery, d as spaceClosedError, l as isConflict, n as CasMismatchError, o as aggregateFailure, r as DbError, s as bucketTimeZoneUnavailable, t as CasExhaustedError, u as isRetryableDbError } from "./db-error-hraC12B9.mjs";
2
+ import { $ as narrowerFilterOps, B as acceptedOperatorsHint, C as ALL_VIEW_CAPABILITIES, E as createFailureCollector, F as geoIndexNotFoundMessage, G as classifyQueryPath, H as bucketSourceVerdict, I as searchIndexNotFoundMessage, J as guardAggregate, K as collectQueryPaths, L as vectorIndexNotFoundMessage, M as NativeIntegrity, N as AtscriptDbReadable, O as fkColumns, P as resolveDesignType, Q as guardQuery, R as ADAPTER_FILTER_REASON, S as ALL_ISOLATION_LEVELS, St as NoopLogger, T as createChangeRecorder, U as canFilterLeaf, V as assertGeoPoint, W as checkHavingKeys, X as guardPath, Y as guardFilter, Z as guardPaths, _ as isVersionExemptPatch, _t as isBucketableField, at as UniquSelect, b as ApplicationIntegrity, bt as normalizeComputedSelect, ct as defaultFulltextIndex, dt as splitFulltextFields, et as sortFieldNames, ft as TableMetadata, g as AtscriptDbTable, gt as aliasTargetOf, h as isViewType, it as FieldMappingStrategy, j as IntegrityStrategy, k as fkKey, lt as describeFulltext, m as isAtscriptDbView, mt as isGeoPointType, n as isColumnTypeChanged, nt as RelationalFieldMapper, ot as numericOperandProblem, p as AtscriptDbView, pt as isGeoIndexableType, q as groupSourceVerdict, rt as DocumentFieldMapper, st as INTEGER_REGEX_OP, tt as unsupportedOperatorMessage, ut as searchTermInteger, v as assertNoVersionWrites, vt as isJsonValueField, w as BaseDbAdapter, x as ALL_BUCKET_UNITS, xt as resolveCalendarBuckets, y as decomposePatch, yt as jsonValueAncestor, z as ENCRYPTED_REASON } from "./column-diff-pdn53AIj.mjs";
3
+ import { n as ALL_AGGREGATE_FNS } from "./aggregate-fns-DsS9UQVB.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-ClUX0DB0.mjs";
5
+ import { a as forceNavNonOptional, c as getKeyProps, o as isNavRelation, r as buildValidationContext, s as createDbValidatorPlugin, t as buildDbValidator } from "./validator-DuDWsIdQ.mjs";
6
+ import { a as searchMemberKind, s as DB_ENTITY_ANNOTATIONS } from "./search-fields-0U0FAFGj.mjs";
7
+ import { a as isPlainObject, i as isEmptyObject, n as findAncestorInSet, o as selfOrAncestor, r as getPath, s as stableJson, t as deletePath } from "./object-PQ1J8jri.mjs";
8
8
  import { t as DEFAULT_DB_SPACE } from "./consts-C_-5_pFq.mjs";
9
9
  import { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, getDbFieldOp, isDbFieldOp, reconcileCas, separateCas, separateFieldOps } from "./ops.mjs";
10
10
  import { isAnnotatedType } from "@atscript/typescript/utils";
@@ -174,10 +174,7 @@ var DbEncryption = class {
174
174
  */
175
175
  async function withOptimisticRetry(table, filter, mutator, opts) {
176
176
  const versionColumn = table.versionColumn;
177
- if (versionColumn === void 0) throw new DbError("INVALID_QUERY", [{
178
- path: "$cas",
179
- message: `withOptimisticRetry: table "${table.tableName}" has no @db.column.version column — CAS cannot be applied`
180
- }]);
177
+ if (versionColumn === void 0) throw invalidQuery("$cas", `withOptimisticRetry: table "${table.tableName}" has no @db.column.version column — CAS cannot be applied`);
181
178
  const maxAttempts = opts?.maxAttempts ?? 5;
182
179
  let lastSeenVersion;
183
180
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
@@ -560,4 +557,4 @@ function isDbEntityType(value) {
560
557
  return DB_ENTITY_ANNOTATIONS.some((name) => value.metadata.has(name));
561
558
  }
562
559
  //#endregion
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 };
560
+ export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_ISOLATION_LEVELS, 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, createChangeRecorder, createDbValidatorPlugin, createFailureCollector, decomposePatch, defaultFulltextIndex, deletePath, describeFulltext, evaluateExpr, findAncestorInSet, fkColumns, fkKey, 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, stableJson, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
@@ -1,5 +1,5 @@
1
- import { i as DepthLimitExceededError, r as DbError } from "./db-error-eSsQX7rt.mjs";
2
- import { a as isPlainObject, r as getPath } from "./object-TkiJQ-Dp.mjs";
1
+ import { c as invalidQuery, i as DepthLimitExceededError, r as DbError } from "./db-error-hraC12B9.mjs";
2
+ import { a as isPlainObject, r as getPath } from "./object-PQ1J8jri.mjs";
3
3
  import { ValidatorError } from "@atscript/typescript/utils";
4
4
  import { isRelationOp } from "@uniqu/core";
5
5
  //#region src/query/query-tree.ts
@@ -351,12 +351,6 @@ function relGuardState(write = false) {
351
351
  path: ""
352
352
  };
353
353
  }
354
- function invalid(path, message) {
355
- return new DbError("INVALID_QUERY", [{
356
- path,
357
- message
358
- }]);
359
- }
360
354
  function notSupported(path, message) {
361
355
  return new DbError("REL_FILTER_NOT_SUPPORTED", [{
362
356
  path,
@@ -395,7 +389,7 @@ function relationStaticFilter(relation, name = "") {
395
389
  const type = ref.type?.();
396
390
  if (!type || type === targetType || tableNameOf(type) === targetName) return "target";
397
391
  if (junctionType && (type === junctionType || tableNameOf(type) === junctionName)) return "junction";
398
- throw invalid(name, `@db.rel.filter on "${name}" references a type other than the related type` + (junctionType ? " and the junction" : "") + " — only those can be referenced");
392
+ throw invalidQuery(name, `@db.rel.filter on "${name}" references a type other than the related type` + (junctionType ? " and the junction" : "") + " — only those can be referenced");
399
393
  };
400
394
  const target = [];
401
395
  const junction = [];
@@ -403,7 +397,7 @@ function relationStaticFilter(relation, name = "") {
403
397
  for (const conjunct of conjuncts) {
404
398
  const sides = /* @__PURE__ */ new Set();
405
399
  collectSides(conjunct, (ref) => sides.add(sideOf(ref)), name);
406
- if (sides.size > 1) throw invalid(name, `@db.rel.filter on "${name}" has a condition reading both the junction and the related type — split it into separate "and" conditions`);
400
+ if (sides.size > 1) throw invalidQuery(name, `@db.rel.filter on "${name}" has a condition reading both the junction and the related type — split it into separate "and" conditions`);
407
401
  const filter = translateQueryTree(conjunct, (ref) => ref.field);
408
402
  (sides.has("junction") ? junction : target).push(filter);
409
403
  }
@@ -428,7 +422,7 @@ function collectSides(node, visit, name) {
428
422
  return;
429
423
  }
430
424
  visit(node.left);
431
- if (isFieldRef(node.right)) throw invalid(name, `@db.rel.filter on "${name}" compares two fields — only field-to-value conditions are supported`);
425
+ if (isFieldRef(node.right)) throw invalidQuery(name, `@db.rel.filter on "${name}" compares two fields — only field-to-value conditions are supported`);
432
426
  }
433
427
  function zip(left, right, a, b) {
434
428
  return left.map((value, i) => ({
@@ -452,14 +446,14 @@ function createRelationFilterHost(owner, resolve) {
452
446
  if (cached) return cached;
453
447
  const meta = owner.getMetadata();
454
448
  const relation = meta.relations.get(nav);
455
- if (!relation) throw invalid(path, `"$some" / "$none" are only valid on a navigation relation — "${nav}" is not one`);
449
+ if (!relation) throw invalidQuery(path, `"$some" / "$none" are only valid on a navigation relation — "${nav}" is not one`);
456
450
  const target = resolve(relation.targetType());
457
451
  if (!target) throw notSupported(path, `Relational predicate on "${path}": the related table is not available`);
458
452
  sameAdapter(target, path, "related");
459
453
  let plan;
460
454
  if (relation.direction === "to") {
461
455
  const fk = findFKEntryForRelation(relation, meta.foreignKeys);
462
- if (!fk) throw invalid(path, `Relation "${nav}" has no foreign key to filter by`);
456
+ if (!fk) throw invalidQuery(path, `Relation "${nav}" has no foreign key to filter by`);
463
457
  plan = {
464
458
  kind: "to",
465
459
  relation,
@@ -468,7 +462,7 @@ function createRelationFilterHost(owner, resolve) {
468
462
  };
469
463
  } else if (relation.direction === "from") {
470
464
  const fk = findRemoteFK(target.getMetadata(), owner.tableName, relation.alias);
471
- if (!fk) throw invalid(path, `Relation "${nav}" has no foreign key to filter by`);
465
+ if (!fk) throw invalidQuery(path, `Relation "${nav}" has no foreign key to filter by`);
472
466
  plan = {
473
467
  kind: "from",
474
468
  relation,
@@ -483,8 +477,8 @@ function createRelationFilterHost(owner, resolve) {
483
477
  const junctionMeta = junction.getMetadata();
484
478
  const fkToThis = findRemoteFK(junctionMeta, owner.tableName);
485
479
  const fkToTarget = findRemoteFK(junctionMeta, tableNameOf(relation.targetType()));
486
- if (!fkToThis || !fkToTarget) throw invalid(path, `Relation "${nav}" has no junction foreign keys to filter by`);
487
- if (fkToThis === fkToTarget) throw invalid(path, `Relation "${nav}" is a self-referencing many-to-many — relational predicates cannot tell its two junction keys apart`);
480
+ if (!fkToThis || !fkToTarget) throw invalidQuery(path, `Relation "${nav}" has no junction foreign keys to filter by`);
481
+ if (fkToThis === fkToTarget) throw invalidQuery(path, `Relation "${nav}" is a self-referencing many-to-many — relational predicates cannot tell its two junction keys apart`);
488
482
  plan = {
489
483
  kind: "via",
490
484
  relation,
@@ -512,9 +506,9 @@ function createRelationFilterHost(owner, resolve) {
512
506
  guard(nav, op, inner, state) {
513
507
  const path = state.path ? `${state.path}.${nav}` : nav;
514
508
  const depth = state.depth + 1;
515
- if (depth > 4) throw invalid("", `Relational predicates nest at most 4 levels deep`);
516
- if (++state.counter.nodes > 16) throw invalid("", `At most 16 relational predicates per query`);
517
- if (!isPlainObject(inner)) throw invalid(path, `"${op}" on "${path}" expects a filter object`);
509
+ if (depth > 4) throw invalidQuery("", `Relational predicates nest at most 4 levels deep`);
510
+ if (++state.counter.nodes > 16) throw invalidQuery("", `At most 16 relational predicates per query`);
511
+ if (!isPlainObject(inner)) throw invalidQuery(path, `"${op}" on "${path}" expects a filter object`);
518
512
  const plan = planOf(nav, path);
519
513
  relationStaticFilter(plan.relation, path);
520
514
  try {
@@ -528,7 +522,7 @@ function createRelationFilterHost(owner, resolve) {
528
522
  }
529
523
  },
530
524
  resolve(nav, _op, inner, depth) {
531
- if (depth > 4) throw invalid("", `Relational predicates nest at most 4 levels deep`);
525
+ if (depth > 4) throw invalidQuery("", `Relational predicates nest at most 4 levels deep`);
532
526
  const plan = planOf(nav, nav);
533
527
  const ownerMeta = owner.getMetadata();
534
528
  const targetMeta = plan.target.getMetadata();
@@ -616,12 +610,12 @@ function resolveRelationFilterTree(filter, meta, depth) {
616
610
  function resolvePredicateMap(key, value, meta, depth) {
617
611
  const host = meta.relationFilters;
618
612
  if (!host) {
619
- if (!meta.navFields.has(key)) throw invalid(key, `"$some" / "$none" are only valid on a navigation relation — "${key}" is not one`);
613
+ if (!meta.navFields.has(key)) throw invalidQuery(key, `"$some" / "$none" are only valid on a navigation relation — "${key}" is not one`);
620
614
  throw notSupported(key, `Relational predicate on "${key}" needs the table to come from a DbSpace (no table resolver)`);
621
615
  }
622
616
  const ops = {};
623
617
  for (const [op, operand] of Object.entries(value)) {
624
- if (!isRelationOp(op)) throw invalid(key, `Cannot mix "$some" / "$none" with "${op}" on "${key}"`);
618
+ if (!isRelationOp(op)) throw invalidQuery(key, `Cannot mix "$some" / "$none" with "${op}" on "${key}"`);
625
619
  ops[op] = isResolvedRelationFilter(operand) ? operand : host.resolve(key, op, operand, depth + 1);
626
620
  }
627
621
  return ops;
@@ -1,5 +1,5 @@
1
- const require_db_error = require("./db-error-JcfJqqpk.cjs");
2
- const require_object = require("./object-Djg28csK.cjs");
1
+ const require_db_error = require("./db-error-DmF1_xrz.cjs");
2
+ const require_object = require("./object-GjsuPNqo.cjs");
3
3
  let _atscript_typescript_utils = require("@atscript/typescript/utils");
4
4
  let _uniqu_core = require("@uniqu/core");
5
5
  //#region src/query/query-tree.ts
@@ -351,12 +351,6 @@ function relGuardState(write = false) {
351
351
  path: ""
352
352
  };
353
353
  }
354
- function invalid(path, message) {
355
- return new require_db_error.DbError("INVALID_QUERY", [{
356
- path,
357
- message
358
- }]);
359
- }
360
354
  function notSupported(path, message) {
361
355
  return new require_db_error.DbError("REL_FILTER_NOT_SUPPORTED", [{
362
356
  path,
@@ -395,7 +389,7 @@ function relationStaticFilter(relation, name = "") {
395
389
  const type = ref.type?.();
396
390
  if (!type || type === targetType || tableNameOf(type) === targetName) return "target";
397
391
  if (junctionType && (type === junctionType || tableNameOf(type) === junctionName)) return "junction";
398
- throw invalid(name, `@db.rel.filter on "${name}" references a type other than the related type` + (junctionType ? " and the junction" : "") + " — only those can be referenced");
392
+ throw require_db_error.invalidQuery(name, `@db.rel.filter on "${name}" references a type other than the related type` + (junctionType ? " and the junction" : "") + " — only those can be referenced");
399
393
  };
400
394
  const target = [];
401
395
  const junction = [];
@@ -403,7 +397,7 @@ function relationStaticFilter(relation, name = "") {
403
397
  for (const conjunct of conjuncts) {
404
398
  const sides = /* @__PURE__ */ new Set();
405
399
  collectSides(conjunct, (ref) => sides.add(sideOf(ref)), name);
406
- if (sides.size > 1) throw invalid(name, `@db.rel.filter on "${name}" has a condition reading both the junction and the related type — split it into separate "and" conditions`);
400
+ if (sides.size > 1) throw require_db_error.invalidQuery(name, `@db.rel.filter on "${name}" has a condition reading both the junction and the related type — split it into separate "and" conditions`);
407
401
  const filter = translateQueryTree(conjunct, (ref) => ref.field);
408
402
  (sides.has("junction") ? junction : target).push(filter);
409
403
  }
@@ -428,7 +422,7 @@ function collectSides(node, visit, name) {
428
422
  return;
429
423
  }
430
424
  visit(node.left);
431
- if (isFieldRef(node.right)) throw invalid(name, `@db.rel.filter on "${name}" compares two fields — only field-to-value conditions are supported`);
425
+ if (isFieldRef(node.right)) throw require_db_error.invalidQuery(name, `@db.rel.filter on "${name}" compares two fields — only field-to-value conditions are supported`);
432
426
  }
433
427
  function zip(left, right, a, b) {
434
428
  return left.map((value, i) => ({
@@ -452,14 +446,14 @@ function createRelationFilterHost(owner, resolve) {
452
446
  if (cached) return cached;
453
447
  const meta = owner.getMetadata();
454
448
  const relation = meta.relations.get(nav);
455
- if (!relation) throw invalid(path, `"$some" / "$none" are only valid on a navigation relation — "${nav}" is not one`);
449
+ if (!relation) throw require_db_error.invalidQuery(path, `"$some" / "$none" are only valid on a navigation relation — "${nav}" is not one`);
456
450
  const target = resolve(relation.targetType());
457
451
  if (!target) throw notSupported(path, `Relational predicate on "${path}": the related table is not available`);
458
452
  sameAdapter(target, path, "related");
459
453
  let plan;
460
454
  if (relation.direction === "to") {
461
455
  const fk = findFKEntryForRelation(relation, meta.foreignKeys);
462
- if (!fk) throw invalid(path, `Relation "${nav}" has no foreign key to filter by`);
456
+ if (!fk) throw require_db_error.invalidQuery(path, `Relation "${nav}" has no foreign key to filter by`);
463
457
  plan = {
464
458
  kind: "to",
465
459
  relation,
@@ -468,7 +462,7 @@ function createRelationFilterHost(owner, resolve) {
468
462
  };
469
463
  } else if (relation.direction === "from") {
470
464
  const fk = findRemoteFK(target.getMetadata(), owner.tableName, relation.alias);
471
- if (!fk) throw invalid(path, `Relation "${nav}" has no foreign key to filter by`);
465
+ if (!fk) throw require_db_error.invalidQuery(path, `Relation "${nav}" has no foreign key to filter by`);
472
466
  plan = {
473
467
  kind: "from",
474
468
  relation,
@@ -483,8 +477,8 @@ function createRelationFilterHost(owner, resolve) {
483
477
  const junctionMeta = junction.getMetadata();
484
478
  const fkToThis = findRemoteFK(junctionMeta, owner.tableName);
485
479
  const fkToTarget = findRemoteFK(junctionMeta, tableNameOf(relation.targetType()));
486
- if (!fkToThis || !fkToTarget) throw invalid(path, `Relation "${nav}" has no junction foreign keys to filter by`);
487
- if (fkToThis === fkToTarget) throw invalid(path, `Relation "${nav}" is a self-referencing many-to-many — relational predicates cannot tell its two junction keys apart`);
480
+ if (!fkToThis || !fkToTarget) throw require_db_error.invalidQuery(path, `Relation "${nav}" has no junction foreign keys to filter by`);
481
+ if (fkToThis === fkToTarget) throw require_db_error.invalidQuery(path, `Relation "${nav}" is a self-referencing many-to-many — relational predicates cannot tell its two junction keys apart`);
488
482
  plan = {
489
483
  kind: "via",
490
484
  relation,
@@ -512,9 +506,9 @@ function createRelationFilterHost(owner, resolve) {
512
506
  guard(nav, op, inner, state) {
513
507
  const path = state.path ? `${state.path}.${nav}` : nav;
514
508
  const depth = state.depth + 1;
515
- if (depth > 4) throw invalid("", `Relational predicates nest at most 4 levels deep`);
516
- if (++state.counter.nodes > 16) throw invalid("", `At most 16 relational predicates per query`);
517
- if (!require_object.isPlainObject(inner)) throw invalid(path, `"${op}" on "${path}" expects a filter object`);
509
+ if (depth > 4) throw require_db_error.invalidQuery("", `Relational predicates nest at most 4 levels deep`);
510
+ if (++state.counter.nodes > 16) throw require_db_error.invalidQuery("", `At most 16 relational predicates per query`);
511
+ if (!require_object.isPlainObject(inner)) throw require_db_error.invalidQuery(path, `"${op}" on "${path}" expects a filter object`);
518
512
  const plan = planOf(nav, path);
519
513
  relationStaticFilter(plan.relation, path);
520
514
  try {
@@ -528,7 +522,7 @@ function createRelationFilterHost(owner, resolve) {
528
522
  }
529
523
  },
530
524
  resolve(nav, _op, inner, depth) {
531
- if (depth > 4) throw invalid("", `Relational predicates nest at most 4 levels deep`);
525
+ if (depth > 4) throw require_db_error.invalidQuery("", `Relational predicates nest at most 4 levels deep`);
532
526
  const plan = planOf(nav, nav);
533
527
  const ownerMeta = owner.getMetadata();
534
528
  const targetMeta = plan.target.getMetadata();
@@ -616,12 +610,12 @@ function resolveRelationFilterTree(filter, meta, depth) {
616
610
  function resolvePredicateMap(key, value, meta, depth) {
617
611
  const host = meta.relationFilters;
618
612
  if (!host) {
619
- if (!meta.navFields.has(key)) throw invalid(key, `"$some" / "$none" are only valid on a navigation relation — "${key}" is not one`);
613
+ if (!meta.navFields.has(key)) throw require_db_error.invalidQuery(key, `"$some" / "$none" are only valid on a navigation relation — "${key}" is not one`);
620
614
  throw notSupported(key, `Relational predicate on "${key}" needs the table to come from a DbSpace (no table resolver)`);
621
615
  }
622
616
  const ops = {};
623
617
  for (const [op, operand] of Object.entries(value)) {
624
- if (!(0, _uniqu_core.isRelationOp)(op)) throw invalid(key, `Cannot mix "$some" / "$none" with "${op}" on "${key}"`);
618
+ if (!(0, _uniqu_core.isRelationOp)(op)) throw require_db_error.invalidQuery(key, `Cannot mix "$some" / "$none" with "${op}" on "${key}"`);
625
619
  ops[op] = isResolvedRelationFilter(operand) ? operand : host.resolve(key, op, operand, depth + 1);
626
620
  }
627
621
  return ops;
@@ -28,5 +28,11 @@ declare function getPath(row: Record<string, unknown>, path: string | readonly s
28
28
  * @since 0.1.141
29
29
  */
30
30
  declare function deletePath(target: Record<string, unknown>, path: string | readonly string[]): void;
31
+ /**
32
+ * `JSON.stringify` with object keys sorted at every level — one string per
33
+ * JSON value, whatever its key order (`{"b":1,"a":2}` = `{"a":2,"b":1}`).
34
+ * @since 0.1.162
35
+ */
36
+ declare function stableJson(value: unknown): string;
31
37
  //#endregion
32
- export { isPlainObject as a, isEmptyObject as i, findAncestorInSet as n, selfOrAncestor as o, getPath as r, deletePath as t };
38
+ export { isPlainObject as a, isEmptyObject as i, findAncestorInSet as n, selfOrAncestor as o, getPath as r, stableJson as s, deletePath as t };
@@ -28,5 +28,11 @@ declare function getPath(row: Record<string, unknown>, path: string | readonly s
28
28
  * @since 0.1.141
29
29
  */
30
30
  declare function deletePath(target: Record<string, unknown>, path: string | readonly string[]): void;
31
+ /**
32
+ * `JSON.stringify` with object keys sorted at every level — one string per
33
+ * JSON value, whatever its key order (`{"b":1,"a":2}` = `{"a":2,"b":1}`).
34
+ * @since 0.1.162
35
+ */
36
+ declare function stableJson(value: unknown): string;
31
37
  //#endregion
32
- export { isPlainObject as a, isEmptyObject as i, findAncestorInSet as n, selfOrAncestor as o, getPath as r, deletePath as t };
38
+ export { isPlainObject as a, isEmptyObject as i, findAncestorInSet as n, selfOrAncestor as o, getPath as r, stableJson as s, deletePath as t };
@@ -62,6 +62,19 @@ function deletePath(target, path) {
62
62
  }
63
63
  if (current !== null && typeof current === "object" && !Array.isArray(current)) delete current[segments[segments.length - 1]];
64
64
  }
65
+ /**
66
+ * `JSON.stringify` with object keys sorted at every level — one string per
67
+ * JSON value, whatever its key order (`{"b":1,"a":2}` = `{"a":2,"b":1}`).
68
+ * @since 0.1.162
69
+ */
70
+ function stableJson(value) {
71
+ return JSON.stringify(value, (_key, v) => {
72
+ if (v === null || typeof v !== "object" || Array.isArray(v)) return v;
73
+ const sorted = {};
74
+ for (const k of Object.keys(v).toSorted()) sorted[k] = v[k];
75
+ return sorted;
76
+ });
77
+ }
65
78
  //#endregion
66
79
  Object.defineProperty(exports, "deletePath", {
67
80
  enumerable: true,
@@ -99,3 +112,9 @@ Object.defineProperty(exports, "selfOrAncestor", {
99
112
  return selfOrAncestor;
100
113
  }
101
114
  });
115
+ Object.defineProperty(exports, "stableJson", {
116
+ enumerable: true,
117
+ get: function() {
118
+ return stableJson;
119
+ }
120
+ });