@common_ch/common 1.0.309 → 1.0.310
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.
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SupportChatStatusEnum = exports.MessageTypeSupportChatEnum = void 0;
|
|
4
|
+
var MessageTypeSupportChatEnum;
|
|
5
|
+
(function (MessageTypeSupportChatEnum) {
|
|
6
|
+
MessageTypeSupportChatEnum["user"] = "user";
|
|
7
|
+
MessageTypeSupportChatEnum["admin"] = "admin";
|
|
8
|
+
})(MessageTypeSupportChatEnum || (exports.MessageTypeSupportChatEnum = MessageTypeSupportChatEnum = {}));
|
|
9
|
+
var SupportChatStatusEnum;
|
|
10
|
+
(function (SupportChatStatusEnum) {
|
|
11
|
+
SupportChatStatusEnum["chatting"] = "chatting";
|
|
12
|
+
SupportChatStatusEnum["start"] = "start";
|
|
13
|
+
SupportChatStatusEnum["done"] = "done";
|
|
14
|
+
})(SupportChatStatusEnum || (exports.SupportChatStatusEnum = SupportChatStatusEnum = {}));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { MessageTypeSupportChatEnum, SupportChatStatusEnum } from '../../enums/supportChat';
|
|
3
|
+
export interface SupportChatAttrs {
|
|
4
|
+
userId: string;
|
|
5
|
+
messages: {
|
|
6
|
+
message: string;
|
|
7
|
+
typeMessage: MessageTypeSupportChatEnum;
|
|
8
|
+
file?: string;
|
|
9
|
+
adminName?: string;
|
|
10
|
+
adminFamily?: string;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
}[];
|
|
13
|
+
status?: SupportChatStatusEnum;
|
|
14
|
+
createdAt?: string;
|
|
15
|
+
updatedAt?: string;
|
|
16
|
+
}
|
|
17
|
+
interface SupportChatModel extends mongoose.Model<SupportChatDoc> {
|
|
18
|
+
build(attrs: SupportChatAttrs): SupportChatDoc;
|
|
19
|
+
}
|
|
20
|
+
export interface SupportChatDoc extends mongoose.Document {
|
|
21
|
+
_id: string;
|
|
22
|
+
userId: string;
|
|
23
|
+
messages: {
|
|
24
|
+
message: string;
|
|
25
|
+
typeMessage: MessageTypeSupportChatEnum;
|
|
26
|
+
file?: string;
|
|
27
|
+
adminName?: string;
|
|
28
|
+
adminFamily?: string;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
}[];
|
|
31
|
+
status?: SupportChatStatusEnum;
|
|
32
|
+
createdAt?: string;
|
|
33
|
+
updatedAt?: string;
|
|
34
|
+
}
|
|
35
|
+
declare const SupportChat: SupportChatModel;
|
|
36
|
+
export { SupportChat };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SupportChat = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const mongoose_update_if_current_1 = require("mongoose-update-if-current");
|
|
9
|
+
const supportChat_1 = require("../../enums/supportChat");
|
|
10
|
+
const supportChatSchema = new mongoose_1.default.Schema({
|
|
11
|
+
userId: {
|
|
12
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
13
|
+
ref: 'User',
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
messages: [{
|
|
17
|
+
file: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: false,
|
|
20
|
+
},
|
|
21
|
+
message: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
adminName: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: false,
|
|
28
|
+
},
|
|
29
|
+
adminFamily: {
|
|
30
|
+
type: String,
|
|
31
|
+
required: false,
|
|
32
|
+
},
|
|
33
|
+
typeMessage: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: true,
|
|
36
|
+
default: supportChat_1.MessageTypeSupportChatEnum.user
|
|
37
|
+
},
|
|
38
|
+
createdAt: {
|
|
39
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
40
|
+
}
|
|
41
|
+
}],
|
|
42
|
+
status: {
|
|
43
|
+
type: String,
|
|
44
|
+
enum: supportChat_1.SupportChatStatusEnum,
|
|
45
|
+
default: supportChat_1.SupportChatStatusEnum.start,
|
|
46
|
+
},
|
|
47
|
+
createdAt: {
|
|
48
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
49
|
+
},
|
|
50
|
+
updatedAt: {
|
|
51
|
+
type: mongoose_1.default.Schema.Types.Date,
|
|
52
|
+
},
|
|
53
|
+
}, {
|
|
54
|
+
timestamps: true,
|
|
55
|
+
});
|
|
56
|
+
supportChatSchema.set('versionKey', 'version');
|
|
57
|
+
supportChatSchema.plugin(mongoose_update_if_current_1.updateIfCurrentPlugin);
|
|
58
|
+
supportChatSchema.index({ 'userId': 1 });
|
|
59
|
+
supportChatSchema.statics.build = (attrs) => {
|
|
60
|
+
return new SupportChat(attrs);
|
|
61
|
+
};
|
|
62
|
+
const SupportChat = mongoose_1.default.model('SupportChat', supportChatSchema);
|
|
63
|
+
exports.SupportChat = SupportChat;
|