@classytic/mongokit 3.3.2 → 3.4.1
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 +137 -7
- package/dist/PaginationEngine-nY04eGUM.mjs +290 -0
- package/dist/actions/index.d.mts +2 -9
- package/dist/actions/index.mjs +3 -5
- package/dist/ai/index.d.mts +1 -1
- package/dist/ai/index.mjs +3 -3
- package/dist/chunk-CfYAbeIz.mjs +13 -0
- package/dist/{limits-s1-d8rWb.mjs → cursor-CHToazHy.mjs} +122 -171
- package/dist/{logger-D8ily-PP.mjs → error-Bpbi_NKo.mjs} +34 -22
- package/dist/{cache-keys-CzFwVnLy.mjs → field-selection-reyDRzXf.mjs} +110 -112
- package/dist/{aggregate-BkOG9qwr.d.mts → index-BuoZIZ15.d.mts} +132 -129
- package/dist/index.d.mts +549 -543
- package/dist/index.mjs +33 -101
- package/dist/{mongooseToJsonSchema-D_i2Am_O.mjs → mongooseToJsonSchema-B6Qyl8BK.mjs} +13 -12
- package/dist/{mongooseToJsonSchema-B6O2ED3n.d.mts → mongooseToJsonSchema-RX9YfJLu.d.mts} +24 -17
- package/dist/pagination/PaginationEngine.d.mts +1 -1
- package/dist/pagination/PaginationEngine.mjs +2 -209
- package/dist/plugins/index.d.mts +1 -2
- package/dist/plugins/index.mjs +2 -3
- package/dist/sort-C-BJEWUZ.mjs +57 -0
- package/dist/{types-pVY0w1Pp.d.mts → types-COINbsdL.d.mts} +57 -27
- package/dist/{aggregate-BClp040M.mjs → update-DGKMmBgG.mjs} +575 -565
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.mjs +4 -5
- package/dist/{custom-id.plugin-BJ3FSnzt.d.mts → validation-chain.plugin-BNoaKDOm.d.mts} +832 -832
- package/dist/{custom-id.plugin-FInXDsUX.mjs → validation-chain.plugin-da3fOo8A.mjs} +2410 -2246
- package/package.json +11 -6
- package/dist/chunk-DQk6qfdC.mjs +0 -18
|
@@ -1,7 +1,95 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ct as LookupOptions, I as ObjectId, K as PopulateSpec, P as MinMaxResult, dt as UpdateWithValidationResult, i as AnyDocument, lt as UpdateManyResult, m as CreateOptions, ot as SortSpec, q as ReadPreferenceType, tt as SelectSpec, ut as UpdateOptions, v as DeleteResult, w as GroupResult, z as OperationOptions } from "./types-COINbsdL.mjs";
|
|
2
2
|
import { ClientSession, Model, PipelineStage } from "mongoose";
|
|
3
3
|
|
|
4
|
-
//#region src/actions/
|
|
4
|
+
//#region src/actions/aggregate.d.ts
|
|
5
|
+
declare namespace aggregate_d_exports {
|
|
6
|
+
export { aggregate, aggregatePaginate, average, countBy, distinct, facet, groupBy, lookup, minMax, sum, unwind };
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Execute aggregation pipeline
|
|
10
|
+
*/
|
|
11
|
+
declare function aggregate<TResult = unknown>(Model: Model<any>, pipeline: PipelineStage[], options?: {
|
|
12
|
+
session?: ClientSession;
|
|
13
|
+
}): Promise<TResult[]>;
|
|
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.
|
|
18
|
+
*/
|
|
19
|
+
declare function aggregatePaginate<TDoc = AnyDocument>(Model: Model<TDoc>, pipeline: PipelineStage[], options?: {
|
|
20
|
+
page?: number;
|
|
21
|
+
limit?: number;
|
|
22
|
+
session?: ClientSession;
|
|
23
|
+
}): Promise<{
|
|
24
|
+
docs: TDoc[];
|
|
25
|
+
total: number;
|
|
26
|
+
page: number;
|
|
27
|
+
limit: number;
|
|
28
|
+
pages: number;
|
|
29
|
+
hasNext: boolean;
|
|
30
|
+
hasPrev: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Group documents by field value
|
|
34
|
+
*/
|
|
35
|
+
declare function groupBy(Model: Model<any>, field: string, options?: {
|
|
36
|
+
limit?: number;
|
|
37
|
+
session?: ClientSession;
|
|
38
|
+
}): Promise<GroupResult[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Count by field values
|
|
41
|
+
*/
|
|
42
|
+
declare function countBy(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
43
|
+
session?: ClientSession;
|
|
44
|
+
}): Promise<GroupResult[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Lookup (join) with another collection
|
|
47
|
+
*
|
|
48
|
+
* MongoDB $lookup has two mutually exclusive forms:
|
|
49
|
+
* 1. Simple form: { from, localField, foreignField, as }
|
|
50
|
+
* 2. Pipeline form: { from, let, pipeline, as }
|
|
51
|
+
*
|
|
52
|
+
* This function automatically selects the appropriate form based on parameters.
|
|
53
|
+
*/
|
|
54
|
+
declare function lookup<TDoc = AnyDocument>(Model: Model<TDoc>, lookupOptions: LookupOptions): Promise<TDoc[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Unwind array field
|
|
57
|
+
*/
|
|
58
|
+
declare function unwind<TDoc = AnyDocument>(Model: Model<TDoc>, field: string, options?: {
|
|
59
|
+
preserveEmpty?: boolean;
|
|
60
|
+
session?: ClientSession;
|
|
61
|
+
}): Promise<TDoc[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Facet search (multiple aggregations in one query)
|
|
64
|
+
*/
|
|
65
|
+
declare function facet<TResult = Record<string, unknown[]>>(Model: Model<any>, facets: Record<string, PipelineStage[]>, options?: {
|
|
66
|
+
session?: ClientSession;
|
|
67
|
+
}): Promise<TResult[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Get distinct values
|
|
70
|
+
*/
|
|
71
|
+
declare function distinct<T = unknown>(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
72
|
+
session?: ClientSession;
|
|
73
|
+
readPreference?: string;
|
|
74
|
+
}): Promise<T[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Calculate sum
|
|
77
|
+
*/
|
|
78
|
+
declare function sum(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
79
|
+
session?: ClientSession;
|
|
80
|
+
}): Promise<number>;
|
|
81
|
+
/**
|
|
82
|
+
* Calculate average
|
|
83
|
+
*/
|
|
84
|
+
declare function average(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
85
|
+
session?: ClientSession;
|
|
86
|
+
}): Promise<number>;
|
|
87
|
+
/**
|
|
88
|
+
* Min/Max
|
|
89
|
+
*/
|
|
90
|
+
declare function minMax(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
91
|
+
session?: ClientSession;
|
|
92
|
+
}): Promise<MinMaxResult>;
|
|
5
93
|
declare namespace create_d_exports {
|
|
6
94
|
export { create, createDefault, createMany, upsert };
|
|
7
95
|
}
|
|
@@ -24,6 +112,42 @@ declare function upsert<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<st
|
|
|
24
112
|
session?: ClientSession;
|
|
25
113
|
updatePipeline?: boolean;
|
|
26
114
|
}): Promise<TDoc | null>;
|
|
115
|
+
declare namespace delete_d_exports {
|
|
116
|
+
export { deleteById, deleteByQuery, deleteMany, restore, softDelete };
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Delete by ID
|
|
120
|
+
*/
|
|
121
|
+
declare function deleteById<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: {
|
|
122
|
+
session?: ClientSession;
|
|
123
|
+
query?: Record<string, unknown>;
|
|
124
|
+
}): Promise<DeleteResult>;
|
|
125
|
+
/**
|
|
126
|
+
* Delete many documents
|
|
127
|
+
*/
|
|
128
|
+
declare function deleteMany<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, options?: {
|
|
129
|
+
session?: ClientSession;
|
|
130
|
+
}): Promise<DeleteResult>;
|
|
131
|
+
/**
|
|
132
|
+
* Delete by query
|
|
133
|
+
*/
|
|
134
|
+
declare function deleteByQuery(Model: Model<any>, query: Record<string, unknown>, options?: {
|
|
135
|
+
session?: ClientSession;
|
|
136
|
+
throwOnNotFound?: boolean;
|
|
137
|
+
}): Promise<DeleteResult>;
|
|
138
|
+
/**
|
|
139
|
+
* Soft delete (set deleted flag)
|
|
140
|
+
*/
|
|
141
|
+
declare function softDelete<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: {
|
|
142
|
+
session?: ClientSession;
|
|
143
|
+
userId?: string;
|
|
144
|
+
}): Promise<DeleteResult>;
|
|
145
|
+
/**
|
|
146
|
+
* Restore soft deleted document
|
|
147
|
+
*/
|
|
148
|
+
declare function restore<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: {
|
|
149
|
+
session?: ClientSession;
|
|
150
|
+
}): Promise<DeleteResult>;
|
|
27
151
|
declare namespace read_d_exports {
|
|
28
152
|
export { count, exists, getAll, getById, getByQuery, getOrCreate, tryGetByQuery };
|
|
29
153
|
}
|
|
@@ -50,7 +174,7 @@ declare function getByQuery<TDoc = AnyDocument>(Model: Model<TDoc>, query: Recor
|
|
|
50
174
|
/**
|
|
51
175
|
* Get document by query without throwing (returns null if not found)
|
|
52
176
|
*/
|
|
53
|
-
declare function tryGetByQuery<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, options?: Omit<OperationOptions,
|
|
177
|
+
declare function tryGetByQuery<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, options?: Omit<OperationOptions, 'throwOnNotFound'>): Promise<TDoc | null>;
|
|
54
178
|
/**
|
|
55
179
|
* Get all documents (basic query without pagination)
|
|
56
180
|
* For pagination, use Repository.paginate() or Repository.stream()
|
|
@@ -75,14 +199,14 @@ declare function getOrCreate<TDoc = AnyDocument>(Model: Model<TDoc>, query: Reco
|
|
|
75
199
|
/**
|
|
76
200
|
* Count documents matching query
|
|
77
201
|
*/
|
|
78
|
-
declare function count(Model: Model<
|
|
202
|
+
declare function count<TDoc = AnyDocument>(Model: Model<TDoc>, query?: Record<string, unknown>, options?: {
|
|
79
203
|
session?: ClientSession;
|
|
80
204
|
readPreference?: ReadPreferenceType;
|
|
81
205
|
}): Promise<number>;
|
|
82
206
|
/**
|
|
83
207
|
* Check if document exists
|
|
84
208
|
*/
|
|
85
|
-
declare function exists(Model: Model<
|
|
209
|
+
declare function exists<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, options?: {
|
|
86
210
|
session?: ClientSession;
|
|
87
211
|
readPreference?: ReadPreferenceType;
|
|
88
212
|
}): Promise<{
|
|
@@ -143,129 +267,8 @@ declare function pushToArray<TDoc = AnyDocument>(Model: Model<TDoc>, id: string
|
|
|
143
267
|
* Pull from array
|
|
144
268
|
*/
|
|
145
269
|
declare function pullFromArray<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, field: string, value: unknown, options?: UpdateOptions): Promise<TDoc>;
|
|
146
|
-
declare namespace
|
|
147
|
-
export {
|
|
270
|
+
declare namespace index_d_exports {
|
|
271
|
+
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 };
|
|
148
272
|
}
|
|
149
|
-
/**
|
|
150
|
-
* Delete by ID
|
|
151
|
-
*/
|
|
152
|
-
declare function deleteById(Model: Model<any>, id: string | ObjectId, options?: {
|
|
153
|
-
session?: ClientSession;
|
|
154
|
-
query?: Record<string, unknown>;
|
|
155
|
-
}): Promise<DeleteResult>;
|
|
156
|
-
/**
|
|
157
|
-
* Delete many documents
|
|
158
|
-
*/
|
|
159
|
-
declare function deleteMany(Model: Model<any>, query: Record<string, unknown>, options?: {
|
|
160
|
-
session?: ClientSession;
|
|
161
|
-
}): Promise<DeleteResult>;
|
|
162
|
-
/**
|
|
163
|
-
* Delete by query
|
|
164
|
-
*/
|
|
165
|
-
declare function deleteByQuery(Model: Model<any>, query: Record<string, unknown>, options?: {
|
|
166
|
-
session?: ClientSession;
|
|
167
|
-
throwOnNotFound?: boolean;
|
|
168
|
-
}): Promise<DeleteResult>;
|
|
169
|
-
/**
|
|
170
|
-
* Soft delete (set deleted flag)
|
|
171
|
-
*/
|
|
172
|
-
declare function softDelete<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: {
|
|
173
|
-
session?: ClientSession;
|
|
174
|
-
userId?: string;
|
|
175
|
-
}): Promise<DeleteResult>;
|
|
176
|
-
/**
|
|
177
|
-
* Restore soft deleted document
|
|
178
|
-
*/
|
|
179
|
-
declare function restore<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: {
|
|
180
|
-
session?: ClientSession;
|
|
181
|
-
}): Promise<DeleteResult>;
|
|
182
|
-
declare namespace aggregate_d_exports {
|
|
183
|
-
export { aggregate, aggregatePaginate, average, countBy, distinct, facet, groupBy, lookup, minMax, sum, unwind };
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Execute aggregation pipeline
|
|
187
|
-
*/
|
|
188
|
-
declare function aggregate<TResult = unknown>(Model: Model<any>, pipeline: PipelineStage[], options?: {
|
|
189
|
-
session?: ClientSession;
|
|
190
|
-
}): Promise<TResult[]>;
|
|
191
|
-
/**
|
|
192
|
-
* Aggregate with pagination using native MongoDB $facet
|
|
193
|
-
* WARNING: $facet results must be <16MB. For larger results (limit >1000),
|
|
194
|
-
* consider using Repository.aggregatePaginate() or splitting into separate queries.
|
|
195
|
-
*/
|
|
196
|
-
declare function aggregatePaginate<TDoc = AnyDocument>(Model: Model<TDoc>, pipeline: PipelineStage[], options?: {
|
|
197
|
-
page?: number;
|
|
198
|
-
limit?: number;
|
|
199
|
-
session?: ClientSession;
|
|
200
|
-
}): Promise<{
|
|
201
|
-
docs: TDoc[];
|
|
202
|
-
total: number;
|
|
203
|
-
page: number;
|
|
204
|
-
limit: number;
|
|
205
|
-
pages: number;
|
|
206
|
-
hasNext: boolean;
|
|
207
|
-
hasPrev: boolean;
|
|
208
|
-
}>;
|
|
209
|
-
/**
|
|
210
|
-
* Group documents by field value
|
|
211
|
-
*/
|
|
212
|
-
declare function groupBy(Model: Model<any>, field: string, options?: {
|
|
213
|
-
limit?: number;
|
|
214
|
-
session?: ClientSession;
|
|
215
|
-
}): Promise<GroupResult[]>;
|
|
216
|
-
/**
|
|
217
|
-
* Count by field values
|
|
218
|
-
*/
|
|
219
|
-
declare function countBy(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
220
|
-
session?: ClientSession;
|
|
221
|
-
}): Promise<GroupResult[]>;
|
|
222
|
-
/**
|
|
223
|
-
* Lookup (join) with another collection
|
|
224
|
-
*
|
|
225
|
-
* MongoDB $lookup has two mutually exclusive forms:
|
|
226
|
-
* 1. Simple form: { from, localField, foreignField, as }
|
|
227
|
-
* 2. Pipeline form: { from, let, pipeline, as }
|
|
228
|
-
*
|
|
229
|
-
* This function automatically selects the appropriate form based on parameters.
|
|
230
|
-
*/
|
|
231
|
-
declare function lookup<TDoc = AnyDocument>(Model: Model<TDoc>, lookupOptions: LookupOptions): Promise<TDoc[]>;
|
|
232
|
-
/**
|
|
233
|
-
* Unwind array field
|
|
234
|
-
*/
|
|
235
|
-
declare function unwind<TDoc = AnyDocument>(Model: Model<TDoc>, field: string, options?: {
|
|
236
|
-
preserveEmpty?: boolean;
|
|
237
|
-
session?: ClientSession;
|
|
238
|
-
}): Promise<TDoc[]>;
|
|
239
|
-
/**
|
|
240
|
-
* Facet search (multiple aggregations in one query)
|
|
241
|
-
*/
|
|
242
|
-
declare function facet<TResult = Record<string, unknown[]>>(Model: Model<any>, facets: Record<string, PipelineStage[]>, options?: {
|
|
243
|
-
session?: ClientSession;
|
|
244
|
-
}): Promise<TResult[]>;
|
|
245
|
-
/**
|
|
246
|
-
* Get distinct values
|
|
247
|
-
*/
|
|
248
|
-
declare function distinct<T = unknown>(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
249
|
-
session?: ClientSession;
|
|
250
|
-
readPreference?: string;
|
|
251
|
-
}): Promise<T[]>;
|
|
252
|
-
/**
|
|
253
|
-
* Calculate sum
|
|
254
|
-
*/
|
|
255
|
-
declare function sum(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
256
|
-
session?: ClientSession;
|
|
257
|
-
}): Promise<number>;
|
|
258
|
-
/**
|
|
259
|
-
* Calculate average
|
|
260
|
-
*/
|
|
261
|
-
declare function average(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
262
|
-
session?: ClientSession;
|
|
263
|
-
}): Promise<number>;
|
|
264
|
-
/**
|
|
265
|
-
* Min/Max
|
|
266
|
-
*/
|
|
267
|
-
declare function minMax(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
268
|
-
session?: ClientSession;
|
|
269
|
-
}): Promise<MinMaxResult>;
|
|
270
273
|
//#endregion
|
|
271
|
-
export { create_d_exports as a,
|
|
274
|
+
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 };
|