@web-ts-toolkit/access-router 0.45.0 → 0.46.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.
@@ -30,6 +30,7 @@ declare class Service<TModel = unknown> extends Base<TModel> {
30
30
  defaults: Defaults<TModel>;
31
31
  protected baseFields: string[];
32
32
  protected baseFieldsExt: string[];
33
+ private readonly persist;
33
34
  findRawParentDoc(args: {
34
35
  filter: Filter<TModel>;
35
36
  select: string;
@@ -53,13 +54,27 @@ declare class Service<TModel = unknown> extends Base<TModel> {
53
54
  skim?: boolean;
54
55
  includePermissions?: boolean;
55
56
  }): Promise<SingleResult<TModel>>;
57
+ /**
58
+ * Update at authorized policy paths: admitted leaves preserve omitted siblings;
59
+ * whole-authorized objects/arrays replace. Shared by updateById and existing-row
60
+ * upsert. Validation precedes trusted prepare output (not re-filtered); partial
61
+ * prepare containers preserve omissions. Transform retains explicit document-setter
62
+ * replacement authority. Send nested client JSON, not literal dotted update keys.
63
+ */
56
64
  updateOne(filter: Filter<TModel>, data: Record<string, unknown>, args?: UpdateOneArgs<TModel>, options?: UpdateOneOptions, decorate?: (doc: unknown, context?: ModelHookContext) => unknown): Promise<SingleResult<TModel> | ErrorResult>;
57
65
  updateById(id: string, data: Record<string, unknown>, args?: UpdateByIdArgs<TModel>, options?: UpdateByIdOptions, decorate?: (doc: unknown, context?: ModelHookContext) => unknown): Promise<SingleResult<TModel> | ErrorResult>;
58
66
  upsert(filter: Filter<TModel>, data: Record<string, unknown>, args?: UpsertArgs<TModel>, options?: UpsertOptions, decorate?: (doc: unknown, context?: ModelHookContext) => unknown): Promise<ServiceResult<TModel>>;
59
67
  delete(id: string): Promise<SingleResult<unknown> | ErrorResult>;
68
+ /**
69
+ * Check existence under row policy (read by default). Terminal false returns a
70
+ * Forbidden ErrorResult before adapter dispatch, in both includeId modes.
71
+ * Allowed matches return true or an `{ _id }` record; misses return false or null.
72
+ * Custom HTTP routes must map ErrorResult to their intended response status.
73
+ */
60
74
  exists(filter: Filter<TModel>, options: ExistsOptions & {
61
75
  includeId: true;
62
76
  }): Promise<SingleResult<unknown> | ErrorResult>;
77
+ /** Boolean existence; terminal false policy returns Forbidden, not successful false. */
63
78
  exists(filter: Filter<TModel>, options?: ExistsOptions): Promise<SingleResult<boolean> | ErrorResult>;
64
79
  protected isValidDistinctFieldName(field: unknown): boolean;
65
80
  protected authorizeDistinctField(field: string): Promise<ErrorResult | null>;
@@ -72,6 +87,13 @@ declare class Service<TModel = unknown> extends Base<TModel> {
72
87
  * validation and subquery parsing so substituted parent data stays inert.
73
88
  */
74
89
  countTrusted(authorizedFilter: Filter<TModel>): Promise<SingleResult<number> | ErrorResult>;
90
+ /**
91
+ * Group target document IDs by original parent-key aliases using one aggregate.
92
+ * Resolves the requested row policy (legacy count includes pass `count`), casts
93
+ * authorized filters/foreign operands with the target schema, and deduplicates IDs
94
+ * independently of pagination. Cast failures return BadRequest; false policy returns
95
+ * Forbidden. Casting does not execute countDocuments middleware/plugins.
96
+ */
75
97
  countByFieldValues(foreignField: string, values: unknown[], filter?: Filter<TModel>, access?: BaseFilterAccess): Promise<SingleResult<Map<string, Set<string>>> | ErrorResult>;
76
98
  getDocPermissions(doc: unknown): Record<string, unknown>;
77
99
  private resolveFindOneArgs;
@@ -93,8 +115,28 @@ declare class Service<TModel = unknown> extends Base<TModel> {
93
115
  private getAccessibleIdSet;
94
116
  listSub(id: SubdocumentId, sub: SubdocumentName, options?: SubdocumentListOptions<TModel>): Promise<ListResult | ErrorResult>;
95
117
  readSub(id: SubdocumentId, sub: SubdocumentName, subId: SubdocumentId, options?: SubdocumentReadOptions): Promise<SingleResult | ErrorResult>;
118
+ /**
119
+ * Apply authorized policy-path updates, preserving protected siblings, then save.
120
+ * Output requires post-save parent read and subdocument read operation/row access;
121
+ * hidden output is successful `data: null` (direct/root-entry 200), not a failed write.
122
+ * Visible output uses read fields plus `_id`. Do not retry solely for null output.
123
+ */
96
124
  updateSub(id: SubdocumentId, sub: SubdocumentName, subId: SubdocumentId, data: Record<string, unknown>): Promise<SingleResult | ErrorResult>;
125
+ /**
126
+ * Save authorized targeted updates, then return readable targets in stored order.
127
+ * Requires parent/subdocument read access for output, not subdocument list access;
128
+ * uses read fields plus `_id`. Hidden output succeeds with `data: [], count: 0`
129
+ * (direct/root-entry 200); count measures visible rows, not all updated rows.
130
+ */
97
131
  bulkUpdateSub(id: SubdocumentId, sub: SubdocumentName, data: SubdocumentBulkUpdateInput | Record<string, unknown>): Promise<ListResult | ErrorResult>;
132
+ /**
133
+ * Append/prepend admitted rows, then return the visible full array (including when
134
+ * input is empty). Output requires post-save parent read and subdocument list AND
135
+ * read guards/row filters; fields use read projection plus `_id`.
136
+ * Hidden output succeeds with code `created`, `data: [], count: 0`
137
+ * (direct/root-entry 201). Visible count/order follow filtered stored rows.
138
+ * Empty output does not mean the write failed; addFirst is a service option.
139
+ */
98
140
  createSub(id: SubdocumentId, sub: SubdocumentName, data: SubdocumentCreateInput, options?: SubdocumentCreateOptions): Promise<ListResult | ErrorResult>;
99
141
  deleteSub(id: SubdocumentId, sub: SubdocumentName, subId: SubdocumentId): Promise<SingleResult | ErrorResult>;
100
142
  getParentDoc(id: SubdocumentId, sub: SubdocumentName, args?: SubdocumentParentArgs, options?: SubdocumentParentOptions): Promise<any>;
@@ -128,6 +170,11 @@ declare class PublicService<TModel = unknown> extends Service<TModel> {
128
170
  select?: TSelect;
129
171
  populate?: TPopulate;
130
172
  }, options?: PublicUpdateOptions): Promise<SingleResult<SelectedPopulatedPublicOutput<TModel, TSelect, TPopulate>> | ErrorResult>;
173
+ /**
174
+ * With an _id, check update-policy existence then update: terminal denial returns
175
+ * Forbidden, an allowed miss remains Unauthorized, and neither creates a row.
176
+ * Without an _id, use the create path.
177
+ */
131
178
  _upsert<TSelect extends Projection | undefined = undefined, TPopulate extends Populate[] | string | undefined = undefined>(data: Record<string, unknown>, args?: Omit<PublicUpsertArgs, 'select' | 'populate'> & {
132
179
  select?: TSelect;
133
180
  populate?: TPopulate;
@@ -244,12 +291,32 @@ type AjvErrorObjectLike = {
244
291
  };
245
292
  };
246
293
  type AjvValidationErrorLike = {
247
- errors?: ReadonlyArray<AjvErrorObjectLike> | null;
294
+ ajv: true;
295
+ validation: true;
296
+ errors: ReadonlyArray<AjvErrorObjectLike>;
248
297
  };
249
- type AjvValidatorLike<T = unknown> = {
250
- (value: unknown): boolean | Promise<T | boolean>;
298
+ /**
299
+ * Structural AJV contract; AJV is not a runtime dependency of access-router.
300
+ * Sync validators return boolean verdicts and expose mutable errors, snapshotted
301
+ * in the same turn. Tagged `$async: true` validators resolve with data (even
302
+ * false/true/null), or reject with AJV ValidationError diagnostics.
303
+ *
304
+ * Untagged promises/thenables are unsupported. Migrate async boolean-verdict
305
+ * wrappers to RequestSchemaValidator, or return data/reject validation errors
306
+ * and retain the literal `$async: true` tag. Real AJV ValidateFunction and
307
+ * AsyncValidateFunction overloads infer output via their type guard without casts; a synchronous
308
+ * structural validator's output type can be supplied explicitly to fromAjv<T>.
309
+ * AJV can type inline async schemas through a sync overload; an AsyncSchema-typed
310
+ * schema selects its async compile/compileAsync overload. Runtime uses the tag.
311
+ */
312
+ type AjvValidatorLike<T = unknown> = ({
313
+ (value: unknown): boolean;
314
+ $async?: false;
315
+ } | {
316
+ (value: unknown): PromiseLike<T>;
317
+ $async: true;
318
+ }) & {
251
319
  errors?: ReadonlyArray<AjvErrorObjectLike> | null;
252
- $async?: boolean;
253
320
  };
254
321
  type ValibotPathItemLike = {
255
322
  key?: unknown;
@@ -447,17 +514,221 @@ interface RequestComplexityOptions {
447
514
  maxBulkItems?: number;
448
515
  maxIncludeCount?: number;
449
516
  maxSubQueryCount?: number;
517
+ /**
518
+ * Defaults to 10. Shared request-and-runtime-owned ceiling on awaited model-service
519
+ * adapter/document persistence operations, including nested includes/root entries.
520
+ * Recursive orchestration holds no permit; internal map/run bounds are per call.
521
+ * One operation may issue multiple driver commands via Mongoose middleware/populate;
522
+ * direct DB/network calls from trusted application hooks are outside this ceiling.
523
+ * Not a process-wide connection limit or protection against competing edits.
524
+ */
450
525
  maxBulkConcurrency?: number;
451
526
  maxHookConcurrency?: number;
527
+ /** Cumulative correlated target executions per request/runtime (default 100); permit release does not refund this budget. */
452
528
  maxCorrelatedQueries?: number;
529
+ /** Correlated template nesting bound (default 5), independent of persistence concurrency. */
453
530
  maxCorrelatedDepth?: number;
454
531
  }
455
532
 
533
+ type OpenApiMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
534
+ type OpenApiSchema = Record<string, unknown>;
535
+ type OpenApiSchemaSource = unknown;
536
+ type OpenApiParameter = {
537
+ name: string;
538
+ in: 'path' | 'query';
539
+ required?: boolean;
540
+ description?: string;
541
+ schema?: OpenApiSchema;
542
+ };
543
+ type OpenApiResponse = {
544
+ description: string;
545
+ content?: Record<string, {
546
+ schema: OpenApiSchema;
547
+ }>;
548
+ };
549
+ type OpenApiResponses = Record<string, OpenApiResponse>;
550
+ type OpenApiRouteDescriptor = {
551
+ method: OpenApiMethod;
552
+ path: string;
553
+ operationId?: string;
554
+ summary?: string;
555
+ description?: string;
556
+ tags?: string[];
557
+ acl?: string;
558
+ deprecated?: boolean;
559
+ query?: OpenApiSchemaSource;
560
+ body?: OpenApiSchemaSource;
561
+ pathParams?: Record<string, OpenApiSchemaSource>;
562
+ responses?: OpenApiResponses;
563
+ /**
564
+ * When true, replaces an existing registration with the same method/path
565
+ * even when the descriptors differ. When false (default), conflicting
566
+ * registrations throw at registration time so consumers can detect
567
+ * accidental route shadowing.
568
+ */
569
+ allowReplace?: boolean;
570
+ /**
571
+ * When true, this exact descriptor is idempotent and registering the same
572
+ * method/path with an equivalent descriptor again is silently accepted.
573
+ * Differing re-registrations still throw unless {@link allowReplace} is set.
574
+ * Additionally, an idempotent descriptor may share its operationId with
575
+ * another idempotent descriptor mounted at a different path on the same
576
+ * registry, so reserved operations (e.g. the root batch route) can be
577
+ * exposed from multiple base paths without triggering strict-mode
578
+ * duplicate-operationId rejection.
579
+ */
580
+ idempotent?: boolean;
581
+ };
582
+ type OpenApiRegistryOptions = {
583
+ /**
584
+ * Throw when the same method/path is registered twice with differing
585
+ * descriptors, instead of silently replacing. Default: true (strict).
586
+ * The {@link AccessRuntime} registry is constructed in strict mode by
587
+ * default; construct {@link OpenApiRegistry} directly with
588
+ * `rejectConflicts: false` for legacy replacement semantics.
589
+ */
590
+ rejectConflicts?: boolean;
591
+ /**
592
+ * Throw when the same operationId is registered more than once, including
593
+ * when {@link OpenApiRouteDescriptor.allowReplace} is set. Default: true.
594
+ */
595
+ rejectDuplicateOperationIds?: boolean;
596
+ };
597
+ type OpenApiDocumentOptions = {
598
+ title: string;
599
+ version: string;
600
+ description?: string;
601
+ servers?: Array<{
602
+ url: string;
603
+ description?: string;
604
+ }>;
605
+ };
606
+ type OpenApiRouterOptions = Partial<OpenApiDocumentOptions> & {
607
+ jsonPath?: string;
608
+ docsPath?: string | false;
609
+ swaggerUiCssUrl?: string;
610
+ swaggerUiBundleUrl?: string;
611
+ };
612
+
613
+ type ModelReferenceMap = {
614
+ [key: string]: string | ModelReferenceMap;
615
+ };
616
+ declare class AccessRuntime {
617
+ private readonly allowGlobalModelLookup;
618
+ constructor(options?: {
619
+ allowGlobalModelLookup?: boolean;
620
+ });
621
+ private readonly globalOptions;
622
+ private readonly defaultModelOptions;
623
+ private readonly modelOptions;
624
+ private readonly modelJsonSchemas;
625
+ private readonly dataOptions;
626
+ private readonly modelRefs;
627
+ private readonly modelSubs;
628
+ private readonly modelAtts;
629
+ private readonly modelInstances;
630
+ private readonly openApiRegistry;
631
+ private openApiPathPrefix;
632
+ registerModelInstance<TModel>(modelName: string, model: mongoose.Model<TModel>): void;
633
+ hasModelInstance(modelName: string): boolean;
634
+ getModelInstance<TModel = unknown>(modelName: string): mongoose.Model<TModel> | null;
635
+ registerOpenApiRoute(route: OpenApiRouteDescriptor): void;
636
+ /**
637
+ * Compose OpenAPI paths while synchronously constructing mounted routers.
638
+ * Prefixes apply before collision checks; prior descriptors and Express paths
639
+ * are unchanged. Nested calls compose and the prior scope is restored even on
640
+ * failure. The callback must finish registration synchronously (no async work).
641
+ */
642
+ withOpenApiPathPrefix<T>(prefix: string, build: () => T): T;
643
+ /**
644
+ * Enable strict OpenAPI collision detection for the remainder of this
645
+ * runtime's lifetime. After this call, conflicting method/path
646
+ * registrations and duplicate operationIds throw {@link OpenApiCollisionError}
647
+ * instead of silently replacing. Existing already-registered routes are
648
+ * not retroactively re-validated.
649
+ */
650
+ enableOpenApiCollisionDetection(): void;
651
+ getOpenApiRoutes(): OpenApiRouteDescriptor[];
652
+ clearOpenApiRoutes(): void;
653
+ getOpenApiSpec(info: OpenApiDocumentOptions): {
654
+ openapi: string;
655
+ info: Omit<OpenApiDocumentOptions, "servers">;
656
+ servers?: OpenApiDocumentOptions["servers"];
657
+ paths: Record<string, Record<string, {
658
+ [key: `x-${string}`]: unknown;
659
+ operationId?: string;
660
+ summary?: string;
661
+ description?: string;
662
+ tags?: string[];
663
+ deprecated?: boolean;
664
+ parameters?: OpenApiParameter[];
665
+ requestBody?: {
666
+ required?: boolean;
667
+ content: Record<string, {
668
+ schema: OpenApiSchema;
669
+ }>;
670
+ };
671
+ responses: OpenApiResponses;
672
+ }>>;
673
+ };
674
+ createBootstrapSnapshot(): {
675
+ globalOptions: GlobalOptions;
676
+ defaultModelOptions: DefaultModelRouterOptions;
677
+ modelOptions: Record<string, ModelRouterOptions>;
678
+ dataOptions: Record<string, DataRouterOptions>;
679
+ modelInstances: Record<string, mongoose.Model<unknown>>;
680
+ modelJsonSchemas: Record<string, Record<string, unknown>>;
681
+ modelRefs: Record<string, ModelReferenceMap>;
682
+ modelSubs: Record<string, string[]>;
683
+ modelAtts: Record<string, string[]>;
684
+ openApi: {
685
+ routes: OpenApiRouteDescriptor[];
686
+ options: Required<OpenApiRegistryOptions>;
687
+ };
688
+ };
689
+ restoreBootstrapSnapshot(snapshot: ReturnType<AccessRuntime['createBootstrapSnapshot']>): void;
690
+ setGlobalOptions(options: GlobalOptions): void;
691
+ setGlobalOption<K extends keyof GlobalOptions>(key: K, value: GlobalOptions[K]): void;
692
+ getGlobalOptions(): GlobalOptions;
693
+ getGlobalOption<K extends keyof GlobalOptions>(key: K, defaultValue?: GlobalOptions[K]): GlobalOptions[K];
694
+ setDefaultModelOptions(options: DefaultModelRouterOptions): void;
695
+ setDefaultModelOption<K extends keyof ExtendedDefaultModelRouterOptions>(key: K, value: ExtendedDefaultModelRouterOptions[K]): void;
696
+ getDefaultModelOptions(): DefaultModelRouterOptions<unknown>;
697
+ getDefaultModelOption<K extends keyof ExtendedDefaultModelRouterOptions>(key: K, defaultValue?: ExtendedDefaultModelRouterOptions[K]): ExtendedDefaultModelRouterOptions<unknown>[K];
698
+ private createModelOptions;
699
+ private getOrCreateModelOptions;
700
+ setModelOptions<TModel = unknown>(modelName: string, options: ModelRouterOptions<TModel>): void;
701
+ setModelOption<K extends keyof ExtendedModelRouterOptions<TModel>, TModel = unknown>(modelName: string, key: K, value: ExtendedModelRouterOptions<TModel>[K]): void;
702
+ getModelOptions<TModel = unknown>(modelName: string): ModelRouterOptions<TModel>;
703
+ getModelOption<K extends keyof ExtendedModelRouterOptions<TModel>, TModel = unknown>(modelName: string, key: K | string, defaultValue?: ExtendedModelRouterOptions<TModel>[K]): ExtendedModelRouterOptions<TModel>[K];
704
+ getExactModelOption<K extends keyof ExtendedModelRouterOptions<TModel>, TModel = unknown>(modelName: string, key: K | string): ExtendedModelRouterOptions<TModel>[K];
705
+ getModelNames(): string[];
706
+ hasModel(modelName: string): boolean;
707
+ getModelJsonSchema(modelName: string): Record<string, unknown>;
708
+ private createDataOptions;
709
+ private getOrCreateDataOptions;
710
+ setDataOptions<TData = unknown>(dataName: string, options: DataRouterOptions<TData>): void;
711
+ setDataOption<K extends keyof DataRouterOptions<TData>, TData = unknown>(dataName: string, key: K, value: DataRouterOptions<TData>[K]): void;
712
+ getDataOptions<TData = unknown>(dataName: string): DataRouterOptions<TData>;
713
+ getDataSnapshot<TData = unknown>(dataName: string): readonly TData[];
714
+ getDataOption<K extends keyof DataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string, defaultValue?: DataRouterOptions<TData>[K]): DataRouterOptions<TData>[K];
715
+ getExactDataOption<K extends keyof ExtendedDataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string): ExtendedDataRouterOptions<TData>[K];
716
+ getDataNames(): string[];
717
+ ensureModelMeta(modelName: string): void;
718
+ getModelRef(modelName: string, refPath: string): string | null;
719
+ getModelSub(modelName: string): string[];
720
+ getModelAtt(modelName: string): string[];
721
+ }
722
+ declare const defaultRuntime: AccessRuntime;
723
+
456
724
  declare class RequestConcurrencyScheduler {
457
725
  readonly limit: number;
726
+ private activeWork;
727
+ private readonly waiters;
458
728
  constructor(limit: number);
459
729
  map<TInput, TOutput>(items: TInput[], iteratee: (item: TInput, index: number, scheduled: true) => Promise<TOutput>): Promise<TOutput[]>;
460
730
  run<TOutput>(iteratee: (scheduled: true) => Promise<TOutput>): Promise<TOutput>;
731
+ work<TOutput>(operation: () => TOutput | PromiseLike<TOutput>): Promise<TOutput>;
461
732
  }
462
733
 
463
734
  type CrossResourceModelOperation = 'list' | 'read' | 'count';
@@ -468,6 +739,7 @@ interface CorrelatedExecState {
468
739
  declare class Base<TModel = unknown> {
469
740
  protected req: ModelRequest;
470
741
  protected modelName: string;
742
+ protected readonly requestRuntime: AccessRuntime;
471
743
  constructor(req: ModelRequest, modelName: string);
472
744
  decorate<T>(doc: T, access: DecorateAccess, context: ModelHookContext): Promise<T>;
473
745
  decorateAll<T>(docs: T[], access: DecorateAllAccess, context: ModelHookContext): Promise<T[]>;
@@ -507,6 +779,8 @@ declare class Base<TModel = unknown> {
507
779
  includePaths: string[];
508
780
  correlatedReferenceFields: string[];
509
781
  };
782
+ private validateIncludeOutputPath;
783
+ private assertIncludeOutputPaths;
510
784
  private getForeignKeyValues;
511
785
  private getForeignKey;
512
786
  private buildForeignKeyIndex;
@@ -712,6 +986,7 @@ interface PublicReadOptions {
712
986
  populateAccess?: PopulateAccess;
713
987
  lean?: boolean;
714
988
  includePermissions?: boolean;
989
+ /** Retry an authorized read miss with list access (default true); requires list operation access. Forbidden/BadRequest never retry. */
715
990
  tryList?: boolean;
716
991
  }
717
992
 
@@ -724,6 +999,7 @@ interface PublicUpsertArgs extends PublicUpdateArgs {
724
999
  }
725
1000
  interface UpdateOneArgs<T = unknown> extends Omit<PublicUpdateArgs, 'select' | 'tasks'> {
726
1001
  overrides?: {
1002
+ /** Trusted replacement: nullish generates row policy; false returns Forbidden without filter generation or persistence. */
727
1003
  filter?: Filter<T>;
728
1004
  populate?: Populate[] | string;
729
1005
  };
@@ -731,6 +1007,7 @@ interface UpdateOneArgs<T = unknown> extends Omit<PublicUpdateArgs, 'select' | '
731
1007
  interface UpdateByIdArgs<T = unknown> extends Omit<UpdateOneArgs<T>, 'overrides'> {
732
1008
  overrides?: {
733
1009
  populate?: Populate[] | string;
1010
+ /** Nullish resolves the identifier; false denies without ID/filter generation or persistence. Objects still receive row policy. */
734
1011
  idFilter?: Filter<T>;
735
1012
  };
736
1013
  }
@@ -861,10 +1138,21 @@ type TypedFilterObject<T> = {
861
1138
  };
862
1139
  type TypedFilter<T> = false | TypedFilterObject<WithDefaultId<T>>;
863
1140
  type Filter<T = unknown> = IsUnknown<T> extends true ? LooseFilter : TypedFilter<T>;
1141
+ /**
1142
+ * Batched related-data join. Count uses one grouped aggregate per execution,
1143
+ * counting distinct authorized target documents independently of list pagination.
1144
+ * The target schema casts authorized filters/foreign operands; invalid casts return
1145
+ * BadRequest. Query casting does not execute countDocuments middleware/plugins.
1146
+ */
864
1147
  interface LegacyInclude {
865
1148
  mode?: 'legacy';
866
1149
  model: string;
867
1150
  op: 'list' | 'read' | 'count';
1151
+ /**
1152
+ * Output path; must not overlap the receiving model's documentPermissionField
1153
+ * (equal, ancestor or descendant, including equivalent bracket paths).
1154
+ * Nested receiving-model settings apply. Rejected before target persistence.
1155
+ */
868
1156
  path: string;
869
1157
  filter?: Filter;
870
1158
  localField: string;
@@ -895,6 +1183,11 @@ interface CorrelatedIncludeBase {
895
1183
  mode: 'correlated';
896
1184
  model: string;
897
1185
  op: 'list' | 'read' | 'count';
1186
+ /**
1187
+ * Output-only field path. Must not equal, contain or descend from the receiving
1188
+ * model's documentPermissionField (default `_permissions`). The include tree is
1189
+ * preflighted before target persistence; violations return BadRequest.
1190
+ */
898
1191
  path: string;
899
1192
  args?: CorrelatedIncludeArgs;
900
1193
  options?: Record<string, never>;
@@ -921,6 +1214,7 @@ interface CorrelatedCountInclude extends CorrelatedIncludeBase {
921
1214
  id?: never;
922
1215
  }
923
1216
  type CorrelatedInclude = CorrelatedReadByIdInclude | CorrelatedReadByFilterInclude | CorrelatedListInclude | CorrelatedCountInclude;
1217
+ /** Related output cannot overwrite authorization metadata at any supported nested level. */
924
1218
  type Include = LegacyInclude | CorrelatedInclude;
925
1219
  type FindAccess = 'list' | 'read';
926
1220
  type PopulateAccess = 'list' | 'read';
@@ -1218,6 +1512,7 @@ interface FindArgs<T = unknown> {
1218
1512
  page?: string | number;
1219
1513
  pageSize?: string | number;
1220
1514
  overrides?: {
1515
+ /** Trusted replacement: nullish generates row policy; false returns Forbidden without filter generation or persistence. */
1221
1516
  filter?: Filter<T>;
1222
1517
  select?: Projection;
1223
1518
  populate?: Populate[] | string;
@@ -1236,6 +1531,7 @@ interface FindOneArgs<T = unknown> {
1236
1531
  populate?: Populate[] | string;
1237
1532
  include?: Include | Include[];
1238
1533
  overrides?: {
1534
+ /** Trusted replacement: nullish generates row policy; false returns Forbidden without filter generation or persistence. */
1239
1535
  filter?: Filter<T>;
1240
1536
  select?: Projection;
1241
1537
  populate?: Populate[] | string;
@@ -1255,14 +1551,18 @@ interface FindByIdArgs<T = unknown> {
1255
1551
  overrides?: {
1256
1552
  select?: Projection;
1257
1553
  populate?: Populate[] | string;
1554
+ /** Nullish resolves the identifier; false denies without ID/filter generation or persistence. Objects still receive row policy. */
1258
1555
  idFilter?: Filter<T>;
1259
1556
  };
1260
1557
  }
1261
1558
  interface FindByIdOptions extends FindOneOptions {
1262
1559
  }
1263
1560
 
1561
+ /** Terminal false row policy returns Forbidden in either result mode, before adapter dispatch. */
1264
1562
  interface ExistsOptions {
1563
+ /** Row-policy access, defaulting to read. */
1265
1564
  access?: BaseFilterAccess;
1565
+ /** Return an `{ _id }` record or null instead of a match/miss boolean. Denial is an ErrorResult, never a miss. */
1266
1566
  includeId?: boolean;
1267
1567
  }
1268
1568
 
@@ -1380,6 +1680,7 @@ interface RootRouterOptions {
1380
1680
  operationAccess?: Validation;
1381
1681
  maxBatchEntries?: number;
1382
1682
  maxOrderGroups?: number;
1683
+ /** Whole root operations per order group; separate from requestComplexity.maxBulkConcurrency persistence admission. */
1383
1684
  maxConcurrentOperations?: number;
1384
1685
  }
1385
1686
  interface OperationAccess {
@@ -1404,6 +1705,7 @@ interface DocPermissions {
1404
1705
  }
1405
1706
  interface DefaultModelRouterOptions<TModel = unknown> {
1406
1707
  listHardLimit?: number;
1708
+ /** Authorization metadata path (default `_permissions`); include output cannot equal, contain or descend from it. */
1407
1709
  documentPermissionField?: string;
1408
1710
  idParam?: string;
1409
1711
  idField?: string;
@@ -1430,6 +1732,11 @@ interface ExtendedDefaultModelRouterOptions<TModel = unknown> extends DefaultMod
1430
1732
  interface ModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions<TModel> {
1431
1733
  modelName?: string;
1432
1734
  basePath?: string;
1735
+ /**
1736
+ * Update grants define assignment boundaries: authorized leaves preserve omitted
1737
+ * siblings; a whole-object/array grant permits replacement (no generic deep merge).
1738
+ * Send nested JSON; literal dotted client keys are not update operators.
1739
+ */
1433
1740
  permissionSchema?: PermissionSchema<AccessRouterFieldKey<TModel>>;
1434
1741
  alwaysSelectFields?: string[];
1435
1742
  docPermissions?: DocPermissions | ModelDocPermissionsHook;
@@ -1438,7 +1745,19 @@ interface ModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions
1438
1745
  decorate?: ModelHook<TModel> | Record<string, ModelHook<TModel>>;
1439
1746
  decorateAll?: ModelListHook<TModel> | Record<string, ModelListHook<TModel>>;
1440
1747
  validate?: ValidateRule | ModelValidateHook | Record<string, ValidateRule | ModelValidateHook>;
1748
+ /**
1749
+ * Trusted model hook after validation of selected client data; output is not
1750
+ * re-filtered and may add protected/server-only fields. During update, supplied
1751
+ * children at partial policy ancestors apply without deleting omitted siblings.
1752
+ * Explicit null/undefined can clear/unset a parent; no output means no assignments.
1753
+ * Use transform document setters for deliberate whole-parent replacement.
1754
+ */
1441
1755
  prepare?: ModelHook<TModel> | Record<string, ModelHook<TModel>>;
1756
+ /**
1757
+ * Trusted live-document hook after update assignment and before save. May replace
1758
+ * protected state explicitly with document setters; do not blindly reintroduce
1759
+ * unfiltered context.originalData. Model hooks are not added to subdocument writes.
1760
+ */
1442
1761
  transform?: ModelDocumentHook<TModel> | Record<string, ModelDocumentHook<TModel>>;
1443
1762
  afterPersist?: ModelDocumentHook<TModel> | Record<string, ModelDocumentHook<TModel>>;
1444
1763
  onChange?: Record<string, ModelChangeHook>;
@@ -1623,11 +1942,22 @@ declare function fromJoi<TSchema extends JoiSchemaLike>(schema: TSchema): Reques
1623
1942
  * diagnostics via mutable `validator.errors`; those errors are snapshotted
1624
1943
  * synchronously before any suspension so concurrent same-turn validations do
1625
1944
  * not observe another input's diagnostics. Asynchronous AJV schemas
1626
- * (`$async: true`) return a promise that resolves with validated data on
1627
- * success or rejects with a `ValidationError` carrying an `errors` array on
1628
- * failure; rejection-carried errors are normalized, while any other rejection
1629
- * propagates unchanged as an operational exception.
1945
+ * (`$async: true`) resolve with validated data, including false/true/null.
1946
+ * AJV `ValidationError` rejections (`ajv: true`, `validation: true`, `errors`
1947
+ * array) are normalized; other throws/rejections preserve operational identity.
1948
+ * Async paths never read shared `validator.errors`.
1949
+ *
1950
+ * Untagged promises/thenables throw TypeError and are observed to prevent
1951
+ * unhandled rejection. Migrate async boolean-verdict wrappers to a custom
1952
+ * RequestSchemaValidator, or retain `$async: true` and return data/reject AJV
1953
+ * validation errors. Sync validators must return boolean verdicts. Real AJV
1954
+ * sync/async validators are accepted without casts; no runtime AJV import is used.
1955
+ * Output is inferred from genuine AJV's type-guard overload (including its async
1956
+ * subtype); structural async output is inferred from the promise. Pass TValue
1957
+ * explicitly for a structural sync boolean validator without a type guard.
1630
1958
  */
1959
+ declare function fromAjv<TValue>(validator: AjvValidatorLike<TValue> & ((value: unknown) => value is TValue)): RequestSchemaValidator<TValue>;
1960
+ /** Adapts structural AJV validators with the same sync-verdict / tagged-async-data contract. */
1631
1961
  declare function fromAjv<TValue = unknown>(validator: AjvValidatorLike<TValue>): RequestSchemaValidator<TValue>;
1632
1962
  declare function fromValibot<TSchema, TOutput = unknown>(schema: TSchema, safeParse: ValibotSafeParseLike): RequestSchemaValidator<TOutput>;
1633
1963
  /**
@@ -1649,4 +1979,4 @@ declare function fromIoTs<TValue = unknown>(decoder: IoTsDecoderLike<TValue>): R
1649
1979
  declare function fromSuperstruct<TStruct, TOutput = unknown>(struct: TStruct, validate: SuperstructValidateLike): RequestSchemaValidator<TOutput>;
1650
1980
  declare function fromVine<TValue = unknown>(validator: VineValidatorLike<TValue>): RequestSchemaValidator<TValue>;
1651
1981
 
1652
- export { type DistinctArgs as $, type AccessRouterBaseRequest as A, type BaseFilterAccess as B, type Change as C, type CreateArgs as D, type CreateOptions as E, type CreateQueryInput as F, CustomHeaders as G, DATA_MIDDLEWARE as H, type DataBaseFilterHook as I, type DataFilter as J, type DataFindArgs as K, type DataFindOneArgs as L, type DataFindOneOptions as M, type DataFindOptions as N, type DataHook as O, type DataHookContext as P, type DataIdentifierHook as Q, type DataListHook as R, type DataOverrideFilterHook as S, type DataRequest as T, type DataRequestSchemas as U, type DataRouterOptions as V, type DecorateAccess as W, type DecorateAllAccess as X, type DeepFieldPath as Y, type DefaultModelRouterOptions as Z, type Defaults as _, type AccessRouterFieldKey as a, type PublicReadOptions as a$, type DistinctBody as a0, type DocPermissionsAccess as a1, type ErrorResult as a2, type ExistsOptions as a3, type ExtendedDataRouterOptions as a4, type ExtendedDefaultModelRouterOptions as a5, type ExtendedModelRouterOptions as a6, type Filter as a7, FilterOperator as a8, type FindAccess as a9, type ModelDocument as aA, type ModelDocumentHook as aB, type ModelHook as aC, type ModelHookContext as aD, type ModelIdentifierHook as aE, type ModelListHook as aF, type ModelOverrideFilterHook as aG, type ModelRequest as aH, type ModelRouterOptions as aI, type ModelValidateHook as aJ, PERMISSIONS as aK, PERMISSION_KEYS as aL, type ParentRef as aM, type PathValue as aN, type PermissionSchema as aO, type Populate as aP, type PopulateAccess as aQ, type PrepareAccess as aR, type Projection as aS, type PublicCreateArgs as aT, type PublicCreateOptions as aU, type PublicErrorResult as aV, type PublicListArgs as aW, type PublicListOptions as aX, type PublicListResult as aY, type PublicOutput as aZ, type PublicReadArgs as a_, type FindArgs as aa, type FindByIdArgs as ab, type FindByIdOptions as ac, type FindOneArgs as ad, type FindOneOptions as ae, type FindOptions as af, type GlobalOptions as ag, type GlobalPermissionValue as ah, type GuardHook as ai, type IdentifierHook as aj, type Include as ak, type IoTsContextEntryLike as al, type IoTsDecodeErrorLike as am, type IoTsDecoderLike as an, type JoiSchemaLike as ao, type JoiValidationErrorDetailLike as ap, type KeyValueProjection as aq, type LegacyInclude as ar, type ListQueryInput as as, type ListResult as at, MIDDLEWARE as au, type MaybePromise as av, type ModelBaseFilterHook as aw, type ModelChangeHook as ax, type ModelDeleteHook as ay, type ModelDocPermissionsHook as az, type AccessRouterLogger as b, type SubdocumentBulkRecord as b$, type PublicServiceResult as b0, type PublicSingleResult as b1, type PublicUpdateArgs as b2, type PublicUpdateOptions as b3, type PublicUpsertArgs as b4, type PublicUpsertOptions as b5, type ReadQueryInput as b6, type Request as b7, type RequestSchemaAdapter as b8, type RequestSchemaFailure as b9, type RootModelUpdateQueryEntry as bA, type RootModelUpsertQueryEntry as bB, type RootOperationResult as bC, type RootQueryEntry as bD, type RootRouterOptions as bE, type RootSubOperation as bF, type RootTarget as bG, type RouteGuardAccess as bH, type SelectAccess as bI, type SelectedPopulatedPublicOutput as bJ, type SelectedPublicOutput as bK, type ServiceResult as bL, type SingleResult as bM, type Sort as bN, type SortOrder as bO, type StandardSchemaFailure as bP, type StandardSchemaInferOutput as bQ, type StandardSchemaIssue as bR, type StandardSchemaPathSegment as bS, type StandardSchemaResult as bT, type StandardSchemaSuccess as bU, type StandardSchemaV1 as bV, StatusCodes as bW, type SubListBody as bX, type SubPopulate as bY, type SubQueryEntry as bZ, type SubReadBody as b_, type RequestSchemaIssue as ba, type RequestSchemaLike as bb, type RequestSchemaOptions as bc, type RequestSchemaResult as bd, type RequestSchemaSuccess as be, type RequestSchemaValidator as bf, type RequestSchemas as bg, type RootDataListQueryEntry as bh, type RootDataOperation as bi, type RootDataReadByFilterQueryEntry as bj, type RootDataReadByIdQueryEntry as bk, type RootModelCountQueryEntry as bl, type RootModelCreateQueryEntry as bm, type RootModelDeleteQueryEntry as bn, type RootModelDistinctQueryEntry as bo, type RootModelListQueryEntry as bp, type RootModelNewQueryEntry as bq, type RootModelOperation as br, type RootModelReadByFilterQueryEntry as bs, type RootModelReadByIdQueryEntry as bt, type RootModelSubBulkUpdateQueryEntry as bu, type RootModelSubCreateQueryEntry as bv, type RootModelSubDeleteQueryEntry as bw, type RootModelSubListQueryEntry as bx, type RootModelSubReadQueryEntry as by, type RootModelSubUpdateQueryEntry as bz, type AccessRouterRequest as c, type SubdocumentBulkUpdateInput as c0, type SubdocumentCreateInput as c1, type SubdocumentCreateOptions as c2, type SubdocumentId as c3, type SubdocumentListOptions as c4, type SubdocumentName as c5, type SubdocumentParentArgs as c6, type SubdocumentParentOptions as c7, type SubdocumentReadOptions as c8, type SubdocumentRecord as c9, type YupValidationErrorLike as cA, defineRequestSchema as cB, fromAjv as cC, fromArkType as cD, fromIoTs as cE, fromJoi as cF, fromStandardSchema as cG, fromSuperstruct as cH, fromValibot as cI, fromVine as cJ, fromYup as cK, fromZod as cL, parseBody as cM, parseBodyWithSchema as cN, parseNestedBodyWithSchema as cO, parsePathParam as cP, parseQuery as cQ, DataService as cR, Service as cS, PublicService as cT, type AccessRouterPermissionMap as cU, type AccessRouterPermissions as cV, type Permissions as cW, type SuperstructFailureLike as ca, type SuperstructValidateLike as cb, type Task as cc, type TaskType as cd, type TransformAccess as ce, type TypedFilter as cf, type UpdateByIdArgs as cg, type UpdateByIdOptions as ch, type UpdateOneArgs as ci, type UpdateOneOptions as cj, type UpdateQueryInput as ck, type UpsertArgs as cl, type UpsertOptions as cm, type UpsertQueryInput as cn, type ValibotIssueLike as co, type ValibotPathItemLike as cp, type ValibotSafeParseLike as cq, type ValibotSafeParseResult as cr, type ValidateAccess as cs, type ValidateRule as ct, type Validation as cu, type ValidationError as cv, type VineValidationErrorLike as cw, type VineValidationMessageLike as cx, type VineValidatorLike as cy, type YupSchemaLike 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 AjvValidationErrorLike as m, type AjvValidatorLike as n, type ArkTypeErrorsLike as o, type ArkTypeLike as p, type ArkTypeProblemLike as q, Codes as r, type CorrelatedCountInclude as s, type CorrelatedFilter as t, type CorrelatedInclude as u, type CorrelatedIncludeArgs as v, type CorrelatedListInclude as w, type CorrelatedReadByFilterInclude as x, type CorrelatedReadByIdInclude as y, type CountBody as z };
1982
+ export { type DistinctArgs as $, type AccessRouterBaseRequest as A, type BaseFilterAccess as B, type Change as C, type CreateArgs as D, type CreateOptions as E, type CreateQueryInput as F, CustomHeaders as G, DATA_MIDDLEWARE as H, type DataBaseFilterHook as I, type DataFilter as J, type DataFindArgs as K, type DataFindOneArgs as L, type DataFindOneOptions as M, type DataFindOptions as N, type DataHook as O, type DataHookContext as P, type DataIdentifierHook as Q, type DataListHook as R, type DataOverrideFilterHook as S, type DataRequest as T, type DataRequestSchemas as U, type DataRouterOptions as V, type DecorateAccess as W, type DecorateAllAccess as X, type DeepFieldPath as Y, type DefaultModelRouterOptions as Z, type Defaults as _, type AccessRouterFieldKey as a, type PublicReadOptions as a$, type DistinctBody as a0, type DocPermissionsAccess as a1, type ErrorResult as a2, type ExistsOptions as a3, type ExtendedDataRouterOptions as a4, type ExtendedDefaultModelRouterOptions as a5, type ExtendedModelRouterOptions as a6, type Filter as a7, FilterOperator as a8, type FindAccess as a9, type ModelDocument as aA, type ModelDocumentHook as aB, type ModelHook as aC, type ModelHookContext as aD, type ModelIdentifierHook as aE, type ModelListHook as aF, type ModelOverrideFilterHook as aG, type ModelRequest as aH, type ModelRouterOptions as aI, type ModelValidateHook as aJ, PERMISSIONS as aK, PERMISSION_KEYS as aL, type ParentRef as aM, type PathValue as aN, type PermissionSchema as aO, type Populate as aP, type PopulateAccess as aQ, type PrepareAccess as aR, type Projection as aS, type PublicCreateArgs as aT, type PublicCreateOptions as aU, type PublicErrorResult as aV, type PublicListArgs as aW, type PublicListOptions as aX, type PublicListResult as aY, type PublicOutput as aZ, type PublicReadArgs as a_, type FindArgs as aa, type FindByIdArgs as ab, type FindByIdOptions as ac, type FindOneArgs as ad, type FindOneOptions as ae, type FindOptions as af, type GlobalOptions as ag, type GlobalPermissionValue as ah, type GuardHook as ai, type IdentifierHook as aj, type Include as ak, type IoTsContextEntryLike as al, type IoTsDecodeErrorLike as am, type IoTsDecoderLike as an, type JoiSchemaLike as ao, type JoiValidationErrorDetailLike as ap, type KeyValueProjection as aq, type LegacyInclude as ar, type ListQueryInput as as, type ListResult as at, MIDDLEWARE as au, type MaybePromise as av, type ModelBaseFilterHook as aw, type ModelChangeHook as ax, type ModelDeleteHook as ay, type ModelDocPermissionsHook as az, type AccessRouterLogger as b, type SubdocumentBulkRecord as b$, type PublicServiceResult as b0, type PublicSingleResult as b1, type PublicUpdateArgs as b2, type PublicUpdateOptions as b3, type PublicUpsertArgs as b4, type PublicUpsertOptions as b5, type ReadQueryInput as b6, type Request as b7, type RequestSchemaAdapter as b8, type RequestSchemaFailure as b9, type RootModelUpdateQueryEntry as bA, type RootModelUpsertQueryEntry as bB, type RootOperationResult as bC, type RootQueryEntry as bD, type RootRouterOptions as bE, type RootSubOperation as bF, type RootTarget as bG, type RouteGuardAccess as bH, type SelectAccess as bI, type SelectedPopulatedPublicOutput as bJ, type SelectedPublicOutput as bK, type ServiceResult as bL, type SingleResult as bM, type Sort as bN, type SortOrder as bO, type StandardSchemaFailure as bP, type StandardSchemaInferOutput as bQ, type StandardSchemaIssue as bR, type StandardSchemaPathSegment as bS, type StandardSchemaResult as bT, type StandardSchemaSuccess as bU, type StandardSchemaV1 as bV, StatusCodes as bW, type SubListBody as bX, type SubPopulate as bY, type SubQueryEntry as bZ, type SubReadBody as b_, type RequestSchemaIssue as ba, type RequestSchemaLike as bb, type RequestSchemaOptions as bc, type RequestSchemaResult as bd, type RequestSchemaSuccess as be, type RequestSchemaValidator as bf, type RequestSchemas as bg, type RootDataListQueryEntry as bh, type RootDataOperation as bi, type RootDataReadByFilterQueryEntry as bj, type RootDataReadByIdQueryEntry as bk, type RootModelCountQueryEntry as bl, type RootModelCreateQueryEntry as bm, type RootModelDeleteQueryEntry as bn, type RootModelDistinctQueryEntry as bo, type RootModelListQueryEntry as bp, type RootModelNewQueryEntry as bq, type RootModelOperation as br, type RootModelReadByFilterQueryEntry as bs, type RootModelReadByIdQueryEntry as bt, type RootModelSubBulkUpdateQueryEntry as bu, type RootModelSubCreateQueryEntry as bv, type RootModelSubDeleteQueryEntry as bw, type RootModelSubListQueryEntry as bx, type RootModelSubReadQueryEntry as by, type RootModelSubUpdateQueryEntry as bz, type AccessRouterRequest as c, type OpenApiResponses as c$, type SubdocumentBulkUpdateInput as c0, type SubdocumentCreateInput as c1, type SubdocumentCreateOptions as c2, type SubdocumentId as c3, type SubdocumentListOptions as c4, type SubdocumentName as c5, type SubdocumentParentArgs as c6, type SubdocumentParentOptions as c7, type SubdocumentReadOptions as c8, type SubdocumentRecord as c9, type YupValidationErrorLike as cA, defineRequestSchema as cB, fromAjv as cC, fromArkType as cD, fromIoTs as cE, fromJoi as cF, fromStandardSchema as cG, fromSuperstruct as cH, fromValibot as cI, fromVine as cJ, fromYup as cK, fromZod as cL, parseBody as cM, parseBodyWithSchema as cN, parseNestedBodyWithSchema as cO, parsePathParam as cP, parseQuery as cQ, AccessRuntime as cR, DataService as cS, Service as cT, PublicService as cU, type OpenApiRouterOptions as cV, type OpenApiRegistryOptions as cW, type OpenApiRouteDescriptor as cX, type OpenApiDocumentOptions as cY, type OpenApiParameter as cZ, type OpenApiSchema as c_, type SuperstructFailureLike as ca, type SuperstructValidateLike as cb, type Task as cc, type TaskType as cd, type TransformAccess as ce, type TypedFilter as cf, type UpdateByIdArgs as cg, type UpdateByIdOptions as ch, type UpdateOneArgs as ci, type UpdateOneOptions as cj, type UpdateQueryInput as ck, type UpsertArgs as cl, type UpsertOptions as cm, type UpsertQueryInput as cn, type ValibotIssueLike as co, type ValibotPathItemLike as cp, type ValibotSafeParseLike as cq, type ValibotSafeParseResult as cr, type ValidateAccess as cs, type ValidateRule as ct, type Validation as cu, type ValidationError as cv, type VineValidationErrorLike as cw, type VineValidationMessageLike as cx, type VineValidatorLike as cy, type YupSchemaLike as cz, type AccessRouterRequestExtensions as d, type AccessRouterPermissionMap as d0, type AccessRouterPermissions as d1, type OpenApiMethod as d2, type Permissions as d3, defaultRuntime as d4, 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 AjvValidationErrorLike as m, type AjvValidatorLike as n, type ArkTypeErrorsLike as o, type ArkTypeLike as p, type ArkTypeProblemLike as q, Codes as r, type CorrelatedCountInclude as s, type CorrelatedFilter as t, type CorrelatedInclude as u, type CorrelatedIncludeArgs as v, type CorrelatedListInclude as w, type CorrelatedReadByFilterInclude as x, type CorrelatedReadByIdInclude as y, type CountBody as z };