@web-ts-toolkit/access-router 0.32.0 → 0.34.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.
@@ -0,0 +1,1702 @@
1
+ import { z } from 'zod';
2
+ import mongoose from 'mongoose';
3
+ import express from 'express';
4
+
5
+ interface BooleanObject {
6
+ [key: string]: boolean;
7
+ }
8
+ interface AccessRouterPermissionMap {
9
+ }
10
+ type AccessRouterPermissionKey = Extract<keyof AccessRouterPermissionMap, string>;
11
+ type PermissionName = AccessRouterPermissionKey | (string & {});
12
+ declare class Permission {
13
+ private readonly permissions;
14
+ private readonly permissionKeys;
15
+ constructor(permissions: BooleanObject);
16
+ get keys(): readonly string[];
17
+ private normalizePermissionArgs;
18
+ hasKey(permission: PermissionName): boolean;
19
+ has(permission: PermissionName): boolean;
20
+ hasAny(permissionOrPermissions: PermissionName | readonly PermissionName[], ...permissions: PermissionName[]): boolean;
21
+ hasAll(permissionOrPermissions: PermissionName | readonly PermissionName[], ...permissions: PermissionName[]): boolean;
22
+ }
23
+
24
+ type Permissions = Permission;
25
+ type AccessRouterPermissions = Permission;
26
+
27
+ type OpenApiMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
28
+ type OpenApiSchema = Record<string, unknown>;
29
+ type OpenApiSchemaSource = unknown;
30
+ type OpenApiParameter = {
31
+ name: string;
32
+ in: 'path' | 'query';
33
+ required?: boolean;
34
+ description?: string;
35
+ schema?: OpenApiSchema;
36
+ };
37
+ type OpenApiResponse = {
38
+ description: string;
39
+ content?: Record<string, {
40
+ schema: OpenApiSchema;
41
+ }>;
42
+ };
43
+ type OpenApiResponses = Record<string, OpenApiResponse>;
44
+ type OpenApiRouteDescriptor = {
45
+ method: OpenApiMethod;
46
+ path: string;
47
+ operationId?: string;
48
+ summary?: string;
49
+ description?: string;
50
+ tags?: string[];
51
+ acl?: string;
52
+ deprecated?: boolean;
53
+ query?: OpenApiSchemaSource;
54
+ body?: OpenApiSchemaSource;
55
+ pathParams?: Record<string, OpenApiSchemaSource>;
56
+ responses?: OpenApiResponses;
57
+ /**
58
+ * When true, replaces an existing registration with the same method/path
59
+ * even when the descriptors differ. When false (default), conflicting
60
+ * registrations throw at registration time so consumers can detect
61
+ * accidental route shadowing.
62
+ */
63
+ allowReplace?: boolean;
64
+ /**
65
+ * When true, this exact descriptor is idempotent and registering the same
66
+ * method/path with an equivalent descriptor again is silently accepted.
67
+ * Differing re-registrations still throw unless {@link allowReplace} is set.
68
+ * Additionally, an idempotent descriptor may share its operationId with
69
+ * another idempotent descriptor mounted at a different path on the same
70
+ * registry, so reserved operations (e.g. the root batch route) can be
71
+ * exposed from multiple base paths without triggering strict-mode
72
+ * duplicate-operationId rejection.
73
+ */
74
+ idempotent?: boolean;
75
+ };
76
+ type OpenApiRegistryOptions = {
77
+ /**
78
+ * Throw when the same method/path is registered twice with differing
79
+ * descriptors, instead of silently replacing. Default: true (strict).
80
+ * The {@link AccessRuntime} registry is constructed in strict mode by
81
+ * default; construct {@link OpenApiRegistry} directly with
82
+ * `rejectConflicts: false` for legacy replacement semantics.
83
+ */
84
+ rejectConflicts?: boolean;
85
+ /**
86
+ * Throw when the same operationId is registered more than once, including
87
+ * when {@link OpenApiRouteDescriptor.allowReplace} is set. Default: true.
88
+ */
89
+ rejectDuplicateOperationIds?: boolean;
90
+ };
91
+ type OpenApiDocumentOptions = {
92
+ title: string;
93
+ version: string;
94
+ description?: string;
95
+ servers?: Array<{
96
+ url: string;
97
+ description?: string;
98
+ }>;
99
+ };
100
+ type OpenApiRouterOptions = Partial<OpenApiDocumentOptions> & {
101
+ jsonPath?: string;
102
+ docsPath?: string | false;
103
+ swaggerUiCssUrl?: string;
104
+ swaggerUiBundleUrl?: string;
105
+ };
106
+
107
+ declare class AccessRuntime {
108
+ constructor();
109
+ private readonly globalOptions;
110
+ private readonly defaultModelOptions;
111
+ private readonly modelOptions;
112
+ private readonly modelJsonSchemas;
113
+ private readonly dataOptions;
114
+ private readonly modelRefs;
115
+ private readonly modelSubs;
116
+ private readonly modelAtts;
117
+ private readonly modelInstances;
118
+ private readonly openApiRegistry;
119
+ registerModelInstance(modelName: string, model: mongoose.Model<unknown>): void;
120
+ hasModelInstance(modelName: string): boolean;
121
+ getModelInstance(modelName: string): mongoose.Model<unknown> | null;
122
+ registerOpenApiRoute(route: OpenApiRouteDescriptor): void;
123
+ /**
124
+ * Enable strict OpenAPI collision detection for the remainder of this
125
+ * runtime's lifetime. After this call, conflicting method/path
126
+ * registrations and duplicate operationIds throw {@link OpenApiCollisionError}
127
+ * instead of silently replacing. Existing already-registered routes are
128
+ * not retroactively re-validated.
129
+ */
130
+ enableOpenApiCollisionDetection(): void;
131
+ getOpenApiRoutes(): OpenApiRouteDescriptor[];
132
+ clearOpenApiRoutes(): void;
133
+ getOpenApiSpec(info: OpenApiDocumentOptions): {
134
+ openapi: string;
135
+ info: Omit<OpenApiDocumentOptions, "servers">;
136
+ servers?: OpenApiDocumentOptions["servers"];
137
+ paths: Record<string, Record<string, {
138
+ [key: `x-${string}`]: unknown;
139
+ operationId?: string;
140
+ summary?: string;
141
+ description?: string;
142
+ tags?: string[];
143
+ deprecated?: boolean;
144
+ parameters?: OpenApiParameter[];
145
+ requestBody?: {
146
+ required?: boolean;
147
+ content: Record<string, {
148
+ schema: OpenApiSchema;
149
+ }>;
150
+ };
151
+ responses: OpenApiResponses;
152
+ }>>;
153
+ };
154
+ setGlobalOptions(options: GlobalOptions): void;
155
+ setGlobalOption<K extends keyof GlobalOptions>(key: K, value: GlobalOptions[K]): void;
156
+ getGlobalOptions(): GlobalOptions;
157
+ getGlobalOption<K extends keyof GlobalOptions>(key: K, defaultValue?: GlobalOptions[K]): GlobalOptions[K];
158
+ setDefaultModelOptions(options: DefaultModelRouterOptions): void;
159
+ setDefaultModelOption<K extends keyof ExtendedDefaultModelRouterOptions>(key: K, value: ExtendedDefaultModelRouterOptions[K]): void;
160
+ getDefaultModelOptions(): DefaultModelRouterOptions<unknown>;
161
+ getDefaultModelOption<K extends keyof ExtendedDefaultModelRouterOptions>(key: K, defaultValue?: ExtendedDefaultModelRouterOptions[K]): ExtendedDefaultModelRouterOptions<unknown>[K];
162
+ private createModelOptions;
163
+ private getOrCreateModelOptions;
164
+ setModelOptions<TModel = unknown>(modelName: string, options: ModelRouterOptions<TModel>): void;
165
+ setModelOption<K extends keyof ExtendedModelRouterOptions<TModel>, TModel = unknown>(modelName: string, key: K, value: ExtendedModelRouterOptions<TModel>[K]): void;
166
+ getModelOptions<TModel = unknown>(modelName: string): ModelRouterOptions<TModel>;
167
+ getModelOption<K extends keyof ExtendedModelRouterOptions<TModel>, TModel = unknown>(modelName: string, key: K | string, defaultValue?: ExtendedModelRouterOptions<TModel>[K]): ExtendedModelRouterOptions<TModel>[K];
168
+ getExactModelOption<K extends keyof ExtendedModelRouterOptions<TModel>, TModel = unknown>(modelName: string, key: K | string): ExtendedModelRouterOptions<TModel>[K];
169
+ getModelNames(): string[];
170
+ hasModel(modelName: string): boolean;
171
+ getModelJsonSchema(modelName: string): Record<string, unknown>;
172
+ private createDataOptions;
173
+ private getOrCreateDataOptions;
174
+ setDataOptions<TData = unknown>(dataName: string, options: DataRouterOptions<TData>): void;
175
+ setDataOption<K extends keyof DataRouterOptions<TData>, TData = unknown>(dataName: string, key: K, value: DataRouterOptions<TData>[K]): void;
176
+ getDataOptions<TData = unknown>(dataName: string): DataRouterOptions<TData>;
177
+ getDataOption<K extends keyof DataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string, defaultValue?: DataRouterOptions<TData>[K]): DataRouterOptions<TData>[K];
178
+ getExactDataOption<K extends keyof ExtendedDataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string): ExtendedDataRouterOptions<TData>[K];
179
+ getDataNames(): string[];
180
+ ensureModelMeta(modelName: string): void;
181
+ getModelRef(modelName: string, refPath: string): string | null;
182
+ getModelSub(modelName: string): string[];
183
+ getModelAtt(modelName: string): string[];
184
+ }
185
+ declare const defaultRuntime: AccessRuntime;
186
+
187
+ interface FindProps {
188
+ filter: Filter;
189
+ select?: Projection;
190
+ sort?: Sort;
191
+ populate?: Populate[] | string;
192
+ limit?: string | number;
193
+ hardLimit?: number;
194
+ skip?: string | number;
195
+ lean?: boolean;
196
+ }
197
+ interface FindOneProps {
198
+ filter: Filter;
199
+ select?: Projection;
200
+ sort?: Sort;
201
+ populate?: Populate[] | string;
202
+ lean?: boolean;
203
+ }
204
+ type SortValue = 1 | -1 | 'asc' | 'ascending' | 'desc' | 'descending';
205
+ type SortType = string | [string, SortValue][] | {
206
+ [key: string]: SortValue;
207
+ } | Map<string, SortValue> | null | undefined;
208
+ declare class Model {
209
+ modelName: string;
210
+ model: mongoose.Model<any>;
211
+ runtime: AccessRuntime | null;
212
+ constructor(modelName: string, runtime?: AccessRuntime);
213
+ new(): any;
214
+ create(data: unknown): Promise<any>;
215
+ find({ filter, select, sort, populate, limit, hardLimit, skip, lean }: FindProps): mongoose.Query<any[], any, {}, any, "find", {}>;
216
+ validateSort(sort: SortType, logError?: (msg: string, ...args: unknown[]) => void): boolean;
217
+ findOne({ filter, select, sort, populate, lean }: FindOneProps): mongoose.Query<any, any, {}, any, "findOne", {}>;
218
+ exists(filter: Filter): ReturnType<typeof Model.prototype.findOne> | null;
219
+ countDocuments(filter?: {}): mongoose.Query<number, any, {}, any, "countDocuments", {}>;
220
+ distinct(field: string, conditions?: {}): mongoose.Query<any[], any, {}, any, "distinct", {}>;
221
+ }
222
+
223
+ declare class Service<TModel = unknown> extends Base<TModel> {
224
+ protected model: Model;
225
+ protected options: ModelRouterOptions<TModel>;
226
+ defaults: Defaults<TModel>;
227
+ protected baseFields: string[];
228
+ protected baseFieldsExt: string[];
229
+ findRawParentDoc(args: {
230
+ filter: Filter<TModel>;
231
+ select: string;
232
+ populate: unknown;
233
+ lean: boolean;
234
+ }): ReturnType<Model['findOne']>;
235
+ private asServiceHookContext;
236
+ private beginOp;
237
+ private completeOp;
238
+ constructor(req: ModelRequest, modelName: string);
239
+ findOne(filter: Filter<TModel>, args?: FindOneArgs<TModel>, options?: FindOneOptions): Promise<SingleResult<TModel> | ErrorResult>;
240
+ findById(id: string, args?: FindByIdArgs<TModel>, options?: FindByIdOptions): Promise<SingleResult<TModel> | ErrorResult>;
241
+ find(filter: Filter<TModel>, args?: FindArgs<TModel>, options?: FindOptions, decorate?: (doc: unknown, context?: ModelHookContext) => unknown): Promise<ListResult<TModel> | ErrorResult>;
242
+ create(data: Record<string, unknown> | Record<string, unknown>[], args?: CreateArgs, options?: CreateOptions, decorate?: (doc: unknown, context?: ModelHookContext) => unknown): Promise<ListResult<TModel> | ErrorResult>;
243
+ private formatBulkValidationIssue;
244
+ new(args?: {
245
+ select?: string[];
246
+ }, options?: {
247
+ skim?: boolean;
248
+ includePermissions?: boolean;
249
+ }): Promise<SingleResult<TModel>>;
250
+ updateOne(filter: Filter<TModel>, data: Record<string, unknown>, args?: UpdateOneArgs<TModel>, options?: UpdateOneOptions, decorate?: (doc: unknown, context?: ModelHookContext) => unknown): Promise<SingleResult<TModel> | ErrorResult>;
251
+ updateById(id: string, data: Record<string, unknown>, args?: UpdateByIdArgs<TModel>, options?: UpdateByIdOptions, decorate?: (doc: unknown, context?: ModelHookContext) => unknown): Promise<SingleResult<TModel> | ErrorResult>;
252
+ upsert(filter: Filter<TModel>, data: Record<string, unknown>, args?: UpsertArgs<TModel>, options?: UpsertOptions, decorate?: (doc: unknown, context?: ModelHookContext) => unknown): Promise<ServiceResult<TModel>>;
253
+ delete(id: string): Promise<SingleResult<unknown> | ErrorResult>;
254
+ exists(filter: Filter<TModel>, options: ExistsOptions & {
255
+ includeId: true;
256
+ }): Promise<SingleResult<unknown> | ErrorResult>;
257
+ exists(filter: Filter<TModel>, options?: ExistsOptions): Promise<SingleResult<boolean> | ErrorResult>;
258
+ protected isValidDistinctFieldName(field: unknown): boolean;
259
+ protected authorizeDistinctField(field: string): Promise<ErrorResult | null>;
260
+ distinct(field: string, args?: DistinctArgs<TModel>): Promise<ListResult<unknown> | ErrorResult>;
261
+ count(filter: Filter<TModel>, access?: BaseFilterAccess): Promise<SingleResult<number> | ErrorResult>;
262
+ getDocPermissions(doc: unknown): Record<string, unknown>;
263
+ private resolveFindOneArgs;
264
+ private resolveFindOneOptions;
265
+ private resolveFindByIdArgs;
266
+ private resolveFindByIdOptions;
267
+ private resolveFindArgs;
268
+ private resolveFindOptions;
269
+ private resolveCreateArgs;
270
+ private resolveCreateOptions;
271
+ private resolveUpdateOneArgs;
272
+ private resolveUpdateOneOptions;
273
+ private resolveUpdateByIdArgs;
274
+ private resolveUpdateByIdOptions;
275
+ private resolveUpsertArgs;
276
+ private resolveUpsertOptions;
277
+ private resolveExistsOptions;
278
+ private getFieldPermissionAccess;
279
+ private getAccessibleIdSet;
280
+ listSub(id: SubdocumentId, sub: SubdocumentName, options?: SubdocumentListOptions<TModel>): Promise<ListResult | ErrorResult>;
281
+ readSub(id: SubdocumentId, sub: SubdocumentName, subId: SubdocumentId, options?: SubdocumentReadOptions): Promise<SingleResult | ErrorResult>;
282
+ updateSub(id: SubdocumentId, sub: SubdocumentName, subId: SubdocumentId, data: Record<string, unknown>): Promise<SingleResult | ErrorResult>;
283
+ bulkUpdateSub(id: SubdocumentId, sub: SubdocumentName, data: SubdocumentBulkUpdateInput | Record<string, unknown>): Promise<ListResult | ErrorResult>;
284
+ createSub(id: SubdocumentId, sub: SubdocumentName, data: SubdocumentCreateInput, options?: SubdocumentCreateOptions): Promise<ListResult | ErrorResult>;
285
+ deleteSub(id: SubdocumentId, sub: SubdocumentName, subId: SubdocumentId): Promise<SingleResult | ErrorResult>;
286
+ getParentDoc(id: SubdocumentId, sub: SubdocumentName, args?: SubdocumentParentArgs, options?: SubdocumentParentOptions): Promise<any>;
287
+ }
288
+
289
+ declare class PublicService<TModel = unknown> extends Service<TModel> {
290
+ _list<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(filter: Filter<TModel>, args?: Omit<PublicListArgs, 'select' | 'populate'> & {
291
+ select?: TSelect;
292
+ populate?: TPopulate;
293
+ }, options?: PublicListOptions): Promise<ListResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
294
+ _create<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(data: unknown, args?: Omit<PublicCreateArgs, 'select' | 'populate'> & {
295
+ select?: TSelect;
296
+ populate?: TPopulate;
297
+ }, options?: PublicCreateOptions): Promise<ListResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
298
+ _new(args?: {
299
+ select?: string[];
300
+ }, options?: {
301
+ skim?: boolean;
302
+ includePermissions?: boolean;
303
+ }): Promise<SingleResult<PublicOutput<TModel>>>;
304
+ _read<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(id: string, args?: Omit<PublicReadArgs, 'select' | 'populate'> & {
305
+ select?: TSelect;
306
+ populate?: TPopulate;
307
+ }, options?: PublicReadOptions): Promise<SingleResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
308
+ _readFilter<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(filter: Filter<TModel>, args?: Omit<PublicReadArgs, 'select' | 'populate'> & {
309
+ select?: TSelect;
310
+ populate?: TPopulate;
311
+ sort?: Sort;
312
+ }, options?: PublicReadOptions): Promise<SingleResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
313
+ _update<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(id: string, data: Record<string, unknown>, args?: Omit<PublicUpdateArgs, 'select' | 'populate'> & {
314
+ select?: TSelect;
315
+ populate?: TPopulate;
316
+ }, options?: PublicUpdateOptions): Promise<SingleResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
317
+ _upsert<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(data: Record<string, unknown>, args?: Omit<PublicUpsertArgs, 'select' | 'populate'> & {
318
+ select?: TSelect;
319
+ populate?: TPopulate;
320
+ }, options?: PublicUpsertOptions): Promise<ServiceResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
321
+ _delete(id: string): Promise<SingleResult<unknown> | ErrorResult>;
322
+ _distinct(field: string, options?: DistinctArgs<TModel>): Promise<ListResult<unknown> | ErrorResult>;
323
+ _count(filter: Filter<TModel>, access?: BaseFilterAccess): Promise<SingleResult<number> | ErrorResult>;
324
+ private resolvePublicListArgs;
325
+ private resolvePublicListOptions;
326
+ private resolvePublicCreateArgs;
327
+ private resolvePublicCreateOptions;
328
+ private resolvePublicReadArgs;
329
+ private resolvePublicReadFilterArgs;
330
+ private resolvePublicReadOptions;
331
+ private resolvePublicUpdateArgs;
332
+ private resolvePublicUpdateOptions;
333
+ }
334
+
335
+ type ValidationError = {
336
+ detail: string;
337
+ pointer?: string;
338
+ parameter?: string;
339
+ };
340
+ type RequestSchemaIssue = {
341
+ message: string;
342
+ path?: Array<string | number>;
343
+ };
344
+ type RequestSchemaSuccess<T = unknown> = {
345
+ success: true;
346
+ data: T;
347
+ };
348
+ type RequestSchemaFailure = {
349
+ success: false;
350
+ issues: RequestSchemaIssue[];
351
+ };
352
+ type RequestSchemaResult<T = unknown> = RequestSchemaSuccess<T> | RequestSchemaFailure;
353
+ type RequestSchemaValidator<T = unknown> = (value: unknown) => RequestSchemaResult<T> | Promise<RequestSchemaResult<T>>;
354
+ type RequestSchemaAdapter<T = unknown> = {
355
+ validate: RequestSchemaValidator<T>;
356
+ openapi?: Record<string, unknown>;
357
+ };
358
+ type RequestSchemaOptions = {
359
+ openapi?: Record<string, unknown>;
360
+ };
361
+ type StandardSchemaPathSegment = {
362
+ key: PropertyKey;
363
+ };
364
+ type StandardSchemaIssue = {
365
+ message: string;
366
+ path?: ReadonlyArray<PropertyKey | StandardSchemaPathSegment>;
367
+ };
368
+ type StandardSchemaSuccess<T = unknown> = {
369
+ value: T;
370
+ issues?: undefined;
371
+ };
372
+ type StandardSchemaFailure = {
373
+ issues: ReadonlyArray<StandardSchemaIssue>;
374
+ };
375
+ type StandardSchemaResult<T = unknown> = StandardSchemaSuccess<T> | StandardSchemaFailure;
376
+ type StandardSchemaV1<Input = unknown, Output = Input> = {
377
+ readonly '~standard': {
378
+ readonly version: 1;
379
+ readonly vendor: string;
380
+ readonly validate: (value: unknown, options?: {
381
+ readonly libraryOptions?: Record<string, unknown> | undefined;
382
+ }) => StandardSchemaResult<Output> | Promise<StandardSchemaResult<Output>>;
383
+ readonly types?: {
384
+ readonly input: Input;
385
+ readonly output: Output;
386
+ };
387
+ };
388
+ };
389
+ type StandardSchemaInferOutput<TSchema extends StandardSchemaV1> = NonNullable<TSchema['~standard']['types']>['output'];
390
+ type RequestSchemaLike<T = unknown> = RequestSchemaValidator<T> | RequestSchemaAdapter<T> | StandardSchemaV1;
391
+ type YupValidationErrorLike = {
392
+ message: string;
393
+ path?: string;
394
+ inner?: ReadonlyArray<YupValidationErrorLike>;
395
+ };
396
+ type YupSchemaLike<T = unknown> = {
397
+ validate: (value: unknown, options?: {
398
+ abortEarly?: boolean;
399
+ stripUnknown?: boolean;
400
+ }) => Promise<T> | T;
401
+ };
402
+ type JoiValidationErrorDetailLike = {
403
+ message: string;
404
+ path?: ReadonlyArray<string | number>;
405
+ };
406
+ type JoiSchemaLike<T = unknown> = {
407
+ validate: (value: unknown, options?: {
408
+ abortEarly?: boolean;
409
+ stripUnknown?: boolean;
410
+ }) => {
411
+ value: T;
412
+ error?: {
413
+ details?: ReadonlyArray<JoiValidationErrorDetailLike>;
414
+ };
415
+ } | Promise<{
416
+ value: T;
417
+ error?: {
418
+ details?: ReadonlyArray<JoiValidationErrorDetailLike>;
419
+ };
420
+ }>;
421
+ };
422
+ type AjvErrorObjectLike = {
423
+ message?: string;
424
+ instancePath?: string;
425
+ schemaPath?: string;
426
+ params?: {
427
+ missingProperty?: string;
428
+ };
429
+ };
430
+ type AjvValidatorLike<T = unknown> = {
431
+ (value: unknown): boolean | Promise<boolean>;
432
+ errors?: ReadonlyArray<AjvErrorObjectLike> | null;
433
+ };
434
+ type ValibotPathItemLike = {
435
+ key?: unknown;
436
+ };
437
+ type ValibotIssueLike = {
438
+ message: string;
439
+ path?: ReadonlyArray<ValibotPathItemLike>;
440
+ };
441
+ type ValibotSafeParseResult<T = unknown> = {
442
+ success: true;
443
+ output: T;
444
+ issues?: undefined;
445
+ } | {
446
+ success: false;
447
+ output?: undefined;
448
+ issues: ReadonlyArray<ValibotIssueLike>;
449
+ };
450
+ type ValibotSafeParseLike = <TSchema, TOutput = unknown>(schema: TSchema, value: unknown, config?: {
451
+ abortEarly?: boolean;
452
+ }) => ValibotSafeParseResult<TOutput> | Promise<ValibotSafeParseResult<TOutput>>;
453
+ type ArkTypeProblemLike = {
454
+ path?: ReadonlyArray<string | number>;
455
+ message?: string;
456
+ problem?: string;
457
+ };
458
+ type ArkTypeErrorsLike = ReadonlyArray<ArkTypeProblemLike> & {
459
+ summary?: string;
460
+ };
461
+ type ArkTypeLike<T = unknown> = {
462
+ (value: unknown): T | ArkTypeErrorsLike;
463
+ errors?: unknown;
464
+ };
465
+ type IoTsContextEntryLike = {
466
+ key: string;
467
+ };
468
+ type IoTsDecodeErrorLike = {
469
+ message?: string;
470
+ context: ReadonlyArray<IoTsContextEntryLike>;
471
+ };
472
+ type IoTsDecoderLike<T = unknown> = {
473
+ decode: (value: unknown) => {
474
+ _tag: 'Left';
475
+ left: ReadonlyArray<IoTsDecodeErrorLike>;
476
+ } | {
477
+ _tag: 'Right';
478
+ right: T;
479
+ };
480
+ };
481
+ type SuperstructFailureLike = {
482
+ message?: string;
483
+ path?: ReadonlyArray<string | number>;
484
+ key?: string | number;
485
+ branch?: ReadonlyArray<unknown>;
486
+ failures?: () => ReadonlyArray<SuperstructFailureLike>;
487
+ };
488
+ type SuperstructValidateLike = <TStruct, TOutput = unknown>(value: unknown, struct: TStruct) => readonly [failure: SuperstructFailureLike, value: undefined] | readonly [failure: undefined, value: TOutput] | Promise<readonly [failure: SuperstructFailureLike, value: undefined] | readonly [failure: undefined, value: TOutput]>;
489
+ type VineValidationMessageLike = {
490
+ field: string;
491
+ message: string;
492
+ index?: number;
493
+ };
494
+ type VineValidationErrorLike = {
495
+ messages: ReadonlyArray<VineValidationMessageLike>;
496
+ };
497
+ type VineValidatorLike<T = unknown> = {
498
+ validate: (value: unknown) => Promise<T> | T;
499
+ };
500
+ type ListQueryInput = {
501
+ skip?: string;
502
+ limit?: string;
503
+ page?: string;
504
+ page_size?: string;
505
+ skim?: 'true' | 'false';
506
+ include_permissions?: 'true' | 'false';
507
+ include_count?: 'true' | 'false';
508
+ include_extra_headers?: 'true' | 'false';
509
+ };
510
+ type CreateQueryInput = {
511
+ include_permissions?: 'true' | 'false';
512
+ };
513
+ type ReadQueryInput = {
514
+ include_permissions?: 'true' | 'false';
515
+ try_list?: 'true' | 'false';
516
+ };
517
+ type UpdateQueryInput = {
518
+ returning_all?: 'true' | 'false';
519
+ };
520
+ type UpsertQueryInput = {
521
+ returning_all?: 'true' | 'false';
522
+ include_permissions?: 'true' | 'false';
523
+ };
524
+ type AdvancedListBody = {
525
+ filter?: Filter | unknown[];
526
+ select?: Projection;
527
+ sort?: Sort;
528
+ populate?: Populate[] | string;
529
+ include?: Include | Include[];
530
+ tasks?: Task | Task[];
531
+ skip?: string | number;
532
+ limit?: string | number;
533
+ page?: string | number;
534
+ pageSize?: string | number;
535
+ options?: {
536
+ skim?: boolean;
537
+ includePermissions?: boolean;
538
+ includeCount?: boolean;
539
+ includeExtraHeaders?: boolean;
540
+ populateAccess?: unknown;
541
+ };
542
+ };
543
+ type CountBody = {
544
+ filter?: Filter | unknown[];
545
+ };
546
+ type AdvancedReadFilterBody = {
547
+ filter?: Filter | unknown[];
548
+ select?: Projection;
549
+ sort?: Sort;
550
+ populate?: Populate[] | string;
551
+ include?: Include | Include[];
552
+ tasks?: Task | Task[];
553
+ options?: {
554
+ skim?: boolean;
555
+ includePermissions?: boolean;
556
+ tryList?: boolean;
557
+ populateAccess?: unknown;
558
+ };
559
+ };
560
+ type AdvancedReadBody = {
561
+ select?: Projection;
562
+ populate?: Populate[] | string;
563
+ include?: Include | Include[];
564
+ tasks?: Task | Task[];
565
+ options?: {
566
+ skim?: boolean;
567
+ includePermissions?: boolean;
568
+ tryList?: boolean;
569
+ populateAccess?: unknown;
570
+ };
571
+ };
572
+ type AdvancedCreateBody = {
573
+ data: unknown;
574
+ select?: Projection;
575
+ populate?: Populate[] | string;
576
+ tasks?: Task | Task[];
577
+ options?: {
578
+ includePermissions?: boolean;
579
+ populateAccess?: unknown;
580
+ };
581
+ };
582
+ type AdvancedUpdateBody = {
583
+ data: unknown;
584
+ select?: Projection;
585
+ populate?: Populate[] | string;
586
+ tasks?: Task | Task[];
587
+ options?: {
588
+ returningAll?: boolean;
589
+ includePermissions?: boolean;
590
+ populateAccess?: unknown;
591
+ };
592
+ };
593
+ type AdvancedUpsertBody = {
594
+ data: Record<string, unknown>;
595
+ select?: Projection;
596
+ populate?: Populate[] | string;
597
+ tasks?: Task | Task[];
598
+ options?: {
599
+ returningAll?: boolean;
600
+ includePermissions?: boolean;
601
+ populateAccess?: unknown;
602
+ };
603
+ };
604
+ type DistinctBody = {
605
+ filter?: Filter | unknown[];
606
+ };
607
+ type SubListBody = {
608
+ filter?: Filter;
609
+ select?: string[];
610
+ };
611
+ type SubReadBody = {
612
+ select?: string[];
613
+ populate?: SubPopulate | SubPopulate[] | string | string[];
614
+ };
615
+
616
+ interface RequestComplexityOptions {
617
+ maxDepth?: number;
618
+ maxNodes?: number;
619
+ maxLogicalClauses?: number;
620
+ maxInValues?: number;
621
+ maxBulkItems?: number;
622
+ maxIncludeCount?: number;
623
+ maxSubQueryCount?: number;
624
+ maxBulkConcurrency?: number;
625
+ }
626
+
627
+ type CrossResourceModelOperation = 'list' | 'read' | 'count';
628
+ declare class Base<TModel = unknown> {
629
+ protected req: ModelRequest;
630
+ protected modelName: string;
631
+ constructor(req: ModelRequest, modelName: string);
632
+ decorate<T>(doc: T, access: DecorateAccess, context: ModelHookContext): Promise<T>;
633
+ decorateAll<T>(docs: T[], access: DecorateAllAccess, context: ModelHookContext): Promise<T[]>;
634
+ genAllowedFields(doc: unknown, access: SelectAccess, baseFields?: string[]): Promise<string[]>;
635
+ genDocPermissions(doc: unknown, access: DocPermissionsAccess, context: ModelHookContext): Promise<Record<string, unknown>>;
636
+ genFilter(access?: BaseFilterAccess, filter?: Filter<TModel>): Promise<Filter<TModel>>;
637
+ getIdentifier(): string | null;
638
+ genIDFilter(id: string): Promise<Filter<TModel>>;
639
+ genPopulate(access?: SelectAccess, populate?: Populate | Populate[] | string | null): Promise<Populate[]>;
640
+ genSelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
641
+ genQuerySelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
642
+ addEmptyPermissions<T>(doc: T): T;
643
+ addDocPermissions<T>(doc: T, access: DocPermissionsAccess, context: ModelHookContext): Promise<T>;
644
+ addFieldPermissions<T extends {
645
+ _id?: unknown;
646
+ }>(doc: T, access: DocPermissionsAccess, context: ModelHookContext): Promise<T>;
647
+ pickAllowedFields<T>(doc: T, access: SelectAccess, baseFields?: string[]): Promise<T>;
648
+ trimOutputFields<T>(doc: T, access: SelectAccess, baseFields?: string[]): Promise<T>;
649
+ prepare<T>(allowedData: T, access: PrepareAccess, context: ModelHookContext): Promise<T>;
650
+ runTasks<T extends object>(docObject: T, tasks: Task | Task[]): T;
651
+ transform<T>(doc: T, access: TransformAccess, context: ModelHookContext): Promise<T>;
652
+ afterPersist<T>(doc: T, access: AfterPersistAccess, context: ModelHookContext): Promise<T>;
653
+ changes(doc: Record<string, unknown>, context: ModelHookContext): Promise<void>;
654
+ beforeDelete<T>(doc: T, context: ModelHookContext): Promise<void>;
655
+ afterDelete<T>(doc: T, context: ModelHookContext): Promise<void>;
656
+ validate(allowedData: unknown, access: ValidateAccess, context: ModelHookContext): Promise<boolean | unknown[]>;
657
+ checkIfModelPermissionExists(accesses: DocPermissionsAccess[]): boolean;
658
+ protected validateClientFilter(filter: Filter | null | undefined): string[];
659
+ getRequestComplexity(): Required<RequestComplexityOptions>;
660
+ protected getClientRequestErrorResult(error: unknown): ErrorResult | null;
661
+ protected throwClientRequestError(code: ErrorResult['code'], detail: string): never;
662
+ protected getAuthorizedTargetService(modelName: string, op: CrossResourceModelOperation): Promise<PublicService<unknown>>;
663
+ protected processInclude(include: Include | Include[]): {
664
+ includes: Include[];
665
+ includeLocalFields: string[];
666
+ includePaths: string[];
667
+ };
668
+ protected includeDocs<TDoc>(docs: TDoc | TDoc[], include: Include | Include[]): Promise<TDoc | TDoc[]>;
669
+ private includeDocsList;
670
+ private includeDocsCount;
671
+ protected parseClientData<TValue>(filter: TValue): Promise<TValue>;
672
+ private handleSubQuery;
673
+ private handleDate;
674
+ }
675
+
676
+ declare class DataService<T> {
677
+ protected req: DataRequest;
678
+ protected dataName: string;
679
+ protected options: DataRouterOptions<T>;
680
+ protected data: T[];
681
+ constructor(req: DataRequest, dataName: string);
682
+ findOne<TSelect extends Projection | undefined = undefined>(filter: DataFilter<T>, args?: DataFindOneArgs<T, TSelect>, options?: DataFindOneOptions): Promise<SingleResult<SelectedPublicOutput<T, TSelect>> | ErrorResult>;
683
+ findById<TSelect extends Projection | undefined = undefined>(id: string, args?: DataFindOneArgs<T, TSelect>, options?: DataFindOneOptions): Promise<SingleResult<SelectedPublicOutput<T, TSelect>> | ErrorResult>;
684
+ find<TSelect extends Projection | undefined = undefined>(filter: DataFilter<T>, args?: DataFindArgs<T, TSelect>, options?: DataFindOptions): Promise<ListResult<SelectedPublicOutput<T, TSelect>> | ErrorResult>;
685
+ decorate<TDoc>(doc: TDoc, access: DecorateAccess, context?: DataHookContext): Promise<TDoc>;
686
+ decorateAll<TDoc>(docs: TDoc[], access: DecorateAllAccess, context?: DataHookContext): Promise<TDoc[]>;
687
+ genAllowedFields(doc: unknown, access: SelectAccess, baseFields?: string[]): Promise<string[]>;
688
+ genFilter(access?: BaseFilterAccess, filter?: DataFilter<T>): Promise<DataFilter<T>>;
689
+ genIDFilter(id: string): Promise<DataFilter<T>>;
690
+ genSelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
691
+ genQuerySelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
692
+ pickAllowedFields<TDoc>(doc: TDoc, access: SelectAccess, baseFields?: string[]): Promise<TDoc>;
693
+ trimOutputFields<TDoc>(doc: TDoc, access: SelectAccess, baseFields?: string[]): Promise<TDoc>;
694
+ private validateSortFields;
695
+ }
696
+
697
+ type InternalModelHookContext = ModelHookContext & {
698
+ fieldPermissionAccess?: {
699
+ readIds?: Set<string>;
700
+ updateIds?: Set<string>;
701
+ };
702
+ };
703
+ declare class Core {
704
+ private req;
705
+ private caches;
706
+ constructor(req: AccessRouterBaseRequest);
707
+ getIdentifier(modelName: string): string;
708
+ genIDFilter<TModel = unknown>(modelName: string, id: string): Promise<Filter<TModel>>;
709
+ genFilter<TModel = unknown>(modelName: string, access?: BaseFilterAccess, _filter?: Filter<TModel>): Promise<Filter<TModel>>;
710
+ private removePrefix;
711
+ genAllowedFields(modelName: string, doc: unknown, access: SelectAccess, baseFields?: string[]): Promise<string[]>;
712
+ pickAllowedFields<T>(modelName: string, doc: T, access: SelectAccess, baseFields?: string[]): Promise<T>;
713
+ genSelect(modelName: string, access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
714
+ genPopulate(modelName: string, access?: SelectAccess | BaseFilterAccess, _populate?: Populate | Populate[] | string | null): Promise<(string | Populate)[]>;
715
+ validate(modelName: string, allowedData: unknown, access: ValidateAccess, context: ModelHookContext): Promise<boolean | unknown[]>;
716
+ prepare<T>(modelName: string, allowedData: T, access: PrepareAccess, context: ModelHookContext): Promise<T>;
717
+ transform<T>(modelName: string, doc: T, access: TransformAccess, context: ModelHookContext): Promise<T>;
718
+ afterPersist<T>(modelName: string, doc: T, access: AfterPersistAccess, context: ModelHookContext): Promise<T>;
719
+ changes(modelName: string, doc: Record<string, unknown>, context: ModelHookContext): Promise<void>;
720
+ beforeDelete<T>(modelName: string, doc: T, context: ModelHookContext): Promise<void>;
721
+ afterDelete<T>(modelName: string, doc: T, context: ModelHookContext): Promise<void>;
722
+ genDocPermissions(modelName: string, doc: unknown, access: DocPermissionsAccess, context: ModelHookContext): Promise<{}>;
723
+ addEmptyPermissions<T>(modelName: string, doc: T): T;
724
+ addDocPermissions<T>(modelName: string, doc: T, access: DocPermissionsAccess, context: ModelHookContext): Promise<T>;
725
+ addFieldPermissions<T extends {
726
+ _id?: unknown;
727
+ }>(modelName: string, doc: T, access: DocPermissionsAccess, context: InternalModelHookContext): Promise<T>;
728
+ decorate<T>(modelName: string, doc: T, access: DecorateAccess, context: ModelHookContext): Promise<T>;
729
+ decorateAll<T>(modelName: string, docs: T[], access: DecorateAllAccess, context: ModelHookContext): Promise<T[]>;
730
+ runTasks<T extends object>(modelName: string, docObject: T, task: Task | Task[]): T;
731
+ getPermissions(): Permission;
732
+ setPermissions(): Promise<void>;
733
+ canActivate(routeGuard: Validation): Promise<boolean>;
734
+ isAllowed(modelName: string, access: RouteGuardAccess | string): Promise<boolean>;
735
+ getService<TModel = unknown>(modelName: string): Service<TModel>;
736
+ getPublicService<TModel = unknown>(modelName: string): PublicService<TModel>;
737
+ service<TModel = unknown>(modelName: string): PublicService<TModel>;
738
+ svc<TModel = unknown>(modelName: string): PublicService<TModel>;
739
+ private getGlobalPermissions;
740
+ }
741
+
742
+ declare class DataCore {
743
+ private req;
744
+ private caches;
745
+ constructor(req: AccessRouterBaseRequest);
746
+ genIDFilter<TData = unknown>(dataName: string, id: string): Promise<Filter<TData>>;
747
+ genFilter<TData = unknown>(dataName: string, access?: BaseFilterAccess, _filter?: Filter<TData>): Promise<Filter<TData>>;
748
+ genAllowedFields(dataName: string, _doc: unknown, access: SelectAccess, baseFields?: string[]): Promise<string[]>;
749
+ pickAllowedFields<TDoc>(dataName: string, doc: TDoc, access: SelectAccess, baseFields?: string[]): Promise<TDoc>;
750
+ genSelect(dataName: string, access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise<string[]>;
751
+ decorate<TDoc>(dataName: string, doc: TDoc, access: DecorateAccess, context?: DataHookContext): Promise<TDoc>;
752
+ decorateAll<TDoc>(dataName: string, docs: TDoc[], access: DecorateAllAccess, context?: DataHookContext): Promise<TDoc[]>;
753
+ getPermissions(): Permission;
754
+ setPermissions(): Promise<void>;
755
+ canActivate(routeGuard: Validation): Promise<boolean>;
756
+ isAllowed(dataName: string, access: RouteGuardAccess | string): Promise<boolean>;
757
+ getService<TData = unknown>(dataName: string): DataService<TData>;
758
+ service<TData = unknown>(dataName: string): DataService<TData>;
759
+ svc<TData = unknown>(dataName: string): DataService<TData>;
760
+ private getGlobalPermissions;
761
+ }
762
+
763
+ declare enum StatusCodes {
764
+ OK = 200,
765
+ Created = 201,
766
+ BadRequest = 400,
767
+ Unauthorized = 401,
768
+ Forbidden = 403,
769
+ NotFound = 404,
770
+ UnprocessableContent = 422
771
+ }
772
+ declare enum Codes {
773
+ Success = "success",
774
+ Created = "created",
775
+ BadRequest = "bad_request",
776
+ Unauthorized = "unauthorized",
777
+ Forbidden = "forbidden",
778
+ NotFound = "not_found"
779
+ }
780
+ declare enum CustomHeaders {
781
+ TotalCount = "wtt-total-count",
782
+ ReturnedCount = "wtt-returned-count",
783
+ Page = "wtt-page",
784
+ PageSize = "wtt-page-size",
785
+ TotalPages = "wtt-total-pages",
786
+ HasNextPage = "wtt-has-next-page",
787
+ HasPreviousPage = "wtt-has-previous-page"
788
+ }
789
+ declare enum FilterOperator {
790
+ SubQuery = 0,
791
+ Date = 1
792
+ }
793
+
794
+ declare const MIDDLEWARE: unique symbol;
795
+ declare const DATA_MIDDLEWARE: unique symbol;
796
+ declare const PERMISSIONS: unique symbol;
797
+ declare const PERMISSION_KEYS: unique symbol;
798
+
799
+ interface AccessRouterRequestExtensions {
800
+ macl?: Core;
801
+ dacl?: DataCore;
802
+ [PERMISSIONS]?: AccessRouterPermissions;
803
+ [PERMISSION_KEYS]?: string[];
804
+ [MIDDLEWARE]?: unknown[] | unknown;
805
+ [DATA_MIDDLEWARE]?: unknown[] | unknown;
806
+ [key: string]: unknown;
807
+ [key: symbol]: unknown;
808
+ }
809
+ type AccessRouterRequest = express.Request & AccessRouterRequestExtensions;
810
+
811
+ interface PublicCreateArgs {
812
+ select?: Projection;
813
+ populate?: Populate[] | string;
814
+ tasks?: Task | Task[];
815
+ }
816
+ interface CreateArgs extends Omit<PublicCreateArgs, 'select' | 'tasks'> {
817
+ }
818
+ interface PublicCreateOptions {
819
+ skim?: boolean;
820
+ includePermissions?: boolean;
821
+ populateAccess?: PopulateAccess;
822
+ }
823
+ interface CreateOptions extends PublicCreateOptions {
824
+ }
825
+
826
+ interface PublicListArgs {
827
+ select?: Projection;
828
+ populate?: Populate[] | string;
829
+ include?: Include | Include[];
830
+ sort?: Sort;
831
+ skip?: string | number;
832
+ limit?: string | number;
833
+ page?: string | number;
834
+ pageSize?: string | number;
835
+ tasks?: Task | Task[];
836
+ }
837
+ interface PublicListOptions {
838
+ skim?: boolean;
839
+ includePermissions?: boolean;
840
+ includeCount?: boolean;
841
+ populateAccess?: PopulateAccess;
842
+ lean?: boolean;
843
+ }
844
+
845
+ interface PublicReadArgs {
846
+ select?: Projection;
847
+ populate?: Populate[] | string;
848
+ include?: Include | Include[];
849
+ tasks?: Task | Task[];
850
+ }
851
+ interface PublicReadOptions {
852
+ skim?: boolean;
853
+ populateAccess?: PopulateAccess;
854
+ lean?: boolean;
855
+ includePermissions?: boolean;
856
+ tryList?: boolean;
857
+ }
858
+
859
+ interface PublicUpdateArgs {
860
+ select?: Projection;
861
+ populate?: Populate[] | string;
862
+ tasks?: Task | Task[];
863
+ }
864
+ interface PublicUpsertArgs extends PublicUpdateArgs {
865
+ }
866
+ interface UpdateOneArgs<T = unknown> extends Omit<PublicUpdateArgs, 'select' | 'tasks'> {
867
+ overrides?: {
868
+ filter?: Filter<T>;
869
+ populate?: Populate[] | string;
870
+ };
871
+ }
872
+ interface UpdateByIdArgs<T = unknown> extends Omit<UpdateOneArgs<T>, 'overrides'> {
873
+ overrides?: {
874
+ populate?: Populate[] | string;
875
+ idFilter?: Filter<T>;
876
+ };
877
+ }
878
+ interface UpsertArgs<T = unknown> extends UpdateOneArgs<T> {
879
+ }
880
+ interface PublicUpdateOptions {
881
+ skim?: boolean;
882
+ returningAll?: boolean;
883
+ includePermissions?: boolean;
884
+ populateAccess?: PopulateAccess;
885
+ }
886
+ interface PublicUpsertOptions extends PublicUpdateOptions {
887
+ }
888
+ interface UpdateOneOptions extends Omit<PublicUpdateOptions, 'returningAll'> {
889
+ }
890
+ interface UpdateByIdOptions extends UpdateOneOptions {
891
+ }
892
+ interface UpsertOptions extends UpdateOneOptions {
893
+ }
894
+
895
+ type DataFilter<T = unknown> = Filter<T>;
896
+ interface DataFindOneArgs<T = unknown, TSelect extends Projection | undefined = Projection | undefined> {
897
+ select?: TSelect;
898
+ }
899
+ interface DataFindOneOptions {
900
+ access?: FindAccess;
901
+ }
902
+ interface DataFindArgs<T = unknown, TSelect extends Projection | undefined = Projection | undefined> {
903
+ select?: TSelect;
904
+ sort?: string;
905
+ skip?: string | number;
906
+ limit?: string | number;
907
+ page?: string | number;
908
+ pageSize?: string | number;
909
+ }
910
+ interface DataFindOptions {
911
+ }
912
+
913
+ interface KeyValueProjection {
914
+ [key: string]: 1 | -1;
915
+ }
916
+ type Projection = string[] | string | KeyValueProjection;
917
+ type SortOrder = -1 | 1 | 'asc' | 'ascending' | 'desc' | 'descending';
918
+ type Sort = string | {
919
+ [key: string]: SortOrder;
920
+ } | [string, SortOrder][] | undefined | null;
921
+ type Primitive = string | number | boolean | bigint | symbol | null | undefined;
922
+ type NonTraversable = Primitive | Date | RegExp | Function;
923
+ type PrevDepth = [never, 0, 1, 2, 3, 4, 5];
924
+ type IsUnknown<T> = unknown extends T ? ([keyof T] extends [never] ? true : false) : false;
925
+ type Descend<T> = T extends readonly (infer U)[] ? U : T;
926
+ type ArrayValue<T> = T extends readonly (infer U)[] ? U : T;
927
+ type ComparableValue = string | number | bigint | Date;
928
+ type WithDefaultId<T> = T extends object ? T & {
929
+ _id?: unknown;
930
+ } : {
931
+ _id?: unknown;
932
+ };
933
+ type PublicOutput<T> = T extends object ? T & Record<string, unknown> : Record<string, unknown>;
934
+ type ModelDocument<TModel = unknown> = mongoose.Document & TModel;
935
+ type TrimLeft<S extends string> = S extends ` ${infer Rest}` ? TrimLeft<Rest> : S;
936
+ type TrimRight<S extends string> = S extends `${infer Rest} ` ? TrimRight<Rest> : S;
937
+ type Trim<S extends string> = TrimLeft<TrimRight<S>>;
938
+ type SplitProjectionString<S extends string> = S extends `${infer Head} ${infer Tail}` ? SplitProjectionString<Head> | SplitProjectionString<Tail> : Trim<S>;
939
+ type ProjectionTokens<TProjection> = TProjection extends readonly string[] ? TProjection[number] : TProjection extends string ? SplitProjectionString<TProjection> : TProjection extends KeyValueProjection ? {
940
+ [K in Extract<keyof TProjection, string>]: TProjection[K] extends 1 ? K : never;
941
+ }[Extract<keyof TProjection, string>] : never;
942
+ type PositiveProjectionPaths<TProjection> = ProjectionTokens<TProjection> extends infer TToken ? TToken extends string ? TToken extends '' ? never : TToken extends `-${string}` ? never : TToken : never : never;
943
+ type UnionToIntersection<T> = (T extends unknown ? (value: T) => void : never) extends (value: infer I) => void ? I : never;
944
+ type Simplify<T> = {
945
+ [K in keyof T]: T[K];
946
+ } & {};
947
+ type DeepPickSingle<T, TPath extends string> = TPath extends `${infer Head}.${infer Tail}` ? Head extends keyof WithDefaultId<T> ? Head extends string ? {
948
+ [K in Head]: WithDefaultId<T>[K] extends readonly (infer U)[] ? Array<Simplify<DeepPickSingle<U, Tail>>> : WithDefaultId<T>[K] extends object ? Simplify<DeepPickSingle<WithDefaultId<T>[K], Tail>> : WithDefaultId<T>[K];
949
+ } : {} : {} : TPath extends keyof WithDefaultId<T> ? Pick<WithDefaultId<T>, TPath> : {};
950
+ type DeepPick<T, TPaths extends string> = Simplify<UnionToIntersection<DeepPickSingle<T, TPaths>>>;
951
+ type SelectedPublicOutput<T, TProjection> = string extends PositiveProjectionPaths<TProjection> ? PublicOutput<T> : [PositiveProjectionPaths<TProjection>] extends [never] ? PublicOutput<T> : DeepPick<T, Extract<PositiveProjectionPaths<TProjection>, string>>;
952
+ type PopulateInput = Populate | string;
953
+ type PopulateInputs<TPopulate> = TPopulate extends readonly (infer U)[] ? U : TPopulate;
954
+ type PopulatePath<TPopulateEntry> = TPopulateEntry extends string ? TPopulateEntry : TPopulateEntry extends {
955
+ path: infer TPath extends string;
956
+ } ? TPath : never;
957
+ type PopulateSelect<TPopulateEntry> = TPopulateEntry extends {
958
+ select?: infer TSelect;
959
+ } ? TSelect : undefined;
960
+ type PopulateLeafValue<TValue, TPopulateEntry> = TValue extends readonly (infer U)[] ? Array<SelectedPublicOutput<U, PopulateSelect<TPopulateEntry>>> : SelectedPublicOutput<TValue, PopulateSelect<TPopulateEntry>>;
961
+ type PopulateEntryShape<T, TPath extends string, TValue> = TPath extends `${infer Head}.${infer Tail}` ? Head extends keyof WithDefaultId<T> ? Head extends string ? {
962
+ [K in Head]: WithDefaultId<T>[K] extends readonly (infer U)[] ? Array<Simplify<PopulateEntryShape<U, Tail, TValue>>> : Simplify<PopulateEntryShape<WithDefaultId<T>[K], Tail, TValue>>;
963
+ } : {} : {} : TPath extends keyof WithDefaultId<T> ? Pick<{
964
+ [K in TPath]: TValue;
965
+ }, TPath> : {};
966
+ type PopulateOutputShape<T, TPopulateEntry> = PopulatePath<TPopulateEntry> extends infer TPath extends string ? PopulateEntryShape<T, TPath, PopulateLeafValue<PathValue<WithDefaultId<T>, TPath>, TPopulateEntry>> : {};
967
+ type PopulateOutput<T, TPopulate> = string extends PopulatePath<PopulateInputs<TPopulate>> ? {} : [PopulatePath<PopulateInputs<TPopulate>>] extends [never] ? {} : Simplify<UnionToIntersection<PopulateOutputShape<T, Extract<PopulateInputs<TPopulate>, PopulateInput>>>>;
968
+ type SelectedPopulatedPublicOutput<T, TProjection, TPopulate> = Simplify<SelectedPublicOutput<T, TProjection> & PopulateOutput<T, TPopulate>>;
969
+ type DeepFieldPath<T, Depth extends number = 4> = [Depth] extends [never] ? never : Descend<T> extends NonTraversable ? never : {
970
+ [K in Extract<keyof Descend<T>, string>]: K | (Descend<T>[K] extends NonTraversable ? never : Descend<T>[K] extends readonly (infer U)[] ? U extends NonTraversable ? never : `${K}.${DeepFieldPath<U, PrevDepth[Depth]>}` : Descend<T>[K] extends object ? `${K}.${DeepFieldPath<Descend<T>[K], PrevDepth[Depth]>}` : never);
971
+ }[Extract<keyof Descend<T>, string>];
972
+ type PathValue<T, TPath extends string> = TPath extends `${infer Head}.${infer Tail}` ? Head extends Extract<keyof Descend<T>, string> ? PathValue<Descend<Descend<T>[Head]>, Tail> : unknown : TPath extends Extract<keyof Descend<T>, string> ? Descend<T>[TPath] : unknown;
973
+ type FieldFilterOperators<T> = {
974
+ $eq?: T;
975
+ $ne?: T;
976
+ $in?: Array<ArrayValue<T>>;
977
+ $nin?: Array<ArrayValue<T>>;
978
+ $exists?: boolean;
979
+ $gt?: ArrayValue<T> extends ComparableValue ? ArrayValue<T> : never;
980
+ $gte?: ArrayValue<T> extends ComparableValue ? ArrayValue<T> : never;
981
+ $lt?: ArrayValue<T> extends ComparableValue ? ArrayValue<T> : never;
982
+ $lte?: ArrayValue<T> extends ComparableValue ? ArrayValue<T> : never;
983
+ $regex?: ArrayValue<T> extends string ? string | RegExp : never;
984
+ $all?: T extends readonly unknown[] ? Array<ArrayValue<T>> : never;
985
+ $size?: T extends readonly unknown[] ? number : never;
986
+ $elemMatch?: ArrayValue<T> extends object ? TypedFilter<ArrayValue<T>> : never;
987
+ $$sq?: unknown;
988
+ $$date?: unknown;
989
+ [key: `$${string}`]: unknown;
990
+ };
991
+ type FieldFilterValue<T> = T | FieldFilterOperators<NonNullable<T>>;
992
+ type LooseFilter = false | Record<string, unknown>;
993
+ type TypedFilterObject<T> = {
994
+ [K in DeepFieldPath<T>]?: FieldFilterValue<PathValue<T, K>>;
995
+ } & {
996
+ _id?: FieldFilterValue<unknown>;
997
+ $and?: TypedFilter<T>[];
998
+ $or?: TypedFilter<T>[];
999
+ $nor?: TypedFilter<T>[];
1000
+ [key: `$${string}`]: unknown;
1001
+ };
1002
+ type TypedFilter<T> = false | TypedFilterObject<WithDefaultId<T>>;
1003
+ type Filter<T = unknown> = IsUnknown<T> extends true ? LooseFilter : TypedFilter<T>;
1004
+ interface Include {
1005
+ model: string;
1006
+ op: 'list' | 'read' | 'count';
1007
+ path: string;
1008
+ filter?: Filter;
1009
+ localField: string;
1010
+ foreignField: string;
1011
+ args?: unknown;
1012
+ options?: unknown;
1013
+ }
1014
+ type FindAccess = 'list' | 'read';
1015
+ type PopulateAccess = 'list' | 'read';
1016
+ interface Populate {
1017
+ path: string;
1018
+ select?: Projection;
1019
+ match?: unknown;
1020
+ access?: PopulateAccess;
1021
+ }
1022
+ interface SubPopulate {
1023
+ path: string;
1024
+ select?: Projection;
1025
+ }
1026
+
1027
+ type GuardHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, permissions: AccessRouterPermissions) => boolean | Promise<boolean>;
1028
+ type Validation = boolean | string | string[] | GuardHook;
1029
+ type SelectAccess = 'list' | 'create' | 'read' | 'update' | string;
1030
+ type RouteGuardAccess = 'new' | 'list' | 'read' | 'update' | 'upsert' | 'delete' | 'create' | 'distinct' | 'count' | 'subs' | string;
1031
+ type DocPermissionsAccess = 'list' | 'create' | 'read' | 'update' | string;
1032
+ type BaseFilterAccess = 'list' | 'read' | 'update' | 'delete' | string;
1033
+ type DecorateAccess = 'list' | 'create' | 'read' | 'update' | string;
1034
+ type DecorateAllAccess = 'list' | string;
1035
+ type ValidateAccess = 'create' | 'update' | string;
1036
+ type PrepareAccess = 'create' | 'update' | string;
1037
+ type TransformAccess = 'update' | string;
1038
+ type AfterPersistAccess = 'create' | 'update' | string;
1039
+
1040
+ interface KeyValue {
1041
+ [key: string]: unknown;
1042
+ }
1043
+ interface Change {
1044
+ op: 'add' | 'replace' | 'remove';
1045
+ path: Array<string | number>;
1046
+ value?: unknown;
1047
+ }
1048
+ interface ModelHookContext {
1049
+ modelName: string;
1050
+ mongooseModel: mongoose.Model<unknown>;
1051
+ operation?: string;
1052
+ originalDocumentSnapshot?: Record<string, unknown>;
1053
+ finalDocumentSnapshot?: Record<string, unknown>;
1054
+ currentDocument?: ModelDocument;
1055
+ originalData?: Record<string, unknown>;
1056
+ allowedData?: Record<string, unknown>;
1057
+ preparedData?: Record<string, unknown>;
1058
+ allowedFields?: string[];
1059
+ modifiedPaths?: string[];
1060
+ changes?: Change[];
1061
+ docPermissions?: KeyValue;
1062
+ resolvedQuery?: {
1063
+ filter?: Filter;
1064
+ select?: string[];
1065
+ populate?: Populate[] | string;
1066
+ sort?: Sort;
1067
+ skip?: number;
1068
+ limit?: number;
1069
+ };
1070
+ }
1071
+ interface DataHookContext {
1072
+ dataName?: string;
1073
+ operation?: string;
1074
+ resolvedQuery?: {
1075
+ filter?: Filter;
1076
+ select?: string[];
1077
+ sort?: Sort;
1078
+ skip?: number;
1079
+ limit?: number;
1080
+ };
1081
+ }
1082
+ type RootTarget = 'model' | 'data';
1083
+ type RootSubOperation = 'subList' | 'subRead' | 'subCreate' | 'subUpdate' | 'subBulkUpdate' | 'subDelete';
1084
+ type RootModelOperation = 'new' | 'list' | 'read' | 'create' | 'update' | 'upsert' | 'delete' | 'distinct' | 'count' | RootSubOperation;
1085
+ type RootDataOperation = 'list' | 'read';
1086
+ interface RootQueryEntryBase<TTarget extends RootTarget, TOp extends string> {
1087
+ target: TTarget;
1088
+ name: string;
1089
+ op: TOp;
1090
+ order?: number;
1091
+ }
1092
+ interface RootModelNewQueryEntry extends RootQueryEntryBase<'model', 'new'> {
1093
+ args?: {
1094
+ select?: string[];
1095
+ };
1096
+ options?: {
1097
+ skim?: boolean;
1098
+ includePermissions?: boolean;
1099
+ };
1100
+ }
1101
+ interface RootModelListQueryEntry extends RootQueryEntryBase<'model', 'list'> {
1102
+ filter?: Filter;
1103
+ args?: PublicListArgs;
1104
+ options?: PublicListOptions;
1105
+ }
1106
+ interface RootModelReadByIdQueryEntry extends RootQueryEntryBase<'model', 'read'> {
1107
+ id: string;
1108
+ args?: PublicReadArgs;
1109
+ options?: PublicReadOptions;
1110
+ }
1111
+ interface RootModelReadByFilterQueryEntry extends RootQueryEntryBase<'model', 'read'> {
1112
+ filter: Filter;
1113
+ args?: PublicReadArgs & {
1114
+ sort?: Sort;
1115
+ };
1116
+ options?: PublicReadOptions;
1117
+ }
1118
+ interface RootModelCreateQueryEntry extends RootQueryEntryBase<'model', 'create'> {
1119
+ data: unknown;
1120
+ args?: PublicCreateArgs;
1121
+ options?: PublicCreateOptions;
1122
+ }
1123
+ interface RootModelUpdateQueryEntry extends RootQueryEntryBase<'model', 'update'> {
1124
+ id: string;
1125
+ data: unknown;
1126
+ args?: PublicUpdateArgs;
1127
+ options?: PublicUpdateOptions;
1128
+ }
1129
+ interface RootModelUpsertQueryEntry extends RootQueryEntryBase<'model', 'upsert'> {
1130
+ data: Record<string, unknown>;
1131
+ args?: PublicUpsertArgs;
1132
+ options?: PublicUpsertOptions;
1133
+ }
1134
+ interface RootModelDeleteQueryEntry extends RootQueryEntryBase<'model', 'delete'> {
1135
+ id: string;
1136
+ }
1137
+ interface RootModelSubListQueryEntry extends RootQueryEntryBase<'model', 'subList'> {
1138
+ id: string;
1139
+ sub: string;
1140
+ filter?: Filter;
1141
+ args?: {
1142
+ select?: string[];
1143
+ };
1144
+ }
1145
+ interface RootModelSubReadQueryEntry extends RootQueryEntryBase<'model', 'subRead'> {
1146
+ id: string;
1147
+ sub: string;
1148
+ subId: string;
1149
+ args?: {
1150
+ select?: string[];
1151
+ populate?: SubPopulate | SubPopulate[] | string | string[];
1152
+ };
1153
+ }
1154
+ interface RootModelSubCreateQueryEntry extends RootQueryEntryBase<'model', 'subCreate'> {
1155
+ id: string;
1156
+ sub: string;
1157
+ data: unknown;
1158
+ }
1159
+ interface RootModelSubUpdateQueryEntry extends RootQueryEntryBase<'model', 'subUpdate'> {
1160
+ id: string;
1161
+ sub: string;
1162
+ subId: string;
1163
+ data: unknown;
1164
+ }
1165
+ interface RootModelSubBulkUpdateQueryEntry extends RootQueryEntryBase<'model', 'subBulkUpdate'> {
1166
+ id: string;
1167
+ sub: string;
1168
+ data: unknown;
1169
+ }
1170
+ interface RootModelSubDeleteQueryEntry extends RootQueryEntryBase<'model', 'subDelete'> {
1171
+ id: string;
1172
+ sub: string;
1173
+ subId: string;
1174
+ }
1175
+ interface RootModelDistinctQueryEntry extends RootQueryEntryBase<'model', 'distinct'> {
1176
+ field: string;
1177
+ filter?: Filter;
1178
+ }
1179
+ interface RootModelCountQueryEntry extends RootQueryEntryBase<'model', 'count'> {
1180
+ filter?: Filter;
1181
+ options?: Record<string, never>;
1182
+ }
1183
+ interface RootDataListQueryEntry extends RootQueryEntryBase<'data', 'list'> {
1184
+ filter?: Filter;
1185
+ args?: DataFindArgs;
1186
+ options?: {
1187
+ includeCount?: boolean;
1188
+ [key: string]: unknown;
1189
+ };
1190
+ }
1191
+ interface RootDataReadByIdQueryEntry extends RootQueryEntryBase<'data', 'read'> {
1192
+ id: string;
1193
+ args?: DataFindOneArgs;
1194
+ }
1195
+ interface RootDataReadByFilterQueryEntry extends RootQueryEntryBase<'data', 'read'> {
1196
+ filter: Filter;
1197
+ args?: DataFindOneArgs;
1198
+ }
1199
+ type RootQueryEntry = RootModelNewQueryEntry | RootModelListQueryEntry | RootModelReadByIdQueryEntry | RootModelReadByFilterQueryEntry | RootModelCreateQueryEntry | RootModelUpdateQueryEntry | RootModelUpsertQueryEntry | RootModelDeleteQueryEntry | RootModelSubListQueryEntry | RootModelSubReadQueryEntry | RootModelSubCreateQueryEntry | RootModelSubUpdateQueryEntry | RootModelSubBulkUpdateQueryEntry | RootModelSubDeleteQueryEntry | RootModelDistinctQueryEntry | RootModelCountQueryEntry | RootDataListQueryEntry | RootDataReadByIdQueryEntry | RootDataReadByFilterQueryEntry;
1200
+ interface RootOperationResult<T = unknown, TError = unknown> {
1201
+ index: number;
1202
+ target: RootTarget;
1203
+ name: string;
1204
+ op: RootModelOperation | RootDataOperation;
1205
+ result: PublicServiceResult<T, TError>;
1206
+ statusCode: number;
1207
+ message: string;
1208
+ }
1209
+ interface SubQueryEntry {
1210
+ model: string;
1211
+ op: 'list' | 'read' | string;
1212
+ id?: string;
1213
+ filter?: Filter;
1214
+ args?: Record<string, unknown>;
1215
+ options?: Record<string, unknown>;
1216
+ sqOptions?: {
1217
+ path?: string;
1218
+ compact?: boolean;
1219
+ };
1220
+ }
1221
+ interface Task {
1222
+ type: string;
1223
+ args: unknown;
1224
+ options: Record<string, unknown>;
1225
+ }
1226
+ interface AccessRouterBaseRequest extends AccessRouterRequest {
1227
+ query: Record<'skip' | 'limit' | 'page' | 'page_size' | 'try_list' | 'skim' | 'include_permissions' | 'include_count' | 'include_extra_headers' | 'returning_all', string>;
1228
+ }
1229
+ interface ModelRequest extends AccessRouterBaseRequest {
1230
+ macl: Core;
1231
+ }
1232
+ interface DataRequest extends AccessRouterBaseRequest {
1233
+ dacl: DataCore;
1234
+ }
1235
+ type Request = AccessRouterBaseRequest;
1236
+ interface ErrorResult<TError = unknown, TQuery = unknown> {
1237
+ success: false;
1238
+ kind: 'error';
1239
+ code: Codes.BadRequest | Codes.Unauthorized | Codes.Forbidden | Codes.NotFound;
1240
+ errors?: TError[];
1241
+ query?: TQuery;
1242
+ }
1243
+ interface SingleResult<T = unknown, TInput = unknown, TQuery = unknown> {
1244
+ success: true;
1245
+ kind: 'single';
1246
+ code: Codes.Success | Codes.Created;
1247
+ data: T;
1248
+ input?: TInput;
1249
+ query?: TQuery;
1250
+ context?: ModelHookContext;
1251
+ }
1252
+ interface ListResult<T = unknown, TInput = unknown, TQuery = unknown> {
1253
+ success: true;
1254
+ kind: 'list';
1255
+ code: Codes.Success | Codes.Created;
1256
+ data: T[];
1257
+ count: number;
1258
+ totalCount?: number | null;
1259
+ input?: TInput;
1260
+ query?: TQuery;
1261
+ contexts?: ModelHookContext[];
1262
+ }
1263
+ type ServiceResult<T = unknown, TError = unknown, TInput = unknown, TQuery = unknown> = SingleResult<T, TInput, TQuery> | ListResult<T, TInput, TQuery> | ErrorResult<TError, TQuery>;
1264
+ /**
1265
+ * Type-only nominal brand that marks an object as a fully-formed public DTO
1266
+ * produced by one of the `toPublic*` serializers. It has no runtime value, so
1267
+ * the serialized JSON shape is unchanged; its only purpose is to make the
1268
+ * internal {@link SingleResult}/{@link ListResult}/{@link ErrorResult} shapes
1269
+ * structurally incompatible with the public DTOs at the type level. Direct
1270
+ * assignment from an internal service result to a public DTO fails to compile
1271
+ * because the internal result does not carry this brand, and crossing the
1272
+ * boundary requires the explicit serializer (or an explicit cast).
1273
+ */
1274
+ declare const publicResultBrand: unique symbol;
1275
+ interface PublicErrorResult<TError = unknown> {
1276
+ success: false;
1277
+ code: Codes.BadRequest | Codes.Unauthorized | Codes.Forbidden | Codes.NotFound;
1278
+ errors?: TError[];
1279
+ [publicResultBrand]: 'public-error';
1280
+ }
1281
+ interface PublicSingleResult<T = unknown> {
1282
+ success: true;
1283
+ kind: 'single';
1284
+ code: Codes.Success | Codes.Created;
1285
+ data: T;
1286
+ [publicResultBrand]: 'public-single';
1287
+ }
1288
+ interface PublicListResult<T = unknown> {
1289
+ success: true;
1290
+ kind: 'list';
1291
+ code: Codes.Success | Codes.Created;
1292
+ data: T[];
1293
+ count: number;
1294
+ totalCount?: number | null;
1295
+ [publicResultBrand]: 'public-list';
1296
+ }
1297
+ type PublicServiceResult<T = unknown, TError = unknown> = PublicSingleResult<T> | PublicListResult<T> | PublicErrorResult<TError>;
1298
+
1299
+ interface FindArgs<T = unknown> {
1300
+ select?: Projection;
1301
+ populate?: Populate[] | string;
1302
+ include?: Include | Include[];
1303
+ sort?: Sort;
1304
+ skip?: string | number;
1305
+ limit?: string | number;
1306
+ page?: string | number;
1307
+ pageSize?: string | number;
1308
+ overrides?: {
1309
+ filter?: Filter<T>;
1310
+ select?: Projection;
1311
+ populate?: Populate[] | string;
1312
+ };
1313
+ }
1314
+ interface FindOptions {
1315
+ skim?: boolean;
1316
+ includePermissions?: boolean;
1317
+ includeCount?: boolean;
1318
+ populateAccess?: PopulateAccess;
1319
+ lean?: boolean;
1320
+ }
1321
+ interface FindOneArgs<T = unknown> {
1322
+ select?: Projection;
1323
+ sort?: Sort;
1324
+ populate?: Populate[] | string;
1325
+ include?: Include | Include[];
1326
+ overrides?: {
1327
+ filter?: Filter<T>;
1328
+ select?: Projection;
1329
+ populate?: Populate[] | string;
1330
+ };
1331
+ }
1332
+ interface FindOneOptions {
1333
+ access?: FindAccess;
1334
+ populateAccess?: PopulateAccess;
1335
+ skim?: boolean;
1336
+ lean?: boolean;
1337
+ includePermissions?: boolean;
1338
+ }
1339
+ interface FindByIdArgs<T = unknown> {
1340
+ select?: Projection;
1341
+ populate?: Populate[] | string;
1342
+ include?: Include | Include[];
1343
+ overrides?: {
1344
+ select?: Projection;
1345
+ populate?: Populate[] | string;
1346
+ idFilter?: Filter<T>;
1347
+ };
1348
+ }
1349
+ interface FindByIdOptions extends FindOneOptions {
1350
+ }
1351
+
1352
+ interface ExistsOptions {
1353
+ access?: BaseFilterAccess;
1354
+ includeId?: boolean;
1355
+ }
1356
+
1357
+ type MaybePromise<T> = T | Promise<T>;
1358
+ type AccessRouterFieldKey<T> = [Extract<keyof T, string>] extends [never] ? string : Extract<keyof T, string>;
1359
+ type IdentifierHook<TValue, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, id: string) => MaybePromise<Filter<TValue>>;
1360
+ type GlobalPermissionValue = Record<string, boolean> | string[] | string | null | undefined;
1361
+ type BaseFilterHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, permissions: AccessRouterPermissions) => MaybePromise<Filter | true | null | undefined>;
1362
+ type OverrideFilterHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, filter: Filter, permissions: AccessRouterPermissions) => MaybePromise<Filter>;
1363
+ type Hook<TValue, TContext, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, value: TValue, permissions: AccessRouterPermissions, context: TContext) => MaybePromise<TValue>;
1364
+ type HookChain<TValue, TContext, TRequest extends AccessRouterRequest = AccessRouterRequest> = Hook<TValue, TContext, TRequest> | Array<Hook<TValue, TContext, TRequest>>;
1365
+ type ValidateRule = boolean | unknown[];
1366
+ type ValidateHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, allowedData: unknown, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<ValidateRule>;
1367
+ type DocPermissionsHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, doc: unknown, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<Record<string, unknown>>;
1368
+ type ChangeHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, previousValue: unknown, nextValue: unknown, changes: Change[], context: ModelHookContext) => MaybePromise<void>;
1369
+ type DeleteHook<TValue = unknown, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, value: TValue, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<void>;
1370
+ type DocumentHook<TValue, TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, value: ModelDocument<TValue>, permissions: AccessRouterPermissions, context: ModelHookContext) => MaybePromise<ModelDocument<TValue>>;
1371
+ type DocumentHookChain<TValue, TRequest extends AccessRouterRequest = AccessRouterRequest> = DocumentHook<TValue, TRequest> | Array<DocumentHook<TValue, TRequest>>;
1372
+ type ModelBaseFilterHook = BaseFilterHook<ModelRequest>;
1373
+ type DataBaseFilterHook = BaseFilterHook<DataRequest>;
1374
+ type ModelOverrideFilterHook = OverrideFilterHook<ModelRequest>;
1375
+ type DataOverrideFilterHook = OverrideFilterHook<DataRequest>;
1376
+ type ModelIdentifierHook<TValue = unknown> = IdentifierHook<TValue, ModelRequest>;
1377
+ type DataIdentifierHook<TValue = unknown> = IdentifierHook<TValue, DataRequest>;
1378
+ type ModelValidateHook = ValidateHook<ModelRequest>;
1379
+ type ModelDocPermissionsHook = DocPermissionsHook<ModelRequest>;
1380
+ type ModelChangeHook = ChangeHook<ModelRequest>;
1381
+ type ModelDocumentHook<TValue = unknown> = DocumentHookChain<TValue, ModelRequest>;
1382
+ type ModelDeleteHook<TValue = unknown> = DeleteHook<ModelDocument<TValue>, ModelRequest>;
1383
+ type ModelHook<TValue = unknown> = HookChain<TValue, ModelHookContext, ModelRequest>;
1384
+ type ModelListHook<TValue = unknown> = HookChain<TValue[], ModelHookContext, ModelRequest>;
1385
+ type DataHook<TValue = unknown> = HookChain<TValue, DataHookContext, DataRequest>;
1386
+ type DataListHook<TValue = unknown> = HookChain<TValue[], DataHookContext, DataRequest>;
1387
+
1388
+ interface DefaultFindOneArgs<TModel = unknown> extends Omit<FindOneArgs<TModel>, 'overrides'> {
1389
+ }
1390
+ interface DefaultFindByIdArgs<TModel = unknown> extends Omit<FindByIdArgs<TModel>, 'overrides'> {
1391
+ }
1392
+ interface DefaultFindArgs<TModel = unknown> extends Omit<FindArgs<TModel>, 'overrides'> {
1393
+ }
1394
+ type RequestSchema = RequestSchemaLike;
1395
+ type NestedRequestSchema = {
1396
+ default?: RequestSchema;
1397
+ data?: RequestSchema;
1398
+ };
1399
+ type SubRouteGuardOptions = Record<string, Validation | Record<string, Validation>>;
1400
+ interface RequestSchemas {
1401
+ create?: RequestSchema;
1402
+ update?: RequestSchema;
1403
+ upsert?: RequestSchema;
1404
+ count?: RequestSchema;
1405
+ distinct?: RequestSchema;
1406
+ advancedList?: RequestSchema;
1407
+ advancedReadFilter?: RequestSchema;
1408
+ advancedRead?: RequestSchema;
1409
+ advancedCreate?: RequestSchema | NestedRequestSchema;
1410
+ advancedCreateData?: RequestSchema;
1411
+ advancedUpdate?: RequestSchema | NestedRequestSchema;
1412
+ advancedUpdateData?: RequestSchema;
1413
+ advancedUpsert?: RequestSchema | NestedRequestSchema;
1414
+ advancedUpsertData?: RequestSchema;
1415
+ subList?: RequestSchema;
1416
+ subRead?: RequestSchema;
1417
+ subCreate?: RequestSchema;
1418
+ subUpdate?: RequestSchema;
1419
+ subBulkUpdate?: RequestSchema;
1420
+ }
1421
+ interface DataRequestSchemas {
1422
+ advancedList?: RequestSchema;
1423
+ advancedReadFilter?: RequestSchema;
1424
+ advancedRead?: RequestSchema;
1425
+ }
1426
+ interface Defaults<TModel = unknown> {
1427
+ findOneArgs?: DefaultFindOneArgs<TModel>;
1428
+ findOneOptions?: FindOneOptions;
1429
+ findByIdArgs?: DefaultFindByIdArgs<TModel>;
1430
+ findByIdOptions?: FindByIdOptions;
1431
+ findArgs?: DefaultFindArgs<TModel>;
1432
+ findOptions?: FindOptions;
1433
+ createArgs?: CreateArgs;
1434
+ createOptions?: CreateOptions;
1435
+ updateOneArgs?: UpdateOneArgs<TModel>;
1436
+ updateOneOptions?: UpdateOneOptions;
1437
+ upsertOptions?: UpsertOptions;
1438
+ updateByIdArgs?: UpdateByIdArgs<TModel>;
1439
+ upsertArgs?: UpsertArgs<TModel>;
1440
+ updateByIdOptions?: UpdateByIdOptions;
1441
+ existsOptions?: ExistsOptions;
1442
+ publicListArgs?: PublicListArgs;
1443
+ publicListOptions?: PublicListOptions;
1444
+ publicCreateArgs?: PublicCreateArgs;
1445
+ publicCreateOptions?: PublicCreateOptions;
1446
+ publicReadArgs?: PublicReadArgs;
1447
+ publicReadOptions?: PublicReadOptions;
1448
+ publicUpdateArgs?: PublicUpdateArgs;
1449
+ publicUpdateOptions?: PublicUpdateOptions;
1450
+ }
1451
+ interface AccessRouterLogger {
1452
+ debug?: (...args: unknown[]) => unknown;
1453
+ info?: (...args: unknown[]) => unknown;
1454
+ warn?: (...args: unknown[]) => unknown;
1455
+ error?: (...args: unknown[]) => unknown;
1456
+ isLevelEnabled?: (level: string) => boolean;
1457
+ }
1458
+ interface GlobalOptions {
1459
+ requestPermissionField?: string;
1460
+ globalPermissions?: (this: AccessRouterRequest, req: AccessRouterRequest) => MaybePromise<GlobalPermissionValue>;
1461
+ logger?: AccessRouterLogger;
1462
+ requestComplexity?: RequestComplexityOptions;
1463
+ }
1464
+ interface RootRouterOptions {
1465
+ basePath: string;
1466
+ operationAccess?: Validation;
1467
+ maxBatchEntries?: number;
1468
+ maxOrderGroups?: number;
1469
+ maxConcurrentOperations?: number;
1470
+ }
1471
+ interface OperationAccess {
1472
+ new?: Validation;
1473
+ list?: Validation;
1474
+ create?: Validation;
1475
+ read?: Validation;
1476
+ update?: Validation;
1477
+ upsert?: Validation;
1478
+ delete?: Validation;
1479
+ distinct?: Validation;
1480
+ count?: Validation;
1481
+ subs?: Validation | SubRouteGuardOptions;
1482
+ }
1483
+ type PermissionRule = Validation | OperationAccess;
1484
+ type PermissionSchema<TField extends string = string> = Partial<Record<TField, PermissionRule>>;
1485
+ interface DocPermissions {
1486
+ list?: ModelDocPermissionsHook;
1487
+ create?: ModelDocPermissionsHook;
1488
+ read?: ModelDocPermissionsHook;
1489
+ update?: ModelDocPermissionsHook;
1490
+ }
1491
+ interface DefaultModelRouterOptions<TModel = unknown> {
1492
+ listHardLimit?: number;
1493
+ documentPermissionField?: string;
1494
+ idParam?: string;
1495
+ idField?: string;
1496
+ resolveIdFilter?: ModelIdentifierHook<TModel>;
1497
+ parentPath?: string;
1498
+ queryRouteSegment?: string;
1499
+ mutationRouteSegment?: string;
1500
+ operationAccess?: Validation | OperationAccess;
1501
+ modelPermissionPrefix?: string;
1502
+ }
1503
+ interface ExtendedDefaultModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions<TModel> {
1504
+ 'operationAccess.default'?: Validation;
1505
+ 'operationAccess.new'?: Validation;
1506
+ 'operationAccess.list'?: Validation;
1507
+ 'operationAccess.read'?: Validation;
1508
+ 'operationAccess.update'?: Validation;
1509
+ 'operationAccess.upsert'?: Validation;
1510
+ 'operationAccess.delete'?: Validation;
1511
+ 'operationAccess.create'?: Validation;
1512
+ 'operationAccess.distinct'?: Validation;
1513
+ 'operationAccess.count'?: Validation;
1514
+ 'operationAccess.subs'?: SubRouteGuardOptions;
1515
+ }
1516
+ interface ModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions<TModel> {
1517
+ modelName?: string;
1518
+ basePath?: string;
1519
+ permissionSchema?: PermissionSchema<AccessRouterFieldKey<TModel>>;
1520
+ alwaysSelectFields?: string[];
1521
+ docPermissions?: DocPermissions | ModelDocPermissionsHook;
1522
+ baseFilter?: ModelBaseFilterHook | Record<string, ModelBaseFilterHook>;
1523
+ overrideFilter?: ModelOverrideFilterHook | Record<string, ModelOverrideFilterHook>;
1524
+ decorate?: ModelHook<TModel> | Record<string, ModelHook<TModel>>;
1525
+ decorateAll?: ModelListHook<TModel> | Record<string, ModelListHook<TModel>>;
1526
+ validate?: ValidateRule | ModelValidateHook | Record<string, ValidateRule | ModelValidateHook>;
1527
+ prepare?: ModelHook<TModel> | Record<string, ModelHook<TModel>>;
1528
+ transform?: ModelDocumentHook<TModel> | Record<string, ModelDocumentHook<TModel>>;
1529
+ afterPersist?: ModelDocumentHook<TModel> | Record<string, ModelDocumentHook<TModel>>;
1530
+ onChange?: Record<string, ModelChangeHook>;
1531
+ beforeDelete?: ModelDeleteHook<TModel>;
1532
+ afterDelete?: ModelDeleteHook<TModel>;
1533
+ requestSchemas?: RequestSchemas;
1534
+ defaults?: Defaults<TModel>;
1535
+ }
1536
+ interface DataRouterOptions<TData = unknown> {
1537
+ data?: TData[];
1538
+ listHardLimit?: number;
1539
+ idParam?: string;
1540
+ idField?: string;
1541
+ resolveIdFilter?: DataIdentifierHook<TData>;
1542
+ parentPath?: string;
1543
+ queryRouteSegment?: string;
1544
+ operationAccess?: Validation | OperationAccess;
1545
+ dataName?: string;
1546
+ basePath?: string;
1547
+ permissionSchema?: PermissionSchema<AccessRouterFieldKey<TData>>;
1548
+ baseFilter?: DataBaseFilterHook | Record<string, DataBaseFilterHook>;
1549
+ overrideFilter?: DataOverrideFilterHook | Record<string, DataOverrideFilterHook>;
1550
+ decorate?: DataHook<TData> | Record<string, DataHook<TData>>;
1551
+ decorateAll?: DataListHook<TData> | Record<string, DataListHook<TData>>;
1552
+ requestSchemas?: DataRequestSchemas;
1553
+ }
1554
+ interface ExtendedModelRouterOptions<TModel = unknown> extends ModelRouterOptions<TModel>, ExtendedDefaultModelRouterOptions<TModel> {
1555
+ 'alwaysSelectFields.default'?: string[];
1556
+ 'alwaysSelectFields.list'?: string[];
1557
+ 'alwaysSelectFields.create'?: string[];
1558
+ 'alwaysSelectFields.read'?: string[];
1559
+ 'alwaysSelectFields.update'?: string[];
1560
+ 'docPermissions.default'?: ModelDocPermissionsHook;
1561
+ 'docPermissions.list'?: ModelDocPermissionsHook;
1562
+ 'docPermissions.create'?: ModelDocPermissionsHook;
1563
+ 'docPermissions.read'?: ModelDocPermissionsHook;
1564
+ 'docPermissions.update'?: ModelDocPermissionsHook;
1565
+ 'baseFilter.default'?: ModelBaseFilterHook;
1566
+ 'baseFilter.list'?: ModelBaseFilterHook;
1567
+ 'baseFilter.read'?: ModelBaseFilterHook;
1568
+ 'baseFilter.update'?: ModelBaseFilterHook;
1569
+ 'baseFilter.delete'?: ModelBaseFilterHook;
1570
+ 'overrideFilter.default'?: ModelOverrideFilterHook;
1571
+ 'overrideFilter.list'?: ModelOverrideFilterHook;
1572
+ 'overrideFilter.read'?: ModelOverrideFilterHook;
1573
+ 'overrideFilter.update'?: ModelOverrideFilterHook;
1574
+ 'overrideFilter.delete'?: ModelOverrideFilterHook;
1575
+ 'decorate.default'?: ModelHook;
1576
+ 'decorate.list'?: ModelHook;
1577
+ 'decorate.create'?: ModelHook;
1578
+ 'decorate.read'?: ModelHook;
1579
+ 'decorate.update'?: ModelHook;
1580
+ 'decorateAll.default'?: ModelListHook;
1581
+ 'decorateAll.list'?: ModelListHook;
1582
+ 'validate.default'?: ValidateRule | ModelValidateHook;
1583
+ 'validate.create'?: ValidateRule | ModelValidateHook;
1584
+ 'validate.update'?: ValidateRule | ModelValidateHook;
1585
+ 'prepare.default'?: ModelHook;
1586
+ 'prepare.create'?: ModelHook;
1587
+ 'prepare.update'?: ModelHook;
1588
+ 'transform.default'?: ModelDocumentHook;
1589
+ 'transform.update'?: ModelDocumentHook;
1590
+ 'afterPersist.default'?: ModelDocumentHook;
1591
+ 'afterPersist.create'?: ModelDocumentHook;
1592
+ 'afterPersist.update'?: ModelDocumentHook;
1593
+ onChange?: Record<string, ModelChangeHook>;
1594
+ 'requestSchemas.create'?: RequestSchema;
1595
+ 'requestSchemas.update'?: RequestSchema;
1596
+ 'requestSchemas.upsert'?: RequestSchema;
1597
+ 'requestSchemas.count'?: RequestSchema;
1598
+ 'requestSchemas.distinct'?: RequestSchema;
1599
+ 'requestSchemas.advancedList'?: RequestSchema;
1600
+ 'requestSchemas.advancedReadFilter'?: RequestSchema;
1601
+ 'requestSchemas.advancedRead'?: RequestSchema;
1602
+ 'requestSchemas.advancedCreate.default'?: RequestSchema;
1603
+ 'requestSchemas.advancedCreate.data'?: RequestSchema;
1604
+ 'requestSchemas.advancedUpdate'?: RequestSchema;
1605
+ 'requestSchemas.advancedUpdate.default'?: RequestSchema;
1606
+ 'requestSchemas.advancedUpdate.data'?: RequestSchema;
1607
+ 'requestSchemas.advancedUpsert.default'?: RequestSchema;
1608
+ 'requestSchemas.advancedUpsert.data'?: RequestSchema;
1609
+ 'requestSchemas.subList'?: RequestSchema;
1610
+ 'requestSchemas.subRead'?: RequestSchema;
1611
+ 'requestSchemas.subCreate'?: RequestSchema;
1612
+ 'requestSchemas.subUpdate'?: RequestSchema;
1613
+ 'requestSchemas.subBulkUpdate'?: RequestSchema;
1614
+ 'defaults.findOneArgs'?: DefaultFindOneArgs<TModel>;
1615
+ 'defaults.findOneOptions'?: FindOneOptions;
1616
+ 'defaults.findByIdArgs'?: DefaultFindByIdArgs<TModel>;
1617
+ 'defaults.findByIdOptions'?: FindByIdOptions;
1618
+ 'defaults.findArgs'?: DefaultFindArgs<TModel>;
1619
+ 'defaults.findOptions'?: FindOptions;
1620
+ 'defaults.createArgs'?: CreateArgs;
1621
+ 'defaults.createOptions'?: CreateOptions;
1622
+ 'defaults.updateOneArgs'?: UpdateOneArgs<TModel>;
1623
+ 'defaults.updateOneOptions'?: UpdateOneOptions;
1624
+ 'defaults.updateByIdArgs'?: UpdateByIdArgs<TModel>;
1625
+ 'defaults.updateByIdOptions'?: UpdateByIdOptions;
1626
+ 'defaults.upsertArgs'?: UpsertArgs<TModel>;
1627
+ 'defaults.existsOptions'?: ExistsOptions;
1628
+ 'defaults.publicListArgs'?: PublicListArgs;
1629
+ 'defaults.publicListOptions'?: PublicListOptions;
1630
+ 'defaults.publicCreateArgs'?: PublicCreateArgs;
1631
+ 'defaults.publicCreateOptions'?: PublicCreateOptions;
1632
+ 'defaults.publicReadArgs'?: PublicReadArgs;
1633
+ 'defaults.publicReadOptions'?: PublicReadOptions;
1634
+ 'defaults.publicUpdateArgs'?: PublicUpdateArgs;
1635
+ 'defaults.publicUpdateOptions'?: PublicUpdateOptions;
1636
+ }
1637
+ interface ExtendedDataRouterOptions<TData = unknown> extends DataRouterOptions<TData> {
1638
+ 'requestSchemas.advancedList'?: RequestSchema;
1639
+ 'requestSchemas.advancedReadFilter'?: RequestSchema;
1640
+ 'requestSchemas.advancedRead'?: RequestSchema;
1641
+ }
1642
+
1643
+ interface DistinctArgs<T = unknown> {
1644
+ filter?: Filter<T>;
1645
+ }
1646
+ type SubdocumentId = string;
1647
+ type SubdocumentName = string;
1648
+ type SubdocumentRecord = Record<string, unknown>;
1649
+ type SubdocumentBulkRecord = SubdocumentRecord & {
1650
+ _id?: unknown;
1651
+ };
1652
+ type SubdocumentCreateInput = SubdocumentRecord | SubdocumentRecord[];
1653
+ type SubdocumentBulkUpdateInput = SubdocumentBulkRecord[];
1654
+ interface SubdocumentListOptions<T = unknown> {
1655
+ filter?: Filter<T>;
1656
+ select?: string[];
1657
+ }
1658
+ interface SubdocumentReadOptions {
1659
+ select?: string[];
1660
+ populate?: SubPopulate | SubPopulate[];
1661
+ }
1662
+ interface SubdocumentCreateOptions {
1663
+ addFirst?: boolean;
1664
+ }
1665
+ interface SubdocumentParentArgs {
1666
+ populate?: SubPopulate | SubPopulate[];
1667
+ }
1668
+ interface SubdocumentParentOptions {
1669
+ access?: BaseFilterAccess;
1670
+ lean?: boolean;
1671
+ }
1672
+
1673
+ declare function parsePathParam(value: string | string[] | undefined, parameter: string): string;
1674
+ declare function parseQuery<TSchema extends z.ZodTypeAny>(schema: TSchema, value: unknown): z.output<TSchema>;
1675
+ declare function parseBody<TSchema extends z.ZodTypeAny>(schema: TSchema, value: unknown): z.output<TSchema>;
1676
+ declare function parseBodyWithSchema<TSchema extends z.ZodTypeAny>(schema: TSchema, value: unknown, userSchema?: RequestSchemaLike): Promise<z.output<TSchema>>;
1677
+ declare function parseNestedBodyWithSchema(schema: z.ZodTypeAny, value: unknown, nestedKey: string, userSchema?: RequestSchemaLike): Promise<Record<string, unknown>>;
1678
+ /**
1679
+ * Wraps a request validator into a request schema adapter used by `access-router`.
1680
+ *
1681
+ * @example
1682
+ * const schema = defineRequestSchema(fromZod(z.object({ name: z.string() })));
1683
+ */
1684
+ declare function defineRequestSchema<T = unknown>(validator: RequestSchemaValidator<T>, options?: RequestSchemaOptions): RequestSchemaAdapter<T>;
1685
+ /**
1686
+ * Adapts a Zod schema into a `RequestSchemaValidator` for `access-router`.
1687
+ *
1688
+ * @example
1689
+ * const validator = fromZod(z.object({ name: z.string() }));
1690
+ */
1691
+ declare function fromZod<TSchema extends z.ZodTypeAny>(schema: TSchema): RequestSchemaValidator<z.output<TSchema>>;
1692
+ declare function fromStandardSchema<TSchema extends StandardSchemaV1>(schema: TSchema): RequestSchemaValidator<StandardSchemaInferOutput<TSchema>>;
1693
+ declare function fromYup<TSchema extends YupSchemaLike>(schema: TSchema): RequestSchemaValidator;
1694
+ declare function fromJoi<TSchema extends JoiSchemaLike>(schema: TSchema): RequestSchemaValidator;
1695
+ declare function fromAjv<TValue = unknown>(validator: AjvValidatorLike<TValue>): RequestSchemaValidator<TValue>;
1696
+ declare function fromValibot<TSchema, TOutput = unknown>(schema: TSchema, safeParse: ValibotSafeParseLike): RequestSchemaValidator<TOutput>;
1697
+ declare function fromArkType<TValue = unknown>(type: ArkTypeLike<TValue>): RequestSchemaValidator<TValue>;
1698
+ declare function fromIoTs<TValue = unknown>(decoder: IoTsDecoderLike<TValue>): RequestSchemaValidator<TValue>;
1699
+ declare function fromSuperstruct<TStruct, TOutput = unknown>(struct: TStruct, validate: SuperstructValidateLike): RequestSchemaValidator<TOutput>;
1700
+ declare function fromVine<TValue = unknown>(validator: VineValidatorLike<TValue>): RequestSchemaValidator<TValue>;
1701
+
1702
+ export { type Filter as $, type AccessRouterBaseRequest as A, type BaseFilterAccess as B, type Change as C, DATA_MIDDLEWARE as D, type DataFindOneOptions as E, type DataFindOptions as F, type DataHook as G, type DataHookContext as H, type DataIdentifierHook as I, type DataListHook as J, type DataOverrideFilterHook as K, type DataRequest as L, type DataRequestSchemas as M, type DataRouterOptions as N, type DecorateAccess as O, type DecorateAllAccess as P, type DeepFieldPath as Q, type DefaultModelRouterOptions as R, type Defaults as S, type DistinctArgs as T, type DistinctBody as U, type DocPermissionsAccess as V, type ErrorResult as W, type ExistsOptions as X, type ExtendedDataRouterOptions as Y, type ExtendedDefaultModelRouterOptions as Z, type ExtendedModelRouterOptions as _, type AccessRouterFieldKey as a, type RequestSchemaFailure as a$, FilterOperator as a0, type FindAccess as a1, type FindArgs as a2, type FindByIdArgs as a3, type FindByIdOptions as a4, type FindOneArgs as a5, type FindOneOptions as a6, type FindOptions as a7, type GlobalOptions as a8, type GlobalPermissionValue as a9, type ModelValidateHook as aA, PERMISSIONS as aB, PERMISSION_KEYS as aC, type PathValue as aD, type PermissionSchema as aE, type Populate as aF, type PopulateAccess as aG, type PrepareAccess as aH, type Projection as aI, type PublicCreateArgs as aJ, type PublicCreateOptions as aK, type PublicErrorResult as aL, type PublicListArgs as aM, type PublicListOptions as aN, type PublicListResult as aO, type PublicOutput as aP, type PublicReadArgs as aQ, type PublicReadOptions as aR, type PublicServiceResult as aS, type PublicSingleResult as aT, type PublicUpdateArgs as aU, type PublicUpdateOptions as aV, type PublicUpsertArgs as aW, type PublicUpsertOptions as aX, type ReadQueryInput as aY, type Request as aZ, type RequestSchemaAdapter as a_, type GuardHook as aa, type IdentifierHook as ab, type Include as ac, type IoTsContextEntryLike as ad, type IoTsDecodeErrorLike as ae, type IoTsDecoderLike as af, type JoiSchemaLike as ag, type JoiValidationErrorDetailLike as ah, type KeyValueProjection as ai, type ListQueryInput as aj, type ListResult as ak, MIDDLEWARE as al, type MaybePromise as am, type ModelBaseFilterHook as an, type ModelChangeHook as ao, type ModelDeleteHook as ap, type ModelDocPermissionsHook as aq, type ModelDocument as ar, type ModelDocumentHook as as, type ModelHook as at, type ModelHookContext as au, type ModelIdentifierHook as av, type ModelListHook as aw, type ModelOverrideFilterHook as ax, type ModelRequest as ay, type ModelRouterOptions as az, type AccessRouterLogger as b, type SubdocumentRecord as b$, type RequestSchemaIssue as b0, type RequestSchemaLike as b1, type RequestSchemaOptions as b2, type RequestSchemaResult as b3, type RequestSchemaSuccess as b4, type RequestSchemaValidator as b5, type RequestSchemas as b6, type RootDataListQueryEntry as b7, type RootDataOperation as b8, type RootDataReadByFilterQueryEntry as b9, type SelectedPublicOutput as bA, type ServiceResult as bB, type SingleResult as bC, type Sort as bD, type SortOrder as bE, type StandardSchemaFailure as bF, type StandardSchemaInferOutput as bG, type StandardSchemaIssue as bH, type StandardSchemaPathSegment as bI, type StandardSchemaResult as bJ, type StandardSchemaSuccess as bK, type StandardSchemaV1 as bL, StatusCodes as bM, type SubListBody as bN, type SubPopulate as bO, type SubQueryEntry as bP, type SubReadBody as bQ, type SubdocumentBulkRecord as bR, type SubdocumentBulkUpdateInput as bS, type SubdocumentCreateInput as bT, type SubdocumentCreateOptions as bU, type SubdocumentId as bV, type SubdocumentListOptions as bW, type SubdocumentName as bX, type SubdocumentParentArgs as bY, type SubdocumentParentOptions as bZ, type SubdocumentReadOptions as b_, type RootDataReadByIdQueryEntry as ba, type RootModelCountQueryEntry as bb, type RootModelCreateQueryEntry as bc, type RootModelDeleteQueryEntry as bd, type RootModelDistinctQueryEntry as be, type RootModelListQueryEntry as bf, type RootModelNewQueryEntry as bg, type RootModelOperation as bh, type RootModelReadByFilterQueryEntry as bi, type RootModelReadByIdQueryEntry as bj, type RootModelSubBulkUpdateQueryEntry as bk, type RootModelSubCreateQueryEntry as bl, type RootModelSubDeleteQueryEntry as bm, type RootModelSubListQueryEntry as bn, type RootModelSubReadQueryEntry as bo, type RootModelSubUpdateQueryEntry as bp, type RootModelUpdateQueryEntry as bq, type RootModelUpsertQueryEntry as br, type RootOperationResult as bs, type RootQueryEntry as bt, type RootRouterOptions as bu, type RootSubOperation as bv, type RootTarget as bw, type RouteGuardAccess as bx, type SelectAccess as by, type SelectedPopulatedPublicOutput as bz, type AccessRouterRequest as c, type SuperstructFailureLike as c0, type SuperstructValidateLike as c1, type Task as c2, type TransformAccess as c3, type TypedFilter as c4, type UpdateByIdArgs as c5, type UpdateByIdOptions as c6, type UpdateOneArgs as c7, type UpdateOneOptions as c8, type UpdateQueryInput as c9, fromZod as cA, parseBody as cB, parseBodyWithSchema as cC, parseNestedBodyWithSchema as cD, parsePathParam as cE, parseQuery as cF, AccessRuntime as cG, DataService as cH, Model as cI, Service as cJ, PublicService as cK, type OpenApiRouterOptions as cL, type OpenApiRegistryOptions as cM, type OpenApiRouteDescriptor as cN, type OpenApiDocumentOptions as cO, type OpenApiParameter as cP, type OpenApiSchema as cQ, type OpenApiResponses as cR, type AccessRouterPermissionMap as cS, type AccessRouterPermissions as cT, type OpenApiMethod as cU, type Permissions as cV, defaultRuntime as cW, type UpsertArgs as ca, type UpsertOptions as cb, type UpsertQueryInput as cc, type ValibotIssueLike as cd, type ValibotPathItemLike as ce, type ValibotSafeParseLike as cf, type ValibotSafeParseResult as cg, type ValidateAccess as ch, type ValidateRule as ci, type Validation as cj, type ValidationError as ck, type VineValidationErrorLike as cl, type VineValidationMessageLike as cm, type VineValidatorLike as cn, type YupSchemaLike as co, type YupValidationErrorLike as cp, defineRequestSchema as cq, fromAjv as cr, fromArkType as cs, fromIoTs as ct, fromJoi as cu, fromStandardSchema as cv, fromSuperstruct as cw, fromValibot as cx, fromVine as cy, fromYup as cz, type AccessRouterRequestExtensions as d, type AdvancedCreateBody as e, 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 AjvValidatorLike as m, type ArkTypeErrorsLike as n, type ArkTypeLike as o, type ArkTypeProblemLike as p, Codes as q, type CountBody as r, type CreateArgs as s, type CreateOptions as t, type CreateQueryInput as u, CustomHeaders as v, type DataBaseFilterHook as w, type DataFilter as x, type DataFindArgs as y, type DataFindOneArgs as z };