@atscript/db 0.1.133 → 0.1.134
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.d.cts +1 -1
- package/dist/agg.d.mts +1 -1
- package/dist/{buckets-CTWy7Y1k.d.cts → buckets-Bo2IcPZ_.d.cts} +55 -8
- package/dist/{buckets-BENuu_tK.d.mts → buckets-Bys2QXyk.d.mts} +55 -8
- package/dist/{db-space-Bv3Ar_Xd.d.mts → db-space-DtGx5HIC.d.cts} +6 -4
- package/dist/{db-space-DROLifb-.d.cts → db-space-grfuZcPR.d.mts} +6 -4
- package/dist/{db-view-caPATLmX.mjs → db-view-B64IpZ2j.mjs} +71 -27
- package/dist/{db-view-B5-bQ5AV.cjs → db-view-pgm2dHIo.cjs} +71 -27
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/rel.d.cts +1 -1
- package/dist/rel.d.mts +1 -1
- package/dist/sync.cjs +1 -1
- package/dist/sync.d.cts +2 -2
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +1 -1
- package/package.json +1 -1
package/dist/agg.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TResolvedBucket } from "./buckets-
|
|
1
|
+
import { n as TResolvedBucket } from "./buckets-Bo2IcPZ_.cjs";
|
|
2
2
|
import { AggregateControls, AggregateExpr, AggregateFn, AggregateQuery, AggregateResult, BucketExpr, BucketUnit, CalendarBucketLabel, ComputedExpr, ResolvedBucket, WeekStart, isAggregateExpr, isBucketExpr, resolveAlias } from "@uniqu/core";
|
|
3
3
|
|
|
4
4
|
//#region src/agg.d.ts
|
package/dist/agg.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TResolvedBucket } from "./buckets-
|
|
1
|
+
import { n as TResolvedBucket } from "./buckets-Bys2QXyk.mjs";
|
|
2
2
|
import { AggregateControls, AggregateExpr, AggregateFn, AggregateQuery, AggregateResult, BucketExpr, BucketUnit, CalendarBucketLabel, ComputedExpr, ResolvedBucket, WeekStart, isAggregateExpr, isBucketExpr, resolveAlias } from "@uniqu/core";
|
|
3
3
|
|
|
4
4
|
//#region src/agg.d.ts
|
|
@@ -361,6 +361,14 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
361
361
|
get preferredId(): readonly string[];
|
|
362
362
|
/** Legitimate row-identifier shapes (primary key + every unique index). */
|
|
363
363
|
get identifications(): readonly TIdentification[];
|
|
364
|
+
/**
|
|
365
|
+
* The {@link identifications} an id may resolve through when fields are
|
|
366
|
+
* hidden per request (since 0.1.134): a unique index with a field that
|
|
367
|
+
* fails `isFieldVisible` is dropped, as if it did not exist. Primary-key,
|
|
368
|
+
* `preferredId` and `@meta.id` fields always count as visible. Without a
|
|
369
|
+
* predicate, every identification.
|
|
370
|
+
*/
|
|
371
|
+
identificationsVisibleTo(isFieldVisible?: TIdResolveOptions["isFieldVisible"]): readonly TIdentification[];
|
|
364
372
|
/**
|
|
365
373
|
* Physical column name of the single `@meta.id` field, or `null` when the
|
|
366
374
|
* schema has zero or multiple `@meta.id` fields. Used by adapters to return
|
|
@@ -414,6 +422,19 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
414
422
|
* Pre-computed field metadata for adapter use.
|
|
415
423
|
*/
|
|
416
424
|
get fieldDescriptors(): readonly TDbFieldMeta[];
|
|
425
|
+
/**
|
|
426
|
+
* The target table of the navigation relation `navField` (since 0.1.134),
|
|
427
|
+
* resolved through the table resolver this readable was built with (the
|
|
428
|
+
* `DbSpace`'s). `undefined` when `navField` is not a relation of this table
|
|
429
|
+
* or no resolver is available (a table constructed without a `DbSpace`).
|
|
430
|
+
* Top-level relation names only — no dotted paths.
|
|
431
|
+
*
|
|
432
|
+
* ```typescript
|
|
433
|
+
* const users = posts.relatedTable('author')
|
|
434
|
+
* users?.primaryKeys // ['id']
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
relatedTable(navField: string): ReturnType<TTableResolver>;
|
|
417
438
|
/**
|
|
418
439
|
* Resolves whether `path` references a real field — directly via `flatMap`
|
|
419
440
|
* or transitively through a nav relation by recursing into the target
|
|
@@ -567,17 +588,20 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
567
588
|
* same identification resolution as {@link findById}. Public so callers can
|
|
568
589
|
* AND-combine the id-filter with a row-level read overlay before issuing
|
|
569
590
|
* `findOne` (avoiding the existence leak that `findById` would cause).
|
|
591
|
+
* `opts.isFieldVisible` (since 0.1.134) drops unique indexes over hidden
|
|
592
|
+
* fields — see {@link identificationsVisibleTo}.
|
|
570
593
|
*/
|
|
571
|
-
resolveIdFilter(id: unknown): FilterExpr | null;
|
|
594
|
+
resolveIdFilter(id: unknown, opts?: TIdResolveOptions): FilterExpr | null;
|
|
572
595
|
/**
|
|
573
596
|
* Resolve an id value into a filter expression.
|
|
574
597
|
*
|
|
575
598
|
* When `preferredId` differs from the PK, scalar ids resolve only against
|
|
576
599
|
* the preferred field (deterministic addressing). Otherwise scalars try PK
|
|
577
600
|
* + every single-field unique index; objects try PK + compound unique
|
|
578
|
-
* indexes.
|
|
601
|
+
* indexes. With `opts.isFieldVisible`, only the identifications
|
|
602
|
+
* {@link identificationsVisibleTo} keeps are tried.
|
|
579
603
|
*/
|
|
580
|
-
protected _resolveIdFilter(id: unknown): FilterExpr | null;
|
|
604
|
+
protected _resolveIdFilter(id: unknown, opts?: TIdResolveOptions): FilterExpr | null;
|
|
581
605
|
/** Build a single-key filter from `idObj` over `fields`, or null if any field is missing/incompatible. */
|
|
582
606
|
private _tryCompoundFilter;
|
|
583
607
|
/**
|
|
@@ -1391,6 +1415,7 @@ declare class TableMetadata {
|
|
|
1391
1415
|
physicalNames: ReadonlySet<string>;
|
|
1392
1416
|
private _built;
|
|
1393
1417
|
private _identifications?;
|
|
1418
|
+
private _alwaysAddressable?;
|
|
1394
1419
|
private _collateMap;
|
|
1395
1420
|
private _columnFromMap;
|
|
1396
1421
|
constructor(nestedObjects: boolean);
|
|
@@ -1487,6 +1512,12 @@ declare class TableMetadata {
|
|
|
1487
1512
|
private _buildIdentifications;
|
|
1488
1513
|
/** Legitimate row-identifier shapes — primary key first, then each unique index. */
|
|
1489
1514
|
getIdentifications(): readonly TIdentification[];
|
|
1515
|
+
/**
|
|
1516
|
+
* Fields that always count as visible for row identification (since
|
|
1517
|
+
* 0.1.134): primary key, `preferredId` and `@meta.id` fields — see
|
|
1518
|
+
* `AtscriptDbReadable.identificationsVisibleTo`.
|
|
1519
|
+
*/
|
|
1520
|
+
getAlwaysAddressable(): ReadonlySet<string>;
|
|
1490
1521
|
private _resolvePreferredId;
|
|
1491
1522
|
}
|
|
1492
1523
|
//#endregion
|
|
@@ -2114,8 +2145,13 @@ interface TTouchManyOptions {
|
|
|
2114
2145
|
*/
|
|
2115
2146
|
require?: "all" | "any";
|
|
2116
2147
|
}
|
|
2117
|
-
/**
|
|
2118
|
-
|
|
2148
|
+
/**
|
|
2149
|
+
* Options of `insertOne/Many`, `replaceOne` / `bulkReplace`, `updateOne` / `bulkUpdate`.
|
|
2150
|
+
* `isFieldVisible` (since 0.1.134, see {@link TIdResolveOptions}) applies to the
|
|
2151
|
+
* top-level rows only — a payload without its primary key identifies through
|
|
2152
|
+
* a unique index; nested-relation writes ignore it.
|
|
2153
|
+
*/
|
|
2154
|
+
interface TWriteOptions<Row = Record<string, unknown>> extends TIdResolveOptions {
|
|
2119
2155
|
/** Nested-relation write recursion limit (default 3). */
|
|
2120
2156
|
maxDepth?: number;
|
|
2121
2157
|
/**
|
|
@@ -2128,8 +2164,8 @@ interface TWriteOptions<Row = Record<string, unknown>> {
|
|
|
2128
2164
|
*/
|
|
2129
2165
|
guard?: TDbWriteGuard<Row>;
|
|
2130
2166
|
}
|
|
2131
|
-
/** Options of `deleteOne`. */
|
|
2132
|
-
interface TDeleteOptions<Row = Record<string, unknown>> {
|
|
2167
|
+
/** Options of `deleteOne`. `isFieldVisible` since 0.1.134 — see {@link TIdResolveOptions}. */
|
|
2168
|
+
interface TDeleteOptions<Row = Record<string, unknown>> extends TIdResolveOptions {
|
|
2133
2169
|
/**
|
|
2134
2170
|
* Validated-stage guard (since 0.1.128): invoked inside the table's
|
|
2135
2171
|
* transaction after the id resolved to a filter and before cascade /
|
|
@@ -2137,6 +2173,17 @@ interface TDeleteOptions<Row = Record<string, unknown>> {
|
|
|
2137
2173
|
*/
|
|
2138
2174
|
guard?: TDbRemoveGuard<Row>;
|
|
2139
2175
|
}
|
|
2176
|
+
/** Options of `resolveIdFilter` / `identificationsVisibleTo` (since 0.1.134). */
|
|
2177
|
+
interface TIdResolveOptions {
|
|
2178
|
+
/**
|
|
2179
|
+
* Field-visibility predicate (e.g. a per-request read scope). A unique-index
|
|
2180
|
+
* identification with a field that fails it is ignored — the id resolves
|
|
2181
|
+
* exactly as if that index did not exist, so a hidden unique key can never
|
|
2182
|
+
* answer "a row with this value exists". Primary-key, `preferredId` and
|
|
2183
|
+
* `@meta.id` fields always count as visible.
|
|
2184
|
+
*/
|
|
2185
|
+
isFieldVisible?: (path: string) => boolean;
|
|
2186
|
+
}
|
|
2140
2187
|
/**
|
|
2141
2188
|
* Adds `null` to every optional property of `O`. Optional columns store SQL
|
|
2142
2189
|
* NULL / Mongo null, and the runtime validator accepts `null` for optional
|
|
@@ -2227,4 +2274,4 @@ declare function isJsonValueField(fd: TDbFieldMeta): boolean;
|
|
|
2227
2274
|
*/
|
|
2228
2275
|
declare function jsonValueAncestor(path: string, jsonValueParents: ReadonlySet<string>): string | undefined;
|
|
2229
2276
|
//#endregion
|
|
2230
|
-
export { TDbWriteGuardContext as $, TDbActionIntent as A,
|
|
2277
|
+
export { TDbWriteGuardContext as $, TDbActionIntent as A, isGeoIndexableType as At, TDbIndexField as B, FieldMappingStrategy as Bt, PrimaryKeyOf$1 as C, TWriteTableResolver as Ct, TCrudOp as D, WithRelation$1 as Dt, TColumnDiff as E, UniqueryControls$1 as Et, TDbDefaultValue as F, DbResponse as Ft, TDbReferentialAction as G, TDbInsertManyResult as H, TGenericLogger as Ht, TDbDeleteResult as I, resolveDesignType as It, TDbRemoveGuardContext as J, TDbRelation as K, TDbFieldMeta as L, DbEncryption as Lt, TDbActionProcessor as M, ALL_BUCKET_UNITS as Mt, TDbCollation as N, BaseDbAdapter as Nt, TCrudPermissions as O, TableMetadata as Ot, TDbDefaultFn as P, AtscriptDbReadable as Pt, TDbWriteGuard as Q, TDbForeignKey as R, TDbEncryptionOptions as Rt, OwnPropsOf$1 as S, TWriteOptions as St, TCascadeTarget as T, Uniquery$1 as Tt, TDbInsertResult as U, UniquSelect as Ut, TDbIndexType as V, NoopLogger as Vt, TDbObjectKind as W, TDbUpdateResult as X, TDbStorageType as Y, TDbWriteAction as Z, FieldOpsFor as _, TSyncColumnResult as _t, jsonValueAncestor as a, TFieldMeta as at, NavPropsOf$1 as b, TTouchManyOptions as bt, AggregateExpr$1 as c, TIdDescriptor as ct, AggregateResult as d, TMetaResponse as dt, TDeleteOptions as et, AtscriptDbWritable as f, TMetadataOverrides as ft, DbRow as g, TSearchIndexInfo as gt, DbQuery as h, TRelationInfo as ht, isJsonValueField as i, TExistingTableOption as it, TDbActionLevel as j, isGeoPointType as jt, TDbActionInfo as k, findAncestorInSet as kt, AggregateFn as l, TIdResolveOptions as lt, DbPatch as m, TReferencingForeignKey as mt, TResolvedBucket as n, TExistingColumn as nt, resolveCalendarBuckets as o, TFkLookupResolver as ot, DbControls as p, TPrimaryKeyChange as pt, TDbRemoveGuard as q, isBucketableField as r, TExistingForeignKey as rt, AggregateControls as s, TFkLookupTarget as st, TBucketFieldSource as t, TEnsureTableOptions as tt, AggregateQuery$1 as u, TIdentification as ut, FilterExpr$1 as v, TTableOptionDiff as vt, TCascadeResolver as w, TypedWithRelation as wt, NullableOptional as x, TValueFormatterPair as xt, FlatOf$1 as y, TTableResolver as yt, TDbIndex as z, DocumentFieldMapper as zt };
|
|
@@ -361,6 +361,14 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
361
361
|
get preferredId(): readonly string[];
|
|
362
362
|
/** Legitimate row-identifier shapes (primary key + every unique index). */
|
|
363
363
|
get identifications(): readonly TIdentification[];
|
|
364
|
+
/**
|
|
365
|
+
* The {@link identifications} an id may resolve through when fields are
|
|
366
|
+
* hidden per request (since 0.1.134): a unique index with a field that
|
|
367
|
+
* fails `isFieldVisible` is dropped, as if it did not exist. Primary-key,
|
|
368
|
+
* `preferredId` and `@meta.id` fields always count as visible. Without a
|
|
369
|
+
* predicate, every identification.
|
|
370
|
+
*/
|
|
371
|
+
identificationsVisibleTo(isFieldVisible?: TIdResolveOptions["isFieldVisible"]): readonly TIdentification[];
|
|
364
372
|
/**
|
|
365
373
|
* Physical column name of the single `@meta.id` field, or `null` when the
|
|
366
374
|
* schema has zero or multiple `@meta.id` fields. Used by adapters to return
|
|
@@ -414,6 +422,19 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
414
422
|
* Pre-computed field metadata for adapter use.
|
|
415
423
|
*/
|
|
416
424
|
get fieldDescriptors(): readonly TDbFieldMeta[];
|
|
425
|
+
/**
|
|
426
|
+
* The target table of the navigation relation `navField` (since 0.1.134),
|
|
427
|
+
* resolved through the table resolver this readable was built with (the
|
|
428
|
+
* `DbSpace`'s). `undefined` when `navField` is not a relation of this table
|
|
429
|
+
* or no resolver is available (a table constructed without a `DbSpace`).
|
|
430
|
+
* Top-level relation names only — no dotted paths.
|
|
431
|
+
*
|
|
432
|
+
* ```typescript
|
|
433
|
+
* const users = posts.relatedTable('author')
|
|
434
|
+
* users?.primaryKeys // ['id']
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
relatedTable(navField: string): ReturnType<TTableResolver>;
|
|
417
438
|
/**
|
|
418
439
|
* Resolves whether `path` references a real field — directly via `flatMap`
|
|
419
440
|
* or transitively through a nav relation by recursing into the target
|
|
@@ -567,17 +588,20 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
567
588
|
* same identification resolution as {@link findById}. Public so callers can
|
|
568
589
|
* AND-combine the id-filter with a row-level read overlay before issuing
|
|
569
590
|
* `findOne` (avoiding the existence leak that `findById` would cause).
|
|
591
|
+
* `opts.isFieldVisible` (since 0.1.134) drops unique indexes over hidden
|
|
592
|
+
* fields — see {@link identificationsVisibleTo}.
|
|
570
593
|
*/
|
|
571
|
-
resolveIdFilter(id: unknown): FilterExpr | null;
|
|
594
|
+
resolveIdFilter(id: unknown, opts?: TIdResolveOptions): FilterExpr | null;
|
|
572
595
|
/**
|
|
573
596
|
* Resolve an id value into a filter expression.
|
|
574
597
|
*
|
|
575
598
|
* When `preferredId` differs from the PK, scalar ids resolve only against
|
|
576
599
|
* the preferred field (deterministic addressing). Otherwise scalars try PK
|
|
577
600
|
* + every single-field unique index; objects try PK + compound unique
|
|
578
|
-
* indexes.
|
|
601
|
+
* indexes. With `opts.isFieldVisible`, only the identifications
|
|
602
|
+
* {@link identificationsVisibleTo} keeps are tried.
|
|
579
603
|
*/
|
|
580
|
-
protected _resolveIdFilter(id: unknown): FilterExpr | null;
|
|
604
|
+
protected _resolveIdFilter(id: unknown, opts?: TIdResolveOptions): FilterExpr | null;
|
|
581
605
|
/** Build a single-key filter from `idObj` over `fields`, or null if any field is missing/incompatible. */
|
|
582
606
|
private _tryCompoundFilter;
|
|
583
607
|
/**
|
|
@@ -1391,6 +1415,7 @@ declare class TableMetadata {
|
|
|
1391
1415
|
physicalNames: ReadonlySet<string>;
|
|
1392
1416
|
private _built;
|
|
1393
1417
|
private _identifications?;
|
|
1418
|
+
private _alwaysAddressable?;
|
|
1394
1419
|
private _collateMap;
|
|
1395
1420
|
private _columnFromMap;
|
|
1396
1421
|
constructor(nestedObjects: boolean);
|
|
@@ -1487,6 +1512,12 @@ declare class TableMetadata {
|
|
|
1487
1512
|
private _buildIdentifications;
|
|
1488
1513
|
/** Legitimate row-identifier shapes — primary key first, then each unique index. */
|
|
1489
1514
|
getIdentifications(): readonly TIdentification[];
|
|
1515
|
+
/**
|
|
1516
|
+
* Fields that always count as visible for row identification (since
|
|
1517
|
+
* 0.1.134): primary key, `preferredId` and `@meta.id` fields — see
|
|
1518
|
+
* `AtscriptDbReadable.identificationsVisibleTo`.
|
|
1519
|
+
*/
|
|
1520
|
+
getAlwaysAddressable(): ReadonlySet<string>;
|
|
1490
1521
|
private _resolvePreferredId;
|
|
1491
1522
|
}
|
|
1492
1523
|
//#endregion
|
|
@@ -2114,8 +2145,13 @@ interface TTouchManyOptions {
|
|
|
2114
2145
|
*/
|
|
2115
2146
|
require?: "all" | "any";
|
|
2116
2147
|
}
|
|
2117
|
-
/**
|
|
2118
|
-
|
|
2148
|
+
/**
|
|
2149
|
+
* Options of `insertOne/Many`, `replaceOne` / `bulkReplace`, `updateOne` / `bulkUpdate`.
|
|
2150
|
+
* `isFieldVisible` (since 0.1.134, see {@link TIdResolveOptions}) applies to the
|
|
2151
|
+
* top-level rows only — a payload without its primary key identifies through
|
|
2152
|
+
* a unique index; nested-relation writes ignore it.
|
|
2153
|
+
*/
|
|
2154
|
+
interface TWriteOptions<Row = Record<string, unknown>> extends TIdResolveOptions {
|
|
2119
2155
|
/** Nested-relation write recursion limit (default 3). */
|
|
2120
2156
|
maxDepth?: number;
|
|
2121
2157
|
/**
|
|
@@ -2128,8 +2164,8 @@ interface TWriteOptions<Row = Record<string, unknown>> {
|
|
|
2128
2164
|
*/
|
|
2129
2165
|
guard?: TDbWriteGuard<Row>;
|
|
2130
2166
|
}
|
|
2131
|
-
/** Options of `deleteOne`. */
|
|
2132
|
-
interface TDeleteOptions<Row = Record<string, unknown>> {
|
|
2167
|
+
/** Options of `deleteOne`. `isFieldVisible` since 0.1.134 — see {@link TIdResolveOptions}. */
|
|
2168
|
+
interface TDeleteOptions<Row = Record<string, unknown>> extends TIdResolveOptions {
|
|
2133
2169
|
/**
|
|
2134
2170
|
* Validated-stage guard (since 0.1.128): invoked inside the table's
|
|
2135
2171
|
* transaction after the id resolved to a filter and before cascade /
|
|
@@ -2137,6 +2173,17 @@ interface TDeleteOptions<Row = Record<string, unknown>> {
|
|
|
2137
2173
|
*/
|
|
2138
2174
|
guard?: TDbRemoveGuard<Row>;
|
|
2139
2175
|
}
|
|
2176
|
+
/** Options of `resolveIdFilter` / `identificationsVisibleTo` (since 0.1.134). */
|
|
2177
|
+
interface TIdResolveOptions {
|
|
2178
|
+
/**
|
|
2179
|
+
* Field-visibility predicate (e.g. a per-request read scope). A unique-index
|
|
2180
|
+
* identification with a field that fails it is ignored — the id resolves
|
|
2181
|
+
* exactly as if that index did not exist, so a hidden unique key can never
|
|
2182
|
+
* answer "a row with this value exists". Primary-key, `preferredId` and
|
|
2183
|
+
* `@meta.id` fields always count as visible.
|
|
2184
|
+
*/
|
|
2185
|
+
isFieldVisible?: (path: string) => boolean;
|
|
2186
|
+
}
|
|
2140
2187
|
/**
|
|
2141
2188
|
* Adds `null` to every optional property of `O`. Optional columns store SQL
|
|
2142
2189
|
* NULL / Mongo null, and the runtime validator accepts `null` for optional
|
|
@@ -2227,4 +2274,4 @@ declare function isJsonValueField(fd: TDbFieldMeta): boolean;
|
|
|
2227
2274
|
*/
|
|
2228
2275
|
declare function jsonValueAncestor(path: string, jsonValueParents: ReadonlySet<string>): string | undefined;
|
|
2229
2276
|
//#endregion
|
|
2230
|
-
export { TDbWriteGuardContext as $, TDbActionIntent as A,
|
|
2277
|
+
export { TDbWriteGuardContext as $, TDbActionIntent as A, isGeoIndexableType as At, TDbIndexField as B, FieldMappingStrategy as Bt, PrimaryKeyOf$1 as C, TWriteTableResolver as Ct, TCrudOp as D, WithRelation$1 as Dt, TColumnDiff as E, UniqueryControls$1 as Et, TDbDefaultValue as F, DbResponse as Ft, TDbReferentialAction as G, TDbInsertManyResult as H, TGenericLogger as Ht, TDbDeleteResult as I, resolveDesignType as It, TDbRemoveGuardContext as J, TDbRelation as K, TDbFieldMeta as L, DbEncryption as Lt, TDbActionProcessor as M, ALL_BUCKET_UNITS as Mt, TDbCollation as N, BaseDbAdapter as Nt, TCrudPermissions as O, TableMetadata as Ot, TDbDefaultFn as P, AtscriptDbReadable as Pt, TDbWriteGuard as Q, TDbForeignKey as R, TDbEncryptionOptions as Rt, OwnPropsOf$1 as S, TWriteOptions as St, TCascadeTarget as T, Uniquery$1 as Tt, TDbInsertResult as U, UniquSelect as Ut, TDbIndexType as V, NoopLogger as Vt, TDbObjectKind as W, TDbUpdateResult as X, TDbStorageType as Y, TDbWriteAction as Z, FieldOpsFor as _, TSyncColumnResult as _t, jsonValueAncestor as a, TFieldMeta as at, NavPropsOf$1 as b, TTouchManyOptions as bt, AggregateExpr$1 as c, TIdDescriptor as ct, AggregateResult as d, TMetaResponse as dt, TDeleteOptions as et, AtscriptDbWritable as f, TMetadataOverrides as ft, DbRow as g, TSearchIndexInfo as gt, DbQuery as h, TRelationInfo as ht, isJsonValueField as i, TExistingTableOption as it, TDbActionLevel as j, isGeoPointType as jt, TDbActionInfo as k, findAncestorInSet as kt, AggregateFn as l, TIdResolveOptions as lt, DbPatch as m, TReferencingForeignKey as mt, TResolvedBucket as n, TExistingColumn as nt, resolveCalendarBuckets as o, TFkLookupResolver as ot, DbControls as p, TPrimaryKeyChange as pt, TDbRemoveGuard as q, isBucketableField as r, TExistingForeignKey as rt, AggregateControls as s, TFkLookupTarget as st, TBucketFieldSource as t, TEnsureTableOptions as tt, AggregateQuery$1 as u, TIdentification as ut, FilterExpr$1 as v, TTableOptionDiff as vt, TCascadeResolver as w, TypedWithRelation as wt, NullableOptional as x, TValueFormatterPair as xt, FlatOf$1 as y, TTableResolver as yt, TDbIndex as z, DocumentFieldMapper as zt };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AtscriptQueryComparison, AtscriptQueryFieldRef, AtscriptQueryFieldRef as AtscriptQueryFieldRef$1, AtscriptQueryNode, AtscriptQueryNode as AtscriptQueryNode$1, AtscriptRef, FlatOf, NavPropsOf, OwnPropsOf, PrimaryKeyOf, TAtscriptAnnotatedType, TAtscriptDataType, Validator } from "@atscript/typescript/utils";
|
|
1
|
+
import { Ct as TWriteTableResolver, H as TDbInsertManyResult, Ht as TGenericLogger, I as TDbDeleteResult, Lt as DbEncryption, Nt as BaseDbAdapter, Ot as TableMetadata, Pt as AtscriptDbReadable, Rt as TDbEncryptionOptions, St as TWriteOptions, U as TDbInsertResult, X as TDbUpdateResult, bt as TTouchManyOptions, et as TDeleteOptions, g as DbRow, lt as TIdResolveOptions, m as DbPatch, mt as TReferencingForeignKey, ot as TFkLookupResolver, w as TCascadeResolver, x as NullableOptional, yt as TTableResolver } from "./buckets-Bo2IcPZ_.cjs";
|
|
3
2
|
import { FilterExpr } from "@uniqu/core";
|
|
3
|
+
import { AtscriptQueryComparison, AtscriptQueryFieldRef, AtscriptQueryFieldRef as AtscriptQueryFieldRef$1, AtscriptQueryNode, AtscriptQueryNode as AtscriptQueryNode$1, AtscriptRef, FlatOf, NavPropsOf, OwnPropsOf, PrimaryKeyOf, TAtscriptAnnotatedType, TAtscriptDataType, Validator } from "@atscript/typescript/utils";
|
|
4
4
|
|
|
5
5
|
//#region src/strategies/integrity.d.ts
|
|
6
6
|
/**
|
|
@@ -202,9 +202,11 @@ declare class AtscriptDbTable<T extends TAtscriptAnnotatedType = TAtscriptAnnota
|
|
|
202
202
|
* 2. Single-field unique index — first `@db.index.unique` field found.
|
|
203
203
|
* 3. Compound unique index — first compound unique index whose fields are all present.
|
|
204
204
|
*
|
|
205
|
-
* Throws when no identifying fields can be found.
|
|
205
|
+
* Throws when no identifying fields can be found. With `isFieldVisible`
|
|
206
|
+
* (since 0.1.134), a unique index over a hidden field is skipped, as if it
|
|
207
|
+
* did not exist — see {@link identificationsVisibleTo}.
|
|
206
208
|
*/
|
|
207
|
-
protected _extractRecordFilter(payload: Record<string, unknown
|
|
209
|
+
protected _extractRecordFilter(payload: Record<string, unknown>, opts?: TIdResolveOptions): FilterExpr;
|
|
208
210
|
private _prepareFilterValue;
|
|
209
211
|
/**
|
|
210
212
|
* Lazy — builds a `normalized-path → from-depth` map from `this._meta.flatMap`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FilterExpr } from "@uniqu/core";
|
|
1
|
+
import { Ct as TWriteTableResolver, H as TDbInsertManyResult, Ht as TGenericLogger, I as TDbDeleteResult, Lt as DbEncryption, Nt as BaseDbAdapter, Ot as TableMetadata, Pt as AtscriptDbReadable, Rt as TDbEncryptionOptions, St as TWriteOptions, U as TDbInsertResult, X as TDbUpdateResult, bt as TTouchManyOptions, et as TDeleteOptions, g as DbRow, lt as TIdResolveOptions, m as DbPatch, mt as TReferencingForeignKey, ot as TFkLookupResolver, w as TCascadeResolver, x as NullableOptional, yt as TTableResolver } from "./buckets-Bys2QXyk.mjs";
|
|
3
2
|
import { AtscriptQueryComparison, AtscriptQueryFieldRef, AtscriptQueryFieldRef as AtscriptQueryFieldRef$1, AtscriptQueryNode, AtscriptQueryNode as AtscriptQueryNode$1, AtscriptRef, FlatOf, NavPropsOf, OwnPropsOf, PrimaryKeyOf, TAtscriptAnnotatedType, TAtscriptDataType, Validator } from "@atscript/typescript/utils";
|
|
3
|
+
import { FilterExpr } from "@uniqu/core";
|
|
4
4
|
|
|
5
5
|
//#region src/strategies/integrity.d.ts
|
|
6
6
|
/**
|
|
@@ -202,9 +202,11 @@ declare class AtscriptDbTable<T extends TAtscriptAnnotatedType = TAtscriptAnnota
|
|
|
202
202
|
* 2. Single-field unique index — first `@db.index.unique` field found.
|
|
203
203
|
* 3. Compound unique index — first compound unique index whose fields are all present.
|
|
204
204
|
*
|
|
205
|
-
* Throws when no identifying fields can be found.
|
|
205
|
+
* Throws when no identifying fields can be found. With `isFieldVisible`
|
|
206
|
+
* (since 0.1.134), a unique index over a hidden field is skipped, as if it
|
|
207
|
+
* did not exist — see {@link identificationsVisibleTo}.
|
|
206
208
|
*/
|
|
207
|
-
protected _extractRecordFilter(payload: Record<string, unknown
|
|
209
|
+
protected _extractRecordFilter(payload: Record<string, unknown>, opts?: TIdResolveOptions): FilterExpr;
|
|
208
210
|
private _prepareFilterValue;
|
|
209
211
|
/**
|
|
210
212
|
* Lazy — builds a `normalized-path → from-depth` map from `this._meta.flatMap`
|
|
@@ -212,6 +212,7 @@ var TableMetadata = class {
|
|
|
212
212
|
physicalNames = /* @__PURE__ */ new Set();
|
|
213
213
|
_built = false;
|
|
214
214
|
_identifications;
|
|
215
|
+
_alwaysAddressable;
|
|
215
216
|
_collateMap = /* @__PURE__ */ new Map();
|
|
216
217
|
_columnFromMap = /* @__PURE__ */ new Map();
|
|
217
218
|
constructor(nestedObjects) {
|
|
@@ -281,6 +282,11 @@ var TableMetadata = class {
|
|
|
281
282
|
if (!this.nestedObjects) this._buildLeafIndexes();
|
|
282
283
|
this._buildIdentifications();
|
|
283
284
|
this._resolvePreferredId(type);
|
|
285
|
+
this._alwaysAddressable = new Set([
|
|
286
|
+
...this.primaryKeys,
|
|
287
|
+
...this.preferredId,
|
|
288
|
+
...this.originalMetaIdFields
|
|
289
|
+
]);
|
|
284
290
|
this._finalizeIndexes();
|
|
285
291
|
this._collateMap.clear();
|
|
286
292
|
this._columnFromMap.clear();
|
|
@@ -739,6 +745,14 @@ var TableMetadata = class {
|
|
|
739
745
|
getIdentifications() {
|
|
740
746
|
return this._identifications ?? [];
|
|
741
747
|
}
|
|
748
|
+
/**
|
|
749
|
+
* Fields that always count as visible for row identification (since
|
|
750
|
+
* 0.1.134): primary key, `preferredId` and `@meta.id` fields — see
|
|
751
|
+
* `AtscriptDbReadable.identificationsVisibleTo`.
|
|
752
|
+
*/
|
|
753
|
+
getAlwaysAddressable() {
|
|
754
|
+
return this._alwaysAddressable ?? /* @__PURE__ */ new Set();
|
|
755
|
+
}
|
|
742
756
|
_resolvePreferredId(type) {
|
|
743
757
|
const preferred = type.metadata.get("db.table.preferredId.uniqueIndex");
|
|
744
758
|
if (preferred === void 0) {
|
|
@@ -2116,6 +2130,19 @@ var AtscriptDbReadable = class {
|
|
|
2116
2130
|
return this._meta.getIdentifications();
|
|
2117
2131
|
}
|
|
2118
2132
|
/**
|
|
2133
|
+
* The {@link identifications} an id may resolve through when fields are
|
|
2134
|
+
* hidden per request (since 0.1.134): a unique index with a field that
|
|
2135
|
+
* fails `isFieldVisible` is dropped, as if it did not exist. Primary-key,
|
|
2136
|
+
* `preferredId` and `@meta.id` fields always count as visible. Without a
|
|
2137
|
+
* predicate, every identification.
|
|
2138
|
+
*/
|
|
2139
|
+
identificationsVisibleTo(isFieldVisible) {
|
|
2140
|
+
const all = this.identifications;
|
|
2141
|
+
if (!isFieldVisible) return all;
|
|
2142
|
+
const always = this._meta.getAlwaysAddressable();
|
|
2143
|
+
return all.filter((ident) => ident.fields.every((f) => always.has(f) || isFieldVisible(f)));
|
|
2144
|
+
}
|
|
2145
|
+
/**
|
|
2119
2146
|
* Physical column name of the single `@meta.id` field, or `null` when the
|
|
2120
2147
|
* schema has zero or multiple `@meta.id` fields. Used by adapters to return
|
|
2121
2148
|
* the user's logical ID instead of the DB-generated one on insert.
|
|
@@ -2235,6 +2262,24 @@ var AtscriptDbReadable = class {
|
|
|
2235
2262
|
return this._meta.fieldDescriptors;
|
|
2236
2263
|
}
|
|
2237
2264
|
/**
|
|
2265
|
+
* The target table of the navigation relation `navField` (since 0.1.134),
|
|
2266
|
+
* resolved through the table resolver this readable was built with (the
|
|
2267
|
+
* `DbSpace`'s). `undefined` when `navField` is not a relation of this table
|
|
2268
|
+
* or no resolver is available (a table constructed without a `DbSpace`).
|
|
2269
|
+
* Top-level relation names only — no dotted paths.
|
|
2270
|
+
*
|
|
2271
|
+
* ```typescript
|
|
2272
|
+
* const users = posts.relatedTable('author')
|
|
2273
|
+
* users?.primaryKeys // ['id']
|
|
2274
|
+
* ```
|
|
2275
|
+
*/
|
|
2276
|
+
relatedTable(navField) {
|
|
2277
|
+
this._ensureBuilt();
|
|
2278
|
+
const targetType = this._meta.relations.get(navField)?.targetType();
|
|
2279
|
+
if (!targetType || !this._tableResolver) return;
|
|
2280
|
+
return this._tableResolver(targetType);
|
|
2281
|
+
}
|
|
2282
|
+
/**
|
|
2238
2283
|
* Resolves whether `path` references a real field — directly via `flatMap`
|
|
2239
2284
|
* or transitively through a nav relation by recursing into the target
|
|
2240
2285
|
* table. Defense-in-depth for query-path validation: `flattenAnnotatedType`
|
|
@@ -2250,12 +2295,7 @@ var AtscriptDbReadable = class {
|
|
|
2250
2295
|
if (dotIdx === -1) return false;
|
|
2251
2296
|
const head = path.slice(0, dotIdx);
|
|
2252
2297
|
const tail = path.slice(dotIdx + 1);
|
|
2253
|
-
|
|
2254
|
-
const relation = this._meta.relations.get(head);
|
|
2255
|
-
if (!relation) return false;
|
|
2256
|
-
const targetType = relation.targetType();
|
|
2257
|
-
if (!targetType || !this._tableResolver) return false;
|
|
2258
|
-
const targetTable = this._tableResolver(targetType);
|
|
2298
|
+
const targetTable = this.relatedTable(head);
|
|
2259
2299
|
if (!targetTable || typeof targetTable.isValidFieldPath !== "function") return false;
|
|
2260
2300
|
const visited = _visited ?? /* @__PURE__ */ new Set();
|
|
2261
2301
|
const cycleKey = `${this.tableName}:${head}`;
|
|
@@ -2621,9 +2661,11 @@ var AtscriptDbReadable = class {
|
|
|
2621
2661
|
* same identification resolution as {@link findById}. Public so callers can
|
|
2622
2662
|
* AND-combine the id-filter with a row-level read overlay before issuing
|
|
2623
2663
|
* `findOne` (avoiding the existence leak that `findById` would cause).
|
|
2664
|
+
* `opts.isFieldVisible` (since 0.1.134) drops unique indexes over hidden
|
|
2665
|
+
* fields — see {@link identificationsVisibleTo}.
|
|
2624
2666
|
*/
|
|
2625
|
-
resolveIdFilter(id) {
|
|
2626
|
-
return this._resolveIdFilter(id);
|
|
2667
|
+
resolveIdFilter(id, opts) {
|
|
2668
|
+
return this._resolveIdFilter(id, opts);
|
|
2627
2669
|
}
|
|
2628
2670
|
/**
|
|
2629
2671
|
* Resolve an id value into a filter expression.
|
|
@@ -2631,9 +2673,10 @@ var AtscriptDbReadable = class {
|
|
|
2631
2673
|
* When `preferredId` differs from the PK, scalar ids resolve only against
|
|
2632
2674
|
* the preferred field (deterministic addressing). Otherwise scalars try PK
|
|
2633
2675
|
* + every single-field unique index; objects try PK + compound unique
|
|
2634
|
-
* indexes.
|
|
2676
|
+
* indexes. With `opts.isFieldVisible`, only the identifications
|
|
2677
|
+
* {@link identificationsVisibleTo} keeps are tried.
|
|
2635
2678
|
*/
|
|
2636
|
-
_resolveIdFilter(id) {
|
|
2679
|
+
_resolveIdFilter(id, opts) {
|
|
2637
2680
|
const pkFields = this.primaryKeys;
|
|
2638
2681
|
const preferredFields = this.preferredId;
|
|
2639
2682
|
const isExplicitPreferred = preferredFields.length !== pkFields.length || preferredFields.some((f, i) => f !== pkFields[i]);
|
|
@@ -2645,12 +2688,13 @@ var AtscriptDbReadable = class {
|
|
|
2645
2688
|
};
|
|
2646
2689
|
const orFilters = [];
|
|
2647
2690
|
const idObj = isScalar ? null : id;
|
|
2648
|
-
|
|
2691
|
+
const identifications = this.identificationsVisibleTo(opts?.isFieldVisible);
|
|
2692
|
+
for (const ident of identifications) {
|
|
2649
2693
|
if (ident.fields.length !== 1) continue;
|
|
2650
2694
|
const filter = tryScalarOrField(ident.fields[0]);
|
|
2651
2695
|
if (filter) orFilters.push(filter);
|
|
2652
2696
|
}
|
|
2653
|
-
if (idObj) for (const ident of
|
|
2697
|
+
if (idObj) for (const ident of identifications) {
|
|
2654
2698
|
if (ident.fields.length < 2) continue;
|
|
2655
2699
|
if (ident.source !== "primaryKey" && orFilters.length > 0) break;
|
|
2656
2700
|
const filter = this._tryCompoundFilter(ident.fields, idObj);
|
|
@@ -4052,7 +4096,7 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
4052
4096
|
const data = items[i];
|
|
4053
4097
|
for (const navField of this._meta.navFields) delete data[navField];
|
|
4054
4098
|
if (versionColumn !== void 0) assertNoVersionWrites(data, versionColumn);
|
|
4055
|
-
const filter = this._extractRecordFilter(data);
|
|
4099
|
+
const filter = this._extractRecordFilter(data, opts);
|
|
4056
4100
|
const prepared = this._fieldMapper.prepareForWrite(data, this._meta, this.adapter);
|
|
4057
4101
|
const result = await this.adapter.replaceOne(this._fieldMapper.translateFilter(filter, this._meta), prepared, expectedVersions[i]);
|
|
4058
4102
|
matchedCount += result.matchedCount;
|
|
@@ -4127,7 +4171,7 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
4127
4171
|
const expectedVersion = expectedVersions[i];
|
|
4128
4172
|
const data = { ...payload };
|
|
4129
4173
|
for (const navField of this._meta.navFields) delete data[navField];
|
|
4130
|
-
const filter = this._extractRecordFilter(data);
|
|
4174
|
+
const filter = this._extractRecordFilter(data, opts);
|
|
4131
4175
|
for (const key of Object.keys(filter)) delete data[key];
|
|
4132
4176
|
if (versionColumn !== void 0) assertNoVersionWrites(data, versionColumn);
|
|
4133
4177
|
const translatedFilter = this._fieldMapper.translateFilter(filter, this._meta);
|
|
@@ -4261,7 +4305,7 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
4261
4305
|
*/
|
|
4262
4306
|
async deleteOne(id, opts) {
|
|
4263
4307
|
this._ensureBuilt();
|
|
4264
|
-
const filter = this._resolveIdFilter(id);
|
|
4308
|
+
const filter = this._resolveIdFilter(id, opts);
|
|
4265
4309
|
if (!filter) return { deletedCount: 0 };
|
|
4266
4310
|
const guard = opts?.guard;
|
|
4267
4311
|
const needsCascade = this._integrity.needsCascade(this._cascadeResolver);
|
|
@@ -4435,9 +4479,11 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
4435
4479
|
* 2. Single-field unique index — first `@db.index.unique` field found.
|
|
4436
4480
|
* 3. Compound unique index — first compound unique index whose fields are all present.
|
|
4437
4481
|
*
|
|
4438
|
-
* Throws when no identifying fields can be found.
|
|
4482
|
+
* Throws when no identifying fields can be found. With `isFieldVisible`
|
|
4483
|
+
* (since 0.1.134), a unique index over a hidden field is skipped, as if it
|
|
4484
|
+
* did not exist — see {@link identificationsVisibleTo}.
|
|
4439
4485
|
*/
|
|
4440
|
-
_extractRecordFilter(payload) {
|
|
4486
|
+
_extractRecordFilter(payload, opts) {
|
|
4441
4487
|
const pkFields = this.primaryKeys;
|
|
4442
4488
|
if (pkFields.length > 0) {
|
|
4443
4489
|
let allPresent = true;
|
|
@@ -4451,17 +4497,15 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
4451
4497
|
return filter;
|
|
4452
4498
|
}
|
|
4453
4499
|
}
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
}
|
|
4462
|
-
if (allPresent) {
|
|
4500
|
+
const identifications = this.identificationsVisibleTo(opts?.isFieldVisible);
|
|
4501
|
+
const singleFields = /* @__PURE__ */ new Set();
|
|
4502
|
+
for (const ident of identifications) if (ident.source !== "primaryKey" && ident.fields.length === 1) singleFields.add(ident.fields[0]);
|
|
4503
|
+
for (const prop of this.uniqueProps) if (singleFields.has(prop) && payload[prop] !== void 0) return { [prop]: this._prepareFilterValue(prop, payload[prop]) };
|
|
4504
|
+
for (const ident of identifications) {
|
|
4505
|
+
if (ident.source === "primaryKey" || ident.fields.length < 2) continue;
|
|
4506
|
+
if (ident.fields.every((field) => payload[field] !== void 0)) {
|
|
4463
4507
|
const filter = {};
|
|
4464
|
-
for (const
|
|
4508
|
+
for (const field of ident.fields) filter[field] = this._prepareFilterValue(field, payload[field]);
|
|
4465
4509
|
return filter;
|
|
4466
4510
|
}
|
|
4467
4511
|
}
|
|
@@ -212,6 +212,7 @@ var TableMetadata = class {
|
|
|
212
212
|
physicalNames = /* @__PURE__ */ new Set();
|
|
213
213
|
_built = false;
|
|
214
214
|
_identifications;
|
|
215
|
+
_alwaysAddressable;
|
|
215
216
|
_collateMap = /* @__PURE__ */ new Map();
|
|
216
217
|
_columnFromMap = /* @__PURE__ */ new Map();
|
|
217
218
|
constructor(nestedObjects) {
|
|
@@ -281,6 +282,11 @@ var TableMetadata = class {
|
|
|
281
282
|
if (!this.nestedObjects) this._buildLeafIndexes();
|
|
282
283
|
this._buildIdentifications();
|
|
283
284
|
this._resolvePreferredId(type);
|
|
285
|
+
this._alwaysAddressable = new Set([
|
|
286
|
+
...this.primaryKeys,
|
|
287
|
+
...this.preferredId,
|
|
288
|
+
...this.originalMetaIdFields
|
|
289
|
+
]);
|
|
284
290
|
this._finalizeIndexes();
|
|
285
291
|
this._collateMap.clear();
|
|
286
292
|
this._columnFromMap.clear();
|
|
@@ -739,6 +745,14 @@ var TableMetadata = class {
|
|
|
739
745
|
getIdentifications() {
|
|
740
746
|
return this._identifications ?? [];
|
|
741
747
|
}
|
|
748
|
+
/**
|
|
749
|
+
* Fields that always count as visible for row identification (since
|
|
750
|
+
* 0.1.134): primary key, `preferredId` and `@meta.id` fields — see
|
|
751
|
+
* `AtscriptDbReadable.identificationsVisibleTo`.
|
|
752
|
+
*/
|
|
753
|
+
getAlwaysAddressable() {
|
|
754
|
+
return this._alwaysAddressable ?? /* @__PURE__ */ new Set();
|
|
755
|
+
}
|
|
742
756
|
_resolvePreferredId(type) {
|
|
743
757
|
const preferred = type.metadata.get("db.table.preferredId.uniqueIndex");
|
|
744
758
|
if (preferred === void 0) {
|
|
@@ -2116,6 +2130,19 @@ var AtscriptDbReadable = class {
|
|
|
2116
2130
|
return this._meta.getIdentifications();
|
|
2117
2131
|
}
|
|
2118
2132
|
/**
|
|
2133
|
+
* The {@link identifications} an id may resolve through when fields are
|
|
2134
|
+
* hidden per request (since 0.1.134): a unique index with a field that
|
|
2135
|
+
* fails `isFieldVisible` is dropped, as if it did not exist. Primary-key,
|
|
2136
|
+
* `preferredId` and `@meta.id` fields always count as visible. Without a
|
|
2137
|
+
* predicate, every identification.
|
|
2138
|
+
*/
|
|
2139
|
+
identificationsVisibleTo(isFieldVisible) {
|
|
2140
|
+
const all = this.identifications;
|
|
2141
|
+
if (!isFieldVisible) return all;
|
|
2142
|
+
const always = this._meta.getAlwaysAddressable();
|
|
2143
|
+
return all.filter((ident) => ident.fields.every((f) => always.has(f) || isFieldVisible(f)));
|
|
2144
|
+
}
|
|
2145
|
+
/**
|
|
2119
2146
|
* Physical column name of the single `@meta.id` field, or `null` when the
|
|
2120
2147
|
* schema has zero or multiple `@meta.id` fields. Used by adapters to return
|
|
2121
2148
|
* the user's logical ID instead of the DB-generated one on insert.
|
|
@@ -2235,6 +2262,24 @@ var AtscriptDbReadable = class {
|
|
|
2235
2262
|
return this._meta.fieldDescriptors;
|
|
2236
2263
|
}
|
|
2237
2264
|
/**
|
|
2265
|
+
* The target table of the navigation relation `navField` (since 0.1.134),
|
|
2266
|
+
* resolved through the table resolver this readable was built with (the
|
|
2267
|
+
* `DbSpace`'s). `undefined` when `navField` is not a relation of this table
|
|
2268
|
+
* or no resolver is available (a table constructed without a `DbSpace`).
|
|
2269
|
+
* Top-level relation names only — no dotted paths.
|
|
2270
|
+
*
|
|
2271
|
+
* ```typescript
|
|
2272
|
+
* const users = posts.relatedTable('author')
|
|
2273
|
+
* users?.primaryKeys // ['id']
|
|
2274
|
+
* ```
|
|
2275
|
+
*/
|
|
2276
|
+
relatedTable(navField) {
|
|
2277
|
+
this._ensureBuilt();
|
|
2278
|
+
const targetType = this._meta.relations.get(navField)?.targetType();
|
|
2279
|
+
if (!targetType || !this._tableResolver) return;
|
|
2280
|
+
return this._tableResolver(targetType);
|
|
2281
|
+
}
|
|
2282
|
+
/**
|
|
2238
2283
|
* Resolves whether `path` references a real field — directly via `flatMap`
|
|
2239
2284
|
* or transitively through a nav relation by recursing into the target
|
|
2240
2285
|
* table. Defense-in-depth for query-path validation: `flattenAnnotatedType`
|
|
@@ -2250,12 +2295,7 @@ var AtscriptDbReadable = class {
|
|
|
2250
2295
|
if (dotIdx === -1) return false;
|
|
2251
2296
|
const head = path.slice(0, dotIdx);
|
|
2252
2297
|
const tail = path.slice(dotIdx + 1);
|
|
2253
|
-
|
|
2254
|
-
const relation = this._meta.relations.get(head);
|
|
2255
|
-
if (!relation) return false;
|
|
2256
|
-
const targetType = relation.targetType();
|
|
2257
|
-
if (!targetType || !this._tableResolver) return false;
|
|
2258
|
-
const targetTable = this._tableResolver(targetType);
|
|
2298
|
+
const targetTable = this.relatedTable(head);
|
|
2259
2299
|
if (!targetTable || typeof targetTable.isValidFieldPath !== "function") return false;
|
|
2260
2300
|
const visited = _visited ?? /* @__PURE__ */ new Set();
|
|
2261
2301
|
const cycleKey = `${this.tableName}:${head}`;
|
|
@@ -2621,9 +2661,11 @@ var AtscriptDbReadable = class {
|
|
|
2621
2661
|
* same identification resolution as {@link findById}. Public so callers can
|
|
2622
2662
|
* AND-combine the id-filter with a row-level read overlay before issuing
|
|
2623
2663
|
* `findOne` (avoiding the existence leak that `findById` would cause).
|
|
2664
|
+
* `opts.isFieldVisible` (since 0.1.134) drops unique indexes over hidden
|
|
2665
|
+
* fields — see {@link identificationsVisibleTo}.
|
|
2624
2666
|
*/
|
|
2625
|
-
resolveIdFilter(id) {
|
|
2626
|
-
return this._resolveIdFilter(id);
|
|
2667
|
+
resolveIdFilter(id, opts) {
|
|
2668
|
+
return this._resolveIdFilter(id, opts);
|
|
2627
2669
|
}
|
|
2628
2670
|
/**
|
|
2629
2671
|
* Resolve an id value into a filter expression.
|
|
@@ -2631,9 +2673,10 @@ var AtscriptDbReadable = class {
|
|
|
2631
2673
|
* When `preferredId` differs from the PK, scalar ids resolve only against
|
|
2632
2674
|
* the preferred field (deterministic addressing). Otherwise scalars try PK
|
|
2633
2675
|
* + every single-field unique index; objects try PK + compound unique
|
|
2634
|
-
* indexes.
|
|
2676
|
+
* indexes. With `opts.isFieldVisible`, only the identifications
|
|
2677
|
+
* {@link identificationsVisibleTo} keeps are tried.
|
|
2635
2678
|
*/
|
|
2636
|
-
_resolveIdFilter(id) {
|
|
2679
|
+
_resolveIdFilter(id, opts) {
|
|
2637
2680
|
const pkFields = this.primaryKeys;
|
|
2638
2681
|
const preferredFields = this.preferredId;
|
|
2639
2682
|
const isExplicitPreferred = preferredFields.length !== pkFields.length || preferredFields.some((f, i) => f !== pkFields[i]);
|
|
@@ -2645,12 +2688,13 @@ var AtscriptDbReadable = class {
|
|
|
2645
2688
|
};
|
|
2646
2689
|
const orFilters = [];
|
|
2647
2690
|
const idObj = isScalar ? null : id;
|
|
2648
|
-
|
|
2691
|
+
const identifications = this.identificationsVisibleTo(opts?.isFieldVisible);
|
|
2692
|
+
for (const ident of identifications) {
|
|
2649
2693
|
if (ident.fields.length !== 1) continue;
|
|
2650
2694
|
const filter = tryScalarOrField(ident.fields[0]);
|
|
2651
2695
|
if (filter) orFilters.push(filter);
|
|
2652
2696
|
}
|
|
2653
|
-
if (idObj) for (const ident of
|
|
2697
|
+
if (idObj) for (const ident of identifications) {
|
|
2654
2698
|
if (ident.fields.length < 2) continue;
|
|
2655
2699
|
if (ident.source !== "primaryKey" && orFilters.length > 0) break;
|
|
2656
2700
|
const filter = this._tryCompoundFilter(ident.fields, idObj);
|
|
@@ -4052,7 +4096,7 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
4052
4096
|
const data = items[i];
|
|
4053
4097
|
for (const navField of this._meta.navFields) delete data[navField];
|
|
4054
4098
|
if (versionColumn !== void 0) assertNoVersionWrites(data, versionColumn);
|
|
4055
|
-
const filter = this._extractRecordFilter(data);
|
|
4099
|
+
const filter = this._extractRecordFilter(data, opts);
|
|
4056
4100
|
const prepared = this._fieldMapper.prepareForWrite(data, this._meta, this.adapter);
|
|
4057
4101
|
const result = await this.adapter.replaceOne(this._fieldMapper.translateFilter(filter, this._meta), prepared, expectedVersions[i]);
|
|
4058
4102
|
matchedCount += result.matchedCount;
|
|
@@ -4127,7 +4171,7 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
4127
4171
|
const expectedVersion = expectedVersions[i];
|
|
4128
4172
|
const data = { ...payload };
|
|
4129
4173
|
for (const navField of this._meta.navFields) delete data[navField];
|
|
4130
|
-
const filter = this._extractRecordFilter(data);
|
|
4174
|
+
const filter = this._extractRecordFilter(data, opts);
|
|
4131
4175
|
for (const key of Object.keys(filter)) delete data[key];
|
|
4132
4176
|
if (versionColumn !== void 0) assertNoVersionWrites(data, versionColumn);
|
|
4133
4177
|
const translatedFilter = this._fieldMapper.translateFilter(filter, this._meta);
|
|
@@ -4261,7 +4305,7 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
4261
4305
|
*/
|
|
4262
4306
|
async deleteOne(id, opts) {
|
|
4263
4307
|
this._ensureBuilt();
|
|
4264
|
-
const filter = this._resolveIdFilter(id);
|
|
4308
|
+
const filter = this._resolveIdFilter(id, opts);
|
|
4265
4309
|
if (!filter) return { deletedCount: 0 };
|
|
4266
4310
|
const guard = opts?.guard;
|
|
4267
4311
|
const needsCascade = this._integrity.needsCascade(this._cascadeResolver);
|
|
@@ -4435,9 +4479,11 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
4435
4479
|
* 2. Single-field unique index — first `@db.index.unique` field found.
|
|
4436
4480
|
* 3. Compound unique index — first compound unique index whose fields are all present.
|
|
4437
4481
|
*
|
|
4438
|
-
* Throws when no identifying fields can be found.
|
|
4482
|
+
* Throws when no identifying fields can be found. With `isFieldVisible`
|
|
4483
|
+
* (since 0.1.134), a unique index over a hidden field is skipped, as if it
|
|
4484
|
+
* did not exist — see {@link identificationsVisibleTo}.
|
|
4439
4485
|
*/
|
|
4440
|
-
_extractRecordFilter(payload) {
|
|
4486
|
+
_extractRecordFilter(payload, opts) {
|
|
4441
4487
|
const pkFields = this.primaryKeys;
|
|
4442
4488
|
if (pkFields.length > 0) {
|
|
4443
4489
|
let allPresent = true;
|
|
@@ -4451,17 +4497,15 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
4451
4497
|
return filter;
|
|
4452
4498
|
}
|
|
4453
4499
|
}
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
}
|
|
4462
|
-
if (allPresent) {
|
|
4500
|
+
const identifications = this.identificationsVisibleTo(opts?.isFieldVisible);
|
|
4501
|
+
const singleFields = /* @__PURE__ */ new Set();
|
|
4502
|
+
for (const ident of identifications) if (ident.source !== "primaryKey" && ident.fields.length === 1) singleFields.add(ident.fields[0]);
|
|
4503
|
+
for (const prop of this.uniqueProps) if (singleFields.has(prop) && payload[prop] !== void 0) return { [prop]: this._prepareFilterValue(prop, payload[prop]) };
|
|
4504
|
+
for (const ident of identifications) {
|
|
4505
|
+
if (ident.source === "primaryKey" || ident.fields.length < 2) continue;
|
|
4506
|
+
if (ident.fields.every((field) => payload[field] !== void 0)) {
|
|
4463
4507
|
const filter = {};
|
|
4464
|
-
for (const
|
|
4508
|
+
for (const field of ident.fields) filter[field] = this._prepareFilterValue(field, payload[field]);
|
|
4465
4509
|
return filter;
|
|
4466
4510
|
}
|
|
4467
4511
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-pgm2dHIo.cjs");
|
|
4
4
|
const require_validator = require("./validator-BtZbcLN2.cjs");
|
|
5
5
|
const require_consts = require("./consts-BzRfCcH2.cjs");
|
|
6
6
|
const require_ops = require("./ops.cjs");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as TDbWriteGuardContext, A as TDbActionIntent, At as
|
|
1
|
+
import { $ as TDbWriteGuardContext, A as TDbActionIntent, At as isGeoIndexableType, B as TDbIndexField, Bt as FieldMappingStrategy, C as PrimaryKeyOf, Ct as TWriteTableResolver, D as TCrudOp, Dt as WithRelation, E as TColumnDiff, Et as UniqueryControls, F as TDbDefaultValue, Ft as DbResponse, G as TDbReferentialAction, H as TDbInsertManyResult, Ht as TGenericLogger, I as TDbDeleteResult, It as resolveDesignType, J as TDbRemoveGuardContext, K as TDbRelation, L as TDbFieldMeta, Lt as DbEncryption, M as TDbActionProcessor, Mt as ALL_BUCKET_UNITS, N as TDbCollation, Nt as BaseDbAdapter, O as TCrudPermissions, Ot as TableMetadata, P as TDbDefaultFn, Pt as AtscriptDbReadable, Q as TDbWriteGuard, R as TDbForeignKey, Rt as TDbEncryptionOptions, S as OwnPropsOf, St as TWriteOptions, T as TCascadeTarget, Tt as Uniquery, U as TDbInsertResult, Ut as UniquSelect, V as TDbIndexType, Vt as NoopLogger, W as TDbObjectKind, X as TDbUpdateResult, Y as TDbStorageType, Z as TDbWriteAction, _ as FieldOpsFor, _t as TSyncColumnResult, a as jsonValueAncestor, at as TFieldMeta, b as NavPropsOf, bt as TTouchManyOptions, c as AggregateExpr, ct as TIdDescriptor, d as AggregateResult, dt as TMetaResponse, et as TDeleteOptions, f as AtscriptDbWritable, ft as TMetadataOverrides, g as DbRow, gt as TSearchIndexInfo, h as DbQuery, ht as TRelationInfo, i as isJsonValueField, it as TExistingTableOption, j as TDbActionLevel, jt as isGeoPointType, k as TDbActionInfo, kt as findAncestorInSet, l as AggregateFn, lt as TIdResolveOptions, m as DbPatch, mt as TReferencingForeignKey, n as TResolvedBucket, nt as TExistingColumn, o as resolveCalendarBuckets, ot as TFkLookupResolver, p as DbControls, pt as TPrimaryKeyChange, q as TDbRemoveGuard, r as isBucketableField, rt as TExistingForeignKey, s as AggregateControls, st as TFkLookupTarget, t as TBucketFieldSource, tt as TEnsureTableOptions, u as AggregateQuery, ut as TIdentification, v as FilterExpr, vt as TTableOptionDiff, w as TCascadeResolver, wt as TypedWithRelation, x as NullableOptional, xt as TValueFormatterPair, y as FlatOf, yt as TTableResolver, z as TDbIndex, zt as DocumentFieldMapper } from "./buckets-Bo2IcPZ_.cjs";
|
|
2
2
|
import { _ as separateFieldOps, a as $mul, c as $update, d as TDbFieldOp, f as TFieldOps, g as separateCas, h as reconcileCas, i as $insert, l as $upsert, m as isDbFieldOp, n as $dec, o as $remove, p as getDbFieldOp, r as $inc, s as $replace, t as $cas, u as TDbCas } from "./ops-AqhV7s9o.cjs";
|
|
3
3
|
import { BucketExpr, BucketUnit, CalendarBucketLabel, ComputedExpr, ResolvedBucket, WeekStart } from "./agg.cjs";
|
|
4
|
-
import { a as TViewColumnMapping, c as AtscriptQueryFieldRef, d as TViewJoin, f as TViewPlan, g as NativeIntegrity, h as IntegrityStrategy, i as AtscriptDbView, l as AtscriptQueryNode, m as AtscriptDbTable, n as TAdapterFactory, o as isAtscriptDbView, p as translateQueryTree, r as TDbSpaceOptions, s as AtscriptQueryComparison, t as DbSpace, u as AtscriptRef } from "./db-space-
|
|
4
|
+
import { a as TViewColumnMapping, c as AtscriptQueryFieldRef, d as TViewJoin, f as TViewPlan, g as NativeIntegrity, h as IntegrityStrategy, i as AtscriptDbView, l as AtscriptQueryNode, m as AtscriptDbTable, n as TAdapterFactory, o as isAtscriptDbView, p as translateQueryTree, r as TDbSpaceOptions, s as AtscriptQueryComparison, t as DbSpace, u as AtscriptRef } from "./db-space-DtGx5HIC.cjs";
|
|
5
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-CewfnGZj.cjs";
|
|
6
6
|
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.cjs";
|
|
7
7
|
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, ResolvedBucket as ResolvedBucket$1, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
@@ -487,4 +487,4 @@ declare function createFailureCollector(what: string): {
|
|
|
487
487
|
throwIfAny: () => void;
|
|
488
488
|
};
|
|
489
489
|
//#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 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 };
|
|
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 };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as TDbWriteGuardContext, A as TDbActionIntent, At as
|
|
1
|
+
import { $ as TDbWriteGuardContext, A as TDbActionIntent, At as isGeoIndexableType, B as TDbIndexField, Bt as FieldMappingStrategy, C as PrimaryKeyOf, Ct as TWriteTableResolver, D as TCrudOp, Dt as WithRelation, E as TColumnDiff, Et as UniqueryControls, F as TDbDefaultValue, Ft as DbResponse, G as TDbReferentialAction, H as TDbInsertManyResult, Ht as TGenericLogger, I as TDbDeleteResult, It as resolveDesignType, J as TDbRemoveGuardContext, K as TDbRelation, L as TDbFieldMeta, Lt as DbEncryption, M as TDbActionProcessor, Mt as ALL_BUCKET_UNITS, N as TDbCollation, Nt as BaseDbAdapter, O as TCrudPermissions, Ot as TableMetadata, P as TDbDefaultFn, Pt as AtscriptDbReadable, Q as TDbWriteGuard, R as TDbForeignKey, Rt as TDbEncryptionOptions, S as OwnPropsOf, St as TWriteOptions, T as TCascadeTarget, Tt as Uniquery, U as TDbInsertResult, Ut as UniquSelect, V as TDbIndexType, Vt as NoopLogger, W as TDbObjectKind, X as TDbUpdateResult, Y as TDbStorageType, Z as TDbWriteAction, _ as FieldOpsFor, _t as TSyncColumnResult, a as jsonValueAncestor, at as TFieldMeta, b as NavPropsOf, bt as TTouchManyOptions, c as AggregateExpr, ct as TIdDescriptor, d as AggregateResult, dt as TMetaResponse, et as TDeleteOptions, f as AtscriptDbWritable, ft as TMetadataOverrides, g as DbRow, gt as TSearchIndexInfo, h as DbQuery, ht as TRelationInfo, i as isJsonValueField, it as TExistingTableOption, j as TDbActionLevel, jt as isGeoPointType, k as TDbActionInfo, kt as findAncestorInSet, l as AggregateFn, lt as TIdResolveOptions, m as DbPatch, mt as TReferencingForeignKey, n as TResolvedBucket, nt as TExistingColumn, o as resolveCalendarBuckets, ot as TFkLookupResolver, p as DbControls, pt as TPrimaryKeyChange, q as TDbRemoveGuard, r as isBucketableField, rt as TExistingForeignKey, s as AggregateControls, st as TFkLookupTarget, t as TBucketFieldSource, tt as TEnsureTableOptions, u as AggregateQuery, ut as TIdentification, v as FilterExpr, vt as TTableOptionDiff, w as TCascadeResolver, wt as TypedWithRelation, x as NullableOptional, xt as TValueFormatterPair, y as FlatOf, yt as TTableResolver, z as TDbIndex, zt as DocumentFieldMapper } from "./buckets-Bys2QXyk.mjs";
|
|
2
2
|
import { _ as separateFieldOps, a as $mul, c as $update, d as TDbFieldOp, f as TFieldOps, g as separateCas, h as reconcileCas, i as $insert, l as $upsert, m as isDbFieldOp, n as $dec, o as $remove, p as getDbFieldOp, r as $inc, s as $replace, t as $cas, u as TDbCas } from "./ops-AqhV7s9o.mjs";
|
|
3
3
|
import { BucketExpr, BucketUnit, CalendarBucketLabel, ComputedExpr, ResolvedBucket, WeekStart } from "./agg.mjs";
|
|
4
|
-
import { a as TViewColumnMapping, c as AtscriptQueryFieldRef, d as TViewJoin, f as TViewPlan, g as NativeIntegrity, h as IntegrityStrategy, i as AtscriptDbView, l as AtscriptQueryNode, m as AtscriptDbTable, n as TAdapterFactory, o as isAtscriptDbView, p as translateQueryTree, r as TDbSpaceOptions, s as AtscriptQueryComparison, t as DbSpace, u as AtscriptRef } from "./db-space-
|
|
4
|
+
import { a as TViewColumnMapping, c as AtscriptQueryFieldRef, d as TViewJoin, f as TViewPlan, g as NativeIntegrity, h as IntegrityStrategy, i as AtscriptDbView, l as AtscriptQueryNode, m as AtscriptDbTable, n as TAdapterFactory, o as isAtscriptDbView, p as translateQueryTree, r as TDbSpaceOptions, s as AtscriptQueryComparison, t as DbSpace, u as AtscriptRef } from "./db-space-grfuZcPR.mjs";
|
|
5
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-CewfnGZj.mjs";
|
|
6
6
|
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.mjs";
|
|
7
7
|
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, ResolvedBucket as ResolvedBucket$1, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
@@ -487,4 +487,4 @@ declare function createFailureCollector(what: string): {
|
|
|
487
487
|
throwIfAny: () => void;
|
|
488
488
|
};
|
|
489
489
|
//#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 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 };
|
|
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 resolveCalendarBuckets, 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 NoopLogger, V as jsonValueAncestor, _ 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-
|
|
2
|
+
import { A as unsupportedOperatorMessage, B as isJsonValueField, C as guardAggregate, D as guardQuery, E as guardPaths, F as TableMetadata, H as resolveCalendarBuckets, 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 NoopLogger, V as jsonValueAncestor, _ 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-B64IpZ2j.mjs";
|
|
3
3
|
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
4
|
import { t as DEFAULT_DB_SPACE } from "./consts-C_-5_pFq.mjs";
|
|
5
5
|
import { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, getDbFieldOp, isDbFieldOp, reconcileCas, separateCas, separateFieldOps } from "./ops.mjs";
|
package/dist/rel.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ct as TWriteTableResolver, Ht as TGenericLogger, K as TDbRelation, Nt as BaseDbAdapter, Ot as TableMetadata, R as TDbForeignKey, yt as TTableResolver } from "./buckets-Bo2IcPZ_.cjs";
|
|
2
2
|
import { t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.cjs";
|
|
3
3
|
import { FilterExpr, WithRelation } from "@uniqu/core";
|
|
4
4
|
import { Validator } from "@atscript/typescript/utils";
|
package/dist/rel.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ct as TWriteTableResolver, Ht as TGenericLogger, K as TDbRelation, Nt as BaseDbAdapter, Ot as TableMetadata, R as TDbForeignKey, yt as TTableResolver } from "./buckets-Bys2QXyk.mjs";
|
|
2
2
|
import { t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.mjs";
|
|
3
3
|
import { Validator } from "@atscript/typescript/utils";
|
|
4
4
|
import { FilterExpr, WithRelation } from "@uniqu/core";
|
package/dist/sync.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_db_view = require("./db-view-
|
|
2
|
+
const require_db_view = require("./db-view-pgm2dHIo.cjs");
|
|
3
3
|
//#region src/schema/schema-hash.ts
|
|
4
4
|
/** Extracts sorted field snapshots from a readable's field descriptors. */
|
|
5
5
|
function extractFieldSnapshots(fields, typeMapper) {
|
package/dist/sync.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as TColumnDiff, F as TDbDefaultValue, L as TDbFieldMeta,
|
|
2
|
-
import { c as AtscriptQueryFieldRef$1, i as AtscriptDbView, l as AtscriptQueryNode$1, t as DbSpace } from "./db-space-
|
|
1
|
+
import { E as TColumnDiff, F as TDbDefaultValue, Ht as TGenericLogger, L as TDbFieldMeta, Pt as AtscriptDbReadable, R as TDbForeignKey, W as TDbObjectKind, Y as TDbStorageType, it as TExistingTableOption, mt as TReferencingForeignKey, nt as TExistingColumn, pt as TPrimaryKeyChange, rt as TExistingForeignKey, tt as TEnsureTableOptions, vt as TTableOptionDiff } from "./buckets-Bo2IcPZ_.cjs";
|
|
2
|
+
import { c as AtscriptQueryFieldRef$1, i as AtscriptDbView, l as AtscriptQueryNode$1, t as DbSpace } from "./db-space-DtGx5HIC.cjs";
|
|
3
3
|
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
4
4
|
|
|
5
5
|
//#region src/schema/sync-entry.d.ts
|
package/dist/sync.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as TColumnDiff, F as TDbDefaultValue, L as TDbFieldMeta,
|
|
2
|
-
import { c as AtscriptQueryFieldRef$1, i as AtscriptDbView, l as AtscriptQueryNode$1, t as DbSpace } from "./db-space-
|
|
1
|
+
import { E as TColumnDiff, F as TDbDefaultValue, Ht as TGenericLogger, L as TDbFieldMeta, Pt as AtscriptDbReadable, R as TDbForeignKey, W as TDbObjectKind, Y as TDbStorageType, it as TExistingTableOption, mt as TReferencingForeignKey, nt as TExistingColumn, pt as TPrimaryKeyChange, rt as TExistingForeignKey, tt as TEnsureTableOptions, vt as TTableOptionDiff } from "./buckets-Bys2QXyk.mjs";
|
|
2
|
+
import { c as AtscriptQueryFieldRef$1, i as AtscriptDbView, l as AtscriptQueryNode$1, t as DbSpace } from "./db-space-grfuZcPR.mjs";
|
|
3
3
|
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
4
4
|
|
|
5
5
|
//#region src/schema/sync-entry.d.ts
|
package/dist/sync.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as NoopLogger } from "./db-view-
|
|
1
|
+
import { U as NoopLogger } from "./db-view-B64IpZ2j.mjs";
|
|
2
2
|
//#region src/schema/schema-hash.ts
|
|
3
3
|
/** Extracts sorted field snapshots from a readable's field descriptors. */
|
|
4
4
|
function extractFieldSnapshots(fields, typeMapper) {
|