@tsed/mongoose 7.85.1 → 7.85.3
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/lib/cjs/decorators/postHook.js.map +1 -1
- package/lib/cjs/decorators/preHook.js +21 -59
- package/lib/cjs/decorators/preHook.js.map +1 -1
- package/lib/cjs/utils/createSchema.js +13 -4
- package/lib/cjs/utils/createSchema.js.map +1 -1
- package/lib/cjs/utils/schemaOptions.js +4 -3
- package/lib/cjs/utils/schemaOptions.js.map +1 -1
- package/lib/esm/decorators/postHook.js.map +1 -1
- package/lib/esm/decorators/preHook.js +21 -59
- package/lib/esm/decorators/preHook.js.map +1 -1
- package/lib/esm/utils/createSchema.js +14 -5
- package/lib/esm/utils/createSchema.js.map +1 -1
- package/lib/esm/utils/schemaOptions.js +4 -3
- package/lib/esm/utils/schemaOptions.js.map +1 -1
- package/lib/types/decorators/postHook.d.ts +4 -4
- package/lib/types/decorators/preHook.d.ts +7 -5
- package/lib/types/interfaces/MongooseSchemaOptions.d.ts +8 -10
- package/lib/types/utils/createSchema.d.ts +2 -2
- package/lib/types/utils/schemaOptions.d.ts +2 -2
- package/lib/types-esm/decorators/postHook.d.ts +4 -4
- package/lib/types-esm/decorators/preHook.d.ts +7 -5
- package/lib/types-esm/interfaces/MongooseSchemaOptions.d.ts +8 -10
- package/lib/types-esm/utils/createSchema.d.ts +2 -2
- package/lib/types-esm/utils/schemaOptions.d.ts +2 -2
- package/package.json +18 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postHook.js","sourceRoot":"","sources":["../../../src/decorators/postHook.ts"],"names":[],"mappings":";;;AAAA,qCAAkF;AAElF,gEAAwD;AAgDxD,SAAgB,QAAQ,CAAU,
|
|
1
|
+
{"version":3,"file":"postHook.js","sourceRoot":"","sources":["../../../src/decorators/postHook.ts"],"names":[],"mappings":";;;AAAA,qCAAkF;AAElF,gEAAwD;AAgDxD,SAAgB,QAAQ,CAAU,MAAuB,EAAE,GAAG,MAAa;IACzE,OAAO,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;QACzB,IAAI,OAAO,GAAwB,MAAM,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,EAAE,GAA0B,MAAM,CAAC,CAAC,CAAC,CAAC;QAE1C,IAAI,IAAA,sBAAe,EAAC,IAAI,CAAC,KAAK,qBAAc,CAAC,UAAU,EAAE;YACvD,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACpB,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACrC;QAED,IAAA,gCAAa,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACrB,IAAI,EAAE;gBACJ;oBACE,MAAM;oBACN,EAAE;oBACF,OAAO;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAQ,CAAC;AACZ,CAAC;AApBD,4BAoBC"}
|
|
@@ -3,68 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PreHook = void 0;
|
|
4
4
|
const core_1 = require("@tsed/core");
|
|
5
5
|
const schemaOptions_js_1 = require("../utils/schemaOptions.js");
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* We can simply attach a `@PreHook` decorator to your model class and
|
|
9
|
-
* define the hook function like you normally would in Mongoose.
|
|
10
|
-
*
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import {Ignore, Required} from "@tsed/common";
|
|
13
|
-
* import {PreHook, Model} from "@tsed/mongoose";
|
|
14
|
-
*
|
|
15
|
-
* @Model()
|
|
16
|
-
* @PreHook("save", (car: CarModel, next) => {
|
|
17
|
-
* if (car.model === 'Tesla') {
|
|
18
|
-
* car.isFast = true;
|
|
19
|
-
* }
|
|
20
|
-
* next();
|
|
21
|
-
*})
|
|
22
|
-
* export class CarModel {
|
|
23
|
-
*
|
|
24
|
-
* @Ignore()
|
|
25
|
-
* _id: string;
|
|
26
|
-
*
|
|
27
|
-
* @Required()
|
|
28
|
-
* model: string;
|
|
29
|
-
*
|
|
30
|
-
* @Required()
|
|
31
|
-
* isFast: boolean;
|
|
32
|
-
*
|
|
33
|
-
* // or Prehook on static method
|
|
34
|
-
* @PreHook("save")
|
|
35
|
-
* static preSave(car: CarModel, next) {
|
|
36
|
-
* if (car.model === 'Tesla') {
|
|
37
|
-
* car.isFast = true;
|
|
38
|
-
* }
|
|
39
|
-
* next();
|
|
40
|
-
* }
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* This will execute the pre-save hook each time a `CarModel` document is saved.
|
|
45
|
-
*
|
|
46
|
-
* @param {string} method
|
|
47
|
-
* @param fn
|
|
48
|
-
* @param options
|
|
49
|
-
* @returns {Function}
|
|
50
|
-
* @decorator
|
|
51
|
-
* @class
|
|
52
|
-
*/
|
|
53
|
-
function PreHook(method, fn, options) {
|
|
6
|
+
function PreHook(method, ...decoratorArgs) {
|
|
54
7
|
return (...args) => {
|
|
55
8
|
if ((0, core_1.decoratorTypeOf)(args) === core_1.DecoratorTypes.METHOD_STC) {
|
|
56
|
-
|
|
57
|
-
|
|
9
|
+
(0, schemaOptions_js_1.schemaOptions)(args[0], {
|
|
10
|
+
pre: [
|
|
11
|
+
{
|
|
12
|
+
method,
|
|
13
|
+
fn: args[0][args[1]].bind(args[0]),
|
|
14
|
+
options: decoratorArgs[0]
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
(0, schemaOptions_js_1.schemaOptions)(args[0], {
|
|
21
|
+
pre: [
|
|
22
|
+
{
|
|
23
|
+
method,
|
|
24
|
+
fn: decoratorArgs[0],
|
|
25
|
+
options: decoratorArgs[1]
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
});
|
|
58
29
|
}
|
|
59
|
-
(0, schemaOptions_js_1.schemaOptions)(args[0], {
|
|
60
|
-
pre: [
|
|
61
|
-
{
|
|
62
|
-
method,
|
|
63
|
-
fn: fn,
|
|
64
|
-
options
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
});
|
|
68
30
|
};
|
|
69
31
|
}
|
|
70
32
|
exports.PreHook = PreHook;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preHook.js","sourceRoot":"","sources":["../../../src/decorators/preHook.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"preHook.js","sourceRoot":"","sources":["../../../src/decorators/preHook.ts"],"names":[],"mappings":";;;AAAA,qCAAkF;AAElF,gEAAwD;AAmDxD,SAAgB,OAAO,CAAU,MAAuB,EAAE,GAAG,aAAoB;IAC/E,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACxB,IAAI,IAAA,sBAAe,EAAC,IAAI,CAAC,KAAK,qBAAc,CAAC,UAAU,EAAE;YACvD,IAAA,gCAAa,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE;gBACrB,GAAG,EAAE;oBACH;wBACE,MAAM;wBACN,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;wBAClC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;qBAC1B;iBACF;aACF,CAAC,CAAC;SACJ;aAAM;YACL,IAAA,gCAAa,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE;gBACrB,GAAG,EAAE;oBACH;wBACE,MAAM;wBACN,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC;wBACpB,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;qBAC1B;iBACF;aACF,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;AACJ,CAAC;AAxBD,0BAwBC"}
|
|
@@ -129,13 +129,13 @@ function createSchemaTypeOptions(propEntity) {
|
|
|
129
129
|
}
|
|
130
130
|
schemaTypeOptions = {
|
|
131
131
|
...schemaTypeOptions,
|
|
132
|
-
type: propEntity.type,
|
|
132
|
+
type: jsonSchema["enum"] && (0, core_1.isClassObject)(propEntity.type) ? (0, core_1.classOf)(jsonSchema["enum"][0]) : propEntity.type,
|
|
133
133
|
match: match,
|
|
134
134
|
min,
|
|
135
135
|
max,
|
|
136
136
|
minlength,
|
|
137
137
|
maxlength,
|
|
138
|
-
enum:
|
|
138
|
+
enum: jsonSchema["enum"],
|
|
139
139
|
default: jsonSchema["default"]
|
|
140
140
|
};
|
|
141
141
|
}
|
|
@@ -146,14 +146,23 @@ function createSchemaTypeOptions(propEntity) {
|
|
|
146
146
|
schemaTypeOptions = (0, core_1.cleanObject)({ ...schemaTypeOptions, ...rawMongooseSchema });
|
|
147
147
|
if (propEntity.isCollection) {
|
|
148
148
|
if (propEntity.isArray) {
|
|
149
|
-
return
|
|
149
|
+
return {
|
|
150
|
+
...schemaTypeOptions,
|
|
151
|
+
type: [schemaTypeOptions.type]
|
|
152
|
+
};
|
|
150
153
|
}
|
|
151
154
|
// Can be a Map or a Set;
|
|
152
155
|
// Mongoose implements only Map;
|
|
153
156
|
if (propEntity.collectionType !== Map) {
|
|
154
157
|
throw new Error(`Invalid collection type. ${(0, core_1.nameOf)(propEntity.collectionType)} is not supported.`);
|
|
155
158
|
}
|
|
156
|
-
|
|
159
|
+
const { default: defaultValue, required, ...otherOpts } = schemaTypeOptions;
|
|
160
|
+
return {
|
|
161
|
+
type: Map,
|
|
162
|
+
of: otherOpts,
|
|
163
|
+
default: defaultValue,
|
|
164
|
+
required
|
|
165
|
+
};
|
|
157
166
|
}
|
|
158
167
|
return schemaTypeOptions;
|
|
159
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSchema.js","sourceRoot":"","sources":["../../../src/utils/createSchema.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"createSchema.js","sourceRoot":"","sources":["../../../src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33
|
-
|
|
31
|
+
: // we need to explicitly gives args to avoid a bug with mongoose
|
|
32
|
+
function (next, arg1, arg2) {
|
|
33
|
+
return fn(this, next, arg1, arg2);
|
|
34
|
+
};
|
|
34
35
|
}
|
|
35
36
|
exports.buildPreHook = buildPreHook;
|
|
36
37
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaOptions.js","sourceRoot":"","sources":["../../../src/utils/schemaOptions.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAE5C,4DAAkE;
|
|
1
|
+
{"version":3,"file":"schemaOptions.js","sourceRoot":"","sources":["../../../src/utils/schemaOptions.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAE5C,4DAAkE;AASlE;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAW,EAAE,OAA+B;IACxE,MAAM,KAAK,GAAG,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,sCAAuB,CAAC,EAAE;QACvC,KAAK,CAAC,GAAG,CAAC,sCAAuB,EAAE,EAAE,CAAC,CAAC;KACxC;IAED,IAAI,OAAO,EAAE;QACX,KAAK,CAAC,GAAG,CAAC,sCAAuB,EAAE,IAAA,gBAAS,EAAC,KAAK,CAAC,GAAG,CAAC,sCAAuB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;KAC5F;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,sCAAuB,CAAC,CAAC;AAC5C,CAAC;AAZD,sCAYC;AAED,SAAS,WAAW,CAAC,IAAwC;IAC3D,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAQ,CAAC;AAC3G,CAAC;AAED;;GAEG;AACH,SAAgB,YAA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C,IAAI,CAAC,CAAC,CAAC,CAAC;KAC5E;AACH,CAAC;AAvBD,gDAuBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postHook.js","sourceRoot":"","sources":["../../../src/decorators/postHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,cAAc,EAAwB,MAAM,YAAY,CAAC;AAElF,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAgDxD,MAAM,UAAU,QAAQ,CAAU,
|
|
1
|
+
{"version":3,"file":"postHook.js","sourceRoot":"","sources":["../../../src/decorators/postHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,cAAc,EAAwB,MAAM,YAAY,CAAC;AAElF,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAgDxD,MAAM,UAAU,QAAQ,CAAU,MAAuB,EAAE,GAAG,MAAa;IACzE,OAAO,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;QACzB,IAAI,OAAO,GAAwB,MAAM,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,EAAE,GAA0B,MAAM,CAAC,CAAC,CAAC,CAAC;QAE1C,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,cAAc,CAAC,UAAU,EAAE;YACvD,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACpB,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACrC;QAED,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACrB,IAAI,EAAE;gBACJ;oBACE,MAAM;oBACN,EAAE;oBACF,OAAO;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAQ,CAAC;AACZ,CAAC"}
|
|
@@ -1,67 +1,29 @@
|
|
|
1
1
|
import { decoratorTypeOf, DecoratorTypes } from "@tsed/core";
|
|
2
2
|
import { schemaOptions } from "../utils/schemaOptions.js";
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* We can simply attach a `@PreHook` decorator to your model class and
|
|
6
|
-
* define the hook function like you normally would in Mongoose.
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import {Ignore, Required} from "@tsed/common";
|
|
10
|
-
* import {PreHook, Model} from "@tsed/mongoose";
|
|
11
|
-
*
|
|
12
|
-
* @Model()
|
|
13
|
-
* @PreHook("save", (car: CarModel, next) => {
|
|
14
|
-
* if (car.model === 'Tesla') {
|
|
15
|
-
* car.isFast = true;
|
|
16
|
-
* }
|
|
17
|
-
* next();
|
|
18
|
-
*})
|
|
19
|
-
* export class CarModel {
|
|
20
|
-
*
|
|
21
|
-
* @Ignore()
|
|
22
|
-
* _id: string;
|
|
23
|
-
*
|
|
24
|
-
* @Required()
|
|
25
|
-
* model: string;
|
|
26
|
-
*
|
|
27
|
-
* @Required()
|
|
28
|
-
* isFast: boolean;
|
|
29
|
-
*
|
|
30
|
-
* // or Prehook on static method
|
|
31
|
-
* @PreHook("save")
|
|
32
|
-
* static preSave(car: CarModel, next) {
|
|
33
|
-
* if (car.model === 'Tesla') {
|
|
34
|
-
* car.isFast = true;
|
|
35
|
-
* }
|
|
36
|
-
* next();
|
|
37
|
-
* }
|
|
38
|
-
* }
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* This will execute the pre-save hook each time a `CarModel` document is saved.
|
|
42
|
-
*
|
|
43
|
-
* @param {string} method
|
|
44
|
-
* @param fn
|
|
45
|
-
* @param options
|
|
46
|
-
* @returns {Function}
|
|
47
|
-
* @decorator
|
|
48
|
-
* @class
|
|
49
|
-
*/
|
|
50
|
-
export function PreHook(method, fn, options) {
|
|
3
|
+
export function PreHook(method, ...decoratorArgs) {
|
|
51
4
|
return (...args) => {
|
|
52
5
|
if (decoratorTypeOf(args) === DecoratorTypes.METHOD_STC) {
|
|
53
|
-
|
|
54
|
-
|
|
6
|
+
schemaOptions(args[0], {
|
|
7
|
+
pre: [
|
|
8
|
+
{
|
|
9
|
+
method,
|
|
10
|
+
fn: args[0][args[1]].bind(args[0]),
|
|
11
|
+
options: decoratorArgs[0]
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
schemaOptions(args[0], {
|
|
18
|
+
pre: [
|
|
19
|
+
{
|
|
20
|
+
method,
|
|
21
|
+
fn: decoratorArgs[0],
|
|
22
|
+
options: decoratorArgs[1]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
});
|
|
55
26
|
}
|
|
56
|
-
schemaOptions(args[0], {
|
|
57
|
-
pre: [
|
|
58
|
-
{
|
|
59
|
-
method,
|
|
60
|
-
fn: fn,
|
|
61
|
-
options
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
});
|
|
65
27
|
};
|
|
66
28
|
}
|
|
67
29
|
//# sourceMappingURL=preHook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preHook.js","sourceRoot":"","sources":["../../../src/decorators/preHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"preHook.js","sourceRoot":"","sources":["../../../src/decorators/preHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,cAAc,EAAwB,MAAM,YAAY,CAAC;AAElF,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAmDxD,MAAM,UAAU,OAAO,CAAU,MAAuB,EAAE,GAAG,aAAoB;IAC/E,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACxB,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,cAAc,CAAC,UAAU,EAAE;YACvD,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;gBACrB,GAAG,EAAE;oBACH;wBACE,MAAM;wBACN,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;wBAClC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;qBAC1B;iBACF;aACF,CAAC,CAAC;SACJ;aAAM;YACL,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;gBACrB,GAAG,EAAE;oBACH;wBACE,MAAM;wBACN,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC;wBACpB,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;qBAC1B;iBACF;aACF,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cleanObject, nameOf, Store } from "@tsed/core";
|
|
1
|
+
import { classOf, cleanObject, isClassObject, nameOf, Store } from "@tsed/core";
|
|
2
2
|
import { deserialize, serialize } from "@tsed/json-mapper";
|
|
3
3
|
import { getProperties, JsonEntityStore } from "@tsed/schema";
|
|
4
4
|
import { pascalCase } from "change-case";
|
|
@@ -121,13 +121,13 @@ export function createSchemaTypeOptions(propEntity) {
|
|
|
121
121
|
}
|
|
122
122
|
schemaTypeOptions = {
|
|
123
123
|
...schemaTypeOptions,
|
|
124
|
-
type: propEntity.type,
|
|
124
|
+
type: jsonSchema["enum"] && isClassObject(propEntity.type) ? classOf(jsonSchema["enum"][0]) : propEntity.type,
|
|
125
125
|
match: match,
|
|
126
126
|
min,
|
|
127
127
|
max,
|
|
128
128
|
minlength,
|
|
129
129
|
maxlength,
|
|
130
|
-
enum:
|
|
130
|
+
enum: jsonSchema["enum"],
|
|
131
131
|
default: jsonSchema["default"]
|
|
132
132
|
};
|
|
133
133
|
}
|
|
@@ -138,14 +138,23 @@ export function createSchemaTypeOptions(propEntity) {
|
|
|
138
138
|
schemaTypeOptions = cleanObject({ ...schemaTypeOptions, ...rawMongooseSchema });
|
|
139
139
|
if (propEntity.isCollection) {
|
|
140
140
|
if (propEntity.isArray) {
|
|
141
|
-
return
|
|
141
|
+
return {
|
|
142
|
+
...schemaTypeOptions,
|
|
143
|
+
type: [schemaTypeOptions.type]
|
|
144
|
+
};
|
|
142
145
|
}
|
|
143
146
|
// Can be a Map or a Set;
|
|
144
147
|
// Mongoose implements only Map;
|
|
145
148
|
if (propEntity.collectionType !== Map) {
|
|
146
149
|
throw new Error(`Invalid collection type. ${nameOf(propEntity.collectionType)} is not supported.`);
|
|
147
150
|
}
|
|
148
|
-
|
|
151
|
+
const { default: defaultValue, required, ...otherOpts } = schemaTypeOptions;
|
|
152
|
+
return {
|
|
153
|
+
type: Map,
|
|
154
|
+
of: otherOpts,
|
|
155
|
+
default: defaultValue,
|
|
156
|
+
required
|
|
157
|
+
};
|
|
149
158
|
}
|
|
150
159
|
return schemaTypeOptions;
|
|
151
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSchema.js","sourceRoot":"","sources":["../../../src/utils/createSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"createSchema.js","sourceRoot":"","sources":["../../../src/utils/createSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AACpF,OAAO,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,aAAa,EAAE,eAAe,EAAa,MAAM,cAAc,CAAC;AACxE,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,QAAgG,MAAM,UAAU,CAAC;AACxH,OAAO,EAAC,eAAe,EAAE,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAGnF,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAC,aAAa,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,CAAC,iBAAiB,CAAC,GAAG,EAAE;QACjC,4CAA4C;QAC5C,iBAAiB,GAAG,EAAC,GAAG,iBAAiB,EAAE,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,IAAI,CAAQ,EAAC,CAAC;KACrF;IAED,iBAAiB,GAAG,WAAW,CAAC,EAAC,GAAG,iBAAiB,EAAE,GAAG,iBAAiB,EAAC,CAAC,CAAC;IAE9E,IAAI,UAAU,CAAC,YAAY,EAAE;QAC3B,IAAI,UAAU,CAAC,OAAO,EAAE;YACtB,OAAO;gBACL,GAAG,iBAAiB;gBACpB,IAAI,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC;aAC/B,CAAC;SACH;QACD,yBAAyB;QACzB,gCAAgC;QAChC,IAAI,UAAU,CAAC,cAAc,KAAK,GAAG,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;SACpG;QAED,MAAM,EAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAC,GAAG,iBAAiB,CAAC;QAC1E,OAAO;YACL,IAAI,EAAE,GAAG;YACT,EAAE,EAAE,SAAS;YACb,OAAO,EAAE,YAAY;YACrB,QAAQ;SACT,CAAC;KACH;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
|
@@ -24,9 +24,10 @@ export function buildPreHook(fn) {
|
|
|
24
24
|
? function () {
|
|
25
25
|
return fn(this);
|
|
26
26
|
}
|
|
27
|
-
:
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
: // we need to explicitly gives args to avoid a bug with mongoose
|
|
28
|
+
function (next, arg1, arg2) {
|
|
29
|
+
return fn(this, next, arg1, arg2);
|
|
30
|
+
};
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* @ignore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaOptions.js","sourceRoot":"","sources":["../../../src/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
|
2
|
-
import { MongooseHookOptions, MongoosePostHookCB } from "../interfaces/MongooseSchemaOptions.js";
|
|
2
|
+
import { MongooseHookOptions, MongooseMethods, MongoosePostHookCB } from "../interfaces/MongooseSchemaOptions.js";
|
|
3
3
|
/**
|
|
4
4
|
* We can simply attach a `@PostHook` decorator to your model class and
|
|
5
5
|
* define the hook function like you normally would in Mongoose.
|
|
@@ -43,6 +43,6 @@ import { MongooseHookOptions, MongoosePostHookCB } from "../interfaces/MongooseS
|
|
|
43
43
|
* @mongoose
|
|
44
44
|
* @class
|
|
45
45
|
*/
|
|
46
|
-
export declare function PostHook<T = any>(method:
|
|
47
|
-
export declare function PostHook<T = any>(method:
|
|
48
|
-
export declare function PostHook<T = any>(method:
|
|
46
|
+
export declare function PostHook<T = any>(method: MongooseMethods, fn: MongoosePostHookCB<T>): ClassDecorator;
|
|
47
|
+
export declare function PostHook<T = any>(method: MongooseMethods, fn: MongoosePostHookCB<T>, options: MongooseHookOptions): ClassDecorator;
|
|
48
|
+
export declare function PostHook<T = any>(method: MongooseMethods, options: MongooseHookOptions): StaticMethodDecorator;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StaticMethodDecorator } from "@tsed/core";
|
|
2
|
+
import type { MongooseHookOptions, MongooseMethods, MongoosePreHookCB } from "../interfaces/MongooseSchemaOptions.js";
|
|
2
3
|
/**
|
|
3
4
|
*
|
|
4
5
|
* We can simply attach a `@PreHook` decorator to your model class and
|
|
@@ -39,11 +40,12 @@ import { MongooseHookOptions, MongoosePreHookCB } from "../interfaces/MongooseSc
|
|
|
39
40
|
*
|
|
40
41
|
* This will execute the pre-save hook each time a `CarModel` document is saved.
|
|
41
42
|
*
|
|
42
|
-
* @param {string} method
|
|
43
|
-
* @param fn
|
|
44
|
-
* @param options
|
|
45
43
|
* @returns {Function}
|
|
46
44
|
* @decorator
|
|
47
45
|
* @class
|
|
46
|
+
* @param method
|
|
47
|
+
* @param fn
|
|
48
|
+
* @param options
|
|
48
49
|
*/
|
|
49
|
-
export declare function PreHook<T = any>(method:
|
|
50
|
+
export declare function PreHook<T = any>(method: MongooseMethods, fn: MongoosePreHookCB<T>, options?: MongooseHookOptions): ClassDecorator;
|
|
51
|
+
export declare function PreHook<T = any>(method: MongooseMethods, options?: MongooseHookOptions): StaticMethodDecorator;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { type IndexOptions, Schema, SchemaOptions } from "mongoose";
|
|
2
2
|
import { MongooseDocument } from "./MongooseDocument.js";
|
|
3
|
+
export type MongooseMethod = "aggregate" | "bulkWrite" | "createCollection" | "save" | "insertMany" | "estimatedDocumentCount" | "countDocuments" | "deleteMany" | "distinct" | "find" | "findOne" | "findOneAndDelete" | "findOneAndReplace" | "findOneAndUpdate" | "replaceOne" | "updateMany" | "init" | "validate";
|
|
4
|
+
export type MongooseMethods = MongooseMethod | RegExp | MongooseMethod[];
|
|
3
5
|
export type MongooseNextCB = (err?: Error) => void;
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export type MongooseHookPromised<T = any> = (doc: T | MongooseDocument<T>) => Promise<void> | void;
|
|
10
|
-
export type MongoosePreHookCB<T = any> = ((doc: T | MongooseDocument<T>, next: MongooseNextCB) => void) | MongooseHookPromised;
|
|
11
|
-
export type MongoosePostHookCB<T = any> = ((doc: T | MongooseDocument<T>, error: Error, next: MongooseNextCB) => void) | ((doc: T | MongooseDocument<T>, error: Error) => Promise<void> | void) | ((doc: T | MongooseDocument<T>, next: MongooseNextCB) => void) | MongooseHookPromised;
|
|
6
|
+
export type MongooseHookOptions = Record<string, unknown>;
|
|
7
|
+
export type MongooseHookPromised<T = any> = (doc: T | MongooseDocument<T>) => Promise<void>;
|
|
8
|
+
export type MongoosePreHookCB<T = any> = (doc: T | MongooseDocument<T>, ...args: unknown[]) => Promise<void> | void;
|
|
9
|
+
export type MongoosePostHookCB<T = any> = (doc: T | MongooseDocument<T>, ...args: unknown[]) => Promise<void> | void;
|
|
12
10
|
export interface MongoosePreHook<T = any> {
|
|
13
|
-
method:
|
|
11
|
+
method: MongooseMethods;
|
|
14
12
|
fn: MongoosePreHookCB<T>;
|
|
15
13
|
options?: MongooseHookOptions;
|
|
16
14
|
}
|
|
17
15
|
export interface MongoosePostHook<T = any> {
|
|
18
|
-
method:
|
|
16
|
+
method: MongooseMethods;
|
|
19
17
|
fn: MongoosePostHookCB<T>;
|
|
20
18
|
options?: MongooseHookOptions;
|
|
21
19
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
2
|
import { JsonEntityStore } from "@tsed/schema";
|
|
3
|
-
import mongoose, { Schema, SchemaDefinition,
|
|
3
|
+
import mongoose, { Schema, SchemaDefinition, SchemaDefinitionProperty } from "mongoose";
|
|
4
4
|
import { MongooseSchemaOptions } from "../interfaces/MongooseSchemaOptions.js";
|
|
5
5
|
import { MongooseVirtualRefOptions } from "../interfaces/MongooseVirtualRefOptions.js";
|
|
6
6
|
export interface MongooseSchemaMetadata {
|
|
@@ -25,4 +25,4 @@ export declare function buildMongooseSchema(target: any): MongooseSchemaMetadata
|
|
|
25
25
|
/**
|
|
26
26
|
* @ignore
|
|
27
27
|
*/
|
|
28
|
-
export declare function createSchemaTypeOptions
|
|
28
|
+
export declare function createSchemaTypeOptions(propEntity: JsonEntityStore): SchemaDefinitionProperty;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "mongoose";
|
|
2
|
-
import {
|
|
2
|
+
import { MongoosePreHookCB, MongooseSchemaOptions } from "../interfaces/MongooseSchemaOptions.js";
|
|
3
3
|
/**
|
|
4
4
|
* @ignore
|
|
5
5
|
*/
|
|
@@ -7,7 +7,7 @@ export declare function schemaOptions(target: any, options?: MongooseSchemaOptio
|
|
|
7
7
|
/**
|
|
8
8
|
* @ignore
|
|
9
9
|
*/
|
|
10
|
-
export declare function buildPreHook(fn: MongoosePreHookCB): (next:
|
|
10
|
+
export declare function buildPreHook(fn: MongoosePreHookCB): (next: any, arg1: any, arg2: any) => any;
|
|
11
11
|
/**
|
|
12
12
|
* @ignore
|
|
13
13
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StaticMethodDecorator } from "@tsed/core";
|
|
2
|
-
import { MongooseHookOptions, MongoosePostHookCB } from "../interfaces/MongooseSchemaOptions.js";
|
|
2
|
+
import { MongooseHookOptions, MongooseMethods, MongoosePostHookCB } from "../interfaces/MongooseSchemaOptions.js";
|
|
3
3
|
/**
|
|
4
4
|
* We can simply attach a `@PostHook` decorator to your model class and
|
|
5
5
|
* define the hook function like you normally would in Mongoose.
|
|
@@ -43,6 +43,6 @@ import { MongooseHookOptions, MongoosePostHookCB } from "../interfaces/MongooseS
|
|
|
43
43
|
* @mongoose
|
|
44
44
|
* @class
|
|
45
45
|
*/
|
|
46
|
-
export declare function PostHook<T = any>(method:
|
|
47
|
-
export declare function PostHook<T = any>(method:
|
|
48
|
-
export declare function PostHook<T = any>(method:
|
|
46
|
+
export declare function PostHook<T = any>(method: MongooseMethods, fn: MongoosePostHookCB<T>): ClassDecorator;
|
|
47
|
+
export declare function PostHook<T = any>(method: MongooseMethods, fn: MongoosePostHookCB<T>, options: MongooseHookOptions): ClassDecorator;
|
|
48
|
+
export declare function PostHook<T = any>(method: MongooseMethods, options: MongooseHookOptions): StaticMethodDecorator;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StaticMethodDecorator } from "@tsed/core";
|
|
2
|
+
import type { MongooseHookOptions, MongooseMethods, MongoosePreHookCB } from "../interfaces/MongooseSchemaOptions.js";
|
|
2
3
|
/**
|
|
3
4
|
*
|
|
4
5
|
* We can simply attach a `@PreHook` decorator to your model class and
|
|
@@ -39,11 +40,12 @@ import { MongooseHookOptions, MongoosePreHookCB } from "../interfaces/MongooseSc
|
|
|
39
40
|
*
|
|
40
41
|
* This will execute the pre-save hook each time a `CarModel` document is saved.
|
|
41
42
|
*
|
|
42
|
-
* @param {string} method
|
|
43
|
-
* @param fn
|
|
44
|
-
* @param options
|
|
45
43
|
* @returns {Function}
|
|
46
44
|
* @decorator
|
|
47
45
|
* @class
|
|
46
|
+
* @param method
|
|
47
|
+
* @param fn
|
|
48
|
+
* @param options
|
|
48
49
|
*/
|
|
49
|
-
export declare function PreHook<T = any>(method:
|
|
50
|
+
export declare function PreHook<T = any>(method: MongooseMethods, fn: MongoosePreHookCB<T>, options?: MongooseHookOptions): ClassDecorator;
|
|
51
|
+
export declare function PreHook<T = any>(method: MongooseMethods, options?: MongooseHookOptions): StaticMethodDecorator;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { type IndexOptions, Schema, SchemaOptions } from "mongoose";
|
|
2
2
|
import { MongooseDocument } from "./MongooseDocument.js";
|
|
3
|
+
export type MongooseMethod = "aggregate" | "bulkWrite" | "createCollection" | "save" | "insertMany" | "estimatedDocumentCount" | "countDocuments" | "deleteMany" | "distinct" | "find" | "findOne" | "findOneAndDelete" | "findOneAndReplace" | "findOneAndUpdate" | "replaceOne" | "updateMany" | "init" | "validate";
|
|
4
|
+
export type MongooseMethods = MongooseMethod | RegExp | MongooseMethod[];
|
|
3
5
|
export type MongooseNextCB = (err?: Error) => void;
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export type MongooseHookPromised<T = any> = (doc: T | MongooseDocument<T>) => Promise<void> | void;
|
|
10
|
-
export type MongoosePreHookCB<T = any> = ((doc: T | MongooseDocument<T>, next: MongooseNextCB) => void) | MongooseHookPromised;
|
|
11
|
-
export type MongoosePostHookCB<T = any> = ((doc: T | MongooseDocument<T>, error: Error, next: MongooseNextCB) => void) | ((doc: T | MongooseDocument<T>, error: Error) => Promise<void> | void) | ((doc: T | MongooseDocument<T>, next: MongooseNextCB) => void) | MongooseHookPromised;
|
|
6
|
+
export type MongooseHookOptions = Record<string, unknown>;
|
|
7
|
+
export type MongooseHookPromised<T = any> = (doc: T | MongooseDocument<T>) => Promise<void>;
|
|
8
|
+
export type MongoosePreHookCB<T = any> = (doc: T | MongooseDocument<T>, ...args: unknown[]) => Promise<void> | void;
|
|
9
|
+
export type MongoosePostHookCB<T = any> = (doc: T | MongooseDocument<T>, ...args: unknown[]) => Promise<void> | void;
|
|
12
10
|
export interface MongoosePreHook<T = any> {
|
|
13
|
-
method:
|
|
11
|
+
method: MongooseMethods;
|
|
14
12
|
fn: MongoosePreHookCB<T>;
|
|
15
13
|
options?: MongooseHookOptions;
|
|
16
14
|
}
|
|
17
15
|
export interface MongoosePostHook<T = any> {
|
|
18
|
-
method:
|
|
16
|
+
method: MongooseMethods;
|
|
19
17
|
fn: MongoosePostHookCB<T>;
|
|
20
18
|
options?: MongooseHookOptions;
|
|
21
19
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
2
|
import { JsonEntityStore } from "@tsed/schema";
|
|
3
|
-
import mongoose, { Schema, SchemaDefinition,
|
|
3
|
+
import mongoose, { Schema, SchemaDefinition, SchemaDefinitionProperty } from "mongoose";
|
|
4
4
|
import { MongooseSchemaOptions } from "../interfaces/MongooseSchemaOptions.js";
|
|
5
5
|
import { MongooseVirtualRefOptions } from "../interfaces/MongooseVirtualRefOptions.js";
|
|
6
6
|
export interface MongooseSchemaMetadata {
|
|
@@ -25,4 +25,4 @@ export declare function buildMongooseSchema(target: any): MongooseSchemaMetadata
|
|
|
25
25
|
/**
|
|
26
26
|
* @ignore
|
|
27
27
|
*/
|
|
28
|
-
export declare function createSchemaTypeOptions
|
|
28
|
+
export declare function createSchemaTypeOptions(propEntity: JsonEntityStore): SchemaDefinitionProperty;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "mongoose";
|
|
2
|
-
import {
|
|
2
|
+
import { MongoosePreHookCB, MongooseSchemaOptions } from "../interfaces/MongooseSchemaOptions.js";
|
|
3
3
|
/**
|
|
4
4
|
* @ignore
|
|
5
5
|
*/
|
|
@@ -7,7 +7,7 @@ export declare function schemaOptions(target: any, options?: MongooseSchemaOptio
|
|
|
7
7
|
/**
|
|
8
8
|
* @ignore
|
|
9
9
|
*/
|
|
10
|
-
export declare function buildPreHook(fn: MongoosePreHookCB): (next:
|
|
10
|
+
export declare function buildPreHook(fn: MongoosePreHookCB): (next: any, arg1: any, arg2: any) => any;
|
|
11
11
|
/**
|
|
12
12
|
* @ignore
|
|
13
13
|
*/
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/mongoose",
|
|
3
3
|
"description": "Mongoose package for Ts.ED framework",
|
|
4
4
|
"type": "commonjs",
|
|
5
|
-
"version": "7.85.
|
|
5
|
+
"version": "7.85.3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tsed",
|
|
8
8
|
"mongoose",
|
|
@@ -34,27 +34,27 @@
|
|
|
34
34
|
"tslib": "2.6.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@tsed/ajv": "7.85.
|
|
38
|
-
"@tsed/barrels": "7.85.
|
|
39
|
-
"@tsed/core": "7.85.
|
|
40
|
-
"@tsed/di": "7.85.
|
|
41
|
-
"@tsed/json-mapper": "7.85.
|
|
37
|
+
"@tsed/ajv": "7.85.3",
|
|
38
|
+
"@tsed/barrels": "7.85.3",
|
|
39
|
+
"@tsed/core": "7.85.3",
|
|
40
|
+
"@tsed/di": "7.85.3",
|
|
41
|
+
"@tsed/json-mapper": "7.85.3",
|
|
42
42
|
"@tsed/logger": "^6.7.8",
|
|
43
|
-
"@tsed/schema": "7.85.
|
|
44
|
-
"@tsed/testcontainers-mongo": "7.85.
|
|
45
|
-
"@tsed/typescript": "7.85.
|
|
43
|
+
"@tsed/schema": "7.85.3",
|
|
44
|
+
"@tsed/testcontainers-mongo": "7.85.3",
|
|
45
|
+
"@tsed/typescript": "7.85.3",
|
|
46
46
|
"eslint": "^8.57.0",
|
|
47
47
|
"mongoose": "6.12.7",
|
|
48
48
|
"typescript": "4.9.5",
|
|
49
49
|
"vitest": "2.0.4"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@tsed/ajv": "7.85.
|
|
53
|
-
"@tsed/core": "7.85.
|
|
54
|
-
"@tsed/di": "7.85.
|
|
55
|
-
"@tsed/json-mapper": "7.85.
|
|
52
|
+
"@tsed/ajv": "7.85.3",
|
|
53
|
+
"@tsed/core": "7.85.3",
|
|
54
|
+
"@tsed/di": "7.85.3",
|
|
55
|
+
"@tsed/json-mapper": "7.85.3",
|
|
56
56
|
"@tsed/logger": "^6.7.8",
|
|
57
|
-
"@tsed/schema": "7.85.
|
|
57
|
+
"@tsed/schema": "7.85.3",
|
|
58
58
|
"mongoose": ">=6.0.0"
|
|
59
59
|
},
|
|
60
60
|
"repository": "https://github.com/tsedio/tsed",
|
|
@@ -63,5 +63,8 @@
|
|
|
63
63
|
},
|
|
64
64
|
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/orm/mongoose",
|
|
65
65
|
"author": "Romain Lenzotti",
|
|
66
|
-
"license": "MIT"
|
|
66
|
+
"license": "MIT",
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"tag": "v7-latest"
|
|
69
|
+
}
|
|
67
70
|
}
|