@classytic/mongokit 3.2.0 → 3.2.2
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.
- package/README.md +470 -193
- package/dist/actions/index.d.mts +9 -0
- package/dist/actions/index.mjs +15 -0
- package/dist/aggregate-BAi4Do-X.mjs +767 -0
- package/dist/aggregate-CCHI7F51.d.mts +269 -0
- package/dist/ai/index.d.mts +125 -0
- package/dist/ai/index.mjs +203 -0
- package/dist/cache-keys-C8Z9B5sw.mjs +204 -0
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/create-BuO6xt0v.mjs +55 -0
- package/dist/custom-id.plugin-B_zIs6gE.mjs +1818 -0
- package/dist/custom-id.plugin-BzZI4gnE.d.mts +893 -0
- package/dist/index.d.mts +1012 -0
- package/dist/index.mjs +1906 -0
- package/dist/limits-DsNeCx4D.mjs +299 -0
- package/dist/logger-D8ily-PP.mjs +51 -0
- package/dist/mongooseToJsonSchema-COdDEkIJ.mjs +317 -0
- package/dist/{mongooseToJsonSchema-CaRF_bCN.d.ts → mongooseToJsonSchema-Wbvjfwkn.d.mts} +16 -89
- package/dist/pagination/PaginationEngine.d.mts +93 -0
- package/dist/pagination/PaginationEngine.mjs +196 -0
- package/dist/plugins/index.d.mts +3 -0
- package/dist/plugins/index.mjs +3 -0
- package/dist/types-D-gploPr.d.mts +1241 -0
- package/dist/utils/{index.d.ts → index.d.mts} +14 -21
- package/dist/utils/index.mjs +5 -0
- package/package.json +21 -21
- package/dist/actions/index.d.ts +0 -3
- package/dist/actions/index.js +0 -5
- package/dist/ai/index.d.ts +0 -175
- package/dist/ai/index.js +0 -206
- package/dist/chunks/chunk-2ZN65ZOP.js +0 -93
- package/dist/chunks/chunk-44KXLGPO.js +0 -388
- package/dist/chunks/chunk-DEVXDBRL.js +0 -1226
- package/dist/chunks/chunk-I7CWNAJB.js +0 -46
- package/dist/chunks/chunk-JWUAVZ3L.js +0 -8
- package/dist/chunks/chunk-UE2IEXZJ.js +0 -306
- package/dist/chunks/chunk-URLJFIR7.js +0 -22
- package/dist/chunks/chunk-VWKIKZYF.js +0 -737
- package/dist/chunks/chunk-WSFCRVEQ.js +0 -7
- package/dist/index-BDn5fSTE.d.ts +0 -516
- package/dist/index.d.ts +0 -1422
- package/dist/index.js +0 -1893
- package/dist/pagination/PaginationEngine.d.ts +0 -117
- package/dist/pagination/PaginationEngine.js +0 -3
- package/dist/plugins/index.d.ts +0 -922
- package/dist/plugins/index.js +0 -6
- package/dist/types-Jni1KgkP.d.ts +0 -780
- package/dist/utils/index.js +0 -5
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { Model } from 'mongoose';
|
|
2
|
-
import { A as AnyDocument, P as PaginationConfig, O as OffsetPaginationOptions, a as OffsetPaginationResult, K as KeysetPaginationOptions, b as KeysetPaginationResult, c as AggregatePaginationOptions, d as AggregatePaginationResult } from '../types-Jni1KgkP.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Pagination Engine
|
|
6
|
-
*
|
|
7
|
-
* Production-grade pagination for MongoDB with support for:
|
|
8
|
-
* - Offset pagination (page-based) - Best for small datasets, random page access
|
|
9
|
-
* - Keyset pagination (cursor-based) - Best for large datasets, infinite scroll
|
|
10
|
-
* - Aggregate pagination - Best for complex queries requiring aggregation
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const engine = new PaginationEngine(UserModel, {
|
|
15
|
-
* defaultLimit: 20,
|
|
16
|
-
* maxLimit: 100,
|
|
17
|
-
* useEstimatedCount: true
|
|
18
|
-
* });
|
|
19
|
-
*
|
|
20
|
-
* // Offset pagination
|
|
21
|
-
* const page1 = await engine.paginate({ page: 1, limit: 20 });
|
|
22
|
-
*
|
|
23
|
-
* // Keyset pagination (better for large datasets)
|
|
24
|
-
* const stream1 = await engine.stream({ sort: { createdAt: -1 }, limit: 20 });
|
|
25
|
-
* const stream2 = await engine.stream({ sort: { createdAt: -1 }, after: stream1.next });
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Internal pagination config with required values
|
|
31
|
-
*/
|
|
32
|
-
interface ResolvedPaginationConfig {
|
|
33
|
-
defaultLimit: number;
|
|
34
|
-
maxLimit: number;
|
|
35
|
-
maxPage: number;
|
|
36
|
-
deepPageThreshold: number;
|
|
37
|
-
cursorVersion: number;
|
|
38
|
-
useEstimatedCount: boolean;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Production-grade pagination engine for MongoDB
|
|
42
|
-
* Supports offset, keyset (cursor), and aggregate pagination
|
|
43
|
-
*/
|
|
44
|
-
declare class PaginationEngine<TDoc = AnyDocument> {
|
|
45
|
-
readonly Model: Model<TDoc>;
|
|
46
|
-
readonly config: ResolvedPaginationConfig;
|
|
47
|
-
/**
|
|
48
|
-
* Create a new pagination engine
|
|
49
|
-
*
|
|
50
|
-
* @param Model - Mongoose model to paginate
|
|
51
|
-
* @param config - Pagination configuration
|
|
52
|
-
*/
|
|
53
|
-
constructor(Model: Model<TDoc, any, any, any>, config?: PaginationConfig);
|
|
54
|
-
/**
|
|
55
|
-
* Offset-based pagination using skip/limit
|
|
56
|
-
* Best for small datasets and when users need random page access
|
|
57
|
-
* O(n) performance - slower for deep pages
|
|
58
|
-
*
|
|
59
|
-
* @param options - Pagination options
|
|
60
|
-
* @returns Pagination result with total count
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* const result = await engine.paginate({
|
|
64
|
-
* filters: { status: 'active' },
|
|
65
|
-
* sort: { createdAt: -1 },
|
|
66
|
-
* page: 1,
|
|
67
|
-
* limit: 20
|
|
68
|
-
* });
|
|
69
|
-
* console.log(result.docs, result.total, result.hasNext);
|
|
70
|
-
*/
|
|
71
|
-
paginate(options?: OffsetPaginationOptions): Promise<OffsetPaginationResult<TDoc>>;
|
|
72
|
-
/**
|
|
73
|
-
* Keyset (cursor-based) pagination for high-performance streaming
|
|
74
|
-
* Best for large datasets, infinite scroll, real-time feeds
|
|
75
|
-
* O(1) performance - consistent speed regardless of position
|
|
76
|
-
*
|
|
77
|
-
* @param options - Pagination options (sort is required)
|
|
78
|
-
* @returns Pagination result with next cursor
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* // First page
|
|
82
|
-
* const page1 = await engine.stream({
|
|
83
|
-
* sort: { createdAt: -1 },
|
|
84
|
-
* limit: 20
|
|
85
|
-
* });
|
|
86
|
-
*
|
|
87
|
-
* // Next page using cursor
|
|
88
|
-
* const page2 = await engine.stream({
|
|
89
|
-
* sort: { createdAt: -1 },
|
|
90
|
-
* after: page1.next,
|
|
91
|
-
* limit: 20
|
|
92
|
-
* });
|
|
93
|
-
*/
|
|
94
|
-
stream(options: KeysetPaginationOptions): Promise<KeysetPaginationResult<TDoc>>;
|
|
95
|
-
/**
|
|
96
|
-
* Aggregate pipeline with pagination
|
|
97
|
-
* Best for complex queries requiring aggregation stages
|
|
98
|
-
* Uses $facet to combine results and count in single query
|
|
99
|
-
*
|
|
100
|
-
* @param options - Aggregation options
|
|
101
|
-
* @returns Pagination result with total count
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* const result = await engine.aggregatePaginate({
|
|
105
|
-
* pipeline: [
|
|
106
|
-
* { $match: { status: 'active' } },
|
|
107
|
-
* { $group: { _id: '$category', count: { $sum: 1 } } },
|
|
108
|
-
* { $sort: { count: -1 } }
|
|
109
|
-
* ],
|
|
110
|
-
* page: 1,
|
|
111
|
-
* limit: 20
|
|
112
|
-
* });
|
|
113
|
-
*/
|
|
114
|
-
aggregatePaginate(options?: AggregatePaginationOptions): Promise<AggregatePaginationResult<TDoc>>;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export { PaginationEngine };
|