Socket
Socket
Sign inDemoInstall

@azure/communication-chat

Package Overview
Dependencies
Maintainers
1
Versions
261
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/communication-chat - npm Package Compare versions

Comparing version 1.4.1-alpha.20240111.1 to 1.4.1-alpha.20240115.1

84

dist-esm/src/chatClient.js
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/// <reference lib="esnext.asynciterable" />
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
import { mapToChatParticipantRestModel, mapToCreateChatThreadOptionsRestModel, mapToCreateChatThreadResultSdkModel, } from "./models/mappers";

@@ -31,10 +30,19 @@ import { ChatApiClient } from "./generated/src";

this.tokenCredential = credential;
this.clientOptions = Object.assign({}, options);
this.clientOptions.signalingClientOptions = Object.assign(Object.assign({}, this.clientOptions.signalingClientOptions), { resourceEndpoint: this.endpoint });
const internalPipelineOptions = Object.assign(Object.assign({}, options), {
loggingOptions: {
logger: logger.info,
this.clientOptions = { ...options };
this.clientOptions.signalingClientOptions = {
...this.clientOptions.signalingClientOptions,
resourceEndpoint: this.endpoint,
};
const internalPipelineOptions = {
...options,
...{
loggingOptions: {
logger: logger.info,
},
},
};
this.client = new ChatApiClient(this.endpoint, {
endpoint: this.endpoint,
...internalPipelineOptions,
});
this.client = new ChatApiClient(this.endpoint, Object.assign({ endpoint: this.endpoint }, internalPipelineOptions));
const authPolicy = createCommunicationTokenCredentialPolicy(this.tokenCredential);

@@ -59,9 +67,8 @@ this.client.pipeline.addPolicy(authPolicy);

return tracingClient.withSpan("ChatClient-CreateChatThread", options, async (updatedOptions) => {
var _a, _b;
// We generate an UUID if the user does not provide an idempotencyToken value
updatedOptions.idempotencyToken = (_a = updatedOptions.idempotencyToken) !== null && _a !== void 0 ? _a : generateUuid();
updatedOptions.idempotencyToken = updatedOptions.idempotencyToken ?? generateUuid();
const updatedRestModelOptions = mapToCreateChatThreadOptionsRestModel(updatedOptions);
const result = await this.client.chat.createChatThread({
topic: request.topic,
participants: (_b = options.participants) === null || _b === void 0 ? void 0 : _b.map((participant) => mapToChatParticipantRestModel(participant)),
participants: options.participants?.map((participant) => mapToChatParticipantRestModel(participant)),
}, updatedRestModelOptions);

@@ -71,43 +78,26 @@ return mapToCreateChatThreadResultSdkModel(result);

}
listChatThreadsPage(continuationState, options = {}) {
return __asyncGenerator(this, arguments, function* listChatThreadsPage_1() {
if (!continuationState.continuationToken) {
const currentSetResponse = yield __await(this.client.chat.listChatThreads(options));
continuationState.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield yield __await(currentSetResponse.value);
}
async *listChatThreadsPage(continuationState, options = {}) {
if (!continuationState.continuationToken) {
const currentSetResponse = await this.client.chat.listChatThreads(options);
continuationState.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield currentSetResponse.value;
}
while (continuationState.continuationToken) {
const currentSetResponse = yield __await(this.client.chat.listChatThreadsNext(continuationState.continuationToken, options));
continuationState.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield yield __await(currentSetResponse.value);
}
else {
break;
}
}
while (continuationState.continuationToken) {
const currentSetResponse = await this.client.chat.listChatThreadsNext(continuationState.continuationToken, options);
continuationState.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield currentSetResponse.value;
}
});
}
listChatThreadsAll(options) {
return __asyncGenerator(this, arguments, function* listChatThreadsAll_1() {
var _a, e_1, _b, _c;
try {
for (var _d = true, _e = __asyncValues(this.listChatThreadsPage({}, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const page = _c;
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
else {
break;
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
}
finally { if (e_1) throw e_1.error; }
}
});
}
}
async *listChatThreadsAll(options) {
for await (const page of this.listChatThreadsPage({}, options)) {
yield* page;
}
}
/**

@@ -114,0 +104,0 @@ * Gets the list of chat threads of a user.

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await, __rest } from "tslib";
import { logger } from "./models/logger";

@@ -20,8 +19,14 @@ import { serializeCommunicationIdentifier, } from "@azure/communication-common";

this.tokenCredential = credential;
const internalPipelineOptions = Object.assign(Object.assign({}, options), {
loggingOptions: {
logger: logger.info,
const internalPipelineOptions = {
...options,
...{
loggingOptions: {
logger: logger.info,
},
},
};
this.client = new ChatApiClient(this.endpoint, {
endpoint: this.endpoint,
...internalPipelineOptions,
});
this.client = new ChatApiClient(this.endpoint, Object.assign({ endpoint: this.endpoint }, internalPipelineOptions));
const authPolicy = createCommunicationTokenCredentialPolicy(this.tokenCredential);

@@ -61,3 +66,3 @@ this.client.pipeline.addPolicy(authPolicy);

this.timeOfLastTypingRequest = undefined;
const result = await this.client.chatThread.sendChatMessage(this.threadId, Object.assign(Object.assign({}, request), options), updatedOptions);
const result = await this.client.chatThread.sendChatMessage(this.threadId, { ...request, ...options }, updatedOptions);
return result;

@@ -78,43 +83,26 @@ });

}
listMessagesPage(pageSettings, options = {}) {
return __asyncGenerator(this, arguments, function* listMessagesPage_1() {
if (!pageSettings.continuationToken) {
const currentSetResponse = yield __await(this.client.chatThread.listChatMessages(this.threadId, options));
pageSettings.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield yield __await(currentSetResponse.value.map(mapToChatMessageSdkModel, this));
}
async *listMessagesPage(pageSettings, options = {}) {
if (!pageSettings.continuationToken) {
const currentSetResponse = await this.client.chatThread.listChatMessages(this.threadId, options);
pageSettings.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield currentSetResponse.value.map(mapToChatMessageSdkModel, this);
}
while (pageSettings.continuationToken) {
const currentSetResponse = yield __await(this.client.chatThread.listChatMessagesNext(this.threadId, pageSettings.continuationToken, options));
pageSettings.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield yield __await(currentSetResponse.value.map(mapToChatMessageSdkModel, this));
}
else {
break;
}
}
while (pageSettings.continuationToken) {
const currentSetResponse = await this.client.chatThread.listChatMessagesNext(this.threadId, pageSettings.continuationToken, options);
pageSettings.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield currentSetResponse.value.map(mapToChatMessageSdkModel, this);
}
});
}
listMessagesAll(options) {
return __asyncGenerator(this, arguments, function* listMessagesAll_1() {
var _a, e_1, _b, _c;
try {
for (var _d = true, _e = __asyncValues(this.listMessagesPage({}, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const page = _c;
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
else {
break;
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
}
finally { if (e_1) throw e_1.error; }
}
});
}
}
async *listMessagesAll(options) {
for await (const page of this.listMessagesPage({}, options)) {
yield* page;
}
}
/**

@@ -183,43 +171,26 @@ * Gets a list of message from a thread identified by threadId.

}
listParticipantsPage(continuationState, options = {}) {
return __asyncGenerator(this, arguments, function* listParticipantsPage_1() {
if (!continuationState.continuationToken) {
const currentSetResponse = yield __await(this.client.chatThread.listChatParticipants(this.threadId, options));
continuationState.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield yield __await(currentSetResponse.value.map(mapToChatParticipantSdkModel, this));
}
async *listParticipantsPage(continuationState, options = {}) {
if (!continuationState.continuationToken) {
const currentSetResponse = await this.client.chatThread.listChatParticipants(this.threadId, options);
continuationState.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield currentSetResponse.value.map(mapToChatParticipantSdkModel, this);
}
while (continuationState.continuationToken) {
const currentSetResponse = yield __await(this.client.chatThread.listChatParticipantsNext(this.threadId, continuationState.continuationToken, options));
continuationState.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield yield __await(currentSetResponse.value.map(mapToChatParticipantSdkModel, this));
}
else {
break;
}
}
while (continuationState.continuationToken) {
const currentSetResponse = await this.client.chatThread.listChatParticipantsNext(this.threadId, continuationState.continuationToken, options);
continuationState.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield currentSetResponse.value.map(mapToChatParticipantSdkModel, this);
}
});
}
listParticipantsAll(options) {
return __asyncGenerator(this, arguments, function* listParticipantsAll_1() {
var _a, e_2, _b, _c;
try {
for (var _d = true, _e = __asyncValues(this.listParticipantsPage({}, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const page = _c;
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
else {
break;
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
}
finally { if (e_2) throw e_2.error; }
}
});
}
}
async *listParticipantsAll(options) {
for await (const page of this.listParticipantsPage({}, options)) {
yield* page;
}
}
/**

@@ -276,6 +247,9 @@ * Gets the participants of the thread identified by threadId.

const dateNow = new Date();
const { senderDisplayName } = updatedOptions, restOptions = __rest(updatedOptions, ["senderDisplayName"]);
const { senderDisplayName, ...restOptions } = updatedOptions;
if (this.canPostTypingNotification(dateNow)) {
this.timeOfLastTypingRequest = dateNow;
await this.client.chatThread.sendTypingNotification(this.threadId, Object.assign({ sendTypingNotificationRequest: { senderDisplayName: senderDisplayName } }, restOptions));
await this.client.chatThread.sendTypingNotification(this.threadId, {
sendTypingNotificationRequest: { senderDisplayName: senderDisplayName },
...restOptions,
});
return true;

@@ -297,43 +271,26 @@ }

}
listReadReceiptsPage(continuationState, options = {}) {
return __asyncGenerator(this, arguments, function* listReadReceiptsPage_1() {
if (!continuationState.continuationToken) {
const currentSetResponse = yield __await(this.client.chatThread.listChatReadReceipts(this.threadId, options));
continuationState.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield yield __await(currentSetResponse.value.map(mapToReadReceiptSdkModel, this));
}
async *listReadReceiptsPage(continuationState, options = {}) {
if (!continuationState.continuationToken) {
const currentSetResponse = await this.client.chatThread.listChatReadReceipts(this.threadId, options);
continuationState.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield currentSetResponse.value.map(mapToReadReceiptSdkModel, this);
}
while (continuationState.continuationToken) {
const currentSetResponse = yield __await(this.client.chatThread.listChatReadReceiptsNext(this.threadId, continuationState.continuationToken, options));
continuationState.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield yield __await(currentSetResponse.value.map(mapToReadReceiptSdkModel, this));
}
else {
break;
}
}
while (continuationState.continuationToken) {
const currentSetResponse = await this.client.chatThread.listChatReadReceiptsNext(this.threadId, continuationState.continuationToken, options);
continuationState.continuationToken = currentSetResponse.nextLink;
if (currentSetResponse.value) {
yield currentSetResponse.value.map(mapToReadReceiptSdkModel, this);
}
});
}
listReadReceiptsAll(options) {
return __asyncGenerator(this, arguments, function* listReadReceiptsAll_1() {
var _a, e_3, _b, _c;
try {
for (var _d = true, _e = __asyncValues(this.listReadReceiptsPage({}, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const page = _c;
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
else {
break;
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
}
finally { if (e_3) throw e_3.error; }
}
});
}
}
async *listReadReceiptsAll(options) {
for await (const page of this.listReadReceiptsPage({}, options)) {
yield* page;
}
}
/**

@@ -340,0 +297,0 @@ * Gets a list of read receipt from a thread identified by threadId.

@@ -12,3 +12,3 @@ // Copyright (c) Microsoft Corporation.

credential: {
getToken: (_scopes, options) => credential.getToken({ abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal }),
getToken: (_scopes, options) => credential.getToken({ abortSignal: options?.abortSignal }),
},

@@ -15,0 +15,0 @@ scopes: [],

@@ -17,3 +17,2 @@ /*

constructor(endpoint, options) {
var _a, _b;
if (endpoint === undefined) {

@@ -33,5 +32,10 @@ throw new Error("'endpoint' cannot be null");

: `${packageDetails}`;
const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
const optionsWithDefaults = {
...defaults,
...options,
userAgentOptions: {
userAgentPrefix
}, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{endpoint}" });
},
endpoint: options.endpoint ?? options.baseUri ?? "{endpoint}"
};
super(optionsWithDefaults);

@@ -38,0 +42,0 @@ // Parameter assignments

@@ -27,3 +27,3 @@ /*

async createChatThread(createChatThreadRequest, options) {
return tracingClient.withSpan("ChatApiClient.createChatThread", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.createChatThread", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ createChatThreadRequest, options }, createChatThreadOperationSpec);

@@ -37,3 +37,3 @@ });

async listChatThreads(options) {
return tracingClient.withSpan("ChatApiClient.listChatThreads", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.listChatThreads", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ options }, listChatThreadsOperationSpec);

@@ -48,3 +48,3 @@ });

async deleteChatThread(chatThreadId, options) {
return tracingClient.withSpan("ChatApiClient.deleteChatThread", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.deleteChatThread", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, options }, deleteChatThreadOperationSpec);

@@ -59,3 +59,3 @@ });

async listChatThreadsNext(nextLink, options) {
return tracingClient.withSpan("ChatApiClient.listChatThreadsNext", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.listChatThreadsNext", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ nextLink, options }, listChatThreadsNextOperationSpec);

@@ -62,0 +62,0 @@ });

@@ -27,3 +27,3 @@ /*

async listChatReadReceipts(chatThreadId, options) {
return tracingClient.withSpan("ChatApiClient.listChatReadReceipts", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.listChatReadReceipts", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, options }, listChatReadReceiptsOperationSpec);

@@ -39,3 +39,3 @@ });

async sendChatReadReceipt(chatThreadId, sendReadReceiptRequest, options) {
return tracingClient.withSpan("ChatApiClient.sendChatReadReceipt", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.sendChatReadReceipt", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, sendReadReceiptRequest, options }, sendChatReadReceiptOperationSpec);

@@ -51,3 +51,3 @@ });

async sendChatMessage(chatThreadId, sendChatMessageRequest, options) {
return tracingClient.withSpan("ChatApiClient.sendChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.sendChatMessage", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, sendChatMessageRequest, options }, sendChatMessageOperationSpec);

@@ -62,3 +62,3 @@ });

async listChatMessages(chatThreadId, options) {
return tracingClient.withSpan("ChatApiClient.listChatMessages", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.listChatMessages", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, options }, listChatMessagesOperationSpec);

@@ -74,3 +74,3 @@ });

async getChatMessage(chatThreadId, chatMessageId, options) {
return tracingClient.withSpan("ChatApiClient.getChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.getChatMessage", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, chatMessageId, options }, getChatMessageOperationSpec);

@@ -87,3 +87,3 @@ });

async updateChatMessage(chatThreadId, chatMessageId, updateChatMessageRequest, options) {
return tracingClient.withSpan("ChatApiClient.updateChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.updateChatMessage", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, chatMessageId, updateChatMessageRequest, options }, updateChatMessageOperationSpec);

@@ -99,3 +99,3 @@ });

async deleteChatMessage(chatThreadId, chatMessageId, options) {
return tracingClient.withSpan("ChatApiClient.deleteChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.deleteChatMessage", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, chatMessageId, options }, deleteChatMessageOperationSpec);

@@ -110,3 +110,3 @@ });

async listChatParticipants(chatThreadId, options) {
return tracingClient.withSpan("ChatApiClient.listChatParticipants", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.listChatParticipants", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, options }, listChatParticipantsOperationSpec);

@@ -122,3 +122,3 @@ });

async removeChatParticipant(chatThreadId, participantCommunicationIdentifier, options) {
return tracingClient.withSpan("ChatApiClient.removeChatParticipant", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.removeChatParticipant", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, participantCommunicationIdentifier, options }, removeChatParticipantOperationSpec);

@@ -134,3 +134,3 @@ });

async addChatParticipants(chatThreadId, addChatParticipantsRequest, options) {
return tracingClient.withSpan("ChatApiClient.addChatParticipants", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.addChatParticipants", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, addChatParticipantsRequest, options }, addChatParticipantsOperationSpec);

@@ -146,3 +146,3 @@ });

async updateChatThreadProperties(chatThreadId, updateChatThreadRequest, options) {
return tracingClient.withSpan("ChatApiClient.updateChatThreadProperties", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.updateChatThreadProperties", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, updateChatThreadRequest, options }, updateChatThreadPropertiesOperationSpec);

@@ -157,3 +157,3 @@ });

async getChatThreadProperties(chatThreadId, options) {
return tracingClient.withSpan("ChatApiClient.getChatThreadProperties", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.getChatThreadProperties", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, options }, getChatThreadPropertiesOperationSpec);

@@ -168,3 +168,3 @@ });

async sendTypingNotification(chatThreadId, options) {
return tracingClient.withSpan("ChatApiClient.sendTypingNotification", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.sendTypingNotification", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, options }, sendTypingNotificationOperationSpec);

@@ -180,3 +180,3 @@ });

async listChatReadReceiptsNext(chatThreadId, nextLink, options) {
return tracingClient.withSpan("ChatApiClient.listChatReadReceiptsNext", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.listChatReadReceiptsNext", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatReadReceiptsNextOperationSpec);

@@ -192,3 +192,3 @@ });

async listChatMessagesNext(chatThreadId, nextLink, options) {
return tracingClient.withSpan("ChatApiClient.listChatMessagesNext", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.listChatMessagesNext", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatMessagesNextOperationSpec);

@@ -204,3 +204,3 @@ });

async listChatParticipantsNext(chatThreadId, nextLink, options) {
return tracingClient.withSpan("ChatApiClient.listChatParticipantsNext", options !== null && options !== void 0 ? options : {}, async (options) => {
return tracingClient.withSpan("ChatApiClient.listChatParticipantsNext", options ?? {}, async (options) => {
return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatParticipantsNextOperationSpec);

@@ -207,0 +207,0 @@ });

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { __rest } from "tslib";
import { deserializeCommunicationIdentifier, serializeCommunicationIdentifier, } from "@azure/communication-common";
export const mapToCreateChatThreadOptionsRestModel = (options) => {
const { participants, idempotencyToken } = options, rest = __rest(options, ["participants", "idempotencyToken"]);
return Object.assign({ repeatabilityRequestId: idempotencyToken }, rest);
const { participants, idempotencyToken, ...rest } = options;
return {
repeatabilityRequestId: idempotencyToken,
...rest,
};
};

@@ -14,4 +16,7 @@ /**

export const mapToChatParticipantRestModel = (chatParticipant) => {
const { id } = chatParticipant, rest = __rest(chatParticipant, ["id"]);
return Object.assign(Object.assign({}, rest), { communicationIdentifier: serializeCommunicationIdentifier(id) });
const { id, ...rest } = chatParticipant;
return {
...rest,
communicationIdentifier: serializeCommunicationIdentifier(id),
};
};

@@ -23,5 +28,4 @@ /**

export const mapToAddChatParticipantsRequestRestModel = (addParticipantsRequest) => {
var _a;
return {
participants: (_a = addParticipantsRequest.participants) === null || _a === void 0 ? void 0 : _a.map((participant) => mapToChatParticipantRestModel(participant)),
participants: addParticipantsRequest.participants?.map((participant) => mapToChatParticipantRestModel(participant)),
};

@@ -34,4 +38,7 @@ };

export const mapToChatParticipantSdkModel = (chatParticipant) => {
const { communicationIdentifier } = chatParticipant, rest = __rest(chatParticipant, ["communicationIdentifier"]);
return Object.assign(Object.assign({}, rest), { id: deserializeCommunicationIdentifier(communicationIdentifier) });
const { communicationIdentifier, ...rest } = chatParticipant;
return {
...rest,
id: deserializeCommunicationIdentifier(communicationIdentifier),
};
};

@@ -42,10 +49,13 @@ /**

export const mapToChatContentSdkModel = (content) => {
const { participants, initiatorCommunicationIdentifier } = content, otherChatContents = __rest(content, ["participants", "initiatorCommunicationIdentifier"]);
let result = Object.assign({}, otherChatContents);
const { participants, initiatorCommunicationIdentifier, ...otherChatContents } = content;
let result = { ...otherChatContents };
if (initiatorCommunicationIdentifier) {
const initiator = deserializeCommunicationIdentifier(initiatorCommunicationIdentifier);
result = Object.assign(Object.assign({}, result), { initiator });
result = { ...result, initiator };
}
if (participants) {
result = Object.assign(Object.assign({}, result), { participants: participants === null || participants === void 0 ? void 0 : participants.map((participant) => mapToChatParticipantSdkModel(participant)) });
result = {
...result,
participants: participants?.map((participant) => mapToChatParticipantSdkModel(participant)),
};
}

@@ -59,10 +69,13 @@ return result;

export const mapToChatMessageSdkModel = (chatMessage) => {
const { content, senderCommunicationIdentifier } = chatMessage, otherChatMessage = __rest(chatMessage, ["content", "senderCommunicationIdentifier"]);
let result = Object.assign({}, otherChatMessage);
const { content, senderCommunicationIdentifier, ...otherChatMessage } = chatMessage;
let result = { ...otherChatMessage };
if (content) {
result = Object.assign(Object.assign({}, result), { content: mapToChatContentSdkModel(content) });
result = {
...result,
content: mapToChatContentSdkModel(content),
};
}
if (senderCommunicationIdentifier) {
const sender = deserializeCommunicationIdentifier(senderCommunicationIdentifier);
result = Object.assign(Object.assign({}, result), { sender });
result = { ...result, sender };
}

@@ -76,4 +89,3 @@ return result;

export const mapToChatMessagesSdkModelArray = (chatMessagesCollection) => {
var _a;
return (_a = chatMessagesCollection.value) === null || _a === void 0 ? void 0 : _a.map((chatMessage) => mapToChatMessageSdkModel(chatMessage));
return chatMessagesCollection.value?.map((chatMessage) => mapToChatMessageSdkModel(chatMessage));
};

@@ -85,8 +97,11 @@ /**

export const mapToChatThreadPropertiesSdkModel = (chatThread) => {
const { createdByCommunicationIdentifier } = chatThread, rest = __rest(chatThread, ["createdByCommunicationIdentifier"]);
const { createdByCommunicationIdentifier, ...rest } = chatThread;
if (createdByCommunicationIdentifier) {
return Object.assign(Object.assign({}, rest), { createdBy: deserializeCommunicationIdentifier(createdByCommunicationIdentifier) });
return {
...rest,
createdBy: deserializeCommunicationIdentifier(createdByCommunicationIdentifier),
};
}
else {
return Object.assign({}, rest);
return { ...rest };
}

@@ -99,8 +114,11 @@ };

export const mapToCreateChatThreadResultSdkModel = (result) => {
const { chatThread } = result, rest = __rest(result, ["chatThread"]);
const { chatThread, ...rest } = result;
if (chatThread) {
return Object.assign(Object.assign({}, rest), { chatThread: mapToChatThreadPropertiesSdkModel(chatThread) });
return {
...rest,
chatThread: mapToChatThreadPropertiesSdkModel(chatThread),
};
}
else {
return Object.assign({}, rest);
return { ...rest };
}

@@ -113,5 +131,8 @@ };

export const mapToReadReceiptSdkModel = (readReceipt) => {
const { senderCommunicationIdentifier } = readReceipt, rest = __rest(readReceipt, ["senderCommunicationIdentifier"]);
return Object.assign(Object.assign({}, rest), { sender: deserializeCommunicationIdentifier(senderCommunicationIdentifier) });
const { senderCommunicationIdentifier, ...rest } = readReceipt;
return {
...rest,
sender: deserializeCommunicationIdentifier(senderCommunicationIdentifier),
};
};
//# sourceMappingURL=mappers.js.map

@@ -5,8 +5,7 @@ // Copyright (c) Microsoft Corporation.

export const getSignalingClient = (credential, logger, options) => {
var _a, _b;
return new CommunicationSignalingClient(credential, logger, {
environment: (_a = options === null || options === void 0 ? void 0 : options.environment) !== null && _a !== void 0 ? _a : undefined,
resourceEndpoint: (_b = options === null || options === void 0 ? void 0 : options.resourceEndpoint) !== null && _b !== void 0 ? _b : undefined,
environment: options?.environment ?? undefined,
resourceEndpoint: options?.resourceEndpoint ?? undefined,
});
};
//# sourceMappingURL=signalingClient.browser.js.map

@@ -5,8 +5,7 @@ // Copyright (c) Microsoft Corporation.

export const getSignalingClient = (credential, logger, options) => {
var _a, _b;
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
// In React Native
return new CommunicationSignalingClient(credential, logger, {
environment: (_a = options === null || options === void 0 ? void 0 : options.environment) !== null && _a !== void 0 ? _a : undefined,
resourceEndpoint: (_b = options === null || options === void 0 ? void 0 : options.resourceEndpoint) !== null && _b !== void 0 ? _b : undefined,
environment: options?.environment ?? undefined,
resourceEndpoint: options?.resourceEndpoint ?? undefined,
});

@@ -13,0 +12,0 @@ }

{
"name": "@azure/communication-chat",
"version": "1.4.1-alpha.20240111.1",
"version": "1.4.1-alpha.20240115.1",
"description": "Azure client library for Azure Communication Chat services",

@@ -5,0 +5,0 @@ "sdk-type": "client",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc