@classytic/mongokit 3.38.1 → 3.39.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.
Files changed (44) hide show
  1. package/dist/{PaginationEngine-CBS1XGzp.d.mts → PaginationEngine-D-P19Y9m.d.mts} +34 -9
  2. package/dist/PaginationEngine-DQ7beTCR.mjs +1182 -0
  3. package/dist/{Repository-Ck5x43wF.mjs → Repository-D7fDpyFx.mjs} +400 -37
  4. package/dist/{Repository-BdSkQ8vc.d.mts → Repository-IxI983_m.d.mts} +55 -8
  5. package/dist/actions/index.d.mts +1 -1
  6. package/dist/actions/index.mjs +1 -1
  7. package/dist/adapter/index.d.mts +21 -0
  8. package/dist/adapter/index.mjs +1 -1
  9. package/dist/{adapter-Bfqz8yHE.mjs → adapter-BrVfPFSW.mjs} +45 -1
  10. package/dist/ai/index.d.mts +1 -1
  11. package/dist/better-auth/index.mjs +2 -2
  12. package/dist/{create-repository-BU4x9Kb0.d.mts → create-repository-CRXjDa3N.d.mts} +5 -5
  13. package/dist/{create-repository-B5EulQ31.mjs → create-repository-DOe9E_5F.mjs} +3 -3
  14. package/dist/{index-DKEql4cL.d.mts → index-CmjNyulu.d.mts} +67 -8
  15. package/dist/index.d.mts +77 -13
  16. package/dist/index.mjs +8 -8
  17. package/dist/{method-registry.plugin-DblM7V6j.mjs → method-registry.plugin-C63pGn1d.mjs} +54 -4
  18. package/dist/{multi-tenant.plugin-BwSvTirB.d.mts → multi-tenant.plugin-B-tzNeYL.d.mts} +60 -4
  19. package/dist/{operations-DZodvjC-.d.mts → operations-CrRIoc8Z.d.mts} +22 -7
  20. package/dist/outbox/index.d.mts +1 -1
  21. package/dist/outbox/index.mjs +2 -2
  22. package/dist/pagination/PaginationEngine.d.mts +1 -1
  23. package/dist/pagination/PaginationEngine.mjs +1 -1
  24. package/dist/pagination/utils/limits.d.mts +1 -1
  25. package/dist/pagination/utils/limits.mjs +22 -1
  26. package/dist/pagination-BpIv2bdS.d.mts +364 -0
  27. package/dist/{plugin-options-DXnlKM3B.d.mts → plugin-options-BuvtOSZf.d.mts} +2 -2
  28. package/dist/plugins/index.d.mts +3 -3
  29. package/dist/plugins/index.mjs +3 -3
  30. package/dist/{repository-H_ffGgpE.d.mts → repository-ZbLtL7Nk.d.mts} +30 -4
  31. package/dist/tenant/index.d.mts +89 -0
  32. package/dist/tenant/index.mjs +94 -0
  33. package/dist/testkit/index.d.mts +2 -2
  34. package/dist/testkit/index.mjs +1 -1
  35. package/dist/{timestamp.plugin-CBQukQzV.mjs → timestamp.plugin-B5eiaItQ.mjs} +31 -8
  36. package/dist/{to-plain-Dyz_qvuo.d.mts → to-plain-B8ufk3Qz.d.mts} +2 -2
  37. package/dist/{update-jSXp3nu3.mjs → update-c_01A0if.mjs} +126 -73
  38. package/dist/utils/index.d.mts +1 -1
  39. package/dist/{validation-chain.plugin-DhNyxNCw.mjs → validation-chain.plugin-Bju1D1Sn.mjs} +2 -2
  40. package/dist/{validation-chain.plugin-yQRob3Av.d.mts → validation-chain.plugin-DvrLJIbJ.d.mts} +3 -19
  41. package/package.json +7 -3
  42. package/dist/PaginationEngine-BX9o_-4R.mjs +0 -735
  43. package/dist/core-62oo3N1C.d.mts +0 -50
  44. package/dist/pagination-jSUdrACK.d.mts +0 -158
@@ -1,8 +1,7 @@
1
- import { _ as UpdateOptions, a as CreateOptions, b as LookupOptions, c as FindOneAndUpdateOptions, d as LookupPopulateResult, g as UpdateManyResult, h as SessionOptions, m as ReadOptions, o as DeleteManyResult, p as OperationOptions, r as CacheableOptions, s as DeleteResult, t as AggregateOptions, u as LookupPopulateOptions, v as WithTransactionOptions, y as LookupBuilder } from "./operations-DZodvjC-.mjs";
2
- import { a as PopulateSpec, i as ObjectId, l as SortSpec$1, o as ReadPreferenceType, s as SelectSpec } from "./core-62oo3N1C.mjs";
3
- import { c as PaginationConfig, r as CollationOptions, t as AggregatePaginationOptions } from "./pagination-jSUdrACK.mjs";
4
- import { _ as RepositoryOptions, d as PluginType, f as PrioritizedHook, o as Middleware, p as RepositoryContext } from "./repository-H_ffGgpE.mjs";
5
- import { t as PaginationEngine } from "./PaginationEngine-CBS1XGzp.mjs";
1
+ import { _ as UpdateOptions, a as CreateOptions, b as LookupOptions, c as FindOneAndUpdateOptions, d as LookupPopulateResult, g as UpdateManyResult, h as SessionOptions, m as ReadOptions, o as DeleteManyResult, p as OperationOptions, r as CacheableOptions, s as DeleteResult, t as AggregateOptions, u as LookupPopulateOptions, v as WithTransactionOptions, y as LookupBuilder } from "./operations-CrRIoc8Z.mjs";
2
+ import { _ as PopulateSpec, g as ObjectId, i as CountStrategy, r as CollationOptions, t as AggregatePaginationOptions, u as PaginationConfig, v as ReadPreferenceType, x as SortSpec$1, y as SelectSpec } from "./pagination-BpIv2bdS.mjs";
3
+ import { _ as RepositoryOptions, d as PluginType, f as PrioritizedHook, o as Middleware, p as RepositoryContext } from "./repository-ZbLtL7Nk.mjs";
4
+ import { t as PaginationEngine } from "./PaginationEngine-D-P19Y9m.mjs";
6
5
  import { AggPaginationRequest, AggRequest, AggResult, ArchiveOptions, ArchiveResult, ArchiveSink, ChangeEvent, FilterInput, KeysetAggPaginationResult, QueryOptions, RepoCapabilities, RepositoryBase, TenantPurgeOptions, TenantPurgeResult, TenantPurgeStrategy, WatchOptions } from "@classytic/repo-core/repository";
7
6
  import { ClientSession, Expression, Model, PipelineStage, PopulateOptions } from "mongoose";
8
7
  import { Filter } from "@classytic/repo-core/filter";
@@ -580,6 +579,18 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
580
579
  * the `Middleware<TDoc>` type for the protocol.
581
580
  */
582
581
  private readonly _middlewares;
582
+ /**
583
+ * Shard-key guard built once from `options.distribution`; `undefined`
584
+ * when not configured so the per-op check is a single falsy test.
585
+ */
586
+ private readonly _checkDistribution;
587
+ /**
588
+ * Whether id-addressed verbs are guarded too — true unless the
589
+ * distribution key IS the id field, where an `_id` match is genuinely
590
+ * routed and guarding would flag every by-id call. See
591
+ * {@link ID_ADDRESSED_OPERATIONS}.
592
+ */
593
+ private readonly _guardIdAddressed;
583
594
  constructor(Model: Model<TDoc, any, any, any>, plugins?: PluginType[], paginationConfig?: PaginationConfig, options?: RepositoryOptions);
584
595
  /**
585
596
  * Live read-through view of the hook engine's listener registry.
@@ -860,8 +871,12 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
860
871
  * repo without a filter to observe deletes.
861
872
  * - `options.signal` ends the iterator (closes the stream). A
862
873
  * pre-aborted signal rejects at the op boundary like every other op.
863
- * - `options.resumeAfter` forwards a previously captured Mongo
864
- * resume token for at-least-once consumption across restarts.
874
+ * - Every yielded event carries `resumeToken` (the change document's
875
+ * `_id`). Persist the last one you finished processing and pass it
876
+ * back as `options.resumeAfter` — or `options.startAfter` to also
877
+ * step past an invalidate event — for at-least-once consumption
878
+ * across restarts. Setting both is rejected up front (Mongo forbids
879
+ * the combination; the driver error is far less legible).
865
880
  *
866
881
  * Context keys for policy plugins (`organizationId`, `bypassTenant`,
867
882
  * `includeDeleted`, ...) ride the options bag at runtime — same as every
@@ -906,6 +921,8 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
906
921
  sort?: SortSpec$1 | string;
907
922
  cursor?: string;
908
923
  after?: string;
924
+ /** Cursor for the PREVIOUS page. Mutually exclusive with `after`/`cursor`. */
925
+ before?: string;
909
926
  page?: number;
910
927
  pagination?: {
911
928
  page?: number;
@@ -916,7 +933,9 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
916
933
  mode?: 'offset' | 'keyset';
917
934
  hint?: string | Record<string, 1 | -1>;
918
935
  maxTimeMS?: number;
919
- countStrategy?: 'exact' | 'estimated' | 'none';
936
+ countStrategy?: CountStrategy;
937
+ /** Ceiling for `countStrategy: 'capped'`. */
938
+ countLimit?: number;
920
939
  readPreference?: ReadPreferenceType;
921
940
  /** Advanced populate options (from QueryParser or Arc's BaseController) */
922
941
  populateOptions?: PopulateOptions[];
@@ -1782,6 +1801,16 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
1782
1801
  * 4. DEFAULT (500) — user-registered hooks
1783
1802
  */
1784
1803
  _buildContext(operation: string, options: Record<string, unknown> | object): Promise<RepositoryContext>;
1804
+ /**
1805
+ * Feed the resolved filter of a guarded verb to the distribution guard.
1806
+ * The slot follows `OP_REGISTRY[op].policyKey` (`query` vs `filters`);
1807
+ * the portable aggregate verbs ALSO carry the caller's filter on
1808
+ * `aggRequest.filter` (merged into the pipeline later by
1809
+ * `_injectPolicyScopeIntoAgg`), and the kit-native pipeline verbs may
1810
+ * carry it as leading `$match` stages — both are folded in so a key the
1811
+ * caller did supply is never reported missing.
1812
+ */
1813
+ private _guardDistribution;
1785
1814
  /**
1786
1815
  * Walk the well-known filter-carrying keys (`query`, `filters`,
1787
1816
  * `having`) and route any Filter IR through `compileFilterToMongo`.
@@ -1796,6 +1825,9 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
1796
1825
  private _resolveSort;
1797
1826
  /**
1798
1827
  * Detect whether to use keyset (cursor) or offset (page) pagination.
1828
+ * Precedence: explicit `mode` → `page` (offset) → `after` (keyset) →
1829
+ * `PaginationConfig.defaultMode` → the sort heuristic (a non-default
1830
+ * sort with no page means the caller wants a cursor).
1799
1831
  */
1800
1832
  private _detectPaginationMode;
1801
1833
  /**
@@ -1866,7 +1898,22 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
1866
1898
  * `errorLabels` exactly as we received it. The caller still sees a
1867
1899
  * thrown error — only the wrapping layer is skipped.
1868
1900
  */
1901
+ /**
1902
+ * Translate a driver error into the repository's error contract, WITHOUT
1903
+ * losing structured diagnostics an action attached to it.
1904
+ *
1905
+ * The translation replaces the object — an E11000 becomes a 409 — so any
1906
+ * property a caller was meant to read went with it. `createMany` attaches a
1907
+ * `partial` report naming which documents landed, and it arrived nowhere:
1908
+ * the report existed, the test for it failed, and the only evidence was the
1909
+ * absence.
1910
+ *
1911
+ * Carried explicitly rather than by copying every own-property, because the
1912
+ * wrap is deliberate: the point is to hide driver internals, and a blanket
1913
+ * copy would put them back.
1914
+ */
1869
1915
  _handleError(error: Error): HttpError;
1916
+ private _translateError;
1870
1917
  }
1871
1918
  //#endregion
1872
1919
  export { AggregationPlan as a, SortOrder as c, AggregationBuilder as i, SortSpec as l, Repository as n, GroupSpec as o, TransitionMachine as r, ProjectionSpec as s, HOOK_PRIORITY as t, VectorSearchOptions as u };
@@ -1,2 +1,2 @@
1
- import { a as create_d_exports, i as delete_d_exports, n as update_d_exports, o as aggregate_d_exports, r as read_d_exports } from "../index-DKEql4cL.mjs";
1
+ import { c as create_d_exports, i as delete_d_exports, n as update_d_exports, r as read_d_exports, u as aggregate_d_exports } from "../index-CmjNyulu.mjs";
2
2
  export { aggregate_d_exports as aggregate, create_d_exports as create, delete_d_exports as deleteActions, read_d_exports as read, update_d_exports as update };
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
- import { g as create_exports, i as update_exports, p as delete_exports, u as read_exports, v as aggregate_exports } from "../update-jSXp3nu3.mjs";
2
+ import { b as create_exports, i as update_exports, m as aggregate_exports, p as delete_exports, u as read_exports } from "../update-c_01A0if.mjs";
3
3
  //#region src/actions/index.ts
4
4
  var actions_exports = /* @__PURE__ */ __exportAll({
5
5
  aggregate: () => aggregate_exports,
@@ -129,6 +129,27 @@ declare class MongooseAdapter<TDoc = unknown, TModelDoc = unknown> implements Da
129
129
  * `matchesRecordFilter` — one shared contract/IR across every kit; its
130
130
  * evaluator is id-coercion aware so a Mongo `ObjectId` `_id` matches its
131
131
  * string form. Arrow field: keeps its binding when passed by reference.
132
+ *
133
+ * The document is flattened to a plain record FIRST, and that step is the
134
+ * whole reason this is not a one-liner. The evaluator resolves field paths
135
+ * with `Object.hasOwn`, own-properties-only and deliberately so: it must not
136
+ * walk a prototype chain, or a crafted `{ 'constructor.x': … }` policy filter
137
+ * could match an inherited member. A HYDRATED Mongoose document keeps its
138
+ * values in `_doc` and exposes them through prototype getters, so it has no
139
+ * own `status`, no own `organizationId` — every path resolves to absent and
140
+ * the filter matches NOTHING. Fail-closed, so it does not leak; it denies.
141
+ *
142
+ * That turned any policy at all into a blanket 404 on every non-compound
143
+ * fetch (`getBySlug`, cache revalidation, the realtime feed) while the same
144
+ * policy worked perfectly on list/get, which filter at the DB. The asymmetry
145
+ * is what made it so hard to see: a resource reads fine until the day someone
146
+ * gives it a row-level policy, and then one route starts lying.
147
+ *
148
+ * Knowing that a Mongoose document is not a plain record is the MONGO kit's
149
+ * job, not the dialect-agnostic evaluator's, so the normalisation lives here.
150
+ * `toObject` rather than `toJSON`: it preserves `ObjectId` and `Date` values,
151
+ * which the evaluator compares by type. A `.lean()` result is already plain
152
+ * and passes through untouched.
132
153
  */
133
154
  readonly matchesFilter: (item: unknown, filters: Record<string, unknown>) => boolean;
134
155
  /**
@@ -1,2 +1,2 @@
1
- import { n as createMongooseAdapter, r as isMongooseModel, t as MongooseAdapter } from "../adapter-Bfqz8yHE.mjs";
1
+ import { n as createMongooseAdapter, r as isMongooseModel, t as MongooseAdapter } from "../adapter-BrVfPFSW.mjs";
2
2
  export { MongooseAdapter, createMongooseAdapter, isMongooseModel };
@@ -19,6 +19,29 @@ const REQUIRED_REPO_METHODS = [
19
19
  "update",
20
20
  "delete"
21
21
  ];
22
+ /**
23
+ * A Mongoose document as a plain record, for anything that reads fields directly.
24
+ *
25
+ * Hydrated documents hold their values in `_doc` and surface them through prototype getters, so
26
+ * `Object.hasOwn(doc, 'status')` is FALSE even though `doc.status` reads fine. Any consumer that
27
+ * refuses to walk the prototype chain — as a prototype-pollution-safe field resolver must — sees
28
+ * an empty document. See `matchesFilter` for what that cost us.
29
+ *
30
+ * `toObject` over `toJSON`: it keeps `ObjectId` and `Date` as values rather than stringifying
31
+ * them, and callers here compare by type. Anything already plain (a `.lean()` result, a POJO) is
32
+ * returned untouched, and a `toObject` that throws degrades to the original rather than taking
33
+ * the caller down.
34
+ */
35
+ function toPlainRecord(item) {
36
+ if (item === null || typeof item !== "object") return item;
37
+ const maybe = item;
38
+ if (typeof maybe.toObject !== "function") return item;
39
+ try {
40
+ return maybe.toObject();
41
+ } catch {
42
+ return item;
43
+ }
44
+ }
22
45
  function describeValue(value) {
23
46
  if (value === null) return "null";
24
47
  if (value === void 0) return "undefined";
@@ -215,8 +238,29 @@ var MongooseAdapter = class {
215
238
  * `matchesRecordFilter` — one shared contract/IR across every kit; its
216
239
  * evaluator is id-coercion aware so a Mongo `ObjectId` `_id` matches its
217
240
  * string form. Arrow field: keeps its binding when passed by reference.
241
+ *
242
+ * The document is flattened to a plain record FIRST, and that step is the
243
+ * whole reason this is not a one-liner. The evaluator resolves field paths
244
+ * with `Object.hasOwn`, own-properties-only and deliberately so: it must not
245
+ * walk a prototype chain, or a crafted `{ 'constructor.x': … }` policy filter
246
+ * could match an inherited member. A HYDRATED Mongoose document keeps its
247
+ * values in `_doc` and exposes them through prototype getters, so it has no
248
+ * own `status`, no own `organizationId` — every path resolves to absent and
249
+ * the filter matches NOTHING. Fail-closed, so it does not leak; it denies.
250
+ *
251
+ * That turned any policy at all into a blanket 404 on every non-compound
252
+ * fetch (`getBySlug`, cache revalidation, the realtime feed) while the same
253
+ * policy worked perfectly on list/get, which filter at the DB. The asymmetry
254
+ * is what made it so hard to see: a resource reads fine until the day someone
255
+ * gives it a row-level policy, and then one route starts lying.
256
+ *
257
+ * Knowing that a Mongoose document is not a plain record is the MONGO kit's
258
+ * job, not the dialect-agnostic evaluator's, so the normalisation lives here.
259
+ * `toObject` rather than `toJSON`: it preserves `ObjectId` and `Date` values,
260
+ * which the evaluator compares by type. A `.lean()` result is already plain
261
+ * and passes through untouched.
218
262
  */
219
- matchesFilter = (item, filters) => matchesRecordFilter(item, filters);
263
+ matchesFilter = (item, filters) => matchesRecordFilter(toPlainRecord(item), filters);
220
264
  /**
221
265
  * No-op — mongokit's per-call resources (`watch()` change streams,
222
266
  * `cursor()` iterators) are released by their own `AbortSignal` /
@@ -1,4 +1,4 @@
1
- import { l as Plugin } from "../repository-H_ffGgpE.mjs";
1
+ import { l as Plugin } from "../repository-ZbLtL7Nk.mjs";
2
2
  import { PipelineStage } from "mongoose";
3
3
  //#region src/ai/types.d.ts
4
4
  /** Supported similarity metrics for vector search */
@@ -1,5 +1,5 @@
1
- import { n as Repository } from "../Repository-Ck5x43wF.mjs";
2
- import { n as createMongooseAdapter } from "../adapter-Bfqz8yHE.mjs";
1
+ import { n as Repository } from "../Repository-D7fDpyFx.mjs";
2
+ import { n as createMongooseAdapter } from "../adapter-BrVfPFSW.mjs";
3
3
  import { asReadOnlyRepo } from "@classytic/repo-core/repository";
4
4
  import { pluralizeBetterAuthCollection, resolveBetterAuthCollections } from "@classytic/repo-core/better-auth";
5
5
  //#region src/better-auth/index.ts
@@ -1,8 +1,8 @@
1
- import { c as PaginationConfig } from "./pagination-jSUdrACK.mjs";
2
- import { _ as RepositoryOptions, d as PluginType } from "./repository-H_ffGgpE.mjs";
3
- import { T as AuditTrailOptions, _ as RepositoryCachePluginOptions, i as CustomIdOptions, t as MultiTenantOptions } from "./multi-tenant.plugin-BwSvTirB.mjs";
4
- import { n as Repository } from "./Repository-BdSkQ8vc.mjs";
5
- import { i as Logger, o as SoftDeleteOptions } from "./plugin-options-DXnlKM3B.mjs";
1
+ import { u as PaginationConfig } from "./pagination-BpIv2bdS.mjs";
2
+ import { _ as RepositoryOptions, d as PluginType } from "./repository-ZbLtL7Nk.mjs";
3
+ import { T as AuditTrailOptions, _ as RepositoryCachePluginOptions, i as CustomIdOptions, t as MultiTenantOptions } from "./multi-tenant.plugin-B-tzNeYL.mjs";
4
+ import { n as Repository } from "./Repository-IxI983_m.mjs";
5
+ import { i as Logger, o as SoftDeleteOptions } from "./plugin-options-BuvtOSZf.mjs";
6
6
  import { Model } from "mongoose";
7
7
  //#region src/create-repository.d.ts
8
8
  /**
@@ -1,6 +1,6 @@
1
- import { n as Repository } from "./Repository-Ck5x43wF.mjs";
2
- import { a as customIdPlugin, f as auditTrailPlugin, i as multiTenantPlugin, m as auditLogPlugin, n as softDeletePlugin, t as timestampPlugin, u as cachePlugin } from "./timestamp.plugin-CBQukQzV.mjs";
3
- import { n as batchOperationsPlugin, t as methodRegistryPlugin } from "./method-registry.plugin-DblM7V6j.mjs";
1
+ import { n as Repository } from "./Repository-D7fDpyFx.mjs";
2
+ import { a as customIdPlugin, f as auditTrailPlugin, i as multiTenantPlugin, m as auditLogPlugin, n as softDeletePlugin, t as timestampPlugin, u as cachePlugin } from "./timestamp.plugin-B5eiaItQ.mjs";
3
+ import { n as batchOperationsPlugin, t as methodRegistryPlugin } from "./method-registry.plugin-C63pGn1d.mjs";
4
4
  //#region src/create-repository.ts
5
5
  function isLoggerAudit(value) {
6
6
  const v = value;
@@ -1,5 +1,5 @@
1
- import { _ as UpdateOptions, a as CreateOptions, b as LookupOptions, c as FindOneAndUpdateOptions, f as MinMaxResult, g as UpdateManyResult, l as GroupResult, p as OperationOptions, s as DeleteResult } from "./operations-DZodvjC-.mjs";
2
- import { a as PopulateSpec, i as ObjectId, l as SortSpec, o as ReadPreferenceType, s as SelectSpec, t as AnyDocument } from "./core-62oo3N1C.mjs";
1
+ import { _ as UpdateOptions, a as CreateOptions, b as LookupOptions, c as FindOneAndUpdateOptions, f as MinMaxResult, g as UpdateManyResult, l as GroupResult, p as OperationOptions, s as DeleteResult } from "./operations-CrRIoc8Z.mjs";
2
+ import { _ as PopulateSpec, g as ObjectId, p as AnyDocument, v as ReadPreferenceType, x as SortSpec, y as SelectSpec } from "./pagination-BpIv2bdS.mjs";
3
3
  import { p as UpdateWithValidationResult } from "./type-utils-CLzRFtIA.mjs";
4
4
  import { Model, PipelineStage } from "mongoose";
5
5
  declare namespace aggregate_d_exports {
@@ -12,9 +12,18 @@ declare function aggregate<TResult = unknown>(Model: Model<any>, pipeline: Pipel
12
12
  session?: unknown;
13
13
  }): Promise<TResult[]>;
14
14
  /**
15
- * Aggregate with pagination using native MongoDB $facet
16
- * WARNING: $facet results must be <16MB. For larger results (limit >1000),
17
- * consider using Repository.aggregatePaginate() or splitting into separate queries.
15
+ * Aggregate with pagination.
16
+ *
17
+ * Page and count run as TWO concurrent pipelines rather than one `$facet`.
18
+ * `$facet` bundles every returned document plus the count into a SINGLE output
19
+ * document, and no stage may exceed 16MB — so a page of large documents failed
20
+ * with `BSONObjectTooLarge` instead of paginating, and the only defence was a
21
+ * warning above an arbitrary limit of 1000 that told the caller to go
22
+ * elsewhere. `$facet` also cannot use an index for the stages inside it.
23
+ *
24
+ * The trade: two reads, so a concurrent write between them can leave `total`
25
+ * a document out of step with `data` — the same trade `PaginationEngine`
26
+ * already makes on both its offset and aggregate paths.
18
27
  */
19
28
  declare function aggregatePaginate<TDoc = AnyDocument>(Model: Model<TDoc>, pipeline: PipelineStage[], options?: {
20
29
  page?: number;
@@ -91,14 +100,64 @@ declare function minMax(Model: Model<any>, field: string, query?: Record<string,
91
100
  session?: unknown;
92
101
  }): Promise<MinMaxResult>;
93
102
  declare namespace create_d_exports {
94
- export { create, createDefault, createMany, upsert };
103
+ export { CreateManyFailure, CreateManyPartial, CreateManyPartialError, create, createDefault, createMany, isCreateManyPartialError, upsert };
95
104
  }
96
105
  /**
97
106
  * Create single document
98
107
  */
99
108
  declare function create<TDoc = AnyDocument>(Model: Model<TDoc>, data: Record<string, unknown>, options?: CreateOptions): Promise<TDoc>;
100
109
  /**
101
- * Create multiple documents
110
+ * One rejected input, keyed by its position in the array that was passed in.
111
+ *
112
+ * The index is the load-bearing part: it is the only way to tie a failure back
113
+ * to the caller's own record — the driver reports failures positionally, and a
114
+ * rejected document never comes back with an `_id` to match on.
115
+ */
116
+ interface CreateManyFailure {
117
+ /** Position in the ORIGINAL `dataArray`. */
118
+ index: number;
119
+ /** The input that was rejected, as supplied. */
120
+ doc: Record<string, unknown>;
121
+ /** MongoDB error code, e.g. 11000 for a duplicate key. */
122
+ code?: number;
123
+ message: string;
124
+ }
125
+ /**
126
+ * What a partially-successful `createMany` actually did.
127
+ *
128
+ * Attached to the thrown error as `partial`. `createMany` still REJECTS — that
129
+ * is unchanged and deliberate — but the rejection now says which documents
130
+ * landed and which did not, instead of leaving the caller to dig through a
131
+ * driver error to find out.
132
+ */
133
+ interface CreateManyPartial<TDoc = AnyDocument> {
134
+ /** Documents the server accepted. */
135
+ inserted: TDoc[];
136
+ /** Every rejected input, in input order. */
137
+ failed: CreateManyFailure[];
138
+ }
139
+ /** The error `createMany` throws when some documents landed and some did not. */
140
+ type CreateManyPartialError<TDoc = AnyDocument> = Error & {
141
+ partial?: CreateManyPartial<TDoc>;
142
+ };
143
+ /** Narrow a caught error to one carrying a partial-write report. */
144
+ declare function isCreateManyPartialError<TDoc = AnyDocument>(err: unknown): err is CreateManyPartialError<TDoc> & {
145
+ partial: CreateManyPartial<TDoc>;
146
+ };
147
+ /**
148
+ * Create multiple documents.
149
+ *
150
+ * **A rejection does NOT mean nothing was written.** Neither ordering does:
151
+ * `ordered: true` stops at the first failure and keeps everything before it,
152
+ * `ordered: false` keeps everything valid. Measured on a six-document batch
153
+ * with a conflict in the middle — ordered wrote 3, unordered wrote 5. Only a
154
+ * transaction gives all-or-nothing.
155
+ *
156
+ * So the rejection carries a `partial` report naming what landed and what did
157
+ * not, because the alternative is a caller retrying the whole batch and
158
+ * double-writing everything that had already succeeded. Use it to retry only
159
+ * `failed`, or to reconcile — and prefer a unique index or an idempotency key
160
+ * for anything that will be retried automatically.
102
161
  */
103
162
  declare function createMany<TDoc = AnyDocument>(Model: Model<TDoc>, dataArray: Record<string, unknown>[], options?: CreateOptions): Promise<TDoc[]>;
104
163
  /**
@@ -301,4 +360,4 @@ declare namespace index_d_exports {
301
360
  export { aggregate_d_exports as aggregate, create_d_exports as create, delete_d_exports as deleteActions, read_d_exports as read, update_d_exports as update };
302
361
  }
303
362
  //#endregion
304
- export { create_d_exports as a, delete_d_exports as i, update_d_exports as n, aggregate_d_exports as o, read_d_exports as r, index_d_exports as t };
363
+ export { CreateManyFailure as a, create_d_exports as c, delete_d_exports as i, isCreateManyPartialError as l, update_d_exports as n, CreateManyPartial as o, read_d_exports as r, CreateManyPartialError as s, index_d_exports as t, aggregate_d_exports as u };
package/dist/index.d.mts CHANGED
@@ -1,18 +1,17 @@
1
- import { _ as UpdateOptions, a as CreateOptions, b as LookupOptions, c as FindOneAndUpdateOptions, d as LookupPopulateResult, f as MinMaxResult, g as UpdateManyResult, h as SessionOptions, i as ConvenientTransactionOptions, l as GroupResult, m as ReadOptions, n as CacheOperationOptions, p as OperationOptions, r as CacheableOptions, s as DeleteResult, t as AggregateOptions, u as LookupPopulateOptions, v as WithTransactionOptions, y as LookupBuilder } from "./operations-DZodvjC-.mjs";
2
- import { a as PopulateSpec, c as SortDirection, i as ObjectId, l as SortSpec$1, n as AnyModel, o as ReadPreferenceType, s as SelectSpec, t as AnyDocument } from "./core-62oo3N1C.mjs";
3
- import { a as DecodedCursor, c as PaginationConfig, i as CursorPayload, l as ValueType, n as BasePaginationOptions, o as KeysetPaginationOptions, r as CollationOptions, s as OffsetPaginationOptions, t as AggregatePaginationOptions } from "./pagination-jSUdrACK.mjs";
4
- import { t as index_d_exports } from "./index-DKEql4cL.mjs";
1
+ import { _ as UpdateOptions, a as CreateOptions, b as LookupOptions, c as FindOneAndUpdateOptions, d as LookupPopulateResult, f as MinMaxResult, g as UpdateManyResult, h as SessionOptions, i as ConvenientTransactionOptions, l as GroupResult, m as ReadOptions, n as CacheOperationOptions, p as OperationOptions, r as CacheableOptions, s as DeleteResult, t as AggregateOptions, u as LookupPopulateOptions, v as WithTransactionOptions, y as LookupBuilder } from "./operations-CrRIoc8Z.mjs";
2
+ import { _ as PopulateSpec, a as CursorPayload, b as SortDirection, c as MongokitPageExtras, d as ValueType, f as CursorSecret, g as ObjectId, i as CountStrategy, l as OffsetPaginationOptions, m as AnyModel, n as BasePaginationOptions, o as DecodedCursor, p as AnyDocument, r as CollationOptions, s as KeysetPaginationOptions, t as AggregatePaginationOptions, u as PaginationConfig, v as ReadPreferenceType, x as SortSpec$1, y as SelectSpec } from "./pagination-BpIv2bdS.mjs";
3
+ import { a as CreateManyFailure, l as isCreateManyPartialError, o as CreateManyPartial, s as CreateManyPartialError, t as index_d_exports } from "./index-CmjNyulu.mjs";
5
4
  import { a as InferRawDoc, c as NonNullableFields, d as Strict, f as UpdatePatch, i as InferDocument, l as PartialBy, n as DeepPartial, o as KeysOfType, p as UpdateWithValidationResult, r as DocField, s as MongoOperatorUpdate, t as CreateInput, u as RequiredBy } from "./type-utils-CLzRFtIA.mjs";
6
- import { S as RepositoryPluginName, _ as RepositoryOptions, a as HookMode, b as MONGOKIT_PLUGIN_NAMES, c as MinimalRepoView, d as PluginType, f as PrioritizedHook, g as RepositoryOperation, h as RepositoryInstance, i as EventPhase, l as Plugin, m as RepositoryEvent, n as EventHandlers, o as Middleware, p as RepositoryContext, r as EventPayload, s as MiddlewareContext, t as AllPluginMethods, u as PluginFunction, v as UserContext, x as MongoKitPluginName, y as WithPlugins } from "./repository-H_ffGgpE.mjs";
7
- import { A as ensureAuditTrailReady, C as AuditTrailMethods, D as AuditTrailQueryOptions, E as AuditTrailQuery, O as EnsureAuditTrailReadyOptions, S as AuditQueryResult, T as AuditTrailOptions, _ as RepositoryCachePluginOptions, a as DateSequentialIdOptions, b as AuditOperation, c as SequentialIdOptions, d as getNextSequence, f as prefixedId, g as RepositoryCacheHandle, h as CacheOptions, i as CustomIdOptions, k as auditTrailPlugin, l as customIdPlugin, m as CacheAdapter, n as adminBypass, o as IdGenerator, p as sequentialId, r as multiTenantPlugin, s as PrefixedIdOptions, t as MultiTenantOptions, u as dateSequentialId, v as cachePlugin, w as AuditTrailMode, x as AuditQueryOptions, y as AuditEntry } from "./multi-tenant.plugin-BwSvTirB.mjs";
8
- import { t as PaginationEngine } from "./PaginationEngine-CBS1XGzp.mjs";
9
- import { a as AggregationPlan, c as SortOrder, i as AggregationBuilder, l as SortSpec, n as Repository, o as GroupSpec, r as TransitionMachine, s as ProjectionSpec, t as HOOK_PRIORITY, u as VectorSearchOptions } from "./Repository-BdSkQ8vc.mjs";
10
- import { a as SoftDeleteFilterMode, c as ValidationChainOptions, i as Logger, l as ValidatorDefinition, n as CascadeRelation, o as SoftDeleteOptions, r as FieldPreset, s as SoftDeleteRepository, t as CascadeOptions } from "./plugin-options-DXnlKM3B.mjs";
11
- import { n as CreateRepositoryConfig, r as createRepository, t as AuditConfig } from "./create-repository-BU4x9Kb0.mjs";
12
- import { A as IdempotencyStoreMethods, B as auditLogPlugin, C as LeaseMethods, D as ImmutableStatesPluginOptions, E as ImmutableClaimView, F as elasticSearchPlugin, H as appendOnlyPlugin, I as cascadePlugin, L as BatchOperationsMethods, M as idempotencyStorePlugin, N as fieldFilterPlugin, O as immutableStatesPlugin, P as ElasticSearchOptions, R as BulkWriteResult, S as methodRegistryPlugin, T as leasePlugin, U as AggregateHelpersMethods, V as AppendOnlyPluginOptions, W as aggregateHelpersPlugin, _ as OperationMetric, a as requireField, b as mongoOperationsPlugin, c as timestampPlugin, d as createTenantContext, f as SubdocumentMethods, g as ObservabilityOptions, h as softDeletePlugin, i as immutableField, j as IdempotencyStorePluginOptions, k as IdempotencyClaim, l as TenantContext, m as SoftDeleteMethods, n as autoInject, o as uniqueField, p as subdocumentPlugin, r as blockIf, s as validationChainPlugin, t as OperationType, u as TenantStore, v as observabilityPlugin, w as LeasePluginOptions, y as MongoOperationsMethods, z as batchOperationsPlugin } from "./validation-chain.plugin-yQRob3Av.mjs";
5
+ import { S as RepositoryPluginName, _ as RepositoryOptions, a as HookMode, b as MONGOKIT_PLUGIN_NAMES, c as MinimalRepoView, d as PluginType, f as PrioritizedHook, g as RepositoryOperation, h as RepositoryInstance, i as EventPhase, l as Plugin, m as RepositoryEvent, n as EventHandlers, o as Middleware, p as RepositoryContext, r as EventPayload, s as MiddlewareContext, t as AllPluginMethods, u as PluginFunction, v as UserContext, x as MongoKitPluginName, y as WithPlugins } from "./repository-ZbLtL7Nk.mjs";
6
+ import { A as ensureAuditTrailReady, C as AuditTrailMethods, D as AuditTrailQueryOptions, E as AuditTrailQuery, O as EnsureAuditTrailReadyOptions, S as AuditQueryResult, T as AuditTrailOptions, _ as RepositoryCachePluginOptions, a as DateSequentialIdOptions, b as AuditOperation, c as SequentialIdOptions, d as getNextSequence, f as prefixedId, g as RepositoryCacheHandle, h as CacheOptions, i as CustomIdOptions, k as auditTrailPlugin, l as customIdPlugin, m as CacheAdapter, n as adminBypass, o as IdGenerator, p as sequentialId, r as multiTenantPlugin, s as PrefixedIdOptions, t as MultiTenantOptions, u as dateSequentialId, v as cachePlugin, w as AuditTrailMode, x as AuditQueryOptions, y as AuditEntry } from "./multi-tenant.plugin-B-tzNeYL.mjs";
7
+ import { t as PaginationEngine } from "./PaginationEngine-D-P19Y9m.mjs";
8
+ import { a as AggregationPlan, c as SortOrder, i as AggregationBuilder, l as SortSpec, n as Repository, o as GroupSpec, r as TransitionMachine, s as ProjectionSpec, t as HOOK_PRIORITY, u as VectorSearchOptions } from "./Repository-IxI983_m.mjs";
9
+ import { a as SoftDeleteFilterMode, c as ValidationChainOptions, i as Logger, l as ValidatorDefinition, n as CascadeRelation, o as SoftDeleteOptions, r as FieldPreset, s as SoftDeleteRepository, t as CascadeOptions } from "./plugin-options-BuvtOSZf.mjs";
10
+ import { n as CreateRepositoryConfig, r as createRepository, t as AuditConfig } from "./create-repository-CRXjDa3N.mjs";
11
+ import { A as IdempotencyStoreMethods, B as auditLogPlugin, C as LeaseMethods, D as ImmutableStatesPluginOptions, E as ImmutableClaimView, F as elasticSearchPlugin, H as appendOnlyPlugin, I as cascadePlugin, L as BatchOperationsMethods, M as idempotencyStorePlugin, N as fieldFilterPlugin, O as immutableStatesPlugin, P as ElasticSearchOptions, R as BulkWriteResult, S as methodRegistryPlugin, T as leasePlugin, U as AggregateHelpersMethods, V as AppendOnlyPluginOptions, W as aggregateHelpersPlugin, _ as OperationMetric, a as requireField, b as mongoOperationsPlugin, c as timestampPlugin, d as createTenantContext, f as SubdocumentMethods, g as ObservabilityOptions, h as softDeletePlugin, i as immutableField, j as IdempotencyStorePluginOptions, k as IdempotencyClaim, l as TenantContext, m as SoftDeleteMethods, n as autoInject, o as uniqueField, p as subdocumentPlugin, r as blockIf, s as validationChainPlugin, t as OperationType, u as TenantStore, v as observabilityPlugin, w as LeasePluginOptions, y as MongoOperationsMethods, z as batchOperationsPlugin } from "./validation-chain.plugin-DvrLJIbJ.mjs";
13
12
  import { n as SchemaPathsLike, t as FieldType$1 } from "./coercion-BjdPX3YF.mjs";
14
13
  import { n as SchemaIndexes } from "./indexes-DIjMpYES.mjs";
15
- import { S as parseDuplicateKeyError, _ as getMongooseProjection, a as createMemoryCache, b as createError, g as getFieldsForUser, h as filterResponseData, i as buildCrudSchemasFromMongooseSchema, m as createFieldPreset, n as CrudSchemasFramework, o as LoggerConfig, r as buildCrudSchemasFromModel, s as configureLogger, t as toPlain, u as idVariants, v as CreateErrorOptions, x as isDuplicateKeyError, y as ParseDuplicateKeyOptions } from "./to-plain-Dyz_qvuo.mjs";
14
+ import { S as parseDuplicateKeyError, _ as getMongooseProjection, a as createMemoryCache, b as createError, g as getFieldsForUser, h as filterResponseData, i as buildCrudSchemasFromMongooseSchema, m as createFieldPreset, n as CrudSchemasFramework, o as LoggerConfig, r as buildCrudSchemasFromModel, s as configureLogger, t as toPlain, u as idVariants, v as CreateErrorOptions, x as isDuplicateKeyError, y as ParseDuplicateKeyOptions } from "./to-plain-B8ufk3Qz.mjs";
16
15
  import { RepoCapabilities } from "@classytic/repo-core/repository";
17
16
  import { ClientSession, Connection, Model, PipelineStage, Schema } from "mongoose";
18
17
  //#region src/actions/cascade-references.d.ts
@@ -396,6 +395,71 @@ declare const READ_OPERATIONS: readonly RepositoryOperation[];
396
395
  /** Filter ops by their policy injection key. */
397
396
  declare function operationsByPolicyKey(key: PolicyKey): RepositoryOperation[];
398
397
  //#endregion
398
+ //#region src/pagination/defaults.d.ts
399
+ /**
400
+ * The subset of {@link PaginationConfig} that describes a deployment rather
401
+ * than one collection's shape.
402
+ *
403
+ * Deliberately NOT `defaultLimit` / `maxLimit` / `cursorVersion`: those are
404
+ * per-collection judgements (a line-item list and an audit log want different
405
+ * page sizes), and a process-wide override of them would be a surprise rather
406
+ * than a policy. What is here is the scale policy — how a page is walked, and
407
+ * whether the rows behind it are counted — plus the one SECURITY setting that
408
+ * is deployment-wide by nature: a signing key is one key for the process, and a
409
+ * repository that quietly declined to use it would be the hole.
410
+ */
411
+ interface PaginationDefaults {
412
+ /** See {@link PaginationConfig.defaultCountStrategy}. */
413
+ defaultCountStrategy?: CountStrategy;
414
+ /**
415
+ * See {@link PaginationConfig.defaultCountLimit}.
416
+ *
417
+ * Belongs to the deployment for the same reason the strategy does: it is the
418
+ * point past which this business stops caring about an exact row count, which
419
+ * is one answer for the whole process, not per collection.
420
+ */
421
+ defaultCountLimit?: number;
422
+ /**
423
+ * See {@link PaginationConfig.cursorSecret}.
424
+ *
425
+ * The reason this one MUST be reachable here: a kernel builds its own
426
+ * repositories, so without the policy seam a host could sign the cursors it
427
+ * mints itself while every engine-owned list kept issuing unsigned ones — a
428
+ * half-signed deployment, which is an unsigned deployment.
429
+ */
430
+ cursorSecret?: CursorSecret;
431
+ /** See {@link PaginationConfig.defaultMode}. */
432
+ defaultMode?: 'offset' | 'keyset';
433
+ /**
434
+ * See {@link PaginationConfig.maxPage}.
435
+ *
436
+ * The other half of the offset cost: `skip(n)` walks n index entries before
437
+ * returning anything, so an unbounded page number is an unbounded read. A
438
+ * fleet that has moved to keyset can lower this to make the offset path's
439
+ * remaining callers fail loudly instead of quietly costing a scan.
440
+ */
441
+ maxPage?: number;
442
+ }
443
+ /**
444
+ * Set the deployment's pagination policy. Merges into whatever is already set,
445
+ * so two call sites configuring different keys do not clobber each other.
446
+ *
447
+ * Call it at boot, before composing modules. Ordering is not load-bearing —
448
+ * repositories read this at query time, not construction time — but a call
449
+ * made after traffic starts changes behaviour mid-flight, which is rarely what
450
+ * anyone means.
451
+ */
452
+ declare function configurePaginationDefaults(defaults: PaginationDefaults): void;
453
+ /**
454
+ * The current deployment policy. Empty until something configures it.
455
+ *
456
+ * A COPY — `Readonly<T>` is erased at runtime, and handing out the live object
457
+ * would let a caller mutate the policy through a getter that promised not to.
458
+ */
459
+ declare function getPaginationDefaults(): Readonly<PaginationDefaults>;
460
+ /** Back to library defaults. For tests — a global that cannot be reset is a leak between them. */
461
+ declare function resetPaginationDefaults(): void;
462
+ //#endregion
399
463
  //#region src/query/parser/types.d.ts
400
464
  type SortSpec$2 = Record<string, 1 | -1>;
401
465
  type FilterQuery = Record<string, unknown>;
@@ -972,4 +1036,4 @@ declare function createOptionsExtractor<TCtx extends Record<string, unknown>>(fi
972
1036
  */
973
1037
  declare function systemContext(extra?: SessionOptions): SessionOptions;
974
1038
  //#endregion
975
- export { ALL_OPERATIONS, type AggregateHelpersMethods, type AggregateOptions, type AggregatePaginationOptions, AggregationBuilder, type AggregationPlan, type SortOrder as AggregationSortOrder, type SortSpec as AggregationSortSpec, type AllPluginMethods, type AnyDocument, type AnyModel, type AppendOnlyPluginOptions, type AuditConfig, type AuditEntry, type AuditOperation, type AuditQueryOptions, type AuditQueryResult, type AuditTrailMethods, type AuditTrailMode, type AuditTrailOptions, AuditTrailQuery, type AuditTrailQueryOptions, type BasePaginationOptions, type BatchOperationsMethods, type BulkWriteResult, type CacheAdapter, type CacheOperationOptions, type CacheOptions, type CacheableOptions, type CapabilityConnectionLike, type CapabilityProbeOptions, type CapabilityResolution, type CascadeOptions, type CascadePurgeReferencesOptions, type CascadeRelation, type CollationOptions, type CollectionRWLike, type ConvenientTransactionOptions, type CreateErrorOptions, type CreateInput, type CreateOptions, type CreateRepositoryConfig, type CrudSchemasFramework, type CursorPayload, type CustomIdOptions, type DateSequentialIdOptions, type DecodedCursor, type DeepPartial, type DefineModelOptions, type DeleteResult, type DocField, type ElasticSearchOptions, type EnsureAuditTrailReadyOptions, type EventHandlers, type EventPayload, type EventPhase, type ExistingModelPolicy, type FieldPreset, type FieldType, type FilterQuery, type FindOneAndUpdateOptions, type GroupResult, type GroupSpec, HOOK_PRIORITY, type HookMode, type IdGenerator, type IdempotencyClaim, type IdempotencyStoreMethods, type IdempotencyStorePluginOptions, type ImmutableClaimView, type ImmutableStatesPluginOptions, type InferDocument, type InferRawDoc, type KeysOfType, type KeysetPaginationOptions, type LeaseMethods, type LeasePluginOptions, type Logger, type LoggerConfig, LookupBuilder, type LookupOptions, type LookupPopulateOptions, type LookupPopulateResult, MONGOKIT_CAPABILITIES, MONGOKIT_PLUGIN_NAMES, MUTATING_OPERATIONS, type Middleware, type MiddlewareContext, type MinMaxResult, type MinimalRepoView, type ModelBlueprint, ModelCollisionError, type ModelSpec, type MongoKitPluginName, type MongoOperationsMethods, type MongoOperatorUpdate, type MongoRepoCapabilities, type MultiTenantOptions, type NonNullableFields, OP_REGISTRY, type ObjectId, type ObservabilityOptions, type OffsetPaginationOptions, type OperationDescriptor, type OperationMetric, type OperationOptions, type OperationType, type PaginationConfig, PaginationEngine, type ParseDuplicateKeyOptions, type ParsedQuery, type PartialBy, type Plugin, type PluginFunction, type PluginType, type PolicyKey, type PopulateOption, type PopulateSpec, type PrefixedIdOptions, type PrioritizedHook, type ProjectionSpec, type PurgeMode, type PurgeableRepoLike, QueryParser, type QueryParserOptions, type QuerySchema, READ_OPERATIONS, type ReadOptions, type ReadPreferenceType, type ReferencePurgeResult, type ReferenceRelation, Repository, Repository as default, type RepositoryCacheHandle, type RepositoryCachePluginOptions, type RepositoryContext, type RepositoryEvent, type RepositoryInstance, type RepositoryOperation, type RepositoryOptions, type RepositoryPluginName, type RequiredBy, type SchemaLike, type SearchMode, type SelectSpec, type SequentialIdOptions, type SessionOptions, type SessionStarter, type SoftDeleteFilterMode, type SoftDeleteMethods, type SoftDeleteOptions, type SoftDeleteRepository, type SortDirection, type SortSpec$1 as SortSpec, type Strict, type SubdocumentMethods, type TenantContext, type TenantStore, type TransactionSupport, type TransitionMachine, type UpdateManyResult, type UpdateOptions, type UpdatePatch, type UpdateWithValidationResult, type UserContext, type ValidationChainOptions, type ValidatorDefinition, type ValueType, type VectorSearchOptions, type WithPlugins, type WithTransactionOptions, index_d_exports as actions, adminBypass, aggregateHelpersPlugin, appendOnlyPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, batchTransaction, blockIf, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, cachePlugin, capabilitiesForSupport, cascadePlugin, cascadePurgeReferences, classifyHelloReply, compileFilterToMongo, configureLogger, createError, createFieldPreset, createMemoryCache, createOptionsExtractor, createRepository, createTenantContext, customIdPlugin, dateSequentialId, defineModel, defineModels, elasticSearchPlugin, ensureAuditTrailReady, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, idVariants, idempotencyStorePlugin, immutableField, immutableStatesPlugin, isDuplicateKeyError, isModelRegistered, isTransactionUnsupported, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, probeMongoCapabilities, repoOptionsFromCtx, requireField, resetCapabilityProbeCache, resolveMongoCapabilities, resolveTransactionSupport, sequentialId, softDeletePlugin, subdocumentPlugin, supportsTransactions, systemContext, timestampPlugin, toPlain, transactionResolutionOf, uniqueField, validationChainPlugin, withTransaction };
1039
+ export { ALL_OPERATIONS, type AggregateHelpersMethods, type AggregateOptions, type AggregatePaginationOptions, AggregationBuilder, type AggregationPlan, type SortOrder as AggregationSortOrder, type SortSpec as AggregationSortSpec, type AllPluginMethods, type AnyDocument, type AnyModel, type AppendOnlyPluginOptions, type AuditConfig, type AuditEntry, type AuditOperation, type AuditQueryOptions, type AuditQueryResult, type AuditTrailMethods, type AuditTrailMode, type AuditTrailOptions, AuditTrailQuery, type AuditTrailQueryOptions, type BasePaginationOptions, type BatchOperationsMethods, type BulkWriteResult, type CacheAdapter, type CacheOperationOptions, type CacheOptions, type CacheableOptions, type CapabilityConnectionLike, type CapabilityProbeOptions, type CapabilityResolution, type CascadeOptions, type CascadePurgeReferencesOptions, type CascadeRelation, type CollationOptions, type CollectionRWLike, type ConvenientTransactionOptions, type CountStrategy, type CreateErrorOptions, type CreateInput, type CreateManyFailure, type CreateManyPartial, type CreateManyPartialError, type CreateOptions, type CreateRepositoryConfig, type CrudSchemasFramework, type CursorPayload, type CursorSecret, type CustomIdOptions, type DateSequentialIdOptions, type DecodedCursor, type DeepPartial, type DefineModelOptions, type DeleteResult, type DocField, type ElasticSearchOptions, type EnsureAuditTrailReadyOptions, type EventHandlers, type EventPayload, type EventPhase, type ExistingModelPolicy, type FieldPreset, type FieldType, type FilterQuery, type FindOneAndUpdateOptions, type GroupResult, type GroupSpec, HOOK_PRIORITY, type HookMode, type IdGenerator, type IdempotencyClaim, type IdempotencyStoreMethods, type IdempotencyStorePluginOptions, type ImmutableClaimView, type ImmutableStatesPluginOptions, type InferDocument, type InferRawDoc, type KeysOfType, type KeysetPaginationOptions, type LeaseMethods, type LeasePluginOptions, type Logger, type LoggerConfig, LookupBuilder, type LookupOptions, type LookupPopulateOptions, type LookupPopulateResult, MONGOKIT_CAPABILITIES, MONGOKIT_PLUGIN_NAMES, MUTATING_OPERATIONS, type Middleware, type MiddlewareContext, type MinMaxResult, type MinimalRepoView, type ModelBlueprint, ModelCollisionError, type ModelSpec, type MongoKitPluginName, type MongoOperationsMethods, type MongoOperatorUpdate, type MongoRepoCapabilities, type MongokitPageExtras, type MultiTenantOptions, type NonNullableFields, OP_REGISTRY, type ObjectId, type ObservabilityOptions, type OffsetPaginationOptions, type OperationDescriptor, type OperationMetric, type OperationOptions, type OperationType, type PaginationConfig, type PaginationDefaults, PaginationEngine, type ParseDuplicateKeyOptions, type ParsedQuery, type PartialBy, type Plugin, type PluginFunction, type PluginType, type PolicyKey, type PopulateOption, type PopulateSpec, type PrefixedIdOptions, type PrioritizedHook, type ProjectionSpec, type PurgeMode, type PurgeableRepoLike, QueryParser, type QueryParserOptions, type QuerySchema, READ_OPERATIONS, type ReadOptions, type ReadPreferenceType, type ReferencePurgeResult, type ReferenceRelation, Repository, Repository as default, type RepositoryCacheHandle, type RepositoryCachePluginOptions, type RepositoryContext, type RepositoryEvent, type RepositoryInstance, type RepositoryOperation, type RepositoryOptions, type RepositoryPluginName, type RequiredBy, type SchemaLike, type SearchMode, type SelectSpec, type SequentialIdOptions, type SessionOptions, type SessionStarter, type SoftDeleteFilterMode, type SoftDeleteMethods, type SoftDeleteOptions, type SoftDeleteRepository, type SortDirection, type SortSpec$1 as SortSpec, type Strict, type SubdocumentMethods, type TenantContext, type TenantStore, type TransactionSupport, type TransitionMachine, type UpdateManyResult, type UpdateOptions, type UpdatePatch, type UpdateWithValidationResult, type UserContext, type ValidationChainOptions, type ValidatorDefinition, type ValueType, type VectorSearchOptions, type WithPlugins, type WithTransactionOptions, index_d_exports as actions, adminBypass, aggregateHelpersPlugin, appendOnlyPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, batchTransaction, blockIf, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, cachePlugin, capabilitiesForSupport, cascadePlugin, cascadePurgeReferences, classifyHelloReply, compileFilterToMongo, configureLogger, configurePaginationDefaults, createError, createFieldPreset, createMemoryCache, createOptionsExtractor, createRepository, createTenantContext, customIdPlugin, dateSequentialId, defineModel, defineModels, elasticSearchPlugin, ensureAuditTrailReady, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, getPaginationDefaults, idVariants, idempotencyStorePlugin, immutableField, immutableStatesPlugin, isCreateManyPartialError, isDuplicateKeyError, isModelRegistered, isTransactionUnsupported, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, probeMongoCapabilities, repoOptionsFromCtx, requireField, resetCapabilityProbeCache, resetPaginationDefaults, resolveMongoCapabilities, resolveTransactionSupport, sequentialId, softDeletePlugin, subdocumentPlugin, supportsTransactions, systemContext, timestampPlugin, toPlain, transactionResolutionOf, uniqueField, validationChainPlugin, withTransaction };
package/dist/index.mjs CHANGED
@@ -1,16 +1,16 @@
1
1
  import { n as idVariants } from "./id-resolution-BqDrk0S2.mjs";
2
- import { _ as resetCapabilityProbeCache, a as supportsTransactions, b as transactionResolutionOf, c as ALL_OPERATIONS, d as READ_OPERATIONS, f as operationsByPolicyKey, g as probeMongoCapabilities, h as classifyHelloReply, i as isTransactionUnsupported, l as MUTATING_OPERATIONS, m as capabilitiesForSupport, n as Repository, o as withTransaction, p as MONGOKIT_CAPABILITIES, r as batchTransaction, s as AggregationBuilder, t as HOOK_PRIORITY, u as OP_REGISTRY, v as resolveMongoCapabilities, x as createMongoPurgePort, y as resolveTransactionSupport } from "./Repository-Ck5x43wF.mjs";
3
- import { b as LookupBuilder, x as compileFilterToMongo } from "./update-jSXp3nu3.mjs";
2
+ import { _ as resetCapabilityProbeCache, a as supportsTransactions, b as transactionResolutionOf, c as ALL_OPERATIONS, d as READ_OPERATIONS, f as operationsByPolicyKey, g as probeMongoCapabilities, h as classifyHelloReply, i as isTransactionUnsupported, l as MUTATING_OPERATIONS, m as capabilitiesForSupport, n as Repository, o as withTransaction, p as MONGOKIT_CAPABILITIES, r as batchTransaction, s as AggregationBuilder, t as HOOK_PRIORITY, u as OP_REGISTRY, v as resolveMongoCapabilities, x as createMongoPurgePort, y as resolveTransactionSupport } from "./Repository-D7fDpyFx.mjs";
3
+ import { _ as compileFilterToMongo, g as LookupBuilder, x as isCreateManyPartialError } from "./update-c_01A0if.mjs";
4
4
  import { n as warn, t as configureLogger } from "./logger-K7dPmu2U.mjs";
5
5
  import { n as isDuplicateKeyError, r as parseDuplicateKeyError, t as createError } from "./error-BuByZwKU.mjs";
6
6
  import { t as actions_exports } from "./actions/index.mjs";
7
- import { a as customIdPlugin, c as prefixedId, d as AuditTrailQuery, f as auditTrailPlugin, i as multiTenantPlugin, l as sequentialId, m as auditLogPlugin, n as softDeletePlugin, o as dateSequentialId, p as ensureAuditTrailReady, r as adminBypass, s as getNextSequence, t as timestampPlugin, u as cachePlugin } from "./timestamp.plugin-CBQukQzV.mjs";
8
- import { n as batchOperationsPlugin, t as methodRegistryPlugin } from "./method-registry.plugin-DblM7V6j.mjs";
9
- import { t as PaginationEngine } from "./PaginationEngine-BX9o_-4R.mjs";
7
+ import { a as customIdPlugin, c as prefixedId, d as AuditTrailQuery, f as auditTrailPlugin, i as multiTenantPlugin, l as sequentialId, m as auditLogPlugin, n as softDeletePlugin, o as dateSequentialId, p as ensureAuditTrailReady, r as adminBypass, s as getNextSequence, t as timestampPlugin, u as cachePlugin } from "./timestamp.plugin-B5eiaItQ.mjs";
8
+ import { n as batchOperationsPlugin, t as methodRegistryPlugin } from "./method-registry.plugin-C63pGn1d.mjs";
9
+ import { a as getPaginationDefaults, i as configurePaginationDefaults, o as resetPaginationDefaults, t as PaginationEngine } from "./PaginationEngine-DQ7beTCR.mjs";
10
10
  import { isGeoOperator, parseGeoFilter } from "./query/primitives/geo.mjs";
11
- import { t as createRepository } from "./create-repository-B5EulQ31.mjs";
11
+ import { t as createRepository } from "./create-repository-DOe9E_5F.mjs";
12
12
  import { n as defineModel, r as isModelRegistered, t as ModelCollisionError } from "./model-registry-ClKtWiHa.mjs";
13
- import { _ as cascadePlugin, a as uniqueField, c as subdocumentPlugin, d as mongoOperationsPlugin, f as leasePlugin, g as elasticSearchPlugin, h as fieldFilterPlugin, i as requireField, l as observabilityPlugin, m as idempotencyStorePlugin, n as blockIf, o as validationChainPlugin, p as immutableStatesPlugin, r as immutableField, s as createTenantContext, t as autoInject, u as MONGOKIT_PLUGIN_NAMES, v as appendOnlyPlugin, y as aggregateHelpersPlugin } from "./validation-chain.plugin-DhNyxNCw.mjs";
13
+ import { _ as cascadePlugin, a as uniqueField, c as subdocumentPlugin, d as mongoOperationsPlugin, f as leasePlugin, g as elasticSearchPlugin, h as fieldFilterPlugin, i as requireField, l as observabilityPlugin, m as idempotencyStorePlugin, n as blockIf, o as validationChainPlugin, p as immutableStatesPlugin, r as immutableField, s as createTenantContext, t as autoInject, u as MONGOKIT_PLUGIN_NAMES, v as appendOnlyPlugin, y as aggregateHelpersPlugin } from "./validation-chain.plugin-Bju1D1Sn.mjs";
14
14
  import { i as getMongooseProjection, n as filterResponseData, r as getFieldsForUser, t as createFieldPreset } from "./field-selection-FSQFLpsU.mjs";
15
15
  import { buildFieldTypeMap, coerceFieldValue, coerceHeuristic } from "./query/primitives/coercion.mjs";
16
16
  import { extractSchemaIndexes } from "./query/primitives/indexes.mjs";
@@ -1781,4 +1781,4 @@ function systemContext(extra) {
1781
1781
  */
1782
1782
  var src_default = Repository;
1783
1783
  //#endregion
1784
- export { ALL_OPERATIONS, AggregationBuilder, AuditTrailQuery, HOOK_PRIORITY, LookupBuilder, MONGOKIT_CAPABILITIES, MONGOKIT_PLUGIN_NAMES, MUTATING_OPERATIONS, ModelCollisionError, OP_REGISTRY, PaginationEngine, QueryParser, READ_OPERATIONS, Repository, actions_exports as actions, adminBypass, aggregateHelpersPlugin, appendOnlyPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, batchTransaction, blockIf, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, cachePlugin, capabilitiesForSupport, cascadePlugin, cascadePurgeReferences, classifyHelloReply, compileFilterToMongo, configureLogger, createError, createFieldPreset, createMemoryCache, createOptionsExtractor, createRepository, createTenantContext, customIdPlugin, dateSequentialId, src_default as default, defineModel, defineModels, elasticSearchPlugin, ensureAuditTrailReady, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, idVariants, idempotencyStorePlugin, immutableField, immutableStatesPlugin, isDuplicateKeyError, isModelRegistered, isTransactionUnsupported, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, probeMongoCapabilities, repoOptionsFromCtx, requireField, resetCapabilityProbeCache, resolveMongoCapabilities, resolveTransactionSupport, sequentialId, softDeletePlugin, subdocumentPlugin, supportsTransactions, systemContext, timestampPlugin, toPlain, transactionResolutionOf, uniqueField, validationChainPlugin, withTransaction };
1784
+ export { ALL_OPERATIONS, AggregationBuilder, AuditTrailQuery, HOOK_PRIORITY, LookupBuilder, MONGOKIT_CAPABILITIES, MONGOKIT_PLUGIN_NAMES, MUTATING_OPERATIONS, ModelCollisionError, OP_REGISTRY, PaginationEngine, QueryParser, READ_OPERATIONS, Repository, actions_exports as actions, adminBypass, aggregateHelpersPlugin, appendOnlyPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, batchTransaction, blockIf, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, cachePlugin, capabilitiesForSupport, cascadePlugin, cascadePurgeReferences, classifyHelloReply, compileFilterToMongo, configureLogger, configurePaginationDefaults, createError, createFieldPreset, createMemoryCache, createOptionsExtractor, createRepository, createTenantContext, customIdPlugin, dateSequentialId, src_default as default, defineModel, defineModels, elasticSearchPlugin, ensureAuditTrailReady, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, getPaginationDefaults, idVariants, idempotencyStorePlugin, immutableField, immutableStatesPlugin, isCreateManyPartialError, isDuplicateKeyError, isModelRegistered, isTransactionUnsupported, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, probeMongoCapabilities, repoOptionsFromCtx, requireField, resetCapabilityProbeCache, resetPaginationDefaults, resolveMongoCapabilities, resolveTransactionSupport, sequentialId, softDeletePlugin, subdocumentPlugin, supportsTransactions, systemContext, timestampPlugin, toPlain, transactionResolutionOf, uniqueField, validationChainPlugin, withTransaction };