@atscript/moost-db 0.1.148 → 0.1.150
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/index.cjs +843 -269
- package/dist/index.d.cts +178 -19
- package/dist/index.d.mts +178 -19
- package/dist/index.mjs +845 -271
- package/package.json +12 -12
package/dist/index.d.mts
CHANGED
|
@@ -6,6 +6,12 @@ import { parseUrl } from "@uniqu/url";
|
|
|
6
6
|
import { AggregateFn, AtscriptDbReadable, AtscriptDbTable, BucketUnit, FilterExpr, FlatOf, TCrudOp, TCrudOp as TCrudOp$1, TCrudPermissions, TCrudPermissions as TCrudPermissions$1, TDbActionInfo, TDbActionInfo as TDbActionInfo$1, TDbActionIntent, TDbActionIntent as TDbActionIntent$1, TDbActionLevel, TDbActionLevel as TDbActionLevel$1, TDbActionProcessor, TDbActionTargetSummary, TDbActionTargetSummary as TDbActionTargetSummary$1, TDbAvailableActions, TDbAvailableActions as TDbAvailableActions$1, TDbFieldMeta, TDbRemoveGuardContext, TDbRemoveGuardContext as TDbRemoveGuardContext$1, TDbWriteAction, TDbWriteAction as TDbWriteAction$1, TDbWriteCheckContext, TDbWriteCheckContext as TDbWriteCheckContext$1, TDbWriteGuardContext, TDbWriteGuardContext as TDbWriteGuardContext$1, TFilterPredicate, TIdResolveOptions, TIdentification, TMetaResponse, TQueryPathOp, TQueryPathOp as TQueryPathOp$1, TQueryPathRefs, TQueryPathSource, Uniquery, UniqueryControls, collectQueryPaths } from "@atscript/db";
|
|
7
7
|
import { EventContext } from "@wooksjs/event-core";
|
|
8
8
|
|
|
9
|
+
//#region src/http-path.d.ts
|
|
10
|
+
/** The published path of every model one app serves (`null`: mounted, published nowhere). */
|
|
11
|
+
interface THttpPathScope {
|
|
12
|
+
readonly paths: ReadonlyMap<TAtscriptAnnotatedType, string | null>;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
9
15
|
//#region src/as-readable.controller.d.ts
|
|
10
16
|
/**
|
|
11
17
|
* Endpoint a {@link AsReadableController.prepareRequest} call serves. `/one`
|
|
@@ -89,8 +95,9 @@ interface TDbParsedRequest {
|
|
|
89
95
|
* Abstract base class for read-only HTTP controllers over an Atscript interface.
|
|
90
96
|
*
|
|
91
97
|
* Shared responsibilities (implemented here):
|
|
92
|
-
* -
|
|
93
|
-
*
|
|
98
|
+
* - Publishes `@db.http.path` (the model's value-help URL) per app after
|
|
99
|
+
* `app.init()`, derived from each controller's own bound route (see
|
|
100
|
+
* `docs/http/index.md`); the constructor only records which model it serves.
|
|
94
101
|
* - Lazily serializes the bound interface for the `/meta` endpoint
|
|
95
102
|
* (see {@link getSerializeOptions}).
|
|
96
103
|
* - Provides DTO-backed validators for the Uniquery controls DTOs and the
|
|
@@ -120,23 +127,44 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
|
|
|
120
127
|
protected app: Moost;
|
|
121
128
|
/** Cached serialized type definition (lazy, computed on first access). */
|
|
122
129
|
private _serializedType?;
|
|
130
|
+
/** App scope every cache below was built for; a different scope drops them all ({@link enterScope}). */
|
|
131
|
+
private _cacheScope?;
|
|
132
|
+
/** Scope of the synchronous build in flight — instance-local, cleared in `finally`. */
|
|
133
|
+
protected _buildScope?: THttpPathScope;
|
|
123
134
|
/** Cached full meta response (computed lazily on first meta() call). */
|
|
124
135
|
private _metaResponse?;
|
|
125
136
|
/** {@link metaCacheKey} the cached response was built for. */
|
|
126
137
|
private _metaResponseKey?;
|
|
127
138
|
/** Cached serialized form schemas keyed by `FormType.name` — populated lazily by {@link metaForm}. */
|
|
128
139
|
private _formSchemas;
|
|
129
|
-
|
|
140
|
+
/**
|
|
141
|
+
* @param opts.canonical Multi-mount models only: marks (`true`) or excludes
|
|
142
|
+
* (`false`) this controller as the model's published value-help route
|
|
143
|
+
* (since 0.1.150). Decorator-bound controllers use the decorator option.
|
|
144
|
+
*/
|
|
145
|
+
constructor(boundType: T, controllerName: string, app: Moost, kindTag?: string, opts?: {
|
|
146
|
+
canonical?: boolean;
|
|
147
|
+
});
|
|
130
148
|
/**
|
|
131
149
|
* Subclass contract: return `true` if `path` addresses a field that exists
|
|
132
150
|
* AND is visible to the current request — see the DB controller's override
|
|
133
151
|
* for the full list of positions that consult it.
|
|
134
152
|
*/
|
|
135
153
|
protected abstract hasField(path: string): boolean;
|
|
136
|
-
/**
|
|
137
|
-
|
|
138
|
-
|
|
154
|
+
/**
|
|
155
|
+
* The app of the current event, through DI — never the one this
|
|
156
|
+
* (singleton) instance was constructed in, which may be gone (a re-booted
|
|
157
|
+
* app, a hot reload). Outside an event it is {@link app}.
|
|
158
|
+
*
|
|
159
|
+
* @since 0.1.150
|
|
160
|
+
*/
|
|
161
|
+
protected currentApp(): Promise<Moost>;
|
|
162
|
+
/** Lazily serializes the bound type (dropped with the other caches on a scope change). */
|
|
139
163
|
protected getSerializedType(): TSerializedAnnotatedType;
|
|
164
|
+
/** Drops every scope-dependent cache when `scope` is not the one they were built for. */
|
|
165
|
+
private enterScope;
|
|
166
|
+
/** Runs a synchronous build with `scope`'s `db.http.path` overrides applied. */
|
|
167
|
+
private buildScoped;
|
|
140
168
|
/**
|
|
141
169
|
* Serializes a type for the meta surfaces (`/meta`, `/meta/form/:name`)
|
|
142
170
|
* with {@link getSerializeOptions}, then re-points every reference chain to
|
|
@@ -145,6 +173,11 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
|
|
|
145
173
|
* serialize exactly as before.
|
|
146
174
|
*/
|
|
147
175
|
protected serializeForMeta(type: TAtscriptAnnotatedType): TSerializedAnnotatedType;
|
|
176
|
+
/**
|
|
177
|
+
* {@link getSerializeOptions} plus the current build's per-app `db.http.path`
|
|
178
|
+
* overrides (a subclass's own `annotationOverrides` entry wins for the same key).
|
|
179
|
+
*/
|
|
180
|
+
private _effectiveSerializeOptions;
|
|
148
181
|
/**
|
|
149
182
|
* One-time initialization hook. Override to seed data, register watchers, etc.
|
|
150
183
|
*/
|
|
@@ -282,6 +315,14 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
|
|
|
282
315
|
* response by principal.
|
|
283
316
|
*/
|
|
284
317
|
meta(): Promise<TMetaResponse>;
|
|
318
|
+
/**
|
|
319
|
+
* The root of a controller's own `/meta` carries its own mount as
|
|
320
|
+
* `db.http.path` (a secondary mount answers with its own route; references to
|
|
321
|
+
* the model elsewhere carry the canonical one). Left alone for parametric
|
|
322
|
+
* mounts and when the serialize options strip the key. Never mutates the
|
|
323
|
+
* cached envelope.
|
|
324
|
+
*/
|
|
325
|
+
private _withOwnHttpPath;
|
|
285
326
|
/**
|
|
286
327
|
* The `/meta` payload for the current request — the cached envelope
|
|
287
328
|
* through {@link applyMetaOverlay} — WITHOUT the `/meta` route's
|
|
@@ -385,6 +426,12 @@ type TDbQueryTargetOpts = boolean | {
|
|
|
385
426
|
* registered symbol, like `ACTION_OVERLAY`).
|
|
386
427
|
*/
|
|
387
428
|
declare const RESOLVE_TARGET: unique symbol;
|
|
429
|
+
/**
|
|
430
|
+
* `q` of {@link AsDbReadableController.resolveQuery}: a `GET /query` string, or a
|
|
431
|
+
* query-target envelope without `dryRun`.
|
|
432
|
+
* @since 0.1.149
|
|
433
|
+
*/
|
|
434
|
+
type TDbResolveQueryInput = string | Omit<TDbActionQueryTarget, "dryRun">;
|
|
388
435
|
/** What {@link RESOLVE_TARGET} resolves. */
|
|
389
436
|
interface TTargetRequest {
|
|
390
437
|
action: string;
|
|
@@ -400,6 +447,8 @@ interface TTargetRequest {
|
|
|
400
447
|
* rows); `"read"` — `transformFilter` (a view resolving rows it delegates).
|
|
401
448
|
*/
|
|
402
449
|
overlay: "action" | "read";
|
|
450
|
+
/** Identity fields to report the READ-visible subset of ({@link TResolvedTarget.visibleOf}). */
|
|
451
|
+
visibleOf?: readonly string[];
|
|
403
452
|
/** Fields of the phase-1 read (sorted by the first identification's fields). */
|
|
404
453
|
select: readonly string[];
|
|
405
454
|
/** Key sets `exclude` entries may use besides the controller's identifications. */
|
|
@@ -414,6 +463,8 @@ interface TResolvedTarget {
|
|
|
414
463
|
dryRun: boolean;
|
|
415
464
|
/** The validated `exclude` entries (already applied to {@link rows}). */
|
|
416
465
|
exclude: Record<string, unknown>[];
|
|
466
|
+
/** {@link TTargetRequest.visibleOf} filtered by the read's field visibility. */
|
|
467
|
+
visibleOf?: readonly string[];
|
|
417
468
|
/**
|
|
418
469
|
* The rows `ids` address that STILL match the target (filter, search,
|
|
419
470
|
* overlay, `queryTargetScope`, `exclude`), aligned with `ids`; `select`
|
|
@@ -940,6 +991,15 @@ declare class FieldCapabilityIndex implements TQueryPathSource {
|
|
|
940
991
|
}
|
|
941
992
|
//#endregion
|
|
942
993
|
//#region src/as-db-readable.controller.d.ts
|
|
994
|
+
/** Options of {@link AsDbReadableController.resolveQuery}. @since 0.1.149 */
|
|
995
|
+
interface TDbResolveQueryOpts<K extends string = string> {
|
|
996
|
+
/** Fields to return besides the identity. Gated like `/query` `$select` under `hasField`. */
|
|
997
|
+
select?: readonly K[];
|
|
998
|
+
/** Most rows (default 1000); `q.maxRows` can only lower it. */
|
|
999
|
+
cap?: number;
|
|
1000
|
+
/** Server-side restriction, ANDed in. Trusted: not gated, not shown to `prepareRequest`. */
|
|
1001
|
+
scope?: FilterExpr;
|
|
1002
|
+
}
|
|
943
1003
|
/** Read endpoint a {@link AsDbReadableController.decorateRows} call serves. */
|
|
944
1004
|
type TDbDecorateEndpoint = "query" | "pages" | "geo" | "one";
|
|
945
1005
|
/**
|
|
@@ -1168,7 +1228,9 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
|
|
|
1168
1228
|
* (`$vector`) or a geo index (`/geo`, `$index`) reading a hidden path
|
|
1169
1229
|
* answers exactly like a nonexistent index (400); a hidden DEFAULT text
|
|
1170
1230
|
* index falls back to the `@db.column.searchable` substring search over
|
|
1171
|
-
* visible fields (or ignores the term when there are none
|
|
1231
|
+
* visible fields (or ignores the term when there are none — on list
|
|
1232
|
+
* endpoints; query targets, delegated targets and {@link resolveQuery}
|
|
1233
|
+
* answer 400 `TARGET_INVALID` instead). A
|
|
1172
1234
|
* `@db.column.derived` field is visible only while its source path is,
|
|
1173
1235
|
* and one whose source is hidden is sealed out of every read projection
|
|
1174
1236
|
* for the request, like a `@db.writeOnly` field. The same holds for a
|
|
@@ -1281,6 +1343,11 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
|
|
|
1281
1343
|
private _searchIndexFieldPaths;
|
|
1282
1344
|
/** `@db.index.geo` indexes — their fields carry physical names, mapped back to logical paths. */
|
|
1283
1345
|
private _geoIndexFieldPaths;
|
|
1346
|
+
/**
|
|
1347
|
+
* The index visibility gate applies: {@link hasField} is overridden, or the
|
|
1348
|
+
* model has `@db.writeOnly` fields (never readable through a search hit).
|
|
1349
|
+
*/
|
|
1350
|
+
private get _indexGateActive();
|
|
1284
1351
|
/** Every path `entry` reads is visible to this request. */
|
|
1285
1352
|
private _indexVisible;
|
|
1286
1353
|
/**
|
|
@@ -1451,6 +1518,8 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
|
|
|
1451
1518
|
* {@link checkCapabilities}, {@link hasField}), where the client
|
|
1452
1519
|
* predicates' {@link transformRelationFilter} also runs: a query target
|
|
1453
1520
|
* never filters on, nor counts by, a field the caller can't read.
|
|
1521
|
+
* {@link resolveQuery} does not call it (there is no action of this
|
|
1522
|
+
* controller to scope).
|
|
1454
1523
|
*
|
|
1455
1524
|
* @since 0.1.147
|
|
1456
1525
|
*/
|
|
@@ -1567,12 +1636,55 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
|
|
|
1567
1636
|
* the first batch, which directly follows the snapshot.
|
|
1568
1637
|
*/
|
|
1569
1638
|
[RESOLVE_TARGET](req: TTargetRequest): Promise<TResolvedTarget>;
|
|
1639
|
+
/**
|
|
1640
|
+
* The shared resolver behind query targets and {@link resolveQuery}: the
|
|
1641
|
+
* query body validated, checked and run as a READ of this controller, then
|
|
1642
|
+
* ONE read of `select` ordered by `sort` — `filter (+ $search) ∧ overlay ∧
|
|
1643
|
+
* scope ∧ ¬exclude`, at most `cap + 1` rows. More than `cap` → 400
|
|
1644
|
+
* `TARGET_TOO_LARGE`; a count other than `expectCount` → 409
|
|
1645
|
+
* `TARGET_CHANGED`.
|
|
1646
|
+
*
|
|
1647
|
+
* Everything that depends on the read's visibility — the `$search`
|
|
1648
|
+
* fallback, the native-search memo, the un-appliable-term refusal and the
|
|
1649
|
+
* delegated identity — is computed INSIDE the read child, where the
|
|
1650
|
+
* permission layer's per-request state is the read's.
|
|
1651
|
+
*/
|
|
1652
|
+
private _resolveMatching;
|
|
1653
|
+
/**
|
|
1654
|
+
* Rows of THIS controller matching `q`, resolved as a READ of it for the
|
|
1655
|
+
* current event's caller (since 0.1.149) — from your own command, e.g. to
|
|
1656
|
+
* act on "every issue matching this search". `q` is a `GET /query` string
|
|
1657
|
+
* (`$search` / `$index` and a filter only) or a query-target envelope
|
|
1658
|
+
* `{ q, exclude?, expectCount?, maxRows? }` (no `dryRun`).
|
|
1659
|
+
*
|
|
1660
|
+
* The read runs under this controller's full read policy
|
|
1661
|
+
* ({@link prepareRequest} with `endpoint: "query"`, {@link hasField},
|
|
1662
|
+
* {@link validateControls}, the capability / index gate and the
|
|
1663
|
+
* {@link transformFilter} overlay) with the current event's identity.
|
|
1664
|
+
* Route interceptors and guards of the `query` route do not run; read
|
|
1665
|
+
* authorization belongs in {@link prepareRequest}. {@link queryTargetScope}
|
|
1666
|
+
* is not called. Hooks see no route params of the caller (only a call from
|
|
1667
|
+
* the routed event's own controller instance keeps its params); pass route-derived
|
|
1668
|
+
* restrictions as `opts.scope`. Joins the caller's open transaction.
|
|
1669
|
+
*
|
|
1670
|
+
* Rows are ordered by identity (`preferredId`, else the primary key) and
|
|
1671
|
+
* carry the identity fields plus `opts.select` (gated like `/query`
|
|
1672
|
+
* `$select`; `transformProjection` is not applied — hide fields with
|
|
1673
|
+
* {@link hasField}; decoration keys and navigation paths are refused). An
|
|
1674
|
+
* identity-less readable is ordered by `select` (each path sortable, else
|
|
1675
|
+
* `TARGET_INVALID`). More than `opts.cap` (default 1000) rows → 400
|
|
1676
|
+
* `TARGET_TOO_LARGE`; a count other than `expectCount` → 409
|
|
1677
|
+
* `TARGET_CHANGED`; a `$search` that can't be applied → 400
|
|
1678
|
+
* `TARGET_INVALID`. Must be awaited inside a running event handler.
|
|
1679
|
+
*/
|
|
1680
|
+
resolveQuery<K extends string = never>(q: TDbResolveQueryInput, opts?: TDbResolveQueryOpts<K>): Promise<Array<Pick<DataType, K & keyof DataType> & Record<string, unknown>>>;
|
|
1570
1681
|
/**
|
|
1571
1682
|
* Runs `fn` as a READ of this controller (since 0.1.147): in a child of
|
|
1572
1683
|
* the current event whose controller context is this controller's `query`
|
|
1573
1684
|
* handler, after `prepareRequest({ endpoint: "query", controls, filter })` — the
|
|
1574
1685
|
* request-scoped state a permission layer builds there (read grant, field
|
|
1575
|
-
* visibility) is the read's and stays in the child.
|
|
1686
|
+
* visibility) is the read's and stays in the child. `routeParams` (since
|
|
1687
|
+
* 0.1.149) replaces the route params the child's hooks read.
|
|
1576
1688
|
*/
|
|
1577
1689
|
private _asRead;
|
|
1578
1690
|
/**
|
|
@@ -1598,7 +1710,18 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
|
|
|
1598
1710
|
* with the existing filter. Applies only when native search does not serve
|
|
1599
1711
|
* the request (no native search, or — since 0.1.143 — its default index
|
|
1600
1712
|
* reads a field {@link hasField} hides) and the request isn't a vector
|
|
1601
|
-
* search (`$vector` consumes the term).
|
|
1713
|
+
* search (`$vector` consumes the term). Lenient on list endpoints: a term
|
|
1714
|
+
* nothing can apply is ignored. Resolvers (query targets, `resolveQuery`)
|
|
1715
|
+
* refuse it — a subclass override that applies the term must return a new
|
|
1716
|
+
* filter object.
|
|
1717
|
+
*
|
|
1718
|
+
* A string field matches when the term is a substring of its text; an
|
|
1719
|
+
* INTEGER field (`number.int` and its sizes, `@expect.int`,
|
|
1720
|
+
* `@db.default.increment`) when it is a substring of the number's decimal
|
|
1721
|
+
* text — `2946` finds `29461277` (since 0.1.150). To search numeric IDs
|
|
1722
|
+
* declare `@db.column.searchable` (fallback) or `@db.index.fulltext`
|
|
1723
|
+
* (native, exact number) on the integer field — override this hook only for
|
|
1724
|
+
* search rules the annotations cannot express.
|
|
1602
1725
|
*/
|
|
1603
1726
|
protected applySearchFallback(filter: FilterExpr | undefined, controls: Record<string, unknown>): FilterExpr | undefined;
|
|
1604
1727
|
/**
|
|
@@ -1621,6 +1744,21 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
|
|
|
1621
1744
|
* the same shape as the one this whole path exists to remove.
|
|
1622
1745
|
*/
|
|
1623
1746
|
private _aggregateControls;
|
|
1747
|
+
/**
|
|
1748
|
+
* `$count` of a native text / vector search: the adapter's own count, so it
|
|
1749
|
+
* agrees with `/query` and `/pages`. A text search counts every match (the
|
|
1750
|
+
* single returned row is discarded); a vector search counts the nearest
|
|
1751
|
+
* neighbours up to `$limit` (default 1000), as `/query` returns them.
|
|
1752
|
+
*/
|
|
1753
|
+
private _countSearched;
|
|
1754
|
+
/**
|
|
1755
|
+
* The controls a native search / vector read is run with: the request's
|
|
1756
|
+
* sealed controls (so every search control — `$fuzzy`, … — reaches the
|
|
1757
|
+
* adapter) plus the select, the threshold and the caller's paging. ONE
|
|
1758
|
+
* builder for `/query`, `/pages` and the native `$count`, so they can't
|
|
1759
|
+
* disagree about what a search matches.
|
|
1760
|
+
*/
|
|
1761
|
+
private _searchReadControls;
|
|
1624
1762
|
private _resolveReadStrategy;
|
|
1625
1763
|
/**
|
|
1626
1764
|
* Post-read row decoration hook. Not implemented by
|
|
@@ -1669,12 +1807,6 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
|
|
|
1669
1807
|
* when implemented.
|
|
1670
1808
|
*/
|
|
1671
1809
|
private _augmentAndDecorate;
|
|
1672
|
-
/**
|
|
1673
|
-
* The app of the current event, through DI — never the one this
|
|
1674
|
-
* (singleton) instance was constructed in, which may be gone (a re-booted
|
|
1675
|
-
* app, a hot reload).
|
|
1676
|
-
*/
|
|
1677
|
-
private _currentApp;
|
|
1678
1810
|
/** The class's `@DbActionsFrom` delegations, validated on first use (per app). */
|
|
1679
1811
|
private _delegations;
|
|
1680
1812
|
/**
|
|
@@ -2143,7 +2275,8 @@ declare class AsDbController<T extends TAtscriptAnnotatedType = TAtscriptAnnotat
|
|
|
2143
2275
|
* Bulk auto-lift: each item carries its own `version` → `$cas`.
|
|
2144
2276
|
* NOTE: per-item conflict disambiguation in the response body is deferred
|
|
2145
2277
|
* (§6.4) — the aggregate `{ matchedCount, modifiedCount }` surfaces partial
|
|
2146
|
-
* application; callers can detect mismatches via `
|
|
2278
|
+
* application; callers can detect mismatches via `matchedCount < N` (`modifiedCount` may
|
|
2279
|
+
* be lower for unchanged values, e.g. a version-exempt patch on MySQL / Mongo).
|
|
2147
2280
|
*/
|
|
2148
2281
|
private _resolveBulkCas;
|
|
2149
2282
|
/**
|
|
@@ -2275,7 +2408,9 @@ declare abstract class AsValueHelpController<T extends TAtscriptAnnotatedType =
|
|
|
2275
2408
|
protected readonly searchableFields: readonly string[];
|
|
2276
2409
|
/** The `@meta.id` field name on the bound interface, if any. */
|
|
2277
2410
|
protected readonly primaryKey: string | undefined;
|
|
2278
|
-
constructor(boundType: T, controllerName: string, app: Moost
|
|
2411
|
+
constructor(boundType: T, controllerName: string, app: Moost, opts?: {
|
|
2412
|
+
canonical?: boolean;
|
|
2413
|
+
});
|
|
2279
2414
|
/** Executes a value-help query against the backing source. */
|
|
2280
2415
|
protected abstract query(controls: ValueHelpQuery<DataType>): Promise<{
|
|
2281
2416
|
data: DataType[];
|
|
@@ -2413,7 +2548,9 @@ declare abstract class AsValueHelpController<T extends TAtscriptAnnotatedType =
|
|
|
2413
2548
|
declare class AsJsonValueHelpController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> extends AsValueHelpController<T, DataType> {
|
|
2414
2549
|
protected rows: DataType[];
|
|
2415
2550
|
private _pkIndex?;
|
|
2416
|
-
constructor(boundType: T, rows: DataType[], app: Moost, controllerName?: string
|
|
2551
|
+
constructor(boundType: T, rows: DataType[], app: Moost, controllerName?: string, opts?: {
|
|
2552
|
+
canonical?: boolean;
|
|
2553
|
+
});
|
|
2417
2554
|
protected query(controls: ValueHelpQuery<DataType>): Promise<{
|
|
2418
2555
|
data: DataType[];
|
|
2419
2556
|
count: number;
|
|
@@ -2552,6 +2689,16 @@ interface TReadableBindingMeta {
|
|
|
2552
2689
|
model?: TAtscriptAnnotatedType;
|
|
2553
2690
|
/** Resolves the readable — lazily for token/factory, identity for instance. */
|
|
2554
2691
|
resolve: () => AtscriptDbReadable<any>;
|
|
2692
|
+
/** The route prefix the decorator derived (`options.prefix`, `@db.http.path`, table name, …). @since 0.1.150 */
|
|
2693
|
+
prefix?: string;
|
|
2694
|
+
/**
|
|
2695
|
+
* Where {@link prefix} came from: the decorator's `prefix` option (or the
|
|
2696
|
+
* factory form), the model's own `@db.http.path`, or its table / view name.
|
|
2697
|
+
* @since 0.1.150
|
|
2698
|
+
*/
|
|
2699
|
+
prefixSource?: "option" | "annotation" | "name";
|
|
2700
|
+
/** The decorator's `canonical` option. @since 0.1.150 */
|
|
2701
|
+
canonical?: boolean;
|
|
2555
2702
|
}
|
|
2556
2703
|
/**
|
|
2557
2704
|
* Class- and method-level metadata written by `@atscript/moost-db`'s
|
|
@@ -2684,6 +2831,18 @@ interface TControllerBindingOptions {
|
|
|
2684
2831
|
* annotation. Ignored for instance/factory bindings.
|
|
2685
2832
|
*/
|
|
2686
2833
|
space?: string;
|
|
2834
|
+
/**
|
|
2835
|
+
* Marks (`true`) or excludes (`false`) this controller as the one whose route
|
|
2836
|
+
* is published as the model's value-help path (`db.http.path`) when the same
|
|
2837
|
+
* model is served by several controllers in one app. A single `canonical: true`
|
|
2838
|
+
* mount wins; `canonical: false` mounts are never published; without a marker
|
|
2839
|
+
* the model's own `@db.http.path`-derived mount breaks ties, and any remaining
|
|
2840
|
+
* ambiguity leaves the path unset (with a boot warning). Parametric mounts
|
|
2841
|
+
* (`:param` / `*` segments) are never published.
|
|
2842
|
+
*
|
|
2843
|
+
* @since 0.1.150
|
|
2844
|
+
*/
|
|
2845
|
+
canonical?: boolean;
|
|
2687
2846
|
}
|
|
2688
2847
|
/**
|
|
2689
2848
|
* Combines the boilerplate needed to turn an {@link AsDbController}
|
|
@@ -3419,4 +3578,4 @@ declare const REL_FILTER_CLIENT_MAX_DEPTH = 3;
|
|
|
3419
3578
|
*/
|
|
3420
3579
|
declare const REL_FILTER_CLIENT_MAX_NODES = 8;
|
|
3421
3580
|
//#endregion
|
|
3422
|
-
export { ActionDisabledError, type ActionDisabledErrorBody, ActionTargetError, type ActionTargetErrorBody, AsDbController, AsDbReadableController, AsJsonValueHelpController, AsReadableController, AsValueHelpController, type AtscriptDbMate, type AtscriptDbMeta, type AtscriptDbParamsMeta, DB_CRUD_HANDLERS, DEFAULT_DB_SPACE, DbAction, DbActionDefault, type DbActionEnvelope, DbActionID, DbActionIDs, type DbActionOpts, DbActionRow, DbActionRows, DbActionTarget, DbActions, DbActionsFrom, DbDecorations, DbRowActions, DbRowsActions, DbTableActions, FieldCapabilityIndex, type IdValidationSource, InputForm, ONE_CONTROLS, PAGES_CONTROLS, QUERY_CONTROLS, READABLE_DEF, REL_FILTER_CLIENT_MAX_DEPTH, REL_FILTER_CLIENT_MAX_NODES, ReadableController, TABLE_DEF, type TActionTargetErrorCode, TAssertExposedOptions, type TCapabilityReadable, type TCapabilityVerdict, TControllerBindingOptions, type TCrudOp, type TCrudPermissions, type TDbActionDisabledVerdict, type TDbActionEnvelope, type TDbActionInfo, type TDbActionInputFormMeta, type TDbActionIntent, type TDbActionLevel, type TDbActionMeta, type TDbActionParamKind, type TDbActionProcessor, type TDbActionQueryTarget, type TDbActionScopeContext, type TDbActionScopePurpose, type TDbActionTarget, type TDbActionTargetSummary, type TDbActionsEntry, type TDbActionsEntryUnpinned, type TDbActionsFromMeta, type TDbActionsFromOpts, type TDbAvailableActions, type TDbClassActionMeta, TDbControlsType, TDbDecorateContext, TDbDecorateEndpoint, type TDbDecorationsOpts, TDbFieldVisibility, TDbIndexFieldPaths, TDbParsedRequest, type TDbQueryTargetOpts, type TDbRemoveGuardContext, TDbRequestContext, TDbRequestEndpoint, type TDbRowIdInput, type TDbRowIdPurpose, type TDbRowIdsContext, type TDbWriteAction, type TDbWriteCheckContext, type TDbWriteGuardContext, type TFieldCapability, type TGateOp, type THttpErrorEntry, type TQueryPathOp, type TQueryPathRefs, TReadableBinding, type TReadableBindingMeta, type TTerminalRef, TableController, UseValidationErrorTransform, VALUE_HELP_CRUD_HANDLERS, ValueHelpQuery, ValueHelpSelect, ViewController, applyTerminalRefs, assertExposed, badRequest, clearDbSpaces, closeDbSpaces, collectQueryPaths, dbActionBodySlot, dbActionInputSlot, discoverActions, discoverRowLevelActions, errorEnvelope, findReadableBinding, getAtscriptDbMate, getControllerFormType, getDbEndpoint, hasActionDelegations, perRow, provideDbSpace, resolveBoundReadable, resolveDbSpace, resolveProp, resolveTerminalRef, unknownRelationError, useDbActionId, useDbActionIds, useDbActionInput, useDbActionRow, useDbActionRows, useDbActionTarget, validationErrorTransform };
|
|
3581
|
+
export { ActionDisabledError, type ActionDisabledErrorBody, ActionTargetError, type ActionTargetErrorBody, AsDbController, AsDbReadableController, AsJsonValueHelpController, AsReadableController, AsValueHelpController, type AtscriptDbMate, type AtscriptDbMeta, type AtscriptDbParamsMeta, DB_CRUD_HANDLERS, DEFAULT_DB_SPACE, DbAction, DbActionDefault, type DbActionEnvelope, DbActionID, DbActionIDs, type DbActionOpts, DbActionRow, DbActionRows, DbActionTarget, DbActions, DbActionsFrom, DbDecorations, DbRowActions, DbRowsActions, DbTableActions, FieldCapabilityIndex, type IdValidationSource, InputForm, ONE_CONTROLS, PAGES_CONTROLS, QUERY_CONTROLS, READABLE_DEF, REL_FILTER_CLIENT_MAX_DEPTH, REL_FILTER_CLIENT_MAX_NODES, ReadableController, TABLE_DEF, type TActionTargetErrorCode, TAssertExposedOptions, type TCapabilityReadable, type TCapabilityVerdict, TControllerBindingOptions, type TCrudOp, type TCrudPermissions, type TDbActionDisabledVerdict, type TDbActionEnvelope, type TDbActionInfo, type TDbActionInputFormMeta, type TDbActionIntent, type TDbActionLevel, type TDbActionMeta, type TDbActionParamKind, type TDbActionProcessor, type TDbActionQueryTarget, type TDbActionScopeContext, type TDbActionScopePurpose, type TDbActionTarget, type TDbActionTargetSummary, type TDbActionsEntry, type TDbActionsEntryUnpinned, type TDbActionsFromMeta, type TDbActionsFromOpts, type TDbAvailableActions, type TDbClassActionMeta, TDbControlsType, TDbDecorateContext, TDbDecorateEndpoint, type TDbDecorationsOpts, TDbFieldVisibility, TDbIndexFieldPaths, TDbParsedRequest, type TDbQueryTargetOpts, type TDbRemoveGuardContext, TDbRequestContext, TDbRequestEndpoint, type TDbResolveQueryInput, TDbResolveQueryOpts, type TDbRowIdInput, type TDbRowIdPurpose, type TDbRowIdsContext, type TDbWriteAction, type TDbWriteCheckContext, type TDbWriteGuardContext, type TFieldCapability, type TGateOp, type THttpErrorEntry, type TQueryPathOp, type TQueryPathRefs, TReadableBinding, type TReadableBindingMeta, type TTerminalRef, TableController, UseValidationErrorTransform, VALUE_HELP_CRUD_HANDLERS, ValueHelpQuery, ValueHelpSelect, ViewController, applyTerminalRefs, assertExposed, badRequest, clearDbSpaces, closeDbSpaces, collectQueryPaths, dbActionBodySlot, dbActionInputSlot, discoverActions, discoverRowLevelActions, errorEnvelope, findReadableBinding, getAtscriptDbMate, getControllerFormType, getDbEndpoint, hasActionDelegations, perRow, provideDbSpace, resolveBoundReadable, resolveDbSpace, resolveProp, resolveTerminalRef, unknownRelationError, useDbActionId, useDbActionIds, useDbActionInput, useDbActionRow, useDbActionRows, useDbActionTarget, validationErrorTransform };
|