@classytic/mongokit 2.0.0 → 2.1.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 (123) hide show
  1. package/README.md +221 -7
  2. package/dist/actions/index.cjs +479 -0
  3. package/dist/actions/index.cjs.map +1 -0
  4. package/dist/actions/index.d.cts +3 -0
  5. package/dist/actions/index.d.ts +3 -0
  6. package/dist/actions/index.js +473 -0
  7. package/dist/actions/index.js.map +1 -0
  8. package/dist/index-BfVJZF-3.d.cts +337 -0
  9. package/dist/index-CgOJ2pqz.d.ts +337 -0
  10. package/dist/index.cjs +2142 -0
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.d.cts +239 -0
  13. package/dist/index.d.ts +239 -0
  14. package/dist/index.js +2108 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/memory-cache-DG2oSSbx.d.ts +142 -0
  17. package/dist/memory-cache-DqfFfKes.d.cts +142 -0
  18. package/dist/pagination/PaginationEngine.cjs +375 -0
  19. package/dist/pagination/PaginationEngine.cjs.map +1 -0
  20. package/dist/pagination/PaginationEngine.d.cts +117 -0
  21. package/dist/pagination/PaginationEngine.d.ts +117 -0
  22. package/dist/pagination/PaginationEngine.js +369 -0
  23. package/dist/pagination/PaginationEngine.js.map +1 -0
  24. package/dist/plugins/index.cjs +874 -0
  25. package/dist/plugins/index.cjs.map +1 -0
  26. package/dist/plugins/index.d.cts +275 -0
  27. package/dist/plugins/index.d.ts +275 -0
  28. package/dist/plugins/index.js +857 -0
  29. package/dist/plugins/index.js.map +1 -0
  30. package/dist/types-Nxhmi1aI.d.cts +510 -0
  31. package/dist/types-Nxhmi1aI.d.ts +510 -0
  32. package/dist/utils/index.cjs +667 -0
  33. package/dist/utils/index.cjs.map +1 -0
  34. package/dist/utils/index.d.cts +189 -0
  35. package/dist/utils/index.d.ts +189 -0
  36. package/dist/utils/index.js +643 -0
  37. package/dist/utils/index.js.map +1 -0
  38. package/package.json +44 -21
  39. package/src/Repository.js +0 -296
  40. package/src/actions/aggregate.js +0 -266
  41. package/src/actions/create.js +0 -59
  42. package/src/actions/delete.js +0 -88
  43. package/src/actions/index.js +0 -11
  44. package/src/actions/read.js +0 -188
  45. package/src/actions/update.js +0 -176
  46. package/src/hooks/lifecycle.js +0 -146
  47. package/src/index.js +0 -71
  48. package/src/pagination/PaginationEngine.js +0 -348
  49. package/src/pagination/utils/cursor.js +0 -119
  50. package/src/pagination/utils/filter.js +0 -42
  51. package/src/pagination/utils/limits.js +0 -82
  52. package/src/pagination/utils/sort.js +0 -101
  53. package/src/plugins/aggregate-helpers.plugin.js +0 -71
  54. package/src/plugins/audit-log.plugin.js +0 -60
  55. package/src/plugins/batch-operations.plugin.js +0 -66
  56. package/src/plugins/field-filter.plugin.js +0 -27
  57. package/src/plugins/index.js +0 -19
  58. package/src/plugins/method-registry.plugin.js +0 -140
  59. package/src/plugins/mongo-operations.plugin.js +0 -317
  60. package/src/plugins/soft-delete.plugin.js +0 -46
  61. package/src/plugins/subdocument.plugin.js +0 -66
  62. package/src/plugins/timestamp.plugin.js +0 -19
  63. package/src/plugins/validation-chain.plugin.js +0 -145
  64. package/src/types.d.ts +0 -87
  65. package/src/utils/error.js +0 -12
  66. package/src/utils/field-selection.js +0 -156
  67. package/src/utils/index.js +0 -12
  68. package/types/Repository.d.ts +0 -95
  69. package/types/Repository.d.ts.map +0 -1
  70. package/types/actions/aggregate.d.ts +0 -112
  71. package/types/actions/aggregate.d.ts.map +0 -1
  72. package/types/actions/create.d.ts +0 -21
  73. package/types/actions/create.d.ts.map +0 -1
  74. package/types/actions/delete.d.ts +0 -37
  75. package/types/actions/delete.d.ts.map +0 -1
  76. package/types/actions/index.d.ts +0 -6
  77. package/types/actions/index.d.ts.map +0 -1
  78. package/types/actions/read.d.ts +0 -135
  79. package/types/actions/read.d.ts.map +0 -1
  80. package/types/actions/update.d.ts +0 -58
  81. package/types/actions/update.d.ts.map +0 -1
  82. package/types/hooks/lifecycle.d.ts +0 -44
  83. package/types/hooks/lifecycle.d.ts.map +0 -1
  84. package/types/index.d.ts +0 -25
  85. package/types/index.d.ts.map +0 -1
  86. package/types/pagination/PaginationEngine.d.ts +0 -386
  87. package/types/pagination/PaginationEngine.d.ts.map +0 -1
  88. package/types/pagination/utils/cursor.d.ts +0 -40
  89. package/types/pagination/utils/cursor.d.ts.map +0 -1
  90. package/types/pagination/utils/filter.d.ts +0 -28
  91. package/types/pagination/utils/filter.d.ts.map +0 -1
  92. package/types/pagination/utils/limits.d.ts +0 -64
  93. package/types/pagination/utils/limits.d.ts.map +0 -1
  94. package/types/pagination/utils/sort.d.ts +0 -41
  95. package/types/pagination/utils/sort.d.ts.map +0 -1
  96. package/types/plugins/aggregate-helpers.plugin.d.ts +0 -6
  97. package/types/plugins/aggregate-helpers.plugin.d.ts.map +0 -1
  98. package/types/plugins/audit-log.plugin.d.ts +0 -6
  99. package/types/plugins/audit-log.plugin.d.ts.map +0 -1
  100. package/types/plugins/batch-operations.plugin.d.ts +0 -6
  101. package/types/plugins/batch-operations.plugin.d.ts.map +0 -1
  102. package/types/plugins/field-filter.plugin.d.ts +0 -6
  103. package/types/plugins/field-filter.plugin.d.ts.map +0 -1
  104. package/types/plugins/index.d.ts +0 -11
  105. package/types/plugins/index.d.ts.map +0 -1
  106. package/types/plugins/method-registry.plugin.d.ts +0 -3
  107. package/types/plugins/method-registry.plugin.d.ts.map +0 -1
  108. package/types/plugins/mongo-operations.plugin.d.ts +0 -4
  109. package/types/plugins/mongo-operations.plugin.d.ts.map +0 -1
  110. package/types/plugins/soft-delete.plugin.d.ts +0 -6
  111. package/types/plugins/soft-delete.plugin.d.ts.map +0 -1
  112. package/types/plugins/subdocument.plugin.d.ts +0 -6
  113. package/types/plugins/subdocument.plugin.d.ts.map +0 -1
  114. package/types/plugins/timestamp.plugin.d.ts +0 -6
  115. package/types/plugins/timestamp.plugin.d.ts.map +0 -1
  116. package/types/plugins/validation-chain.plugin.d.ts +0 -31
  117. package/types/plugins/validation-chain.plugin.d.ts.map +0 -1
  118. package/types/utils/error.d.ts +0 -11
  119. package/types/utils/error.d.ts.map +0 -1
  120. package/types/utils/field-selection.d.ts +0 -9
  121. package/types/utils/field-selection.d.ts.map +0 -1
  122. package/types/utils/index.d.ts +0 -2
  123. package/types/utils/index.d.ts.map +0 -1
@@ -1,386 +0,0 @@
1
- /**
2
- * @typedef {import('mongoose').Model} Model
3
- * @typedef {import('mongoose').PopulateOptions} PopulateOptions
4
- * @typedef {import('mongoose').ClientSession} ClientSession
5
- */
6
- /**
7
- * @typedef {Object} PaginationConfig
8
- * @property {number} [defaultLimit=10] - Default number of documents per page
9
- * @property {number} [maxLimit=100] - Maximum allowed limit
10
- * @property {number} [maxPage=10000] - Maximum allowed page number
11
- * @property {number} [deepPageThreshold=100] - Page number that triggers performance warning
12
- * @property {number} [cursorVersion=1] - Cursor version for forward compatibility
13
- * @property {boolean} [useEstimatedCount=false] - Use estimatedDocumentCount for faster counts on large collections
14
- */
15
- /**
16
- * @typedef {Object} OffsetPaginationOptions
17
- * @property {Record<string, any>} [filters={}] - MongoDB query filters
18
- * @property {Record<string, 1|-1>} [sort] - Sort specification
19
- * @property {number} [page=1] - Page number (1-indexed)
20
- * @property {number} [limit] - Number of documents per page
21
- * @property {string|string[]} [select] - Fields to select
22
- * @property {string|string[]|PopulateOptions|PopulateOptions[]} [populate] - Fields to populate
23
- * @property {boolean} [lean=true] - Return plain JavaScript objects
24
- * @property {ClientSession} [session] - MongoDB session for transactions
25
- */
26
- /**
27
- * @typedef {Object} KeysetPaginationOptions
28
- * @property {Record<string, any>} [filters={}] - MongoDB query filters
29
- * @property {Record<string, 1|-1>} [sort] - Sort specification (required at runtime)
30
- * @property {string} [after] - Cursor token for next page
31
- * @property {number} [limit] - Number of documents per page
32
- * @property {string|string[]} [select] - Fields to select
33
- * @property {string|string[]|PopulateOptions|PopulateOptions[]} [populate] - Fields to populate
34
- * @property {boolean} [lean=true] - Return plain JavaScript objects
35
- * @property {ClientSession} [session] - MongoDB session for transactions
36
- */
37
- /**
38
- * @typedef {Object} AggregatePaginationOptions
39
- * @property {any[]} [pipeline=[]] - Aggregation pipeline stages
40
- * @property {number} [page=1] - Page number (1-indexed)
41
- * @property {number} [limit] - Number of documents per page
42
- * @property {ClientSession} [session] - MongoDB session for transactions
43
- */
44
- /**
45
- * @typedef {Object} OffsetPaginationResult
46
- * @property {'offset'} method - Pagination method used
47
- * @property {any[]} docs - Array of documents
48
- * @property {number} page - Current page number
49
- * @property {number} limit - Documents per page
50
- * @property {number} total - Total document count
51
- * @property {number} pages - Total page count
52
- * @property {boolean} hasNext - Whether next page exists
53
- * @property {boolean} hasPrev - Whether previous page exists
54
- * @property {string} [warning] - Performance warning for deep pagination
55
- */
56
- /**
57
- * @typedef {Object} KeysetPaginationResult
58
- * @property {'keyset'} method - Pagination method used
59
- * @property {any[]} docs - Array of documents
60
- * @property {number} limit - Documents per page
61
- * @property {boolean} hasMore - Whether more documents exist
62
- * @property {string|null} next - Cursor token for next page
63
- */
64
- /**
65
- * @typedef {Object} AggregatePaginationResult
66
- * @property {'aggregate'} method - Pagination method used
67
- * @property {any[]} docs - Array of documents
68
- * @property {number} page - Current page number
69
- * @property {number} limit - Documents per page
70
- * @property {number} total - Total document count
71
- * @property {number} pages - Total page count
72
- * @property {boolean} hasNext - Whether next page exists
73
- * @property {boolean} hasPrev - Whether previous page exists
74
- * @property {string} [warning] - Performance warning for deep pagination
75
- */
76
- /**
77
- * Production-grade pagination engine for MongoDB
78
- * Supports offset, keyset (cursor), and aggregate pagination
79
- *
80
- * @example
81
- * const engine = new PaginationEngine(UserModel, {
82
- * defaultLimit: 20,
83
- * maxLimit: 100,
84
- * useEstimatedCount: true
85
- * });
86
- *
87
- * // Offset pagination
88
- * const page1 = await engine.paginate({ page: 1, limit: 20 });
89
- *
90
- * // Keyset pagination (better for large datasets)
91
- * const stream1 = await engine.stream({ sort: { createdAt: -1 }, limit: 20 });
92
- * const stream2 = await engine.stream({ sort: { createdAt: -1 }, after: stream1.next });
93
- */
94
- export class PaginationEngine {
95
- /**
96
- * Create a new pagination engine
97
- *
98
- * @param {Model} Model - Mongoose model to paginate
99
- * @param {PaginationConfig} [config={}] - Pagination configuration
100
- */
101
- constructor(Model: Model, config?: PaginationConfig);
102
- Model: import("mongoose").Model<any, any, any, any, any, any, any>;
103
- config: {
104
- defaultLimit: number;
105
- maxLimit: number;
106
- maxPage: number;
107
- deepPageThreshold: number;
108
- cursorVersion: number;
109
- useEstimatedCount: boolean;
110
- };
111
- /**
112
- * Offset-based pagination using skip/limit
113
- * Best for small datasets and when users need random page access
114
- * O(n) performance - slower for deep pages
115
- *
116
- * @param {OffsetPaginationOptions} [options={}] - Pagination options
117
- * @returns {Promise<OffsetPaginationResult>} Pagination result with total count
118
- *
119
- * @example
120
- * const result = await engine.paginate({
121
- * filters: { status: 'active' },
122
- * sort: { createdAt: -1 },
123
- * page: 1,
124
- * limit: 20
125
- * });
126
- * console.log(result.docs, result.total, result.hasNext);
127
- */
128
- paginate(options?: OffsetPaginationOptions): Promise<OffsetPaginationResult>;
129
- /**
130
- * Keyset (cursor-based) pagination for high-performance streaming
131
- * Best for large datasets, infinite scroll, real-time feeds
132
- * O(1) performance - consistent speed regardless of position
133
- *
134
- * @param {KeysetPaginationOptions} options - Pagination options (sort is required)
135
- * @returns {Promise<KeysetPaginationResult>} Pagination result with next cursor
136
- *
137
- * @example
138
- * // First page
139
- * const page1 = await engine.stream({
140
- * sort: { createdAt: -1 },
141
- * limit: 20
142
- * });
143
- *
144
- * // Next page using cursor
145
- * const page2 = await engine.stream({
146
- * sort: { createdAt: -1 },
147
- * after: page1.next,
148
- * limit: 20
149
- * });
150
- */
151
- stream(options?: KeysetPaginationOptions): Promise<KeysetPaginationResult>;
152
- /**
153
- * Aggregate pipeline with pagination
154
- * Best for complex queries requiring aggregation stages
155
- * Uses $facet to combine results and count in single query
156
- *
157
- * @param {AggregatePaginationOptions} [options={}] - Aggregation options
158
- * @returns {Promise<AggregatePaginationResult>} Pagination result with total count
159
- *
160
- * @example
161
- * const result = await engine.aggregatePaginate({
162
- * pipeline: [
163
- * { $match: { status: 'active' } },
164
- * { $group: { _id: '$category', count: { $sum: 1 } } },
165
- * { $sort: { count: -1 } }
166
- * ],
167
- * page: 1,
168
- * limit: 20
169
- * });
170
- */
171
- aggregatePaginate(options?: AggregatePaginationOptions): Promise<AggregatePaginationResult>;
172
- }
173
- export type Model = import("mongoose").Model<any, any, any, any, any, any, any>;
174
- export type PopulateOptions = import("mongoose").PopulateOptions;
175
- export type ClientSession = import("mongoose").ClientSession;
176
- export type PaginationConfig = {
177
- /**
178
- * - Default number of documents per page
179
- */
180
- defaultLimit?: number;
181
- /**
182
- * - Maximum allowed limit
183
- */
184
- maxLimit?: number;
185
- /**
186
- * - Maximum allowed page number
187
- */
188
- maxPage?: number;
189
- /**
190
- * - Page number that triggers performance warning
191
- */
192
- deepPageThreshold?: number;
193
- /**
194
- * - Cursor version for forward compatibility
195
- */
196
- cursorVersion?: number;
197
- /**
198
- * - Use estimatedDocumentCount for faster counts on large collections
199
- */
200
- useEstimatedCount?: boolean;
201
- };
202
- export type OffsetPaginationOptions = {
203
- /**
204
- * - MongoDB query filters
205
- */
206
- filters?: Record<string, any>;
207
- /**
208
- * - Sort specification
209
- */
210
- sort?: Record<string, 1 | -1>;
211
- /**
212
- * - Page number (1-indexed)
213
- */
214
- page?: number;
215
- /**
216
- * - Number of documents per page
217
- */
218
- limit?: number;
219
- /**
220
- * - Fields to select
221
- */
222
- select?: string | string[];
223
- /**
224
- * - Fields to populate
225
- */
226
- populate?: string | string[] | PopulateOptions | PopulateOptions[];
227
- /**
228
- * - Return plain JavaScript objects
229
- */
230
- lean?: boolean;
231
- /**
232
- * - MongoDB session for transactions
233
- */
234
- session?: ClientSession;
235
- };
236
- export type KeysetPaginationOptions = {
237
- /**
238
- * - MongoDB query filters
239
- */
240
- filters?: Record<string, any>;
241
- /**
242
- * - Sort specification (required at runtime)
243
- */
244
- sort?: Record<string, 1 | -1>;
245
- /**
246
- * - Cursor token for next page
247
- */
248
- after?: string;
249
- /**
250
- * - Number of documents per page
251
- */
252
- limit?: number;
253
- /**
254
- * - Fields to select
255
- */
256
- select?: string | string[];
257
- /**
258
- * - Fields to populate
259
- */
260
- populate?: string | string[] | PopulateOptions | PopulateOptions[];
261
- /**
262
- * - Return plain JavaScript objects
263
- */
264
- lean?: boolean;
265
- /**
266
- * - MongoDB session for transactions
267
- */
268
- session?: ClientSession;
269
- };
270
- export type AggregatePaginationOptions = {
271
- /**
272
- * - Aggregation pipeline stages
273
- */
274
- pipeline?: any[];
275
- /**
276
- * - Page number (1-indexed)
277
- */
278
- page?: number;
279
- /**
280
- * - Number of documents per page
281
- */
282
- limit?: number;
283
- /**
284
- * - MongoDB session for transactions
285
- */
286
- session?: ClientSession;
287
- };
288
- export type OffsetPaginationResult = {
289
- /**
290
- * - Pagination method used
291
- */
292
- method: "offset";
293
- /**
294
- * - Array of documents
295
- */
296
- docs: any[];
297
- /**
298
- * - Current page number
299
- */
300
- page: number;
301
- /**
302
- * - Documents per page
303
- */
304
- limit: number;
305
- /**
306
- * - Total document count
307
- */
308
- total: number;
309
- /**
310
- * - Total page count
311
- */
312
- pages: number;
313
- /**
314
- * - Whether next page exists
315
- */
316
- hasNext: boolean;
317
- /**
318
- * - Whether previous page exists
319
- */
320
- hasPrev: boolean;
321
- /**
322
- * - Performance warning for deep pagination
323
- */
324
- warning?: string;
325
- };
326
- export type KeysetPaginationResult = {
327
- /**
328
- * - Pagination method used
329
- */
330
- method: "keyset";
331
- /**
332
- * - Array of documents
333
- */
334
- docs: any[];
335
- /**
336
- * - Documents per page
337
- */
338
- limit: number;
339
- /**
340
- * - Whether more documents exist
341
- */
342
- hasMore: boolean;
343
- /**
344
- * - Cursor token for next page
345
- */
346
- next: string | null;
347
- };
348
- export type AggregatePaginationResult = {
349
- /**
350
- * - Pagination method used
351
- */
352
- method: "aggregate";
353
- /**
354
- * - Array of documents
355
- */
356
- docs: any[];
357
- /**
358
- * - Current page number
359
- */
360
- page: number;
361
- /**
362
- * - Documents per page
363
- */
364
- limit: number;
365
- /**
366
- * - Total document count
367
- */
368
- total: number;
369
- /**
370
- * - Total page count
371
- */
372
- pages: number;
373
- /**
374
- * - Whether next page exists
375
- */
376
- hasNext: boolean;
377
- /**
378
- * - Whether previous page exists
379
- */
380
- hasPrev: boolean;
381
- /**
382
- * - Performance warning for deep pagination
383
- */
384
- warning?: string;
385
- };
386
- //# sourceMappingURL=PaginationEngine.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaginationEngine.d.ts","sourceRoot":"","sources":["../../src/pagination/PaginationEngine.js"],"names":[],"mappings":"AAYA;;;;GAIG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH;IACE;;;;;OAKG;IACH,mBAHW,KAAK,WACL,gBAAgB,EAY1B;IATC,mEAAkB;IAClB;;;;;;;MAOC;IAGH;;;;;;;;;;;;;;;;OAgBG;IACH,mBAZW,uBAAuB,GACrB,OAAO,CAAC,sBAAsB,CAAC,CA8D3C;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,iBAjBW,uBAAuB,GACrB,OAAO,CAAC,sBAAsB,CAAC,CAmE3C;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,4BAdW,0BAA0B,GACxB,OAAO,CAAC,yBAAyB,CAAC,CA+D9C;CACF;;8BA7UY,OAAO,UAAU,EAAE,eAAe;4BAClC,OAAO,UAAU,EAAE,aAAa;;;;;mBAK/B,MAAM;;;;eACN,MAAM;;;;cACN,MAAM;;;;wBACN,MAAM;;;;oBACN,MAAM;;;;wBACN,OAAO;;;;;;cAKP,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;WACnB,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC;;;;WACpB,MAAM;;;;YACN,MAAM;;;;aACN,MAAM,GAAC,MAAM,EAAE;;;;eACf,MAAM,GAAC,MAAM,EAAE,GAAC,eAAe,GAAC,eAAe,EAAE;;;;WACjD,OAAO;;;;cACP,aAAa;;;;;;cAKb,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;WACnB,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC;;;;YACpB,MAAM;;;;YACN,MAAM;;;;aACN,MAAM,GAAC,MAAM,EAAE;;;;eACf,MAAM,GAAC,MAAM,EAAE,GAAC,eAAe,GAAC,eAAe,EAAE;;;;WACjD,OAAO;;;;cACP,aAAa;;;;;;eAKb,GAAG,EAAE;;;;WACL,MAAM;;;;YACN,MAAM;;;;cACN,aAAa;;;;;;YAKb,QAAQ;;;;UACR,GAAG,EAAE;;;;UACL,MAAM;;;;WACN,MAAM;;;;WACN,MAAM;;;;WACN,MAAM;;;;aACN,OAAO;;;;aACP,OAAO;;;;cACP,MAAM;;;;;;YAKN,QAAQ;;;;UACR,GAAG,EAAE;;;;WACL,MAAM;;;;aACN,OAAO;;;;UACP,MAAM,GAAC,IAAI;;;;;;YAKX,WAAW;;;;UACX,GAAG,EAAE;;;;UACL,MAAM;;;;WACN,MAAM;;;;WACN,MAAM;;;;WACN,MAAM;;;;aACN,OAAO;;;;aACP,OAAO;;;;cACP,MAAM"}
@@ -1,40 +0,0 @@
1
- /**
2
- * Encodes document values and sort metadata into a base64 cursor token
3
- *
4
- * @param {any} doc - Document to extract cursor values from
5
- * @param {string} primaryField - Primary sort field name
6
- * @param {Record<string, 1|-1>} sort - Normalized sort specification
7
- * @param {number} [version=1] - Cursor version for forward compatibility
8
- * @returns {string} Base64-encoded cursor token
9
- */
10
- export function encodeCursor(doc: any, primaryField: string, sort: Record<string, 1 | -1>, version?: number): string;
11
- /**
12
- * Decodes a cursor token back into document values and sort metadata
13
- *
14
- * @param {string} token - Base64-encoded cursor token
15
- * @returns {{value: any, id: any, sort: Record<string, 1|-1>, version: number}} Decoded cursor data
16
- * @throws {Error} If token is invalid or malformed
17
- */
18
- export function decodeCursor(token: string): {
19
- value: any;
20
- id: any;
21
- sort: Record<string, 1 | -1>;
22
- version: number;
23
- };
24
- /**
25
- * Validates that cursor sort matches current query sort
26
- *
27
- * @param {Record<string, 1|-1>} cursorSort - Sort specification from cursor
28
- * @param {Record<string, 1|-1>} currentSort - Sort specification from query
29
- * @throws {Error} If sorts don't match
30
- */
31
- export function validateCursorSort(cursorSort: Record<string, 1 | -1>, currentSort: Record<string, 1 | -1>): void;
32
- /**
33
- * Validates cursor version matches expected version
34
- *
35
- * @param {number} cursorVersion - Version from cursor
36
- * @param {number} expectedVersion - Expected version from config
37
- * @throws {Error} If versions don't match
38
- */
39
- export function validateCursorVersion(cursorVersion: number, expectedVersion: number): void;
40
- //# sourceMappingURL=cursor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../../src/pagination/utils/cursor.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,kCANW,GAAG,gBACH,MAAM,QACN,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,YACpB,MAAM,GACJ,MAAM,CAgBlB;AAED;;;;;;GAMG;AACH,oCAJW,MAAM,GACJ;IAAC,KAAK,EAAE,GAAG,CAAC;IAAC,EAAE,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAiB9E;AAED;;;;;;GAMG;AACH,+CAJW,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,eACpB,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,QAU9B;AAED;;;;;;GAMG;AACH,qDAJW,MAAM,mBACN,MAAM,QAOhB"}
@@ -1,28 +0,0 @@
1
- /**
2
- * Builds MongoDB filter for keyset pagination
3
- * Creates compound $or condition for proper cursor-based filtering
4
- *
5
- * @param {Record<string, any>} baseFilters - Existing query filters
6
- * @param {Record<string, 1|-1>} sort - Normalized sort specification
7
- * @param {any} cursorValue - Primary field value from cursor
8
- * @param {any} cursorId - _id value from cursor
9
- * @returns {Record<string, any>} MongoDB filter with keyset condition
10
- *
11
- * @example
12
- * buildKeysetFilter(
13
- * { status: 'active' },
14
- * { createdAt: -1, _id: -1 },
15
- * new Date('2024-01-01'),
16
- * new ObjectId('...')
17
- * )
18
- * // Returns:
19
- * // {
20
- * // status: 'active',
21
- * // $or: [
22
- * // { createdAt: { $lt: Date('2024-01-01') } },
23
- * // { createdAt: Date('2024-01-01'), _id: { $lt: ObjectId('...') } }
24
- * // ]
25
- * // }
26
- */
27
- export function buildKeysetFilter(baseFilters: Record<string, any>, sort: Record<string, 1 | -1>, cursorValue: any, cursorId: any): Record<string, any>;
28
- //# sourceMappingURL=filter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/pagination/utils/filter.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,+CAtBW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QACnB,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,eACpB,GAAG,YACH,GAAG,GACD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAiC/B"}
@@ -1,64 +0,0 @@
1
- /**
2
- * @typedef {Object} PaginationConfig
3
- * @property {number} defaultLimit - Default limit value
4
- * @property {number} maxLimit - Maximum allowed limit
5
- * @property {number} maxPage - Maximum allowed page number
6
- */
7
- /**
8
- * Validates and sanitizes limit value
9
- * Parses strings to numbers and prevents NaN bugs
10
- *
11
- * @param {number|string} limit - Requested limit
12
- * @param {PaginationConfig} config - Pagination configuration
13
- * @returns {number} Sanitized limit between 1 and maxLimit
14
- */
15
- export function validateLimit(limit: number | string, config: PaginationConfig): number;
16
- /**
17
- * Validates and sanitizes page number
18
- * Parses strings to numbers and prevents NaN bugs
19
- *
20
- * @param {number|string} page - Requested page (1-indexed)
21
- * @param {PaginationConfig} config - Pagination configuration
22
- * @returns {number} Sanitized page number >= 1
23
- * @throws {Error} If page exceeds maxPage
24
- */
25
- export function validatePage(page: number | string, config: PaginationConfig): number;
26
- /**
27
- * Checks if page number should trigger deep pagination warning
28
- *
29
- * @param {number} page - Current page number
30
- * @param {number} threshold - Warning threshold
31
- * @returns {boolean} True if warning should be shown
32
- */
33
- export function shouldWarnDeepPagination(page: number, threshold: number): boolean;
34
- /**
35
- * Calculates number of documents to skip for offset pagination
36
- *
37
- * @param {number} page - Page number (1-indexed)
38
- * @param {number} limit - Documents per page
39
- * @returns {number} Number of documents to skip
40
- */
41
- export function calculateSkip(page: number, limit: number): number;
42
- /**
43
- * Calculates total number of pages
44
- *
45
- * @param {number} total - Total document count
46
- * @param {number} limit - Documents per page
47
- * @returns {number} Total number of pages
48
- */
49
- export function calculateTotalPages(total: number, limit: number): number;
50
- export type PaginationConfig = {
51
- /**
52
- * - Default limit value
53
- */
54
- defaultLimit: number;
55
- /**
56
- * - Maximum allowed limit
57
- */
58
- maxLimit: number;
59
- /**
60
- * - Maximum allowed page number
61
- */
62
- maxPage: number;
63
- };
64
- //# sourceMappingURL=limits.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../../src/pagination/utils/limits.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,qCAJW,MAAM,GAAC,MAAM,UACb,gBAAgB,GACd,MAAM,CAUlB;AAED;;;;;;;;GAQG;AACH,mCALW,MAAM,GAAC,MAAM,UACb,gBAAgB,GACd,MAAM,CAiBlB;AAED;;;;;;GAMG;AACH,+CAJW,MAAM,aACN,MAAM,GACJ,OAAO,CAInB;AAED;;;;;;GAMG;AACH,oCAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;GAMG;AACH,2CAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAIlB;;;;;kBA/Ea,MAAM;;;;cACN,MAAM;;;;aACN,MAAM"}
@@ -1,41 +0,0 @@
1
- /**
2
- * Normalizes sort object to ensure stable key order
3
- * Primary fields first, _id last (not alphabetical)
4
- *
5
- * @param {Record<string, 1|-1>} sort - Sort specification
6
- * @returns {Record<string, 1|-1>} Normalized sort with stable key order
7
- */
8
- export function normalizeSort(sort: Record<string, 1 | -1>): Record<string, 1 | -1>;
9
- /**
10
- * Validates and normalizes sort for keyset pagination
11
- * Auto-adds _id tie-breaker if needed
12
- * Ensures _id direction matches primary field
13
- *
14
- * @param {Record<string, 1|-1>} sort - Sort specification
15
- * @returns {Record<string, 1|-1>} Validated and normalized sort
16
- * @throws {Error} If sort is invalid for keyset pagination
17
- */
18
- export function validateKeysetSort(sort: Record<string, 1 | -1>): Record<string, 1 | -1>;
19
- /**
20
- * Inverts sort directions (1 becomes -1, -1 becomes 1)
21
- *
22
- * @param {Record<string, 1|-1>} sort - Sort specification
23
- * @returns {Record<string, 1|-1>} Inverted sort
24
- */
25
- export function invertSort(sort: Record<string, 1 | -1>): Record<string, 1 | -1>;
26
- /**
27
- * Extracts primary sort field (first non-_id field)
28
- *
29
- * @param {Record<string, 1|-1>} sort - Sort specification
30
- * @returns {string} Primary field name
31
- */
32
- export function getPrimaryField(sort: Record<string, 1 | -1>): string;
33
- /**
34
- * Gets sort direction for a specific field
35
- *
36
- * @param {Record<string, 1|-1>} sort - Sort specification
37
- * @param {string} field - Field name
38
- * @returns {1|-1|undefined} Sort direction
39
- */
40
- export function getDirection(sort: Record<string, 1 | -1>, field: string): 1 | -1 | undefined;
41
- //# sourceMappingURL=sort.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../src/pagination/utils/sort.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oCAHW,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,GAClB,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,CAehC;AAED;;;;;;;;GAQG;AACH,yCAJW,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,GAClB,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,CAiChC;AAED;;;;;GAKG;AACH,iCAHW,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,GAClB,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,CAWhC;AAED;;;;;GAKG;AACH,sCAHW,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,GAClB,MAAM,CAKlB;AAED;;;;;;GAMG;AACH,mCAJW,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC,SACpB,MAAM,GACJ,CAAC,GAAC,CAAC,CAAC,GAAC,SAAS,CAI1B"}
@@ -1,6 +0,0 @@
1
- export function aggregateHelpersPlugin(): {
2
- name: string;
3
- apply(repo: any): void;
4
- };
5
- export default aggregateHelpersPlugin;
6
- //# sourceMappingURL=aggregate-helpers.plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aggregate-helpers.plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/aggregate-helpers.plugin.js"],"names":[],"mappings":"AAKO;;;EA+DL"}
@@ -1,6 +0,0 @@
1
- export function auditLogPlugin(logger: any): {
2
- name: string;
3
- apply(repo: any): void;
4
- };
5
- export default auditLogPlugin;
6
- //# sourceMappingURL=audit-log.plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"audit-log.plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/audit-log.plugin.js"],"names":[],"mappings":"AAAO;;;EAyDL"}
@@ -1,6 +0,0 @@
1
- export function batchOperationsPlugin(): {
2
- name: string;
3
- apply(repo: any): void;
4
- };
5
- export default batchOperationsPlugin;
6
- //# sourceMappingURL=batch-operations.plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"batch-operations.plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/batch-operations.plugin.js"],"names":[],"mappings":"AAKO;;;EA0DL"}
@@ -1,6 +0,0 @@
1
- export function fieldFilterPlugin(fieldPreset: any): {
2
- name: string;
3
- apply(repo: any): void;
4
- };
5
- export default fieldFilterPlugin;
6
- //# sourceMappingURL=field-filter.plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"field-filter.plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/field-filter.plugin.js"],"names":[],"mappings":"AAEO;;;EAsBL"}
@@ -1,11 +0,0 @@
1
- export { fieldFilterPlugin } from "./field-filter.plugin.js";
2
- export { timestampPlugin } from "./timestamp.plugin.js";
3
- export { auditLogPlugin } from "./audit-log.plugin.js";
4
- export { softDeletePlugin } from "./soft-delete.plugin.js";
5
- export { methodRegistryPlugin } from "./method-registry.plugin.js";
6
- export { mongoOperationsPlugin } from "./mongo-operations.plugin.js";
7
- export { batchOperationsPlugin } from "./batch-operations.plugin.js";
8
- export { aggregateHelpersPlugin } from "./aggregate-helpers.plugin.js";
9
- export { subdocumentPlugin } from "./subdocument.plugin.js";
10
- export { validationChainPlugin, blockIf, requireField, autoInject, immutableField, uniqueField } from "./validation-chain.plugin.js";
11
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.js"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- export function methodRegistryPlugin(): any;
2
- export default methodRegistryPlugin;
3
- //# sourceMappingURL=method-registry.plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"method-registry.plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/method-registry.plugin.js"],"names":[],"mappings":"AAkDO,4CAuFL"}
@@ -1,4 +0,0 @@
1
- export function mongoOperationsPlugin(): any;
2
- export default mongoOperationsPlugin;
3
- export type ObjectId = import("../types.js").ObjectId;
4
- //# sourceMappingURL=mongo-operations.plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mongo-operations.plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/mongo-operations.plugin.js"],"names":[],"mappings":"AA0DO,6CAgQL;;uBAzTW,OAAO,aAAa,EAAE,QAAQ"}
@@ -1,6 +0,0 @@
1
- export function softDeletePlugin(options?: {}): {
2
- name: string;
3
- apply(repo: any): void;
4
- };
5
- export default softDeletePlugin;
6
- //# sourceMappingURL=soft-delete.plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"soft-delete.plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/soft-delete.plugin.js"],"names":[],"mappings":"AAAO;;;EA2CL"}