@lyxa.ai/core 1.0.104 → 1.0.106
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/README.md +1 -0
- package/dist/libraries/mongo/models/embedded/loyaltyPoint.model.d.ts +16 -0
- package/dist/libraries/mongo/models/embedded/loyaltyPoint.model.js +61 -0
- package/dist/libraries/mongo/models/embedded/loyaltyPoint.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/order-cancel.model.d.ts +1 -0
- package/dist/libraries/mongo/models/embedded/order-cancel.model.js +5 -0
- package/dist/libraries/mongo/models/embedded/order-cancel.model.js.map +1 -1
- package/dist/libraries/mongo/models/index.d.ts +0 -13
- package/dist/libraries/mongo/models/index.js +1 -14
- package/dist/libraries/mongo/models/index.js.map +1 -1
- package/dist/libraries/mongo/models/order.model.js +1 -1
- package/dist/libraries/mongo/models/order.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/referral-code-coupon.model.d.ts +2 -2
- package/dist/libraries/mongo/models/providers/referral-code-coupon.model.js +2 -2
- package/dist/libraries/mongo/models/providers/referral-code-coupon.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/referral-reward-coupon.model.d.ts +3 -3
- package/dist/libraries/mongo/models/providers/referral-reward-coupon.model.js +3 -3
- package/dist/libraries/mongo/models/providers/referral-reward-coupon.model.js.map +1 -1
- package/dist/libraries/mongo/models/punch-marketing-history.model.d.ts +4 -8
- package/dist/libraries/mongo/models/punch-marketing-history.model.js +4 -20
- package/dist/libraries/mongo/models/punch-marketing-history.model.js.map +1 -1
- package/dist/utilities/enum.d.ts +6 -22
- package/dist/utilities/enum.js +7 -26
- package/dist/utilities/enum.js.map +1 -1
- package/dist/utilities/validation/common-validation.d.ts +7 -7
- package/package.json +1 -1
- package/dist/libraries/mongo/models/agent-performance.model.d.ts +0 -13
- package/dist/libraries/mongo/models/agent-performance.model.js +0 -68
- package/dist/libraries/mongo/models/agent-performance.model.js.map +0 -1
- package/dist/libraries/mongo/models/app-screen-setting.model.d.ts +0 -9
- package/dist/libraries/mongo/models/app-screen-setting.model.js +0 -72
- package/dist/libraries/mongo/models/app-screen-setting.model.js.map +0 -1
- package/dist/libraries/mongo/models/chat-room.model.d.ts +0 -16
- package/dist/libraries/mongo/models/chat-room.model.js +0 -79
- package/dist/libraries/mongo/models/chat-room.model.js.map +0 -1
- package/dist/libraries/mongo/models/embedded/chat-participant.model.d.ts +0 -13
- package/dist/libraries/mongo/models/embedded/chat-participant.model.js +0 -47
- package/dist/libraries/mongo/models/embedded/chat-participant.model.js.map +0 -1
- package/dist/libraries/mongo/models/message.model.d.ts +0 -18
- package/dist/libraries/mongo/models/message.model.js +0 -70
- package/dist/libraries/mongo/models/message.model.js.map +0 -1
- package/dist/libraries/mongo/models/order-payment.model.d.ts +0 -17
- package/dist/libraries/mongo/models/order-payment.model.js +0 -84
- package/dist/libraries/mongo/models/order-payment.model.js.map +0 -1
- package/dist/libraries/mongo/models/ticket.model.d.ts +0 -29
- package/dist/libraries/mongo/models/ticket.model.js +0 -178
- package/dist/libraries/mongo/models/ticket.model.js.map +0 -1
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Ref } from '@typegoose/typegoose';
|
|
2
|
-
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
3
|
-
import { User } from './user.model';
|
|
4
|
-
import { Admin } from './admin.model';
|
|
5
|
-
import { Shop } from './shop.model';
|
|
6
|
-
import { MessageSender } from '../../../utilities/enum';
|
|
7
|
-
import { Rider } from './rider.model';
|
|
8
|
-
import { Chatroom } from './chat-room.model';
|
|
9
|
-
export declare class Message extends TimeStamps {
|
|
10
|
-
chatroom: Ref<Chatroom>;
|
|
11
|
-
content: string;
|
|
12
|
-
senderType: MessageSender;
|
|
13
|
-
sender: Ref<User | Admin | Shop | Rider>;
|
|
14
|
-
isRead?: boolean;
|
|
15
|
-
readAt?: Date;
|
|
16
|
-
attachmentUrl?: string;
|
|
17
|
-
messageType?: string;
|
|
18
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Message = void 0;
|
|
13
|
-
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
|
-
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
|
-
const enum_1 = require("../../../utilities/enum");
|
|
16
|
-
const chat_room_model_1 = require("./chat-room.model");
|
|
17
|
-
let Message = class Message extends defaultClasses_1.TimeStamps {
|
|
18
|
-
chatroom;
|
|
19
|
-
content;
|
|
20
|
-
senderType;
|
|
21
|
-
sender;
|
|
22
|
-
isRead;
|
|
23
|
-
readAt;
|
|
24
|
-
attachmentUrl;
|
|
25
|
-
messageType;
|
|
26
|
-
};
|
|
27
|
-
exports.Message = Message;
|
|
28
|
-
__decorate([
|
|
29
|
-
(0, typegoose_1.prop)({ required: true, ref: () => chat_room_model_1.Chatroom }),
|
|
30
|
-
__metadata("design:type", Object)
|
|
31
|
-
], Message.prototype, "chatroom", void 0);
|
|
32
|
-
__decorate([
|
|
33
|
-
(0, typegoose_1.prop)({ required: true, type: String }),
|
|
34
|
-
__metadata("design:type", String)
|
|
35
|
-
], Message.prototype, "content", void 0);
|
|
36
|
-
__decorate([
|
|
37
|
-
(0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.MessageSender }),
|
|
38
|
-
__metadata("design:type", String)
|
|
39
|
-
], Message.prototype, "senderType", void 0);
|
|
40
|
-
__decorate([
|
|
41
|
-
(0, typegoose_1.prop)({ refPath: 'senderType' }),
|
|
42
|
-
__metadata("design:type", Object)
|
|
43
|
-
], Message.prototype, "sender", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
46
|
-
__metadata("design:type", Boolean)
|
|
47
|
-
], Message.prototype, "isRead", void 0);
|
|
48
|
-
__decorate([
|
|
49
|
-
(0, typegoose_1.prop)({ type: Date }),
|
|
50
|
-
__metadata("design:type", Date)
|
|
51
|
-
], Message.prototype, "readAt", void 0);
|
|
52
|
-
__decorate([
|
|
53
|
-
(0, typegoose_1.prop)({ type: String }),
|
|
54
|
-
__metadata("design:type", String)
|
|
55
|
-
], Message.prototype, "attachmentUrl", void 0);
|
|
56
|
-
__decorate([
|
|
57
|
-
(0, typegoose_1.prop)({ type: String, enum: ['TEXT', 'IMAGE', 'FILE'] }),
|
|
58
|
-
__metadata("design:type", String)
|
|
59
|
-
], Message.prototype, "messageType", void 0);
|
|
60
|
-
exports.Message = Message = __decorate([
|
|
61
|
-
(0, typegoose_1.modelOptions)({
|
|
62
|
-
schemaOptions: {
|
|
63
|
-
collection: 'messages',
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
(0, typegoose_1.index)({ chatroom: 1, createdAt: -1 }),
|
|
67
|
-
(0, typegoose_1.index)({ sender: 1, senderType: 1 }),
|
|
68
|
-
(0, typegoose_1.index)({ isRead: 1, chatroom: 1 })
|
|
69
|
-
], Message);
|
|
70
|
-
//# sourceMappingURL=message.model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message.model.js","sourceRoot":"/","sources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UAAU,EAAE,UAAU;SACtB;KACD,CAAC;IACD,IAAA,iBAAK,EAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;IACrC,IAAA,iBAAK,EAAC,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;IACnC,IAAA,iBAAK,EAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;GACrB,OAAO,CAwBnB","sourcesContent":["import { prop, Ref, modelOptions, index } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { User } from './user.model';\nimport { Admin } from './admin.model';\nimport { Shop } from './shop.model';\nimport { MessageSender } from '../../../utilities/enum';\nimport { Rider } from './rider.model';\nimport { Chatroom } from './chat-room.model';\n\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'messages',\n\t},\n})\n@index({ chatroom: 1, createdAt: -1 })\n@index({ sender: 1, senderType: 1 })\n@index({ isRead: 1, chatroom: 1 })\nexport class Message extends TimeStamps {\n\t@prop({ required: true, ref: () => Chatroom })\n\tpublic chatroom!: Ref<Chatroom>;\n\n\t@prop({ required: true, type: String })\n\tpublic content!: string;\n\n\t@prop({ required: true, type: String, enum: MessageSender })\n\tpublic senderType!: MessageSender;\n\n\t@prop({ refPath: 'senderType' })\n\tpublic sender!: Ref<User | Admin | Shop | Rider>;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isRead?: boolean;\n\n\t@prop({ type: Date })\n\tpublic readAt?: Date;\n\n\t@prop({ type: String })\n\tpublic attachmentUrl?: string;\n\n\t@prop({ type: String, enum: ['TEXT', 'IMAGE', 'FILE'] })\n\tpublic messageType?: string;\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Ref } from '@typegoose/typegoose';
|
|
2
|
-
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
3
|
-
import { Order } from './order.model';
|
|
4
|
-
import { PaymentMethod, PaymentStatus } from '../../../utilities/enum';
|
|
5
|
-
import { PaymentInformation } from './embedded/payment-infromation.model';
|
|
6
|
-
import { PaymentAttempt } from './embedded/payment-attempt.model';
|
|
7
|
-
export declare class OrderPayment extends TimeStamps {
|
|
8
|
-
order: Ref<Order>;
|
|
9
|
-
paymentMethod?: PaymentMethod;
|
|
10
|
-
paymentInformation?: PaymentInformation;
|
|
11
|
-
status?: PaymentStatus;
|
|
12
|
-
receiptUrl?: string;
|
|
13
|
-
attempts?: PaymentAttempt[];
|
|
14
|
-
currency: string;
|
|
15
|
-
amount: number;
|
|
16
|
-
secondaryAmount?: number;
|
|
17
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.OrderPayment = void 0;
|
|
13
|
-
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
|
-
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
|
-
const order_model_1 = require("./order.model");
|
|
16
|
-
const enum_1 = require("../../../utilities/enum");
|
|
17
|
-
const payment_infromation_model_1 = require("./embedded/payment-infromation.model");
|
|
18
|
-
const payment_attempt_model_1 = require("./embedded/payment-attempt.model");
|
|
19
|
-
let OrderPayment = class OrderPayment extends defaultClasses_1.TimeStamps {
|
|
20
|
-
order;
|
|
21
|
-
paymentMethod;
|
|
22
|
-
paymentInformation;
|
|
23
|
-
status;
|
|
24
|
-
receiptUrl;
|
|
25
|
-
attempts;
|
|
26
|
-
currency;
|
|
27
|
-
amount;
|
|
28
|
-
secondaryAmount;
|
|
29
|
-
};
|
|
30
|
-
exports.OrderPayment = OrderPayment;
|
|
31
|
-
__decorate([
|
|
32
|
-
(0, typegoose_1.prop)({ required: true, ref: () => order_model_1.Order, index: true, unique: true }),
|
|
33
|
-
__metadata("design:type", Object)
|
|
34
|
-
], OrderPayment.prototype, "order", void 0);
|
|
35
|
-
__decorate([
|
|
36
|
-
(0, typegoose_1.prop)({ type: String, enum: enum_1.PaymentMethod, default: enum_1.PaymentMethod.CASH }),
|
|
37
|
-
__metadata("design:type", String)
|
|
38
|
-
], OrderPayment.prototype, "paymentMethod", void 0);
|
|
39
|
-
__decorate([
|
|
40
|
-
(0, typegoose_1.prop)({ type: () => payment_infromation_model_1.PaymentInformation }),
|
|
41
|
-
__metadata("design:type", payment_infromation_model_1.PaymentInformation)
|
|
42
|
-
], OrderPayment.prototype, "paymentInformation", void 0);
|
|
43
|
-
__decorate([
|
|
44
|
-
(0, typegoose_1.prop)({ type: String, enum: enum_1.PaymentStatus, default: enum_1.PaymentStatus.PENDING }),
|
|
45
|
-
__metadata("design:type", String)
|
|
46
|
-
], OrderPayment.prototype, "status", void 0);
|
|
47
|
-
__decorate([
|
|
48
|
-
(0, typegoose_1.prop)(),
|
|
49
|
-
__metadata("design:type", String)
|
|
50
|
-
], OrderPayment.prototype, "receiptUrl", void 0);
|
|
51
|
-
__decorate([
|
|
52
|
-
(0, typegoose_1.prop)({ type: [payment_attempt_model_1.PaymentAttempt], default: [] }),
|
|
53
|
-
__metadata("design:type", Array)
|
|
54
|
-
], OrderPayment.prototype, "attempts", void 0);
|
|
55
|
-
__decorate([
|
|
56
|
-
(0, typegoose_1.prop)({ type: String }),
|
|
57
|
-
__metadata("design:type", String)
|
|
58
|
-
], OrderPayment.prototype, "currency", void 0);
|
|
59
|
-
__decorate([
|
|
60
|
-
(0, typegoose_1.prop)({ required: true, type: Number }),
|
|
61
|
-
__metadata("design:type", Number)
|
|
62
|
-
], OrderPayment.prototype, "amount", void 0);
|
|
63
|
-
__decorate([
|
|
64
|
-
(0, typegoose_1.prop)({ type: Number }),
|
|
65
|
-
__metadata("design:type", Number)
|
|
66
|
-
], OrderPayment.prototype, "secondaryAmount", void 0);
|
|
67
|
-
exports.OrderPayment = OrderPayment = __decorate([
|
|
68
|
-
(0, typegoose_1.modelOptions)({
|
|
69
|
-
schemaOptions: {
|
|
70
|
-
timestamps: true,
|
|
71
|
-
collection: 'orderPayments',
|
|
72
|
-
toJSON: { virtuals: true },
|
|
73
|
-
toObject: { virtuals: true },
|
|
74
|
-
},
|
|
75
|
-
options: {
|
|
76
|
-
allowMixed: typegoose_1.Severity.ALLOW,
|
|
77
|
-
},
|
|
78
|
-
}),
|
|
79
|
-
(0, typegoose_1.index)({ order: 1 }),
|
|
80
|
-
(0, typegoose_1.index)({ status: 1 }),
|
|
81
|
-
(0, typegoose_1.index)({ paymentMethod: 1 }),
|
|
82
|
-
(0, typegoose_1.index)({ createdAt: -1 })
|
|
83
|
-
], OrderPayment);
|
|
84
|
-
//# sourceMappingURL=order-payment.model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"order-payment.model.js","sourceRoot":"/","sources":["libraries/mongo/models/order-payment.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAgF;AAChF,4EAAqE;AACrE,+CAAsC;AACtC,kDAAuE;AACvE,oFAA0E;AAC1E,4EAAkE;AAiB3D,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,2BAAU;IAE3C,KAAK,CAAa;IAGlB,aAAa,CAAi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;YAC3B,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC1B,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC5B;QACD,OAAO,EAAE;YACR,UAAU,EAAE,oBAAQ,CAAC,KAAK;SAC1B;KACD,CAAC;IACD,IAAA,iBAAK,EAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACnB,IAAA,iBAAK,EAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IACpB,IAAA,iBAAK,EAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;IAC3B,IAAA,iBAAK,EAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;GACZ,YAAY,CA2BxB","sourcesContent":["import { index, modelOptions, prop, Ref, Severity } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Order } from './order.model';\nimport { PaymentMethod, PaymentStatus } from '../../../utilities/enum';\nimport { PaymentInformation } from './embedded/payment-infromation.model';\nimport { PaymentAttempt } from './embedded/payment-attempt.model';\n\n@modelOptions({\n\tschemaOptions: {\n\t\ttimestamps: true,\n\t\tcollection: 'orderPayments',\n\t\ttoJSON: { virtuals: true },\n\t\ttoObject: { virtuals: true },\n\t},\n\toptions: {\n\t\tallowMixed: Severity.ALLOW,\n\t},\n})\n@index({ order: 1 })\n@index({ status: 1 })\n@index({ paymentMethod: 1 })\n@index({ createdAt: -1 })\nexport class OrderPayment extends TimeStamps {\n\t@prop({ required: true, ref: () => Order, index: true, unique: true })\n\torder: Ref<Order>;\n\n\t@prop({ type: String, enum: PaymentMethod, default: PaymentMethod.CASH })\n\tpaymentMethod?: PaymentMethod;\n\n\t@prop({ type: () => PaymentInformation })\n\tpaymentInformation?: PaymentInformation;\n\n\t@prop({ type: String, enum: PaymentStatus, default: PaymentStatus.PENDING })\n\tstatus?: PaymentStatus;\n\n\t@prop()\n\treceiptUrl?: string;\n\n\t@prop({ type: [PaymentAttempt], default: [] })\n\tattempts?: PaymentAttempt[];\n\n\t@prop({ type: String })\n\tcurrency: string;\n\n\t@prop({ required: true, type: Number })\n\tamount: number;\n\n\t@prop({ type: Number })\n\tsecondaryAmount?: number;\n}\n"]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Ref } from '@typegoose/typegoose';
|
|
2
|
-
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
3
|
-
import { User } from './user.model';
|
|
4
|
-
import { Shop } from './shop.model';
|
|
5
|
-
import { Order } from './order.model';
|
|
6
|
-
import { Admin } from './admin.model';
|
|
7
|
-
import { TicketType, TicketStatus } from '../../../utilities/enum';
|
|
8
|
-
import { Chatroom } from './chat-room.model';
|
|
9
|
-
export declare class Ticket extends TimeStamps {
|
|
10
|
-
ticketId: string;
|
|
11
|
-
type: TicketType;
|
|
12
|
-
status: TicketStatus;
|
|
13
|
-
client: Ref<User | Shop>;
|
|
14
|
-
clientType: string;
|
|
15
|
-
subject: string;
|
|
16
|
-
description?: string;
|
|
17
|
-
order?: Ref<Order>;
|
|
18
|
-
assignedAgent?: Ref<Admin>;
|
|
19
|
-
assignedAt?: Date;
|
|
20
|
-
assignmentAttempts?: number;
|
|
21
|
-
chatroom: Ref<Chatroom>;
|
|
22
|
-
resolvedAt?: Date;
|
|
23
|
-
closedAt?: Date;
|
|
24
|
-
resolutionTimeMinutes?: number;
|
|
25
|
-
customerRating?: number;
|
|
26
|
-
customerFeedback?: string;
|
|
27
|
-
agentScore?: number;
|
|
28
|
-
tags?: string[];
|
|
29
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
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;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.Ticket = void 0;
|
|
46
|
-
const typegoose_1 = require("@typegoose/typegoose");
|
|
47
|
-
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
48
|
-
const order_model_1 = require("./order.model");
|
|
49
|
-
const admin_model_1 = require("./admin.model");
|
|
50
|
-
const enum_1 = require("../../../utilities/enum");
|
|
51
|
-
const chat_room_model_1 = require("./chat-room.model");
|
|
52
|
-
let Ticket = class Ticket extends defaultClasses_1.TimeStamps {
|
|
53
|
-
ticketId;
|
|
54
|
-
type;
|
|
55
|
-
status;
|
|
56
|
-
client;
|
|
57
|
-
clientType;
|
|
58
|
-
subject;
|
|
59
|
-
description;
|
|
60
|
-
order;
|
|
61
|
-
assignedAgent;
|
|
62
|
-
assignedAt;
|
|
63
|
-
assignmentAttempts;
|
|
64
|
-
chatroom;
|
|
65
|
-
resolvedAt;
|
|
66
|
-
closedAt;
|
|
67
|
-
resolutionTimeMinutes;
|
|
68
|
-
customerRating;
|
|
69
|
-
customerFeedback;
|
|
70
|
-
agentScore;
|
|
71
|
-
tags;
|
|
72
|
-
};
|
|
73
|
-
exports.Ticket = Ticket;
|
|
74
|
-
__decorate([
|
|
75
|
-
(0, typegoose_1.prop)({ required: true, type: String, unique: true }),
|
|
76
|
-
__metadata("design:type", String)
|
|
77
|
-
], Ticket.prototype, "ticketId", void 0);
|
|
78
|
-
__decorate([
|
|
79
|
-
(0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.TicketType }),
|
|
80
|
-
__metadata("design:type", String)
|
|
81
|
-
], Ticket.prototype, "type", void 0);
|
|
82
|
-
__decorate([
|
|
83
|
-
(0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.TicketStatus, default: enum_1.TicketStatus.PENDING }),
|
|
84
|
-
__metadata("design:type", String)
|
|
85
|
-
], Ticket.prototype, "status", void 0);
|
|
86
|
-
__decorate([
|
|
87
|
-
(0, typegoose_1.prop)({ refPath: 'clientType', required: true }),
|
|
88
|
-
__metadata("design:type", Object)
|
|
89
|
-
], Ticket.prototype, "client", void 0);
|
|
90
|
-
__decorate([
|
|
91
|
-
(0, typegoose_1.prop)({ required: true, type: String, enum: ['User', 'Shop'] }),
|
|
92
|
-
__metadata("design:type", String)
|
|
93
|
-
], Ticket.prototype, "clientType", void 0);
|
|
94
|
-
__decorate([
|
|
95
|
-
(0, typegoose_1.prop)({ type: String, required: true }),
|
|
96
|
-
__metadata("design:type", String)
|
|
97
|
-
], Ticket.prototype, "subject", void 0);
|
|
98
|
-
__decorate([
|
|
99
|
-
(0, typegoose_1.prop)({ type: String }),
|
|
100
|
-
__metadata("design:type", String)
|
|
101
|
-
], Ticket.prototype, "description", void 0);
|
|
102
|
-
__decorate([
|
|
103
|
-
(0, typegoose_1.prop)({ ref: () => order_model_1.Order }),
|
|
104
|
-
__metadata("design:type", Object)
|
|
105
|
-
], Ticket.prototype, "order", void 0);
|
|
106
|
-
__decorate([
|
|
107
|
-
(0, typegoose_1.prop)({ ref: () => admin_model_1.Admin }),
|
|
108
|
-
__metadata("design:type", Object)
|
|
109
|
-
], Ticket.prototype, "assignedAgent", void 0);
|
|
110
|
-
__decorate([
|
|
111
|
-
(0, typegoose_1.prop)({ type: Date }),
|
|
112
|
-
__metadata("design:type", Date)
|
|
113
|
-
], Ticket.prototype, "assignedAt", void 0);
|
|
114
|
-
__decorate([
|
|
115
|
-
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
116
|
-
__metadata("design:type", Number)
|
|
117
|
-
], Ticket.prototype, "assignmentAttempts", void 0);
|
|
118
|
-
__decorate([
|
|
119
|
-
(0, typegoose_1.prop)({ ref: () => chat_room_model_1.Chatroom, required: true }),
|
|
120
|
-
__metadata("design:type", Object)
|
|
121
|
-
], Ticket.prototype, "chatroom", void 0);
|
|
122
|
-
__decorate([
|
|
123
|
-
(0, typegoose_1.prop)({ type: Date }),
|
|
124
|
-
__metadata("design:type", Date)
|
|
125
|
-
], Ticket.prototype, "resolvedAt", void 0);
|
|
126
|
-
__decorate([
|
|
127
|
-
(0, typegoose_1.prop)({ type: Date }),
|
|
128
|
-
__metadata("design:type", Date)
|
|
129
|
-
], Ticket.prototype, "closedAt", void 0);
|
|
130
|
-
__decorate([
|
|
131
|
-
(0, typegoose_1.prop)({ type: Number }),
|
|
132
|
-
__metadata("design:type", Number)
|
|
133
|
-
], Ticket.prototype, "resolutionTimeMinutes", void 0);
|
|
134
|
-
__decorate([
|
|
135
|
-
(0, typegoose_1.prop)({ type: Number, min: 1, max: 5 }),
|
|
136
|
-
__metadata("design:type", Number)
|
|
137
|
-
], Ticket.prototype, "customerRating", void 0);
|
|
138
|
-
__decorate([
|
|
139
|
-
(0, typegoose_1.prop)({ type: String }),
|
|
140
|
-
__metadata("design:type", String)
|
|
141
|
-
], Ticket.prototype, "customerFeedback", void 0);
|
|
142
|
-
__decorate([
|
|
143
|
-
(0, typegoose_1.prop)({ type: Number }),
|
|
144
|
-
__metadata("design:type", Number)
|
|
145
|
-
], Ticket.prototype, "agentScore", void 0);
|
|
146
|
-
__decorate([
|
|
147
|
-
(0, typegoose_1.prop)({ type: [String], default: [] }),
|
|
148
|
-
__metadata("design:type", Array)
|
|
149
|
-
], Ticket.prototype, "tags", void 0);
|
|
150
|
-
exports.Ticket = Ticket = __decorate([
|
|
151
|
-
(0, typegoose_1.pre)('save', async function (next) {
|
|
152
|
-
if (this.isNew && !this.ticketId) {
|
|
153
|
-
const { CounterModel } = await Promise.resolve().then(() => __importStar(require('.')));
|
|
154
|
-
try {
|
|
155
|
-
const counter = await CounterModel.findOneAndUpdate({ counterType: 'ticket' }, { $inc: { value: 1 } }, { new: true, upsert: true });
|
|
156
|
-
const currentDate = new Date().toISOString().slice(0, 10).replace(/-/g, '');
|
|
157
|
-
this.ticketId = `TKT-${currentDate}-${String(counter.value).padStart(4, '0')}`;
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
return next(error);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
next();
|
|
164
|
-
}),
|
|
165
|
-
(0, typegoose_1.modelOptions)({
|
|
166
|
-
schemaOptions: {
|
|
167
|
-
collection: 'tickets',
|
|
168
|
-
timestamps: true,
|
|
169
|
-
},
|
|
170
|
-
}),
|
|
171
|
-
(0, typegoose_1.index)({ assignedAgent: 1, status: 1 }),
|
|
172
|
-
(0, typegoose_1.index)({ type: 1, status: 1, priority: 1 }),
|
|
173
|
-
(0, typegoose_1.index)({ client: 1, clientType: 1, status: 1 }),
|
|
174
|
-
(0, typegoose_1.index)({ createdAt: -1 }),
|
|
175
|
-
(0, typegoose_1.index)({ ticketId: 1 }, { unique: true }),
|
|
176
|
-
(0, typegoose_1.index)({ chatroom: 1 })
|
|
177
|
-
], Ticket);
|
|
178
|
-
//# sourceMappingURL=ticket.model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ticket.model.js","sourceRoot":"/","sources":["libraries/mongo/models/ticket.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAiF;AACjF,4EAAqE;AAGrE,+CAAsC;AACtC,+CAAsC;AACtC,kDAAmE;AACnE,uDAA6C;AAiCtC,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,2BAAU;IAE9B,QAAQ,CAAU;IAGlB,IAAI,CAAc;IAGlB,MAAM,CAAgB;IAGtB,MAAM,CAAoB;IAG1B,UAAU,CAAU;IAGpB,OAAO,CAAU;IAGjB,WAAW,CAAU;IAGrB,KAAK,CAAc;IAGnB,aAAa,CAAc;IAG3B,UAAU,CAAQ;IAGlB,kBAAkB,CAAU;IAG5B,QAAQ,CAAiB;IAGzB,UAAU,CAAQ;IAGlB,QAAQ,CAAQ;IAGh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imeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { User } from './user.model';\nimport { Shop } from './shop.model';\nimport { Order } from './order.model';\nimport { Admin } from './admin.model';\nimport { TicketType, TicketStatus } from '../../../utilities/enum';\nimport { Chatroom } from './chat-room.model';\n\n@pre<Ticket>('save', async function (next) {\n\tif (this.isNew && !this.ticketId) {\n\t\tconst { CounterModel } = await import('.');\n\n\t\ttry {\n\t\t\tconst counter = await CounterModel.findOneAndUpdate(\n\t\t\t\t{ counterType: 'ticket' },\n\t\t\t\t{ $inc: { value: 1 } },\n\t\t\t\t{ new: true, upsert: true }\n\t\t\t);\n\n\t\t\tconst currentDate = new Date().toISOString().slice(0, 10).replace(/-/g, '');\n\t\t\tthis.ticketId = `TKT-${currentDate}-${String(counter.value).padStart(4, '0')}`;\n\t\t} catch (error) {\n\t\t\treturn next(error as Error);\n\t\t}\n\t}\n\tnext();\n})\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'tickets',\n\t\ttimestamps: true,\n\t},\n})\n@index({ assignedAgent: 1, status: 1 })\n@index({ type: 1, status: 1, priority: 1 })\n@index({ client: 1, clientType: 1, status: 1 })\n@index({ createdAt: -1 })\n@index({ ticketId: 1 }, { unique: true })\n@index({ chatroom: 1 })\nexport class Ticket extends TimeStamps {\n\t@prop({ required: true, type: String, unique: true })\n\tpublic ticketId!: string;\n\n\t@prop({ required: true, type: String, enum: TicketType })\n\tpublic type!: TicketType;\n\n\t@prop({ required: true, type: String, enum: TicketStatus, default: TicketStatus.PENDING })\n\tpublic status!: TicketStatus;\n\n\t@prop({ refPath: 'clientType', required: true })\n\tpublic client!: Ref<User | Shop>;\n\n\t@prop({ required: true, type: String, enum: ['User', 'Shop'] })\n\tpublic clientType!: string;\n\n\t@prop({ type: String, required: true })\n\tpublic subject!: string;\n\n\t@prop({ type: String })\n\tpublic description?: string;\n\n\t@prop({ ref: () => Order })\n\tpublic order?: Ref<Order>;\n\n\t@prop({ ref: () => Admin })\n\tpublic assignedAgent?: Ref<Admin>;\n\n\t@prop({ type: Date })\n\tpublic assignedAt?: Date;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic assignmentAttempts?: number;\n\n\t@prop({ ref: () => Chatroom, required: true })\n\tpublic chatroom!: Ref<Chatroom>;\n\n\t@prop({ type: Date })\n\tpublic resolvedAt?: Date;\n\n\t@prop({ type: Date })\n\tpublic closedAt?: Date;\n\n\t@prop({ type: Number })\n\tpublic resolutionTimeMinutes?: number;\n\n\t@prop({ type: Number, min: 1, max: 5 })\n\tpublic customerRating?: number;\n\n\t@prop({ type: String })\n\tpublic customerFeedback?: string;\n\n\t@prop({ type: Number })\n\tpublic agentScore?: number;\n\n\t@prop({ type: [String], default: [] })\n\tpublic tags?: string[];\n}\n"]}
|