@classytic/mongokit 3.43.1 → 3.45.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 (92) hide show
  1. package/README.md +18 -3
  2. package/dist/{PaginationEngine-DZnkbSrr.mjs → PaginationEngine-BRlLTQQz.mjs} +13 -27
  3. package/dist/{PaginationEngine-CRHyuUtw.d.mts → PaginationEngine-BWb-c47a.d.mts} +1 -3
  4. package/dist/{Repository-DnL4xk5w.d.mts → Repository-DJuRmBNx.d.mts} +44 -13
  5. package/dist/{Repository-Dj6xqPxJ.mjs → Repository-DheA7oW-.mjs} +330 -112
  6. package/dist/actions/index.d.mts +1 -1
  7. package/dist/actions/index.mjs +2 -2
  8. package/dist/{actions-ChYfkPYP.mjs → actions-DKQx9ToJ.mjs} +3 -4
  9. package/dist/adapter/index.d.mts +6 -10
  10. package/dist/adapter/index.mjs +1 -1
  11. package/dist/{adapter-CkMoMF83.mjs → adapter-Qzgc3ZD_.mjs} +4 -6
  12. package/dist/ai/index.d.mts +21 -8
  13. package/dist/ai/index.mjs +15 -9
  14. package/dist/better-auth/index.d.mts +21 -20
  15. package/dist/better-auth/index.mjs +12 -23
  16. package/dist/{coercion-BjdPX3YF.d.mts → coercion-COp9DRNw.d.mts} +0 -2
  17. package/dist/{create-repository-UjwPWR1z.mjs → create-repository-C9DHHcl7.mjs} +4 -5
  18. package/dist/{create-repository-CJtVdwig.d.mts → create-repository-DG-gwOf0.d.mts} +5 -7
  19. package/dist/{derive-DRBiegRH.mjs → derive-Dxsc31fV.mjs} +3 -6
  20. package/dist/{error-BuByZwKU.mjs → error-DjdmPLWO.mjs} +1 -2
  21. package/dist/{field-selection-FSQFLpsU.mjs → field-selection-DPFaFw9Y.mjs} +1 -2
  22. package/dist/{id-chunks-BmAwsqNk.mjs → id-chunks-DH-RAZWG.mjs} +13 -8
  23. package/dist/{id-resolution-BqDrk0S2.mjs → id-resolution-Cqh49d9J.mjs} +1 -2
  24. package/dist/idempotency/index.d.mts +4 -7
  25. package/dist/idempotency/index.mjs +1 -2
  26. package/dist/{index-SYF8N28D.d.mts → index-5mhQ63_B.d.mts} +3 -4
  27. package/dist/{index-C0AjVqX3.d.mts → index-ehGZLbrd.d.mts} +2 -8
  28. package/dist/index.d.mts +70 -102
  29. package/dist/index.mjs +36 -52
  30. package/dist/indexes/verify-indexes.d.mts +8 -11
  31. package/dist/indexes/verify-indexes.mjs +1 -2
  32. package/dist/{indexes-DIjMpYES.d.mts → indexes-FfyOuhDK.d.mts} +0 -2
  33. package/dist/{join-scope-DSAznE8E.mjs → join-scope-C1gOtZ59.mjs} +2 -3
  34. package/dist/kernel-conformance/index.d.mts +39 -13
  35. package/dist/kernel-conformance/index.mjs +4 -7
  36. package/dist/lock/index.d.mts +134 -7
  37. package/dist/lock/index.mjs +349 -14
  38. package/dist/{logger-K7dPmu2U.mjs → logger-hbWOlj_X.mjs} +1 -2
  39. package/dist/{method-registry.plugin-C63pGn1d.mjs → method-registry.plugin-BeJfQBJV.mjs} +5 -7
  40. package/dist/{model-registry-ClKtWiHa.mjs → model-registry-DrVfJ3Nt.mjs} +1 -2
  41. package/dist/{mongooseToJsonSchema-C3k4ide0.mjs → mongooseToJsonSchema-DMDotz4_.mjs} +2 -3
  42. package/dist/{multi-tenant.plugin-B_q9NUHc.d.mts → multi-tenant.plugin-BTPtCLNK.d.mts} +143 -11
  43. package/dist/{operations-XiFgG5US.d.mts → operations-D6XsHx4e.d.mts} +19 -11
  44. package/dist/outbox/index.d.mts +24 -9
  45. package/dist/outbox/index.mjs +17 -6
  46. package/dist/pagination/PaginationEngine.d.mts +1 -1
  47. package/dist/pagination/PaginationEngine.mjs +1 -1
  48. package/dist/pagination/utils/limits.d.mts +6 -9
  49. package/dist/pagination/utils/limits.mjs +2 -3
  50. package/dist/{pagination-D6psses0.d.mts → pagination-BAM9cA4N.d.mts} +6 -16
  51. package/dist/{plugin-options-Cirmb4Kp.d.mts → plugin-options-DrNGWV5b.d.mts} +2 -4
  52. package/dist/plugins/index.d.mts +6 -7
  53. package/dist/plugins/index.mjs +6 -7
  54. package/dist/query/primitives/coercion.d.mts +1 -1
  55. package/dist/query/primitives/coercion.mjs +2 -3
  56. package/dist/query/primitives/geo.d.mts +11 -14
  57. package/dist/query/primitives/geo.mjs +1 -2
  58. package/dist/query/primitives/indexes.d.mts +1 -1
  59. package/dist/query/primitives/indexes.mjs +1 -2
  60. package/dist/{query-defaults-BxUcSOoF.mjs → query-defaults-DwvWUjZU.mjs} +18 -54
  61. package/dist/read-model/index.d.mts +18 -21
  62. package/dist/read-model/index.mjs +3 -4
  63. package/dist/{repository-MqAP409e.d.mts → repository-B0aFVgP2.d.mts} +25 -29
  64. package/dist/retention-purge-CCd_VXUf.d.mts +38 -0
  65. package/dist/{rolldown-runtime-D7D4PA-g.mjs → rolldown-runtime-D8jQpDG7.mjs} +1 -2
  66. package/dist/search/index.d.mts +1 -1
  67. package/dist/search/index.mjs +1 -1
  68. package/dist/sync/index.d.mts +113 -17
  69. package/dist/sync/index.mjs +421 -65
  70. package/dist/tenant/index.d.mts +8 -11
  71. package/dist/tenant/index.mjs +1 -2
  72. package/dist/testkit/index.d.mts +179 -23
  73. package/dist/testkit/index.mjs +421 -23
  74. package/dist/{timestamp.plugin-DpOWavVI.mjs → timestamp.plugin-B-IJrlYb.mjs} +192 -49
  75. package/dist/{to-plain-vksRrLtc.mjs → to-plain-CEKv_ylg.mjs} +2 -4
  76. package/dist/{to-plain-o5tUY2nV.d.mts → to-plain-Do-8jTKC.d.mts} +2 -16
  77. package/dist/{transaction-DmiB4k2P.mjs → transaction-C6Oj941P.mjs} +18 -19
  78. package/dist/{type-utils-CLzRFtIA.d.mts → type-utils-CKvuewAL.d.mts} +0 -2
  79. package/dist/{update-WgeAUJ_I.mjs → update-CYaJMu6j.mjs} +13 -23
  80. package/dist/usage/index.d.mts +2 -5
  81. package/dist/usage/index.mjs +8 -6
  82. package/dist/utils/index.d.mts +8 -10
  83. package/dist/utils/index.mjs +7 -7
  84. package/dist/{validation-chain.plugin-BAeC5eVT.d.mts → validation-chain.plugin-COYrUdd8.d.mts} +150 -48
  85. package/dist/{validation-chain.plugin-DRApTmkN.mjs → validation-chain.plugin-DJplVJ12.mjs} +210 -55
  86. package/llms.txt +33 -0
  87. package/package.json +29 -25
  88. package/skills/mongokit/SKILL.md +112 -0
  89. package/skills/mongokit/references/pagination-search.md +87 -0
  90. package/skills/mongokit/references/plugins-tenancy.md +103 -0
  91. package/skills/mongokit/references/repository-api.md +83 -0
  92. package/skills/mongokit/references/transactions-outbox.md +103 -0
@@ -1,4 +1,3 @@
1
- //#region src/query/primitives/geo.d.ts
2
1
  /**
3
2
  * Geo query primitives
4
3
  *
@@ -14,21 +13,21 @@
14
13
  * `[nearSphere]`, or `[geoWithin]` operator on a field.
15
14
  */
16
15
  /** Geo operators recognized by the parser */
17
- declare const GEO_OPERATORS: readonly ["near", "nearSphere", "geoWithin", "withinRadius"];
18
- type GeoOperator = (typeof GEO_OPERATORS)[number];
16
+ export declare const GEO_OPERATORS: readonly ['near', 'nearSphere', 'geoWithin', 'withinRadius'];
17
+ export type GeoOperator = (typeof GEO_OPERATORS)[number];
19
18
  /**
20
19
  * True iff `operator` is one of the geo operators we handle.
21
20
  * Used by the operator router in QueryParser to short-circuit before the
22
21
  * generic numeric/string operator handling kicks in.
23
22
  */
24
- declare function isGeoOperator(operator: string): operator is GeoOperator;
23
+ export declare function isGeoOperator(operator: string): operator is GeoOperator;
25
24
  /**
26
25
  * Parse a comma-separated coordinate list into numbers, validating each value
27
26
  * is a finite number. Returns null on any parse failure — callers must treat
28
27
  * null as "drop this filter entirely" rather than substituting defaults
29
28
  * (which would silently widen the query).
30
29
  */
31
- declare function parseCoordinateList(raw: unknown): number[] | null;
30
+ export declare function parseCoordinateList(raw: unknown): number[] | null;
32
31
  /**
33
32
  * Validate a [lng, lat] pair against MongoDB's accepted ranges.
34
33
  * Longitude: [-180, 180]. Latitude: [-90, 90]. Out-of-range coordinates
@@ -36,7 +35,7 @@ declare function parseCoordinateList(raw: unknown): number[] | null;
36
35
  * with `coordinates: [999, 40]` would either error inside Mongo or worse,
37
36
  * silently behave unexpectedly.
38
37
  */
39
- declare function isValidLngLat(lng: number, lat: number): boolean;
38
+ export declare function isValidLngLat(lng: number, lat: number): boolean;
40
39
  /**
41
40
  * Build a `$near` or `$nearSphere` filter for a single field from a coordinate
42
41
  * list. Accepts:
@@ -45,7 +44,7 @@ declare function isValidLngLat(lng: number, lat: number): boolean;
45
44
  *
46
45
  * Returns null on any validation failure (drop the filter).
47
46
  */
48
- declare function buildNearFilter(variant: 'near' | 'nearSphere', coords: number[]): Record<string, unknown> | null;
47
+ export declare function buildNearFilter(variant: 'near' | 'nearSphere', coords: number[]): Record<string, unknown> | null;
49
48
  /**
50
49
  * Build a `$geoWithin: $centerSphere` filter from [lng, lat, radiusMeters].
51
50
  *
@@ -62,14 +61,14 @@ declare function buildNearFilter(variant: 'near' | 'nearSphere', coords: number[
62
61
  * `$centerSphere` takes the radius in radians, so we convert from the
63
62
  * caller-friendly meters using Earth's equatorial radius.
64
63
  */
65
- declare function buildWithinRadiusFilter(coords: number[]): Record<string, unknown> | null;
64
+ export declare function buildWithinRadiusFilter(coords: number[]): Record<string, unknown> | null;
66
65
  /**
67
66
  * Build a `$geoWithin: $box` filter from a 4-element coordinate list:
68
67
  * [minLng, minLat, maxLng, maxLat]
69
68
  *
70
69
  * Returns null on any validation failure (drop the filter).
71
70
  */
72
- declare function buildGeoWithinBoxFilter(coords: number[]): Record<string, unknown> | null;
71
+ export declare function buildGeoWithinBoxFilter(coords: number[]): Record<string, unknown> | null;
73
72
  /**
74
73
  * Rewrite a filter object that contains `$near` / `$nearSphere` into an
75
74
  * equivalent count-compatible filter using `$geoWithin: $centerSphere`.
@@ -91,7 +90,7 @@ declare function buildGeoWithinBoxFilter(coords: number[]): Record<string, unkno
91
90
  * rewritten to a bounded `$centerSphere`; caller should fall back to
92
91
  * `countStrategy: 'none'`)
93
92
  */
94
- declare function rewriteNearForCount(filters: unknown): Record<string, unknown> | null;
93
+ export declare function rewriteNearForCount(filters: unknown): Record<string, unknown> | null;
95
94
  /**
96
95
  * Detect whether a Mongo filter object contains a `$near` or `$nearSphere`
97
96
  * operator on any field at the top level. These are SORT operators in
@@ -104,13 +103,11 @@ declare function rewriteNearForCount(filters: unknown): Record<string, unknown>
104
103
  *
105
104
  * Returns false for falsy / non-object inputs.
106
105
  */
107
- declare function hasNearOperator(filters: unknown): boolean;
106
+ export declare function hasNearOperator(filters: unknown): boolean;
108
107
  /**
109
108
  * High-level entry point: given an operator name and the raw value from the
110
109
  * URL, return the MongoDB filter for that field — or null if the operator is
111
110
  * not a geo operator (caller should fall through to normal handling) or the
112
111
  * value is invalid (caller should drop the filter).
113
112
  */
114
- declare function parseGeoFilter(operator: string, raw: unknown): Record<string, unknown> | null;
115
- //#endregion
116
- export { GEO_OPERATORS, GeoOperator, buildGeoWithinBoxFilter, buildNearFilter, buildWithinRadiusFilter, hasNearOperator, isGeoOperator, isValidLngLat, parseCoordinateList, parseGeoFilter, rewriteNearForCount };
113
+ export declare function parseGeoFilter(operator: string, raw: unknown): Record<string, unknown> | null;
@@ -1,4 +1,4 @@
1
- //#region src/query/primitives/geo.ts
1
+ // src/query/primitives/geo.ts
2
2
  /**
3
3
  * Geo query primitives
4
4
  *
@@ -207,5 +207,4 @@ function parseGeoFilter(operator, raw) {
207
207
  if (operator === "withinRadius") return buildWithinRadiusFilter(coords);
208
208
  return null;
209
209
  }
210
- //#endregion
211
210
  export { GEO_OPERATORS, buildGeoWithinBoxFilter, buildNearFilter, buildWithinRadiusFilter, hasNearOperator, isGeoOperator, isValidLngLat, parseCoordinateList, parseGeoFilter, rewriteNearForCount };
@@ -1,2 +1,2 @@
1
- import { n as SchemaIndexes, r as extractSchemaIndexes, t as IndexableSchema } from "../../indexes-DIjMpYES.mjs";
1
+ import { n as SchemaIndexes, r as extractSchemaIndexes, t as IndexableSchema } from "../../indexes-FfyOuhDK.mjs";
2
2
  export { IndexableSchema, SchemaIndexes, extractSchemaIndexes };
@@ -1,4 +1,4 @@
1
- //#region src/query/primitives/indexes.ts
1
+ // src/query/primitives/indexes.ts
2
2
  const EMPTY = {
3
3
  geoFields: [],
4
4
  textFields: [],
@@ -42,5 +42,4 @@ function extractSchemaIndexes(schema) {
42
42
  other
43
43
  };
44
44
  }
45
- //#endregion
46
45
  export { extractSchemaIndexes };
@@ -1,6 +1,6 @@
1
- import { t as createError } from "./error-BuByZwKU.mjs";
1
+ import { t as createError } from "./error-DjdmPLWO.mjs";
2
2
  import mongoose from "mongoose";
3
- //#region src/repository/query-defaults.ts
3
+ // src/repository/query-defaults.ts
4
4
  /**
5
5
  * Query defaults — the time bound and read/write concerns every repository command carries.
6
6
  *
@@ -9,13 +9,13 @@ import mongoose from "mongoose";
9
9
  * An explicit value always wins (FL1). For an aggregation the aggregate chain is consulted before
10
10
  * the generic query chain, because it is the more specific instruction.
11
11
  *
12
- * The bound travels as per-op CSOT `timeoutMS` (the driver derives the wire `maxTimeMS` from
13
- * it, and a client-level `timeoutMS` cannot override it). It and `comment` go to the commands Mongoose itself bounds with its global `maxTimeMS`
14
- * (find, findOne, countDocuments, distinct, findOneAndUpdate, aggregate:
15
- * lib/query.js:2465,2812,2905,3074,3610; lib/aggregate.js:1106). Writes get `writeConcern`. The
16
- * connection's CSOT `timeoutMS` bounds everything else; {@link assertQueryDefaultsConfigured}
17
- * checks both at boot. Inside a transaction a DEFAULT read/write concern or read preference is
18
- * dropped (the transaction owns them); a per-call one is passed and the driver judges it.
12
+ * The bound travels as the server-side `maxTimeMS` on the command (driver 7.8 made the client-side
13
+ * `timeoutMS` / CSOT a no-op, CVE-2026-119179, so there is no per-op client budget any more). It
14
+ * reaches find, findOne, countDocuments, distinct, findOneAndUpdate, aggregate, insertMany,
15
+ * update/delete and bulkWrite. A single-document `create()` goes through Mongoose `save()`, which
16
+ * forwards no `maxTimeMS`, so it is NOT server-bounded. Writes also get `writeConcern`.
17
+ * {@link assertQueryDefaultsConfigured} checks the deployment bound at boot. Inside a transaction a DEFAULT read/write concern or read
18
+ * preference is dropped (the transaction owns them); a per-call one is passed and the driver judges it.
19
19
  */
20
20
  /** On `globalThis`, for the reason `pagination/defaults.ts` gives: a duplicated install must share it. */
21
21
  const POLICY_SLOT = Symbol.for("classytic.mongokit.queryDefaults");
@@ -60,31 +60,19 @@ function resetQueryDefaults() {
60
60
  };
61
61
  }
62
62
  /**
63
- * Boot check (M7): throws unless the deployment sets a query `maxTimeMS`, and — when a connection
64
- * is passed — unless its client carries a CSOT `timeoutMS`. Returns what it verified.
63
+ * Boot check (M7): throws unless the deployment sets a query `maxTimeMS`. Returns what it verified.
64
+ * A client `timeoutMS` is not checked: the driver (7.8+) drops it from the client options and only
65
+ * logs a process warning, so there is nothing to read; it bounds nothing either way.
65
66
  */
66
- function assertQueryDefaultsConfigured(connection) {
67
+ function assertQueryDefaultsConfigured() {
67
68
  const maxTimeMS = policy().query.maxTimeMS;
68
69
  if (maxTimeMS === void 0) throw createError(500, "[mongokit] no deployment query time bound: call configureQueryDefaults({ maxTimeMS }) at boot", {
69
70
  code: QUERY_DEFAULTS_ERROR_CODES.NOT_CONFIGURED,
70
71
  meta: { missing: "maxTimeMS" }
71
72
  });
72
- if (!connection) return { maxTimeMS };
73
- const timeoutMS = connection.getClient().options.timeoutMS;
74
- if (!(typeof timeoutMS === "number" && timeoutMS > 0)) throw createError(500, "[mongokit] the connection has no CSOT timeoutMS: pass { timeoutMS } to mongoose.connect()", {
75
- code: QUERY_DEFAULTS_ERROR_CODES.NOT_CONFIGURED,
76
- meta: { missing: "timeoutMS" }
77
- });
78
- return {
79
- maxTimeMS,
80
- timeoutMS
81
- };
73
+ return { maxTimeMS };
82
74
  }
83
- const QUERY_DEFAULTS_ERROR_CODES = {
84
- NOT_CONFIGURED: "mongokit.query_defaults.not_configured",
85
- /** A per-call bound inside a transaction that carries its own CSOT budget (the driver forbids both). */
86
- TIMEOUT_IN_TRANSACTION: "mongokit.query_defaults.timeout_in_transaction"
87
- };
75
+ const QUERY_DEFAULTS_ERROR_CODES = { NOT_CONFIGURED: "mongokit.query_defaults.not_configured" };
88
76
  const TX_DEADLINE = Symbol.for("@classytic/mongokit/transaction-deadline");
89
77
  /**
90
78
  * Set (or clear) the transaction budget's deadline (`performance.now()` ms) on a session.
@@ -108,14 +96,6 @@ function inTransaction(session) {
108
96
  const s = session;
109
97
  return typeof s?.inTransaction === "function" && s.inTransaction();
110
98
  }
111
- /**
112
- * A `withTransaction` running under a CSOT budget: the driver refuses any per-op `timeoutMS`
113
- * there (mongodb lib/utils.js:451, `session.explicit && session.timeoutContext != null`).
114
- */
115
- function csotTransaction(session) {
116
- const s = session;
117
- return inTransaction(session) && s?.explicit === true && s.timeoutContext != null;
118
- }
119
99
  /** Resolve the options one command runs with. `repo` is the repository's own defaults. */
120
100
  function resolveQueryOptions(kind, perCall, repo = {}) {
121
101
  const deployment = policy();
@@ -132,7 +112,6 @@ function resolveQueryOptions(kind, perCall, repo = {}) {
132
112
  const budget = tx ? transactionRemaining(perCall.session) : void 0;
133
113
  if (budget !== void 0 && budget <= 0) throw new mongoose.mongo.MongoOperationTimeoutError("Transaction budget exhausted before this operation");
134
114
  if (kind !== "write") {
135
- if (csotTransaction(perCall.session) && perCall.maxTimeMS !== void 0) throw createError(400, "[mongokit] a per-call maxTimeMS cannot be honoured inside a transaction with its own timeoutMS budget; bound the transaction instead", { code: QUERY_DEFAULTS_ERROR_CODES.TIMEOUT_IN_TRANSACTION });
136
115
  const bound = tx ? perCall.maxTimeMS : perCall.maxTimeMS ?? (kind === "aggregate" ? repo.aggregate?.maxTimeMs ?? deployment.aggregate.maxTimeMs : void 0) ?? q.maxTimeMS;
137
116
  const capped = budget === void 0 ? bound : Math.min(bound ?? Number.POSITIVE_INFINITY, budget);
138
117
  if (capped !== void 0) out.maxTimeMS = capped;
@@ -174,35 +153,20 @@ function readPreferenceMode(value) {
174
153
  }
175
154
  /** Apply resolved options to a mongoose Query. */
176
155
  function applyToQuery(query, o) {
177
- if (o.maxTimeMS !== void 0) {
178
- const csot = { timeoutMS: o.maxTimeMS };
179
- query.setOptions(csot);
180
- }
156
+ if (o.maxTimeMS !== void 0) query.maxTimeMS(o.maxTimeMS);
181
157
  if (o.comment !== void 0) query.setOptions({ comment: o.comment });
182
158
  if (o.readPreference !== void 0) query.read(readPreferenceMode(o.readPreference));
183
159
  if (o.readConcern !== void 0) query.readConcern(o.readConcern);
184
160
  if (o.writeConcern !== void 0) query.setOptions({ writeConcern: o.writeConcern });
185
161
  if (o.hint !== void 0) query.hint(o.hint);
186
162
  }
187
- /**
188
- * Make a find cursor's bound apply PER BATCH (CSOT `timeoutMode: 'iteration'`). Only when some
189
- * `timeoutMS` exists (this op's, or the client's): the driver refuses a timeoutMode without one
190
- * (mongodb lib/cursor/abstract_cursor.js:114). In iteration mode the driver enforces the budget
191
- * client-side per batch and sends no wire maxTimeMS.
192
- */
193
- function applyCursorTimeoutMode(query, o, connection) {
194
- const clientTimeout = connection.getClient().options.timeoutMS;
195
- if (o.maxTimeMS === void 0 && clientTimeout === void 0) return;
196
- query.setOptions({ timeoutMode: "iteration" });
197
- }
198
163
  /** Apply resolved options to a mongoose Aggregate. */
199
164
  function applyToAggregate(aggregation, o) {
200
- if (o.maxTimeMS !== void 0) aggregation.option({ timeoutMS: o.maxTimeMS });
165
+ if (o.maxTimeMS !== void 0) aggregation.option({ maxTimeMS: o.maxTimeMS });
201
166
  if (o.comment !== void 0) aggregation.option({ comment: o.comment });
202
167
  if (o.readPreference !== void 0) aggregation.read(readPreferenceMode(o.readPreference));
203
168
  if (o.readConcern !== void 0) aggregation.readConcern(o.readConcern);
204
169
  if (o.allowDiskUse !== void 0) aggregation.allowDiskUse(o.allowDiskUse);
205
170
  if (o.hint !== void 0) aggregation.hint(o.hint);
206
171
  }
207
- //#endregion
208
- export { assertQueryDefaultsConfigured as a, getQueryDefaults as c, setTransactionDeadline as d, applyToQuery as i, resetQueryDefaults as l, applyCursorTimeoutMode as n, configureAggregateDefaults as o, applyToAggregate as r, configureQueryDefaults as s, QUERY_DEFAULTS_ERROR_CODES as t, resolveQueryOptions as u };
172
+ export { configureAggregateDefaults as a, resetQueryDefaults as c, assertQueryDefaultsConfigured as i, resolveQueryOptions as l, applyToAggregate as n, configureQueryDefaults as o, applyToQuery as r, getQueryDefaults as s, QUERY_DEFAULTS_ERROR_CODES as t, setTransactionDeadline as u };
@@ -1,18 +1,17 @@
1
- import { r as Repository } from "../Repository-DnL4xk5w.mjs";
1
+ import { r as Repository } from "../Repository-DJuRmBNx.mjs";
2
2
  import { BulkUpsertResult } from "@classytic/repo-core/repository";
3
- //#region src/read-model/index.d.ts
4
- declare const READ_MODEL_ERROR_CODES: {
5
- readonly MERGE_IN_TRANSACTION: "mongokit.read_model.merge_in_transaction";
6
- readonly ON_NOT_UNIQUE: "mongokit.read_model.on_not_unique";
7
- readonly ON_MISSING_SCOPE: "mongokit.read_model.on_missing_scope";
8
- readonly DEDUPE_NEEDS_TRANSACTION: "mongokit.read_model.dedupe_needs_transaction";
9
- readonly DEDUPE_KEY_MISSING: "mongokit.read_model.dedupe_key_missing";
10
- readonly INCREMENT_FAILED: "mongokit.read_model.increment_failed";
11
- readonly TOO_LARGE: "mongokit.read_model.too_large";
3
+ export declare const READ_MODEL_ERROR_CODES: {
4
+ readonly MERGE_IN_TRANSACTION: 'mongokit.read_model.merge_in_transaction';
5
+ readonly ON_NOT_UNIQUE: 'mongokit.read_model.on_not_unique';
6
+ readonly ON_MISSING_SCOPE: 'mongokit.read_model.on_missing_scope';
7
+ readonly DEDUPE_NEEDS_TRANSACTION: 'mongokit.read_model.dedupe_needs_transaction';
8
+ readonly DEDUPE_KEY_MISSING: 'mongokit.read_model.dedupe_key_missing';
9
+ readonly INCREMENT_FAILED: 'mongokit.read_model.increment_failed';
10
+ readonly TOO_LARGE: 'mongokit.read_model.too_large';
12
11
  };
13
12
  /** Caller scope forwarded to every repository call (tenant, bypass, attribution). */
14
- type ReadModelScope = Record<string, unknown>;
15
- interface IncrementGrain {
13
+ export type ReadModelScope = Record<string, unknown>;
14
+ export interface IncrementGrain {
16
15
  /** The read-model key (without the policy scope, which the repository adds). */
17
16
  key: Record<string, unknown>;
18
17
  inc: Record<string, number>;
@@ -21,12 +20,12 @@ interface IncrementGrain {
21
20
  dedupeKey?: string;
22
21
  }
23
22
  /** Sum grains per key, apply them in one upsert; with a ledger, count each dedupeKey once. */
24
- declare function applyIncrements<TDoc>(target: Repository<TDoc>, grains: readonly IncrementGrain[], options?: ReadModelScope & {
23
+ export declare function applyIncrements<TDoc>(target: Repository<TDoc>, grains: readonly IncrementGrain[], options?: ReadModelScope & {
25
24
  session?: unknown;
26
25
  /** Repository over a collection unique on (scope, `dedupeKey`). */
27
26
  ledger?: Repository<unknown>;
28
27
  }): Promise<BulkUpsertResult>;
29
- interface RebuildOptions {
28
+ export interface RebuildOptions {
30
29
  /** Source stages producing one row per read-model grain (with every `on` field except scope fields). */
31
30
  pipeline: readonly unknown[];
32
31
  /** Fields identifying a grain; must equal a unique index of the target and include its tenant field. */
@@ -37,11 +36,11 @@ interface RebuildOptions {
37
36
  session?: unknown;
38
37
  }
39
38
  /** Rebuild the scope's slice of `target` from `source` with one `$merge`, then drop stale grains. */
40
- declare function rebuildInto<TSrc, TDoc>(source: Repository<TSrc>, target: Repository<TDoc>, options: RebuildOptions): Promise<{
39
+ export declare function rebuildInto<TSrc, TDoc>(source: Repository<TSrc>, target: Repository<TDoc>, options: RebuildOptions): Promise<{
41
40
  rebuildId: string;
42
41
  removed: number;
43
42
  }>;
44
- interface ReconcileOptions {
43
+ export interface ReconcileOptions {
45
44
  pipeline: readonly unknown[];
46
45
  on: readonly string[];
47
46
  /** Fields compared between the recomputed and the stored row. */
@@ -50,7 +49,7 @@ interface ReconcileOptions {
50
49
  /** Refuse past this many rows on either side (both are held in memory). Default 100,000. */
51
50
  maxRows?: number;
52
51
  }
53
- interface DriftRow {
52
+ export interface DriftRow {
54
53
  key: Record<string, unknown>;
55
54
  /** Recomputed measures, `null` when the source produces no such grain. */
56
55
  expected: Record<string, unknown> | null;
@@ -58,9 +57,7 @@ interface DriftRow {
58
57
  actual: Record<string, unknown> | null;
59
58
  }
60
59
  /** Recompute the scope's grains from `source` and report every one that differs in `target`. */
61
- declare function reconcile<TSrc, TDoc>(source: Repository<TSrc>, target: Repository<TDoc>, options: ReconcileOptions): Promise<{
60
+ export declare function reconcile<TSrc, TDoc>(source: Repository<TSrc>, target: Repository<TDoc>, options: ReconcileOptions): Promise<{
62
61
  drift: DriftRow[];
63
62
  compared: number;
64
- }>;
65
- //#endregion
66
- export { DriftRow, IncrementGrain, READ_MODEL_ERROR_CODES, ReadModelScope, RebuildOptions, ReconcileOptions, applyIncrements, rebuildInto, reconcile };
63
+ }>;
@@ -1,7 +1,7 @@
1
- import { t as createError } from "../error-BuByZwKU.mjs";
2
- import { i as scopeForCollection, o as tenantFieldsOf } from "../join-scope-DSAznE8E.mjs";
1
+ import { i as scopeForCollection, o as tenantFieldsOf } from "../join-scope-C1gOtZ59.mjs";
2
+ import { t as createError } from "../error-DjdmPLWO.mjs";
3
3
  import { randomUUID } from "node:crypto";
4
- //#region src/read-model/index.ts
4
+ // src/read-model/index.ts
5
5
  /**
6
6
  * `@classytic/mongokit/read-model` — maintain and verify a derived (read) collection.
7
7
  *
@@ -189,5 +189,4 @@ async function reconcile(source, target, options) {
189
189
  compared: expectedRows.length
190
190
  };
191
191
  }
192
- //#endregion
193
192
  export { READ_MODEL_ERROR_CODES, applyIncrements, rebuildInto, reconcile };
@@ -1,10 +1,9 @@
1
- import { A as ObjectId, D as AnyDocument, F as SortSpec, M as ReadPreferenceType, N as SelectSpec, _ as QueryDefaults, b as WriteConcernSpec, i as CountStrategy, j as PopulateSpec, k as FilterQuery, p as AggregateDefaults, v as ReadConcernLevel } from "./pagination-D6psses0.mjs";
2
- import { r as DocField } from "./type-utils-CLzRFtIA.mjs";
1
+ import { A as ObjectId, D as AnyDocument, F as SortSpec, M as ReadPreferenceType, N as SelectSpec, _ as QueryDefaults, b as WriteConcernSpec, i as CountStrategy, j as PopulateSpec, k as FilterQuery, p as AggregateDefaults, v as ReadConcernLevel } from "./pagination-BAM9cA4N.mjs";
2
+ import { r as DocField } from "./type-utils-CKvuewAL.mjs";
3
3
  import { DistributionConfig, DistributionMissHandler, RepoCapabilities, RepositoryBase } from "@classytic/repo-core/repository";
4
4
  import { Model, PipelineStage } from "mongoose";
5
5
  import { HttpError } from "@classytic/repo-core/errors";
6
6
  import { OffsetPaginationResult } from "@classytic/repo-core/pagination";
7
- //#region src/plugins/names.d.ts
8
7
  /**
9
8
  * Canonical identifiers exposed by mongokit's bundled plugins.
10
9
  *
@@ -13,34 +12,32 @@ import { OffsetPaginationResult } from "@classytic/repo-core/pagination";
13
12
  * The values intentionally preserve the plugins' existing public names.
14
13
  */
15
14
  declare const MONGOKIT_PLUGIN_NAMES: {
16
- readonly aggregateHelpers: "aggregate-helpers";
17
- readonly appendOnly: "appendOnly";
18
- readonly auditLog: "auditLog";
19
- readonly auditTrail: "auditTrail";
20
- readonly batchOperations: "batch-operations";
21
- readonly cache: "cache";
22
- readonly cascade: "cascade";
23
- readonly changeLog: "changeLog";
24
- readonly customId: "custom-id";
25
- readonly elasticSearch: "elastic-search";
26
- readonly fieldFilter: "fieldFilter";
27
- readonly immutableStates: "immutableStates";
28
- readonly lease: "lease";
29
- readonly methodRegistry: "method-registry";
30
- readonly mongoOperations: "mongo-operations";
31
- readonly multiTenant: "multi-tenant";
32
- readonly observability: "observability";
33
- readonly searchKeys: "search-keys";
34
- readonly softDelete: "softDelete";
35
- readonly subdocument: "subdocument";
36
- readonly timestamp: "timestamp";
37
- readonly validationChain: "validation-chain";
15
+ readonly aggregateHelpers: 'aggregate-helpers';
16
+ readonly appendOnly: 'appendOnly';
17
+ readonly auditLog: 'auditLog';
18
+ readonly auditTrail: 'auditTrail';
19
+ readonly batchOperations: 'batch-operations';
20
+ readonly cache: 'cache';
21
+ readonly cascade: 'cascade';
22
+ readonly changeLog: 'changeLog';
23
+ readonly customId: 'custom-id';
24
+ readonly elasticSearch: 'elastic-search';
25
+ readonly fieldFilter: 'fieldFilter';
26
+ readonly immutableStates: 'immutableStates';
27
+ readonly lease: 'lease';
28
+ readonly methodRegistry: 'method-registry';
29
+ readonly mongoOperations: 'mongo-operations';
30
+ readonly multiTenant: 'multi-tenant';
31
+ readonly observability: 'observability';
32
+ readonly searchKeys: 'search-keys';
33
+ readonly softDelete: 'softDelete';
34
+ readonly subdocument: 'subdocument';
35
+ readonly timestamp: 'timestamp';
36
+ readonly validationChain: 'validation-chain';
38
37
  };
39
38
  type MongoKitPluginName = (typeof MONGOKIT_PLUGIN_NAMES)[keyof typeof MONGOKIT_PLUGIN_NAMES];
40
39
  /** Bundled-name autocomplete while remaining open to third-party plugins. */
41
40
  type RepositoryPluginName = MongoKitPluginName | (string & Record<never, never>);
42
- //#endregion
43
- //#region src/types/repository.d.ts
44
41
  /** Hook execution mode */
45
42
  type HookMode = 'sync' | 'async';
46
43
  /**
@@ -533,7 +530,7 @@ type AllPluginMethods<TDoc> = {
533
530
  setMin(id: string | ObjectId, field: DocField<TDoc>, value: unknown, options?: Record<string, unknown>): Promise<TDoc>;
534
531
  setMax(id: string | ObjectId, field: DocField<TDoc>, value: unknown, options?: Record<string, unknown>): Promise<TDoc>;
535
532
  atomicUpdate(id: string | ObjectId, operators: Record<string, Record<string, unknown>>, options?: Record<string, unknown>): Promise<TDoc>;
536
- bulkWrite(operations: Record<string, unknown>[], options?: {
533
+ bulkWrite(operations: readonly Record<string, unknown>[], options?: {
537
534
  session?: unknown;
538
535
  ordered?: boolean;
539
536
  }): Promise<{
@@ -602,5 +599,4 @@ type AllPluginMethods<TDoc> = {
602
599
  * ```
603
600
  */
604
601
  type WithPlugins<TDoc, TRepo extends RepositoryInstance = RepositoryInstance> = TRepo & AllPluginMethods<TDoc>;
605
- //#endregion
606
602
  export { RepositoryPluginName as C, MongoKitPluginName as S, RepositoryOptions as _, HookMode as a, WithPlugins as b, MinimalRepoView as c, PluginType as d, PrioritizedHook as f, RepositoryOperation as g, RepositoryInstance as h, EventPhase as i, Plugin as l, RepositoryEvent as m, EventHandlers as n, Middleware as o, RepositoryContext as p, EventPayload as r, MiddlewareContext as s, AllPluginMethods as t, PluginFunction as u, RepositorySearchMode as v, MONGOKIT_PLUGIN_NAMES as x, UserContext as y };
@@ -0,0 +1,38 @@
1
+ import { p as RepositoryContext } from "./repository-B0aFVgP2.mjs";
2
+ /** Per-call retention purge request (`options.retentionPurge`). */
3
+ interface RetentionPurgeRequest {
4
+ /** Why the rows are removed (e.g. `'retention: 7 years'`). Required, non-blank. */
5
+ reason: string;
6
+ /** Who or what purges (user id, `'job:retention'`). Carried to the audit events. */
7
+ actor?: string | undefined;
8
+ }
9
+ /** Common payload of the per-plugin purge audit events, one per successful delete call. */
10
+ interface RetentionPurgeEvent {
11
+ operation: 'delete' | 'deleteMany';
12
+ reason: string;
13
+ actor: string | undefined;
14
+ /** `delete`: the id. */
15
+ id: unknown;
16
+ /** `deleteMany`: the final filter (after policy hooks such as tenant scope). */
17
+ filter: Record<string, unknown> | undefined;
18
+ /** Rows removed (`delete`: 1 or 0). */
19
+ deletedCount: number;
20
+ /** True when the delete is an `archiveByFilter` chunk the sink acknowledged first. */
21
+ archived: boolean;
22
+ /**
23
+ * The delete's session, when the call ran in one. Write the audit row with it
24
+ * (`{ session: event.session }`) so the delete and its audit commit or abort
25
+ * together. Listeners are awaited and a throwing one fails the purge call.
26
+ */
27
+ session: unknown;
28
+ context: RepositoryContext;
29
+ }
30
+ /** Error codes thrown for a malformed or unauthorized retention purge. */
31
+ declare const RETENTION_PURGE_ERROR_CODES: {
32
+ readonly DISABLED: 'RETENTION_PURGE_DISABLED';
33
+ readonly REASON_REQUIRED: 'RETENTION_PURGE_REASON_REQUIRED';
34
+ readonly INVALID_ACTOR: 'RETENTION_PURGE_INVALID_ACTOR';
35
+ readonly HARD_ONLY: 'RETENTION_PURGE_HARD_ONLY';
36
+ readonly ARCHIVE_UNATTESTED: 'RETENTION_PURGE_ARCHIVE_UNATTESTED';
37
+ };
38
+ export { RetentionPurgeEvent as n, RetentionPurgeRequest as r, RETENTION_PURGE_ERROR_CODES as t };
@@ -1,4 +1,4 @@
1
- //#region \0rolldown/runtime.js
1
+ // \0rolldown/runtime.js
2
2
  var __defProp = Object.defineProperty;
3
3
  var __exportAll = (all, no_symbols) => {
4
4
  let target = {};
@@ -9,5 +9,4 @@ var __exportAll = (all, no_symbols) => {
9
9
  if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
10
  return target;
11
11
  };
12
- //#endregion
13
12
  export { __exportAll as t };
@@ -1,2 +1,2 @@
1
- import { a as prefixSearchFilter, c as SearchMatchRange, d as tokenizeSearchText, f as SEARCH_KEYS_ERROR_CODES, i as buildSearchKeys, l as findSearchMatches, n as MAX_PREFIX_SEARCH_TERMS, o as searchKeysIndex, p as SearchKeysWriteError, r as PrefixSearchFilterOptions, s as searchKeysPath, t as DEFAULT_SEARCH_KEYS_FIELD, u as normalizeSearchText } from "../index-C0AjVqX3.mjs";
1
+ import { a as prefixSearchFilter, c as SearchMatchRange, d as tokenizeSearchText, f as SEARCH_KEYS_ERROR_CODES, i as buildSearchKeys, l as findSearchMatches, n as MAX_PREFIX_SEARCH_TERMS, o as searchKeysIndex, p as SearchKeysWriteError, r as PrefixSearchFilterOptions, s as searchKeysPath, t as DEFAULT_SEARCH_KEYS_FIELD, u as normalizeSearchText } from "../index-ehGZLbrd.mjs";
2
2
  export { DEFAULT_SEARCH_KEYS_FIELD, MAX_PREFIX_SEARCH_TERMS, type PrefixSearchFilterOptions, SEARCH_KEYS_ERROR_CODES, SearchKeysWriteError, type SearchMatchRange, buildSearchKeys, findSearchMatches, normalizeSearchText, prefixSearchFilter, searchKeysIndex, searchKeysPath, tokenizeSearchText };
@@ -1 +1 @@
1
- export { l as DEFAULT_SEARCH_KEYS_FIELD, u as MAX_PREFIX_SEARCH_TERMS, t as SEARCH_KEYS_ERROR_CODES, n as SearchKeysWriteError, d as buildSearchKeys, h as findSearchMatches, g as normalizeSearchText, f as prefixSearchFilter, p as searchKeysIndex, m as searchKeysPath, _ as tokenizeSearchText } from "../derive-DRBiegRH.mjs";
1
+ export { l as DEFAULT_SEARCH_KEYS_FIELD, u as MAX_PREFIX_SEARCH_TERMS, t as SEARCH_KEYS_ERROR_CODES, n as SearchKeysWriteError, d as buildSearchKeys, h as findSearchMatches, g as normalizeSearchText, f as prefixSearchFilter, p as searchKeysIndex, m as searchKeysPath, _ as tokenizeSearchText } from "../derive-Dxsc31fV.mjs";