@web-ts-toolkit/access-router 0.53.0 → 0.55.0

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.
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import mongoose from 'mongoose';
2
+ import mongoose, { Model, Schema } from 'mongoose';
3
3
  import express from 'express';
4
4
 
5
5
  interface BooleanObject {
@@ -24,6 +24,13 @@ declare class Permission {
24
24
  type Permissions = Permission;
25
25
  type AccessRouterPermissions = Permission;
26
26
 
27
+ /** Package-only, per-call output intent. Resolve defaults before any async admission. */
28
+
29
+ interface ModelServiceIntent {
30
+ readonly args: FindArgs;
31
+ readonly options: Omit<FindOptions & FindOneOptions, 'authorization'>;
32
+ }
33
+
27
34
  type OpenApiMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
28
35
  type OpenApiSchema = Record<string, unknown>;
29
36
  type OpenApiSchemaSource = unknown;
@@ -104,224 +111,6 @@ type OpenApiRouterOptions = Partial<OpenApiDocumentOptions> & {
104
111
  swaggerUiBundleUrl?: string;
105
112
  };
106
113
 
107
- type ModelReferenceMap = {
108
- [key: string]: string | ModelReferenceMap;
109
- };
110
- /**
111
- * Owner of global/model/data options, registered Mongoose models and OpenAPI routes.
112
- * Prefer createAccessRuntime() for a callable API with factories and bound setters;
113
- * its `.runtime` exposes this owner. A bare instance has no createRouter method.
114
- * Registries/configuration are isolated; the Mongoose jsonSchema extension is initialized
115
- * idempotently. The defaultRuntime additionally adopts process-global named models.
116
- */
117
- declare class AccessRuntime {
118
- private readonly allowGlobalModelLookup;
119
- constructor(options?: {
120
- allowGlobalModelLookup?: boolean;
121
- });
122
- private readonly globalOptions;
123
- private readonly defaultModelOptions;
124
- private readonly modelOptions;
125
- private readonly modelJsonSchemas;
126
- private readonly dataOptions;
127
- private readonly modelRefs;
128
- private readonly modelSubs;
129
- private readonly modelAtts;
130
- private readonly modelInstances;
131
- private readonly openApiRegistry;
132
- private openApiPathPrefix;
133
- registerModelInstance<TModel>(modelName: string, model: mongoose.Model<TModel>): void;
134
- hasModelInstance(modelName: string): boolean;
135
- getModelInstance<TModel = unknown>(modelName: string): mongoose.Model<TModel> | null;
136
- registerOpenApiRoute(route: OpenApiRouteDescriptor): void;
137
- /**
138
- * Compose OpenAPI paths while synchronously constructing mounted routers.
139
- * Prefixes apply before collision checks; prior descriptors and Express paths
140
- * are unchanged. Nested calls compose and the prior scope is restored even on
141
- * failure. The callback must finish registration synchronously (no async work).
142
- */
143
- withOpenApiPathPrefix<T>(prefix: string, build: () => T): T;
144
- /**
145
- * Enable strict OpenAPI collision detection for the remainder of this
146
- * runtime's lifetime. After this call, conflicting method/path
147
- * registrations and duplicate operationIds throw {@link OpenApiCollisionError}
148
- * instead of silently replacing. Existing already-registered routes are
149
- * not retroactively re-validated.
150
- */
151
- enableOpenApiCollisionDetection(): void;
152
- getOpenApiRoutes(): OpenApiRouteDescriptor[];
153
- clearOpenApiRoutes(): void;
154
- getOpenApiSpec(info: OpenApiDocumentOptions): {
155
- openapi: string;
156
- info: Omit<OpenApiDocumentOptions, "servers">;
157
- servers?: OpenApiDocumentOptions["servers"];
158
- paths: Record<string, Record<string, {
159
- [key: `x-${string}`]: unknown;
160
- operationId?: string;
161
- summary?: string;
162
- description?: string;
163
- tags?: string[];
164
- deprecated?: boolean;
165
- parameters?: OpenApiParameter[];
166
- requestBody?: {
167
- required?: boolean;
168
- content: Record<string, {
169
- schema: OpenApiSchema;
170
- }>;
171
- };
172
- responses: OpenApiResponses;
173
- }>>;
174
- };
175
- createBootstrapSnapshot(): {
176
- globalOptions: GlobalOptions;
177
- defaultModelOptions: DefaultModelRouterOptions;
178
- modelOptions: Record<string, ModelRouterOptions>;
179
- dataOptions: Record<string, DataRouterOptions>;
180
- modelInstances: Record<string, mongoose.Model<unknown>>;
181
- modelJsonSchemas: Record<string, Record<string, unknown>>;
182
- modelRefs: Record<string, ModelReferenceMap>;
183
- modelSubs: Record<string, string[]>;
184
- modelAtts: Record<string, string[]>;
185
- openApi: {
186
- routes: OpenApiRouteDescriptor[];
187
- options: Required<OpenApiRegistryOptions>;
188
- };
189
- };
190
- restoreBootstrapSnapshot(snapshot: ReturnType<AccessRuntime['createBootstrapSnapshot']>): void;
191
- /** Shallowly replace supplied global values; nested objects such as requestComplexity are not deep-merged. */
192
- setGlobalOptions(options: GlobalOptions): void;
193
- setGlobalOption<K extends keyof GlobalOptions>(key: K, value: GlobalOptions[K]): void;
194
- getGlobalOptions(): GlobalOptions;
195
- getGlobalOption<K extends keyof GlobalOptions>(key: K, defaultValue?: GlobalOptions[K]): GlobalOptions[K];
196
- /** Update model starting defaults shallowly; already-stored model values are not broadcast-replaced. */
197
- setDefaultModelOptions(options: DefaultModelRouterOptions): void;
198
- setDefaultModelOption<K extends keyof ExtendedDefaultModelRouterOptions>(key: K, value: ExtendedDefaultModelRouterOptions[K]): void;
199
- getDefaultModelOptions(): DefaultModelRouterOptions<unknown>;
200
- getDefaultModelOption<K extends keyof ExtendedDefaultModelRouterOptions>(key: K, defaultValue?: ExtendedDefaultModelRouterOptions[K]): ExtendedDefaultModelRouterOptions<unknown>[K];
201
- private createModelOptions;
202
- private getOrCreateModelOptions;
203
- /**
204
- * Assign `{ ...modelDefaults, ...storedOptions, ...options }` shallowly. A supplied
205
- * operationAccess/defaults object replaces that whole value. Defaults accept only
206
- * query/presentation settings; virtual configuration is validated before assignment.
207
- * Existing router.options remains its construction-time snapshot. Fresh model-service
208
- * calls capture the owner's current options/defaults; in-flight calls retain their snapshot.
209
- */
210
- setModelOptions<TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string, options: ModelRouterOptions<TModel, TVirtuals>): void;
211
- setModelOption<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>, TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string, key: K, value: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): void;
212
- /** Frozen stored snapshot, not fully resolved per-path defaults. Read again for current configuration. */
213
- getModelOptions<TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string): ModelRouterOptions<TModel, TVirtuals>;
214
- /**
215
- * Generic stored exact → parent.default → parent lookup; only undefined falls through.
216
- * The exact runtime-model-default path is the final fallback if the stored parent is
217
- * absent. This is not the route-specific variant-to-base resolver; use
218
- * getExactModelOption to inspect a variant including its exact model-default fallback.
219
- */
220
- getModelOption<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>, TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string, key: K | string, defaultValue?: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): ExtendedModelRouterOptions<TModel, TVirtuals>[K];
221
- /** Exact stored path, then the same runtime-model-default path; no parent/default or variant-to-base lookup. */
222
- getExactModelOption<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>, TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string, key: K | string): ExtendedModelRouterOptions<TModel, TVirtuals>[K];
223
- /**
224
- * List registered virtual leaf names for a scope (VIRT-01).
225
- * Scope containers (`{ sub }`) are not leaves. Inapplicable names are
226
- * still listed here; applicability is decided per-access by
227
- * {@link resolveVirtualDescriptor}. Request-controlled include collisions
228
- * are validated by VIRT-05, not guessed here.
229
- */
230
- getVirtualNames(modelName: string, scopePath?: string[]): string[];
231
- /**
232
- * Whether a field is a registered virtual leaf in a scope (VIRT-01).
233
- * Inapplicable registered names stay virtual (never persisted), even when
234
- * no getter applies for the current access. Containers and persisted
235
- * fields return false.
236
- */
237
- isVirtualField(modelName: string, fieldName: string, scopePath?: string[]): boolean;
238
- /**
239
- * Resolve an applicable virtual descriptor with exact → `.default` → bare
240
- * semantics (VIRT-01, VIRT-00A D1/D5). Returns `undefined` when no getter
241
- * applies for `access`. Crucially, an access-record object is NEVER
242
- * interpreted as a getter descriptor when the access is absent: an
243
- * inapplicable registered name stays virtual (excluded from persisted
244
- * projections, write admission, and DB sort/filter/distinct).
245
- * Shared record-level `dependsOn` is inherited when a leaf lacks its own.
246
- */
247
- resolveVirtualDescriptor(modelName: string, virtualName: string, access: string, scopePath?: string[]): {
248
- get: (...args: never[]) => unknown;
249
- dependsOn: string[];
250
- } | undefined;
251
- getModelNames(): string[];
252
- hasModel(modelName: string): boolean;
253
- getModelJsonSchema(modelName: string): Record<string, unknown>;
254
- private createDataOptions;
255
- private getOrCreateDataOptions;
256
- setDataOptions<TData = unknown>(dataName: string, options: DataRouterOptions<TData>): void;
257
- setDataOption<K extends keyof ExtendedDataRouterOptions<TData>, TData = unknown>(dataName: string, key: K, value: ExtendedDataRouterOptions<TData>[K]): void;
258
- getDataOptions<TData = unknown>(dataName: string): DataRouterOptions<TData>;
259
- /**
260
- * Reusable configured data view: plain containers are frozen; native properties
261
- * return detached mutable copies on access. Native identity is not stable.
262
- * Replacement leaves previously captured views on their original data version.
263
- */
264
- getDataSnapshot<TData = unknown>(dataName: string): readonly TData[];
265
- getDataOption<K extends keyof ExtendedDataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string, defaultValue?: ExtendedDataRouterOptions<TData>[K]): ExtendedDataRouterOptions<TData>[K];
266
- getExactDataOption<K extends keyof ExtendedDataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string): ExtendedDataRouterOptions<TData>[K];
267
- getDataNames(): string[];
268
- ensureModelMeta(modelName: string): void;
269
- getModelRef(modelName: string, refPath: string): string | null;
270
- getModelSub(modelName: string): string[];
271
- getModelAtt(modelName: string): string[];
272
- }
273
- declare const defaultRuntime: AccessRuntime;
274
-
275
- declare class DataCore {
276
- private req;
277
- private readonly requestRuntime;
278
- private caches;
279
- private cachedPermissions;
280
- constructor(req: AccessRouterBaseRequest);
281
- genIDFilter<TData = unknown>(dataName: string, id: string): Promise<Filter<TData>>;
282
- genFilter<TData = unknown>(dataName: string, access?: BaseFilterAccess, _filter?: Filter<TData>): Promise<Filter<TData>>;
283
- /** Request-schema allowlist, independent of doc values. No model hooks or backend elevation. */
284
- genAllowedFields(dataName: string, _doc: unknown, access: SelectAccess, options?: DataFieldOptions): Promise<string[]>;
285
- /** Request-only existing-value pick. No automatic identity/metadata retention; options default to {}. */
286
- pickAllowedFields<TDoc>(dataName: string, doc: TDoc, access: SelectAccess, options?: DataFieldOptions): Promise<TDoc>;
287
- /**
288
- * Request-only requested-token intersection. Omitted/null/empty/exclusion-only select
289
- * yields []; DataService then applies no extra projection after request trimming.
290
- * Named options default to {}; legacy elevation and positional arguments are removed.
291
- */
292
- genSelect(dataName: string, access: SelectAccess, targetFields?: Projection, options?: DataFieldOptions): Promise<string[]>;
293
- private fieldPermissionSchema;
294
- decorate<TDoc>(dataName: string, doc: TDoc, access: DecorateAccess, context?: DataHookContext): Promise<TDoc>;
295
- decorateAll<TDoc>(dataName: string, docs: TDoc[], access: DecorateAllAccess, context?: DataHookContext): Promise<TDoc[]>;
296
- getPermissions(): Permission;
297
- setPermissions(): Promise<void>;
298
- canActivate(routeGuard: Validation): Promise<boolean>;
299
- isAllowed(dataName: string, access: RouteGuardAccess | string): Promise<boolean>;
300
- /** Authorize route entry using explicit server-owned basic/advanced metadata. */
301
- isAllowedRoute(dataName: string, baseAccess: RouteGuardAccess | string, variant: RouteVariant): Promise<boolean>;
302
- getService<TData = unknown>(dataName: string): DataService<TData>;
303
- service<TData = unknown>(dataName: string): DataService<TData>;
304
- svc<TData = unknown>(dataName: string): DataService<TData>;
305
- private getGlobalPermissions;
306
- }
307
-
308
- declare const MIDDLEWARE: unique symbol;
309
- declare const DATA_MIDDLEWARE: unique symbol;
310
- declare const PERMISSIONS: unique symbol;
311
- declare const PERMISSION_KEYS: unique symbol;
312
-
313
- interface AccessRouterRequestExtensions {
314
- macl?: Core;
315
- dacl?: DataCore;
316
- [PERMISSIONS]?: AccessRouterPermissions;
317
- [PERMISSION_KEYS]?: string[];
318
- [MIDDLEWARE]?: unknown[] | unknown;
319
- [DATA_MIDDLEWARE]?: unknown[] | unknown;
320
- [key: string]: unknown;
321
- [key: symbol]: unknown;
322
- }
323
- type AccessRouterRequest = express.Request & AccessRouterRequestExtensions;
324
-
325
114
  /** Request-only list arguments: advanced body fields, or root-entry args; no per-call authorization. */
326
115
  interface PublicListArgs {
327
116
  select?: Projection;
@@ -501,50 +290,544 @@ interface CorrelatedIncludeBase {
501
290
  model: string;
502
291
  op: 'list' | 'read' | 'count';
503
292
  /**
504
- * Output-only field path. Must not equal, contain or descend from the receiving
505
- * model's documentPermissionField (default `_permissions`). The include tree is
506
- * preflighted before target persistence; violations return BadRequest.
293
+ * Output-only field path. Must not equal, contain or descend from the receiving
294
+ * model's documentPermissionField (default `_permissions`). The include tree is
295
+ * preflighted before target persistence; violations return BadRequest.
296
+ */
297
+ path: string;
298
+ args?: CorrelatedIncludeArgs;
299
+ options?: Record<string, never>;
300
+ }
301
+ /** Identifier read: exactly one of `id` / `filter` must be present. */
302
+ interface CorrelatedReadByIdInclude extends CorrelatedIncludeBase {
303
+ op: 'read';
304
+ id: string | ParentRef;
305
+ filter?: never;
306
+ }
307
+ interface CorrelatedReadByFilterInclude extends CorrelatedIncludeBase {
308
+ op: 'read';
309
+ filter: CorrelatedFilter;
310
+ id?: never;
311
+ }
312
+ interface CorrelatedListInclude extends CorrelatedIncludeBase {
313
+ op: 'list';
314
+ filter: CorrelatedFilter;
315
+ id?: never;
316
+ }
317
+ interface CorrelatedCountInclude extends CorrelatedIncludeBase {
318
+ op: 'count';
319
+ filter: CorrelatedFilter;
320
+ id?: never;
321
+ }
322
+ type CorrelatedInclude = CorrelatedReadByIdInclude | CorrelatedReadByFilterInclude | CorrelatedListInclude | CorrelatedCountInclude;
323
+ /** Related output cannot overwrite authorization metadata at any supported nested level. */
324
+ type Include = LegacyInclude | CorrelatedInclude;
325
+ type FindAccess = 'list' | 'read';
326
+ type PopulateAccess = 'list' | 'read';
327
+ interface Populate {
328
+ path: string;
329
+ select?: Projection;
330
+ match?: unknown;
331
+ access?: PopulateAccess;
332
+ }
333
+ interface SubPopulate {
334
+ path: string;
335
+ select?: Projection;
336
+ }
337
+
338
+ type MaybePromise<T> = T | Promise<T>;
339
+ type AccessRouterFieldKey<T> = [Extract<keyof T, string>] extends [never] ? string : Extract<keyof T, string>;
340
+ type IdentifierHook<TValue, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, id: string) => MaybePromise<Filter<TValue>>;
341
+ type GlobalPermissionValue = Record<string, boolean> | string[] | string | null | undefined;
342
+ type BaseFilterHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, permissions: AccessRouterPermissions) => MaybePromise<Filter | true | null | undefined>;
343
+ type OverrideFilterHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, filter: Filter, permissions: AccessRouterPermissions) => MaybePromise<Filter>;
344
+ type Hook<TValue, TContext, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, value: TValue, permissions: AccessRouterPermissions, context: TContext) => MaybePromise<TValue>;
345
+ type HookChain<TValue, TContext, TRequest extends AccessRouterRequest = AccessRouterRequest> = Hook<TValue, TContext, TRequest> | Array<Hook<TValue, TContext, TRequest>>;
346
+ type ValidateRule = boolean | unknown[];
347
+ type ValidateHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, allowedData: unknown, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<ValidateRule>;
348
+ type DocPermissionsHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, doc: unknown, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<Record<string, unknown>>;
349
+ type ChangeHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, previousValue: unknown, nextValue: unknown, changes: Change[], context: ModelHookContext) => MaybePromise<void>;
350
+ type DeleteHook<TValue = unknown, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, value: TValue, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<void>;
351
+ type DocumentHook<TValue, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, value: ModelDocument<TValue>, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<ModelDocument<TValue>>;
352
+ type DocumentHookChain<TValue, TRequest extends AccessRouterRequest = AccessRouterRequest> = DocumentHook<TValue, TRequest> | Array<DocumentHook<TValue, TRequest>>;
353
+ type ModelBaseFilterHook = BaseFilterHook<ModelRequest>;
354
+ type DataBaseFilterHook = BaseFilterHook<DataRequest>;
355
+ type ModelOverrideFilterHook = OverrideFilterHook<ModelRequest>;
356
+ type DataOverrideFilterHook = OverrideFilterHook<DataRequest>;
357
+ type ModelIdentifierHook<TValue = unknown> = IdentifierHook<TValue, ModelRequest>;
358
+ type DataIdentifierHook<TValue = unknown> = IdentifierHook<TValue, DataRequest>;
359
+ type ModelValidateHook = ValidateHook<ModelRequest>;
360
+ /**
361
+ * Request-user grants from untrimmed projected input. Declare private persisted inputs
362
+ * with alwaysSelectFields. Integrated output resolves once per document/access stage,
363
+ * independently of skim or metadata serialization; use the result's document handle
364
+ * for later picks after input/metadata trim. Backend grants do not forge user metadata.
365
+ */
366
+ type ModelDocPermissionsHook = DocPermissionsHook<ModelRequest>;
367
+ type ModelChangeHook = ChangeHook<ModelRequest>;
368
+ type ModelDocumentHook<TValue = unknown> = DocumentHookChain<TValue, ModelRequest>;
369
+ type ModelDeleteHook<TValue = unknown> = DeleteHook<ModelDocument<TValue>, ModelRequest>;
370
+ type ModelHook<TValue = unknown> = HookChain<TValue, ModelHookContext, ModelRequest>;
371
+ type ModelListHook<TValue = unknown> = HookChain<TValue[], ModelHookContext, ModelRequest>;
372
+ type DataHook<TValue = unknown> = HookChain<TValue, DataHookContext, DataRequest>;
373
+ type DataListHook<TValue = unknown> = HookChain<TValue[], DataHookContext, DataRequest>;
374
+ /**
375
+ * Supported per-access virtual getter keys (VIRT-00A D1/D5).
376
+ * `default` is a fallback access; `delete`/`distinct`/`count` are NOT
377
+ * virtual accesses and must be rejected at configuration time.
378
+ */
379
+ type ModelVirtualAccess = 'list' | 'create' | 'read' | 'update';
380
+ type ModelVirtualRecordAccess = 'default' | ModelVirtualAccess;
381
+ /**
382
+ * Scope-aware virtual getter context (VIRT-00A D2, frozen).
383
+ * Extends {@link ModelHookContext} with the receiving model, definition/
384
+ * permission `scopePath` (e.g. `[]` at root, `['contacts','sub']` for
385
+ * `contacts.sub.displayName`), and the three effective accesses. The
386
+ * initiating operation stays in `context.operation` and is never
387
+ * overwritten with fallback/effective visibility.
388
+ *
389
+ * Embedded outputs reuse the owning parent's internally computed grants with
390
+ * the scope's `permissionSchema.<field>.sub` rules; dedicated subdocument
391
+ * routes resolve grants from the raw parent lookup. Related (populate/
392
+ * include) targets finalize with the target model's own definitions,
393
+ * permissions, selection, and effective access before parent getters run.
394
+ * Declaration-scoped private inputs use the getter's fourth argument, never
395
+ * this context or its document-authorization metadata.
396
+ */
397
+ interface ModelVirtualContext extends ModelHookContext {
398
+ receivingModelName: string;
399
+ scopePath: string[];
400
+ virtualAccess: ModelVirtualAccess;
401
+ outputAccess: ModelVirtualAccess;
402
+ docPermissionsAccess: ModelVirtualAccess;
403
+ }
404
+ type IsUnknownVirtual<T> = unknown extends T ? ([keyof T] extends [never] ? true : false) : false;
405
+ /**
406
+ * Typed isolated persisted view for a virtual getter scope (VIRT-00A D3/D4).
407
+ * Known models use a partial read-only persisted view (never
408
+ * `Record<string, unknown>`); unknown/untyped models keep an explicit
409
+ * loose fallback. This first argument retains the ordinary persisted/local
410
+ * dependency and finalized-public-related view. `dependsOnPopulate` does not
411
+ * retype persisted ref IDs or add its automatically retained refs here.
412
+ */
413
+ type ModelVirtualDoc<TModel = unknown> = IsUnknownVirtual<TModel> extends true ? Readonly<Partial<Record<string, unknown>>> : [Extract<keyof TModel, string>] extends [never] ? Readonly<Partial<Record<string, unknown>>> : Readonly<Partial<TModel>>;
414
+ /**
415
+ * Server-owned, one-hop persisted input declaration. `path` is a scope-local
416
+ * ObjectId ref (scalar or 1D array) to a model already configured in this runtime.
417
+ * Embedded virtuals use their `.sub` scope's field, never a dotted source path.
418
+ * `select` uses Populate's string/array/1-or-minus-1 grammar; omitted/empty means
419
+ * all eligible static persisted fields. Target virtuals, metadata, dynamic paths
420
+ * and traversal through target refs are rejected. `_id` is included unless excluded.
421
+ * Static string refs must bind the actual same-connection ObjectId model; register
422
+ * its model instance AND options first. Validation is eager/atomic, including setters.
423
+ * This grants getter input fields only, not public population or output fields.
424
+ * Target operationAccess.read, overrideFilter.read and baseFilter.read still use
425
+ * the original actor's request authority/tenant scope, independently of ordinary
426
+ * populate match/access and authorization.related. Private target virtuals never run.
427
+ */
428
+ interface ModelVirtualPopulateDependency<TModel = unknown> {
429
+ /** Top-level ref relative to this virtual's scope; no dotted source paths. Retained automatically. */
430
+ path: AccessRouterFieldKey<TModel>;
431
+ /** Persisted target mask: string, string[], or 1/-1 object (not 0). Empty/omitted selects all eligible fields. */
432
+ select?: Projection;
433
+ }
434
+ type VirtualPopulateMap<TModel, TPopulated> = {
435
+ [K in keyof TPopulated]: K extends AccessRouterFieldKey<TModel> ? unknown : never;
436
+ };
437
+ type VirtualPopulatePartial<T> = T extends Date | RegExp | ArrayBuffer | ArrayBufferView | {
438
+ readonly _bsontype: string;
439
+ } ? T : T extends readonly (infer U)[] ? readonly VirtualPopulatePartial<U>[] : T extends object ? {
440
+ readonly [K in keyof T]?: VirtualPopulatePartial<T[K]>;
441
+ } : T;
442
+ type VirtualPopulateKnownValue<TSource, TTarget> = TSource extends readonly unknown[] ? readonly (VirtualPopulatePartial<TTarget> | null)[] : VirtualPopulatePartial<TTarget>;
443
+ type VirtualPopulateValue<TSource, TTarget> = unknown extends TSource ? VirtualPopulatePartial<TTarget> | readonly (VirtualPopulatePartial<TTarget> | null)[] | null : VirtualPopulateKnownValue<NonNullable<TSource>, TTarget> | null;
444
+ /**
445
+ * Declaration-scoped fourth getter input. Explicitly map source keys to target
446
+ * persisted shapes; IDs cannot infer a target model. Each key and target field
447
+ * may be missing, scalar misses are null, and arrays preserve null slots. Source
448
+ * cardinality determines the view (unknown sources permit scalar or array).
449
+ * Containers are deeply readonly/partial; native scalar types are preserved.
450
+ * Each getter/row/array slot receives isolated copies, including native mutable
451
+ * leaves. Native methods are not made immutable by this type. Hydrated and lean
452
+ * materialization can differ; this is not a JSON-value conversion promise.
453
+ * This annotation does not select fields or confer authority. No implicit transport
454
+ * to DTOs, hooks, handles or metadata; an authorized getter's deliberate return is output.
455
+ */
456
+ type ModelVirtualPopulateInputs<TModel = unknown, TPopulated extends VirtualPopulateMap<TModel, TPopulated> = Record<never, never>> = {
457
+ readonly [K in keyof TPopulated]?: VirtualPopulateValue<K extends keyof TModel ? TModel[K] : unknown, TPopulated[K]>;
458
+ };
459
+ /**
460
+ * Virtual getter signature (VIRT-00A D3/D4, frozen).
461
+ * Its first argument is an isolated plain-object snapshot of ordinary persisted/
462
+ * local-dependency inputs + finalized public related/embedded outputs for its scope.
463
+ * Sibling virtual values are not visible. Input mutations have no implicit effect
464
+ * on response data or lifecycle snapshots. Only the returned field value is committed;
465
+ * `undefined` omits the field; throws omit fail-closed. `this` is the
466
+ * model request. The optional fourth argument contains only this getter's
467
+ * declared private populated inputs; default it to `{}` or guard undefined.
468
+ * It is separate from `doc`, whose persisted/public-related typing is unchanged.
469
+ * The runtime supplies it (empty without a declaration); the empty default generic
470
+ * guesses no target shape. Optionality preserves legacy three-argument direct calls
471
+ * and callbacks. Absent source refs or unavailable target reads skip invocation;
472
+ * present null/empty refs and missing target rows yield null/[]/null array slots.
473
+ * Private values are not implicitly transported to output or authorization metadata;
474
+ * an authorized getter can deliberately return a computed value using them.
475
+ */
476
+ type ModelVirtualGetter<TModel = unknown, TValue = unknown, TPopulated extends VirtualPopulateMap<TModel, TPopulated> = Record<never, never>> = (this: ModelRequest, doc: ModelVirtualDoc<TModel>, permissions: AccessRouterPermissions, context: ModelVirtualContext, populated?: ModelVirtualPopulateInputs<TModel, TPopulated>) => MaybePromise<TValue | undefined>;
477
+ /**
478
+ * Leaf virtual descriptor: `{ get, dependsOn?, dependsOnPopulate? }`.
479
+ * `dependsOn` lists top-level persisted field names relative to the
480
+ * definition's scope (e.g. `['displayName']` inside `contacts.sub`, never
481
+ * `['contacts.sub.displayName']`). Dotted paths and virtual-to-virtual
482
+ * dependencies are rejected at configuration time.
483
+ *
484
+ * The getter runs after `toObject()`/lean normalization and after internal
485
+ * document-permissions computation, with global permissions available and
486
+ * before `decorate`/`decorateAll`/tasks. Only the returned field value is
487
+ * committed via document-aware helpers: `undefined` (or a throw) omits the
488
+ * field fail-closed and computed values never persist. Getters see an
489
+ * isolated plain-object view for both lean and hydrated results; mutating the
490
+ * input has no implicit effect on response data or lifecycle snapshots.
491
+ *
492
+ * Annotate a descriptor separately with `TPopulated` to type its private fourth
493
+ * getter argument, then assign it to ordinary `ModelVirtuals`. The optional
494
+ * generic never changes the persisted model, write types or public output.
495
+ * Use `populated = {}` or guard undefined to retain three-argument direct calls.
496
+ * See the shipped README's "Private populated dependencies" for registration,
497
+ * all three public reference shapes, target read/row gates and absence/error rules.
498
+ *
499
+ * @example
500
+ * ```ts
501
+ * import type { ModelVirtualDescriptor } from '@web-ts-toolkit/access-router';
502
+ * import type { Types } from 'mongoose';
503
+ * interface Order { total: number; account: Types.ObjectId | null; }
504
+ * interface Account { balance: number; creditLimit: number; }
505
+ * const descriptor: ModelVirtualDescriptor<Order, boolean, { account: Account }> = {
506
+ * dependsOn: ['total'],
507
+ * dependsOnPopulate: [{ path: 'account', select: ['balance', 'creditLimit'] }],
508
+ * get(doc, _permissions, _context, populated = {}) {
509
+ * const account = populated.account;
510
+ * if (doc.total === undefined || account?.balance === undefined || account.creditLimit === undefined)
511
+ * return undefined;
512
+ * return doc.total <= account.balance + account.creditLimit;
513
+ * },
514
+ * };
515
+ * ```
516
+ */
517
+ interface ModelVirtualDescriptor<TModel = unknown, TValue = unknown, TPopulated extends VirtualPopulateMap<TModel, TPopulated> = Record<never, never>> {
518
+ /** Only this return becomes virtual output; private inputs are not implicitly transported. */
519
+ get: ModelVirtualGetter<TModel, TValue, TPopulated>;
520
+ /** Local top-level persisted input names relative to the definition's scope. */
521
+ dependsOn?: Array<AccessRouterFieldKey<TModel>>;
522
+ /** Server-only private fourth-argument inputs; source refs retained automatically. `[]` clears a shared list. */
523
+ dependsOnPopulate?: ModelVirtualPopulateDependency<TModel>[];
524
+ }
525
+ /**
526
+ * Per-access virtual record (VIRT-01): `default` + `list`/`create`/`read`/
527
+ * `update` (NOT `delete`/`distinct`/`count`). Each present access holds a
528
+ * leaf descriptor or bare getter shorthand. An optional shared `dependsOn`
529
+ * supports the documented `{ dependsOn, read: getter }` shape; a leaf's own
530
+ * `dependsOn` wins over the shared list during resolution. `dependsOnPopulate`
531
+ * inherits independently by the same rule: undefined inherits, a defined leaf
532
+ * list replaces the shared list wholesale (including `[]`).
533
+ */
534
+ type ModelVirtualAccessRecord<TModel = unknown, TValue = unknown, TPopulated extends VirtualPopulateMap<TModel, TPopulated> = Record<never, never>> = {
535
+ default?: ModelVirtualDescriptor<TModel, TValue, TPopulated> | ModelVirtualGetter<TModel, TValue, TPopulated>;
536
+ list?: ModelVirtualDescriptor<TModel, TValue, TPopulated> | ModelVirtualGetter<TModel, TValue, TPopulated>;
537
+ create?: ModelVirtualDescriptor<TModel, TValue, TPopulated> | ModelVirtualGetter<TModel, TValue, TPopulated>;
538
+ read?: ModelVirtualDescriptor<TModel, TValue, TPopulated> | ModelVirtualGetter<TModel, TValue, TPopulated>;
539
+ update?: ModelVirtualDescriptor<TModel, TValue, TPopulated> | ModelVirtualGetter<TModel, TValue, TPopulated>;
540
+ dependsOn?: Array<AccessRouterFieldKey<TModel>>;
541
+ /** Shared private input list; each resolved getter gets only its own mask. A leaf's defined list replaces it. */
542
+ dependsOnPopulate?: ModelVirtualPopulateDependency<TModel>[];
543
+ };
544
+ /** Single virtual entry: bare getter, leaf descriptor, or per-access record. */
545
+ type ModelVirtualLeaf<TModel = unknown, TValue = unknown, TPopulated extends VirtualPopulateMap<TModel, TPopulated> = Record<never, never>> = ModelVirtualGetter<TModel, TValue, TPopulated> | ModelVirtualDescriptor<TModel, TValue, TPopulated> | ModelVirtualAccessRecord<TModel, TValue, TPopulated>;
546
+ type UnwrapVirtualArray<T> = T extends readonly (infer U)[] ? U : T;
547
+ /**
548
+ * Persisted sub-scope model for an embedded container field (VIRT-01).
549
+ * Unwraps arrays/nullable wrappers to the element/object type; unknown
550
+ * fields fall back to a loose record.
551
+ */
552
+ type VirtualSubModel<TModel, TField extends string> = TField extends keyof TModel ? UnwrapVirtualArray<NonNullable<TModel[TField]>> : Record<string, unknown>;
553
+ type LooseVirtualLeaf = ModelVirtualGetter<Record<string, unknown>, unknown> | ModelVirtualDescriptor<Record<string, unknown>, unknown> | ModelVirtualAccessRecord<Record<string, unknown>, unknown>;
554
+ type LooseVirtualSubEntry = LooseVirtualLeaf | {
555
+ sub?: Record<string, LooseVirtualLeaf | {
556
+ sub?: Record<string, LooseVirtualLeaf>;
557
+ }>;
558
+ };
559
+ /**
560
+ * Virtual definitions for a model scope (VIRT-01).
561
+ * Root leaves come from `TVirtuals` (strict: unknown persisted getter
562
+ * fields are type errors). Embedded containers mirror
563
+ * `permissionSchema.<field>.sub`: any persisted field may host a `sub`
564
+ * record whose leaves use the container's persisted sub-model view.
565
+ * Untyped models keep an explicit loose record fallback.
566
+ *
567
+ * Selected virtual outputs are optional (`Partial`): authorization, absent
568
+ * dependencies, `undefined`, and fail-closed errors can omit them. Virtual
569
+ * names are never added to persisted `Filter`, sort/distinct inputs, or
570
+ * client write types.
571
+ *
572
+ * @example End-to-end typed virtual (persisted `User` has no `fullAddress`):
573
+ * ```ts
574
+ * import acl from '@web-ts-toolkit/access-router';
575
+ * import type { SelectedPublicOutput } from '@web-ts-toolkit/access-router/advanced';
576
+ * interface User { name: string; address: string; }
577
+ * interface UserVirtuals { fullAddress: string; }
578
+ * const router = acl.createRouter<User, UserVirtuals>('User', {
579
+ * permissionSchema: {
580
+ * name: { read: true },
581
+ * address: { read: 'canViewAddress' },
582
+ * fullAddress: { read: 'canViewAddress' },
583
+ * },
584
+ * virtuals: {
585
+ * fullAddress: {
586
+ * dependsOn: ['address'],
587
+ * read: async function (doc) {
588
+ * if (doc.address === undefined) return undefined;
589
+ * return `addr:${doc.address}`;
590
+ * },
591
+ * },
592
+ * },
593
+ * });
594
+ * type Out = SelectedPublicOutput<User, ['name', 'fullAddress'], UserVirtuals>;
595
+ * const out: Out = { name: 'Ada', fullAddress: 'addr:x' };
596
+ * const omitted: Out = { name: 'Ada' }; // virtual is optional when denied/missing
597
+ * void [router, out, omitted];
598
+ * ```
599
+ */
600
+ type ModelVirtuals<TModel = unknown, TVirtuals extends object = Record<never, never>> = IsUnknownVirtual<TModel> extends true ? Record<string, LooseVirtualSubEntry> : {
601
+ [K in Extract<keyof TVirtuals, string>]?: ModelVirtualLeaf<TModel, TVirtuals[K]>;
602
+ } & {
603
+ [K in Extract<keyof TModel, string>]?: {
604
+ sub?: Record<string, ModelVirtualLeaf<VirtualSubModel<TModel, K>, unknown> | {
605
+ sub?: Record<string, LooseVirtualLeaf>;
606
+ }>;
607
+ };
608
+ };
609
+
610
+ interface ResolvedVirtualDescriptor {
611
+ get: (...args: never[]) => unknown;
612
+ dependsOn: string[];
613
+ dependsOnPopulate?: ModelVirtualPopulateDependency[];
614
+ }
615
+
616
+ type ModelReferenceMap = {
617
+ [key: string]: string | ModelReferenceMap;
618
+ };
619
+ /**
620
+ * Owner of global/model/data options, registered Mongoose models and OpenAPI routes.
621
+ * Prefer createAccessRuntime() for a callable API with factories and bound setters;
622
+ * its `.runtime` exposes this owner. A bare instance has no createRouter method.
623
+ * Registries/configuration are isolated; the Mongoose jsonSchema extension is initialized
624
+ * idempotently. The defaultRuntime additionally adopts process-global named models.
625
+ */
626
+ declare class AccessRuntime {
627
+ private readonly allowGlobalModelLookup;
628
+ constructor(options?: {
629
+ allowGlobalModelLookup?: boolean;
630
+ });
631
+ private readonly globalOptions;
632
+ private readonly defaultModelOptions;
633
+ private readonly modelOptions;
634
+ private readonly modelJsonSchemas;
635
+ private readonly dataOptions;
636
+ private readonly modelRefs;
637
+ private readonly modelSubs;
638
+ private readonly modelAtts;
639
+ private readonly modelInstances;
640
+ private readonly openApiRegistry;
641
+ private openApiPathPrefix;
642
+ registerModelInstance<TModel>(modelName: string, model: mongoose.Model<TModel>): void;
643
+ hasModelInstance(modelName: string): boolean;
644
+ getModelInstance<TModel = unknown>(modelName: string): mongoose.Model<TModel> | null;
645
+ registerOpenApiRoute(route: OpenApiRouteDescriptor): void;
646
+ /**
647
+ * Compose OpenAPI paths while synchronously constructing mounted routers.
648
+ * Prefixes apply before collision checks; prior descriptors and Express paths
649
+ * are unchanged. Nested calls compose and the prior scope is restored even on
650
+ * failure. The callback must finish registration synchronously (no async work).
651
+ */
652
+ withOpenApiPathPrefix<T>(prefix: string, build: () => T): T;
653
+ /**
654
+ * Enable strict OpenAPI collision detection for the remainder of this
655
+ * runtime's lifetime. After this call, conflicting method/path
656
+ * registrations and duplicate operationIds throw {@link OpenApiCollisionError}
657
+ * instead of silently replacing. Existing already-registered routes are
658
+ * not retroactively re-validated.
659
+ */
660
+ enableOpenApiCollisionDetection(): void;
661
+ getOpenApiRoutes(): OpenApiRouteDescriptor[];
662
+ clearOpenApiRoutes(): void;
663
+ getOpenApiSpec(info: OpenApiDocumentOptions): {
664
+ openapi: string;
665
+ info: Omit<OpenApiDocumentOptions, "servers">;
666
+ servers?: OpenApiDocumentOptions["servers"];
667
+ paths: Record<string, Record<string, {
668
+ [key: `x-${string}`]: unknown;
669
+ operationId?: string;
670
+ summary?: string;
671
+ description?: string;
672
+ tags?: string[];
673
+ deprecated?: boolean;
674
+ parameters?: OpenApiParameter[];
675
+ requestBody?: {
676
+ required?: boolean;
677
+ content: Record<string, {
678
+ schema: OpenApiSchema;
679
+ }>;
680
+ };
681
+ responses: OpenApiResponses;
682
+ }>>;
683
+ };
684
+ createBootstrapSnapshot(): {
685
+ globalOptions: GlobalOptions;
686
+ defaultModelOptions: DefaultModelRouterOptions;
687
+ modelOptions: Record<string, ModelRouterOptions>;
688
+ dataOptions: Record<string, DataRouterOptions>;
689
+ modelInstances: Record<string, mongoose.Model<unknown>>;
690
+ modelJsonSchemas: Record<string, Record<string, unknown>>;
691
+ modelRefs: Record<string, ModelReferenceMap>;
692
+ modelSubs: Record<string, string[]>;
693
+ modelAtts: Record<string, string[]>;
694
+ openApi: {
695
+ routes: OpenApiRouteDescriptor[];
696
+ options: Required<OpenApiRegistryOptions>;
697
+ };
698
+ };
699
+ restoreBootstrapSnapshot(snapshot: ReturnType<AccessRuntime['createBootstrapSnapshot']>): void;
700
+ /** Shallowly replace supplied global values; nested objects such as requestComplexity are not deep-merged. */
701
+ setGlobalOptions(options: GlobalOptions): void;
702
+ setGlobalOption<K extends keyof GlobalOptions>(key: K, value: GlobalOptions[K]): void;
703
+ getGlobalOptions(): GlobalOptions;
704
+ getGlobalOption<K extends keyof GlobalOptions>(key: K, defaultValue?: GlobalOptions[K]): GlobalOptions[K];
705
+ /** Update model starting defaults shallowly; already-stored model values are not broadcast-replaced. */
706
+ setDefaultModelOptions(options: DefaultModelRouterOptions): void;
707
+ setDefaultModelOption<K extends keyof ExtendedDefaultModelRouterOptions>(key: K, value: ExtendedDefaultModelRouterOptions[K]): void;
708
+ getDefaultModelOptions(): DefaultModelRouterOptions<unknown>;
709
+ getDefaultModelOption<K extends keyof ExtendedDefaultModelRouterOptions>(key: K, defaultValue?: ExtendedDefaultModelRouterOptions[K]): ExtendedDefaultModelRouterOptions<unknown>[K];
710
+ private createModelOptions;
711
+ private getOrCreateModelOptions;
712
+ /**
713
+ * Assign `{ ...modelDefaults, ...storedOptions, ...options }` shallowly. A supplied
714
+ * operationAccess/defaults object replaces that whole value. Defaults accept only
715
+ * query/presentation settings; virtual configuration is validated before assignment.
716
+ * Existing router.options remains its construction-time snapshot. Fresh model-service
717
+ * calls capture the owner's current options/defaults; in-flight calls retain their snapshot.
718
+ */
719
+ setModelOptions<TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string, options: ModelRouterOptions<TModel, TVirtuals>): void;
720
+ setModelOption<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>, TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string, key: K, value: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): void;
721
+ /** Frozen stored snapshot, not fully resolved per-path defaults. Read again for current configuration. */
722
+ getModelOptions<TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string): ModelRouterOptions<TModel, TVirtuals>;
723
+ /**
724
+ * Generic stored exact → parent.default → parent lookup; only undefined falls through.
725
+ * The exact runtime-model-default path is the final fallback if the stored parent is
726
+ * absent. This is not the route-specific variant-to-base resolver; use
727
+ * getExactModelOption to inspect a variant including its exact model-default fallback.
728
+ */
729
+ getModelOption<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>, TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string, key: K | string, defaultValue?: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): ExtendedModelRouterOptions<TModel, TVirtuals>[K];
730
+ /** Exact stored path, then the same runtime-model-default path; no parent/default or variant-to-base lookup. */
731
+ getExactModelOption<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>, TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string, key: K | string): ExtendedModelRouterOptions<TModel, TVirtuals>[K];
732
+ /**
733
+ * List registered virtual leaf names for a scope (VIRT-01).
734
+ * Scope containers (`{ sub }`) are not leaves. Inapplicable names are
735
+ * still listed here; applicability is decided per-access by
736
+ * {@link resolveVirtualDescriptor}. Request-controlled include collisions
737
+ * are validated by VIRT-05, not guessed here.
738
+ */
739
+ getVirtualNames(modelName: string, scopePath?: string[]): string[];
740
+ /**
741
+ * Whether a field is a registered virtual leaf in a scope (VIRT-01).
742
+ * Inapplicable registered names stay virtual (never persisted), even when
743
+ * no getter applies for the current access. Containers and persisted
744
+ * fields return false.
745
+ */
746
+ isVirtualField(modelName: string, fieldName: string, scopePath?: string[]): boolean;
747
+ /**
748
+ * Resolve an applicable virtual descriptor with exact → `.default` → bare
749
+ * semantics (VIRT-01, VIRT-00A D1/D5). Returns `undefined` when no getter
750
+ * applies for `access`. Crucially, an access-record object is NEVER
751
+ * interpreted as a getter descriptor when the access is absent: an
752
+ * inapplicable registered name stays virtual (excluded from persisted
753
+ * projections, write admission, and DB sort/filter/distinct).
754
+ * Shared `dependsOn` and `dependsOnPopulate` lists inherit independently;
755
+ * each defined leaf list replaces its shared list wholesale.
756
+ */
757
+ resolveVirtualDescriptor(modelName: string, virtualName: string, access: string, scopePath?: string[]): ResolvedVirtualDescriptor | undefined;
758
+ getModelNames(): string[];
759
+ hasModel(modelName: string): boolean;
760
+ getModelJsonSchema(modelName: string): Record<string, unknown>;
761
+ private createDataOptions;
762
+ private getOrCreateDataOptions;
763
+ setDataOptions<TData = unknown>(dataName: string, options: DataRouterOptions<TData>): void;
764
+ setDataOption<K extends keyof ExtendedDataRouterOptions<TData>, TData = unknown>(dataName: string, key: K, value: ExtendedDataRouterOptions<TData>[K]): void;
765
+ getDataOptions<TData = unknown>(dataName: string): DataRouterOptions<TData>;
766
+ /**
767
+ * Reusable configured data view: plain containers are frozen; native properties
768
+ * return detached mutable copies on access. Native identity is not stable.
769
+ * Replacement leaves previously captured views on their original data version.
770
+ */
771
+ getDataSnapshot<TData = unknown>(dataName: string): readonly TData[];
772
+ getDataOption<K extends keyof ExtendedDataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string, defaultValue?: ExtendedDataRouterOptions<TData>[K]): ExtendedDataRouterOptions<TData>[K];
773
+ getExactDataOption<K extends keyof ExtendedDataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string): ExtendedDataRouterOptions<TData>[K];
774
+ getDataNames(): string[];
775
+ ensureModelMeta(modelName: string): void;
776
+ getModelRef(modelName: string, refPath: string): string | null;
777
+ getModelSub(modelName: string): string[];
778
+ getModelAtt(modelName: string): string[];
779
+ }
780
+ declare const defaultRuntime: AccessRuntime;
781
+
782
+ declare class DataCore {
783
+ private req;
784
+ private readonly requestRuntime;
785
+ private caches;
786
+ private cachedPermissions;
787
+ constructor(req: AccessRouterBaseRequest);
788
+ genIDFilter<TData = unknown>(dataName: string, id: string): Promise<Filter<TData>>;
789
+ genFilter<TData = unknown>(dataName: string, access?: BaseFilterAccess, _filter?: Filter<TData>): Promise<Filter<TData>>;
790
+ /** Request-schema allowlist, independent of doc values. No model hooks or backend elevation. */
791
+ genAllowedFields(dataName: string, _doc: unknown, access: SelectAccess, options?: DataFieldOptions): Promise<string[]>;
792
+ /** Request-only existing-value pick. No automatic identity/metadata retention; options default to {}. */
793
+ pickAllowedFields<TDoc>(dataName: string, doc: TDoc, access: SelectAccess, options?: DataFieldOptions): Promise<TDoc>;
794
+ /**
795
+ * Request-only requested-token intersection. Omitted/null/empty/exclusion-only select
796
+ * yields []; DataService then applies no extra projection after request trimming.
797
+ * Named options default to {}; legacy elevation and positional arguments are removed.
507
798
  */
508
- path: string;
509
- args?: CorrelatedIncludeArgs;
510
- options?: Record<string, never>;
511
- }
512
- /** Identifier read: exactly one of `id` / `filter` must be present. */
513
- interface CorrelatedReadByIdInclude extends CorrelatedIncludeBase {
514
- op: 'read';
515
- id: string | ParentRef;
516
- filter?: never;
517
- }
518
- interface CorrelatedReadByFilterInclude extends CorrelatedIncludeBase {
519
- op: 'read';
520
- filter: CorrelatedFilter;
521
- id?: never;
522
- }
523
- interface CorrelatedListInclude extends CorrelatedIncludeBase {
524
- op: 'list';
525
- filter: CorrelatedFilter;
526
- id?: never;
527
- }
528
- interface CorrelatedCountInclude extends CorrelatedIncludeBase {
529
- op: 'count';
530
- filter: CorrelatedFilter;
531
- id?: never;
532
- }
533
- type CorrelatedInclude = CorrelatedReadByIdInclude | CorrelatedReadByFilterInclude | CorrelatedListInclude | CorrelatedCountInclude;
534
- /** Related output cannot overwrite authorization metadata at any supported nested level. */
535
- type Include = LegacyInclude | CorrelatedInclude;
536
- type FindAccess = 'list' | 'read';
537
- type PopulateAccess = 'list' | 'read';
538
- interface Populate {
539
- path: string;
540
- select?: Projection;
541
- match?: unknown;
542
- access?: PopulateAccess;
799
+ genSelect(dataName: string, access: SelectAccess, targetFields?: Projection, options?: DataFieldOptions): Promise<string[]>;
800
+ private fieldPermissionSchema;
801
+ decorate<TDoc>(dataName: string, doc: TDoc, access: DecorateAccess, context?: DataHookContext): Promise<TDoc>;
802
+ decorateAll<TDoc>(dataName: string, docs: TDoc[], access: DecorateAllAccess, context?: DataHookContext): Promise<TDoc[]>;
803
+ getPermissions(): Permission;
804
+ setPermissions(): Promise<void>;
805
+ canActivate(routeGuard: Validation): Promise<boolean>;
806
+ isAllowed(dataName: string, access: RouteGuardAccess | string): Promise<boolean>;
807
+ /** Authorize route entry using explicit server-owned basic/advanced metadata. */
808
+ isAllowedRoute(dataName: string, baseAccess: RouteGuardAccess | string, variant: RouteVariant): Promise<boolean>;
809
+ getService<TData = unknown>(dataName: string): DataService<TData>;
810
+ service<TData = unknown>(dataName: string): DataService<TData>;
811
+ svc<TData = unknown>(dataName: string): DataService<TData>;
812
+ private getGlobalPermissions;
543
813
  }
544
- interface SubPopulate {
545
- path: string;
546
- select?: Projection;
814
+
815
+ declare const MIDDLEWARE: unique symbol;
816
+ declare const DATA_MIDDLEWARE: unique symbol;
817
+ declare const PERMISSIONS: unique symbol;
818
+ declare const PERMISSION_KEYS: unique symbol;
819
+
820
+ interface AccessRouterRequestExtensions {
821
+ macl?: Core;
822
+ dacl?: DataCore;
823
+ [PERMISSIONS]?: AccessRouterPermissions;
824
+ [PERMISSION_KEYS]?: string[];
825
+ [MIDDLEWARE]?: unknown[] | unknown;
826
+ [DATA_MIDDLEWARE]?: unknown[] | unknown;
827
+ [key: string]: unknown;
828
+ [key: symbol]: unknown;
547
829
  }
830
+ type AccessRouterRequest = express.Request & AccessRouterRequestExtensions;
548
831
 
549
832
  /**
550
833
  * Bounded persisted/registered-virtual response paths, including embedded array children.
@@ -798,6 +1081,37 @@ type AllowedOutputFieldOptions<TModel = unknown, TVirtuals extends object = Reco
798
1081
  readonly purpose: 'output';
799
1082
  };
800
1083
 
1084
+ /** Package-private D2 validation/capture. Terminal persisted inputs, never output grants or target I/O. */
1085
+
1086
+ interface VirtualPopulateTarget {
1087
+ /** Stable per-capture identity for grouping even when native policy values are copied on read. */
1088
+ readonly identity: object;
1089
+ readonly runtime: AccessRuntime;
1090
+ readonly modelName: string;
1091
+ readonly model: Model<unknown>;
1092
+ /** Binding identity only. Execution uses the owned catalog/selections, not live schema inspection. */
1093
+ readonly schema: Schema;
1094
+ /** Terminal read policy: no target virtual registry or private dependency graph. */
1095
+ readonly configuration: AuthorizationConfiguration;
1096
+ }
1097
+ interface CapturedVirtualPopulateDependency {
1098
+ /** Scope-local path and absolute persisted source path (no `.sub` markers). */
1099
+ readonly path: string;
1100
+ readonly sourcePath: string;
1101
+ readonly cardinality: 'scalar' | 'array';
1102
+ readonly target: VirtualPopulateTarget;
1103
+ /** Eligible leaf mask for this getter only; never a public output selection. */
1104
+ readonly selection: readonly string[];
1105
+ /** Positive persisted paths, including association identity even for `-_id`. */
1106
+ readonly fetchSelection: readonly string[];
1107
+ readonly includeId: boolean;
1108
+ }
1109
+ /**
1110
+ * An opaque function identity survives configuration copying without copying a
1111
+ * Mongoose schema/runtime graph. Bindings live only here, not on DTOs or handles.
1112
+ */
1113
+ type VirtualPopulateSnapshotToken = () => void;
1114
+
801
1115
  interface AuthorizationBinding {
802
1116
  readonly request: AccessRouterRequest;
803
1117
  readonly runtime: object;
@@ -827,6 +1141,8 @@ interface AuthorizationFieldCatalog {
827
1141
  }
828
1142
  interface AuthorizationConfiguration {
829
1143
  readonly catalog: AuthorizationFieldCatalog;
1144
+ /** Opaque terminal private-input capture. Never related authority or public document metadata. */
1145
+ readonly virtualPopulateSnapshot?: VirtualPopulateSnapshotToken;
830
1146
  readonly documentPermissionField?: string;
831
1147
  /** Captured permission schema, virtual descriptors, always-select and metadata posture. */
832
1148
  readonly [key: string]: unknown;
@@ -836,9 +1152,15 @@ interface AuthorizationRelatedTarget {
836
1152
  readonly path: string;
837
1153
  readonly modelName: string;
838
1154
  readonly configuration: AuthorizationConfiguration;
1155
+ /** Effective include args/options, resolved with that target's captured defaults. */
1156
+ readonly queryIntent?: ModelServiceIntent;
1157
+ /** Existing include operation gate, resolved synchronously with its target. */
1158
+ readonly operationGuard?: unknown;
839
1159
  /** Passthrough is the existing global unregistered-populate opt-out, not a caller policy. */
840
1160
  readonly kind?: 'output' | 'count' | 'passthrough';
841
1161
  readonly relatedTargets?: readonly AuthorizationRelatedTarget[];
1162
+ /** Captured supported raw-ref transport shape; exotic ordinary populates keep their adapter path. */
1163
+ readonly staticObjectIdReference?: boolean;
842
1164
  }
843
1165
  declare const resolvedAuthorizationBrand: unique symbol;
844
1166
  interface ResolvedServiceAuthorization {
@@ -883,6 +1205,7 @@ type FieldAuthorizationState = 'granted' | 'deferred' | 'denied';
883
1205
  type VirtualProjectionAccess = 'list' | 'create' | 'read' | 'update' | (string & {});
884
1206
  type VirtualCandidateAuthState = 'granted' | 'deferred';
885
1207
  interface VirtualProjectionSnapshot {
1208
+ virtualPopulateSnapshot?: VirtualPopulateSnapshotToken;
886
1209
  catalog?: AuthorizationFieldCatalog;
887
1210
  permissionSchema?: Record<string, unknown> | null;
888
1211
  virtuals?: Record<string, unknown> | null;
@@ -894,12 +1217,11 @@ interface VirtualProjectionSnapshot {
894
1217
  }
895
1218
  interface PlanVirtualCandidate {
896
1219
  name: string;
897
- descriptor: {
898
- get: (...args: never[]) => unknown;
899
- dependsOn: string[];
900
- };
1220
+ descriptor: ResolvedVirtualDescriptor;
901
1221
  authState: VirtualCandidateAuthState;
902
1222
  dependsOn: string[];
1223
+ /** Terminal private reads for this active getter; not first-argument dependencies. */
1224
+ populateDependencies: readonly CapturedVirtualPopulateDependency[];
903
1225
  virtualAccess: VirtualProjectionAccess;
904
1226
  outputAccess: VirtualProjectionAccess;
905
1227
  }
@@ -925,6 +1247,10 @@ interface VirtualProjectionPlan {
925
1247
  outputVirtualNames: string[];
926
1248
  /** Safe Mongoose projection: no virtuals, no `.sub` paths, no `-_id`. */
927
1249
  persistedFetchSelection: string[];
1250
+ /** Pre-expansion persisted/hook input mask. Fetching new refs confers no hook-input authority. */
1251
+ publicPersistedFetchSelection: string[];
1252
+ /** Empty embedded hook views retain container shape, never a private fetch's contents. */
1253
+ publicStructurePaths?: string[];
928
1254
  candidates: PlanVirtualCandidate[];
929
1255
  virtualOnlyDeps: string[];
930
1256
  internalOnlyFields: string[];
@@ -1013,6 +1339,13 @@ declare class Service<TModel = unknown, TVirtuals extends object = Record<never,
1013
1339
  /** Presence, not truthiness: never read a legacy slot or treat it as payload data. */
1014
1340
  private admitServiceCall;
1015
1341
  private executionOutputPlan;
1342
+ private preparedOutputIntent;
1343
+ /** Raw result -> exact ref capture -> detached ordinary source/hook rows.
1344
+ * Private inputs travel separately through finalization, never through snapshots.
1345
+ */
1346
+ private loadOutputPopulateDependencies;
1347
+ /** Dependency-bearing post-lifecycle/template work uses detached output copies. */
1348
+ private prepareDetachedOutputRows;
1016
1349
  private requestSortFields;
1017
1350
  /** One output stage per row, independent of metadata and of pre-write admission. */
1018
1351
  private finalizeDirectOutput;
@@ -1062,7 +1395,8 @@ declare class Service<TModel = unknown, TVirtuals extends object = Record<never,
1062
1395
  * Finalizes already-filtered (visible-only) sub rows through the shared
1063
1396
  * boundary with scope ` [sub,'sub']`, owning-parent `read` grants, and
1064
1397
  * scoped rules. Children (deeper nested + related via `related`) finalize
1065
- * before sub getters; only finalized children appear in getter views.
1398
+ * before sub getters; argument one has finalized public children. Declared
1399
+ * private populated inputs travel separately in argument four.
1066
1400
  * Uses a bounded row map + request/runtime hook-chain admission (stable
1067
1401
  * order, limit-one reentry, no persistence permits held). Waiting ancestor
1068
1402
  * callback frames do not consume extra permits. Callers must filter rows BEFORE
@@ -1247,18 +1581,6 @@ declare class Service<TModel = unknown, TVirtuals extends object = Record<never,
1247
1581
  countByFieldValues(foreignField: string, values: readonly unknown[], filter?: Filter<TModel>, access?: BaseFilterAccess): Promise<SingleResult<Map<string, number>> | ErrorResult>;
1248
1582
  private countPreparedByFieldValueGroups;
1249
1583
  getDocPermissions(doc: unknown): Record<string, unknown>;
1250
- private resolveFindOneArgs;
1251
- private resolveFindOneOptions;
1252
- private resolveFindByIdArgs;
1253
- private resolveFindByIdOptions;
1254
- private resolveFindArgs;
1255
- private resolveFindOptions;
1256
- private resolveCreateArgs;
1257
- private resolveCreateOptions;
1258
- private resolveUpdateOneArgs;
1259
- private resolveUpdateOneOptions;
1260
- private resolveUpdateByIdArgs;
1261
- private resolveUpdateByIdOptions;
1262
1584
  private resolveUpsertArgs;
1263
1585
  private resolveUpsertOptions;
1264
1586
  private resolveExistsOptions;
@@ -1356,6 +1678,8 @@ declare class PublicService<TModel = unknown, TVirtuals extends object = Record<
1356
1678
  _delete(id: string): Promise<SingleResult<unknown> | ErrorResult>;
1357
1679
  _distinct(field: string, options?: DistinctArgs<TModel>): Promise<ListResult<unknown> | ErrorResult>;
1358
1680
  _count(filter: Filter<TModel>, access?: BaseFilterAccess): Promise<SingleResult<number> | ErrorResult>;
1681
+ /** Own the conditional gate with the read; execute only after a nonterminal miss. */
1682
+ private captureListFallbackAdmission;
1359
1683
  private admitPublicCall;
1360
1684
  private resolvePublicListArgs;
1361
1685
  private resolvePublicListOptions;
@@ -1635,7 +1959,7 @@ declare class Base<TModel = unknown, TVirtuals extends object = Record<never, ne
1635
1959
  protected getAuthorizedTargetService(modelName: string, op: CrossResourceModelOperation, path?: string, parentAuthorization?: ResolvedServiceAuthorization): Promise<PublicService<unknown, Record<never, never>>>;
1636
1960
  private relatedBinding;
1637
1961
  private relatedExecution;
1638
- protected processInclude(include: Include | Include[]): {
1962
+ protected processInclude(include: Include | Include[], authorization?: ResolvedServiceAuthorization): {
1639
1963
  includes: LegacyInclude[];
1640
1964
  correlatedIncludes: CorrelatedInclude[];
1641
1965
  includeLocalFields: string[];
@@ -2688,198 +3012,6 @@ interface ExistsOptions {
2688
3012
  includeId?: boolean;
2689
3013
  }
2690
3014
 
2691
- type MaybePromise<T> = T | Promise<T>;
2692
- type AccessRouterFieldKey<T> = [Extract<keyof T, string>] extends [never] ? string : Extract<keyof T, string>;
2693
- type IdentifierHook<TValue, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, id: string) => MaybePromise<Filter<TValue>>;
2694
- type GlobalPermissionValue = Record<string, boolean> | string[] | string | null | undefined;
2695
- type BaseFilterHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, permissions: AccessRouterPermissions) => MaybePromise<Filter | true | null | undefined>;
2696
- type OverrideFilterHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, filter: Filter, permissions: AccessRouterPermissions) => MaybePromise<Filter>;
2697
- type Hook<TValue, TContext, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, value: TValue, permissions: AccessRouterPermissions, context: TContext) => MaybePromise<TValue>;
2698
- type HookChain<TValue, TContext, TRequest extends AccessRouterRequest = AccessRouterRequest> = Hook<TValue, TContext, TRequest> | Array<Hook<TValue, TContext, TRequest>>;
2699
- type ValidateRule = boolean | unknown[];
2700
- type ValidateHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, allowedData: unknown, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<ValidateRule>;
2701
- type DocPermissionsHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, doc: unknown, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<Record<string, unknown>>;
2702
- type ChangeHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, previousValue: unknown, nextValue: unknown, changes: Change[], context: ModelHookContext) => MaybePromise<void>;
2703
- type DeleteHook<TValue = unknown, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, value: TValue, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<void>;
2704
- type DocumentHook<TValue, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, value: ModelDocument<TValue>, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<ModelDocument<TValue>>;
2705
- type DocumentHookChain<TValue, TRequest extends AccessRouterRequest = AccessRouterRequest> = DocumentHook<TValue, TRequest> | Array<DocumentHook<TValue, TRequest>>;
2706
- type ModelBaseFilterHook = BaseFilterHook<ModelRequest>;
2707
- type DataBaseFilterHook = BaseFilterHook<DataRequest>;
2708
- type ModelOverrideFilterHook = OverrideFilterHook<ModelRequest>;
2709
- type DataOverrideFilterHook = OverrideFilterHook<DataRequest>;
2710
- type ModelIdentifierHook<TValue = unknown> = IdentifierHook<TValue, ModelRequest>;
2711
- type DataIdentifierHook<TValue = unknown> = IdentifierHook<TValue, DataRequest>;
2712
- type ModelValidateHook = ValidateHook<ModelRequest>;
2713
- /**
2714
- * Request-user grants from untrimmed projected input. Declare private persisted inputs
2715
- * with alwaysSelectFields. Integrated output resolves once per document/access stage,
2716
- * independently of skim or metadata serialization; use the result's document handle
2717
- * for later picks after input/metadata trim. Backend grants do not forge user metadata.
2718
- */
2719
- type ModelDocPermissionsHook = DocPermissionsHook<ModelRequest>;
2720
- type ModelChangeHook = ChangeHook<ModelRequest>;
2721
- type ModelDocumentHook<TValue = unknown> = DocumentHookChain<TValue, ModelRequest>;
2722
- type ModelDeleteHook<TValue = unknown> = DeleteHook<ModelDocument<TValue>, ModelRequest>;
2723
- type ModelHook<TValue = unknown> = HookChain<TValue, ModelHookContext, ModelRequest>;
2724
- type ModelListHook<TValue = unknown> = HookChain<TValue[], ModelHookContext, ModelRequest>;
2725
- type DataHook<TValue = unknown> = HookChain<TValue, DataHookContext, DataRequest>;
2726
- type DataListHook<TValue = unknown> = HookChain<TValue[], DataHookContext, DataRequest>;
2727
- /**
2728
- * Supported per-access virtual getter keys (VIRT-00A D1/D5).
2729
- * `default` is a fallback access; `delete`/`distinct`/`count` are NOT
2730
- * virtual accesses and must be rejected at configuration time.
2731
- */
2732
- type ModelVirtualAccess = 'list' | 'create' | 'read' | 'update';
2733
- type ModelVirtualRecordAccess = 'default' | ModelVirtualAccess;
2734
- /**
2735
- * Scope-aware virtual getter context (VIRT-00A D2, frozen).
2736
- * Extends {@link ModelHookContext} with the receiving model, definition/
2737
- * permission `scopePath` (e.g. `[]` at root, `['contacts','sub']` for
2738
- * `contacts.sub.displayName`), and the three effective accesses. The
2739
- * initiating operation stays in `context.operation` and is never
2740
- * overwritten with fallback/effective visibility.
2741
- *
2742
- * Embedded outputs reuse the owning parent's internally computed grants with
2743
- * the scope's `permissionSchema.<field>.sub` rules; dedicated subdocument
2744
- * routes resolve grants from the raw parent lookup. Related (populate/
2745
- * include) targets finalize with the target model's own definitions,
2746
- * permissions, selection, and effective access before parent getters run.
2747
- */
2748
- interface ModelVirtualContext extends ModelHookContext {
2749
- receivingModelName: string;
2750
- scopePath: string[];
2751
- virtualAccess: ModelVirtualAccess;
2752
- outputAccess: ModelVirtualAccess;
2753
- docPermissionsAccess: ModelVirtualAccess;
2754
- }
2755
- type IsUnknownVirtual<T> = unknown extends T ? ([keyof T] extends [never] ? true : false) : false;
2756
- /**
2757
- * Typed isolated persisted view for a virtual getter scope (VIRT-00A D3/D4).
2758
- * Known models use a partial read-only persisted view (never
2759
- * `Record<string, unknown>`); unknown/untyped models keep an explicit
2760
- * loose fallback.
2761
- */
2762
- type ModelVirtualDoc<TModel = unknown> = IsUnknownVirtual<TModel> extends true ? Readonly<Partial<Record<string, unknown>>> : [Extract<keyof TModel, string>] extends [never] ? Readonly<Partial<Record<string, unknown>>> : Readonly<Partial<TModel>>;
2763
- /**
2764
- * Virtual getter signature (VIRT-00A D3/D4, frozen).
2765
- * Receives an isolated plain-object snapshot of persisted dependencies +
2766
- * already-finalized related/embedded outputs for its scope. Sibling virtual
2767
- * values are not visible. Mutating the input cannot change response data or
2768
- * lifecycle snapshots. Only the returned field value is committed;
2769
- * `undefined` omits the field; throws omit fail-closed. `this` is the
2770
- * model request.
2771
- */
2772
- type ModelVirtualGetter<TModel = unknown, TValue = unknown> = (this: ModelRequest, doc: ModelVirtualDoc<TModel>, permissions: AccessRouterPermissions, context: ModelVirtualContext) => MaybePromise<TValue | undefined>;
2773
- /**
2774
- * Leaf virtual descriptor (VIRT-01): `{ get, dependsOn }`.
2775
- * `dependsOn` lists top-level persisted field names relative to the
2776
- * definition's scope (e.g. `['displayName']` inside `contacts.sub`, never
2777
- * `['contacts.sub.displayName']`). Dotted paths and virtual-to-virtual
2778
- * dependencies are rejected at configuration time.
2779
- *
2780
- * The getter runs after `toObject()`/lean normalization and after internal
2781
- * document-permissions computation, with global permissions available and
2782
- * before `decorate`/`decorateAll`/tasks. Only the returned field value is
2783
- * committed via document-aware helpers: `undefined` (or a throw) omits the
2784
- * field fail-closed and computed values never persist. Getters see an
2785
- * isolated plain-object view for both lean and hydrated results; mutating the
2786
- * input cannot change response data or lifecycle snapshots.
2787
- *
2788
- * @example
2789
- * ```ts
2790
- * import type { ModelVirtualDescriptor } from '@web-ts-toolkit/access-router';
2791
- * interface User { name: string; address: string; }
2792
- * const descriptor: ModelVirtualDescriptor<User, string> = {
2793
- * dependsOn: ['address'],
2794
- * get: async (doc) => (doc.address === undefined ? undefined : `addr:${doc.address}`),
2795
- * };
2796
- * ```
2797
- */
2798
- interface ModelVirtualDescriptor<TModel = unknown, TValue = unknown> {
2799
- get: ModelVirtualGetter<TModel, TValue>;
2800
- dependsOn?: Array<AccessRouterFieldKey<TModel>>;
2801
- }
2802
- /**
2803
- * Per-access virtual record (VIRT-01): `default` + `list`/`create`/`read`/
2804
- * `update` (NOT `delete`/`distinct`/`count`). Each present access holds a
2805
- * leaf descriptor or bare getter shorthand. An optional shared `dependsOn`
2806
- * supports the documented `{ dependsOn, read: getter }` shape; a leaf's own
2807
- * `dependsOn` wins over the shared list during resolution.
2808
- */
2809
- type ModelVirtualAccessRecord<TModel = unknown, TValue = unknown> = {
2810
- default?: ModelVirtualDescriptor<TModel, TValue> | ModelVirtualGetter<TModel, TValue>;
2811
- list?: ModelVirtualDescriptor<TModel, TValue> | ModelVirtualGetter<TModel, TValue>;
2812
- create?: ModelVirtualDescriptor<TModel, TValue> | ModelVirtualGetter<TModel, TValue>;
2813
- read?: ModelVirtualDescriptor<TModel, TValue> | ModelVirtualGetter<TModel, TValue>;
2814
- update?: ModelVirtualDescriptor<TModel, TValue> | ModelVirtualGetter<TModel, TValue>;
2815
- dependsOn?: Array<AccessRouterFieldKey<TModel>>;
2816
- };
2817
- /** Single virtual entry: bare getter, leaf descriptor, or per-access record. */
2818
- type ModelVirtualLeaf<TModel = unknown, TValue = unknown> = ModelVirtualGetter<TModel, TValue> | ModelVirtualDescriptor<TModel, TValue> | ModelVirtualAccessRecord<TModel, TValue>;
2819
- type UnwrapVirtualArray<T> = T extends readonly (infer U)[] ? U : T;
2820
- /**
2821
- * Persisted sub-scope model for an embedded container field (VIRT-01).
2822
- * Unwraps arrays/nullable wrappers to the element/object type; unknown
2823
- * fields fall back to a loose record.
2824
- */
2825
- type VirtualSubModel<TModel, TField extends string> = TField extends keyof TModel ? UnwrapVirtualArray<NonNullable<TModel[TField]>> : Record<string, unknown>;
2826
- type LooseVirtualLeaf = ModelVirtualGetter<Record<string, unknown>, unknown> | ModelVirtualDescriptor<Record<string, unknown>, unknown> | ModelVirtualAccessRecord<Record<string, unknown>, unknown>;
2827
- type LooseVirtualSubEntry = LooseVirtualLeaf | {
2828
- sub?: Record<string, LooseVirtualLeaf | {
2829
- sub?: Record<string, LooseVirtualLeaf>;
2830
- }>;
2831
- };
2832
- /**
2833
- * Virtual definitions for a model scope (VIRT-01).
2834
- * Root leaves come from `TVirtuals` (strict: unknown persisted getter
2835
- * fields are type errors). Embedded containers mirror
2836
- * `permissionSchema.<field>.sub`: any persisted field may host a `sub`
2837
- * record whose leaves use the container's persisted sub-model view.
2838
- * Untyped models keep an explicit loose record fallback.
2839
- *
2840
- * Selected virtual outputs are optional (`Partial`): authorization, absent
2841
- * dependencies, `undefined`, and fail-closed errors can omit them. Virtual
2842
- * names are never added to persisted `Filter`, sort/distinct inputs, or
2843
- * client write types.
2844
- *
2845
- * @example End-to-end typed virtual (persisted `User` has no `fullAddress`):
2846
- * ```ts
2847
- * import acl from '@web-ts-toolkit/access-router';
2848
- * import type { SelectedPublicOutput } from '@web-ts-toolkit/access-router/advanced';
2849
- * interface User { name: string; address: string; }
2850
- * interface UserVirtuals { fullAddress: string; }
2851
- * const router = acl.createRouter<User, UserVirtuals>('User', {
2852
- * permissionSchema: {
2853
- * name: { read: true },
2854
- * address: { read: 'canViewAddress' },
2855
- * fullAddress: { read: 'canViewAddress' },
2856
- * },
2857
- * virtuals: {
2858
- * fullAddress: {
2859
- * dependsOn: ['address'],
2860
- * read: async function (doc) {
2861
- * if (doc.address === undefined) return undefined;
2862
- * return `addr:${doc.address}`;
2863
- * },
2864
- * },
2865
- * },
2866
- * });
2867
- * type Out = SelectedPublicOutput<User, ['name', 'fullAddress'], UserVirtuals>;
2868
- * const out: Out = { name: 'Ada', fullAddress: 'addr:x' };
2869
- * const omitted: Out = { name: 'Ada' }; // virtual is optional when denied/missing
2870
- * void [router, out, omitted];
2871
- * ```
2872
- */
2873
- type ModelVirtuals<TModel = unknown, TVirtuals extends object = Record<never, never>> = IsUnknownVirtual<TModel> extends true ? Record<string, LooseVirtualSubEntry> : {
2874
- [K in Extract<keyof TVirtuals, string>]?: ModelVirtualLeaf<TModel, TVirtuals[K]>;
2875
- } & {
2876
- [K in Extract<keyof TModel, string>]?: {
2877
- sub?: Record<string, ModelVirtualLeaf<VirtualSubModel<TModel, K>, unknown> | {
2878
- sub?: Record<string, LooseVirtualLeaf>;
2879
- }>;
2880
- };
2881
- };
2882
-
2883
3015
  type RequestSchema = RequestSchemaLike;
2884
3016
  type NestedRequestSchema = {
2885
3017
  default?: RequestSchema;
@@ -3305,6 +3437,12 @@ interface ModelRouterOptions<TModel = unknown, TVirtuals extends object = Record
3305
3437
  * authorized. Virtuals are output-only: registered names (including
3306
3438
  * embedded `sub` leaves) are excluded from persisted projections, client
3307
3439
  * write admission, and database sort/filter/distinct handling.
3440
+ * `dependsOnPopulate` declares one-hop private persisted target inputs only in
3441
+ * that getter's fourth argument. Annotate ModelVirtualDescriptor<Source, Value,
3442
+ * { ref: Target }> separately, then assign here; persisted/write/public types
3443
+ * stay unchanged. Register target models/options first in this runtime. Source
3444
+ * refs are retained automatically; target base read/tenant gates still apply.
3445
+ * The original public selection/population is preserved, including ID restoration.
3308
3446
  *
3309
3447
  * @example Shortest typed happy-path (persisted model lacks `fullAddress`):
3310
3448
  * ```ts
@@ -3611,4 +3749,4 @@ declare function fromIoTs<TValue = unknown>(decoder: IoTsDecoderLike<TValue>): R
3611
3749
  declare function fromSuperstruct<TStruct, TOutput = unknown>(struct: TStruct, validate: SuperstructValidateLike): RequestSchemaValidator<TOutput>;
3612
3750
  declare function fromVine<TValue = unknown>(validator: VineValidatorLike<TValue>): RequestSchemaValidator<TValue>;
3613
3751
 
3614
- export { type DecorateAccess as $, type AccessRouterBaseRequest as A, type BaseFilterAccess as B, type Change as C, type CorrelatedReadByFilterInclude as D, type CorrelatedReadByIdInclude as E, type CountBody as F, type CreateArgs as G, type CreateAuthorization as H, type CreateOptions as I, type CreateQueryInput as J, CustomHeaders as K, DATA_MIDDLEWARE as L, type DataBaseFilterHook as M, type DataFieldOptions as N, type DataFilter as O, type DataFindArgs as P, type DataFindOneArgs as Q, type DataFindOneOptions as R, type DataFindOptions as S, type DataHook as T, type DataHookContext as U, type DataIdentifierHook as V, type DataListHook as W, type DataOverrideFilterHook as X, type DataRequest as Y, type DataRequestSchemas as Z, type DataRouterOptions as _, type AccessRouterFieldKey as a, type ModelVirtualGetter as a$, type DecorateAllAccess as a0, type DeepFieldPath as a1, type DefaultModelRouterOptions as a2, type Defaults as a3, type DistinctArgs as a4, type DistinctBody as a5, type DocPermissionsAccess as a6, type DocumentAuthorization as a7, type ErrorResult as a8, type ExistsOptions as a9, type JoiValidationErrorDetailLike as aA, type KeyValueProjection as aB, type LegacyInclude as aC, type ListQueryInput as aD, type ListResult as aE, MIDDLEWARE as aF, type MaybePromise as aG, type ModelBaseFilterHook as aH, type ModelChangeHook as aI, type ModelDeleteHook as aJ, type ModelDocPermissionsHook as aK, type ModelDocument as aL, type ModelDocumentHook as aM, type ModelHook as aN, type ModelHookContext as aO, type ModelHydrationOptions as aP, type ModelIdentifierHook as aQ, type ModelListHook as aR, type ModelOverrideFilterHook as aS, type ModelRequest as aT, type ModelRouterOptions as aU, type ModelValidateHook as aV, type ModelVirtualAccess as aW, type ModelVirtualAccessRecord as aX, type ModelVirtualContext as aY, type ModelVirtualDescriptor as aZ, type ModelVirtualDoc as a_, type ExtendedDataRouterOptions as aa, type ExtendedDefaultModelRouterOptions as ab, type ExtendedModelRouterOptions as ac, type FieldAuthorization as ad, type FieldOperationAccess as ae, type Filter as af, FilterOperator as ag, type FindAccess as ah, type FindArgs as ai, type FindByIdArgs as aj, type FindByIdOptions as ak, type FindOneArgs as al, type FindOneOptions as am, type FindOptions as an, type GlobalOptions as ao, type GlobalPermissionValue as ap, type GuardHook as aq, type HydrationMode as ar, type IdentifierHook as as, type Include as at, type InputFieldAuthorization as au, type InputFieldPath as av, type IoTsContextEntryLike as aw, type IoTsDecodeErrorLike as ax, type IoTsDecoderLike as ay, type JoiSchemaLike as az, type AccessRouterLogger as b, type RootModelNewQueryEntry as b$, type ModelVirtualLeaf as b0, type ModelVirtualRecordAccess as b1, type ModelVirtuals as b2, type MutationAuthorization as b3, type NewArgs as b4, type NewOptions as b5, type OperationAccess as b6, type OperationAuthorization as b7, type OutputAuthorization as b8, type OutputFieldOptions as b9, type PublicSubdocumentMutationOptions as bA, type PublicSubdocumentReadOptions as bB, type PublicUpdateArgs as bC, type PublicUpdateOptions as bD, type PublicUpsertArgs as bE, type PublicUpsertOptions as bF, type ReadQueryInput as bG, type RelatedAuthorization as bH, type Request as bI, type RequestSchemaAdapter as bJ, type RequestSchemaFailure as bK, type RequestSchemaIssue as bL, type RequestSchemaLike as bM, type RequestSchemaOptions as bN, type RequestSchemaResult as bO, type RequestSchemaSuccess as bP, type RequestSchemaValidator as bQ, type RequestSchemas as bR, type RootDataListQueryEntry as bS, type RootDataOperation as bT, type RootDataReadByFilterQueryEntry as bU, type RootDataReadByIdQueryEntry as bV, type RootModelCountQueryEntry as bW, type RootModelCreateQueryEntry as bX, type RootModelDeleteQueryEntry as bY, type RootModelDistinctQueryEntry as bZ, type RootModelListQueryEntry as b_, type OutputFieldPath as ba, type OutputPlanningOptions as bb, PERMISSIONS as bc, PERMISSION_KEYS as bd, type PairedRouteAccess as be, type ParentRef as bf, type PathValue as bg, type PermissionSchema as bh, type Populate as bi, type PopulateAccess as bj, type PopulatePlanningOptions as bk, type PrepareAccess as bl, type Projection as bm, type PublicCreateArgs as bn, type PublicCreateOptions as bo, type PublicErrorResult as bp, type PublicListArgs as bq, type PublicListOptions as br, type PublicListResult as bs, type PublicOutput as bt, type PublicReadArgs as bu, type PublicReadOptions as bv, type PublicServiceResult as bw, type PublicSingleResult as bx, type PublicSubdocumentCreateOptions as by, type PublicSubdocumentListOptions as bz, type AccessRouterRequest as c, type SubdocumentReadAuthorization as c$, type RootModelOperation as c0, type RootModelReadByFilterQueryEntry as c1, type RootModelReadByIdQueryEntry as c2, type RootModelSubBulkUpdateQueryEntry as c3, type RootModelSubCreateQueryEntry as c4, type RootModelSubDeleteQueryEntry as c5, type RootModelSubListQueryEntry as c6, type RootModelSubReadQueryEntry as c7, type RootModelSubUpdateQueryEntry as c8, type RootModelUpdateQueryEntry as c9, type StandardSchemaSuccess as cA, type StandardSchemaV1 as cB, StatusCodes as cC, type SubListBody as cD, type SubOperationAccess as cE, type SubPopulate as cF, type SubQueryEntry as cG, type SubReadBody as cH, type SubRouteGuardOptions as cI, type SubdocumentBulkRecord as cJ, type SubdocumentBulkUpdateInput as cK, type SubdocumentCreateAuthorization as cL, type SubdocumentCreateInput as cM, type SubdocumentCreateOptions as cN, type SubdocumentCreateVisibilityAuthorization as cO, type SubdocumentDeleteAuthorization as cP, type SubdocumentDeleteOptions as cQ, type SubdocumentGateAuthorization as cR, type SubdocumentId as cS, type SubdocumentInputAuthorization as cT, type SubdocumentListOptions as cU, type SubdocumentModel as cV, type SubdocumentMutationAuthorization as cW, type SubdocumentName as cX, type SubdocumentOutputAuthorization as cY, type SubdocumentParentArgs as cZ, type SubdocumentParentOptions as c_, type RootModelUpsertQueryEntry as ca, type RootOperationResult as cb, type RootQueryEntry as cc, type RootRouterOptions as cd, type RootSubOperation as ce, type RootTarget as cf, type RouteBaseAccess as cg, type RouteGuardAccess as ch, type RouteVariant as ci, type RouteVariantAccess as cj, type RowAuthorization as ck, type SelectAccess as cl, type SelectedPopulatedPublicOutput as cm, type SelectedPublicOutput as cn, type ServiceAuthorization as co, type ServiceOutputContext as cp, type ServiceOutputDecorator as cq, type ServiceResult as cr, type SingleResult as cs, type Sort as ct, type SortOrder as cu, type StandardSchemaFailure as cv, type StandardSchemaInferOutput as cw, type StandardSchemaIssue as cx, type StandardSchemaPathSegment as cy, type StandardSchemaResult as cz, type AccessRouterRequestExtensions as d, type AccessRouterPermissions as d$, type SubdocumentReadOptions as d0, type SubdocumentRecord as d1, type SubdocumentUpdateOptions as d2, type SubdocumentVirtuals as d3, type SubdocumentVisibilityAuthorization as d4, type SuperstructFailureLike as d5, type SuperstructValidateLike as d6, type Task as d7, type TaskType as d8, type TransformAccess as d9, fromAjv as dA, fromArkType as dB, fromIoTs as dC, fromJoi as dD, fromStandardSchema as dE, fromSuperstruct as dF, fromValibot as dG, fromVine as dH, fromYup as dI, fromZod as dJ, parseBody as dK, parseBodyWithSchema as dL, parseNestedBodyWithSchema as dM, parsePathParam as dN, parseQuery as dO, AccessRuntime as dP, DataService as dQ, Service as dR, PublicService as dS, type OpenApiRouterOptions as dT, type OpenApiRegistryOptions as dU, type OpenApiRouteDescriptor as dV, type OpenApiDocumentOptions as dW, type OpenApiParameter as dX, type OpenApiSchema as dY, type OpenApiResponses as dZ, type AccessRouterPermissionMap as d_, type TypedFilter as da, type UpdateByIdArgs as db, type UpdateByIdOptions as dc, type UpdateOneArgs as dd, type UpdateOneOptions as de, type UpdateQueryInput as df, type UpsertArgs as dg, type UpsertOptions as dh, type UpsertQueryInput as di, type ValibotIssueLike as dj, type ValibotPathItemLike as dk, type ValibotSafeParseLike as dl, type ValibotSafeParseResult as dm, type ValidateAccess as dn, type ValidateRule as dp, type Validation as dq, type ValidationError as dr, type VineValidationErrorLike as ds, type VineValidationMessageLike as dt, type VineValidatorLike as du, type VirtualSubModel as dv, type WithVirtuals as dw, type YupSchemaLike as dx, type YupValidationErrorLike as dy, defineRequestSchema as dz, type AdvancedCreateBody as e, type OpenApiMethod as e0, type Permissions as e1, defaultRuntime as e2, type AdvancedListBody as f, type AdvancedReadBody as g, type AdvancedReadFilterBody as h, type AdvancedUpdateBody as i, type AdvancedUpsertBody as j, type AfterPersistAccess as k, type AjvErrorObjectLike as l, type AjvValidationErrorLike as m, type AjvValidatorLike as n, type AllowedOutputFieldOptions as o, type ArkTypeErrorsLike as p, type ArkTypeLike as q, type ArkTypeProblemLike as r, type AuthorizedListResult as s, type AuthorizedSingleResult as t, Codes as u, type CorrelatedCountInclude as v, type CorrelatedFilter as w, type CorrelatedInclude as x, type CorrelatedIncludeArgs as y, type CorrelatedListInclude as z };
3752
+ export { type DecorateAccess as $, type AccessRouterBaseRequest as A, type BaseFilterAccess as B, type Change as C, type CorrelatedReadByFilterInclude as D, type CorrelatedReadByIdInclude as E, type CountBody as F, type CreateArgs as G, type CreateAuthorization as H, type CreateOptions as I, type CreateQueryInput as J, CustomHeaders as K, DATA_MIDDLEWARE as L, type DataBaseFilterHook as M, type DataFieldOptions as N, type DataFilter as O, type DataFindArgs as P, type DataFindOneArgs as Q, type DataFindOneOptions as R, type DataFindOptions as S, type DataHook as T, type DataHookContext as U, type DataIdentifierHook as V, type DataListHook as W, type DataOverrideFilterHook as X, type DataRequest as Y, type DataRequestSchemas as Z, type DataRouterOptions as _, type AccessRouterFieldKey as a, type ModelVirtualGetter as a$, type DecorateAllAccess as a0, type DeepFieldPath as a1, type DefaultModelRouterOptions as a2, type Defaults as a3, type DistinctArgs as a4, type DistinctBody as a5, type DocPermissionsAccess as a6, type DocumentAuthorization as a7, type ErrorResult as a8, type ExistsOptions as a9, type JoiValidationErrorDetailLike as aA, type KeyValueProjection as aB, type LegacyInclude as aC, type ListQueryInput as aD, type ListResult as aE, MIDDLEWARE as aF, type MaybePromise as aG, type ModelBaseFilterHook as aH, type ModelChangeHook as aI, type ModelDeleteHook as aJ, type ModelDocPermissionsHook as aK, type ModelDocument as aL, type ModelDocumentHook as aM, type ModelHook as aN, type ModelHookContext as aO, type ModelHydrationOptions as aP, type ModelIdentifierHook as aQ, type ModelListHook as aR, type ModelOverrideFilterHook as aS, type ModelRequest as aT, type ModelRouterOptions as aU, type ModelValidateHook as aV, type ModelVirtualAccess as aW, type ModelVirtualAccessRecord as aX, type ModelVirtualContext as aY, type ModelVirtualDescriptor as aZ, type ModelVirtualDoc as a_, type ExtendedDataRouterOptions as aa, type ExtendedDefaultModelRouterOptions as ab, type ExtendedModelRouterOptions as ac, type FieldAuthorization as ad, type FieldOperationAccess as ae, type Filter as af, FilterOperator as ag, type FindAccess as ah, type FindArgs as ai, type FindByIdArgs as aj, type FindByIdOptions as ak, type FindOneArgs as al, type FindOneOptions as am, type FindOptions as an, type GlobalOptions as ao, type GlobalPermissionValue as ap, type GuardHook as aq, type HydrationMode as ar, type IdentifierHook as as, type Include as at, type InputFieldAuthorization as au, type InputFieldPath as av, type IoTsContextEntryLike as aw, type IoTsDecodeErrorLike as ax, type IoTsDecoderLike as ay, type JoiSchemaLike as az, type AccessRouterLogger as b, type RootModelDistinctQueryEntry as b$, type ModelVirtualLeaf as b0, type ModelVirtualPopulateDependency as b1, type ModelVirtualPopulateInputs as b2, type ModelVirtualRecordAccess as b3, type ModelVirtuals as b4, type MutationAuthorization as b5, type NewArgs as b6, type NewOptions as b7, type OperationAccess as b8, type OperationAuthorization as b9, type PublicSubdocumentCreateOptions as bA, type PublicSubdocumentListOptions as bB, type PublicSubdocumentMutationOptions as bC, type PublicSubdocumentReadOptions as bD, type PublicUpdateArgs as bE, type PublicUpdateOptions as bF, type PublicUpsertArgs as bG, type PublicUpsertOptions as bH, type ReadQueryInput as bI, type RelatedAuthorization as bJ, type Request as bK, type RequestSchemaAdapter as bL, type RequestSchemaFailure as bM, type RequestSchemaIssue as bN, type RequestSchemaLike as bO, type RequestSchemaOptions as bP, type RequestSchemaResult as bQ, type RequestSchemaSuccess as bR, type RequestSchemaValidator as bS, type RequestSchemas as bT, type RootDataListQueryEntry as bU, type RootDataOperation as bV, type RootDataReadByFilterQueryEntry as bW, type RootDataReadByIdQueryEntry as bX, type RootModelCountQueryEntry as bY, type RootModelCreateQueryEntry as bZ, type RootModelDeleteQueryEntry as b_, type OutputAuthorization as ba, type OutputFieldOptions as bb, type OutputFieldPath as bc, type OutputPlanningOptions as bd, PERMISSIONS as be, PERMISSION_KEYS as bf, type PairedRouteAccess as bg, type ParentRef as bh, type PathValue as bi, type PermissionSchema as bj, type Populate as bk, type PopulateAccess as bl, type PopulatePlanningOptions as bm, type PrepareAccess as bn, type Projection as bo, type PublicCreateArgs as bp, type PublicCreateOptions as bq, type PublicErrorResult as br, type PublicListArgs as bs, type PublicListOptions as bt, type PublicListResult as bu, type PublicOutput as bv, type PublicReadArgs as bw, type PublicReadOptions as bx, type PublicServiceResult as by, type PublicSingleResult as bz, type AccessRouterRequest as c, type SubdocumentParentArgs as c$, type RootModelListQueryEntry as c0, type RootModelNewQueryEntry as c1, type RootModelOperation as c2, type RootModelReadByFilterQueryEntry as c3, type RootModelReadByIdQueryEntry as c4, type RootModelSubBulkUpdateQueryEntry as c5, type RootModelSubCreateQueryEntry as c6, type RootModelSubDeleteQueryEntry as c7, type RootModelSubListQueryEntry as c8, type RootModelSubReadQueryEntry as c9, type StandardSchemaPathSegment as cA, type StandardSchemaResult as cB, type StandardSchemaSuccess as cC, type StandardSchemaV1 as cD, StatusCodes as cE, type SubListBody as cF, type SubOperationAccess as cG, type SubPopulate as cH, type SubQueryEntry as cI, type SubReadBody as cJ, type SubRouteGuardOptions as cK, type SubdocumentBulkRecord as cL, type SubdocumentBulkUpdateInput as cM, type SubdocumentCreateAuthorization as cN, type SubdocumentCreateInput as cO, type SubdocumentCreateOptions as cP, type SubdocumentCreateVisibilityAuthorization as cQ, type SubdocumentDeleteAuthorization as cR, type SubdocumentDeleteOptions as cS, type SubdocumentGateAuthorization as cT, type SubdocumentId as cU, type SubdocumentInputAuthorization as cV, type SubdocumentListOptions as cW, type SubdocumentModel as cX, type SubdocumentMutationAuthorization as cY, type SubdocumentName as cZ, type SubdocumentOutputAuthorization as c_, type RootModelSubUpdateQueryEntry as ca, type RootModelUpdateQueryEntry as cb, type RootModelUpsertQueryEntry as cc, type RootOperationResult as cd, type RootQueryEntry as ce, type RootRouterOptions as cf, type RootSubOperation as cg, type RootTarget as ch, type RouteBaseAccess as ci, type RouteGuardAccess as cj, type RouteVariant as ck, type RouteVariantAccess as cl, type RowAuthorization as cm, type SelectAccess as cn, type SelectedPopulatedPublicOutput as co, type SelectedPublicOutput as cp, type ServiceAuthorization as cq, type ServiceOutputContext as cr, type ServiceOutputDecorator as cs, type ServiceResult as ct, type SingleResult as cu, type Sort as cv, type SortOrder as cw, type StandardSchemaFailure as cx, type StandardSchemaInferOutput as cy, type StandardSchemaIssue as cz, type AccessRouterRequestExtensions as d, type OpenApiResponses as d$, type SubdocumentParentOptions as d0, type SubdocumentReadAuthorization as d1, type SubdocumentReadOptions as d2, type SubdocumentRecord as d3, type SubdocumentUpdateOptions as d4, type SubdocumentVirtuals as d5, type SubdocumentVisibilityAuthorization as d6, type SuperstructFailureLike as d7, type SuperstructValidateLike as d8, type Task as d9, type YupValidationErrorLike as dA, defineRequestSchema as dB, fromAjv as dC, fromArkType as dD, fromIoTs as dE, fromJoi as dF, fromStandardSchema as dG, fromSuperstruct as dH, fromValibot as dI, fromVine as dJ, fromYup as dK, fromZod as dL, parseBody as dM, parseBodyWithSchema as dN, parseNestedBodyWithSchema as dO, parsePathParam as dP, parseQuery as dQ, AccessRuntime as dR, DataService as dS, Service as dT, PublicService as dU, type OpenApiRouterOptions as dV, type OpenApiRegistryOptions as dW, type OpenApiRouteDescriptor as dX, type OpenApiDocumentOptions as dY, type OpenApiParameter as dZ, type OpenApiSchema as d_, type TaskType as da, type TransformAccess as db, type TypedFilter as dc, type UpdateByIdArgs as dd, type UpdateByIdOptions as de, type UpdateOneArgs as df, type UpdateOneOptions as dg, type UpdateQueryInput as dh, type UpsertArgs as di, type UpsertOptions as dj, type UpsertQueryInput as dk, type ValibotIssueLike as dl, type ValibotPathItemLike as dm, type ValibotSafeParseLike as dn, type ValibotSafeParseResult as dp, type ValidateAccess as dq, type ValidateRule as dr, type Validation as ds, type ValidationError as dt, type VineValidationErrorLike as du, type VineValidationMessageLike as dv, type VineValidatorLike as dw, type VirtualSubModel as dx, type WithVirtuals as dy, type YupSchemaLike as dz, type AdvancedCreateBody as e, type AccessRouterPermissionMap as e0, type AccessRouterPermissions as e1, type OpenApiMethod as e2, type Permissions as e3, defaultRuntime as e4, type AdvancedListBody as f, type AdvancedReadBody as g, type AdvancedReadFilterBody as h, type AdvancedUpdateBody as i, type AdvancedUpsertBody as j, type AfterPersistAccess as k, type AjvErrorObjectLike as l, type AjvValidationErrorLike as m, type AjvValidatorLike as n, type AllowedOutputFieldOptions as o, type ArkTypeErrorsLike as p, type ArkTypeLike as q, type ArkTypeProblemLike as r, type AuthorizedListResult as s, type AuthorizedSingleResult as t, Codes as u, type CorrelatedCountInclude as v, type CorrelatedFilter as w, type CorrelatedInclude as x, type CorrelatedIncludeArgs as y, type CorrelatedListInclude as z };