zync-nest-data-module 1.1.38 ā 1.1.41
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/database/database.repository.d.ts +0 -1
- package/dist/database/database.repository.js +0 -1
- package/dist/database/database.repository.js.map +1 -1
- package/dist/database/database.scheme.d.ts +1 -1
- package/dist/database/database.scheme.js +5 -5
- package/dist/database/database.scheme.js.map +1 -1
- package/dist/database/database.transaction.d.ts +1 -1
- package/dist/database/database.transaction.js +12 -3
- package/dist/database/database.transaction.js.map +1 -1
- package/dist/database/database.utils.d.ts +2 -2
- package/dist/database/database.utils.js +42 -27
- package/dist/database/database.utils.js.map +1 -1
- package/dist/redis/redis.module.js +2 -3
- package/dist/redis/redis.module.js.map +1 -1
- package/dist/service/service.d.ts +0 -1
- package/dist/service/service.js +4 -0
- package/dist/service/service.js.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +4 -5
- package/dist/index.js.map +0 -1
- package/libs/src/app.controller.ts +0 -91
- package/libs/src/app.module.ts +0 -34
- 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 -274
- package/libs/src/backup/backup.worker.ts +0 -35
- package/libs/src/backup/index.ts +0 -4
- package/libs/src/base/dto.ts +0 -46
- package/libs/src/base/index.ts +0 -2
- package/libs/src/base/resolver.ts +0 -20
- package/libs/src/database/database.module.ts +0 -28
- package/libs/src/database/database.repository.ts +0 -355
- package/libs/src/database/database.scheme.ts +0 -128
- package/libs/src/database/database.service.ts +0 -75
- package/libs/src/database/database.sync.ts +0 -61
- package/libs/src/database/database.transaction.ts +0 -99
- package/libs/src/database/database.uniqueId.ts +0 -90
- package/libs/src/database/database.utils.ts +0 -99
- package/libs/src/database/index.ts +0 -8
- package/libs/src/index.ts +0 -5
- package/libs/src/main.ts +0 -52
- package/libs/src/redis/index.ts +0 -2
- package/libs/src/redis/redis.interface.ts +0 -34
- package/libs/src/redis/redis.module.ts +0 -30
- package/libs/src/redis/redis.service.ts +0 -137
- package/libs/src/service/index.ts +0 -1
- package/libs/src/service/service.ts +0 -181
- package/libs/src/test/test.controller.ts +0 -59
- package/libs/src/test/test.dto.ts +0 -41
- package/libs/src/test/test.module.ts +0 -24
- package/libs/src/test/test.redis.ts +0 -19
- package/libs/src/test/test.repository.ts +0 -44
- package/libs/src/test/test.resolver.ts +0 -35
- 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
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { forwardRef, Inject, Logger } from "@nestjs/common";
|
|
2
|
-
import { AbstractBaseRepository, IPageParams, TransactionManager, TransactionSession } from "../database";
|
|
3
|
-
|
|
4
|
-
class BaseService<T> {
|
|
5
|
-
constructor(
|
|
6
|
-
@Inject(forwardRef(() => AbstractBaseRepository))
|
|
7
|
-
protected readonly repository: AbstractBaseRepository<any>
|
|
8
|
-
) { }
|
|
9
|
-
|
|
10
|
-
public async create(data: Partial<T> | T): Promise<T> {
|
|
11
|
-
return await this.repository.create(data);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public async update(_id: string, data: Partial<T> | T): Promise<T> {
|
|
15
|
-
return await this.repository.update(_id, data);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public async updateMany(query: Partial<T>, model: Partial<T>): Promise<void> {
|
|
19
|
-
return await this.repository.updateMany(query, model);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public async findById(_id: string): Promise<T> {
|
|
23
|
-
return await this.repository.findById(_id);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public async findOne(query: Partial<T>): Promise<T> {
|
|
27
|
-
return await this.repository.findOne(query);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public async find(query: Partial<T>): Promise<T[]> {
|
|
31
|
-
return await this.repository.find(query);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public async findLast(query?: Partial<T>): Promise<T> {
|
|
35
|
-
return await this.repository.findLast(query);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public async delete(_id: string): Promise<Boolean> {
|
|
39
|
-
await this.repository.delete(_id);
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public async deleteMany(query: Partial<T>): Promise<Boolean> {
|
|
44
|
-
await this.repository.deleteMany(query);
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public async page(
|
|
49
|
-
query: Partial<T> & IPageParams
|
|
50
|
-
): Promise<{ totalRecords: number; data: Array<T> }> {
|
|
51
|
-
return await this.repository.page(query);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public async count(query: Partial<T>): Promise<number> {
|
|
55
|
-
return this.repository.count(query);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export abstract class AbstractBaseService<T> extends BaseService<T> {
|
|
60
|
-
protected readonly logger: Logger = new Logger(AbstractBaseService.name);
|
|
61
|
-
constructor(
|
|
62
|
-
@Inject(forwardRef(() => AbstractBaseRepository))
|
|
63
|
-
protected readonly repository: AbstractBaseRepository<any>,
|
|
64
|
-
@Inject(forwardRef(() => TransactionManager))
|
|
65
|
-
public readonly transactionManager: TransactionManager
|
|
66
|
-
) {
|
|
67
|
-
super(repository);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
protected abstract setSession(session: any): void;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
public get session(): TransactionSession {
|
|
74
|
-
return TransactionManager.getCurrentSession();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public get sessionName(): string {
|
|
78
|
-
return this.transactionManager.sessionName;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
public async withRetryTransaction(sessionName: string, operations: () => Promise<T>, retries: number = 3): Promise<T> {
|
|
82
|
-
if (process.env.mongodb_transaction_enable !== "true") return await operations();
|
|
83
|
-
|
|
84
|
-
return this.transactionManager.run(async () => {
|
|
85
|
-
try {
|
|
86
|
-
await this.startSession(sessionName);
|
|
87
|
-
|
|
88
|
-
let attempt = 0;
|
|
89
|
-
while (attempt < retries) {
|
|
90
|
-
try {
|
|
91
|
-
const op = await operations();
|
|
92
|
-
await this.commitSession(sessionName);
|
|
93
|
-
return op;
|
|
94
|
-
} catch (error) {
|
|
95
|
-
if (this.isRetryableError(error)) {
|
|
96
|
-
this.logger.log(`[TransactionManager] Retrying transaction...`);
|
|
97
|
-
await this.delay(1000 * (attempt + 1)); // Exponential backoff
|
|
98
|
-
await this.transactionManager.abortTransaction();
|
|
99
|
-
await this.startSession(sessionName, true);
|
|
100
|
-
} else {
|
|
101
|
-
await this.abortSession();
|
|
102
|
-
throw error;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
attempt++;
|
|
106
|
-
}
|
|
107
|
-
} catch (error) {
|
|
108
|
-
this.logger.error(`[TransactionManager] Error in transaction`, error);
|
|
109
|
-
await this.abortSession();
|
|
110
|
-
throw error;
|
|
111
|
-
} finally {
|
|
112
|
-
this.logger.log(`[TransactionManager] Finally block`);
|
|
113
|
-
if (this.transactionManager.sessionName == sessionName) {
|
|
114
|
-
await this.endSession();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
private isRetryableError(error: any): boolean {
|
|
122
|
-
return (
|
|
123
|
-
error.code === 112 // WriteConflict
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
private delay(ms: number): Promise<void> {
|
|
128
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
protected async startSession(sessionName: string, force: boolean = false) {
|
|
132
|
-
if (this.transactionManager.sessionName && !force) {
|
|
133
|
-
this.logger.log(`[TransactionManager] startSession ${this.transactionManager.sessionName} - ${sessionName} is already active`);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
this.logger.log(`[TransactionManager] startSession ${sessionName} is started`);
|
|
138
|
-
|
|
139
|
-
await this.transactionManager.startTransaction();
|
|
140
|
-
this.transactionManager.sessionName = sessionName;
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
protected async commitSession(sessionName: string) {
|
|
145
|
-
if (this.transactionManager.sessionName !== sessionName) {
|
|
146
|
-
this.logger.log(`[TransactionManager] Session ${this.transactionManager.sessionName} - ${sessionName} is not active`);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
await this.transactionManager.commitTransaction();
|
|
151
|
-
this.transactionManager.sessionName = undefined;
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
public async abortSession() {
|
|
156
|
-
await this.transactionManager.abortTransaction();
|
|
157
|
-
this.transactionManager.sessionName = undefined;
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
public async endSession() {
|
|
162
|
-
await this.transactionManager.endTransaction();
|
|
163
|
-
this.transactionManager.sessionName = undefined;
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
protected getObjectId(): string | any {
|
|
168
|
-
return this.repository.getObjectId();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
protected toObjectId(value: string | any): any {
|
|
172
|
-
return this.repository.toObjectId(value);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
public async checkExist(id: any): Promise<void> {
|
|
176
|
-
const exist = await this.repository.findOne(id);
|
|
177
|
-
if (!exist) {
|
|
178
|
-
throw new Error("Record does not exist");
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Body, Controller, Delete, Get, Param, Post, Put, Query } from "@nestjs/common";
|
|
2
|
-
import { ApiOperation, ApiParam, ApiQuery, ApiResponse, ApiTags } from "@nestjs/swagger";
|
|
3
|
-
import { CreateTestInput, Test, TestPageInput, TestPageResult, TestQueryInput, UpdateTestInput } from "./test.dto";
|
|
4
|
-
import { TestRedisService } from "./test.redis";
|
|
5
|
-
|
|
6
|
-
@ApiTags("Test")
|
|
7
|
-
@Controller("test")
|
|
8
|
-
export class TestController {
|
|
9
|
-
constructor(private readonly testRedisSvc: TestRedisService) {}
|
|
10
|
-
|
|
11
|
-
@Post()
|
|
12
|
-
@ApiOperation({ summary: "Create Test" })
|
|
13
|
-
@ApiResponse({ status: 201, description: "Test created successfully", type: Test })
|
|
14
|
-
public async create(@Body() test: CreateTestInput): Promise<Test> {
|
|
15
|
-
return this.testRedisSvc.create(test as any);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Put(":id")
|
|
19
|
-
@ApiOperation({ summary: "Update Test" })
|
|
20
|
-
@ApiParam({ name: "id", description: "Test ID" })
|
|
21
|
-
@ApiResponse({ status: 200, description: "Test updated", type: Test })
|
|
22
|
-
public async update(@Param("id") id: string, @Body() test: UpdateTestInput): Promise<Test> {
|
|
23
|
-
return this.testRedisSvc.update(id, { ...test } as any);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@Delete(":id")
|
|
27
|
-
@ApiOperation({ summary: "Delete Test" })
|
|
28
|
-
@ApiParam({ name: "id", description: "Test ID" })
|
|
29
|
-
@ApiResponse({ status: 200, description: "Test deleted" })
|
|
30
|
-
public async delete(@Param("id") id: string): Promise<{ success: boolean }> {
|
|
31
|
-
await this.testRedisSvc.delete(id);
|
|
32
|
-
return { success: true };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@Get("findOne")
|
|
36
|
-
@ApiOperation({ summary: "Find one Test" })
|
|
37
|
-
@ApiQuery({ name: "_id", required: false, description: "Test ID" })
|
|
38
|
-
@ApiResponse({ status: 200, description: "Returns the found test", type: Test })
|
|
39
|
-
public async findOne(@Query() query: TestQueryInput): Promise<Test> {
|
|
40
|
-
return this.testRedisSvc.findOne(query as any);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@Get("find")
|
|
44
|
-
@ApiOperation({ summary: "Find Tests" })
|
|
45
|
-
@ApiQuery({ name: "query", required: false, description: "Test query" })
|
|
46
|
-
@ApiResponse({ status: 200, description: "Returns the found tests", type: [Test] })
|
|
47
|
-
public async find(@Query() query: TestQueryInput): Promise<Test[]> {
|
|
48
|
-
return this.testRedisSvc.find(query as any);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@Get("page")
|
|
52
|
-
@ApiOperation({ summary: "Get paginated list of Tests" })
|
|
53
|
-
@ApiQuery({ name: "page", type: "number", required: false })
|
|
54
|
-
@ApiQuery({ name: "limit", type: "number", required: false })
|
|
55
|
-
@ApiResponse({ status: 200, description: "Returns a page of tests", type: TestPageResult })
|
|
56
|
-
public async page(@Query() pageQuery: TestPageInput): Promise<{ totalRecords: number; data: Array<Partial<Test>> }> {
|
|
57
|
-
return this.testRedisSvc.page({ ...pageQuery } as any);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Field, InputType, ObjectType, PartialType } from "@nestjs/graphql";
|
|
2
|
-
|
|
3
|
-
@ObjectType()
|
|
4
|
-
export class Test {
|
|
5
|
-
@Field({ nullable: true })
|
|
6
|
-
name: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
@InputType()
|
|
10
|
-
export class TestCommonInput {
|
|
11
|
-
@Field({ nullable: true })
|
|
12
|
-
name: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@InputType()
|
|
16
|
-
export class CreateTestInput extends TestCommonInput {}
|
|
17
|
-
|
|
18
|
-
@InputType()
|
|
19
|
-
export class UpdateTestInput extends PartialType(TestCommonInput) {}
|
|
20
|
-
|
|
21
|
-
@InputType()
|
|
22
|
-
export class TestQueryInput {
|
|
23
|
-
@Field({ nullable: true })
|
|
24
|
-
keyword: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@ObjectType()
|
|
28
|
-
export class TestPageResult {
|
|
29
|
-
@Field({})
|
|
30
|
-
totalRecords: number;
|
|
31
|
-
@Field((type) => [Test])
|
|
32
|
-
data: Array<Test>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@InputType()
|
|
36
|
-
export class TestPageInput extends TestQueryInput {
|
|
37
|
-
@Field({})
|
|
38
|
-
skip: number;
|
|
39
|
-
@Field({})
|
|
40
|
-
take: number;
|
|
41
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { forwardRef, Module } from "@nestjs/common";
|
|
2
|
-
import { MongooseModule } from "@nestjs/mongoose";
|
|
3
|
-
import { DatabaseModule } from "../database";
|
|
4
|
-
import { TestRepository } from "./test.repository";
|
|
5
|
-
import { TestResolver } from "./test.resolver";
|
|
6
|
-
import { Test, TestSchema } from "./test.schema";
|
|
7
|
-
import { TestService } from "./test.service";
|
|
8
|
-
import { TestController } from "./test.controller";
|
|
9
|
-
import { TestRedisService } from "./test.redis";
|
|
10
|
-
|
|
11
|
-
const TestMongooseModule = MongooseModule.forFeature([
|
|
12
|
-
{
|
|
13
|
-
name: Test.name,
|
|
14
|
-
schema: TestSchema
|
|
15
|
-
}
|
|
16
|
-
]);
|
|
17
|
-
|
|
18
|
-
@Module({
|
|
19
|
-
imports: [TestMongooseModule, DatabaseModule.forFeature([{ name: Test.name, schema: TestSchema }])],
|
|
20
|
-
providers: [TestRepository, TestService, TestResolver, TestRedisService],
|
|
21
|
-
exports: [TestService],
|
|
22
|
-
controllers: [TestController]
|
|
23
|
-
})
|
|
24
|
-
export class TestModule {}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { EntityData } from "redis-om";
|
|
2
|
-
import { RedisService } from "../redis/redis.service";
|
|
3
|
-
import { Test } from "./test.schema";
|
|
4
|
-
|
|
5
|
-
export class TestRedisService extends RedisService<Test & EntityData & { _id: string }> {
|
|
6
|
-
public cacheKey = "test";
|
|
7
|
-
|
|
8
|
-
public mapSchema(): Record<string, any> {
|
|
9
|
-
return {
|
|
10
|
-
name: { type: "string", index: true },
|
|
11
|
-
createdAt: { type: "number" },
|
|
12
|
-
updatedAt: { type: "number" }
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public buildQuery(query: any): any {
|
|
17
|
-
return query;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Injectable } from "@nestjs/common";
|
|
2
|
-
import { InjectModel } from "@nestjs/mongoose";
|
|
3
|
-
import moment from "moment";
|
|
4
|
-
import { SoftDeleteModel } from "mongoose-delete";
|
|
5
|
-
import { AbstractBaseRepository } from "../database/database.repository";
|
|
6
|
-
import { Test, TestDocument, TestSchema } from "./test.schema";
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class TestRepository extends AbstractBaseRepository<TestDocument> {
|
|
10
|
-
constructor(
|
|
11
|
-
@InjectModel(Test.name)
|
|
12
|
-
public dbModel: SoftDeleteModel<TestDocument>
|
|
13
|
-
) {
|
|
14
|
-
super(dbModel);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public async mapData(data: any, isCreate: boolean): Promise<TestDocument> {
|
|
18
|
-
const payload: any = data;
|
|
19
|
-
|
|
20
|
-
if (isCreate) {
|
|
21
|
-
payload.ref = payload.ref || (await this.generateRef());
|
|
22
|
-
payload.createdBy = payload.createdBy;
|
|
23
|
-
payload.createdAt = payload.createdAt
|
|
24
|
-
? moment(payload.createdAt).valueOf()
|
|
25
|
-
: moment().valueOf();
|
|
26
|
-
} else {
|
|
27
|
-
payload.updatedBy = payload.updatedBy;
|
|
28
|
-
payload.updatedAt = payload.updatedAt
|
|
29
|
-
? moment(payload.updatedAt).valueOf()
|
|
30
|
-
: moment().valueOf();
|
|
31
|
-
}
|
|
32
|
-
return this.mapIds(payload);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
protected buildQuery(query: Partial<TestDocument>) {
|
|
36
|
-
const andConditions: any[] = [];
|
|
37
|
-
|
|
38
|
-
this.schemaKeysQuery(TestSchema, { query }, (condition: any) => {
|
|
39
|
-
andConditions.push(condition);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return this.cleanupQuery(andConditions);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Args, Mutation, Query, Resolver } from "@nestjs/graphql";
|
|
2
|
-
import { CreateTestInput, Test, TestPageInput, TestPageResult, TestQueryInput, UpdateTestInput } from "./test.dto";
|
|
3
|
-
import { TestService } from "./test.service";
|
|
4
|
-
import { TestRedisService } from "./test.redis";
|
|
5
|
-
|
|
6
|
-
@Resolver(() => Test)
|
|
7
|
-
export class TestResolver {
|
|
8
|
-
constructor(private readonly testSvc: TestService, private readonly testRedisSvc: TestRedisService) {}
|
|
9
|
-
|
|
10
|
-
@Mutation((returns) => Test, { name: "createTest" })
|
|
11
|
-
public async create(@Args("test") test: CreateTestInput) {
|
|
12
|
-
return this.testRedisSvc.create(test as any);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@Mutation((returns) => Test, { name: "updateTest" })
|
|
16
|
-
public async update(@Args("_id") id: string, @Args("test") test: UpdateTestInput) {
|
|
17
|
-
return this.testRedisSvc.update(id, { ...test } as any);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@Mutation((returns) => Boolean, { name: "deleteTest" })
|
|
21
|
-
public async delete(@Args("_id") id: string) {
|
|
22
|
-
await this.testRedisSvc.delete(id);
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@Query((returns) => Test, { name: "findOneTest" })
|
|
27
|
-
public async findOne(@Args("test") test: TestQueryInput) {
|
|
28
|
-
return this.testRedisSvc.findOne(test as any);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@Query((returns) => TestPageResult, { name: "testPage" })
|
|
32
|
-
public async page(@Args("page") page: TestPageInput) {
|
|
33
|
-
return this.testRedisSvc.page({ ...page } as any);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
|
2
|
-
import { Document } from "mongoose";
|
|
3
|
-
import { BaseSchema, IPageParams } from "../database/database.scheme";
|
|
4
|
-
export type TestDocument = Test & Document;
|
|
5
|
-
|
|
6
|
-
@Schema({ collection: "tests" })
|
|
7
|
-
export class Test extends BaseSchema {
|
|
8
|
-
@Prop({ required: true })
|
|
9
|
-
name: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const TestSchema = SchemaFactory.createForClass(Test);
|
|
13
|
-
|
|
14
|
-
export class TestQuery extends Test {
|
|
15
|
-
keyword?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class PageParams extends TestQuery implements IPageParams {
|
|
19
|
-
skip: number;
|
|
20
|
-
take: number;
|
|
21
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { forwardRef, Inject, Injectable } from "@nestjs/common";
|
|
2
|
-
import { TestRepository } from "./test.repository";
|
|
3
|
-
import { Test } from "./test.schema";
|
|
4
|
-
import { TransactionManager } from "../database";
|
|
5
|
-
import { AbstractBaseService } from "../service/service";
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class TestService extends AbstractBaseService<Test> {
|
|
9
|
-
constructor(
|
|
10
|
-
@Inject(forwardRef(() => TestRepository))
|
|
11
|
-
private readonly testRepo: TestRepository,
|
|
12
|
-
@Inject(forwardRef(() => TransactionManager))
|
|
13
|
-
transactionManager: TransactionManager
|
|
14
|
-
) {
|
|
15
|
-
super(testRepo, transactionManager);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
protected setSession(session: any): void {}
|
|
19
|
-
}
|
package/libs/tsconfig.lib.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"outDir": "../dist"
|
|
6
|
-
},
|
|
7
|
-
"include": [
|
|
8
|
-
"src/database/**/*",
|
|
9
|
-
"src/backup/**/*",
|
|
10
|
-
"src/service/**/*",
|
|
11
|
-
"src/index.ts",
|
|
12
|
-
],
|
|
13
|
-
"exclude": [
|
|
14
|
-
"node_modules",
|
|
15
|
-
"dist",
|
|
16
|
-
"test",
|
|
17
|
-
"**/*spec.ts",
|
|
18
|
-
]
|
|
19
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "commonjs",
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"removeComments": true,
|
|
6
|
-
"emitDecoratorMetadata": true,
|
|
7
|
-
"experimentalDecorators": true,
|
|
8
|
-
"allowSyntheticDefaultImports": true,
|
|
9
|
-
"target": "ES2021",
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"outDir": "./dist",
|
|
12
|
-
"baseUrl": "./",
|
|
13
|
-
"incremental": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"strictNullChecks": false,
|
|
16
|
-
"noImplicitAny": false,
|
|
17
|
-
"strictBindCallApply": false,
|
|
18
|
-
"forceConsistentCasingInFileNames": false,
|
|
19
|
-
"noFallthroughCasesInSwitch": false,
|
|
20
|
-
"esModuleInterop": true
|
|
21
|
-
},
|
|
22
|
-
"include": [
|
|
23
|
-
"libs/**/*"
|
|
24
|
-
],
|
|
25
|
-
"exclude": [
|
|
26
|
-
"node_modules",
|
|
27
|
-
"dist"
|
|
28
|
-
]
|
|
29
|
-
}
|
package/update-links.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { execSync } = require("child_process");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Script to update pnpm links when changes are made to zync-nest-library
|
|
9
|
-
* This script will:
|
|
10
|
-
* 1. Build the library
|
|
11
|
-
* 2. Update the version in package.json
|
|
12
|
-
* 3. Re-link to consuming projects
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
// Configuration - projects that use this library
|
|
16
|
-
const CONSUMING_PROJECTS = [
|
|
17
|
-
"/Users/sabiridwan/Projects/Async/zyncount/zyncount-be",
|
|
18
|
-
"/Users/sabiridwan/Projects/MalikStream/ms-gold/msgld-be",
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const LIBRARY_PATH =
|
|
22
|
-
"/Users/sabiridwan/Projects/Async/zync-library/zync-nest-libary";
|
|
23
|
-
|
|
24
|
-
function execCommand(command, cwd = process.cwd()) {
|
|
25
|
-
try {
|
|
26
|
-
console.log(`\nš§ Executing: ${command}`);
|
|
27
|
-
console.log(`š In directory: ${cwd}`);
|
|
28
|
-
|
|
29
|
-
const output = execSync(command, {
|
|
30
|
-
cwd,
|
|
31
|
-
stdio: "inherit",
|
|
32
|
-
encoding: "utf8",
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return output;
|
|
36
|
-
} catch (error) {
|
|
37
|
-
console.error(`ā Error executing command: ${command}`);
|
|
38
|
-
console.error(error.message);
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function updateLibraryVersion(versionType = "patch") {
|
|
44
|
-
console.log(`\nš¦ Updating library version (${versionType})...`);
|
|
45
|
-
execCommand(`npm version ${versionType} --no-git-tag-version`, LIBRARY_PATH);
|
|
46
|
-
|
|
47
|
-
// Get the new version
|
|
48
|
-
const packageJson = JSON.parse(
|
|
49
|
-
fs.readFileSync(path.join(LIBRARY_PATH, "package.json"), "utf8")
|
|
50
|
-
);
|
|
51
|
-
console.log(`ā
Updated to version: ${packageJson.version}`);
|
|
52
|
-
return packageJson.version;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function buildLibrary() {
|
|
56
|
-
console.log("\nšļø Building library...");
|
|
57
|
-
execCommand("pnpm run build", LIBRARY_PATH);
|
|
58
|
-
console.log("ā
Library built successfully");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function linkLibraryGlobally() {
|
|
62
|
-
console.log("\nš Linking library globally...");
|
|
63
|
-
execCommand("pnpm link --global", LIBRARY_PATH);
|
|
64
|
-
console.log("ā
Library linked globally");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function updateConsumingProjects() {
|
|
68
|
-
console.log("\nš Updating consuming projects...");
|
|
69
|
-
|
|
70
|
-
for (const projectPath of CONSUMING_PROJECTS) {
|
|
71
|
-
if (!fs.existsSync(projectPath)) {
|
|
72
|
-
console.log(`ā ļø Project not found: ${projectPath}`);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
console.log(`\nš Updating project: ${path.basename(projectPath)}`);
|
|
77
|
-
|
|
78
|
-
// Unlink first (in case it's already linked)
|
|
79
|
-
try {
|
|
80
|
-
execCommand("pnpm unlink zync-nest-library", projectPath);
|
|
81
|
-
} catch (error) {
|
|
82
|
-
// Ignore errors if not linked
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Link the new version
|
|
86
|
-
execCommand("pnpm link zync-nest-library", projectPath);
|
|
87
|
-
console.log(`ā
Updated ${path.basename(projectPath)}`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function main() {
|
|
92
|
-
console.log("š Starting pnpm link update process...");
|
|
93
|
-
|
|
94
|
-
const args = process.argv.slice(2);
|
|
95
|
-
const versionType = args[0] || "patch"; // patch, minor, major
|
|
96
|
-
const skipVersionUpdate = args.includes("--skip-version");
|
|
97
|
-
const skipBuild = args.includes("--skip-build");
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
-
// Update version if not skipped
|
|
101
|
-
if (!skipVersionUpdate) {
|
|
102
|
-
updateLibraryVersion(versionType);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Build library if not skipped
|
|
106
|
-
if (!skipBuild) {
|
|
107
|
-
buildLibrary();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Link library globally
|
|
111
|
-
linkLibraryGlobally();
|
|
112
|
-
|
|
113
|
-
// Update consuming projects
|
|
114
|
-
updateConsumingProjects();
|
|
115
|
-
|
|
116
|
-
console.log("\nš Pnpm link update completed successfully!");
|
|
117
|
-
|
|
118
|
-
// Show usage information
|
|
119
|
-
console.log("\nš Next steps:");
|
|
120
|
-
console.log("1. Test your changes in the consuming projects");
|
|
121
|
-
console.log("2. When ready, publish the library: npm publish");
|
|
122
|
-
console.log(
|
|
123
|
-
"3. Update consuming projects to use published version: pnpm update zync-nest-library"
|
|
124
|
-
);
|
|
125
|
-
} catch (error) {
|
|
126
|
-
console.error("\nā Update process failed:", error.message);
|
|
127
|
-
process.exit(1);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Show help
|
|
132
|
-
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
133
|
-
console.log(`
|
|
134
|
-
š Pnpm Link Update Script
|
|
135
|
-
|
|
136
|
-
Usage:
|
|
137
|
-
node update-links.js [version-type] [options]
|
|
138
|
-
|
|
139
|
-
Arguments:
|
|
140
|
-
version-type Version bump type: patch (default), minor, major
|
|
141
|
-
|
|
142
|
-
Options:
|
|
143
|
-
--skip-version Skip version update
|
|
144
|
-
--skip-build Skip build step
|
|
145
|
-
--help, -h Show this help message
|
|
146
|
-
|
|
147
|
-
Examples:
|
|
148
|
-
node update-links.js # Patch version update with build
|
|
149
|
-
node update-links.js minor # Minor version update with build
|
|
150
|
-
node update-links.js --skip-build # Update links without building
|
|
151
|
-
node update-links.js patch --skip-version --skip-build # Only update links
|
|
152
|
-
|
|
153
|
-
Projects that will be updated:
|
|
154
|
-
${CONSUMING_PROJECTS.map((p) => ` - ${p}`).join("\n")}
|
|
155
|
-
`);
|
|
156
|
-
process.exit(0);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
main();
|