@atscript/db 0.1.135 → 0.1.136
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agg-DKuf_v2L.d.cts → agg-CV7y8nC6.d.cts} +13 -3
- package/dist/{agg-BtlGeRfj.d.mts → agg-D5DHsAby.d.mts} +13 -3
- package/dist/agg.cjs +35 -3
- package/dist/agg.d.cts +2 -2
- package/dist/agg.d.mts +2 -2
- package/dist/agg.mjs +34 -1
- package/dist/aggregate-fns-CGBv3E8S.cjs +87 -0
- package/dist/aggregate-fns-CfsveE1w.mjs +58 -0
- package/dist/{buckets-D6PBXKRJ.d.cts → buckets-kKY0RKYN.d.cts} +60 -17
- package/dist/{buckets-GruoVxH5.d.mts → buckets-y4EzoX7D.d.mts} +60 -17
- package/dist/{db-space-9CH5neN7.d.mts → db-space-BX4K3vb6.d.mts} +126 -7
- package/dist/{db-space-BdtBNTeH.d.cts → db-space-ClG41vJh.d.cts} +126 -7
- package/dist/{db-view-Dm7MpUGB.cjs → db-view-BAzhEUxB.cjs} +391 -92
- package/dist/{db-view-Doh8vPg3.mjs → db-view-BrAtbaOx.mjs} +385 -92
- package/dist/index.cjs +17 -3
- package/dist/index.d.cts +12 -10
- package/dist/index.d.mts +12 -10
- package/dist/index.mjs +14 -4
- package/dist/{nested-writer-wk1EFUNY.cjs → nested-writer-BZNCuqI6.cjs} +16 -2
- package/dist/{nested-writer-CqL24ojl.mjs → nested-writer-FWD5oOYh.mjs} +11 -3
- package/dist/plugin.cjs +215 -75
- package/dist/plugin.mjs +215 -76
- package/dist/rel.cjs +2 -2
- package/dist/rel.d.cts +2 -20
- package/dist/rel.d.mts +2 -20
- package/dist/rel.mjs +2 -2
- package/dist/relation-helpers-BVjQflL_.d.cts +30 -0
- package/dist/relation-helpers-D4haLo1n.d.mts +30 -0
- package/dist/{relation-loader-BD4xANQJ.cjs → relation-loader-6ZB_5KFq.cjs} +1 -1
- package/dist/{relation-loader-B68R1LET.mjs → relation-loader-CTFaZpVa.mjs} +1 -1
- package/dist/shared.cjs +5 -1
- package/dist/shared.d.cts +16 -3
- package/dist/shared.d.mts +16 -3
- package/dist/shared.mjs +2 -2
- package/dist/sync.cjs +37 -10
- package/dist/sync.d.cts +24 -4
- package/dist/sync.d.mts +24 -4
- package/dist/sync.mjs +37 -10
- package/dist/{validation-utils-MWOP1Ts4.mjs → validation-utils-B4h-GW4d.mjs} +29 -7
- package/dist/{validation-utils-B7SXPkm7.cjs → validation-utils-Dg0hW6dn.cjs} +52 -6
- package/dist/{validator-CewfnGZj.d.mts → validator-Drb2N-YL.d.cts} +1 -1
- package/dist/{validator-CewfnGZj.d.cts → validator-Drb2N-YL.d.mts} +1 -1
- package/dist/validator.d.cts +1 -1
- package/dist/validator.d.mts +1 -1
- package/package.json +1 -1
- package/dist/agg-CvXDGnKi.mjs +0 -61
- package/dist/agg-EcIbAFnJ.cjs +0 -78
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_db_error = require("./db-error-DTkkeu5b.cjs");
|
|
3
|
-
const require_db_view = require("./db-view-
|
|
3
|
+
const require_db_view = require("./db-view-BAzhEUxB.cjs");
|
|
4
|
+
const require_aggregate_fns = require("./aggregate-fns-CGBv3E8S.cjs");
|
|
5
|
+
const require_nested_writer = require("./nested-writer-BZNCuqI6.cjs");
|
|
4
6
|
const require_validator = require("./validator-BtZbcLN2.cjs");
|
|
5
7
|
const require_consts = require("./consts-BzRfCcH2.cjs");
|
|
6
8
|
const require_ops = require("./ops.cjs");
|
|
@@ -355,6 +357,14 @@ var DbSpace = class {
|
|
|
355
357
|
//#endregion
|
|
356
358
|
//#region src/query/query-tree.ts
|
|
357
359
|
/**
|
|
360
|
+
* `true` when a query-tree operand is a field reference (`{ field, type? }`)
|
|
361
|
+
* rather than a literal — e.g. the right side of a field-to-field comparison.
|
|
362
|
+
* @since 0.1.136
|
|
363
|
+
*/
|
|
364
|
+
function isFieldRef(value) {
|
|
365
|
+
return value !== null && typeof value === "object" && "field" in value;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
358
368
|
* Translates a JS-emitted query tree into a FilterExpr.
|
|
359
369
|
* Resolves field references (type + field path) to physical column names
|
|
360
370
|
* via the provided resolver function.
|
|
@@ -365,11 +375,11 @@ function translateQueryTree(node, resolveField) {
|
|
|
365
375
|
if ("$not" in node) return { $not: translateQueryTree(node.$not, resolveField) };
|
|
366
376
|
const comp = node;
|
|
367
377
|
const leftField = resolveField(comp.left);
|
|
368
|
-
if (comp.right
|
|
378
|
+
if (isFieldRef(comp.right)) {
|
|
369
379
|
const rightField = resolveField(comp.right);
|
|
370
380
|
return { [leftField]: { [comp.op]: { $field: rightField } } };
|
|
371
381
|
}
|
|
372
|
-
if (comp.op === "$exists") return { [leftField]: { $exists:
|
|
382
|
+
if (comp.op === "$exists") return { [leftField]: { $exists: comp.right !== false } };
|
|
373
383
|
return { [leftField]: { [comp.op]: comp.right } };
|
|
374
384
|
}
|
|
375
385
|
//#endregion
|
|
@@ -383,6 +393,7 @@ exports.$replace = require_ops.$replace;
|
|
|
383
393
|
exports.$update = require_ops.$update;
|
|
384
394
|
exports.$upsert = require_ops.$upsert;
|
|
385
395
|
exports.ADAPTER_FILTER_REASON = require_db_view.ADAPTER_FILTER_REASON;
|
|
396
|
+
exports.ALL_AGGREGATE_FNS = require_aggregate_fns.ALL_AGGREGATE_FNS;
|
|
386
397
|
exports.ALL_BUCKET_UNITS = require_db_view.ALL_BUCKET_UNITS;
|
|
387
398
|
exports.ApplicationIntegrity = require_db_view.ApplicationIntegrity;
|
|
388
399
|
exports.AtscriptDbReadable = require_db_view.AtscriptDbReadable;
|
|
@@ -437,6 +448,7 @@ exports.isAtscriptDbView = require_db_view.isAtscriptDbView;
|
|
|
437
448
|
exports.isBucketableField = require_db_view.isBucketableField;
|
|
438
449
|
exports.isDbFieldOp = require_ops.isDbFieldOp;
|
|
439
450
|
exports.isEmptyObject = require_validator.isEmptyObject;
|
|
451
|
+
exports.isFieldRef = isFieldRef;
|
|
440
452
|
exports.isGeoIndexableType = require_db_view.isGeoIndexableType;
|
|
441
453
|
exports.isGeoPointType = require_db_view.isGeoPointType;
|
|
442
454
|
exports.isJsonValueField = require_db_view.isJsonValueField;
|
|
@@ -450,12 +462,14 @@ Object.defineProperty(exports, "isPrimitive", {
|
|
|
450
462
|
});
|
|
451
463
|
exports.jsonValueAncestor = require_db_view.jsonValueAncestor;
|
|
452
464
|
exports.narrowerFilterOps = require_db_view.narrowerFilterOps;
|
|
465
|
+
exports.normalizeComputedSelect = require_db_view.normalizeComputedSelect;
|
|
453
466
|
exports.reconcileCas = require_ops.reconcileCas;
|
|
454
467
|
exports.resolveCalendarBuckets = require_db_view.resolveCalendarBuckets;
|
|
455
468
|
exports.resolveDesignType = require_db_view.resolveDesignType;
|
|
456
469
|
exports.separateCas = require_ops.separateCas;
|
|
457
470
|
exports.separateFieldOps = require_ops.separateFieldOps;
|
|
458
471
|
exports.sortFieldNames = require_db_view.sortFieldNames;
|
|
472
|
+
exports.tableNameOf = require_nested_writer.tableNameOf;
|
|
459
473
|
exports.translateQueryTree = translateQueryTree;
|
|
460
474
|
exports.unsupportedOperatorMessage = require_db_view.unsupportedOperatorMessage;
|
|
461
475
|
Object.defineProperty(exports, "walkFilter", {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as TDbWriteGuard, A as TDbActionInfo, At as findAncestorInSet, B as TDbIndex, Bt as DocumentFieldMapper, C as OwnPropsOf, Ct as TWriteOptions, D as TColumnDiff, Dt as UniqueryControls, E as TCascadeTarget, Et as Uniquery, F as TDbDefaultFn, Ft as AtscriptDbReadable, G as TDbObjectKind, H as TDbIndexType, Ht as NoopLogger, I as TDbDefaultValue, It as DbResponse, J as TDbRemoveGuard, K as TDbReferentialAction, L as TDbDeleteResult, Lt as resolveDesignType, M as TDbActionLevel, Mt as isGeoPointType, N as TDbActionProcessor, Nt as ALL_BUCKET_UNITS, O as TCrudOp, Ot as WithRelation, P as TDbCollation, Pt as BaseDbAdapter, Q as TDbWriteAction, R as TDbFieldMeta, Rt as DbEncryption, S as NullableOptional, St as TValueFormatterPair, T as TCascadeResolver, Tt as TypedWithRelation, U as TDbInsertManyResult, Ut as TGenericLogger, V as TDbIndexField, Vt as FieldMappingStrategy, W as TDbInsertResult, Wt as UniquSelect, X as TDbStorageType, Y as TDbRemoveGuardContext, Z as TDbUpdateResult, _ as DbRow, _t as TSearchIndexInfo, a as jsonValueAncestor, at as TExistingTableOption, b as FlatOf, bt as TTableResolver, c as AggregateControls, ct as TFkLookupTarget, d as AggregateQuery, dt as TIdentification, et as TDbWriteGuardContext, f as AggregateResult, ft as TMetaResponse, g as DbQuery, gt as TRelationInfo, h as DbPatch, ht as TReferencingForeignKey, i as isJsonValueField, it as TExistingForeignKey, j as TDbActionIntent, jt as isGeoIndexableType, k as TCrudPermissions, kt as TableMetadata, l as AggregateExpr, lt as TIdDescriptor, m as DbControls, mt as TPrimaryKeyChange, n as TResolvedBucket, nt as TEnsureTableOptions, o as normalizeComputedSelect, ot as TFieldMeta, p as AtscriptDbWritable, pt as TMetadataOverrides, q as TDbRelation, r as isBucketableField, rt as TExistingColumn, s as resolveCalendarBuckets, st as TFkLookupResolver, t as TBucketFieldSource, tt as TDeleteOptions, u as AggregateFn, ut as TIdResolveOptions, v as FieldOpsFor, vt as TSyncColumnResult, w as PrimaryKeyOf, wt as TWriteTableResolver, x as NavPropsOf, xt as TTouchManyOptions, y as FilterExpr, yt as TTableOptionDiff, z as TDbForeignKey, zt as TDbEncryptionOptions } from "./buckets-kKY0RKYN.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
|
-
import { c as CalendarBucketLabel, d as WeekStart, l as ComputedExpr, o as BucketExpr, s as BucketUnit, u as ResolvedBucket } from "./agg-
|
|
4
|
-
import { a as TViewColumnMapping, c as
|
|
5
|
-
import { _ as DbErrorCode, a as buildValidationContext, c as isNavRelation, d as TArrayPatch, f as TDbPatch, g as DbError, h as CasMismatchError, l as isEmptyObject, m as CasExhaustedError, n as ValidatorMode, p as getKeyProps, r as buildDbValidator, s as forceNavNonOptional, t as ValidationContext, u as isPlainObject, v as bucketTimeZoneUnavailable } from "./validator-
|
|
3
|
+
import { c as CalendarBucketLabel, d as WeekStart, g as ALL_AGGREGATE_FNS, l as ComputedExpr, o as BucketExpr, s as BucketUnit, u as ResolvedBucket } from "./agg-CV7y8nC6.cjs";
|
|
4
|
+
import { _ as IntegrityStrategy, a as TViewColumnMapping, c as AtscriptQueryComparison, d as AtscriptRef, f as TViewJoin, g as AtscriptDbTable, h as translateQueryTree, i as AtscriptDbView, l as AtscriptQueryFieldRef, m as isFieldRef, n as TAdapterFactory, o as TViewJsonType, p as TViewPlan, r as TDbSpaceOptions, s as isAtscriptDbView, t as DbSpace, u as AtscriptQueryNode, v as NativeIntegrity } from "./db-space-ClG41vJh.cjs";
|
|
5
|
+
import { _ as DbErrorCode, a as buildValidationContext, c as isNavRelation, d as TArrayPatch, f as TDbPatch, g as DbError, h as CasMismatchError, l as isEmptyObject, m as CasExhaustedError, n as ValidatorMode, p as getKeyProps, r as buildDbValidator, s as forceNavNonOptional, t as ValidationContext, u as isPlainObject, v as bucketTimeZoneUnavailable } from "./validator-Drb2N-YL.cjs";
|
|
6
6
|
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.cjs";
|
|
7
|
+
import { i as tableNameOf } from "./relation-helpers-BVjQflL_.cjs";
|
|
7
8
|
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, ResolvedBucket as ResolvedBucket$1, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
8
9
|
|
|
9
10
|
//#region src/shared/consts.d.ts
|
|
@@ -105,7 +106,7 @@ declare class ApplicationIntegrity extends IntegrityStrategy {
|
|
|
105
106
|
* - `$exists` with a non-boolean operand → `INVALID_QUERY`
|
|
106
107
|
* - malformed `$select` computed entries / `$groupBy` entries, calendar
|
|
107
108
|
* buckets outside grouped queries or with a bad unit / zone / alias →
|
|
108
|
-
* `INVALID_QUERY` (the shared normalizer, `
|
|
109
|
+
* `INVALID_QUERY` (the shared normalizer, `normalizeComputedSelect`)
|
|
109
110
|
* - a calendar bucket over a field that is not a bucket source
|
|
110
111
|
* (`bucketSourceVerdict`) → `INVALID_QUERY`, or `BUCKET_NOT_SUPPORTED`
|
|
111
112
|
* when the adapter has no calendar buckets at all; a unit the adapter's
|
|
@@ -283,7 +284,7 @@ interface TQueryPathRefs {
|
|
|
283
284
|
* `$sort` / `$having`; a bucket alias is also dropped from `groupBy`, which
|
|
284
285
|
* lists grouped fields only.
|
|
285
286
|
*
|
|
286
|
-
* Entry shapes are not checked here — see `
|
|
287
|
+
* Entry shapes are not checked here — see `normalizeComputedSelect`.
|
|
287
288
|
*/
|
|
288
289
|
declare function collectQueryPaths(query: TGuardedQuery, aggregate?: boolean): TQueryPathRefs;
|
|
289
290
|
/** What a logical path is on THIS readable / adapter (since 0.1.128). */
|
|
@@ -346,7 +347,7 @@ declare function guardPath(meta: TableMetadata, adapter: BaseDbAdapter, path: st
|
|
|
346
347
|
* {@link guardPath}). Adapters may therefore assume every path they receive
|
|
347
348
|
* is physical.
|
|
348
349
|
*
|
|
349
|
-
* Entry shapes are the caller's to normalize first (`
|
|
350
|
+
* Entry shapes are the caller's to normalize first (`normalizeComputedSelect`
|
|
350
351
|
* — {@link guardQuery} / {@link guardAggregate} do).
|
|
351
352
|
*
|
|
352
353
|
* In aggregate mode (`aggregate = true`) `$select` computed entries have
|
|
@@ -380,13 +381,14 @@ declare function checkHavingKeys(refs: TQueryPathRefs): {
|
|
|
380
381
|
} | undefined;
|
|
381
382
|
/**
|
|
382
383
|
* Aggregate-path guard: $groupBy / $select / $having encryption refs + filter
|
|
383
|
-
* + $sort, then the path guard, then the adapter's
|
|
384
|
+
* + $sort, then the path guard, then the adapter's aggregate functions
|
|
385
|
+
* (`AGG_FN_NOT_SUPPORTED`) and calendar-bucket units
|
|
384
386
|
* (`BUCKET_NOT_SUPPORTED`), then the `$having` key rule
|
|
385
387
|
* ({@link checkHavingKeys} — after the path guard so an unknown key still
|
|
386
388
|
* reads `Unknown field`).
|
|
387
389
|
*
|
|
388
390
|
* `buckets` are the query's resolved calendar buckets when the caller already
|
|
389
|
-
* ran `
|
|
391
|
+
* ran `normalizeComputedSelect` (resolved here otherwise).
|
|
390
392
|
*/
|
|
391
393
|
declare function guardAggregate(meta: TableMetadata, adapter: BaseDbAdapter, query: AggregateQuery$1, resolved?: readonly ResolvedBucket$1[]): void;
|
|
392
394
|
//#endregion
|
|
@@ -487,4 +489,4 @@ declare function createFailureCollector(what: string): {
|
|
|
487
489
|
throwIfAny: () => void;
|
|
488
490
|
};
|
|
489
491
|
//#endregion
|
|
490
|
-
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_BUCKET_UNITS, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type BucketExpr, type BucketUnit, type CalendarBucketLabel, CasExhaustedError, CasMismatchError, type ComputedExpr, DEFAULT_DB_SPACE, type DbControls, DbEncryption, DbError, type DbErrorCode, type DbPatch, type DbQuery, type DbResponse, type DbRow, DbSpace, type DbValidationContext, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, type FlatOf, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type OwnPropsOf, type PrimaryKeyOf, RelationalFieldMapper, type ResolvedBucket, type TAdapterFactory, type TArrayPatch, type TBucketFieldSource, type TBucketSourceTable, type TBucketSourceVerdict, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateResult, type TDbWriteAction, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TMetaResponse, type TMetadataOverrides, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReferencingForeignKey, type TRelationInfo, type TResolvedBucket, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, 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, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, findAncestorInSet, forceNavNonOptional, getDbFieldOp, getKeyProps, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isDbFieldOp, isEmptyObject, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, jsonValueAncestor, narrowerFilterOps, reconcileCas, resolveCalendarBuckets, resolveDesignType, separateCas, separateFieldOps, sortFieldNames, translateQueryTree, unsupportedOperatorMessage, walkFilter, withOptimisticRetry };
|
|
492
|
+
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type BucketExpr, type BucketUnit, type CalendarBucketLabel, CasExhaustedError, CasMismatchError, type ComputedExpr, DEFAULT_DB_SPACE, type DbControls, DbEncryption, DbError, type DbErrorCode, type DbPatch, type DbQuery, type DbResponse, type DbRow, DbSpace, type DbValidationContext, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, type FlatOf, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type OwnPropsOf, type PrimaryKeyOf, RelationalFieldMapper, type ResolvedBucket, type TAdapterFactory, type TArrayPatch, type TBucketFieldSource, type TBucketSourceTable, type TBucketSourceVerdict, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateResult, type TDbWriteAction, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TMetaResponse, type TMetadataOverrides, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReferencingForeignKey, type TRelationInfo, type TResolvedBucket, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, findAncestorInSet, forceNavNonOptional, getDbFieldOp, getKeyProps, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, reconcileCas, resolveCalendarBuckets, resolveDesignType, separateCas, separateFieldOps, sortFieldNames, tableNameOf, translateQueryTree, unsupportedOperatorMessage, walkFilter, withOptimisticRetry };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as TDbWriteGuard, A as TDbActionInfo, At as findAncestorInSet, B as TDbIndex, Bt as DocumentFieldMapper, C as OwnPropsOf, Ct as TWriteOptions, D as TColumnDiff, Dt as UniqueryControls, E as TCascadeTarget, Et as Uniquery, F as TDbDefaultFn, Ft as AtscriptDbReadable, G as TDbObjectKind, H as TDbIndexType, Ht as NoopLogger, I as TDbDefaultValue, It as DbResponse, J as TDbRemoveGuard, K as TDbReferentialAction, L as TDbDeleteResult, Lt as resolveDesignType, M as TDbActionLevel, Mt as isGeoPointType, N as TDbActionProcessor, Nt as ALL_BUCKET_UNITS, O as TCrudOp, Ot as WithRelation, P as TDbCollation, Pt as BaseDbAdapter, Q as TDbWriteAction, R as TDbFieldMeta, Rt as DbEncryption, S as NullableOptional, St as TValueFormatterPair, T as TCascadeResolver, Tt as TypedWithRelation, U as TDbInsertManyResult, Ut as TGenericLogger, V as TDbIndexField, Vt as FieldMappingStrategy, W as TDbInsertResult, Wt as UniquSelect, X as TDbStorageType, Y as TDbRemoveGuardContext, Z as TDbUpdateResult, _ as DbRow, _t as TSearchIndexInfo, a as jsonValueAncestor, at as TExistingTableOption, b as FlatOf, bt as TTableResolver, c as AggregateControls, ct as TFkLookupTarget, d as AggregateQuery, dt as TIdentification, et as TDbWriteGuardContext, f as AggregateResult, ft as TMetaResponse, g as DbQuery, gt as TRelationInfo, h as DbPatch, ht as TReferencingForeignKey, i as isJsonValueField, it as TExistingForeignKey, j as TDbActionIntent, jt as isGeoIndexableType, k as TCrudPermissions, kt as TableMetadata, l as AggregateExpr, lt as TIdDescriptor, m as DbControls, mt as TPrimaryKeyChange, n as TResolvedBucket, nt as TEnsureTableOptions, o as normalizeComputedSelect, ot as TFieldMeta, p as AtscriptDbWritable, pt as TMetadataOverrides, q as TDbRelation, r as isBucketableField, rt as TExistingColumn, s as resolveCalendarBuckets, st as TFkLookupResolver, t as TBucketFieldSource, tt as TDeleteOptions, u as AggregateFn, ut as TIdResolveOptions, v as FieldOpsFor, vt as TSyncColumnResult, w as PrimaryKeyOf, wt as TWriteTableResolver, x as NavPropsOf, xt as TTouchManyOptions, y as FilterExpr, yt as TTableOptionDiff, z as TDbForeignKey, zt as TDbEncryptionOptions } from "./buckets-y4EzoX7D.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
|
-
import { c as CalendarBucketLabel, d as WeekStart, l as ComputedExpr, o as BucketExpr, s as BucketUnit, u as ResolvedBucket } from "./agg-
|
|
4
|
-
import { a as TViewColumnMapping, c as
|
|
5
|
-
import { _ as DbErrorCode, a as buildValidationContext, c as isNavRelation, d as TArrayPatch, f as TDbPatch, g as DbError, h as CasMismatchError, l as isEmptyObject, m as CasExhaustedError, n as ValidatorMode, p as getKeyProps, r as buildDbValidator, s as forceNavNonOptional, t as ValidationContext, u as isPlainObject, v as bucketTimeZoneUnavailable } from "./validator-
|
|
3
|
+
import { c as CalendarBucketLabel, d as WeekStart, g as ALL_AGGREGATE_FNS, l as ComputedExpr, o as BucketExpr, s as BucketUnit, u as ResolvedBucket } from "./agg-D5DHsAby.mjs";
|
|
4
|
+
import { _ as IntegrityStrategy, a as TViewColumnMapping, c as AtscriptQueryComparison, d as AtscriptRef, f as TViewJoin, g as AtscriptDbTable, h as translateQueryTree, i as AtscriptDbView, l as AtscriptQueryFieldRef, m as isFieldRef, n as TAdapterFactory, o as TViewJsonType, p as TViewPlan, r as TDbSpaceOptions, s as isAtscriptDbView, t as DbSpace, u as AtscriptQueryNode, v as NativeIntegrity } from "./db-space-BX4K3vb6.mjs";
|
|
5
|
+
import { _ as DbErrorCode, a as buildValidationContext, c as isNavRelation, d as TArrayPatch, f as TDbPatch, g as DbError, h as CasMismatchError, l as isEmptyObject, m as CasExhaustedError, n as ValidatorMode, p as getKeyProps, r as buildDbValidator, s as forceNavNonOptional, t as ValidationContext, u as isPlainObject, v as bucketTimeZoneUnavailable } from "./validator-Drb2N-YL.mjs";
|
|
6
6
|
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.mjs";
|
|
7
|
+
import { i as tableNameOf } from "./relation-helpers-D4haLo1n.mjs";
|
|
7
8
|
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, ResolvedBucket as ResolvedBucket$1, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
8
9
|
|
|
9
10
|
//#region src/shared/consts.d.ts
|
|
@@ -105,7 +106,7 @@ declare class ApplicationIntegrity extends IntegrityStrategy {
|
|
|
105
106
|
* - `$exists` with a non-boolean operand → `INVALID_QUERY`
|
|
106
107
|
* - malformed `$select` computed entries / `$groupBy` entries, calendar
|
|
107
108
|
* buckets outside grouped queries or with a bad unit / zone / alias →
|
|
108
|
-
* `INVALID_QUERY` (the shared normalizer, `
|
|
109
|
+
* `INVALID_QUERY` (the shared normalizer, `normalizeComputedSelect`)
|
|
109
110
|
* - a calendar bucket over a field that is not a bucket source
|
|
110
111
|
* (`bucketSourceVerdict`) → `INVALID_QUERY`, or `BUCKET_NOT_SUPPORTED`
|
|
111
112
|
* when the adapter has no calendar buckets at all; a unit the adapter's
|
|
@@ -283,7 +284,7 @@ interface TQueryPathRefs {
|
|
|
283
284
|
* `$sort` / `$having`; a bucket alias is also dropped from `groupBy`, which
|
|
284
285
|
* lists grouped fields only.
|
|
285
286
|
*
|
|
286
|
-
* Entry shapes are not checked here — see `
|
|
287
|
+
* Entry shapes are not checked here — see `normalizeComputedSelect`.
|
|
287
288
|
*/
|
|
288
289
|
declare function collectQueryPaths(query: TGuardedQuery, aggregate?: boolean): TQueryPathRefs;
|
|
289
290
|
/** What a logical path is on THIS readable / adapter (since 0.1.128). */
|
|
@@ -346,7 +347,7 @@ declare function guardPath(meta: TableMetadata, adapter: BaseDbAdapter, path: st
|
|
|
346
347
|
* {@link guardPath}). Adapters may therefore assume every path they receive
|
|
347
348
|
* is physical.
|
|
348
349
|
*
|
|
349
|
-
* Entry shapes are the caller's to normalize first (`
|
|
350
|
+
* Entry shapes are the caller's to normalize first (`normalizeComputedSelect`
|
|
350
351
|
* — {@link guardQuery} / {@link guardAggregate} do).
|
|
351
352
|
*
|
|
352
353
|
* In aggregate mode (`aggregate = true`) `$select` computed entries have
|
|
@@ -380,13 +381,14 @@ declare function checkHavingKeys(refs: TQueryPathRefs): {
|
|
|
380
381
|
} | undefined;
|
|
381
382
|
/**
|
|
382
383
|
* Aggregate-path guard: $groupBy / $select / $having encryption refs + filter
|
|
383
|
-
* + $sort, then the path guard, then the adapter's
|
|
384
|
+
* + $sort, then the path guard, then the adapter's aggregate functions
|
|
385
|
+
* (`AGG_FN_NOT_SUPPORTED`) and calendar-bucket units
|
|
384
386
|
* (`BUCKET_NOT_SUPPORTED`), then the `$having` key rule
|
|
385
387
|
* ({@link checkHavingKeys} — after the path guard so an unknown key still
|
|
386
388
|
* reads `Unknown field`).
|
|
387
389
|
*
|
|
388
390
|
* `buckets` are the query's resolved calendar buckets when the caller already
|
|
389
|
-
* ran `
|
|
391
|
+
* ran `normalizeComputedSelect` (resolved here otherwise).
|
|
390
392
|
*/
|
|
391
393
|
declare function guardAggregate(meta: TableMetadata, adapter: BaseDbAdapter, query: AggregateQuery$1, resolved?: readonly ResolvedBucket$1[]): void;
|
|
392
394
|
//#endregion
|
|
@@ -487,4 +489,4 @@ declare function createFailureCollector(what: string): {
|
|
|
487
489
|
throwIfAny: () => void;
|
|
488
490
|
};
|
|
489
491
|
//#endregion
|
|
490
|
-
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_BUCKET_UNITS, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type BucketExpr, type BucketUnit, type CalendarBucketLabel, CasExhaustedError, CasMismatchError, type ComputedExpr, DEFAULT_DB_SPACE, type DbControls, DbEncryption, DbError, type DbErrorCode, type DbPatch, type DbQuery, type DbResponse, type DbRow, DbSpace, type DbValidationContext, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, type FlatOf, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type OwnPropsOf, type PrimaryKeyOf, RelationalFieldMapper, type ResolvedBucket, type TAdapterFactory, type TArrayPatch, type TBucketFieldSource, type TBucketSourceTable, type TBucketSourceVerdict, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateResult, type TDbWriteAction, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TMetaResponse, type TMetadataOverrides, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReferencingForeignKey, type TRelationInfo, type TResolvedBucket, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, 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, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, findAncestorInSet, forceNavNonOptional, getDbFieldOp, getKeyProps, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isDbFieldOp, isEmptyObject, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, jsonValueAncestor, narrowerFilterOps, reconcileCas, resolveCalendarBuckets, resolveDesignType, separateCas, separateFieldOps, sortFieldNames, translateQueryTree, unsupportedOperatorMessage, walkFilter, withOptimisticRetry };
|
|
492
|
+
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type BucketExpr, type BucketUnit, type CalendarBucketLabel, CasExhaustedError, CasMismatchError, type ComputedExpr, DEFAULT_DB_SPACE, type DbControls, DbEncryption, DbError, type DbErrorCode, type DbPatch, type DbQuery, type DbResponse, type DbRow, DbSpace, type DbValidationContext, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, type FlatOf, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type OwnPropsOf, type PrimaryKeyOf, RelationalFieldMapper, type ResolvedBucket, type TAdapterFactory, type TArrayPatch, type TBucketFieldSource, type TBucketSourceTable, type TBucketSourceVerdict, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateResult, type TDbWriteAction, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TMetaResponse, type TMetadataOverrides, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReferencingForeignKey, type TRelationInfo, type TResolvedBucket, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, findAncestorInSet, forceNavNonOptional, getDbFieldOp, getKeyProps, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, reconcileCas, resolveCalendarBuckets, resolveDesignType, separateCas, separateFieldOps, sortFieldNames, tableNameOf, translateQueryTree, unsupportedOperatorMessage, walkFilter, withOptimisticRetry };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { a as bucketTimeZoneUnavailable, n as CasMismatchError, r as DbError, t as CasExhaustedError } from "./db-error-D5uilS_A.mjs";
|
|
2
|
-
import { A as unsupportedOperatorMessage, B as isJsonValueField, C as guardAggregate, D as guardQuery, E as guardPaths, F as TableMetadata, H as
|
|
2
|
+
import { A as unsupportedOperatorMessage, B as isJsonValueField, C as guardAggregate, D as guardQuery, E as guardPaths, F as TableMetadata, H as normalizeComputedSelect, I as findAncestorInSet, L as isGeoIndexableType, M as DocumentFieldMapper, N as FieldMappingStrategy, O as narrowerFilterOps, P as UniquSelect, R as isGeoPointType, S as collectQueryPaths, T as guardPath, U as resolveCalendarBuckets, V as jsonValueAncestor, W as NoopLogger, _ as assertGeoPoint, a as decomposePatch, b as checkHavingKeys, c as BaseDbAdapter, d as NativeIntegrity, f as AtscriptDbReadable, g as acceptedOperatorsHint, h as ENCRYPTED_REASON, i as assertNoVersionWrites, j as RelationalFieldMapper, k as sortFieldNames, l as createFailureCollector, m as ADAPTER_FILTER_REASON, n as isAtscriptDbView, o as ApplicationIntegrity, p as resolveDesignType, r as AtscriptDbTable, s as ALL_BUCKET_UNITS, t as AtscriptDbView, u as IntegrityStrategy, v as bucketSourceVerdict, w as guardFilter, x as classifyQueryPath, y as canFilterLeaf, z as isBucketableField } from "./db-view-BrAtbaOx.mjs";
|
|
3
|
+
import { t as ALL_AGGREGATE_FNS } from "./aggregate-fns-CfsveE1w.mjs";
|
|
4
|
+
import { v as tableNameOf } from "./nested-writer-FWD5oOYh.mjs";
|
|
3
5
|
import { a as forceNavNonOptional, c as getKeyProps, l as isEmptyObject, o as isNavRelation, r as buildValidationContext, s as createDbValidatorPlugin, t as buildDbValidator, u as isPlainObject } from "./validator-Ch7UIQl9.mjs";
|
|
4
6
|
import { t as DEFAULT_DB_SPACE } from "./consts-C_-5_pFq.mjs";
|
|
5
7
|
import { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, getDbFieldOp, isDbFieldOp, reconcileCas, separateCas, separateFieldOps } from "./ops.mjs";
|
|
@@ -354,6 +356,14 @@ var DbSpace = class {
|
|
|
354
356
|
//#endregion
|
|
355
357
|
//#region src/query/query-tree.ts
|
|
356
358
|
/**
|
|
359
|
+
* `true` when a query-tree operand is a field reference (`{ field, type? }`)
|
|
360
|
+
* rather than a literal — e.g. the right side of a field-to-field comparison.
|
|
361
|
+
* @since 0.1.136
|
|
362
|
+
*/
|
|
363
|
+
function isFieldRef(value) {
|
|
364
|
+
return value !== null && typeof value === "object" && "field" in value;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
357
367
|
* Translates a JS-emitted query tree into a FilterExpr.
|
|
358
368
|
* Resolves field references (type + field path) to physical column names
|
|
359
369
|
* via the provided resolver function.
|
|
@@ -364,12 +374,12 @@ function translateQueryTree(node, resolveField) {
|
|
|
364
374
|
if ("$not" in node) return { $not: translateQueryTree(node.$not, resolveField) };
|
|
365
375
|
const comp = node;
|
|
366
376
|
const leftField = resolveField(comp.left);
|
|
367
|
-
if (comp.right
|
|
377
|
+
if (isFieldRef(comp.right)) {
|
|
368
378
|
const rightField = resolveField(comp.right);
|
|
369
379
|
return { [leftField]: { [comp.op]: { $field: rightField } } };
|
|
370
380
|
}
|
|
371
|
-
if (comp.op === "$exists") return { [leftField]: { $exists:
|
|
381
|
+
if (comp.op === "$exists") return { [leftField]: { $exists: comp.right !== false } };
|
|
372
382
|
return { [leftField]: { [comp.op]: comp.right } };
|
|
373
383
|
}
|
|
374
384
|
//#endregion
|
|
375
|
-
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_BUCKET_UNITS, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, BaseDbAdapter, CasExhaustedError, CasMismatchError, DEFAULT_DB_SPACE, DbEncryption, DbError, DbSpace, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, IntegrityStrategy, NativeIntegrity, NoopLogger, RelationalFieldMapper, TableMetadata, UniquSelect, acceptedOperatorsHint, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, findAncestorInSet, forceNavNonOptional, getDbFieldOp, getKeyProps, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isDbFieldOp, isEmptyObject, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, jsonValueAncestor, narrowerFilterOps, reconcileCas, resolveCalendarBuckets, resolveDesignType, separateCas, separateFieldOps, sortFieldNames, translateQueryTree, unsupportedOperatorMessage, walkFilter, withOptimisticRetry };
|
|
385
|
+
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, BaseDbAdapter, CasExhaustedError, CasMismatchError, DEFAULT_DB_SPACE, DbEncryption, DbError, DbSpace, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, IntegrityStrategy, NativeIntegrity, NoopLogger, RelationalFieldMapper, TableMetadata, UniquSelect, acceptedOperatorsHint, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, findAncestorInSet, forceNavNonOptional, getDbFieldOp, getKeyProps, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, reconcileCas, resolveCalendarBuckets, resolveDesignType, separateCas, separateFieldOps, sortFieldNames, tableNameOf, translateQueryTree, unsupportedOperatorMessage, walkFilter, withOptimisticRetry };
|
|
@@ -26,11 +26,19 @@ function findRemoteFK(targetTable, thisTableName, alias) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
+
* Table name of an annotated type — its `@db.table`, else its type id (`""`
|
|
30
|
+
* when neither is set). The rule relations, foreign keys and view plans use
|
|
31
|
+
* to name a referenced table.
|
|
32
|
+
* @since 0.1.136
|
|
33
|
+
*/
|
|
34
|
+
function tableNameOf(type) {
|
|
35
|
+
return type?.metadata?.get("db.table") || type?.id || "";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
29
38
|
* Resolves the target table name from a relation's target type metadata.
|
|
30
39
|
*/
|
|
31
40
|
function resolveRelationTargetTable(relation) {
|
|
32
|
-
|
|
33
|
-
return targetType?.metadata?.get("db.table") || targetType?.id || "";
|
|
41
|
+
return tableNameOf(relation.targetType());
|
|
34
42
|
}
|
|
35
43
|
//#endregion
|
|
36
44
|
//#region src/table/error-utils.ts
|
|
@@ -742,6 +750,12 @@ Object.defineProperty(exports, "resolveRelationTargetTable", {
|
|
|
742
750
|
return resolveRelationTargetTable;
|
|
743
751
|
}
|
|
744
752
|
});
|
|
753
|
+
Object.defineProperty(exports, "tableNameOf", {
|
|
754
|
+
enumerable: true,
|
|
755
|
+
get: function() {
|
|
756
|
+
return tableNameOf;
|
|
757
|
+
}
|
|
758
|
+
});
|
|
745
759
|
Object.defineProperty(exports, "validateBatch", {
|
|
746
760
|
enumerable: true,
|
|
747
761
|
get: function() {
|
|
@@ -26,11 +26,19 @@ function findRemoteFK(targetTable, thisTableName, alias) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
+
* Table name of an annotated type — its `@db.table`, else its type id (`""`
|
|
30
|
+
* when neither is set). The rule relations, foreign keys and view plans use
|
|
31
|
+
* to name a referenced table.
|
|
32
|
+
* @since 0.1.136
|
|
33
|
+
*/
|
|
34
|
+
function tableNameOf(type) {
|
|
35
|
+
return type?.metadata?.get("db.table") || type?.id || "";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
29
38
|
* Resolves the target table name from a relation's target type metadata.
|
|
30
39
|
*/
|
|
31
40
|
function resolveRelationTargetTable(relation) {
|
|
32
|
-
|
|
33
|
-
return targetType?.metadata?.get("db.table") || targetType?.id || "";
|
|
41
|
+
return tableNameOf(relation.targetType());
|
|
34
42
|
}
|
|
35
43
|
//#endregion
|
|
36
44
|
//#region src/table/error-utils.ts
|
|
@@ -646,4 +654,4 @@ async function viaReplace(targetTable, junctionTable, targets, parentPK, targetP
|
|
|
646
654
|
}
|
|
647
655
|
}
|
|
648
656
|
//#endregion
|
|
649
|
-
export { resolveRelationTargetTable as _, batchPatchNestedTo as a, batchReplaceNestedTo as c, preValidateNestedFrom as d, validateBatch as f, findRemoteFK as g, findFKForRelation as h, batchPatchNestedFrom as i, batchReplaceNestedVia as l, remapDeleteFkViolation as m, batchInsertNestedTo as n, batchPatchNestedVia as o, enrichFkViolation as p, batchInsertNestedVia as r, batchReplaceNestedFrom as s, batchInsertNestedFrom as t, checkDepthOverflow as u };
|
|
657
|
+
export { resolveRelationTargetTable as _, batchPatchNestedTo as a, batchReplaceNestedTo as c, preValidateNestedFrom as d, validateBatch as f, findRemoteFK as g, findFKForRelation as h, batchPatchNestedFrom as i, batchReplaceNestedVia as l, remapDeleteFkViolation as m, batchInsertNestedTo as n, batchPatchNestedVia as o, enrichFkViolation as p, batchInsertNestedVia as r, batchReplaceNestedFrom as s, batchInsertNestedFrom as t, checkDepthOverflow as u, tableNameOf as v };
|