@platform-modules/foreign-ministry 1.0.26 → 1.0.27
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/data-source.js +7 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/models/ConversationModel.d.ts +16 -0
- package/dist/models/ConversationModel.js +64 -0
- package/dist/models/ConversationParticipantModel.d.ts +14 -0
- package/dist/models/ConversationParticipantModel.js +68 -0
- package/dist/models/MessageModel.d.ts +27 -0
- package/dist/models/MessageModel.js +108 -0
- package/package.json +1 -1
- package/src/data-source.ts +7 -1
- package/src/index.ts +3 -0
- package/src/models/ConversationModel.ts +48 -0
- package/src/models/ConversationParticipantModel.ts +51 -0
- package/src/models/MessageModel.ts +93 -0
package/dist/data-source.js
CHANGED
|
@@ -26,6 +26,9 @@ const DepartmentsModel_1 = require("./models/DepartmentsModel");
|
|
|
26
26
|
const DivisionModel_1 = require("./models/DivisionModel");
|
|
27
27
|
const faqsModel_1 = require("./models/faqsModel");
|
|
28
28
|
const questionTagsModel_1 = require("./models/questionTagsModel");
|
|
29
|
+
const ConversationModel_1 = require("./models/ConversationModel");
|
|
30
|
+
const ConversationParticipantModel_1 = require("./models/ConversationParticipantModel");
|
|
31
|
+
const MessageModel_1 = require("./models/MessageModel");
|
|
29
32
|
exports.AppDataSource = new typeorm_1.DataSource({
|
|
30
33
|
type: 'postgres',
|
|
31
34
|
host: process.env.DB_HOST || 'localhost',
|
|
@@ -56,6 +59,9 @@ exports.AppDataSource = new typeorm_1.DataSource({
|
|
|
56
59
|
DepartmentsModel_1.Departments,
|
|
57
60
|
DivisionModel_1.Division,
|
|
58
61
|
faqsModel_1.Faqs,
|
|
59
|
-
questionTagsModel_1.QuestionTags
|
|
62
|
+
questionTagsModel_1.QuestionTags,
|
|
63
|
+
ConversationModel_1.Conversation,
|
|
64
|
+
ConversationParticipantModel_1.ConversationParticipant,
|
|
65
|
+
MessageModel_1.Message
|
|
60
66
|
],
|
|
61
67
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -19,3 +19,6 @@ export * from './models/DepartmentsModel';
|
|
|
19
19
|
export * from './models/DivisionModel';
|
|
20
20
|
export * from './models/faqsModel';
|
|
21
21
|
export * from './models/questionTagsModel';
|
|
22
|
+
export * from './models/ConversationModel';
|
|
23
|
+
export * from './models/ConversationParticipantModel';
|
|
24
|
+
export * from './models/MessageModel';
|
package/dist/index.js
CHANGED
|
@@ -35,3 +35,6 @@ __exportStar(require("./models/DepartmentsModel"), exports);
|
|
|
35
35
|
__exportStar(require("./models/DivisionModel"), exports);
|
|
36
36
|
__exportStar(require("./models/faqsModel"), exports);
|
|
37
37
|
__exportStar(require("./models/questionTagsModel"), exports);
|
|
38
|
+
__exportStar(require("./models/ConversationModel"), exports);
|
|
39
|
+
__exportStar(require("./models/ConversationParticipantModel"), exports);
|
|
40
|
+
__exportStar(require("./models/MessageModel"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseModel } from './BaseModel';
|
|
2
|
+
import { ConversationParticipant } from './ConversationParticipantModel';
|
|
3
|
+
import { Message } from './MessageModel';
|
|
4
|
+
export declare enum ConversationType {
|
|
5
|
+
DIRECT = "Direct",
|
|
6
|
+
GROUP = "Group"
|
|
7
|
+
}
|
|
8
|
+
export declare class Conversation extends BaseModel {
|
|
9
|
+
conversationType: ConversationType;
|
|
10
|
+
conversationName?: string;
|
|
11
|
+
createdAt: Date;
|
|
12
|
+
updatedAt?: Date;
|
|
13
|
+
participants?: ConversationParticipant[];
|
|
14
|
+
messages?: Message[];
|
|
15
|
+
constructor(conversationType?: ConversationType, conversationName?: string, createdAt?: Date, updatedAt?: Date);
|
|
16
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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.Conversation = exports.ConversationType = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const BaseModel_1 = require("./BaseModel");
|
|
15
|
+
const ConversationParticipantModel_1 = require("./ConversationParticipantModel");
|
|
16
|
+
const MessageModel_1 = require("./MessageModel");
|
|
17
|
+
var ConversationType;
|
|
18
|
+
(function (ConversationType) {
|
|
19
|
+
ConversationType["DIRECT"] = "Direct";
|
|
20
|
+
ConversationType["GROUP"] = "Group";
|
|
21
|
+
})(ConversationType || (exports.ConversationType = ConversationType = {}));
|
|
22
|
+
let Conversation = class Conversation extends BaseModel_1.BaseModel {
|
|
23
|
+
constructor(conversationType, conversationName, createdAt, updatedAt) {
|
|
24
|
+
super();
|
|
25
|
+
this.conversationType = conversationType || ConversationType.DIRECT;
|
|
26
|
+
this.conversationName = conversationName;
|
|
27
|
+
this.createdAt = createdAt || new Date();
|
|
28
|
+
this.updatedAt = updatedAt;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.Conversation = Conversation;
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.Column)({
|
|
34
|
+
type: 'enum',
|
|
35
|
+
enum: ConversationType,
|
|
36
|
+
default: ConversationType.DIRECT
|
|
37
|
+
}),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], Conversation.prototype, "conversationType", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], Conversation.prototype, "conversationName", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
46
|
+
__metadata("design:type", Date)
|
|
47
|
+
], Conversation.prototype, "createdAt", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.Column)({ type: 'timestamp', nullable: true }),
|
|
50
|
+
__metadata("design:type", Date)
|
|
51
|
+
], Conversation.prototype, "updatedAt", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, typeorm_1.OneToMany)(() => ConversationParticipantModel_1.ConversationParticipant, participant => participant.conversation),
|
|
54
|
+
__metadata("design:type", Array)
|
|
55
|
+
], Conversation.prototype, "participants", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, typeorm_1.OneToMany)(() => MessageModel_1.Message, message => message.conversation),
|
|
58
|
+
__metadata("design:type", Array)
|
|
59
|
+
], Conversation.prototype, "messages", void 0);
|
|
60
|
+
exports.Conversation = Conversation = __decorate([
|
|
61
|
+
(0, typeorm_1.Entity)({ name: 'conversations' }),
|
|
62
|
+
__metadata("design:paramtypes", [String, String, Date,
|
|
63
|
+
Date])
|
|
64
|
+
], Conversation);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseModel } from './BaseModel';
|
|
2
|
+
import { Conversation } from './ConversationModel';
|
|
3
|
+
import { User } from './user';
|
|
4
|
+
export declare class ConversationParticipant extends BaseModel {
|
|
5
|
+
conversationId: number;
|
|
6
|
+
userId: number;
|
|
7
|
+
roleId: number;
|
|
8
|
+
joinedAt: Date;
|
|
9
|
+
createdAt: Date;
|
|
10
|
+
updatedAt?: Date;
|
|
11
|
+
conversation?: Conversation;
|
|
12
|
+
user?: User;
|
|
13
|
+
constructor(conversationId?: number, userId?: number, roleId?: number, joinedAt?: Date, createdAt?: Date, updatedAt?: Date);
|
|
14
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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.ConversationParticipant = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const BaseModel_1 = require("./BaseModel");
|
|
15
|
+
const ConversationModel_1 = require("./ConversationModel");
|
|
16
|
+
const user_1 = require("./user");
|
|
17
|
+
let ConversationParticipant = class ConversationParticipant extends BaseModel_1.BaseModel {
|
|
18
|
+
constructor(conversationId, userId, roleId, joinedAt, createdAt, updatedAt) {
|
|
19
|
+
super();
|
|
20
|
+
this.conversationId = conversationId || 0;
|
|
21
|
+
this.userId = userId || 0;
|
|
22
|
+
this.roleId = roleId || 0;
|
|
23
|
+
this.joinedAt = joinedAt || new Date();
|
|
24
|
+
this.createdAt = createdAt || new Date();
|
|
25
|
+
this.updatedAt = updatedAt;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.ConversationParticipant = ConversationParticipant;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.Column)({ type: 'bigint' }),
|
|
31
|
+
__metadata("design:type", Number)
|
|
32
|
+
], ConversationParticipant.prototype, "conversationId", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)({ type: 'int' }),
|
|
35
|
+
__metadata("design:type", Number)
|
|
36
|
+
], ConversationParticipant.prototype, "userId", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ type: 'int' }),
|
|
39
|
+
__metadata("design:type", Number)
|
|
40
|
+
], ConversationParticipant.prototype, "roleId", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
43
|
+
__metadata("design:type", Date)
|
|
44
|
+
], ConversationParticipant.prototype, "joinedAt", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
47
|
+
__metadata("design:type", Date)
|
|
48
|
+
], ConversationParticipant.prototype, "createdAt", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typeorm_1.Column)({ type: 'timestamp', nullable: true }),
|
|
51
|
+
__metadata("design:type", Date)
|
|
52
|
+
], ConversationParticipant.prototype, "updatedAt", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.ManyToOne)(() => ConversationModel_1.Conversation, conversation => conversation.participants),
|
|
55
|
+
(0, typeorm_1.JoinColumn)({ name: 'conversationId' }),
|
|
56
|
+
__metadata("design:type", ConversationModel_1.Conversation)
|
|
57
|
+
], ConversationParticipant.prototype, "conversation", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typeorm_1.ManyToOne)(() => user_1.User),
|
|
60
|
+
(0, typeorm_1.JoinColumn)({ name: 'userId' }),
|
|
61
|
+
__metadata("design:type", user_1.User)
|
|
62
|
+
], ConversationParticipant.prototype, "user", void 0);
|
|
63
|
+
exports.ConversationParticipant = ConversationParticipant = __decorate([
|
|
64
|
+
(0, typeorm_1.Entity)({ name: 'conversation_participants' }),
|
|
65
|
+
__metadata("design:paramtypes", [Number, Number, Number, Date,
|
|
66
|
+
Date,
|
|
67
|
+
Date])
|
|
68
|
+
], ConversationParticipant);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseModel } from './BaseModel';
|
|
2
|
+
import { Conversation } from './ConversationModel';
|
|
3
|
+
import { User } from './user';
|
|
4
|
+
export declare enum MessageType {
|
|
5
|
+
TEXT = "text",
|
|
6
|
+
IMAGE = "image",
|
|
7
|
+
VIDEO = "video",
|
|
8
|
+
FILE = "file",
|
|
9
|
+
LINK = "link"
|
|
10
|
+
}
|
|
11
|
+
export declare class Message extends BaseModel {
|
|
12
|
+
conversationId: number;
|
|
13
|
+
senderId: number;
|
|
14
|
+
content?: string;
|
|
15
|
+
messageType: MessageType;
|
|
16
|
+
replyToMessageId?: number;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
isDeleted: boolean;
|
|
19
|
+
attachmentUrl?: string;
|
|
20
|
+
attachmentFileType?: string;
|
|
21
|
+
attachmentFileName?: string;
|
|
22
|
+
attachmentFileSize?: number;
|
|
23
|
+
deletedAt?: Date;
|
|
24
|
+
conversation?: Conversation;
|
|
25
|
+
sender?: User;
|
|
26
|
+
constructor(conversationId?: number, senderId?: number, content?: string, messageType?: MessageType, replyToMessageId?: number, createdAt?: Date, isDeleted?: boolean, attachmentUrl?: string, attachmentFileType?: string, attachmentFileName?: string, attachmentFileSize?: number, deletedAt?: Date);
|
|
27
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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 = exports.MessageType = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const BaseModel_1 = require("./BaseModel");
|
|
15
|
+
const ConversationModel_1 = require("./ConversationModel");
|
|
16
|
+
const user_1 = require("./user");
|
|
17
|
+
var MessageType;
|
|
18
|
+
(function (MessageType) {
|
|
19
|
+
MessageType["TEXT"] = "text";
|
|
20
|
+
MessageType["IMAGE"] = "image";
|
|
21
|
+
MessageType["VIDEO"] = "video";
|
|
22
|
+
MessageType["FILE"] = "file";
|
|
23
|
+
MessageType["LINK"] = "link";
|
|
24
|
+
})(MessageType || (exports.MessageType = MessageType = {}));
|
|
25
|
+
let Message = class Message extends BaseModel_1.BaseModel {
|
|
26
|
+
constructor(conversationId, senderId, content, messageType, replyToMessageId, createdAt, isDeleted, attachmentUrl, attachmentFileType, attachmentFileName, attachmentFileSize, deletedAt) {
|
|
27
|
+
super();
|
|
28
|
+
this.conversationId = conversationId || 0;
|
|
29
|
+
this.senderId = senderId || 0;
|
|
30
|
+
this.content = content || '';
|
|
31
|
+
this.messageType = messageType || MessageType.TEXT;
|
|
32
|
+
this.replyToMessageId = replyToMessageId;
|
|
33
|
+
this.createdAt = createdAt || new Date();
|
|
34
|
+
this.isDeleted = isDeleted || false;
|
|
35
|
+
this.attachmentUrl = attachmentUrl;
|
|
36
|
+
this.attachmentFileType = attachmentFileType;
|
|
37
|
+
this.attachmentFileName = attachmentFileName;
|
|
38
|
+
this.attachmentFileSize = attachmentFileSize;
|
|
39
|
+
this.deletedAt = deletedAt;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.Message = Message;
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ type: 'bigint' }),
|
|
45
|
+
__metadata("design:type", Number)
|
|
46
|
+
], Message.prototype, "conversationId", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typeorm_1.Column)({ type: 'int' }),
|
|
49
|
+
__metadata("design:type", Number)
|
|
50
|
+
], Message.prototype, "senderId", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true, default: '' }),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], Message.prototype, "content", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, typeorm_1.Column)({
|
|
57
|
+
type: 'enum',
|
|
58
|
+
enum: MessageType,
|
|
59
|
+
default: MessageType.TEXT
|
|
60
|
+
}),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], Message.prototype, "messageType", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, typeorm_1.Column)({ type: 'bigint', nullable: true }),
|
|
65
|
+
__metadata("design:type", Number)
|
|
66
|
+
], Message.prototype, "replyToMessageId", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
69
|
+
__metadata("design:type", Date)
|
|
70
|
+
], Message.prototype, "createdAt", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, typeorm_1.Column)({ type: 'boolean', default: false }),
|
|
73
|
+
__metadata("design:type", Boolean)
|
|
74
|
+
], Message.prototype, "isDeleted", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
77
|
+
__metadata("design:type", String)
|
|
78
|
+
], Message.prototype, "attachmentUrl", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 50, nullable: true }),
|
|
81
|
+
__metadata("design:type", String)
|
|
82
|
+
], Message.prototype, "attachmentFileType", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
|
|
85
|
+
__metadata("design:type", String)
|
|
86
|
+
], Message.prototype, "attachmentFileName", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
89
|
+
__metadata("design:type", Number)
|
|
90
|
+
], Message.prototype, "attachmentFileSize", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, typeorm_1.Column)({ type: 'timestamp', nullable: true }),
|
|
93
|
+
__metadata("design:type", Date)
|
|
94
|
+
], Message.prototype, "deletedAt", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
(0, typeorm_1.ManyToOne)(() => ConversationModel_1.Conversation, conversation => conversation.messages),
|
|
97
|
+
(0, typeorm_1.JoinColumn)({ name: 'conversationId' }),
|
|
98
|
+
__metadata("design:type", ConversationModel_1.Conversation)
|
|
99
|
+
], Message.prototype, "conversation", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, typeorm_1.ManyToOne)(() => user_1.User),
|
|
102
|
+
(0, typeorm_1.JoinColumn)({ name: 'senderId' }),
|
|
103
|
+
__metadata("design:type", user_1.User)
|
|
104
|
+
], Message.prototype, "sender", void 0);
|
|
105
|
+
exports.Message = Message = __decorate([
|
|
106
|
+
(0, typeorm_1.Entity)({ name: 'messages' }),
|
|
107
|
+
__metadata("design:paramtypes", [Number, Number, String, String, Number, Date, Boolean, String, String, String, Number, Date])
|
|
108
|
+
], Message);
|
package/package.json
CHANGED
package/src/data-source.ts
CHANGED
|
@@ -25,6 +25,9 @@ import { Division } from './models/DivisionModel';
|
|
|
25
25
|
|
|
26
26
|
import { Faqs } from './models/faqsModel';
|
|
27
27
|
import { QuestionTags } from './models/questionTagsModel';
|
|
28
|
+
import { Conversation } from './models/ConversationModel';
|
|
29
|
+
import { ConversationParticipant } from './models/ConversationParticipantModel';
|
|
30
|
+
import { Message } from './models/MessageModel';
|
|
28
31
|
|
|
29
32
|
|
|
30
33
|
export const AppDataSource = new DataSource({
|
|
@@ -57,6 +60,9 @@ export const AppDataSource = new DataSource({
|
|
|
57
60
|
Departments,
|
|
58
61
|
Division,
|
|
59
62
|
Faqs,
|
|
60
|
-
QuestionTags
|
|
63
|
+
QuestionTags,
|
|
64
|
+
Conversation,
|
|
65
|
+
ConversationParticipant,
|
|
66
|
+
Message
|
|
61
67
|
],
|
|
62
68
|
});
|
package/src/index.ts
CHANGED
|
@@ -19,3 +19,6 @@ export * from './models/DepartmentsModel';
|
|
|
19
19
|
export * from './models/DivisionModel';
|
|
20
20
|
export * from './models/faqsModel';
|
|
21
21
|
export * from './models/questionTagsModel';
|
|
22
|
+
export * from './models/ConversationModel';
|
|
23
|
+
export * from './models/ConversationParticipantModel';
|
|
24
|
+
export * from './models/MessageModel';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Column, Entity, OneToMany } from "typeorm";
|
|
2
|
+
import { BaseModel } from './BaseModel';
|
|
3
|
+
import { ConversationParticipant } from './ConversationParticipantModel';
|
|
4
|
+
import { Message } from './MessageModel';
|
|
5
|
+
|
|
6
|
+
export enum ConversationType {
|
|
7
|
+
DIRECT = "Direct",
|
|
8
|
+
GROUP = "Group"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@Entity({ name: 'conversations' })
|
|
12
|
+
export class Conversation extends BaseModel {
|
|
13
|
+
|
|
14
|
+
@Column({
|
|
15
|
+
type: 'enum',
|
|
16
|
+
enum: ConversationType,
|
|
17
|
+
default: ConversationType.DIRECT
|
|
18
|
+
})
|
|
19
|
+
conversationType: ConversationType;
|
|
20
|
+
|
|
21
|
+
@Column({ type: 'varchar', length: 255, nullable: true })
|
|
22
|
+
conversationName?: string;
|
|
23
|
+
|
|
24
|
+
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
25
|
+
createdAt: Date;
|
|
26
|
+
|
|
27
|
+
@Column({ type: 'timestamp', nullable: true })
|
|
28
|
+
updatedAt?: Date;
|
|
29
|
+
|
|
30
|
+
@OneToMany(() => ConversationParticipant, participant => participant.conversation)
|
|
31
|
+
participants?: ConversationParticipant[];
|
|
32
|
+
|
|
33
|
+
@OneToMany(() => Message, message => message.conversation)
|
|
34
|
+
messages?: Message[];
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
conversationType?: ConversationType,
|
|
38
|
+
conversationName?: string,
|
|
39
|
+
createdAt?: Date,
|
|
40
|
+
updatedAt?: Date
|
|
41
|
+
) {
|
|
42
|
+
super();
|
|
43
|
+
this.conversationType = conversationType || ConversationType.DIRECT;
|
|
44
|
+
this.conversationName = conversationName;
|
|
45
|
+
this.createdAt = createdAt || new Date();
|
|
46
|
+
this.updatedAt = updatedAt;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Column, Entity, ManyToOne, JoinColumn } from "typeorm";
|
|
2
|
+
import { BaseModel } from './BaseModel';
|
|
3
|
+
import { Conversation } from './ConversationModel';
|
|
4
|
+
import { User } from './user';
|
|
5
|
+
|
|
6
|
+
@Entity({ name: 'conversation_participants' })
|
|
7
|
+
export class ConversationParticipant extends BaseModel {
|
|
8
|
+
|
|
9
|
+
@Column({ type: 'bigint' })
|
|
10
|
+
conversationId: number;
|
|
11
|
+
|
|
12
|
+
@Column({ type: 'int' })
|
|
13
|
+
userId: number;
|
|
14
|
+
|
|
15
|
+
@Column({ type: 'int' })
|
|
16
|
+
roleId: number;
|
|
17
|
+
|
|
18
|
+
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
19
|
+
joinedAt: Date;
|
|
20
|
+
|
|
21
|
+
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
|
|
24
|
+
@Column({ type: 'timestamp', nullable: true })
|
|
25
|
+
updatedAt?: Date;
|
|
26
|
+
|
|
27
|
+
@ManyToOne(() => Conversation, conversation => conversation.participants)
|
|
28
|
+
@JoinColumn({ name: 'conversationId' })
|
|
29
|
+
conversation?: Conversation;
|
|
30
|
+
|
|
31
|
+
@ManyToOne(() => User)
|
|
32
|
+
@JoinColumn({ name: 'userId' })
|
|
33
|
+
user?: User;
|
|
34
|
+
|
|
35
|
+
constructor(
|
|
36
|
+
conversationId?: number,
|
|
37
|
+
userId?: number,
|
|
38
|
+
roleId?: number,
|
|
39
|
+
joinedAt?: Date,
|
|
40
|
+
createdAt?: Date,
|
|
41
|
+
updatedAt?: Date
|
|
42
|
+
) {
|
|
43
|
+
super();
|
|
44
|
+
this.conversationId = conversationId || 0;
|
|
45
|
+
this.userId = userId || 0;
|
|
46
|
+
this.roleId = roleId || 0;
|
|
47
|
+
this.joinedAt = joinedAt || new Date();
|
|
48
|
+
this.createdAt = createdAt || new Date();
|
|
49
|
+
this.updatedAt = updatedAt;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Column, Entity, ManyToOne, JoinColumn } from "typeorm";
|
|
2
|
+
import { BaseModel } from './BaseModel';
|
|
3
|
+
import { Conversation } from './ConversationModel';
|
|
4
|
+
import { User } from './user';
|
|
5
|
+
|
|
6
|
+
export enum MessageType {
|
|
7
|
+
TEXT = "text",
|
|
8
|
+
IMAGE = "image",
|
|
9
|
+
VIDEO = "video",
|
|
10
|
+
FILE = "file",
|
|
11
|
+
LINK = "link"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@Entity({ name: 'messages' })
|
|
15
|
+
export class Message extends BaseModel {
|
|
16
|
+
|
|
17
|
+
@Column({ type: 'bigint' })
|
|
18
|
+
conversationId: number;
|
|
19
|
+
|
|
20
|
+
@Column({ type: 'int' })
|
|
21
|
+
senderId: number;
|
|
22
|
+
|
|
23
|
+
@Column({ type: 'text', nullable: true, default: '' })
|
|
24
|
+
content?: string;
|
|
25
|
+
|
|
26
|
+
@Column({
|
|
27
|
+
type: 'enum',
|
|
28
|
+
enum: MessageType,
|
|
29
|
+
default: MessageType.TEXT
|
|
30
|
+
})
|
|
31
|
+
messageType: MessageType;
|
|
32
|
+
|
|
33
|
+
@Column({ type: 'bigint', nullable: true })
|
|
34
|
+
replyToMessageId?: number;
|
|
35
|
+
|
|
36
|
+
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
37
|
+
createdAt: Date;
|
|
38
|
+
|
|
39
|
+
@Column({ type: 'boolean', default: false })
|
|
40
|
+
isDeleted: boolean;
|
|
41
|
+
|
|
42
|
+
@Column({ type: 'text', nullable: true })
|
|
43
|
+
attachmentUrl?: string;
|
|
44
|
+
|
|
45
|
+
@Column({ type: 'varchar', length: 50, nullable: true })
|
|
46
|
+
attachmentFileType?: string;
|
|
47
|
+
|
|
48
|
+
@Column({ type: 'varchar', length: 255, nullable: true })
|
|
49
|
+
attachmentFileName?: string;
|
|
50
|
+
|
|
51
|
+
@Column({ type: 'int', nullable: true })
|
|
52
|
+
attachmentFileSize?: number;
|
|
53
|
+
|
|
54
|
+
@Column({ type: 'timestamp', nullable: true })
|
|
55
|
+
deletedAt?: Date;
|
|
56
|
+
|
|
57
|
+
@ManyToOne(() => Conversation, conversation => conversation.messages)
|
|
58
|
+
@JoinColumn({ name: 'conversationId' })
|
|
59
|
+
conversation?: Conversation;
|
|
60
|
+
|
|
61
|
+
@ManyToOne(() => User)
|
|
62
|
+
@JoinColumn({ name: 'senderId' })
|
|
63
|
+
sender?: User;
|
|
64
|
+
|
|
65
|
+
constructor(
|
|
66
|
+
conversationId?: number,
|
|
67
|
+
senderId?: number,
|
|
68
|
+
content?: string,
|
|
69
|
+
messageType?: MessageType,
|
|
70
|
+
replyToMessageId?: number,
|
|
71
|
+
createdAt?: Date,
|
|
72
|
+
isDeleted?: boolean,
|
|
73
|
+
attachmentUrl?: string,
|
|
74
|
+
attachmentFileType?: string,
|
|
75
|
+
attachmentFileName?: string,
|
|
76
|
+
attachmentFileSize?: number,
|
|
77
|
+
deletedAt?: Date
|
|
78
|
+
) {
|
|
79
|
+
super();
|
|
80
|
+
this.conversationId = conversationId || 0;
|
|
81
|
+
this.senderId = senderId || 0;
|
|
82
|
+
this.content = content || '';
|
|
83
|
+
this.messageType = messageType || MessageType.TEXT;
|
|
84
|
+
this.replyToMessageId = replyToMessageId;
|
|
85
|
+
this.createdAt = createdAt || new Date();
|
|
86
|
+
this.isDeleted = isDeleted || false;
|
|
87
|
+
this.attachmentUrl = attachmentUrl;
|
|
88
|
+
this.attachmentFileType = attachmentFileType;
|
|
89
|
+
this.attachmentFileName = attachmentFileName;
|
|
90
|
+
this.attachmentFileSize = attachmentFileSize;
|
|
91
|
+
this.deletedAt = deletedAt;
|
|
92
|
+
}
|
|
93
|
+
}
|