@foxiko/nest-common 0.0.31 → 0.0.32
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.
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.FetchedEntity = exports.CrudEntityInterceptor = void 0;
|
|
4
13
|
exports.InjectCrudEntity = InjectCrudEntity;
|
|
5
14
|
const common_1 = require("@nestjs/common");
|
|
6
15
|
const constants_1 = require("../constants");
|
|
7
|
-
const mongodb_1 = require("mongodb");
|
|
8
16
|
const typeorm_1 = require("typeorm");
|
|
17
|
+
const mongodb_1 = require("mongodb");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
9
19
|
const entity_name_util_1 = require("../utils/entity-name.util");
|
|
10
|
-
class CrudEntityInterceptor {
|
|
20
|
+
let CrudEntityInterceptor = class CrudEntityInterceptor {
|
|
11
21
|
constructor(dataSource) {
|
|
12
22
|
this.dataSource = dataSource;
|
|
13
23
|
}
|
|
@@ -28,7 +38,7 @@ class CrudEntityInterceptor {
|
|
|
28
38
|
}
|
|
29
39
|
let parsedId = idValue;
|
|
30
40
|
const primaryKeyType = Reflect.getMetadata('design:type', options.entity.prototype, primaryKey);
|
|
31
|
-
if (primaryKeyType ===
|
|
41
|
+
if (primaryKeyType === typeorm_2.ObjectId) {
|
|
32
42
|
try {
|
|
33
43
|
parsedId = new mongodb_1.ObjectId(idValue);
|
|
34
44
|
}
|
|
@@ -59,8 +69,12 @@ class CrudEntityInterceptor {
|
|
|
59
69
|
req[constants_1.FETCHED_ENTITY_KEY] = entity;
|
|
60
70
|
return next.handle();
|
|
61
71
|
}
|
|
62
|
-
}
|
|
72
|
+
};
|
|
63
73
|
exports.CrudEntityInterceptor = CrudEntityInterceptor;
|
|
74
|
+
exports.CrudEntityInterceptor = CrudEntityInterceptor = __decorate([
|
|
75
|
+
(0, common_1.Injectable)(),
|
|
76
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
77
|
+
], CrudEntityInterceptor);
|
|
64
78
|
function InjectCrudEntity() {
|
|
65
79
|
return (0, common_1.UseInterceptors)(CrudEntityInterceptor);
|
|
66
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-entity.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/inject-entity.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inject-entity.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/inject-entity.decorator.ts"],"names":[],"mappings":";;;;;;;;;;;;AA6FA,4CAEC;AA/FD,2CAUwB;AAExB,4CAAyE;AAEzE,qCAAsE;AACtE,qCAAoD;AACpD,qCAAmC;AACnC,gEAA2D;AAGpD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD,KAAK,CAAC,SAAS,CAAC,OAAyB,EAAE,IAAiB;QAC1D,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAChD,MAAM,MAAM,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