@atscript/moost-db 0.1.150 → 0.1.152

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.d.cts CHANGED
@@ -6,6 +6,33 @@ import { Mate, Moost, TConsoleBase, TMateParamMeta, TMoostMetadata } from "moost
6
6
  import { parseUrl } from "@uniqu/url";
7
7
  import { EventContext } from "@wooksjs/event-core";
8
8
 
9
+ //#region src/meta/meta-cache.d.ts
10
+ /**
11
+ * `/meta` identity memo (since 0.1.151). Each layer that turns the cached
12
+ * envelope into a request's `/meta` object memoizes its output per INPUT
13
+ * identity and per the request-dependent answers it reads (the key), so
14
+ * equal inputs give the same object across requests. The final object is
15
+ * then registered with wooks' `prerenderJson` (JSON serialized once, weak
16
+ * ETag from the bytes).
17
+ *
18
+ * Soundness: a memoized object is never mutated (the `applyMetaOverlay`
19
+ * contract), so its identity implies its bytes; every key covers every
20
+ * request-dependent input its layer reads. Inputs that are not themselves
21
+ * stable (an overlay that builds a fresh object per request) are not memoized —
22
+ * their output is computed per request, as before, and gets no ETag.
23
+ */
24
+ /** Memoized variants per input object, then per key — one per controller instance. */
25
+ type TMetaVariants = WeakMap<object, Map<string, object>>;
26
+ /**
27
+ * Marks a `/meta` payload your override memoizes (an `applyMetaOverlay`
28
+ * variant, a `metaForm` projection) as reusable: it is deep-frozen and, when
29
+ * served again, sent from its serialized-once JSON with an `ETag`. Return the
30
+ * same object for the same inputs only — its bytes are fixed from now on.
31
+ *
32
+ * @since 0.1.151
33
+ */
34
+ declare function stableMeta<T extends object>(obj: T): T;
35
+ //#endregion
9
36
  //#region src/http-path.d.ts
10
37
  /** The published path of every model one app serves (`null`: mounted, published nowhere). */
11
38
  interface THttpPathScope {
@@ -76,6 +103,18 @@ interface TDbRequestContext {
76
103
  */
77
104
  readonly onConflict?: "ignore";
78
105
  }
106
+ /**
107
+ * HTTP caching of `GET /meta` and `GET /meta/form/:name` — see
108
+ * {@link AsReadableController.metaHttpCaching}.
109
+ *
110
+ * @since 0.1.151
111
+ */
112
+ interface TDbMetaHttpCaching {
113
+ /** `Cache-Control` value (default `"private, no-cache"`); not set when the response already has one. */
114
+ cacheControl?: string;
115
+ /** Request headers the response varies by, merged into `Vary` (default `["Authorization", "Cookie"]`). */
116
+ vary?: readonly string[];
117
+ }
79
118
  /** Control DTO a {@link AsReadableController.validateControls} call checks against. @since 0.1.143 (`"geo"`) */
80
119
  type TDbControlsType = "query" | "pages" | "getOne" | "geo";
81
120
  /**
@@ -137,6 +176,12 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
137
176
  private _metaResponseKey?;
138
177
  /** Cached serialized form schemas keyed by `FormType.name` — populated lazily by {@link metaForm}. */
139
178
  private _formSchemas;
179
+ /**
180
+ * @internal Memoized `/meta` variants of this controller (own mount path,
181
+ * index visibility, decorations, delegated actions) — per input object, then
182
+ * per layer-prefixed key; see `meta/meta-cache.ts`.
183
+ */
184
+ protected readonly _metaVariants: TMetaVariants;
140
185
  /**
141
186
  * @param opts.canonical Multi-mount models only: marks (`true`) or excludes
142
187
  * (`false`) this controller as the model's published value-help route
@@ -313,8 +358,38 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
313
358
  * static envelope is cached (rebuilt when {@link metaCacheKey} changes);
314
359
  * {@link applyMetaOverlay} runs per request so subclasses can prune the
315
360
  * response by principal.
361
+ *
362
+ * Since 0.1.151 the response is HTTP-cacheable ({@link metaHttpCaching}):
363
+ * `Cache-Control: private, no-cache`, `Vary: Authorization, Cookie` and —
364
+ * when the payload is the same object as for an earlier request with the
365
+ * same inputs — a weak `ETag` computed from the serialized bytes, so a
366
+ * matching `If-None-Match` answers `304 Not Modified`. The JSON is then
367
+ * serialized once, not per request.
316
368
  */
317
369
  meta(): Promise<TMetaResponse>;
370
+ /**
371
+ * HTTP caching of `GET /meta` and `GET /meta/form/:name` (since 0.1.151).
372
+ * Default `{}`: `Cache-Control: private, no-cache` (kept when the response
373
+ * already carries one), `Vary: Authorization, Cookie` (merged into an
374
+ * existing `Vary`), and a weak `ETag` from the response bytes with `304`
375
+ * on a matching `If-None-Match`. Return `false` to send none of it (the
376
+ * pre-0.1.151 response), or override the header values — e.g.
377
+ * `{ cacheControl: "no-store" }` for deployments where no browser may keep
378
+ * a copy.
379
+ *
380
+ * The `ETag` is a hash of the final bytes, computed after every overlay:
381
+ * a request whose principal sees a different `/meta` gets a different tag
382
+ * (a `200`), so a `304` only ever confirms the bytes the client already
383
+ * holds. A refused request (`prepareRequest` throwing) is answered with its
384
+ * error, never `304`.
385
+ */
386
+ protected metaHttpCaching(): TDbMetaHttpCaching | false;
387
+ /**
388
+ * Applies {@link metaHttpCaching} to the current response and — when `body`
389
+ * is identity-stable (a cached / memoized object) — registers it for
390
+ * prerendering with an ETag (deep-frozen in dev / test).
391
+ */
392
+ private _serveMeta;
318
393
  /**
319
394
  * The root of a controller's own `/meta` carries its own mount as
320
395
  * `db.http.path` (a secondary mount answers with its own route; references to
@@ -323,6 +398,8 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
323
398
  * cached envelope.
324
399
  */
325
400
  private _withOwnHttpPath;
401
+ /** {@link _withOwnHttpPath} for the mount `own`. */
402
+ private _ownHttpPathOf;
326
403
  /**
327
404
  * The `/meta` payload for the current request — the cached envelope
328
405
  * through {@link applyMetaOverlay} — WITHOUT the `/meta` route's
@@ -386,6 +463,12 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
386
463
  * composables). The cached envelope MUST NOT be mutated — see
387
464
  * `docs/http/permissions.md` for the full contract, including the
388
465
  * "discoverability only" caveat.
466
+ *
467
+ * `/meta`'s serialize-once memo and `ETag` (since 0.1.151) need a stable
468
+ * object: return the envelope itself when nothing changes, or memoize your
469
+ * outputs and return them through `stableMeta()` (deep-freezes and marks
470
+ * them) — never mutate one afterwards. A fresh object per request is
471
+ * correct, just served without an `ETag`.
389
472
  */
390
473
  protected applyMetaOverlay(meta: TMetaResponse): TMetaResponse | Promise<TMetaResponse>;
391
474
  }
@@ -1106,6 +1189,8 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
1106
1189
  */
1107
1190
  protected get capabilities(): FieldCapabilityIndex;
1108
1191
  private _capabilities?;
1192
+ /** The adapter answers {@link capabilities} last confirmed its index against (identity fast path). */
1193
+ private _capabilityInputs?;
1109
1194
  /** The client relational-predicate gate (since 0.1.147), built on first use — see {@link _relationGate}. */
1110
1195
  private _relGate?;
1111
1196
  /**
@@ -1136,6 +1221,12 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
1136
1221
  private readonly _derivedSource;
1137
1222
  /** `@db.writeOnly` paths of `$with` target readables, collected once per target. */
1138
1223
  private readonly _targetWriteOnly;
1224
+ /** The forced exclusion `$select` per sealed set (see {@link _sealSelect}). */
1225
+ private readonly _exclusionBySealed;
1226
+ /** The objects of {@link _exclusionBySealed}. */
1227
+ private readonly _forcedExclusions;
1228
+ /** {@link widenPreferredIdProjection} of each forced exclusion. */
1229
+ private readonly _widenedExclusions;
1139
1230
  /** Own leaf paths per readable (bound + `$with` targets), see {@link _leavesOf}. */
1140
1231
  private readonly _targetLeaves;
1141
1232
  private _indexFieldPathsCache?;
@@ -1261,6 +1352,10 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
1261
1352
  filter?: FilterExpr;
1262
1353
  controls?: object;
1263
1354
  }): HttpError | undefined;
1355
+ /** {@link checkCapabilities} reusing `refs` (the walk it makes) when the method is not overridden. */
1356
+ private _checkCapabilitiesWith;
1357
+ /** The walk of the `parsed` in flight, handed to {@link checkCapabilities} (sync, cleared after). */
1358
+ private _sharedRefs?;
1264
1359
  /**
1265
1360
  * The core's shared normalizer of `$select` computed entries
1266
1361
  * (`normalizeComputedSelect`) as a 400 with the core's wording and `path`
@@ -1377,6 +1472,8 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
1377
1472
  * `@db.column.searchable` fallback when any of its fields is visible).
1378
1473
  */
1379
1474
  private _applyIndexVisibility;
1475
+ /** {@link _applyIndexVisibility} for the given answers. */
1476
+ private _narrowIndexVisibility;
1380
1477
  /**
1381
1478
  * Compute an embedding vector from a search term.
1382
1479
  * Override in subclass to integrate with your embedding provider (OpenAI, etc.).
@@ -1541,6 +1638,12 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
1541
1638
  * read endpoint then passes to {@link _runReadWithActions}.
1542
1639
  */
1543
1640
  private _projectRead;
1641
+ /**
1642
+ * {@link widenPreferredIdProjection} of a sealed `$select` — memoized for the
1643
+ * forced exclusion of a read without `$select` (one object per sealed set,
1644
+ * see {@link _sealSelect}): its widening depends on the controller alone.
1645
+ */
1646
+ private _widenSealed;
1544
1647
  private widenPreferredIdProjection;
1545
1648
  private _widenArrayProjection;
1546
1649
  private _widenMapProjection;
@@ -2555,6 +2658,13 @@ declare class AsJsonValueHelpController<T extends TAtscriptAnnotatedType = TAtsc
2555
2658
  data: DataType[];
2556
2659
  count: number;
2557
2660
  }>;
2661
+ /**
2662
+ * `field`'s lowercased values by position in {@link rows} (the `$search`
2663
+ * haystack). An entry is used only while the row still holds the value it
2664
+ * was lowercased from (`src`), so rows edited in place stay correct.
2665
+ */
2666
+ private _lowercased;
2667
+ private _haystack?;
2558
2668
  protected getOne(id: string | number): Promise<DataType | null>;
2559
2669
  /**
2560
2670
  * Ports the value-help `$sort` grammar to the shared engine's `{ field: 1 |
@@ -3578,4 +3688,4 @@ declare const REL_FILTER_CLIENT_MAX_DEPTH = 3;
3578
3688
  */
3579
3689
  declare const REL_FILTER_CLIENT_MAX_NODES = 8;
3580
3690
  //#endregion
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 };
3691
+ 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, TDbMetaHttpCaching, 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, stableMeta, unknownRelationError, useDbActionId, useDbActionIds, useDbActionInput, useDbActionRow, useDbActionRows, useDbActionTarget, validationErrorTransform };
package/dist/index.d.mts CHANGED
@@ -6,6 +6,33 @@ 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/meta/meta-cache.d.ts
10
+ /**
11
+ * `/meta` identity memo (since 0.1.151). Each layer that turns the cached
12
+ * envelope into a request's `/meta` object memoizes its output per INPUT
13
+ * identity and per the request-dependent answers it reads (the key), so
14
+ * equal inputs give the same object across requests. The final object is
15
+ * then registered with wooks' `prerenderJson` (JSON serialized once, weak
16
+ * ETag from the bytes).
17
+ *
18
+ * Soundness: a memoized object is never mutated (the `applyMetaOverlay`
19
+ * contract), so its identity implies its bytes; every key covers every
20
+ * request-dependent input its layer reads. Inputs that are not themselves
21
+ * stable (an overlay that builds a fresh object per request) are not memoized —
22
+ * their output is computed per request, as before, and gets no ETag.
23
+ */
24
+ /** Memoized variants per input object, then per key — one per controller instance. */
25
+ type TMetaVariants = WeakMap<object, Map<string, object>>;
26
+ /**
27
+ * Marks a `/meta` payload your override memoizes (an `applyMetaOverlay`
28
+ * variant, a `metaForm` projection) as reusable: it is deep-frozen and, when
29
+ * served again, sent from its serialized-once JSON with an `ETag`. Return the
30
+ * same object for the same inputs only — its bytes are fixed from now on.
31
+ *
32
+ * @since 0.1.151
33
+ */
34
+ declare function stableMeta<T extends object>(obj: T): T;
35
+ //#endregion
9
36
  //#region src/http-path.d.ts
10
37
  /** The published path of every model one app serves (`null`: mounted, published nowhere). */
11
38
  interface THttpPathScope {
@@ -76,6 +103,18 @@ interface TDbRequestContext {
76
103
  */
77
104
  readonly onConflict?: "ignore";
78
105
  }
106
+ /**
107
+ * HTTP caching of `GET /meta` and `GET /meta/form/:name` — see
108
+ * {@link AsReadableController.metaHttpCaching}.
109
+ *
110
+ * @since 0.1.151
111
+ */
112
+ interface TDbMetaHttpCaching {
113
+ /** `Cache-Control` value (default `"private, no-cache"`); not set when the response already has one. */
114
+ cacheControl?: string;
115
+ /** Request headers the response varies by, merged into `Vary` (default `["Authorization", "Cookie"]`). */
116
+ vary?: readonly string[];
117
+ }
79
118
  /** Control DTO a {@link AsReadableController.validateControls} call checks against. @since 0.1.143 (`"geo"`) */
80
119
  type TDbControlsType = "query" | "pages" | "getOne" | "geo";
81
120
  /**
@@ -137,6 +176,12 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
137
176
  private _metaResponseKey?;
138
177
  /** Cached serialized form schemas keyed by `FormType.name` — populated lazily by {@link metaForm}. */
139
178
  private _formSchemas;
179
+ /**
180
+ * @internal Memoized `/meta` variants of this controller (own mount path,
181
+ * index visibility, decorations, delegated actions) — per input object, then
182
+ * per layer-prefixed key; see `meta/meta-cache.ts`.
183
+ */
184
+ protected readonly _metaVariants: TMetaVariants;
140
185
  /**
141
186
  * @param opts.canonical Multi-mount models only: marks (`true`) or excludes
142
187
  * (`false`) this controller as the model's published value-help route
@@ -313,8 +358,38 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
313
358
  * static envelope is cached (rebuilt when {@link metaCacheKey} changes);
314
359
  * {@link applyMetaOverlay} runs per request so subclasses can prune the
315
360
  * response by principal.
361
+ *
362
+ * Since 0.1.151 the response is HTTP-cacheable ({@link metaHttpCaching}):
363
+ * `Cache-Control: private, no-cache`, `Vary: Authorization, Cookie` and —
364
+ * when the payload is the same object as for an earlier request with the
365
+ * same inputs — a weak `ETag` computed from the serialized bytes, so a
366
+ * matching `If-None-Match` answers `304 Not Modified`. The JSON is then
367
+ * serialized once, not per request.
316
368
  */
317
369
  meta(): Promise<TMetaResponse>;
370
+ /**
371
+ * HTTP caching of `GET /meta` and `GET /meta/form/:name` (since 0.1.151).
372
+ * Default `{}`: `Cache-Control: private, no-cache` (kept when the response
373
+ * already carries one), `Vary: Authorization, Cookie` (merged into an
374
+ * existing `Vary`), and a weak `ETag` from the response bytes with `304`
375
+ * on a matching `If-None-Match`. Return `false` to send none of it (the
376
+ * pre-0.1.151 response), or override the header values — e.g.
377
+ * `{ cacheControl: "no-store" }` for deployments where no browser may keep
378
+ * a copy.
379
+ *
380
+ * The `ETag` is a hash of the final bytes, computed after every overlay:
381
+ * a request whose principal sees a different `/meta` gets a different tag
382
+ * (a `200`), so a `304` only ever confirms the bytes the client already
383
+ * holds. A refused request (`prepareRequest` throwing) is answered with its
384
+ * error, never `304`.
385
+ */
386
+ protected metaHttpCaching(): TDbMetaHttpCaching | false;
387
+ /**
388
+ * Applies {@link metaHttpCaching} to the current response and — when `body`
389
+ * is identity-stable (a cached / memoized object) — registers it for
390
+ * prerendering with an ETag (deep-frozen in dev / test).
391
+ */
392
+ private _serveMeta;
318
393
  /**
319
394
  * The root of a controller's own `/meta` carries its own mount as
320
395
  * `db.http.path` (a secondary mount answers with its own route; references to
@@ -323,6 +398,8 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
323
398
  * cached envelope.
324
399
  */
325
400
  private _withOwnHttpPath;
401
+ /** {@link _withOwnHttpPath} for the mount `own`. */
402
+ private _ownHttpPathOf;
326
403
  /**
327
404
  * The `/meta` payload for the current request — the cached envelope
328
405
  * through {@link applyMetaOverlay} — WITHOUT the `/meta` route's
@@ -386,6 +463,12 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
386
463
  * composables). The cached envelope MUST NOT be mutated — see
387
464
  * `docs/http/permissions.md` for the full contract, including the
388
465
  * "discoverability only" caveat.
466
+ *
467
+ * `/meta`'s serialize-once memo and `ETag` (since 0.1.151) need a stable
468
+ * object: return the envelope itself when nothing changes, or memoize your
469
+ * outputs and return them through `stableMeta()` (deep-freezes and marks
470
+ * them) — never mutate one afterwards. A fresh object per request is
471
+ * correct, just served without an `ETag`.
389
472
  */
390
473
  protected applyMetaOverlay(meta: TMetaResponse): TMetaResponse | Promise<TMetaResponse>;
391
474
  }
@@ -1106,6 +1189,8 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
1106
1189
  */
1107
1190
  protected get capabilities(): FieldCapabilityIndex;
1108
1191
  private _capabilities?;
1192
+ /** The adapter answers {@link capabilities} last confirmed its index against (identity fast path). */
1193
+ private _capabilityInputs?;
1109
1194
  /** The client relational-predicate gate (since 0.1.147), built on first use — see {@link _relationGate}. */
1110
1195
  private _relGate?;
1111
1196
  /**
@@ -1136,6 +1221,12 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
1136
1221
  private readonly _derivedSource;
1137
1222
  /** `@db.writeOnly` paths of `$with` target readables, collected once per target. */
1138
1223
  private readonly _targetWriteOnly;
1224
+ /** The forced exclusion `$select` per sealed set (see {@link _sealSelect}). */
1225
+ private readonly _exclusionBySealed;
1226
+ /** The objects of {@link _exclusionBySealed}. */
1227
+ private readonly _forcedExclusions;
1228
+ /** {@link widenPreferredIdProjection} of each forced exclusion. */
1229
+ private readonly _widenedExclusions;
1139
1230
  /** Own leaf paths per readable (bound + `$with` targets), see {@link _leavesOf}. */
1140
1231
  private readonly _targetLeaves;
1141
1232
  private _indexFieldPathsCache?;
@@ -1261,6 +1352,10 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
1261
1352
  filter?: FilterExpr;
1262
1353
  controls?: object;
1263
1354
  }): HttpError | undefined;
1355
+ /** {@link checkCapabilities} reusing `refs` (the walk it makes) when the method is not overridden. */
1356
+ private _checkCapabilitiesWith;
1357
+ /** The walk of the `parsed` in flight, handed to {@link checkCapabilities} (sync, cleared after). */
1358
+ private _sharedRefs?;
1264
1359
  /**
1265
1360
  * The core's shared normalizer of `$select` computed entries
1266
1361
  * (`normalizeComputedSelect`) as a 400 with the core's wording and `path`
@@ -1377,6 +1472,8 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
1377
1472
  * `@db.column.searchable` fallback when any of its fields is visible).
1378
1473
  */
1379
1474
  private _applyIndexVisibility;
1475
+ /** {@link _applyIndexVisibility} for the given answers. */
1476
+ private _narrowIndexVisibility;
1380
1477
  /**
1381
1478
  * Compute an embedding vector from a search term.
1382
1479
  * Override in subclass to integrate with your embedding provider (OpenAI, etc.).
@@ -1541,6 +1638,12 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
1541
1638
  * read endpoint then passes to {@link _runReadWithActions}.
1542
1639
  */
1543
1640
  private _projectRead;
1641
+ /**
1642
+ * {@link widenPreferredIdProjection} of a sealed `$select` — memoized for the
1643
+ * forced exclusion of a read without `$select` (one object per sealed set,
1644
+ * see {@link _sealSelect}): its widening depends on the controller alone.
1645
+ */
1646
+ private _widenSealed;
1544
1647
  private widenPreferredIdProjection;
1545
1648
  private _widenArrayProjection;
1546
1649
  private _widenMapProjection;
@@ -2555,6 +2658,13 @@ declare class AsJsonValueHelpController<T extends TAtscriptAnnotatedType = TAtsc
2555
2658
  data: DataType[];
2556
2659
  count: number;
2557
2660
  }>;
2661
+ /**
2662
+ * `field`'s lowercased values by position in {@link rows} (the `$search`
2663
+ * haystack). An entry is used only while the row still holds the value it
2664
+ * was lowercased from (`src`), so rows edited in place stay correct.
2665
+ */
2666
+ private _lowercased;
2667
+ private _haystack?;
2558
2668
  protected getOne(id: string | number): Promise<DataType | null>;
2559
2669
  /**
2560
2670
  * Ports the value-help `$sort` grammar to the shared engine's `{ field: 1 |
@@ -3578,4 +3688,4 @@ declare const REL_FILTER_CLIENT_MAX_DEPTH = 3;
3578
3688
  */
3579
3689
  declare const REL_FILTER_CLIENT_MAX_NODES = 8;
3580
3690
  //#endregion
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 };
3691
+ 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, TDbMetaHttpCaching, 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, stableMeta, unknownRelationError, useDbActionId, useDbActionIds, useDbActionInput, useDbActionRow, useDbActionRows, useDbActionTarget, validationErrorTransform };