common-tg-service 1.0.28 → 1.0.29
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/components/transactions/schemas/transaction.schema.d.ts +3 -0
- package/dist/components/transactions/schemas/transaction.schema.js +26 -12
- package/dist/components/transactions/schemas/transaction.schema.js.map +1 -1
- package/dist/components/transactions/transaction.service.d.ts +1 -0
- package/dist/components/transactions/transaction.service.js +17 -5
- package/dist/components/transactions/transaction.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -35,6 +35,9 @@ export declare class Transaction {
|
|
|
35
35
|
chatId: string;
|
|
36
36
|
ip: string;
|
|
37
37
|
status: string;
|
|
38
|
+
isDeleted: boolean;
|
|
39
|
+
createdAt?: Date;
|
|
40
|
+
updatedAt?: Date;
|
|
38
41
|
}
|
|
39
42
|
export declare const TransactionSchema: import("mongoose").Schema<Transaction, import("mongoose").Model<Transaction, any, any, any, Document<unknown, any, Transaction> & Transaction & {
|
|
40
43
|
_id: import("mongoose").Types.ObjectId;
|
|
@@ -15,19 +15,19 @@ let Transaction = class Transaction {
|
|
|
15
15
|
};
|
|
16
16
|
exports.Transaction = Transaction;
|
|
17
17
|
__decorate([
|
|
18
|
-
(0, mongoose_1.Prop)({ required:
|
|
18
|
+
(0, mongoose_1.Prop)({ required: true, unique: true, index: true }),
|
|
19
19
|
__metadata("design:type", String)
|
|
20
20
|
], Transaction.prototype, "transactionId", void 0);
|
|
21
21
|
__decorate([
|
|
22
|
-
(0, mongoose_1.Prop)({ required:
|
|
22
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
23
23
|
__metadata("design:type", Number)
|
|
24
24
|
], Transaction.prototype, "amount", void 0);
|
|
25
25
|
__decorate([
|
|
26
|
-
(0, mongoose_1.Prop)({ required:
|
|
26
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
27
27
|
__metadata("design:type", String)
|
|
28
28
|
], Transaction.prototype, "issue", void 0);
|
|
29
29
|
__decorate([
|
|
30
|
-
(0, mongoose_1.Prop)({ required:
|
|
30
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
31
31
|
__metadata("design:type", String)
|
|
32
32
|
], Transaction.prototype, "description", void 0);
|
|
33
33
|
__decorate([
|
|
@@ -35,31 +35,45 @@ __decorate([
|
|
|
35
35
|
__metadata("design:type", String)
|
|
36
36
|
], Transaction.prototype, "refundMethod", void 0);
|
|
37
37
|
__decorate([
|
|
38
|
-
(0, mongoose_1.Prop)({ required: false }),
|
|
38
|
+
(0, mongoose_1.Prop)({ required: false, default: 'undefined' }),
|
|
39
39
|
__metadata("design:type", String)
|
|
40
40
|
], Transaction.prototype, "profile", void 0);
|
|
41
41
|
__decorate([
|
|
42
|
-
(0, mongoose_1.Prop)({ required:
|
|
42
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
43
43
|
__metadata("design:type", String)
|
|
44
44
|
], Transaction.prototype, "chatId", void 0);
|
|
45
45
|
__decorate([
|
|
46
|
-
(0, mongoose_1.Prop)({ required: false }),
|
|
46
|
+
(0, mongoose_1.Prop)({ required: false, default: 'undefined' }),
|
|
47
47
|
__metadata("design:type", String)
|
|
48
48
|
], Transaction.prototype, "ip", void 0);
|
|
49
49
|
__decorate([
|
|
50
|
-
(0, mongoose_1.Prop)({
|
|
50
|
+
(0, mongoose_1.Prop)({
|
|
51
|
+
required: true,
|
|
52
|
+
enum: ['pending', 'completed', 'failed', 'cancelled'],
|
|
53
|
+
default: 'pending'
|
|
54
|
+
}),
|
|
51
55
|
__metadata("design:type", String)
|
|
52
56
|
], Transaction.prototype, "status", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, mongoose_1.Prop)({ default: false }),
|
|
59
|
+
__metadata("design:type", Boolean)
|
|
60
|
+
], Transaction.prototype, "isDeleted", void 0);
|
|
53
61
|
exports.Transaction = Transaction = __decorate([
|
|
54
|
-
(0, mongoose_1.Schema)({
|
|
62
|
+
(0, mongoose_1.Schema)({
|
|
55
63
|
timestamps: true,
|
|
64
|
+
collection: 'transactions',
|
|
56
65
|
toJSON: {
|
|
57
66
|
virtuals: true,
|
|
58
|
-
transform: (
|
|
59
|
-
delete ret.
|
|
67
|
+
transform: (_doc, ret) => {
|
|
68
|
+
delete ret.__v;
|
|
69
|
+
return ret;
|
|
60
70
|
},
|
|
61
|
-
}
|
|
71
|
+
}
|
|
62
72
|
})
|
|
63
73
|
], Transaction);
|
|
64
74
|
exports.TransactionSchema = mongoose_1.SchemaFactory.createForClass(Transaction);
|
|
75
|
+
exports.TransactionSchema.index({ createdAt: 1 });
|
|
76
|
+
exports.TransactionSchema.index({ transactionId: 1 }, { unique: true });
|
|
77
|
+
exports.TransactionSchema.index({ chatId: 1 });
|
|
78
|
+
exports.TransactionSchema.index({ status: 1 });
|
|
65
79
|
//# sourceMappingURL=transaction.schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.schema.js","sourceRoot":"","sources":["../../../../src/components/transactions/schemas/transaction.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA+D;
|
|
1
|
+
{"version":3,"file":"transaction.schema.js","sourceRoot":"","sources":["../../../../src/components/transactions/schemas/transaction.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA+D;AAgBxD,IAAM,WAAW,GAAjB,MAAM,WAAW;CAqCvB,CAAA;AArCY,kCAAW;AAEtB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;kDAC9B;AAGtB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACV;AAGf;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACX;AAGd;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACL;AA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KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -29,6 +29,7 @@ import { UpdateTransactionDto } from './dto/update-transaction.dto';
|
|
|
29
29
|
import { Transaction, TransactionDocument } from './schemas/transaction.schema';
|
|
30
30
|
export declare class TransactionService {
|
|
31
31
|
private readonly transactionModel;
|
|
32
|
+
private readonly logger;
|
|
32
33
|
constructor(transactionModel: Model<TransactionDocument>);
|
|
33
34
|
create(createTransactionDto: CreateTransactionDto): Promise<Transaction>;
|
|
34
35
|
findOne(id: string): Promise<Transaction>;
|
|
@@ -11,20 +11,32 @@ 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 TransactionService_1;
|
|
14
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
16
|
exports.TransactionService = void 0;
|
|
16
17
|
const common_1 = require("@nestjs/common");
|
|
17
18
|
const mongoose_1 = require("@nestjs/mongoose");
|
|
18
19
|
const mongoose_2 = require("mongoose");
|
|
19
20
|
const transaction_schema_1 = require("./schemas/transaction.schema");
|
|
20
|
-
let TransactionService = class TransactionService {
|
|
21
|
+
let TransactionService = TransactionService_1 = class TransactionService {
|
|
21
22
|
constructor(transactionModel) {
|
|
22
23
|
this.transactionModel = transactionModel;
|
|
24
|
+
this.logger = new common_1.Logger(TransactionService_1.name);
|
|
23
25
|
}
|
|
24
26
|
async create(createTransactionDto) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
this.logger.debug('Creating new transaction with data:', createTransactionDto);
|
|
28
|
+
try {
|
|
29
|
+
const newTransaction = new this.transactionModel(createTransactionDto);
|
|
30
|
+
this.logger.debug('Transaction model created:', newTransaction.toObject());
|
|
31
|
+
const savedTransaction = await newTransaction.save();
|
|
32
|
+
this.logger.debug('Transaction saved successfully:', savedTransaction.toObject());
|
|
33
|
+
return savedTransaction;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
this.logger.error('Error saving transaction:', error);
|
|
37
|
+
this.logger.error('Transaction data that failed:', createTransactionDto);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
28
40
|
}
|
|
29
41
|
async findOne(id) {
|
|
30
42
|
const transaction = await this.transactionModel.findById(id).exec();
|
|
@@ -70,7 +82,7 @@ let TransactionService = class TransactionService {
|
|
|
70
82
|
}
|
|
71
83
|
};
|
|
72
84
|
exports.TransactionService = TransactionService;
|
|
73
|
-
exports.TransactionService = TransactionService = __decorate([
|
|
85
|
+
exports.TransactionService = TransactionService = TransactionService_1 = __decorate([
|
|
74
86
|
(0, common_1.Injectable)(),
|
|
75
87
|
__param(0, (0, mongoose_1.InjectModel)(transaction_schema_1.Transaction.name)),
|
|
76
88
|
__metadata("design:paramtypes", [mongoose_2.Model])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.service.js","sourceRoot":"","sources":["../../../src/components/transactions/transaction.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transaction.service.js","sourceRoot":"","sources":["../../../src/components/transactions/transaction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAuE;AACvE,+CAA+C;AAC/C,uCAAiC;AAGjC,qEAAgF;AAGzE,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAG7B,YACiC,gBAA6D;QAA5C,qBAAgB,GAAhB,gBAAgB,CAA4B;QAH7E,WAAM,GAAG,IAAI,eAAM,CAAC,oBAAkB,CAAC,IAAI,CAAC,CAAC;IAI3D,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,oBAA0C;QACrD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,oBAAoB,CAAC,CAAC;QAE/E,IAAI,CAAC;YACH,MAAM,cAAc,GAAG,IAAI,IAAI,CAAC,gBAAgB,CAAC,oBA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