@bearei/server-common 1.3.0 → 1.3.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/dist/app.entity.d.ts
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { BaseEntity
|
|
1
|
+
import { BaseEntity } from 'typeorm';
|
|
2
2
|
import type { EntityStatus } from './app.interface';
|
|
3
3
|
export declare class CommonEntity extends BaseEntity {
|
|
4
4
|
primaryId: number;
|
|
5
5
|
id: string;
|
|
6
6
|
entityStatus: EntityStatus;
|
|
7
|
+
version: number;
|
|
7
8
|
createdAt: Date;
|
|
8
9
|
updatedAt: Date;
|
|
9
|
-
version: number;
|
|
10
|
-
sort: number;
|
|
11
10
|
deletedAt: Date;
|
|
12
11
|
beforeInsert(): void;
|
|
13
|
-
afterInsert(): void;
|
|
14
12
|
beforeUpdate(): void;
|
|
15
13
|
beforeSoftRemove(): void;
|
|
16
14
|
beforeRecover(): void;
|
|
17
15
|
}
|
|
18
|
-
export declare class CommonEntitySubscriber implements EntitySubscriberInterface<CommonEntity> {
|
|
19
|
-
listenTo(): typeof CommonEntity;
|
|
20
|
-
afterInsert(event: InsertEvent<CommonEntity>): void;
|
|
21
|
-
}
|
package/dist/app.entity.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.CommonEntity = void 0;
|
|
16
16
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
17
17
|
const nanoid_1 = require("nanoid");
|
|
18
18
|
const typeorm_1 = require("typeorm");
|
|
@@ -21,18 +21,14 @@ let CommonEntity = class CommonEntity extends typeorm_1.BaseEntity {
|
|
|
21
21
|
primaryId;
|
|
22
22
|
id;
|
|
23
23
|
entityStatus;
|
|
24
|
+
version;
|
|
24
25
|
createdAt;
|
|
25
26
|
updatedAt;
|
|
26
|
-
version;
|
|
27
|
-
sort;
|
|
28
27
|
deletedAt;
|
|
29
28
|
beforeInsert() {
|
|
30
29
|
this.createdAt = dayjs_1.default.utc().toDate();
|
|
31
30
|
this.id = (0, nanoid_1.nanoid)();
|
|
32
31
|
}
|
|
33
|
-
afterInsert() {
|
|
34
|
-
this.sort = this.primaryId;
|
|
35
|
-
}
|
|
36
32
|
beforeUpdate() {
|
|
37
33
|
this.updatedAt = dayjs_1.default.utc().toDate();
|
|
38
34
|
}
|
|
@@ -63,6 +59,10 @@ __decorate([
|
|
|
63
59
|
}),
|
|
64
60
|
__metadata("design:type", String)
|
|
65
61
|
], CommonEntity.prototype, "entityStatus", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, typeorm_1.VersionColumn)({ nullable: false }),
|
|
64
|
+
__metadata("design:type", Number)
|
|
65
|
+
], CommonEntity.prototype, "version", void 0);
|
|
66
66
|
__decorate([
|
|
67
67
|
(0, typeorm_1.CreateDateColumn)({ nullable: false, type: 'timestamptz' }),
|
|
68
68
|
__metadata("design:type", Date)
|
|
@@ -71,14 +71,6 @@ __decorate([
|
|
|
71
71
|
(0, typeorm_1.UpdateDateColumn)({ nullable: false, type: 'timestamptz' }),
|
|
72
72
|
__metadata("design:type", Date)
|
|
73
73
|
], CommonEntity.prototype, "updatedAt", void 0);
|
|
74
|
-
__decorate([
|
|
75
|
-
(0, typeorm_1.VersionColumn)({ nullable: false }),
|
|
76
|
-
__metadata("design:type", Number)
|
|
77
|
-
], CommonEntity.prototype, "version", void 0);
|
|
78
|
-
__decorate([
|
|
79
|
-
(0, typeorm_1.Column)({ nullable: false, type: 'int', default: 0 }),
|
|
80
|
-
__metadata("design:type", Number)
|
|
81
|
-
], CommonEntity.prototype, "sort", void 0);
|
|
82
74
|
__decorate([
|
|
83
75
|
(0, typeorm_1.DeleteDateColumn)({ default: null, type: 'timestamptz' }),
|
|
84
76
|
__metadata("design:type", Date)
|
|
@@ -89,12 +81,6 @@ __decorate([
|
|
|
89
81
|
__metadata("design:paramtypes", []),
|
|
90
82
|
__metadata("design:returntype", void 0)
|
|
91
83
|
], CommonEntity.prototype, "beforeInsert", null);
|
|
92
|
-
__decorate([
|
|
93
|
-
(0, typeorm_1.AfterInsert)(),
|
|
94
|
-
__metadata("design:type", Function),
|
|
95
|
-
__metadata("design:paramtypes", []),
|
|
96
|
-
__metadata("design:returntype", void 0)
|
|
97
|
-
], CommonEntity.prototype, "afterInsert", null);
|
|
98
84
|
__decorate([
|
|
99
85
|
(0, typeorm_1.BeforeUpdate)(),
|
|
100
86
|
__metadata("design:type", Function),
|
|
@@ -115,22 +101,6 @@ __decorate([
|
|
|
115
101
|
], CommonEntity.prototype, "beforeRecover", null);
|
|
116
102
|
exports.CommonEntity = CommonEntity = __decorate([
|
|
117
103
|
(0, typeorm_1.Index)(['createdAt']),
|
|
118
|
-
(0, typeorm_1.Index)(['id'], { unique: true })
|
|
119
|
-
(0, typeorm_1.Index)(['sort'])
|
|
104
|
+
(0, typeorm_1.Index)(['id'], { unique: true })
|
|
120
105
|
], CommonEntity);
|
|
121
|
-
let CommonEntitySubscriber = class CommonEntitySubscriber {
|
|
122
|
-
listenTo() {
|
|
123
|
-
return CommonEntity;
|
|
124
|
-
}
|
|
125
|
-
afterInsert(event) {
|
|
126
|
-
const { entity, manager } = event;
|
|
127
|
-
if (entity.primaryId) {
|
|
128
|
-
manager.update(CommonEntity, { primaryId: entity.primaryId }, { sort: entity.primaryId });
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
exports.CommonEntitySubscriber = CommonEntitySubscriber;
|
|
133
|
-
exports.CommonEntitySubscriber = CommonEntitySubscriber = __decorate([
|
|
134
|
-
(0, typeorm_1.EventSubscriber)()
|
|
135
|
-
], CommonEntitySubscriber);
|
|
136
106
|
//# sourceMappingURL=app.entity.js.map
|
package/dist/app.entity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.entity.js","sourceRoot":"","sources":["../src/app.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAyB;AACzB,mCAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"app.entity.js","sourceRoot":"","sources":["../src/app.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAyB;AACzB,mCAA6B;AAC7B,qCAagB;AAChB,yCAAwC;AAKjC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,oBAAU;IAE3C,SAAS,CAAQ;IAGjB,EAAE,CAAQ;IASV,YAAY,CAAc;IAG1B,OAAO,CAAQ;IAGf,SAAS,CAAM;IAGf,SAAS,CAAM;IAGf,SAAS,CAAM;IAGf,YAAY;QACX,IAAI,CAAC,SAAS,GAAG,eAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAA;QACrC,IAAI,CAAC,EAAE,GAAG,IAAA,eAAM,GAAE,CAAA;IACnB,CAAC;IAGD,YAAY;QACX,IAAI,CAAC,SAAS,GAAG,eAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAA;IACtC,CAAC;IAGD,gBAAgB;QACf,IAAI,CAAC,SAAS,GAAG,eAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAA;QACrC,IAAI,CAAC,YAAY,GAAG,wBAAa,CAAC,YAAY,CAAA;IAC/C,CAAC;IAGD,aAAa;QACZ,IAAI,CAAC,YAAY,GAAG,wBAAa,CAAC,QAAQ,CAAA;IAC3C,CAAC;CACD,CAAA;AAjDY,oCAAY;AAExB;IADC,IAAA,gCAAsB,EAAC,UAAU,CAAC;;+CAClB;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAC,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAC,CAAC;;wCAC7C;AASV;IAPC,IAAA,gBAAM,EAAC;QACP,OAAO,EAAE,wBAAa,CAAC,QAAQ;QAC/B,IAAI,EAAE,wBAAa;QACnB,QAAQ,EAAE,kBAAkB;QAC5B,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,MAAM;KACZ,CAAC;;kDACwB;AAG1B;IADC,IAAA,uBAAa,EAAC,EAAC,QAAQ,EAAE,KAAK,EAAC,CAAC;;6CAClB;AAGf;IADC,IAAA,0BAAgB,EAAC,EAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAC,CAAC;8BAC9C,IAAI;+CAAA;AAGf;IADC,IAAA,0BAAgB,EAAC,EAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAC,CAAC;8BAC9C,IAAI;+CAAA;AAGf;IADC,IAAA,0BAAgB,EAAC,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAC,CAAC;8BAC5C,IAAI;+CAAA;AAGf;IADC,IAAA,sBAAY,GAAE;;;;gDAId;AAGD;IADC,IAAA,sBAAY,GAAE;;;;gDAGd;AAGD;IADC,IAAA,0BAAgB,GAAE;;;;oDAIlB;AAGD;IADC,IAAA,uBAAa,GAAE;;;;iDAGf;uBAhDW,YAAY;IAFxB,IAAA,eAAK,EAAC,CAAC,WAAW,CAAC,CAAC;IACpB,IAAA,eAAK,EAAC,CAAC,IAAI,CAAC,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;GACjB,YAAY,CAiDxB"}
|
|
@@ -11,7 +11,6 @@ exports.DatabaseModule = void 0;
|
|
|
11
11
|
const common_1 = require("@nestjs/common");
|
|
12
12
|
const config_1 = require("@nestjs/config");
|
|
13
13
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
14
|
-
const app_entity_1 = require("../app.entity");
|
|
15
14
|
let DatabaseModule = DatabaseModule_1 = class DatabaseModule {
|
|
16
15
|
static forRoot(options = {}) {
|
|
17
16
|
return {
|
|
@@ -29,7 +28,6 @@ let DatabaseModule = DatabaseModule_1 = class DatabaseModule {
|
|
|
29
28
|
logging: false,
|
|
30
29
|
password: configService.get('database.password'),
|
|
31
30
|
port: configService.get('database.port'),
|
|
32
|
-
subscribers: [app_entity_1.CommonEntitySubscriber],
|
|
33
31
|
synchronize: false,
|
|
34
32
|
type: configService.get('database.type'),
|
|
35
33
|
username: configService.get('database.username'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.module.js","sourceRoot":"","sources":["../../src/database/database.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AACpD,2CAA0D;AAC1D,6CAAmE;
|
|
1
|
+
{"version":3,"file":"database.module.js","sourceRoot":"","sources":["../../src/database/database.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AACpD,2CAA0D;AAC1D,6CAAmE;AAG5D,IAAM,cAAc,sBAApB,MAAM,cAAc;IAC1B,MAAM,CAAC,OAAO,CAAC,UAAyC,EAAE;QACzD,OAAO;YACN,MAAM,EAAE,gBAAc;YACtB,OAAO,EAAE;gBACR,qBAAY;gBACZ,uBAAa,CAAC,YAAY,CAAC;oBAC1B,OAAO,EAAE,CAAC,qBAAY,CAAC;oBACvB,MAAM,EAAE,CAAC,sBAAa,CAAC;oBACvB,UAAU,EAAE,KAAK,EAAE,aAA4B,EAAE,EAAE;wBAClD,MAAM,UAAU,GAAG;4BAClB,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,mBAAmB,CAAC;4BAChD,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,mBAAmB,CAAC;4BAChD,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC;4BACxC,OAAO,EAAE,KAAK;4BACd,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,mBAAmB,CAAC;4BAChD,IAAI,EAAE,aAAa,CAAC,GAAG,CAAS,eAAe,CAAC;4BAChD,WAAW,EAAE,KAAK;4BAClB,IAAI,EAAE,aAAa,CAAC,GAAG,CAAa,eAAe,CAAC;4BACpD,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,mBAAmB,CAAC;4BAChD,KAAK,EAAE;gCACN,uBAAuB,EAAE,IAAI;gCAC7B,iBAAiB,EAAE,KAAK;gCACxB,GAAG,EAAE,EAAE;6BACP;4BACD,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI;gCAC5C,MAAM,EAAE,kBAAkB;gCAC1B,OAAO,EAAE,IAAI;6BACb,CAAC;4BACF,GAAG,OAAO;yBACc,CAAA;wBAEzB,OAAO,UAAU,CAAA;oBAClB,CAAC;iBACD,CAAC;aACF;SACD,CAAA;IACF,CAAC;CACD,CAAA;AAtCY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,cAAc,CAsC1B"}
|