@atscript/db 0.1.132 → 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-BvoYYQ2Q.d.cts → buckets-Bo2IcPZ_.d.cts} +74 -21
- package/dist/{buckets-D2XPrwSC.d.mts → buckets-Bys2QXyk.d.mts} +74 -21
- package/dist/{db-space-BQQEgB3d.d.mts → db-space-DtGx5HIC.d.cts} +6 -4
- package/dist/{db-space-Cslq5Dux.d.cts → db-space-grfuZcPR.d.mts} +6 -4
- package/dist/{db-view-DVGWWhA3.mjs → db-view-B64IpZ2j.mjs} +163 -60
- package/dist/{db-view-CuFAhzwF.cjs → db-view-pgm2dHIo.cjs} +180 -59
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +65 -7
- package/dist/index.d.mts +65 -7
- package/dist/index.mjs +2 -2
- 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 +3 -3
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
|
|
@@ -460,10 +481,11 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
460
481
|
* `resolveCalendarBuckets`: shapes, unit, zone, alias, grouping)
|
|
461
482
|
* - Plain fields in $select are a subset of $groupBy
|
|
462
483
|
* - When dimensions/measures are defined (strict mode): $groupBy fields
|
|
463
|
-
* must be dimensions
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
* adapter's calendar-bucket units
|
|
484
|
+
* must be dimensions, aggregate $field values must be measures (or '*')
|
|
485
|
+
* - the path guard (a bucket source must pass `bucketSourceVerdict` —
|
|
486
|
+
* timestamp type, no JSON ancestor, a dimension in strict mode, an
|
|
487
|
+
* adapter with calendar buckets) and the adapter's calendar-bucket units
|
|
488
|
+
* (`BUCKET_NOT_SUPPORTED`)
|
|
467
489
|
*
|
|
468
490
|
* Translates field names, delegates to adapter.aggregate(),
|
|
469
491
|
* then reverse-maps and applies fromStorage formatters on results.
|
|
@@ -566,17 +588,20 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
566
588
|
* same identification resolution as {@link findById}. Public so callers can
|
|
567
589
|
* AND-combine the id-filter with a row-level read overlay before issuing
|
|
568
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}.
|
|
569
593
|
*/
|
|
570
|
-
resolveIdFilter(id: unknown): FilterExpr | null;
|
|
594
|
+
resolveIdFilter(id: unknown, opts?: TIdResolveOptions): FilterExpr | null;
|
|
571
595
|
/**
|
|
572
596
|
* Resolve an id value into a filter expression.
|
|
573
597
|
*
|
|
574
598
|
* When `preferredId` differs from the PK, scalar ids resolve only against
|
|
575
599
|
* the preferred field (deterministic addressing). Otherwise scalars try PK
|
|
576
600
|
* + every single-field unique index; objects try PK + compound unique
|
|
577
|
-
* indexes.
|
|
601
|
+
* indexes. With `opts.isFieldVisible`, only the identifications
|
|
602
|
+
* {@link identificationsVisibleTo} keeps are tried.
|
|
578
603
|
*/
|
|
579
|
-
protected _resolveIdFilter(id: unknown): FilterExpr | null;
|
|
604
|
+
protected _resolveIdFilter(id: unknown, opts?: TIdResolveOptions): FilterExpr | null;
|
|
580
605
|
/** Build a single-key filter from `idObj` over `fields`, or null if any field is missing/incompatible. */
|
|
581
606
|
private _tryCompoundFilter;
|
|
582
607
|
/**
|
|
@@ -1390,6 +1415,7 @@ declare class TableMetadata {
|
|
|
1390
1415
|
physicalNames: ReadonlySet<string>;
|
|
1391
1416
|
private _built;
|
|
1392
1417
|
private _identifications?;
|
|
1418
|
+
private _alwaysAddressable?;
|
|
1393
1419
|
private _collateMap;
|
|
1394
1420
|
private _columnFromMap;
|
|
1395
1421
|
constructor(nestedObjects: boolean);
|
|
@@ -1486,6 +1512,12 @@ declare class TableMetadata {
|
|
|
1486
1512
|
private _buildIdentifications;
|
|
1487
1513
|
/** Legitimate row-identifier shapes — primary key first, then each unique index. */
|
|
1488
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>;
|
|
1489
1521
|
private _resolvePreferredId;
|
|
1490
1522
|
}
|
|
1491
1523
|
//#endregion
|
|
@@ -2113,8 +2145,13 @@ interface TTouchManyOptions {
|
|
|
2113
2145
|
*/
|
|
2114
2146
|
require?: "all" | "any";
|
|
2115
2147
|
}
|
|
2116
|
-
/**
|
|
2117
|
-
|
|
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 {
|
|
2118
2155
|
/** Nested-relation write recursion limit (default 3). */
|
|
2119
2156
|
maxDepth?: number;
|
|
2120
2157
|
/**
|
|
@@ -2127,8 +2164,8 @@ interface TWriteOptions<Row = Record<string, unknown>> {
|
|
|
2127
2164
|
*/
|
|
2128
2165
|
guard?: TDbWriteGuard<Row>;
|
|
2129
2166
|
}
|
|
2130
|
-
/** Options of `deleteOne`. */
|
|
2131
|
-
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 {
|
|
2132
2169
|
/**
|
|
2133
2170
|
* Validated-stage guard (since 0.1.128): invoked inside the table's
|
|
2134
2171
|
* transaction after the id resolved to a filter and before cascade /
|
|
@@ -2136,6 +2173,17 @@ interface TDeleteOptions<Row = Record<string, unknown>> {
|
|
|
2136
2173
|
*/
|
|
2137
2174
|
guard?: TDbRemoveGuard<Row>;
|
|
2138
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
|
+
}
|
|
2139
2187
|
/**
|
|
2140
2188
|
* Adds `null` to every optional property of `O`. Optional columns store SQL
|
|
2141
2189
|
* NULL / Mongo null, and the runtime validator accepts `null` for optional
|
|
@@ -2184,10 +2232,12 @@ interface TBucketFieldSource {
|
|
|
2184
2232
|
* moost-db's HTTP gate — so both layers answer with the same wording.
|
|
2185
2233
|
* Everything downstream (`collectQueryPaths`, the field mappers,
|
|
2186
2234
|
* `UniquSelect`, adapters) assumes normalized input and does not re-check.
|
|
2187
|
-
* - **
|
|
2188
|
-
* filterability
|
|
2189
|
-
*
|
|
2190
|
-
*
|
|
2235
|
+
* - **The source field** (encryption, JSON ancestor, timestamp type,
|
|
2236
|
+
* physical filterability, strict-mode dimension, an adapter with calendar
|
|
2237
|
+
* buckets) is `bucketSourceVerdict` — ONE function, called by the path
|
|
2238
|
+
* guard (`guardPath` op `bucket`) and by moost-db's capability index, so
|
|
2239
|
+
* `/meta.fields[P].bucketable` and the core cannot disagree.
|
|
2240
|
+
* - **The unit** (`calendarBucketUnits()` lacks it) is `guardAggregate`'s
|
|
2191
2241
|
* (`BUCKET_NOT_SUPPORTED`); SQL builders only re-assert the inlined
|
|
2192
2242
|
* literals (defense in depth).
|
|
2193
2243
|
*
|
|
@@ -2200,11 +2250,14 @@ declare function resolveCalendarBuckets(controls: {
|
|
|
2200
2250
|
$groupBy?: unknown;
|
|
2201
2251
|
} | undefined, fields: TBucketFieldSource, aggregate?: boolean): ResolvedBucket[];
|
|
2202
2252
|
/**
|
|
2203
|
-
* Whether a field
|
|
2204
|
-
* `integer` leaf carrying the `timestamp` tag
|
|
2205
|
-
* `.created`, `.updated`) that is not
|
|
2206
|
-
* declaration — no annotation opts a field
|
|
2207
|
-
*
|
|
2253
|
+
* Whether a field's TYPE allows it to be the source of a calendar bucket: a
|
|
2254
|
+
* `number` / `integer` leaf carrying the `timestamp` tag
|
|
2255
|
+
* (`number.timestamp`, `.created`, `.updated`) that is not
|
|
2256
|
+
* `@db.encrypted`. The type is the declaration — no annotation opts a field
|
|
2257
|
+
* in.
|
|
2258
|
+
*
|
|
2259
|
+
* @deprecated since 0.1.133 — the type rule alone; use `bucketSourceVerdict`,
|
|
2260
|
+
* the full bucket-source rule the core and moost-db apply.
|
|
2208
2261
|
*/
|
|
2209
2262
|
declare function isBucketableField(fd: TDbFieldMeta): boolean;
|
|
2210
2263
|
/**
|
|
@@ -2221,4 +2274,4 @@ declare function isJsonValueField(fd: TDbFieldMeta): boolean;
|
|
|
2221
2274
|
*/
|
|
2222
2275
|
declare function jsonValueAncestor(path: string, jsonValueParents: ReadonlySet<string>): string | undefined;
|
|
2223
2276
|
//#endregion
|
|
2224
|
-
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
|
|
@@ -460,10 +481,11 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
460
481
|
* `resolveCalendarBuckets`: shapes, unit, zone, alias, grouping)
|
|
461
482
|
* - Plain fields in $select are a subset of $groupBy
|
|
462
483
|
* - When dimensions/measures are defined (strict mode): $groupBy fields
|
|
463
|
-
* must be dimensions
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
* adapter's calendar-bucket units
|
|
484
|
+
* must be dimensions, aggregate $field values must be measures (or '*')
|
|
485
|
+
* - the path guard (a bucket source must pass `bucketSourceVerdict` —
|
|
486
|
+
* timestamp type, no JSON ancestor, a dimension in strict mode, an
|
|
487
|
+
* adapter with calendar buckets) and the adapter's calendar-bucket units
|
|
488
|
+
* (`BUCKET_NOT_SUPPORTED`)
|
|
467
489
|
*
|
|
468
490
|
* Translates field names, delegates to adapter.aggregate(),
|
|
469
491
|
* then reverse-maps and applies fromStorage formatters on results.
|
|
@@ -566,17 +588,20 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
566
588
|
* same identification resolution as {@link findById}. Public so callers can
|
|
567
589
|
* AND-combine the id-filter with a row-level read overlay before issuing
|
|
568
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}.
|
|
569
593
|
*/
|
|
570
|
-
resolveIdFilter(id: unknown): FilterExpr | null;
|
|
594
|
+
resolveIdFilter(id: unknown, opts?: TIdResolveOptions): FilterExpr | null;
|
|
571
595
|
/**
|
|
572
596
|
* Resolve an id value into a filter expression.
|
|
573
597
|
*
|
|
574
598
|
* When `preferredId` differs from the PK, scalar ids resolve only against
|
|
575
599
|
* the preferred field (deterministic addressing). Otherwise scalars try PK
|
|
576
600
|
* + every single-field unique index; objects try PK + compound unique
|
|
577
|
-
* indexes.
|
|
601
|
+
* indexes. With `opts.isFieldVisible`, only the identifications
|
|
602
|
+
* {@link identificationsVisibleTo} keeps are tried.
|
|
578
603
|
*/
|
|
579
|
-
protected _resolveIdFilter(id: unknown): FilterExpr | null;
|
|
604
|
+
protected _resolveIdFilter(id: unknown, opts?: TIdResolveOptions): FilterExpr | null;
|
|
580
605
|
/** Build a single-key filter from `idObj` over `fields`, or null if any field is missing/incompatible. */
|
|
581
606
|
private _tryCompoundFilter;
|
|
582
607
|
/**
|
|
@@ -1390,6 +1415,7 @@ declare class TableMetadata {
|
|
|
1390
1415
|
physicalNames: ReadonlySet<string>;
|
|
1391
1416
|
private _built;
|
|
1392
1417
|
private _identifications?;
|
|
1418
|
+
private _alwaysAddressable?;
|
|
1393
1419
|
private _collateMap;
|
|
1394
1420
|
private _columnFromMap;
|
|
1395
1421
|
constructor(nestedObjects: boolean);
|
|
@@ -1486,6 +1512,12 @@ declare class TableMetadata {
|
|
|
1486
1512
|
private _buildIdentifications;
|
|
1487
1513
|
/** Legitimate row-identifier shapes — primary key first, then each unique index. */
|
|
1488
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>;
|
|
1489
1521
|
private _resolvePreferredId;
|
|
1490
1522
|
}
|
|
1491
1523
|
//#endregion
|
|
@@ -2113,8 +2145,13 @@ interface TTouchManyOptions {
|
|
|
2113
2145
|
*/
|
|
2114
2146
|
require?: "all" | "any";
|
|
2115
2147
|
}
|
|
2116
|
-
/**
|
|
2117
|
-
|
|
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 {
|
|
2118
2155
|
/** Nested-relation write recursion limit (default 3). */
|
|
2119
2156
|
maxDepth?: number;
|
|
2120
2157
|
/**
|
|
@@ -2127,8 +2164,8 @@ interface TWriteOptions<Row = Record<string, unknown>> {
|
|
|
2127
2164
|
*/
|
|
2128
2165
|
guard?: TDbWriteGuard<Row>;
|
|
2129
2166
|
}
|
|
2130
|
-
/** Options of `deleteOne`. */
|
|
2131
|
-
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 {
|
|
2132
2169
|
/**
|
|
2133
2170
|
* Validated-stage guard (since 0.1.128): invoked inside the table's
|
|
2134
2171
|
* transaction after the id resolved to a filter and before cascade /
|
|
@@ -2136,6 +2173,17 @@ interface TDeleteOptions<Row = Record<string, unknown>> {
|
|
|
2136
2173
|
*/
|
|
2137
2174
|
guard?: TDbRemoveGuard<Row>;
|
|
2138
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
|
+
}
|
|
2139
2187
|
/**
|
|
2140
2188
|
* Adds `null` to every optional property of `O`. Optional columns store SQL
|
|
2141
2189
|
* NULL / Mongo null, and the runtime validator accepts `null` for optional
|
|
@@ -2184,10 +2232,12 @@ interface TBucketFieldSource {
|
|
|
2184
2232
|
* moost-db's HTTP gate — so both layers answer with the same wording.
|
|
2185
2233
|
* Everything downstream (`collectQueryPaths`, the field mappers,
|
|
2186
2234
|
* `UniquSelect`, adapters) assumes normalized input and does not re-check.
|
|
2187
|
-
* - **
|
|
2188
|
-
* filterability
|
|
2189
|
-
*
|
|
2190
|
-
*
|
|
2235
|
+
* - **The source field** (encryption, JSON ancestor, timestamp type,
|
|
2236
|
+
* physical filterability, strict-mode dimension, an adapter with calendar
|
|
2237
|
+
* buckets) is `bucketSourceVerdict` — ONE function, called by the path
|
|
2238
|
+
* guard (`guardPath` op `bucket`) and by moost-db's capability index, so
|
|
2239
|
+
* `/meta.fields[P].bucketable` and the core cannot disagree.
|
|
2240
|
+
* - **The unit** (`calendarBucketUnits()` lacks it) is `guardAggregate`'s
|
|
2191
2241
|
* (`BUCKET_NOT_SUPPORTED`); SQL builders only re-assert the inlined
|
|
2192
2242
|
* literals (defense in depth).
|
|
2193
2243
|
*
|
|
@@ -2200,11 +2250,14 @@ declare function resolveCalendarBuckets(controls: {
|
|
|
2200
2250
|
$groupBy?: unknown;
|
|
2201
2251
|
} | undefined, fields: TBucketFieldSource, aggregate?: boolean): ResolvedBucket[];
|
|
2202
2252
|
/**
|
|
2203
|
-
* Whether a field
|
|
2204
|
-
* `integer` leaf carrying the `timestamp` tag
|
|
2205
|
-
* `.created`, `.updated`) that is not
|
|
2206
|
-
* declaration — no annotation opts a field
|
|
2207
|
-
*
|
|
2253
|
+
* Whether a field's TYPE allows it to be the source of a calendar bucket: a
|
|
2254
|
+
* `number` / `integer` leaf carrying the `timestamp` tag
|
|
2255
|
+
* (`number.timestamp`, `.created`, `.updated`) that is not
|
|
2256
|
+
* `@db.encrypted`. The type is the declaration — no annotation opts a field
|
|
2257
|
+
* in.
|
|
2258
|
+
*
|
|
2259
|
+
* @deprecated since 0.1.133 — the type rule alone; use `bucketSourceVerdict`,
|
|
2260
|
+
* the full bucket-source rule the core and moost-db apply.
|
|
2208
2261
|
*/
|
|
2209
2262
|
declare function isBucketableField(fd: TDbFieldMeta): boolean;
|
|
2210
2263
|
/**
|
|
@@ -2221,4 +2274,4 @@ declare function isJsonValueField(fd: TDbFieldMeta): boolean;
|
|
|
2221
2274
|
*/
|
|
2222
2275
|
declare function jsonValueAncestor(path: string, jsonValueParents: ReadonlySet<string>): string | undefined;
|
|
2223
2276
|
//#endregion
|
|
2224
|
-
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`
|