zync-nest-data-module 1.0.0 → 1.1.39
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/.prettierrc.json +23 -0
- package/README.md +226 -439
- package/dist/backup/backup.module.d.ts +1 -1
- package/dist/backup/backup.module.js +6 -6
- package/dist/backup/backup.module.js.map +1 -1
- package/dist/backup/backup.service.d.ts +1 -0
- package/dist/backup/backup.service.js +41 -18
- package/dist/backup/backup.service.js.map +1 -1
- package/dist/backup/backup.worker.d.ts +1 -0
- package/dist/backup/backup.worker.js +43 -0
- package/dist/backup/backup.worker.js.map +1 -0
- package/dist/base/dto.d.ts +19 -0
- package/dist/base/dto.js +86 -0
- package/dist/base/dto.js.map +1 -0
- package/dist/base/index.d.ts +2 -0
- package/dist/base/index.js +19 -0
- package/dist/base/index.js.map +1 -0
- package/dist/base/resolver.d.ts +6 -0
- package/dist/base/resolver.js +54 -0
- package/dist/base/resolver.js.map +1 -0
- package/dist/database/database.module.d.ts +5 -1
- package/dist/database/database.module.js +24 -19
- package/dist/database/database.module.js.map +1 -1
- package/dist/database/database.repository.d.ts +3 -2
- package/dist/database/database.repository.js +32 -25
- package/dist/database/database.repository.js.map +1 -1
- package/dist/database/database.scheme.d.ts +2 -8
- package/dist/database/database.scheme.js +2 -2
- package/dist/database/database.scheme.js.map +1 -1
- package/dist/database/database.service.d.ts +5 -3
- package/dist/database/database.service.js +44 -17
- package/dist/database/database.service.js.map +1 -1
- package/dist/database/database.transaction.d.ts +7 -7
- package/dist/database/database.transaction.js +61 -50
- package/dist/database/database.transaction.js.map +1 -1
- package/dist/database/database.uniqueId.d.ts +8 -3
- package/dist/database/database.uniqueId.js +26 -7
- package/dist/database/database.uniqueId.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/redis/index.d.ts +2 -0
- package/dist/redis/index.js +19 -0
- package/dist/redis/index.js.map +1 -0
- package/dist/redis/redis.module.d.ts +2 -0
- package/dist/redis/redis.module.js +42 -0
- package/dist/redis/redis.module.js.map +1 -0
- package/dist/redis/redis.service.d.ts +27 -0
- package/dist/redis/redis.service.js +126 -0
- package/dist/redis/redis.service.js.map +1 -0
- package/dist/service/service.d.ts +2 -2
- package/dist/service/service.js +42 -56
- package/dist/service/service.js.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +43 -25
- package/dist/index.js.map +0 -1
- package/libs/src/app.controller.ts +0 -84
- package/libs/src/app.module.ts +0 -31
- package/libs/src/backup/backup.config.ts +0 -45
- package/libs/src/backup/backup.interface.ts +0 -21
- package/libs/src/backup/backup.module.ts +0 -11
- package/libs/src/backup/backup.service.ts +0 -283
- package/libs/src/backup/index.ts +0 -4
- package/libs/src/database/database.module.ts +0 -26
- package/libs/src/database/database.repository.ts +0 -358
- package/libs/src/database/database.scheme.ts +0 -128
- package/libs/src/database/database.service.ts +0 -36
- package/libs/src/database/database.sync.ts +0 -61
- package/libs/src/database/database.transaction.ts +0 -101
- package/libs/src/database/database.uniqueId.ts +0 -59
- package/libs/src/database/database.utils.ts +0 -99
- package/libs/src/database/index.ts +0 -8
- package/libs/src/index.ts +0 -3
- package/libs/src/main.ts +0 -62
- package/libs/src/service/index.ts +0 -1
- package/libs/src/service/service.ts +0 -201
- package/libs/src/test/test.dto.ts +0 -41
- package/libs/src/test/test.module.ts +0 -20
- package/libs/src/test/test.repository.ts +0 -44
- package/libs/src/test/test.resolver.ts +0 -44
- package/libs/src/test/test.schema.ts +0 -21
- package/libs/src/test/test.service.ts +0 -19
- package/libs/tsconfig.lib.json +0 -19
- package/tsconfig.json +0 -29
- package/update-links.js +0 -159
|
@@ -11,13 +11,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var _a;
|
|
15
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
15
|
exports.ApUniqueIdGenerator = exports.UniqueIdSchema = exports.UniqueId = void 0;
|
|
17
16
|
const common_1 = require("@nestjs/common");
|
|
18
17
|
const mongoose_1 = require("@nestjs/mongoose");
|
|
19
18
|
const mongoose_2 = require("mongoose");
|
|
20
|
-
const
|
|
19
|
+
const database_module_1 = require("./database.module");
|
|
20
|
+
const core_1 = require("@nestjs/core");
|
|
21
21
|
let UniqueId = class UniqueId {
|
|
22
22
|
};
|
|
23
23
|
exports.UniqueId = UniqueId;
|
|
@@ -34,11 +34,29 @@ exports.UniqueId = UniqueId = __decorate([
|
|
|
34
34
|
], UniqueId);
|
|
35
35
|
exports.UniqueIdSchema = mongoose_1.SchemaFactory.createForClass(UniqueId);
|
|
36
36
|
let ApUniqueIdGenerator = class ApUniqueIdGenerator {
|
|
37
|
-
constructor(
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
37
|
+
constructor(connName, moduleRef) {
|
|
38
|
+
this.connName = connName;
|
|
39
|
+
this.moduleRef = moduleRef;
|
|
40
|
+
}
|
|
41
|
+
onModuleInit() {
|
|
42
|
+
this.ensureModelInitialized();
|
|
43
|
+
}
|
|
44
|
+
ensureModelInitialized() {
|
|
45
|
+
if (!this.model) {
|
|
46
|
+
this.model = this.connName
|
|
47
|
+
? this.moduleRef.get((0, mongoose_1.getModelToken)(UniqueId.name, this.connName), {
|
|
48
|
+
strict: false
|
|
49
|
+
})
|
|
50
|
+
: this.moduleRef.get((0, mongoose_1.getModelToken)(UniqueId.name), {
|
|
51
|
+
strict: false
|
|
52
|
+
});
|
|
53
|
+
if (!this.model) {
|
|
54
|
+
throw new Error(`UniqueId model is not initialized. Please ensure MongooseModule.forFeature includes UniqueId schema with connection name: ${this.connName || "default"}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
40
57
|
}
|
|
41
58
|
async getNextUniqueId(key = "uniqueId") {
|
|
59
|
+
this.ensureModelInitialized();
|
|
42
60
|
const result = await this.model.findOneAndUpdate({ key }, { $inc: { sequence_value: 1 } }, { returnDocument: "after", upsert: true });
|
|
43
61
|
if (!result) {
|
|
44
62
|
throw new Error("Failed to generate unique ID");
|
|
@@ -49,6 +67,7 @@ let ApUniqueIdGenerator = class ApUniqueIdGenerator {
|
|
|
49
67
|
return new mongoose_2.Types.ObjectId().toString();
|
|
50
68
|
}
|
|
51
69
|
async seed() {
|
|
70
|
+
this.ensureModelInitialized();
|
|
52
71
|
const keys = [{ key: "uniqueId", sequence_value: 1001 }];
|
|
53
72
|
for await (const key of keys) {
|
|
54
73
|
const exist = await this.model.findOne({ key: key.key });
|
|
@@ -62,7 +81,7 @@ let ApUniqueIdGenerator = class ApUniqueIdGenerator {
|
|
|
62
81
|
exports.ApUniqueIdGenerator = ApUniqueIdGenerator;
|
|
63
82
|
exports.ApUniqueIdGenerator = ApUniqueIdGenerator = __decorate([
|
|
64
83
|
(0, common_1.Injectable)({}),
|
|
65
|
-
__param(0, (0,
|
|
66
|
-
__metadata("design:paramtypes", [
|
|
84
|
+
__param(0, (0, common_1.Inject)(database_module_1.CONNECTION_NAME)),
|
|
85
|
+
__metadata("design:paramtypes", [String, core_1.ModuleRef])
|
|
67
86
|
], ApUniqueIdGenerator);
|
|
68
87
|
//# sourceMappingURL=database.uniqueId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.uniqueId.js","sourceRoot":"","sources":["../../libs/src/database/database.uniqueId.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"database.uniqueId.js","sourceRoot":"","sources":["../../libs/src/database/database.uniqueId.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAkE;AAClE,+CAA2F;AAC3F,uCAA2C;AAE3C,uDAAoD;AACpD,uCAAyC;AAGlC,IAAM,QAAQ,GAAd,MAAM,QAAQ;CAMpB,CAAA;AANY,4BAAQ;AAGnB;IADC,IAAA,eAAI,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;qCACX;AAEZ;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C,EAAE,EAAE,EAC/B,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAC1C,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,MAAM,CAAC,cAAc,CAAC;IAC/B,CAAC;IAEM,WAAW;QAChB,OAAO,IAAI,gBAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;IACzC,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAE9B,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;QAEzD,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YAC7B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;YAEzD,IAAI,KAAK,EAAE,CAAC;gBACV,SAAS;YACX,CAAC;YACD,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF,CAAA;AAnEY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,EAAC,EAAE,CAAC;IAIA,WAAA,IAAA,eAAM,EAAC,iCAAe,CAAC,CAAA;6CAAgE,gBAAS;GAHlG,mBAAmB,CAmE/B"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,4 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./backup"), exports);
|
|
18
18
|
__exportStar(require("./database"), exports);
|
|
19
19
|
__exportStar(require("./service"), exports);
|
|
20
|
+
__exportStar(require("./base"), exports);
|
|
21
|
+
__exportStar(require("./redis"), exports);
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./redis.service"), exports);
|
|
18
|
+
__exportStar(require("./redis.module"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../libs/src/redis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,iDAA+B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RedisModule = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const config_1 = require("@nestjs/config");
|
|
15
|
+
const ioredis_1 = __importDefault(require("ioredis"));
|
|
16
|
+
let RedisModule = class RedisModule {
|
|
17
|
+
};
|
|
18
|
+
exports.RedisModule = RedisModule;
|
|
19
|
+
exports.RedisModule = RedisModule = __decorate([
|
|
20
|
+
(0, common_1.Global)(),
|
|
21
|
+
(0, common_1.Module)({
|
|
22
|
+
imports: [config_1.ConfigModule],
|
|
23
|
+
providers: [
|
|
24
|
+
{
|
|
25
|
+
provide: "REDIS_CLIENT",
|
|
26
|
+
useFactory: async () => {
|
|
27
|
+
const client = new ioredis_1.default({
|
|
28
|
+
host: process.env.redis_host || "127.0.0.1",
|
|
29
|
+
port: Number(process.env.redis_port) || 6379,
|
|
30
|
+
password: process.env.redis_password || undefined,
|
|
31
|
+
db: Number(process.env.redis_database) || 0
|
|
32
|
+
});
|
|
33
|
+
client.on("connect", () => console.log("✅ Redis connected"));
|
|
34
|
+
client.on("error", (err) => console.error("❌ Redis error:", err));
|
|
35
|
+
return client;
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
exports: ["REDIS_CLIENT"]
|
|
40
|
+
})
|
|
41
|
+
], RedisModule);
|
|
42
|
+
//# sourceMappingURL=redis.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.module.js","sourceRoot":"","sources":["../../libs/src/redis/redis.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,2CAAgD;AAChD,2CAA8C;AAC9C,sDAA4B;AAyBrB,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAI,CAAA;AAAf,kCAAW;sBAAX,WAAW;IAvBvB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,qBAAY,CAAC;QACvB,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,cAAc;gBACvB,UAAU,EAAE,KAAK,IAAI,EAAE;oBACrB,MAAM,MAAM,GAAG,IAAI,iBAAK,CAAC;wBACvB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,WAAW;wBAC3C,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI;wBAC5C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,SAAS;wBACjD,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC;qBAC5C,CAAC,CAAC;oBAEH,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC;oBAC7D,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,CAAC;oBAElE,OAAO,MAAM,CAAC;gBAChB,CAAC;aACF;SACF;QACD,OAAO,EAAE,CAAC,cAAc,CAAC;KAC1B,CAAC;GACW,WAAW,CAAI"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RedisPubSub } from "graphql-redis-subscriptions";
|
|
2
|
+
import { EntityData, Repository, Schema, Search } from "redis-om";
|
|
3
|
+
import { IPageParams } from "../database/database.scheme";
|
|
4
|
+
export declare abstract class RedisService<T extends EntityData> extends RedisPubSub {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
readonly baseKey: string;
|
|
7
|
+
private redisOmClient;
|
|
8
|
+
constructor();
|
|
9
|
+
abstract cacheKey: string;
|
|
10
|
+
protected abstract buildQuery(search: Search, query: any): Search;
|
|
11
|
+
protected abstract mapSchema(): Record<string, any>;
|
|
12
|
+
protected repository(): Promise<Repository<T>>;
|
|
13
|
+
private createSchema;
|
|
14
|
+
private getRedisOmClient;
|
|
15
|
+
getRepository(schema: Schema<any>): Promise<Repository<any>>;
|
|
16
|
+
create(data: Partial<T> | T): Promise<T>;
|
|
17
|
+
update(_id: string, data: Partial<T> | T): Promise<T>;
|
|
18
|
+
delete(id: string): Promise<boolean>;
|
|
19
|
+
findById(_id: string): Promise<T>;
|
|
20
|
+
getEntityId(_id: string): Promise<string>;
|
|
21
|
+
findOne(query: Partial<T>): Promise<T>;
|
|
22
|
+
find(query: Partial<T>): Promise<T[]>;
|
|
23
|
+
page(query: Partial<T> & IPageParams): Promise<{
|
|
24
|
+
totalRecords: number;
|
|
25
|
+
data: Array<Partial<T>>;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
};
|
|
11
|
+
var RedisService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.RedisService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const graphql_redis_subscriptions_1 = require("graphql-redis-subscriptions");
|
|
16
|
+
const redis_om_1 = require("redis-om");
|
|
17
|
+
let RedisService = RedisService_1 = class RedisService extends graphql_redis_subscriptions_1.RedisPubSub {
|
|
18
|
+
constructor() {
|
|
19
|
+
super({
|
|
20
|
+
connection: {
|
|
21
|
+
host: process.env.redis_host || "localhost",
|
|
22
|
+
port: Number(process.env.redis_port) || 6379,
|
|
23
|
+
username: process.env.redis_username || undefined,
|
|
24
|
+
password: process.env.redis_password || undefined,
|
|
25
|
+
db: Number(process.env.redis_database) || 0
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
this.logger = new common_1.Logger(RedisService_1.name);
|
|
29
|
+
this.baseKey = `${process.env.redis_prefix || "zync_redis_data"}:`;
|
|
30
|
+
this.redisOmClient = null;
|
|
31
|
+
}
|
|
32
|
+
async repository() {
|
|
33
|
+
const schema = this.createSchema(this.cacheKey, this.mapSchema());
|
|
34
|
+
const repository = await this.getRepository(schema);
|
|
35
|
+
try {
|
|
36
|
+
await repository.createIndex();
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
this.logger.error(`Error creating index for ${this.cacheKey}: ${error}`);
|
|
40
|
+
}
|
|
41
|
+
return repository;
|
|
42
|
+
}
|
|
43
|
+
createSchema(name, fields) {
|
|
44
|
+
return new redis_om_1.Schema(`${this.baseKey}${name}`, fields, {
|
|
45
|
+
dataStructure: "JSON",
|
|
46
|
+
indexName: `${this.baseKey}${name}:idx`
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async getRedisOmClient() {
|
|
50
|
+
if (this.redisOmClient)
|
|
51
|
+
return this.redisOmClient;
|
|
52
|
+
const host = process.env.redis_host || "127.0.0.1";
|
|
53
|
+
const port = Number(process.env.redis_port) || 6379;
|
|
54
|
+
const password = process.env.redis_password;
|
|
55
|
+
const db = Number(process.env.redis_database) || 0;
|
|
56
|
+
const authSegment = password ? `:${password}@` : "";
|
|
57
|
+
const url = `redis://${authSegment}${host}:${port}/${db}`;
|
|
58
|
+
const client = new redis_om_1.Client();
|
|
59
|
+
await client.open(url);
|
|
60
|
+
this.redisOmClient = client;
|
|
61
|
+
return client;
|
|
62
|
+
}
|
|
63
|
+
async getRepository(schema) {
|
|
64
|
+
return (await this.getRedisOmClient()).fetchRepository(schema);
|
|
65
|
+
}
|
|
66
|
+
async create(data) {
|
|
67
|
+
const repository = await this.repository();
|
|
68
|
+
const _id = data._id;
|
|
69
|
+
const existing = _id ? await this.findById(_id) : null;
|
|
70
|
+
if (existing) {
|
|
71
|
+
return await this.update(_id, data);
|
|
72
|
+
}
|
|
73
|
+
return await repository.save(JSON.parse(JSON.stringify(data)));
|
|
74
|
+
}
|
|
75
|
+
async update(_id, data) {
|
|
76
|
+
const repository = await this.repository();
|
|
77
|
+
const entityId = await this.getEntityId(_id);
|
|
78
|
+
const entity = await repository.fetch(entityId);
|
|
79
|
+
Object.assign(entity, JSON.parse(JSON.stringify(data)));
|
|
80
|
+
return await repository.save(entity);
|
|
81
|
+
}
|
|
82
|
+
async delete(id) {
|
|
83
|
+
const repository = await this.repository();
|
|
84
|
+
await repository.remove(await this.getEntityId(id));
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
async findById(_id) {
|
|
88
|
+
const repository = await this.repository();
|
|
89
|
+
return await repository
|
|
90
|
+
.search()
|
|
91
|
+
.where("_id")
|
|
92
|
+
.eq(_id)
|
|
93
|
+
.return.first();
|
|
94
|
+
}
|
|
95
|
+
async getEntityId(_id) {
|
|
96
|
+
const repository = await this.repository();
|
|
97
|
+
return await repository
|
|
98
|
+
.search()
|
|
99
|
+
.where("_id")
|
|
100
|
+
.eq(_id)
|
|
101
|
+
.return.firstId();
|
|
102
|
+
}
|
|
103
|
+
async findOne(query) {
|
|
104
|
+
const repository = await this.repository();
|
|
105
|
+
const search = this.buildQuery(repository.search(), query);
|
|
106
|
+
return (await search.return.first());
|
|
107
|
+
}
|
|
108
|
+
async find(query) {
|
|
109
|
+
const repository = await this.repository();
|
|
110
|
+
const search = this.buildQuery(repository.search(), query);
|
|
111
|
+
return (await search.return.all());
|
|
112
|
+
}
|
|
113
|
+
async page(query) {
|
|
114
|
+
const repository = await this.repository();
|
|
115
|
+
const search = this.buildQuery(repository.search(), query);
|
|
116
|
+
const totalRecords = await search.return.count();
|
|
117
|
+
const data = (await search.return.page(query.skip, query.take));
|
|
118
|
+
return { totalRecords, data };
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
exports.RedisService = RedisService;
|
|
122
|
+
exports.RedisService = RedisService = RedisService_1 = __decorate([
|
|
123
|
+
(0, common_1.Injectable)(),
|
|
124
|
+
__metadata("design:paramtypes", [])
|
|
125
|
+
], RedisService);
|
|
126
|
+
//# sourceMappingURL=redis.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.service.js","sourceRoot":"","sources":["../../libs/src/redis/redis.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6EAA0D;AAC1D,uCAA6G;AAItG,IAAe,YAAY,oBAA3B,MAAe,YAAmC,SAAQ,yCAAW;IAK1E;QACE,KAAK,CAAC;YACJ,UAAU,EAAE;gBACV,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,WAAW;gBAC3C,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI;gBAC5C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,SAAS;gBACjD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,SAAS;gBACjD,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC;aAC5C;SACF,CAAC,CAAC;QAbY,WAAM,GAAG,IAAI,eA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CAAC,MAAM,CAAC,KAAK,EAAE,CAAM,CAAC;IAC5C,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,KAAiB;QACjC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;QAC3D,OAAO,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAQ,CAAC;IAC5C,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,KAA+B;QAC/C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAQ,CAAC;QACvE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAChC,CAAC;CACF,CAAA;AAlIqB,oCAAY;uBAAZ,YAAY;IADjC,IAAA,mBAAU,GAAE;;GACS,YAAY,CAkIjC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Logger } from "@nestjs/common";
|
|
1
2
|
import { AbstractBaseRepository, IPageParams, TransactionManager, TransactionSession } from "../database";
|
|
2
3
|
declare class BaseService<T> {
|
|
3
4
|
protected readonly repository: AbstractBaseRepository<any>;
|
|
@@ -20,11 +21,10 @@ declare class BaseService<T> {
|
|
|
20
21
|
export declare abstract class AbstractBaseService<T> extends BaseService<T> {
|
|
21
22
|
protected readonly repository: AbstractBaseRepository<any>;
|
|
22
23
|
readonly transactionManager: TransactionManager;
|
|
23
|
-
|
|
24
|
+
protected readonly logger: Logger;
|
|
24
25
|
constructor(repository: AbstractBaseRepository<any>, transactionManager: TransactionManager);
|
|
25
26
|
protected abstract setSession(session: any): void;
|
|
26
27
|
get session(): TransactionSession;
|
|
27
|
-
set session(v: TransactionSession);
|
|
28
28
|
get sessionName(): string;
|
|
29
29
|
withRetryTransaction(sessionName: string, operations: () => Promise<T>, retries?: number): Promise<T>;
|
|
30
30
|
private isRetryableError;
|
package/dist/service/service.js
CHANGED
|
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
+
var AbstractBaseService_1;
|
|
14
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
16
|
exports.AbstractBaseService = void 0;
|
|
16
17
|
const common_1 = require("@nestjs/common");
|
|
@@ -59,61 +60,59 @@ BaseService = __decorate([
|
|
|
59
60
|
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => database_1.AbstractBaseRepository))),
|
|
60
61
|
__metadata("design:paramtypes", [database_1.AbstractBaseRepository])
|
|
61
62
|
], BaseService);
|
|
62
|
-
let AbstractBaseService = class AbstractBaseService extends BaseService {
|
|
63
|
+
let AbstractBaseService = AbstractBaseService_1 = class AbstractBaseService extends BaseService {
|
|
63
64
|
constructor(repository, transactionManager) {
|
|
64
65
|
super(repository);
|
|
65
66
|
this.repository = repository;
|
|
66
67
|
this.transactionManager = transactionManager;
|
|
68
|
+
this.logger = new common_1.Logger(AbstractBaseService_1.name);
|
|
67
69
|
}
|
|
68
70
|
get session() {
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
set session(v) {
|
|
72
|
-
this._session = v;
|
|
73
|
-
this.repository.session = this._session;
|
|
71
|
+
return database_1.TransactionManager.getCurrentSession();
|
|
74
72
|
}
|
|
75
73
|
get sessionName() {
|
|
76
74
|
return this.transactionManager.sessionName;
|
|
77
75
|
}
|
|
78
76
|
async withRetryTransaction(sessionName, operations, retries = 3) {
|
|
79
|
-
if (
|
|
77
|
+
if (process.env.mongodb_transaction_enable !== "true")
|
|
80
78
|
return await operations();
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
if (this.isRetryableError(error)) {
|
|
93
|
-
console.log(`[TransactionManager] Retrying transaction...`);
|
|
94
|
-
await this.delay(1000 * (attempt + 1));
|
|
95
|
-
await this.transactionManager.abortTransaction();
|
|
96
|
-
await this.startSession(sessionName, true);
|
|
79
|
+
return this.transactionManager.run(async () => {
|
|
80
|
+
try {
|
|
81
|
+
await this.startSession(sessionName);
|
|
82
|
+
let attempt = 0;
|
|
83
|
+
while (attempt < retries) {
|
|
84
|
+
try {
|
|
85
|
+
const op = await operations();
|
|
86
|
+
await this.commitSession(sessionName);
|
|
87
|
+
return op;
|
|
97
88
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (this.isRetryableError(error)) {
|
|
91
|
+
this.logger.log(`[TransactionManager] Retrying transaction...`);
|
|
92
|
+
await this.delay(1000 * (attempt + 1));
|
|
93
|
+
await this.transactionManager.abortTransaction();
|
|
94
|
+
await this.startSession(sessionName, true);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
await this.abortSession();
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
101
100
|
}
|
|
101
|
+
attempt++;
|
|
102
102
|
}
|
|
103
|
-
attempt++;
|
|
104
103
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
finally {
|
|
112
|
-
console.log(`[TransactionManager] Finally block`);
|
|
113
|
-
if (this.transactionManager.sessionName == sessionName) {
|
|
114
|
-
await this.endSession();
|
|
104
|
+
catch (error) {
|
|
105
|
+
this.logger.error(`[TransactionManager] Error in transaction`, error);
|
|
106
|
+
await this.abortSession();
|
|
107
|
+
throw error;
|
|
115
108
|
}
|
|
116
|
-
|
|
109
|
+
finally {
|
|
110
|
+
this.logger.log(`[TransactionManager] Finally block`);
|
|
111
|
+
if (this.transactionManager.sessionName == sessionName) {
|
|
112
|
+
await this.endSession();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
117
116
|
}
|
|
118
117
|
isRetryableError(error) {
|
|
119
118
|
return (error.code === 112);
|
|
@@ -123,41 +122,28 @@ let AbstractBaseService = class AbstractBaseService extends BaseService {
|
|
|
123
122
|
}
|
|
124
123
|
async startSession(sessionName, force = false) {
|
|
125
124
|
if (this.transactionManager.sessionName && !force) {
|
|
126
|
-
this.
|
|
127
|
-
this.repository.session = this._session;
|
|
128
|
-
console.log(`[TransactionManager] startSession ${this.transactionManager.sessionName} - ${sessionName} is already active`);
|
|
125
|
+
this.logger.log(`[TransactionManager] startSession ${this.transactionManager.sessionName} - ${sessionName} is already active`);
|
|
129
126
|
return;
|
|
130
127
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
this.repository.session = this._session;
|
|
128
|
+
this.logger.log(`[TransactionManager] startSession ${sessionName} is started`);
|
|
129
|
+
await this.transactionManager.startTransaction();
|
|
134
130
|
this.transactionManager.sessionName = sessionName;
|
|
135
|
-
this.setSession(this._session);
|
|
136
131
|
}
|
|
137
132
|
async commitSession(sessionName) {
|
|
138
133
|
if (this.transactionManager.sessionName !== sessionName) {
|
|
139
|
-
|
|
134
|
+
this.logger.log(`[TransactionManager] Session ${this.transactionManager.sessionName} - ${sessionName} is not active`);
|
|
140
135
|
return;
|
|
141
136
|
}
|
|
142
137
|
await this.transactionManager.commitTransaction();
|
|
143
|
-
this._session = null;
|
|
144
|
-
this.repository.session = null;
|
|
145
138
|
this.transactionManager.sessionName = undefined;
|
|
146
|
-
this.setSession(null);
|
|
147
139
|
}
|
|
148
140
|
async abortSession() {
|
|
149
141
|
await this.transactionManager.abortTransaction();
|
|
150
|
-
this._session = null;
|
|
151
|
-
this.repository.session = null;
|
|
152
142
|
this.transactionManager.sessionName = undefined;
|
|
153
|
-
this.setSession(null);
|
|
154
143
|
}
|
|
155
144
|
async endSession() {
|
|
156
145
|
await this.transactionManager.endTransaction();
|
|
157
|
-
this._session = null;
|
|
158
|
-
this.repository.session = null;
|
|
159
146
|
this.transactionManager.sessionName = undefined;
|
|
160
|
-
this.setSession(null);
|
|
161
147
|
}
|
|
162
148
|
getObjectId() {
|
|
163
149
|
return this.repository.getObjectId();
|
|
@@ -173,7 +159,7 @@ let AbstractBaseService = class AbstractBaseService extends BaseService {
|
|
|
173
159
|
}
|
|
174
160
|
};
|
|
175
161
|
exports.AbstractBaseService = AbstractBaseService;
|
|
176
|
-
exports.AbstractBaseService = AbstractBaseService = __decorate([
|
|
162
|
+
exports.AbstractBaseService = AbstractBaseService = AbstractBaseService_1 = __decorate([
|
|
177
163
|
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => database_1.AbstractBaseRepository))),
|
|
178
164
|
__param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => database_1.TransactionManager))),
|
|
179
165
|
__metadata("design:paramtypes", [database_1.AbstractBaseRepository,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../libs/src/service/service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../libs/src/service/service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,0CAA0G;AAE1G,IAAM,WAAW,GAAjB,MAAM,WAAW;IACf,YAEqB,UAAuC;QAAvC,eAAU,GAAV,UAAU,CAA6B;IACxD,CAAC;IAEE,KAAK,CAAC,MAAM,CAAC,IAAoB;QACtC,O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