@wildix/xbees-conversations-utils 1.1.49 → 1.1.51
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeStreamChannelsUsers = exports.normalizeStreamChannelsUsersToMap = exports.normalizeStreamChannelUsersToMap = exports.normalizeStreamChannelUsers = exports.normalizeStreamChannelOwnReadIndicators = exports.normalizeStreamChannelReadIndicators = exports.normalizeStreamChannelReadIndicator = exports.localizeStreamChannel = exports.localizeStreamChannelsMembersToMapByChannelId = exports.localizeStreamChannelMembers = exports.localizeStreamMember = exports.normalizeStreamMember = exports.normalizeStreamChannel = exports.localizeStreamMessage = exports.normalizeStreamMessage = exports.normalizeStreamReaction = exports.localizeStreamUser = exports.normalizeStreamUser = void 0;
|
|
3
|
+
exports.normalizeStreamChannelMembersUserPresencesToMap = exports.normalizeStreamChannelsUserPresencesToMap = exports.normalizeStreamChannelsUsers = exports.normalizeStreamChannelsUsersToMap = exports.normalizeStreamChannelUsersToMap = exports.normalizeStreamChannelUsers = exports.normalizeStreamChannelOwnReadIndicators = exports.normalizeStreamChannelReadIndicators = exports.normalizeStreamChannelReadIndicator = exports.localizeStreamChannel = exports.localizeStreamChannelsMembersToMapByChannelId = exports.localizeStreamChannelMembers = exports.localizeStreamMember = exports.normalizeStreamMember = exports.normalizeStreamChannel = exports.localizeStreamMessage = exports.normalizeStreamMessage = exports.normalizeStreamReaction = exports.localizeStreamUser = exports.normalizeStreamUser = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
const xbees_conversations_client_1 = require("@wildix/xbees-conversations-client");
|
|
6
6
|
function normalizeStreamUser(streamUser) {
|
|
@@ -159,6 +159,8 @@ function normalizeStreamChannel(channel) {
|
|
|
159
159
|
updatedAt: data.updated_at,
|
|
160
160
|
whatsapp: data.whatsapp,
|
|
161
161
|
whatsappStatus: data.whatsapp_status,
|
|
162
|
+
autoRecord: data.is_auto_record,
|
|
163
|
+
transcriptionLanguage: data.transcription_language,
|
|
162
164
|
};
|
|
163
165
|
}
|
|
164
166
|
exports.normalizeStreamChannel = normalizeStreamChannel;
|
|
@@ -222,6 +224,7 @@ function localizeStreamChannel(streamChannel) {
|
|
|
222
224
|
unreadMark,
|
|
223
225
|
isExternal: Boolean(normalizedChannel.external),
|
|
224
226
|
isBroadcast: Boolean(normalizedChannel.broadcast),
|
|
227
|
+
isAutoRecord: Boolean(normalizedChannel.autoRecord),
|
|
225
228
|
lastRead,
|
|
226
229
|
lastMessage: normalizedLastMessage,
|
|
227
230
|
lastMessageAt,
|
|
@@ -287,3 +290,42 @@ function normalizeStreamChannelsUsers(streamChannels) {
|
|
|
287
290
|
return Object.values(normalizeStreamChannelsUsersToMap(streamChannels));
|
|
288
291
|
}
|
|
289
292
|
exports.normalizeStreamChannelsUsers = normalizeStreamChannelsUsers;
|
|
293
|
+
function normalizeStreamChannelsUserPresencesToMap(streamChannels) {
|
|
294
|
+
return streamChannels
|
|
295
|
+
.flatMap((channel) => {
|
|
296
|
+
return channel.state?.members ? [channel.state.members] : [];
|
|
297
|
+
})
|
|
298
|
+
.flatMap((memberMap) => {
|
|
299
|
+
return Object.entries(memberMap ?? {});
|
|
300
|
+
})
|
|
301
|
+
.reduce((acc, [memberKey, memberValue]) => {
|
|
302
|
+
const u = memberValue?.user;
|
|
303
|
+
if (u) {
|
|
304
|
+
acc[memberKey] = {
|
|
305
|
+
id: u.id,
|
|
306
|
+
online: u.online,
|
|
307
|
+
company: u.company,
|
|
308
|
+
pbxExtension: u.pbxExtension,
|
|
309
|
+
name: u.name,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
return acc;
|
|
313
|
+
}, {});
|
|
314
|
+
}
|
|
315
|
+
exports.normalizeStreamChannelsUserPresencesToMap = normalizeStreamChannelsUserPresencesToMap;
|
|
316
|
+
function normalizeStreamChannelMembersUserPresencesToMap(channelMembers) {
|
|
317
|
+
return channelMembers.reduce((acc, member) => {
|
|
318
|
+
const u = member?.user;
|
|
319
|
+
if (u) {
|
|
320
|
+
acc[u.id] = {
|
|
321
|
+
id: u.id,
|
|
322
|
+
online: u.online,
|
|
323
|
+
company: u.company,
|
|
324
|
+
pbxExtension: u.pbxExtension,
|
|
325
|
+
name: u.name,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
return acc;
|
|
329
|
+
}, {});
|
|
330
|
+
}
|
|
331
|
+
exports.normalizeStreamChannelMembersUserPresencesToMap = normalizeStreamChannelMembersUserPresencesToMap;
|
package/dist-es/normalization.js
CHANGED
|
@@ -151,6 +151,8 @@ export function normalizeStreamChannel(channel) {
|
|
|
151
151
|
updatedAt: data.updated_at,
|
|
152
152
|
whatsapp: data.whatsapp,
|
|
153
153
|
whatsappStatus: data.whatsapp_status,
|
|
154
|
+
autoRecord: data.is_auto_record,
|
|
155
|
+
transcriptionLanguage: data.transcription_language,
|
|
154
156
|
};
|
|
155
157
|
}
|
|
156
158
|
export function normalizeStreamMember(member) {
|
|
@@ -209,6 +211,7 @@ export function localizeStreamChannel(streamChannel) {
|
|
|
209
211
|
unreadMark,
|
|
210
212
|
isExternal: Boolean(normalizedChannel.external),
|
|
211
213
|
isBroadcast: Boolean(normalizedChannel.broadcast),
|
|
214
|
+
isAutoRecord: Boolean(normalizedChannel.autoRecord),
|
|
212
215
|
lastRead,
|
|
213
216
|
lastMessage: normalizedLastMessage,
|
|
214
217
|
lastMessageAt,
|
|
@@ -266,3 +269,40 @@ export function normalizeStreamChannelsUsersToMap(streamChannels) {
|
|
|
266
269
|
export function normalizeStreamChannelsUsers(streamChannels) {
|
|
267
270
|
return Object.values(normalizeStreamChannelsUsersToMap(streamChannels));
|
|
268
271
|
}
|
|
272
|
+
export function normalizeStreamChannelsUserPresencesToMap(streamChannels) {
|
|
273
|
+
return streamChannels
|
|
274
|
+
.flatMap((channel) => {
|
|
275
|
+
return channel.state?.members ? [channel.state.members] : [];
|
|
276
|
+
})
|
|
277
|
+
.flatMap((memberMap) => {
|
|
278
|
+
return Object.entries(memberMap ?? {});
|
|
279
|
+
})
|
|
280
|
+
.reduce((acc, [memberKey, memberValue]) => {
|
|
281
|
+
const u = memberValue?.user;
|
|
282
|
+
if (u) {
|
|
283
|
+
acc[memberKey] = {
|
|
284
|
+
id: u.id,
|
|
285
|
+
online: u.online,
|
|
286
|
+
company: u.company,
|
|
287
|
+
pbxExtension: u.pbxExtension,
|
|
288
|
+
name: u.name,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
return acc;
|
|
292
|
+
}, {});
|
|
293
|
+
}
|
|
294
|
+
export function normalizeStreamChannelMembersUserPresencesToMap(channelMembers) {
|
|
295
|
+
return channelMembers.reduce((acc, member) => {
|
|
296
|
+
const u = member?.user;
|
|
297
|
+
if (u) {
|
|
298
|
+
acc[u.id] = {
|
|
299
|
+
id: u.id,
|
|
300
|
+
online: u.online,
|
|
301
|
+
company: u.company,
|
|
302
|
+
pbxExtension: u.pbxExtension,
|
|
303
|
+
name: u.name,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
return acc;
|
|
307
|
+
}, {});
|
|
308
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StreamChannel, StreamMessageResponse, StreamReactionResponse, StreamUserResponse, StreamChannelResponse, StreamChannelMemberResponse, StreamReadIndicator } from "./stream";
|
|
2
|
-
import { LocalizedMessage, LocalizedUser, LocalizedChannel, LocalizedChannelMember, LocalizedReadIndicator } from "./types";
|
|
2
|
+
import { LocalizedMessage, LocalizedUser, LocalizedChannel, LocalizedChannelMember, LocalizedReadIndicator, UserPresence } from "./types";
|
|
3
3
|
import { Channel, ChannelMember, Message, Reaction, User } from "@wildix/xbees-conversations-client";
|
|
4
4
|
export declare function normalizeStreamUser(streamUser: StreamUserResponse): User;
|
|
5
5
|
export declare function localizeStreamUser(streamUser: StreamUserResponse): LocalizedUser;
|
|
@@ -19,3 +19,5 @@ export declare function normalizeStreamChannelUsers(streamChannel: StreamChannel
|
|
|
19
19
|
export declare function normalizeStreamChannelUsersToMap(streamChannel: StreamChannel): Record<string, LocalizedUser>;
|
|
20
20
|
export declare function normalizeStreamChannelsUsersToMap(streamChannels: StreamChannel[]): Record<string, LocalizedUser>;
|
|
21
21
|
export declare function normalizeStreamChannelsUsers(streamChannels: StreamChannel[]): LocalizedUser[];
|
|
22
|
+
export declare function normalizeStreamChannelsUserPresencesToMap(streamChannels: StreamChannel[]): Record<string, UserPresence>;
|
|
23
|
+
export declare function normalizeStreamChannelMembersUserPresencesToMap(channelMembers: StreamChannelMemberResponse[]): Record<string, UserPresence>;
|
package/dist-types/stream.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface StreamChannelFields extends UR {
|
|
|
27
27
|
is_broadcast?: boolean;
|
|
28
28
|
external?: boolean;
|
|
29
29
|
unreadMarkUsers?: string[];
|
|
30
|
+
is_auto_record?: boolean;
|
|
31
|
+
transcription_language?: string;
|
|
30
32
|
}
|
|
31
33
|
export interface StreamType extends ExtendableGenerics {
|
|
32
34
|
attachmentType: StreamAttachmentFields;
|
package/dist-types/types.d.ts
CHANGED
|
@@ -19,11 +19,12 @@ export interface LocalizedMessage extends Omit<Message, 'user' | 'createdAt' | '
|
|
|
19
19
|
pinned: boolean | undefined;
|
|
20
20
|
ref?: string | null;
|
|
21
21
|
}
|
|
22
|
-
export interface LocalizedChannel extends Omit<Channel, 'createdAt' | 'updatedAt' | 'is_broadcast' | 'external' | 'hidden'> {
|
|
22
|
+
export interface LocalizedChannel extends Omit<Channel, 'createdAt' | 'updatedAt' | 'is_broadcast' | 'external' | 'hidden' | 'autoRecord'> {
|
|
23
23
|
createdAt: Date;
|
|
24
24
|
isArchived: boolean;
|
|
25
25
|
isBroadcast?: boolean;
|
|
26
26
|
isExternal: boolean;
|
|
27
|
+
isAutoRecord?: boolean;
|
|
27
28
|
lastMessage: LocalizedMessage | null;
|
|
28
29
|
lastMessageAt: Date;
|
|
29
30
|
lastRead: Date;
|
|
@@ -42,3 +43,10 @@ export interface LocalizedReadIndicator {
|
|
|
42
43
|
export interface LocalizedChannelMember extends Omit<ChannelMember, 'createdAt'> {
|
|
43
44
|
createdAt: Date;
|
|
44
45
|
}
|
|
46
|
+
export interface UserPresence {
|
|
47
|
+
id: string;
|
|
48
|
+
online: boolean;
|
|
49
|
+
company?: string;
|
|
50
|
+
pbxExtension?: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildix/xbees-conversations-utils",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.51",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist-cjs/index.js",
|
|
6
6
|
"module": "./dist-es/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@wildix/xbees-conversations-client": "1.1.
|
|
24
|
+
"@wildix/xbees-conversations-client": "1.1.24",
|
|
25
25
|
"stream-chat": "8.12.1",
|
|
26
26
|
"tslib": "^2.5.0"
|
|
27
27
|
},
|