@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.
- package/README.md +221 -7
- package/dist/actions/index.cjs +479 -0
- package/dist/actions/index.cjs.map +1 -0
- package/dist/actions/index.d.cts +3 -0
- package/dist/actions/index.d.ts +3 -0
- package/dist/actions/index.js +473 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/index-BfVJZF-3.d.cts +337 -0
- package/dist/index-CgOJ2pqz.d.ts +337 -0
- package/dist/index.cjs +2142 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +239 -0
- package/dist/index.d.ts +239 -0
- package/dist/index.js +2108 -0
- package/dist/index.js.map +1 -0
- package/dist/memory-cache-DG2oSSbx.d.ts +142 -0
- package/dist/memory-cache-DqfFfKes.d.cts +142 -0
- package/dist/pagination/PaginationEngine.cjs +375 -0
- package/dist/pagination/PaginationEngine.cjs.map +1 -0
- package/dist/pagination/PaginationEngine.d.cts +117 -0
- package/dist/pagination/PaginationEngine.d.ts +117 -0
- package/dist/pagination/PaginationEngine.js +369 -0
- package/dist/pagination/PaginationEngine.js.map +1 -0
- package/dist/plugins/index.cjs +874 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.cts +275 -0
- package/dist/plugins/index.d.ts +275 -0
- package/dist/plugins/index.js +857 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/types-Nxhmi1aI.d.cts +510 -0
- package/dist/types-Nxhmi1aI.d.ts +510 -0
- package/dist/utils/index.cjs +667 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +189 -0
- package/dist/utils/index.d.ts +189 -0
- package/dist/utils/index.js +643 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +44 -21
- package/src/Repository.js +0 -296
- package/src/actions/aggregate.js +0 -266
- package/src/actions/create.js +0 -59
- package/src/actions/delete.js +0 -88
- package/src/actions/index.js +0 -11
- package/src/actions/read.js +0 -188
- package/src/actions/update.js +0 -176
- package/src/hooks/lifecycle.js +0 -146
- package/src/index.js +0 -71
- package/src/pagination/PaginationEngine.js +0 -348
- package/src/pagination/utils/cursor.js +0 -119
- package/src/pagination/utils/filter.js +0 -42
- package/src/pagination/utils/limits.js +0 -82
- package/src/pagination/utils/sort.js +0 -101
- package/src/plugins/aggregate-helpers.plugin.js +0 -71
- package/src/plugins/audit-log.plugin.js +0 -60
- package/src/plugins/batch-operations.plugin.js +0 -66
- package/src/plugins/field-filter.plugin.js +0 -27
- package/src/plugins/index.js +0 -19
- package/src/plugins/method-registry.plugin.js +0 -140
- package/src/plugins/mongo-operations.plugin.js +0 -317
- package/src/plugins/soft-delete.plugin.js +0 -46
- package/src/plugins/subdocument.plugin.js +0 -66
- package/src/plugins/timestamp.plugin.js +0 -19
- package/src/plugins/validation-chain.plugin.js +0 -145
- package/src/types.d.ts +0 -87
- package/src/utils/error.js +0 -12
- package/src/utils/field-selection.js +0 -156
- package/src/utils/index.js +0 -12
- package/types/Repository.d.ts +0 -95
- package/types/Repository.d.ts.map +0 -1
- package/types/actions/aggregate.d.ts +0 -112
- package/types/actions/aggregate.d.ts.map +0 -1
- package/types/actions/create.d.ts +0 -21
- package/types/actions/create.d.ts.map +0 -1
- package/types/actions/delete.d.ts +0 -37
- package/types/actions/delete.d.ts.map +0 -1
- package/types/actions/index.d.ts +0 -6
- package/types/actions/index.d.ts.map +0 -1
- package/types/actions/read.d.ts +0 -135
- package/types/actions/read.d.ts.map +0 -1
- package/types/actions/update.d.ts +0 -58
- package/types/actions/update.d.ts.map +0 -1
- package/types/hooks/lifecycle.d.ts +0 -44
- package/types/hooks/lifecycle.d.ts.map +0 -1
- package/types/index.d.ts +0 -25
- package/types/index.d.ts.map +0 -1
- package/types/pagination/PaginationEngine.d.ts +0 -386
- package/types/pagination/PaginationEngine.d.ts.map +0 -1
- package/types/pagination/utils/cursor.d.ts +0 -40
- package/types/pagination/utils/cursor.d.ts.map +0 -1
- package/types/pagination/utils/filter.d.ts +0 -28
- package/types/pagination/utils/filter.d.ts.map +0 -1
- package/types/pagination/utils/limits.d.ts +0 -64
- package/types/pagination/utils/limits.d.ts.map +0 -1
- package/types/pagination/utils/sort.d.ts +0 -41
- package/types/pagination/utils/sort.d.ts.map +0 -1
- package/types/plugins/aggregate-helpers.plugin.d.ts +0 -6
- package/types/plugins/aggregate-helpers.plugin.d.ts.map +0 -1
- package/types/plugins/audit-log.plugin.d.ts +0 -6
- package/types/plugins/audit-log.plugin.d.ts.map +0 -1
- package/types/plugins/batch-operations.plugin.d.ts +0 -6
- package/types/plugins/batch-operations.plugin.d.ts.map +0 -1
- package/types/plugins/field-filter.plugin.d.ts +0 -6
- package/types/plugins/field-filter.plugin.d.ts.map +0 -1
- package/types/plugins/index.d.ts +0 -11
- package/types/plugins/index.d.ts.map +0 -1
- package/types/plugins/method-registry.plugin.d.ts +0 -3
- package/types/plugins/method-registry.plugin.d.ts.map +0 -1
- package/types/plugins/mongo-operations.plugin.d.ts +0 -4
- package/types/plugins/mongo-operations.plugin.d.ts.map +0 -1
- package/types/plugins/soft-delete.plugin.d.ts +0 -6
- package/types/plugins/soft-delete.plugin.d.ts.map +0 -1
- package/types/plugins/subdocument.plugin.d.ts +0 -6
- package/types/plugins/subdocument.plugin.d.ts.map +0 -1
- package/types/plugins/timestamp.plugin.d.ts +0 -6
- package/types/plugins/timestamp.plugin.d.ts.map +0 -1
- package/types/plugins/validation-chain.plugin.d.ts +0 -31
- package/types/plugins/validation-chain.plugin.d.ts.map +0 -1
- package/types/utils/error.d.ts +0 -11
- package/types/utils/error.d.ts.map +0 -1
- package/types/utils/field-selection.d.ts +0 -9
- package/types/utils/field-selection.d.ts.map +0 -1
- package/types/utils/index.d.ts +0 -2
- package/types/utils/index.d.ts.map +0 -1
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Aggregate Actions
|
|
3
|
-
* MongoDB aggregation pipeline operations
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {import('mongoose').Model} Model
|
|
7
|
-
* @typedef {import('mongoose').ClientSession} ClientSession
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Execute aggregation pipeline
|
|
11
|
-
*
|
|
12
|
-
* @param {Model} Model - Mongoose model
|
|
13
|
-
* @param {any[]} pipeline - Aggregation pipeline stages
|
|
14
|
-
* @param {Object} [options={}] - Aggregation options
|
|
15
|
-
* @param {ClientSession} [options.session] - MongoDB session
|
|
16
|
-
* @returns {Promise<any[]>} Aggregation results
|
|
17
|
-
*/
|
|
18
|
-
export function aggregate(Model: Model, pipeline: any[], options?: {
|
|
19
|
-
session?: ClientSession;
|
|
20
|
-
}): Promise<any[]>;
|
|
21
|
-
/**
|
|
22
|
-
* Aggregate with pagination using native MongoDB $facet
|
|
23
|
-
* WARNING: $facet results must be <16MB. For larger results (limit >1000),
|
|
24
|
-
* consider using Repository.aggregatePaginate() or splitting into separate queries.
|
|
25
|
-
*
|
|
26
|
-
* @param {Model} Model - Mongoose model
|
|
27
|
-
* @param {any[]} pipeline - Aggregation pipeline stages (before pagination)
|
|
28
|
-
* @param {Object} [options={}] - Pagination options
|
|
29
|
-
* @param {number} [options.page=1] - Page number (1-indexed)
|
|
30
|
-
* @param {number} [options.limit=10] - Documents per page
|
|
31
|
-
* @param {ClientSession} [options.session] - MongoDB session
|
|
32
|
-
* @returns {Promise<{docs: any[], total: number, page: number, limit: number, pages: number, hasNext: boolean, hasPrev: boolean}>} Paginated results
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* const result = await aggregatePaginate(UserModel, [
|
|
36
|
-
* { $match: { status: 'active' } },
|
|
37
|
-
* { $group: { _id: '$category', count: { $sum: 1 } } }
|
|
38
|
-
* ], { page: 1, limit: 20 });
|
|
39
|
-
*/
|
|
40
|
-
export function aggregatePaginate(Model: Model, pipeline: any[], options?: {
|
|
41
|
-
page?: number;
|
|
42
|
-
limit?: number;
|
|
43
|
-
session?: ClientSession;
|
|
44
|
-
}): Promise<{
|
|
45
|
-
docs: any[];
|
|
46
|
-
total: number;
|
|
47
|
-
page: number;
|
|
48
|
-
limit: number;
|
|
49
|
-
pages: number;
|
|
50
|
-
hasNext: boolean;
|
|
51
|
-
hasPrev: boolean;
|
|
52
|
-
}>;
|
|
53
|
-
/**
|
|
54
|
-
* Group documents by field value
|
|
55
|
-
*
|
|
56
|
-
* @param {Model} Model - Mongoose model
|
|
57
|
-
* @param {string} field - Field name to group by
|
|
58
|
-
* @param {Object} [options={}] - Options
|
|
59
|
-
* @param {number} [options.limit] - Maximum groups to return
|
|
60
|
-
* @param {ClientSession} [options.session] - MongoDB session
|
|
61
|
-
* @returns {Promise<Array<{_id: any, count: number}>>} Grouped results
|
|
62
|
-
*/
|
|
63
|
-
export function groupBy(Model: Model, field: string, options?: {
|
|
64
|
-
limit?: number;
|
|
65
|
-
session?: ClientSession;
|
|
66
|
-
}): Promise<Array<{
|
|
67
|
-
_id: any;
|
|
68
|
-
count: number;
|
|
69
|
-
}>>;
|
|
70
|
-
/**
|
|
71
|
-
* Count by field values
|
|
72
|
-
*/
|
|
73
|
-
export function countBy(Model: any, field: any, query?: {}, options?: {}): Promise<any[]>;
|
|
74
|
-
/**
|
|
75
|
-
* Lookup (join) with another collection
|
|
76
|
-
*/
|
|
77
|
-
export function lookup(Model: any, { from, localField, foreignField, as, pipeline, query, options }: {
|
|
78
|
-
from: any;
|
|
79
|
-
localField: any;
|
|
80
|
-
foreignField: any;
|
|
81
|
-
as: any;
|
|
82
|
-
pipeline?: any[];
|
|
83
|
-
query?: {};
|
|
84
|
-
options?: {};
|
|
85
|
-
}): Promise<any[]>;
|
|
86
|
-
/**
|
|
87
|
-
* Unwind array field
|
|
88
|
-
*/
|
|
89
|
-
export function unwind(Model: any, field: any, options?: {}): Promise<any[]>;
|
|
90
|
-
/**
|
|
91
|
-
* Facet search (multiple aggregations in one query)
|
|
92
|
-
*/
|
|
93
|
-
export function facet(Model: any, facets: any, options?: {}): Promise<any[]>;
|
|
94
|
-
/**
|
|
95
|
-
* Get distinct values
|
|
96
|
-
*/
|
|
97
|
-
export function distinct(Model: any, field: any, query?: {}, options?: {}): Promise<any>;
|
|
98
|
-
/**
|
|
99
|
-
* Calculate sum
|
|
100
|
-
*/
|
|
101
|
-
export function sum(Model: any, field: any, query?: {}, options?: {}): Promise<any>;
|
|
102
|
-
/**
|
|
103
|
-
* Calculate average
|
|
104
|
-
*/
|
|
105
|
-
export function average(Model: any, field: any, query?: {}, options?: {}): Promise<any>;
|
|
106
|
-
/**
|
|
107
|
-
* Min/Max
|
|
108
|
-
*/
|
|
109
|
-
export function minMax(Model: any, field: any, query?: {}, options?: {}): Promise<any>;
|
|
110
|
-
export type Model = import("mongoose").Model<any, any, any, any, any, any, any>;
|
|
111
|
-
export type ClientSession = import("mongoose").ClientSession;
|
|
112
|
-
//# sourceMappingURL=aggregate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate.d.ts","sourceRoot":"","sources":["../../src/actions/aggregate.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AAEH;;;;;;;;GAQG;AACH,iCANW,KAAK,YACL,GAAG,EAAE,YAEb;IAAgC,OAAO,GAA/B,aAAa;CACrB,GAAU,OAAO,CAAC,GAAG,EAAE,CAAC,CAU1B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,yCAdW,KAAK,YACL,GAAG,EAAE,YAEb;IAAyB,IAAI,GAArB,MAAM;IACW,KAAK,GAAtB,MAAM;IACkB,OAAO,GAA/B,aAAa;CACrB,GAAU,OAAO,CAAC;IAAC,IAAI,EAAE,GAAG,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,CAAC,CAwDjI;AAED;;;;;;;;;GASG;AACH,+BAPW,KAAK,SACL,MAAM,YAEd;IAAyB,KAAK,GAAtB,MAAM;IACkB,OAAO,GAA/B,aAAa;CACrB,GAAU,OAAO,CAAC,KAAK,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAAC,CAAC,CAarD;AAED;;GAEG;AACH,0FAaC;AAED;;GAEG;AACH;;;;;;;;mBA0BC;AAED;;GAEG;AACH,6EAWC;AAED;;GAEG;AACH,6EAIC;AAED;;GAEG;AACH,yFAEC;AAED;;GAEG;AACH,oFAgBC;AAED;;GAEG;AACH,wFAgBC;AAED;;GAEG;AACH,uFAiBC;;4BAjQY,OAAO,UAAU,EAAE,aAAa"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create Actions
|
|
3
|
-
* Pure functions for document creation
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Create single document
|
|
7
|
-
*/
|
|
8
|
-
export function create(Model: any, data: any, options?: {}): Promise<any>;
|
|
9
|
-
/**
|
|
10
|
-
* Create multiple documents
|
|
11
|
-
*/
|
|
12
|
-
export function createMany(Model: any, dataArray: any, options?: {}): Promise<any>;
|
|
13
|
-
/**
|
|
14
|
-
* Create with defaults (useful for initialization)
|
|
15
|
-
*/
|
|
16
|
-
export function createDefault(Model: any, overrides?: {}, options?: {}): Promise<any>;
|
|
17
|
-
/**
|
|
18
|
-
* Upsert (create or update)
|
|
19
|
-
*/
|
|
20
|
-
export function upsert(Model: any, query: any, data: any, options?: {}): Promise<any>;
|
|
21
|
-
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/actions/create.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,0EAIC;AAED;;GAEG;AACH,mFAKC;AAED;;GAEG;AACH,sFAaC;AAED;;GAEG;AACH,sFAYC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delete by ID
|
|
3
|
-
*/
|
|
4
|
-
export function deleteById(Model: any, id: any, options?: {}): Promise<{
|
|
5
|
-
success: boolean;
|
|
6
|
-
message: string;
|
|
7
|
-
}>;
|
|
8
|
-
/**
|
|
9
|
-
* Delete many documents
|
|
10
|
-
*/
|
|
11
|
-
export function deleteMany(Model: any, query: any, options?: {}): Promise<{
|
|
12
|
-
success: boolean;
|
|
13
|
-
count: any;
|
|
14
|
-
message: string;
|
|
15
|
-
}>;
|
|
16
|
-
/**
|
|
17
|
-
* Delete by query
|
|
18
|
-
*/
|
|
19
|
-
export function deleteByQuery(Model: any, query: any, options?: {}): Promise<{
|
|
20
|
-
success: boolean;
|
|
21
|
-
message: string;
|
|
22
|
-
}>;
|
|
23
|
-
/**
|
|
24
|
-
* Soft delete (set deleted flag)
|
|
25
|
-
*/
|
|
26
|
-
export function softDelete(Model: any, id: any, options?: {}): Promise<{
|
|
27
|
-
success: boolean;
|
|
28
|
-
message: string;
|
|
29
|
-
}>;
|
|
30
|
-
/**
|
|
31
|
-
* Restore soft deleted document
|
|
32
|
-
*/
|
|
33
|
-
export function restore(Model: any, id: any, options?: {}): Promise<{
|
|
34
|
-
success: boolean;
|
|
35
|
-
message: string;
|
|
36
|
-
}>;
|
|
37
|
-
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/actions/delete.js"],"names":[],"mappings":"AAOA;;GAEG;AACH;;;GAQC;AAED;;GAEG;AACH;;;;GAQC;AAED;;GAEG;AACH;;;GAQC;AAED;;GAEG;AACH;;;GAgBC;AAED;;GAEG;AACH;;;GAgBC"}
|
package/types/actions/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.js"],"names":[],"mappings":""}
|
package/types/actions/read.d.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {import('mongoose').Model} Model
|
|
3
|
-
* @typedef {import('mongoose').PopulateOptions} PopulateOptions
|
|
4
|
-
* @typedef {import('mongoose').ClientSession} ClientSession
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Get document by ID
|
|
8
|
-
*
|
|
9
|
-
* @param {Model} Model - Mongoose model
|
|
10
|
-
* @param {string} id - Document ID
|
|
11
|
-
* @param {Object} [options={}] - Query options
|
|
12
|
-
* @param {string|string[]} [options.select] - Fields to select
|
|
13
|
-
* @param {string|string[]|PopulateOptions|PopulateOptions[]} [options.populate] - Fields to populate
|
|
14
|
-
* @param {boolean} [options.lean] - Return plain JavaScript object
|
|
15
|
-
* @param {ClientSession} [options.session] - MongoDB session
|
|
16
|
-
* @param {boolean} [options.throwOnNotFound=true] - Throw error if not found
|
|
17
|
-
* @returns {Promise<any>} Document or null
|
|
18
|
-
* @throws {Error} If document not found and throwOnNotFound is true
|
|
19
|
-
*/
|
|
20
|
-
export function getById(Model: Model, id: string, options?: {
|
|
21
|
-
select?: string | string[];
|
|
22
|
-
populate?: string | string[] | PopulateOptions | PopulateOptions[];
|
|
23
|
-
lean?: boolean;
|
|
24
|
-
session?: ClientSession;
|
|
25
|
-
throwOnNotFound?: boolean;
|
|
26
|
-
}): Promise<any>;
|
|
27
|
-
/**
|
|
28
|
-
* Get document by query
|
|
29
|
-
*
|
|
30
|
-
* @param {Model} Model - Mongoose model
|
|
31
|
-
* @param {Record<string, any>} query - MongoDB query
|
|
32
|
-
* @param {Object} [options={}] - Query options
|
|
33
|
-
* @param {string|string[]} [options.select] - Fields to select
|
|
34
|
-
* @param {string|string[]|PopulateOptions|PopulateOptions[]} [options.populate] - Fields to populate
|
|
35
|
-
* @param {boolean} [options.lean] - Return plain JavaScript object
|
|
36
|
-
* @param {ClientSession} [options.session] - MongoDB session
|
|
37
|
-
* @param {boolean} [options.throwOnNotFound=true] - Throw error if not found
|
|
38
|
-
* @returns {Promise<any>} Document or null
|
|
39
|
-
* @throws {Error} If document not found and throwOnNotFound is true
|
|
40
|
-
*/
|
|
41
|
-
export function getByQuery(Model: Model, query: Record<string, any>, options?: {
|
|
42
|
-
select?: string | string[];
|
|
43
|
-
populate?: string | string[] | PopulateOptions | PopulateOptions[];
|
|
44
|
-
lean?: boolean;
|
|
45
|
-
session?: ClientSession;
|
|
46
|
-
throwOnNotFound?: boolean;
|
|
47
|
-
}): Promise<any>;
|
|
48
|
-
/**
|
|
49
|
-
* Get document by query without throwing (returns null if not found)
|
|
50
|
-
*
|
|
51
|
-
* @param {Model} Model - Mongoose model
|
|
52
|
-
* @param {Record<string, any>} query - MongoDB query
|
|
53
|
-
* @param {Object} [options={}] - Query options
|
|
54
|
-
* @param {string|string[]} [options.select] - Fields to select
|
|
55
|
-
* @param {string|string[]|PopulateOptions|PopulateOptions[]} [options.populate] - Fields to populate
|
|
56
|
-
* @param {boolean} [options.lean] - Return plain JavaScript object
|
|
57
|
-
* @param {ClientSession} [options.session] - MongoDB session
|
|
58
|
-
* @returns {Promise<any|null>} Document or null
|
|
59
|
-
*/
|
|
60
|
-
export function tryGetByQuery(Model: Model, query: Record<string, any>, options?: {
|
|
61
|
-
select?: string | string[];
|
|
62
|
-
populate?: string | string[] | PopulateOptions | PopulateOptions[];
|
|
63
|
-
lean?: boolean;
|
|
64
|
-
session?: ClientSession;
|
|
65
|
-
}): Promise<any | null>;
|
|
66
|
-
/**
|
|
67
|
-
* Get all documents (basic query without pagination)
|
|
68
|
-
* For pagination, use Repository.paginate() or Repository.stream()
|
|
69
|
-
*
|
|
70
|
-
* @param {Model} Model - Mongoose model
|
|
71
|
-
* @param {Record<string, any>} [query={}] - MongoDB query
|
|
72
|
-
* @param {Object} [options={}] - Query options
|
|
73
|
-
* @param {string|string[]} [options.select] - Fields to select
|
|
74
|
-
* @param {string|string[]|PopulateOptions|PopulateOptions[]} [options.populate] - Fields to populate
|
|
75
|
-
* @param {Record<string, 1|-1>} [options.sort] - Sort specification
|
|
76
|
-
* @param {number} [options.limit] - Maximum documents to return
|
|
77
|
-
* @param {number} [options.skip] - Documents to skip
|
|
78
|
-
* @param {boolean} [options.lean=true] - Return plain JavaScript objects
|
|
79
|
-
* @param {ClientSession} [options.session] - MongoDB session
|
|
80
|
-
* @returns {Promise<any[]>} Array of documents
|
|
81
|
-
*/
|
|
82
|
-
export function getAll(Model: Model, query?: Record<string, any>, options?: {
|
|
83
|
-
select?: string | string[];
|
|
84
|
-
populate?: string | string[] | PopulateOptions | PopulateOptions[];
|
|
85
|
-
sort?: Record<string, 1 | -1>;
|
|
86
|
-
limit?: number;
|
|
87
|
-
skip?: number;
|
|
88
|
-
lean?: boolean;
|
|
89
|
-
session?: ClientSession;
|
|
90
|
-
}): Promise<any[]>;
|
|
91
|
-
/**
|
|
92
|
-
* Get or create document (upsert)
|
|
93
|
-
*
|
|
94
|
-
* @param {Model} Model - Mongoose model
|
|
95
|
-
* @param {Record<string, any>} query - Query to find document
|
|
96
|
-
* @param {Record<string, any>} createData - Data to insert if not found
|
|
97
|
-
* @param {Object} [options={}] - Query options
|
|
98
|
-
* @param {ClientSession} [options.session] - MongoDB session
|
|
99
|
-
* @param {boolean} [options.updatePipeline] - Use update pipeline
|
|
100
|
-
* @returns {Promise<any>} Created or found document
|
|
101
|
-
*/
|
|
102
|
-
export function getOrCreate(Model: Model, query: Record<string, any>, createData: Record<string, any>, options?: {
|
|
103
|
-
session?: ClientSession;
|
|
104
|
-
updatePipeline?: boolean;
|
|
105
|
-
}): Promise<any>;
|
|
106
|
-
/**
|
|
107
|
-
* Count documents matching query
|
|
108
|
-
*
|
|
109
|
-
* @param {Model} Model - Mongoose model
|
|
110
|
-
* @param {Record<string, any>} [query={}] - MongoDB query
|
|
111
|
-
* @param {Object} [options={}] - Query options
|
|
112
|
-
* @param {ClientSession} [options.session] - MongoDB session
|
|
113
|
-
* @returns {Promise<number>} Document count
|
|
114
|
-
*/
|
|
115
|
-
export function count(Model: Model, query?: Record<string, any>, options?: {
|
|
116
|
-
session?: ClientSession;
|
|
117
|
-
}): Promise<number>;
|
|
118
|
-
/**
|
|
119
|
-
* Check if document exists
|
|
120
|
-
*
|
|
121
|
-
* @param {Model} Model - Mongoose model
|
|
122
|
-
* @param {Record<string, any>} query - MongoDB query
|
|
123
|
-
* @param {Object} [options={}] - Query options
|
|
124
|
-
* @param {ClientSession} [options.session] - MongoDB session
|
|
125
|
-
* @returns {Promise<{_id: any} | null>} Document ID if exists, null otherwise
|
|
126
|
-
*/
|
|
127
|
-
export function exists(Model: Model, query: Record<string, any>, options?: {
|
|
128
|
-
session?: ClientSession;
|
|
129
|
-
}): Promise<{
|
|
130
|
-
_id: any;
|
|
131
|
-
} | null>;
|
|
132
|
-
export type Model = import("mongoose").Model<any, any, any, any, any, any, any>;
|
|
133
|
-
export type PopulateOptions = import("mongoose").PopulateOptions;
|
|
134
|
-
export type ClientSession = import("mongoose").ClientSession;
|
|
135
|
-
//# sourceMappingURL=read.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/actions/read.js"],"names":[],"mappings":"AAOA;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AACH,+BAXW,KAAK,MACL,MAAM,YAEd;IAAkC,MAAM,GAAhC,MAAM,GAAC,MAAM,EAAE;IAC6C,QAAQ,GAApE,MAAM,GAAC,MAAM,EAAE,GAAC,eAAe,GAAC,eAAe,EAAE;IAC/B,IAAI,GAAtB,OAAO;IACiB,OAAO,GAA/B,aAAa;IACK,eAAe,GAAjC,OAAO;CACf,GAAU,OAAO,CAAC,GAAG,CAAC,CAiBxB;AAED;;;;;;;;;;;;;GAaG;AACH,kCAXW,KAAK,SACL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAE3B;IAAkC,MAAM,GAAhC,MAAM,GAAC,MAAM,EAAE;IAC6C,QAAQ,GAApE,MAAM,GAAC,MAAM,EAAE,GAAC,eAAe,GAAC,eAAe,EAAE;IAC/B,IAAI,GAAtB,OAAO;IACiB,OAAO,GAA/B,aAAa;IACK,eAAe,GAAjC,OAAO;CACf,GAAU,OAAO,CAAC,GAAG,CAAC,CAiBxB;AAED;;;;;;;;;;;GAWG;AACH,qCATW,KAAK,SACL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAE3B;IAAkC,MAAM,GAAhC,MAAM,GAAC,MAAM,EAAE;IAC6C,QAAQ,GAApE,MAAM,GAAC,MAAM,EAAE,GAAC,eAAe,GAAC,eAAe,EAAE;IAC/B,IAAI,GAAtB,OAAO;IACiB,OAAO,GAA/B,aAAa;CACrB,GAAU,OAAO,CAAC,GAAG,GAAC,IAAI,CAAC,CAI7B;AAED;;;;;;;;;;;;;;;GAeG;AACH,8BAZW,KAAK,UACL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAE3B;IAAkC,MAAM,GAAhC,MAAM,GAAC,MAAM,EAAE;IAC6C,QAAQ,GAApE,MAAM,GAAC,MAAM,EAAE,GAAC,eAAe,GAAC,eAAe,EAAE;IAClB,IAAI,GAAnC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAC,CAAC,CAAC,CAAC;IACH,KAAK,GAAtB,MAAM;IACW,IAAI,GAArB,MAAM;IACY,IAAI,GAAtB,OAAO;IACiB,OAAO,GAA/B,aAAa;CACrB,GAAU,OAAO,CAAC,GAAG,EAAE,CAAC,CAe1B;AAED;;;;;;;;;;GAUG;AACH,mCARW,KAAK,SACL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,cACnB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAE3B;IAAgC,OAAO,GAA/B,aAAa;IACK,cAAc,GAAhC,OAAO;CACf,GAAU,OAAO,CAAC,GAAG,CAAC,CAcxB;AAED;;;;;;;;GAQG;AACH,6BANW,KAAK,UACL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAE3B;IAAgC,OAAO,GAA/B,aAAa;CACrB,GAAU,OAAO,CAAC,MAAM,CAAC,CAI3B;AAED;;;;;;;;GAQG;AACH,8BANW,KAAK,SACL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAE3B;IAAgC,OAAO,GAA/B,aAAa;CACrB,GAAU,OAAO,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAC,GAAG,IAAI,CAAC,CAItC;;8BAhKY,OAAO,UAAU,EAAE,eAAe;4BAClC,OAAO,UAAU,EAAE,aAAa"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Update by ID
|
|
3
|
-
*/
|
|
4
|
-
export function update(Model: any, id: any, data: any, options?: {}): Promise<any>;
|
|
5
|
-
/**
|
|
6
|
-
* Update with query constraints (optimized)
|
|
7
|
-
* Returns null if constraints not met (not an error)
|
|
8
|
-
*/
|
|
9
|
-
export function updateWithConstraints(Model: any, id: any, data: any, constraints?: {}, options?: {}): Promise<any>;
|
|
10
|
-
/**
|
|
11
|
-
* Update with validation (smart optimization)
|
|
12
|
-
* 1-query on success, 2-queries for detailed errors
|
|
13
|
-
*/
|
|
14
|
-
export function updateWithValidation(Model: any, id: any, data: any, validationOptions?: {}, options?: {}): Promise<{
|
|
15
|
-
success: boolean;
|
|
16
|
-
data: any;
|
|
17
|
-
error?: undefined;
|
|
18
|
-
} | {
|
|
19
|
-
success: boolean;
|
|
20
|
-
error: {
|
|
21
|
-
code: number;
|
|
22
|
-
message: string;
|
|
23
|
-
violations?: undefined;
|
|
24
|
-
};
|
|
25
|
-
data?: undefined;
|
|
26
|
-
} | {
|
|
27
|
-
success: boolean;
|
|
28
|
-
error: {
|
|
29
|
-
code: number;
|
|
30
|
-
message: any;
|
|
31
|
-
violations: any;
|
|
32
|
-
};
|
|
33
|
-
data?: undefined;
|
|
34
|
-
}>;
|
|
35
|
-
/**
|
|
36
|
-
* Update many documents
|
|
37
|
-
*/
|
|
38
|
-
export function updateMany(Model: any, query: any, data: any, options?: {}): Promise<{
|
|
39
|
-
matchedCount: any;
|
|
40
|
-
modifiedCount: any;
|
|
41
|
-
}>;
|
|
42
|
-
/**
|
|
43
|
-
* Update by query
|
|
44
|
-
*/
|
|
45
|
-
export function updateByQuery(Model: any, query: any, data: any, options?: {}): Promise<any>;
|
|
46
|
-
/**
|
|
47
|
-
* Increment field
|
|
48
|
-
*/
|
|
49
|
-
export function increment(Model: any, id: any, field: any, value?: number, options?: {}): Promise<any>;
|
|
50
|
-
/**
|
|
51
|
-
* Push to array
|
|
52
|
-
*/
|
|
53
|
-
export function pushToArray(Model: any, id: any, field: any, value: any, options?: {}): Promise<any>;
|
|
54
|
-
/**
|
|
55
|
-
* Pull from array
|
|
56
|
-
*/
|
|
57
|
-
export function pullFromArray(Model: any, id: any, field: any, value: any, options?: {}): Promise<any>;
|
|
58
|
-
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/actions/update.js"],"names":[],"mappings":"AAOA;;GAEG;AACH,mFAgBC;AAED;;;GAGG;AACH,oHAcC;AAED;;;GAGG;AACH;;;;;;;;;;;;;;;;;;;;GAoDC;AAED;;GAEG;AACH;;;GAWC;AAED;;GAEG;AACH,6FAgBC;AAED;;GAEG;AACH,uGAEC;AAED;;GAEG;AACH,qGAEC;AAED;;GAEG;AACH,uGAEC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export class RepositoryLifecycle extends EventEmitter<[never]> {
|
|
2
|
-
constructor();
|
|
3
|
-
hooks: Map<any, any>;
|
|
4
|
-
/**
|
|
5
|
-
* Register hook
|
|
6
|
-
*/
|
|
7
|
-
on(event: any, handler: any): this;
|
|
8
|
-
/**
|
|
9
|
-
* Execute hooks before action
|
|
10
|
-
*/
|
|
11
|
-
runBeforeHooks(action: any, context: any): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Execute hooks after action
|
|
14
|
-
*/
|
|
15
|
-
runAfterHooks(action: any, context: any, result: any): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Execute hooks on error
|
|
18
|
-
*/
|
|
19
|
-
runErrorHooks(action: any, context: any, error: any): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
export namespace hooks {
|
|
22
|
-
function autoTimestamp(): {
|
|
23
|
-
'before:create': (context: any) => void;
|
|
24
|
-
'before:update': (context: any) => void;
|
|
25
|
-
};
|
|
26
|
-
function autoUser(userField?: string): {
|
|
27
|
-
'before:create': (context: any) => void;
|
|
28
|
-
};
|
|
29
|
-
function autoOrganization(orgField?: string): {
|
|
30
|
-
'before:create': (context: any) => void;
|
|
31
|
-
};
|
|
32
|
-
function auditLog(logger: any): {
|
|
33
|
-
'after:create': (context: any, result: any) => void;
|
|
34
|
-
'after:update': (context: any, result: any) => void;
|
|
35
|
-
'after:delete': (context: any, result: any) => void;
|
|
36
|
-
};
|
|
37
|
-
function cacheInvalidation(cache: any): {
|
|
38
|
-
'after:create': (context: any, result: any) => Promise<void>;
|
|
39
|
-
'after:update': (context: any, result: any) => Promise<void>;
|
|
40
|
-
'after:delete': (context: any) => Promise<void>;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
import { EventEmitter } from 'events';
|
|
44
|
-
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/hooks/lifecycle.js"],"names":[],"mappings":"AAOA;IACE,cAGC;IADC,qBAAsB;IAGxB;;OAEG;IACH,mCAMC;IAED;;OAEG;IACH,yDAQC;IAED;;OAEG;IACH,qEAQC;IAED;;OAEG;IACH,oEAQC;CACF;;IASgB;;;MAQb;IAKQ;;MAMR;IAKgB;;MAMhB;IAKQ;;;;MAqBR;IAKiB;;;;MAWjB;;6BA1IyB,QAAQ"}
|
package/types/index.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export { Repository } from "./Repository.js";
|
|
2
|
-
export { PaginationEngine } from "./pagination/PaginationEngine.js";
|
|
3
|
-
export { fieldFilterPlugin } from "./plugins/field-filter.plugin.js";
|
|
4
|
-
export { timestampPlugin } from "./plugins/timestamp.plugin.js";
|
|
5
|
-
export { auditLogPlugin } from "./plugins/audit-log.plugin.js";
|
|
6
|
-
export { softDeletePlugin } from "./plugins/soft-delete.plugin.js";
|
|
7
|
-
export { methodRegistryPlugin } from "./plugins/method-registry.plugin.js";
|
|
8
|
-
export { mongoOperationsPlugin } from "./plugins/mongo-operations.plugin.js";
|
|
9
|
-
export { batchOperationsPlugin } from "./plugins/batch-operations.plugin.js";
|
|
10
|
-
export { aggregateHelpersPlugin } from "./plugins/aggregate-helpers.plugin.js";
|
|
11
|
-
export { subdocumentPlugin } from "./plugins/subdocument.plugin.js";
|
|
12
|
-
export * as actions from "./actions/index.js";
|
|
13
|
-
export function createRepository(Model: any, plugins?: any[]): Repository;
|
|
14
|
-
export default Repository;
|
|
15
|
-
export type PaginationConfig = import("./pagination/PaginationEngine.js").PaginationConfig;
|
|
16
|
-
export type OffsetPaginationOptions = import("./pagination/PaginationEngine.js").OffsetPaginationOptions;
|
|
17
|
-
export type KeysetPaginationOptions = import("./pagination/PaginationEngine.js").KeysetPaginationOptions;
|
|
18
|
-
export type AggregatePaginationOptions = import("./pagination/PaginationEngine.js").AggregatePaginationOptions;
|
|
19
|
-
export type OffsetPaginationResult = import("./pagination/PaginationEngine.js").OffsetPaginationResult;
|
|
20
|
-
export type KeysetPaginationResult = import("./pagination/PaginationEngine.js").KeysetPaginationResult;
|
|
21
|
-
export type AggregatePaginationResult = import("./pagination/PaginationEngine.js").AggregatePaginationResult;
|
|
22
|
-
import { Repository } from './Repository.js';
|
|
23
|
-
export { validationChainPlugin, blockIf, requireField, autoInject, immutableField, uniqueField } from "./plugins/validation-chain.plugin.js";
|
|
24
|
-
export { getFieldsForUser, getMongooseProjection, filterResponseData, createFieldPreset } from "./utils/field-selection.js";
|
|
25
|
-
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAkEO,0EAEN;;+BA7CY,OAAO,kCAAkC,EAAE,gBAAgB;sCAC3D,OAAO,kCAAkC,EAAE,uBAAuB;sCAClE,OAAO,kCAAkC,EAAE,uBAAuB;yCAClE,OAAO,kCAAkC,EAAE,0BAA0B;qCACrE,OAAO,kCAAkC,EAAE,sBAAsB;qCACjE,OAAO,kCAAkC,EAAE,sBAAsB;wCACjE,OAAO,kCAAkC,EAAE,yBAAyB;2BAmCtD,iBAAiB"}
|