rerobe-js-orm 2.5.6 → 2.5.7
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/lib/factories/ChatRoom/ChatRoomFactory.d.ts +1 -1
- package/lib/factories/ChatRoom/ChatRoomFromNewUserSignUp.d.ts +1 -1
- package/lib/factories/ChatRoom/ChatRoomFromNewUserSignUp.js +2 -1
- package/lib/models/ChatRoom.d.ts +12 -0
- package/lib/models/ChatRoom.js +92 -0
- package/lib/types/rerobe-chatroom-types.d.ts +16 -0
- package/package.json +1 -1
|
@@ -4,5 +4,5 @@ export default abstract class ChatRoomFactory extends Base {
|
|
|
4
4
|
abstract createChatRoom(user: {
|
|
5
5
|
uid: string;
|
|
6
6
|
displayName: string;
|
|
7
|
-
}, admins: ChatRoomUserInfo[], welcomeMessage: LastMessageObj, chatRoomType: ChatRoomType): ChatRoom;
|
|
7
|
+
}, admins: ChatRoomUserInfo[], welcomeMessage: LastMessageObj, chatRoomType: ChatRoomType, merchantId: string): ChatRoom;
|
|
8
8
|
}
|
|
@@ -4,5 +4,5 @@ export default class ChatRoomFromNewUserSignUp extends ChatRoomFactory {
|
|
|
4
4
|
createChatRoom(user: {
|
|
5
5
|
uid: string;
|
|
6
6
|
displayName: string;
|
|
7
|
-
}, admins: ChatRoomUserInfo[], welcomeMessageObj: LastMessageObj, chatRoomType: ChatRoomType): ChatRoom;
|
|
7
|
+
}, admins: ChatRoomUserInfo[], welcomeMessageObj: LastMessageObj, chatRoomType: ChatRoomType, merchantId: string): ChatRoom;
|
|
8
8
|
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const ChatRoomFactory_1 = require("./ChatRoomFactory");
|
|
4
4
|
const ChatRoom_1 = require("../../models/ChatRoom");
|
|
5
5
|
class ChatRoomFromNewUserSignUp extends ChatRoomFactory_1.default {
|
|
6
|
-
createChatRoom(user, admins, welcomeMessageObj, chatRoomType) {
|
|
6
|
+
createChatRoom(user, admins, welcomeMessageObj, chatRoomType, merchantId) {
|
|
7
7
|
const chatRoomAttributes = {
|
|
8
8
|
userIdsToBeNotified: [user.uid],
|
|
9
9
|
type: chatRoomType,
|
|
@@ -18,6 +18,7 @@ class ChatRoomFromNewUserSignUp extends ChatRoomFactory_1.default {
|
|
|
18
18
|
online: false,
|
|
19
19
|
typing: false,
|
|
20
20
|
} }),
|
|
21
|
+
merchantId: merchantId || '',
|
|
21
22
|
};
|
|
22
23
|
return new ChatRoom_1.default(Object.assign({}, chatRoomAttributes));
|
|
23
24
|
}
|
package/lib/models/ChatRoom.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import Base from '../Base';
|
|
2
2
|
export default class ChatRoom extends Base {
|
|
3
|
+
documentId: string;
|
|
3
4
|
userIdsToBeNotified: string[];
|
|
4
5
|
type: ChatRoomType;
|
|
5
6
|
lastMessage: LastMessageObj;
|
|
6
7
|
userIds: string[];
|
|
7
8
|
userInfo: ChatRoomUserInfoObj;
|
|
9
|
+
merchantId: string;
|
|
8
10
|
constructor(props?: any);
|
|
9
11
|
toObj(): ChatRoomAttributes;
|
|
12
|
+
generateSchemaForTypesense(name?: string): {
|
|
13
|
+
default_sorting_field: string;
|
|
14
|
+
fields: {
|
|
15
|
+
facet: boolean;
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}[];
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
toObjForTypesense(): TypesenseChatRoomObj;
|
|
10
22
|
}
|
package/lib/models/ChatRoom.js
CHANGED
|
@@ -4,20 +4,112 @@ const Base_1 = require("../Base");
|
|
|
4
4
|
class ChatRoom extends Base_1.default {
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super();
|
|
7
|
+
this.documentId = (props === null || props === void 0 ? void 0 : props.documentId) || this.utilities.makeRandId(28);
|
|
7
8
|
this.userIdsToBeNotified = (props === null || props === void 0 ? void 0 : props.userIdsToBeNotified) || [];
|
|
8
9
|
this.type = (props === null || props === void 0 ? void 0 : props.type) || 'CUSTOMER_SUPPORT';
|
|
9
10
|
this.lastMessage = (props === null || props === void 0 ? void 0 : props.lastMessage) || {};
|
|
10
11
|
this.userIds = (props === null || props === void 0 ? void 0 : props.userIds) || [];
|
|
11
12
|
this.userInfo = (props === null || props === void 0 ? void 0 : props.userInfo) || {};
|
|
13
|
+
this.merchantId = (props === null || props === void 0 ? void 0 : props.merchantId) || '';
|
|
12
14
|
}
|
|
13
15
|
toObj() {
|
|
14
16
|
return {
|
|
17
|
+
documentId: this.documentId,
|
|
15
18
|
userIdsToBeNotified: this.userIdsToBeNotified,
|
|
16
19
|
type: this.type,
|
|
17
20
|
lastMessage: this.lastMessage,
|
|
18
21
|
userIds: this.userIds,
|
|
19
22
|
userInfo: this.userInfo,
|
|
23
|
+
merchantId: this.merchantId,
|
|
20
24
|
};
|
|
21
25
|
}
|
|
26
|
+
generateSchemaForTypesense(name = 'prod_chatRooms_20220704') {
|
|
27
|
+
return {
|
|
28
|
+
default_sorting_field: 'lastMessage.createdAtTimestamp',
|
|
29
|
+
fields: [
|
|
30
|
+
{
|
|
31
|
+
facet: false,
|
|
32
|
+
name: 'documentId',
|
|
33
|
+
type: 'string',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
facet: true,
|
|
37
|
+
name: 'type',
|
|
38
|
+
type: 'string',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
facet: false,
|
|
42
|
+
name: 'userIds',
|
|
43
|
+
type: 'string[]',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
facet: false,
|
|
47
|
+
name: 'userIdsToBeNotified',
|
|
48
|
+
type: 'string[]',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
facet: false,
|
|
52
|
+
name: 'lastMessage.authorId',
|
|
53
|
+
type: 'string',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
facet: true,
|
|
57
|
+
name: 'lastMessage.authorName',
|
|
58
|
+
type: 'string',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
facet: false,
|
|
62
|
+
name: 'lastMessage.content',
|
|
63
|
+
type: 'string',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
facet: true,
|
|
67
|
+
name: 'lastMessage.createdAtTimestamp',
|
|
68
|
+
type: 'int64',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
facet: true,
|
|
72
|
+
name: 'adminMemberNames',
|
|
73
|
+
type: 'string[]',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
facet: true,
|
|
77
|
+
name: 'userNames',
|
|
78
|
+
type: 'string[]',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
facet: true,
|
|
82
|
+
name: 'merchantId',
|
|
83
|
+
type: 'string',
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
name,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
toObjForTypesense() {
|
|
90
|
+
const userNames = [];
|
|
91
|
+
const sanitizedAdminMembersNames = Object.keys(this.userInfo).reduce((result, key) => {
|
|
92
|
+
const currentUserInfo = this.userInfo[key];
|
|
93
|
+
userNames.push(this.utilities.sanitizeString(currentUserInfo.displayName));
|
|
94
|
+
if (currentUserInfo.isChatAdmin) {
|
|
95
|
+
result.push(this.utilities.sanitizeString(currentUserInfo.displayName));
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}, []);
|
|
99
|
+
const stagedObj = {
|
|
100
|
+
documentId: this.utilities.sanitizeString(this.documentId),
|
|
101
|
+
type: this.utilities.sanitizeString(this.type),
|
|
102
|
+
userIds: this.utilities.sanitzeStringArr(this.userIds),
|
|
103
|
+
userIdsToBeNotified: this.utilities.sanitzeStringArr(this.userIdsToBeNotified),
|
|
104
|
+
'lastMessage.authorId': this.utilities.sanitizeString(this.lastMessage.authorId),
|
|
105
|
+
'lastMessage.authorName': this.utilities.sanitizeString(this.lastMessage.authorName),
|
|
106
|
+
'lastMessage.content': this.utilities.sanitizeString(this.lastMessage.content),
|
|
107
|
+
'lastMessage.createdAtTimestamp': this.utilities.sanitizeMillisTimeStamp(this.lastMessage.createdAt),
|
|
108
|
+
adminMemberNames: sanitizedAdminMembersNames,
|
|
109
|
+
userNames,
|
|
110
|
+
merchantId: this.utilities.sanitizeString(this.merchantId),
|
|
111
|
+
};
|
|
112
|
+
return stagedObj;
|
|
113
|
+
}
|
|
22
114
|
}
|
|
23
115
|
exports.default = ChatRoom;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
declare type ChatRoomAttributes = {
|
|
2
|
+
documentId: string;
|
|
2
3
|
userIdsToBeNotified: string[];
|
|
3
4
|
type: ChatRoomType;
|
|
4
5
|
lastMessage: LastMessageObj;
|
|
5
6
|
userIds: string[];
|
|
6
7
|
userInfo: ChatRoomUserInfoObj;
|
|
8
|
+
merchantId: string;
|
|
7
9
|
};
|
|
8
10
|
declare type ChatRoomType = 'CUSTOMER_SUPPORT' | 'SELLER_CONCIERGE';
|
|
9
11
|
declare type LastMessageObj = {
|
|
@@ -23,5 +25,19 @@ declare type ChatRoomUserInfo = {
|
|
|
23
25
|
typing: boolean;
|
|
24
26
|
isChatAdmin?: boolean;
|
|
25
27
|
isReRobeStaff?: boolean;
|
|
28
|
+
isSeller?: boolean;
|
|
26
29
|
firstName?: string;
|
|
27
30
|
};
|
|
31
|
+
declare type TypesenseChatRoomObj = {
|
|
32
|
+
documentId: string;
|
|
33
|
+
type: string;
|
|
34
|
+
userIds: string[];
|
|
35
|
+
userIdsToBeNotified: string[];
|
|
36
|
+
'lastMessage.authorId': string;
|
|
37
|
+
'lastMessage.authorName': string;
|
|
38
|
+
'lastMessage.content': string;
|
|
39
|
+
'lastMessage.createdAtTimestamp': number;
|
|
40
|
+
adminMemberNames: string[];
|
|
41
|
+
userNames: string[];
|
|
42
|
+
merchantId: string;
|
|
43
|
+
};
|