@classytic/mongokit 3.38.1 → 3.40.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 (51) hide show
  1. package/dist/{PaginationEngine-CBS1XGzp.d.mts → PaginationEngine-D-P19Y9m.d.mts} +34 -9
  2. package/dist/PaginationEngine-Dvl8jcRY.mjs +1198 -0
  3. package/dist/{Repository-Ck5x43wF.mjs → Repository-BMgPSkqZ.mjs} +672 -655
  4. package/dist/{Repository-BdSkQ8vc.d.mts → Repository-CR8Y9g2E.d.mts} +106 -34
  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-B5EulQ31.mjs → create-repository-BzBUMvd1.mjs} +3 -3
  13. package/dist/{create-repository-BU4x9Kb0.d.mts → create-repository-CAle1MSU.d.mts} +5 -5
  14. package/dist/idempotency/index.d.mts +23 -0
  15. package/dist/idempotency/index.mjs +134 -0
  16. package/dist/{index-DKEql4cL.d.mts → index-CmjNyulu.d.mts} +67 -8
  17. package/dist/index.d.mts +125 -35
  18. package/dist/index.mjs +286 -676
  19. package/dist/indexes/verify-indexes.d.mts +14 -1
  20. package/dist/indexes/verify-indexes.mjs +54 -7
  21. package/dist/{method-registry.plugin-DblM7V6j.mjs → method-registry.plugin-C63pGn1d.mjs} +54 -4
  22. package/dist/{multi-tenant.plugin-BwSvTirB.d.mts → multi-tenant.plugin-CBgCo9im.d.mts} +77 -5
  23. package/dist/{operations-DZodvjC-.d.mts → operations-CrRIoc8Z.d.mts} +22 -7
  24. package/dist/outbox/index.d.mts +1 -1
  25. package/dist/outbox/index.mjs +7 -5
  26. package/dist/pagination/PaginationEngine.d.mts +1 -1
  27. package/dist/pagination/PaginationEngine.mjs +1 -1
  28. package/dist/pagination/utils/limits.d.mts +1 -1
  29. package/dist/pagination/utils/limits.mjs +22 -1
  30. package/dist/pagination-BpIv2bdS.d.mts +364 -0
  31. package/dist/{plugin-options-DXnlKM3B.d.mts → plugin-options-Zk46lD6F.d.mts} +16 -2
  32. package/dist/plugins/index.d.mts +8 -3
  33. package/dist/plugins/index.mjs +99 -26
  34. package/dist/{repository-H_ffGgpE.d.mts → repository-odl03582.d.mts} +50 -6
  35. package/dist/sync/index.d.mts +40 -0
  36. package/dist/sync/index.mjs +334 -0
  37. package/dist/tenant/index.d.mts +89 -0
  38. package/dist/tenant/index.mjs +96 -0
  39. package/dist/testkit/index.d.mts +2 -2
  40. package/dist/testkit/index.mjs +1 -1
  41. package/dist/{timestamp.plugin-CBQukQzV.mjs → timestamp.plugin-DF0gJB6p.mjs} +116 -9
  42. package/dist/{to-plain-Dyz_qvuo.d.mts → to-plain-k7SjNlSS.d.mts} +2 -2
  43. package/dist/transaction-B5L9glO0.mjs +533 -0
  44. package/dist/{update-jSXp3nu3.mjs → update-DG0fCwRJ.mjs} +293 -83
  45. package/dist/utils/index.d.mts +1 -1
  46. package/dist/{validation-chain.plugin-DhNyxNCw.mjs → validation-chain.plugin-BLY2gLEk.mjs} +192 -279
  47. package/dist/{validation-chain.plugin-yQRob3Av.d.mts → validation-chain.plugin-DYp9E7K2.d.mts} +26 -20
  48. package/package.json +17 -4
  49. package/dist/PaginationEngine-BX9o_-4R.mjs +0 -735
  50. package/dist/core-62oo3N1C.d.mts +0 -50
  51. package/dist/pagination-jSUdrACK.d.mts +0 -158
@@ -1,6 +1,6 @@
1
- import { a as PopulateSpec, i as ObjectId, l as SortSpec, s as SelectSpec } from "./core-62oo3N1C.mjs";
2
- import { h as RepositoryInstance, l as Plugin, p as RepositoryContext } from "./repository-H_ffGgpE.mjs";
3
- import { c as ValidationChainOptions, i as Logger, l as ValidatorDefinition, o as SoftDeleteOptions, r as FieldPreset, t as CascadeOptions } from "./plugin-options-DXnlKM3B.mjs";
1
+ import { _ as PopulateSpec, g as ObjectId, x as SortSpec, y as SelectSpec } from "./pagination-BpIv2bdS.mjs";
2
+ import { h as RepositoryInstance, l as Plugin, p as RepositoryContext } from "./repository-odl03582.mjs";
3
+ import { c as ValidationChainOptions, i as Logger, l as ValidatorDefinition, o as SoftDeleteOptions, r as FieldPreset, t as CascadeOptions } from "./plugin-options-Zk46lD6F.mjs";
4
4
  import { BulkWriteResult } from "@classytic/repo-core/repository";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { OffsetPaginationResult } from "@classytic/repo-core/pagination";
@@ -113,22 +113,19 @@ declare function appendOnlyPlugin(options?: AppendOnlyPluginOptions): Plugin;
113
113
  declare function auditLogPlugin(logger: Logger): Plugin;
114
114
  //#endregion
115
115
  //#region src/plugins/batch-operations.plugin.d.ts
116
- /**
117
- * Batch operations plugin.
118
- *
119
- * @example
120
- * const repo = new Repository(Model, [
121
- * methodRegistryPlugin(),
122
- * batchOperationsPlugin(),
123
- * ]);
124
- *
125
- * // updateMany + deleteMany are primitives on Repository — no plugin needed.
126
- * await repo.updateMany({ status: 'pending' }, { status: 'active' });
127
- * await repo.deleteMany({ status: 'deleted' });
128
- *
129
- * // bulkWrite is what this plugin contributes.
130
- * await repo.bulkWrite([...ops]);
131
- */
116
+ /** Options accepted by `repo.bulkWrite`. Plugin context may ride alongside. */
117
+ interface BulkWriteOptions {
118
+ /** Stop at the first failure. Default `true`, matching the driver. */
119
+ ordered?: boolean;
120
+ session?: unknown;
121
+ writeConcern?: Record<string, unknown>;
122
+ bypassDocumentValidation?: boolean;
123
+ comment?: unknown;
124
+ let?: Record<string, unknown>;
125
+ ignoreUndefined?: boolean;
126
+ /** Plugin context (tenant id, actor, ...) - spread into the op context. */
127
+ [key: string]: unknown;
128
+ }
132
129
  declare function batchOperationsPlugin(): Plugin;
133
130
  interface BatchOperationsMethods {
134
131
  /**
@@ -319,6 +316,12 @@ interface IdempotencyStoreMethods<TProgress = Record<string, unknown>, TResult =
319
316
  error?: string;
320
317
  }): Promise<boolean>;
321
318
  }
319
+ /**
320
+ * @deprecated Use `runIdempotent` from `@classytic/repo-core/idempotency` over
321
+ * `createIdempotencyStore` from `@classytic/mongokit/idempotency` — one claim contract for every
322
+ * layer (body fingerprint, transaction participation, recovery points, `maxAttempts`, ambiguous
323
+ * failures, lapsed-claim sweeps). Removed in mongokit 4.
324
+ */
322
325
  declare function idempotencyStorePlugin(options?: IdempotencyStorePluginOptions): Plugin;
323
326
  //#endregion
324
327
  //#region src/plugins/immutable-states.plugin.d.ts
@@ -786,6 +789,9 @@ interface SoftDeleteMethods<TDoc> {
786
789
  */
787
790
  restore(id: string | ObjectId, options?: {
788
791
  session?: unknown;
792
+ organizationId?: unknown;
793
+ bypassTenant?: boolean;
794
+ [key: string]: unknown;
789
795
  }): Promise<TDoc>;
790
796
  /**
791
797
  * Get paginated list of soft-deleted documents
@@ -958,4 +964,4 @@ declare function immutableField(field: string): ValidatorDefinition;
958
964
  */
959
965
  declare function uniqueField(field: string, errorMessage?: string): ValidatorDefinition;
960
966
  //#endregion
961
- export { IdempotencyStoreMethods as A, auditLogPlugin as B, LeaseMethods as C, ImmutableStatesPluginOptions as D, ImmutableClaimView as E, elasticSearchPlugin as F, appendOnlyPlugin as H, cascadePlugin as I, BatchOperationsMethods as L, idempotencyStorePlugin as M, fieldFilterPlugin as N, immutableStatesPlugin as O, ElasticSearchOptions as P, BulkWriteResult as R, methodRegistryPlugin as S, leasePlugin as T, AggregateHelpersMethods as U, AppendOnlyPluginOptions as V, aggregateHelpersPlugin as W, OperationMetric as _, requireField as a, mongoOperationsPlugin as b, timestampPlugin as c, createTenantContext as d, SubdocumentMethods as f, ObservabilityOptions as g, softDeletePlugin as h, immutableField as i, IdempotencyStorePluginOptions as j, IdempotencyClaim as k, TenantContext as l, SoftDeleteMethods as m, autoInject as n, uniqueField as o, subdocumentPlugin as p, blockIf as r, validationChainPlugin as s, OperationType as t, TenantStore as u, observabilityPlugin as v, LeasePluginOptions as w, MethodRegistryRepository as x, MongoOperationsMethods as y, batchOperationsPlugin as z };
967
+ export { IdempotencyStoreMethods as A, batchOperationsPlugin as B, LeaseMethods as C, ImmutableStatesPluginOptions as D, ImmutableClaimView as E, elasticSearchPlugin as F, aggregateHelpersPlugin as G, AppendOnlyPluginOptions as H, cascadePlugin as I, BatchOperationsMethods as L, idempotencyStorePlugin as M, fieldFilterPlugin as N, immutableStatesPlugin as O, ElasticSearchOptions as P, BulkWriteOptions as R, methodRegistryPlugin as S, leasePlugin as T, appendOnlyPlugin as U, auditLogPlugin as V, AggregateHelpersMethods as W, OperationMetric as _, requireField as a, mongoOperationsPlugin as b, timestampPlugin as c, createTenantContext as d, SubdocumentMethods as f, ObservabilityOptions as g, softDeletePlugin as h, immutableField as i, IdempotencyStorePluginOptions as j, IdempotencyClaim as k, TenantContext as l, SoftDeleteMethods as m, autoInject as n, uniqueField as o, subdocumentPlugin as p, blockIf as r, validationChainPlugin as s, OperationType as t, TenantStore as u, observabilityPlugin as v, LeasePluginOptions as w, MethodRegistryRepository as x, MongoOperationsMethods as y, BulkWriteResult as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/mongokit",
3
- "version": "3.38.1",
3
+ "version": "3.40.0",
4
4
  "description": "Production-grade MongoDB repositories - smart pagination, events, and plugins. Built on @classytic/repo-core.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -48,6 +48,14 @@
48
48
  "types": "./dist/outbox/index.d.mts",
49
49
  "default": "./dist/outbox/index.mjs"
50
50
  },
51
+ "./idempotency": {
52
+ "types": "./dist/idempotency/index.d.mts",
53
+ "default": "./dist/idempotency/index.mjs"
54
+ },
55
+ "./sync": {
56
+ "types": "./dist/sync/index.d.mts",
57
+ "default": "./dist/sync/index.mjs"
58
+ },
51
59
  "./lock": {
52
60
  "types": "./dist/lock/index.d.mts",
53
61
  "default": "./dist/lock/index.mjs"
@@ -72,6 +80,10 @@
72
80
  "types": "./dist/indexes/verify-indexes.d.mts",
73
81
  "default": "./dist/indexes/verify-indexes.mjs"
74
82
  },
83
+ "./tenant": {
84
+ "types": "./dist/tenant/index.d.mts",
85
+ "default": "./dist/tenant/index.mjs"
86
+ },
75
87
  "./testkit": {
76
88
  "types": "./dist/testkit/index.d.mts",
77
89
  "default": "./dist/testkit/index.mjs"
@@ -130,7 +142,7 @@
130
142
  },
131
143
  "homepage": "https://github.com/classytic/mongokit#readme",
132
144
  "peerDependencies": {
133
- "@classytic/repo-core": ">=0.27.0",
145
+ "@classytic/repo-core": ">=0.30.0",
134
146
  "mongodb-memory-server": ">=10.4.3",
135
147
  "mongoose": ">=9.4.1"
136
148
  },
@@ -164,7 +176,8 @@
164
176
  "format": "biome format src/ --write",
165
177
  "check": "biome ci src/ --diagnostic-level=error",
166
178
  "check:dead-code": "knip",
167
- "ci": "npm run check && npm run typecheck && npm run typecheck:tests && npm run build && npm run lint:package && npm run check:dead-code && npm run check:forgotten-exports && npm test",
179
+ "check:peer-skew": "node scripts/check-peer-skew.mjs",
180
+ "ci": "npm run check:peer-skew && npm run check && npm run typecheck && npm run typecheck:tests && npm run build && npm run lint:package && npm run check:dead-code && npm run check:forgotten-exports && npm test",
168
181
  "push": "classytic-push",
169
182
  "prepublishOnly": "npm run ci",
170
183
  "publish:dry": "npm publish --dry-run --access public",
@@ -182,7 +195,7 @@
182
195
  "@better-auth/mongo-adapter": "^1.6.29",
183
196
  "@biomejs/biome": "^2.5.8",
184
197
  "@classytic/dev-tools": "^0.2.0",
185
- "@classytic/repo-core": "^0.27.0",
198
+ "@classytic/repo-core": "^0.30.0",
186
199
  "@types/node": "^26.2.0",
187
200
  "@vitest/coverage-v8": "^4.1.10",
188
201
  "ajv": "^8.20.0",