@azure/communication-chat 1.5.0-beta.2 → 1.6.0-beta.1
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/index.js +785 -63
- package/dist/index.js.map +1 -1
- package/dist-esm/src/chatClient.js +5 -4
- package/dist-esm/src/chatClient.js.map +1 -1
- package/dist-esm/src/chatThreadClient.js +81 -10
- package/dist-esm/src/chatThreadClient.js.map +1 -1
- package/dist-esm/src/generated/src/chatApiClient.js +2 -2
- package/dist-esm/src/generated/src/chatApiClient.js.map +1 -1
- package/dist-esm/src/generated/src/models/index.js +10 -0
- package/dist-esm/src/generated/src/models/index.js.map +1 -1
- package/dist-esm/src/generated/src/models/mappers.js +265 -41
- package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/src/models/parameters.js +73 -1
- package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/src/operations/chatThread.js +98 -0
- package/dist-esm/src/generated/src/operations/chatThread.js.map +1 -1
- package/dist-esm/src/generated/src/operationsInterfaces/chatThread.js.map +1 -1
- package/dist-esm/src/generated/src/tracing.js +1 -1
- package/dist-esm/src/generated/src/tracing.js.map +1 -1
- package/dist-esm/src/models/mappers.js +68 -5
- package/dist-esm/src/models/mappers.js.map +1 -1
- package/dist-esm/src/models/models.js.map +1 -1
- package/dist-esm/src/models/options.js.map +1 -1
- package/dist-esm/src/xhrHttpClient.js +186 -0
- package/dist-esm/src/xhrHttpClient.js.map +1 -0
- package/package.json +3 -3
- package/types/communication-chat.d.ts +86 -1
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var communicationCommon = require('@azure/communication-common');
|
|
7
7
|
var logger$1 = require('@azure/logger');
|
|
8
|
+
var abortController = require('@azure/abort-controller');
|
|
8
9
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
9
10
|
var coreTracing = require('@azure/core-tracing');
|
|
10
11
|
var coreClient = require('@azure/core-client');
|
|
@@ -55,6 +56,41 @@ const mapToAddChatParticipantsRequestRestModel = (addParticipantsRequest) => {
|
|
|
55
56
|
participants: (_a = addParticipantsRequest.participants) === null || _a === void 0 ? void 0 : _a.map((participant) => mapToChatParticipantRestModel(participant)),
|
|
56
57
|
};
|
|
57
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* @internal
|
|
61
|
+
* Mapping chat attachment SDK model to chat attachment REST model
|
|
62
|
+
*/
|
|
63
|
+
const mapToChatAttachmentRestModel = (chatAttachment) => {
|
|
64
|
+
const { attachmentType } = chatAttachment, rest = tslib.__rest(chatAttachment, ["attachmentType"]);
|
|
65
|
+
if (attachmentType === "unknown") {
|
|
66
|
+
throw new Error("'unknown' attachmentType not supported");
|
|
67
|
+
}
|
|
68
|
+
return Object.assign(Object.assign({}, rest), { attachmentType: attachmentType });
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* @internal
|
|
72
|
+
* Mapping send message request and options to send chat message request REST model
|
|
73
|
+
*/
|
|
74
|
+
const mapToSendChatMessageRequestRestModel = (sendMessageRequest, sendMessageOptions) => {
|
|
75
|
+
const { attachments } = sendMessageOptions, restOptions = tslib.__rest(sendMessageOptions, ["attachments"]);
|
|
76
|
+
let request = Object.assign(Object.assign({}, sendMessageRequest), restOptions);
|
|
77
|
+
if (attachments) {
|
|
78
|
+
request = Object.assign(Object.assign({}, request), { attachments: attachments === null || attachments === void 0 ? void 0 : attachments.map((attachment) => mapToChatAttachmentRestModel(attachment)) });
|
|
79
|
+
}
|
|
80
|
+
return request;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* @internal
|
|
84
|
+
* Mapping update message options to update chat message request REST model
|
|
85
|
+
*/
|
|
86
|
+
const mapToUpdateChatMessageRequestRestModel = (updateMessageOptions) => {
|
|
87
|
+
const { attachments } = updateMessageOptions, restOptions = tslib.__rest(updateMessageOptions, ["attachments"]);
|
|
88
|
+
let request = Object.assign({}, restOptions);
|
|
89
|
+
if (attachments) {
|
|
90
|
+
request = Object.assign(Object.assign({}, request), { attachments: attachments === null || attachments === void 0 ? void 0 : attachments.map((attachment) => mapToChatAttachmentRestModel(attachment)) });
|
|
91
|
+
}
|
|
92
|
+
return request;
|
|
93
|
+
};
|
|
58
94
|
/**
|
|
59
95
|
* @internal
|
|
60
96
|
* Mapping chat participant REST model to chat participant SDK model
|
|
@@ -63,11 +99,19 @@ const mapToChatParticipantSdkModel = (chatParticipant) => {
|
|
|
63
99
|
const { communicationIdentifier } = chatParticipant, rest = tslib.__rest(chatParticipant, ["communicationIdentifier"]);
|
|
64
100
|
return Object.assign(Object.assign({}, rest), { id: communicationCommon.deserializeCommunicationIdentifier(communicationIdentifier) });
|
|
65
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* @internal
|
|
104
|
+
* Mapping chat attachment REST model to chat attachment SDK model
|
|
105
|
+
*/
|
|
106
|
+
const mapToChatAttachmentSdkModel = (chatAttachment) => {
|
|
107
|
+
const { attachmentType } = chatAttachment, rest = tslib.__rest(chatAttachment, ["attachmentType"]);
|
|
108
|
+
return Object.assign(Object.assign({}, rest), { attachmentType: attachmentType });
|
|
109
|
+
};
|
|
66
110
|
/**
|
|
67
111
|
* @internal
|
|
68
112
|
*/
|
|
69
113
|
const mapToChatContentSdkModel = (content) => {
|
|
70
|
-
const { participants, initiatorCommunicationIdentifier } = content, otherChatContents = tslib.__rest(content, ["participants", "initiatorCommunicationIdentifier"]);
|
|
114
|
+
const { participants, attachments, initiatorCommunicationIdentifier } = content, otherChatContents = tslib.__rest(content, ["participants", "attachments", "initiatorCommunicationIdentifier"]);
|
|
71
115
|
let result = Object.assign({}, otherChatContents);
|
|
72
116
|
if (initiatorCommunicationIdentifier) {
|
|
73
117
|
const initiator = communicationCommon.deserializeCommunicationIdentifier(initiatorCommunicationIdentifier);
|
|
@@ -76,6 +120,9 @@ const mapToChatContentSdkModel = (content) => {
|
|
|
76
120
|
if (participants) {
|
|
77
121
|
result = Object.assign(Object.assign({}, result), { participants: participants === null || participants === void 0 ? void 0 : participants.map((participant) => mapToChatParticipantSdkModel(participant)) });
|
|
78
122
|
}
|
|
123
|
+
if (attachments) {
|
|
124
|
+
result = Object.assign(Object.assign({}, result), { attachments: attachments === null || attachments === void 0 ? void 0 : attachments.map((attachment) => mapToChatAttachmentSdkModel(attachment)) });
|
|
125
|
+
}
|
|
79
126
|
return result;
|
|
80
127
|
};
|
|
81
128
|
/**
|
|
@@ -94,18 +141,35 @@ const mapToChatMessageSdkModel = (chatMessage) => {
|
|
|
94
141
|
}
|
|
95
142
|
return result;
|
|
96
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* @internal
|
|
146
|
+
* Mapping chat retention policy REST model to chat retention policy SDK model
|
|
147
|
+
*/
|
|
148
|
+
const mapToRetentionPolicySdkModel = (retentionPolicy) => {
|
|
149
|
+
if (retentionPolicy.kind === "threadCreationDate") {
|
|
150
|
+
return retentionPolicy;
|
|
151
|
+
}
|
|
152
|
+
if (retentionPolicy.kind === "none") {
|
|
153
|
+
return retentionPolicy;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
throw new Error(`Retention Policy ${retentionPolicy.kind} is not supported`);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
97
159
|
/**
|
|
98
160
|
* @internal
|
|
99
161
|
* Mapping chat thread REST model to chat thread SDK model
|
|
100
162
|
*/
|
|
101
163
|
const mapToChatThreadPropertiesSdkModel = (chatThread) => {
|
|
102
|
-
const { createdByCommunicationIdentifier } = chatThread, rest = tslib.__rest(chatThread, ["createdByCommunicationIdentifier"]);
|
|
164
|
+
const { createdByCommunicationIdentifier, retentionPolicy } = chatThread, rest = tslib.__rest(chatThread, ["createdByCommunicationIdentifier", "retentionPolicy"]);
|
|
165
|
+
let result = Object.assign({}, rest);
|
|
103
166
|
if (createdByCommunicationIdentifier) {
|
|
104
|
-
|
|
167
|
+
result = Object.assign(Object.assign({}, result), { createdBy: communicationCommon.deserializeCommunicationIdentifier(createdByCommunicationIdentifier) });
|
|
105
168
|
}
|
|
106
|
-
|
|
107
|
-
|
|
169
|
+
if (retentionPolicy) {
|
|
170
|
+
result = Object.assign(Object.assign({}, result), { retentionPolicy: mapToRetentionPolicySdkModel(retentionPolicy) });
|
|
108
171
|
}
|
|
172
|
+
return result;
|
|
109
173
|
};
|
|
110
174
|
/**
|
|
111
175
|
* @internal
|
|
@@ -139,7 +203,7 @@ const mapToReadReceiptSdkModel = (readReceipt) => {
|
|
|
139
203
|
const tracingClient = coreTracing.createTracingClient({
|
|
140
204
|
namespace: "Azure.Communication",
|
|
141
205
|
packageName: "@azure/communication-chat",
|
|
142
|
-
packageVersion: "1.
|
|
206
|
+
packageVersion: "1.6.0-beta.1",
|
|
143
207
|
});
|
|
144
208
|
|
|
145
209
|
/*
|
|
@@ -244,6 +308,13 @@ const CommunicationIdentifierModel = {
|
|
|
244
308
|
className: "MicrosoftTeamsUserIdentifierModel",
|
|
245
309
|
},
|
|
246
310
|
},
|
|
311
|
+
microsoftTeamsApp: {
|
|
312
|
+
serializedName: "microsoftTeamsApp",
|
|
313
|
+
type: {
|
|
314
|
+
name: "Composite",
|
|
315
|
+
className: "MicrosoftTeamsAppIdentifierModel",
|
|
316
|
+
},
|
|
317
|
+
},
|
|
247
318
|
},
|
|
248
319
|
},
|
|
249
320
|
};
|
|
@@ -304,6 +375,27 @@ const MicrosoftTeamsUserIdentifierModel = {
|
|
|
304
375
|
},
|
|
305
376
|
},
|
|
306
377
|
};
|
|
378
|
+
const MicrosoftTeamsAppIdentifierModel = {
|
|
379
|
+
type: {
|
|
380
|
+
name: "Composite",
|
|
381
|
+
className: "MicrosoftTeamsAppIdentifierModel",
|
|
382
|
+
modelProperties: {
|
|
383
|
+
appId: {
|
|
384
|
+
serializedName: "appId",
|
|
385
|
+
required: true,
|
|
386
|
+
type: {
|
|
387
|
+
name: "String",
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
cloud: {
|
|
391
|
+
serializedName: "cloud",
|
|
392
|
+
type: {
|
|
393
|
+
name: "String",
|
|
394
|
+
},
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
};
|
|
307
399
|
const CommunicationErrorResponse = {
|
|
308
400
|
type: {
|
|
309
401
|
name: "Composite",
|
|
@@ -421,6 +513,59 @@ const SendChatMessageRequest = {
|
|
|
421
513
|
value: { type: { name: "String" } },
|
|
422
514
|
},
|
|
423
515
|
},
|
|
516
|
+
attachments: {
|
|
517
|
+
serializedName: "attachments",
|
|
518
|
+
type: {
|
|
519
|
+
name: "Sequence",
|
|
520
|
+
element: {
|
|
521
|
+
type: {
|
|
522
|
+
name: "Composite",
|
|
523
|
+
className: "ChatAttachment",
|
|
524
|
+
},
|
|
525
|
+
},
|
|
526
|
+
},
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
};
|
|
531
|
+
const ChatAttachment = {
|
|
532
|
+
type: {
|
|
533
|
+
name: "Composite",
|
|
534
|
+
className: "ChatAttachment",
|
|
535
|
+
modelProperties: {
|
|
536
|
+
id: {
|
|
537
|
+
serializedName: "id",
|
|
538
|
+
required: true,
|
|
539
|
+
type: {
|
|
540
|
+
name: "String",
|
|
541
|
+
},
|
|
542
|
+
},
|
|
543
|
+
attachmentType: {
|
|
544
|
+
serializedName: "attachmentType",
|
|
545
|
+
required: true,
|
|
546
|
+
type: {
|
|
547
|
+
name: "Enum",
|
|
548
|
+
allowedValues: ["image", "file"],
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
name: {
|
|
552
|
+
serializedName: "name",
|
|
553
|
+
type: {
|
|
554
|
+
name: "String",
|
|
555
|
+
},
|
|
556
|
+
},
|
|
557
|
+
url: {
|
|
558
|
+
serializedName: "url",
|
|
559
|
+
type: {
|
|
560
|
+
name: "String",
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
previewUrl: {
|
|
564
|
+
serializedName: "previewUrl",
|
|
565
|
+
type: {
|
|
566
|
+
name: "String",
|
|
567
|
+
},
|
|
568
|
+
},
|
|
424
569
|
},
|
|
425
570
|
},
|
|
426
571
|
};
|
|
@@ -641,47 +786,6 @@ const ChatParticipant = {
|
|
|
641
786
|
},
|
|
642
787
|
},
|
|
643
788
|
};
|
|
644
|
-
const ChatAttachment = {
|
|
645
|
-
type: {
|
|
646
|
-
name: "Composite",
|
|
647
|
-
className: "ChatAttachment",
|
|
648
|
-
modelProperties: {
|
|
649
|
-
id: {
|
|
650
|
-
serializedName: "id",
|
|
651
|
-
required: true,
|
|
652
|
-
type: {
|
|
653
|
-
name: "String",
|
|
654
|
-
},
|
|
655
|
-
},
|
|
656
|
-
attachmentType: {
|
|
657
|
-
serializedName: "attachmentType",
|
|
658
|
-
required: true,
|
|
659
|
-
type: {
|
|
660
|
-
name: "Enum",
|
|
661
|
-
allowedValues: ["image", "file"],
|
|
662
|
-
},
|
|
663
|
-
},
|
|
664
|
-
name: {
|
|
665
|
-
serializedName: "name",
|
|
666
|
-
type: {
|
|
667
|
-
name: "String",
|
|
668
|
-
},
|
|
669
|
-
},
|
|
670
|
-
url: {
|
|
671
|
-
serializedName: "url",
|
|
672
|
-
type: {
|
|
673
|
-
name: "String",
|
|
674
|
-
},
|
|
675
|
-
},
|
|
676
|
-
previewUrl: {
|
|
677
|
-
serializedName: "previewUrl",
|
|
678
|
-
type: {
|
|
679
|
-
name: "String",
|
|
680
|
-
},
|
|
681
|
-
},
|
|
682
|
-
},
|
|
683
|
-
},
|
|
684
|
-
};
|
|
685
789
|
const UpdateChatMessageRequest = {
|
|
686
790
|
type: {
|
|
687
791
|
name: "Composite",
|
|
@@ -700,6 +804,18 @@ const UpdateChatMessageRequest = {
|
|
|
700
804
|
value: { type: { name: "String" } },
|
|
701
805
|
},
|
|
702
806
|
},
|
|
807
|
+
attachments: {
|
|
808
|
+
serializedName: "attachments",
|
|
809
|
+
type: {
|
|
810
|
+
name: "Sequence",
|
|
811
|
+
element: {
|
|
812
|
+
type: {
|
|
813
|
+
name: "Composite",
|
|
814
|
+
className: "ChatAttachment",
|
|
815
|
+
},
|
|
816
|
+
},
|
|
817
|
+
},
|
|
818
|
+
},
|
|
703
819
|
},
|
|
704
820
|
},
|
|
705
821
|
};
|
|
@@ -804,6 +920,34 @@ const CreateChatThreadRequest = {
|
|
|
804
920
|
value: { type: { name: "String" } },
|
|
805
921
|
},
|
|
806
922
|
},
|
|
923
|
+
retentionPolicy: {
|
|
924
|
+
serializedName: "retentionPolicy",
|
|
925
|
+
type: {
|
|
926
|
+
name: "Composite",
|
|
927
|
+
className: "ChatRetentionPolicy",
|
|
928
|
+
},
|
|
929
|
+
},
|
|
930
|
+
},
|
|
931
|
+
},
|
|
932
|
+
};
|
|
933
|
+
const ChatRetentionPolicy = {
|
|
934
|
+
type: {
|
|
935
|
+
name: "Composite",
|
|
936
|
+
className: "ChatRetentionPolicy",
|
|
937
|
+
uberParent: "ChatRetentionPolicy",
|
|
938
|
+
polymorphicDiscriminator: {
|
|
939
|
+
serializedName: "kind",
|
|
940
|
+
clientName: "kind",
|
|
941
|
+
},
|
|
942
|
+
modelProperties: {
|
|
943
|
+
kind: {
|
|
944
|
+
serializedName: "kind",
|
|
945
|
+
required: true,
|
|
946
|
+
type: {
|
|
947
|
+
name: "Enum",
|
|
948
|
+
allowedValues: ["threadCreationDate", "none"],
|
|
949
|
+
},
|
|
950
|
+
},
|
|
807
951
|
},
|
|
808
952
|
},
|
|
809
953
|
};
|
|
@@ -881,6 +1025,13 @@ const ChatThreadProperties = {
|
|
|
881
1025
|
value: { type: { name: "String" } },
|
|
882
1026
|
},
|
|
883
1027
|
},
|
|
1028
|
+
retentionPolicy: {
|
|
1029
|
+
serializedName: "retentionPolicy",
|
|
1030
|
+
type: {
|
|
1031
|
+
name: "Composite",
|
|
1032
|
+
className: "ChatRetentionPolicy",
|
|
1033
|
+
},
|
|
1034
|
+
},
|
|
884
1035
|
},
|
|
885
1036
|
},
|
|
886
1037
|
};
|
|
@@ -965,6 +1116,13 @@ const UpdateChatThreadRequest = {
|
|
|
965
1116
|
value: { type: { name: "String" } },
|
|
966
1117
|
},
|
|
967
1118
|
},
|
|
1119
|
+
retentionPolicy: {
|
|
1120
|
+
serializedName: "retentionPolicy",
|
|
1121
|
+
type: {
|
|
1122
|
+
name: "Composite",
|
|
1123
|
+
className: "ChatRetentionPolicy",
|
|
1124
|
+
},
|
|
1125
|
+
},
|
|
968
1126
|
},
|
|
969
1127
|
},
|
|
970
1128
|
};
|
|
@@ -982,6 +1140,136 @@ const SendTypingNotificationRequest = {
|
|
|
982
1140
|
},
|
|
983
1141
|
},
|
|
984
1142
|
};
|
|
1143
|
+
const UploadChatImageResult = {
|
|
1144
|
+
type: {
|
|
1145
|
+
name: "Composite",
|
|
1146
|
+
className: "UploadChatImageResult",
|
|
1147
|
+
modelProperties: {
|
|
1148
|
+
id: {
|
|
1149
|
+
serializedName: "id",
|
|
1150
|
+
required: true,
|
|
1151
|
+
type: {
|
|
1152
|
+
name: "String",
|
|
1153
|
+
},
|
|
1154
|
+
},
|
|
1155
|
+
attachmentType: {
|
|
1156
|
+
serializedName: "attachmentType",
|
|
1157
|
+
type: {
|
|
1158
|
+
name: "Enum",
|
|
1159
|
+
allowedValues: ["image", "file"],
|
|
1160
|
+
},
|
|
1161
|
+
},
|
|
1162
|
+
name: {
|
|
1163
|
+
serializedName: "name",
|
|
1164
|
+
type: {
|
|
1165
|
+
name: "String",
|
|
1166
|
+
},
|
|
1167
|
+
},
|
|
1168
|
+
},
|
|
1169
|
+
},
|
|
1170
|
+
};
|
|
1171
|
+
const ErrorResponse = {
|
|
1172
|
+
type: {
|
|
1173
|
+
name: "Composite",
|
|
1174
|
+
className: "ErrorResponse",
|
|
1175
|
+
modelProperties: {
|
|
1176
|
+
error: {
|
|
1177
|
+
serializedName: "error",
|
|
1178
|
+
type: {
|
|
1179
|
+
name: "Composite",
|
|
1180
|
+
className: "ErrorModel",
|
|
1181
|
+
},
|
|
1182
|
+
},
|
|
1183
|
+
},
|
|
1184
|
+
},
|
|
1185
|
+
};
|
|
1186
|
+
const ErrorModel = {
|
|
1187
|
+
type: {
|
|
1188
|
+
name: "Composite",
|
|
1189
|
+
className: "ErrorModel",
|
|
1190
|
+
modelProperties: {
|
|
1191
|
+
code: {
|
|
1192
|
+
serializedName: "code",
|
|
1193
|
+
required: true,
|
|
1194
|
+
type: {
|
|
1195
|
+
name: "String",
|
|
1196
|
+
},
|
|
1197
|
+
},
|
|
1198
|
+
message: {
|
|
1199
|
+
serializedName: "message",
|
|
1200
|
+
required: true,
|
|
1201
|
+
type: {
|
|
1202
|
+
name: "String",
|
|
1203
|
+
},
|
|
1204
|
+
},
|
|
1205
|
+
details: {
|
|
1206
|
+
serializedName: "details",
|
|
1207
|
+
type: {
|
|
1208
|
+
name: "Sequence",
|
|
1209
|
+
element: {
|
|
1210
|
+
type: {
|
|
1211
|
+
name: "Composite",
|
|
1212
|
+
className: "ErrorDetail",
|
|
1213
|
+
},
|
|
1214
|
+
},
|
|
1215
|
+
},
|
|
1216
|
+
},
|
|
1217
|
+
},
|
|
1218
|
+
},
|
|
1219
|
+
};
|
|
1220
|
+
const ErrorDetail = {
|
|
1221
|
+
type: {
|
|
1222
|
+
name: "Composite",
|
|
1223
|
+
className: "ErrorDetail",
|
|
1224
|
+
modelProperties: {
|
|
1225
|
+
code: {
|
|
1226
|
+
serializedName: "code",
|
|
1227
|
+
required: true,
|
|
1228
|
+
type: {
|
|
1229
|
+
name: "String",
|
|
1230
|
+
},
|
|
1231
|
+
},
|
|
1232
|
+
message: {
|
|
1233
|
+
serializedName: "message",
|
|
1234
|
+
required: true,
|
|
1235
|
+
type: {
|
|
1236
|
+
name: "String",
|
|
1237
|
+
},
|
|
1238
|
+
},
|
|
1239
|
+
},
|
|
1240
|
+
},
|
|
1241
|
+
};
|
|
1242
|
+
const ThreadCreationDateRetentionPolicy = {
|
|
1243
|
+
serializedName: "threadCreationDate",
|
|
1244
|
+
type: {
|
|
1245
|
+
name: "Composite",
|
|
1246
|
+
className: "ThreadCreationDateRetentionPolicy",
|
|
1247
|
+
uberParent: "ChatRetentionPolicy",
|
|
1248
|
+
polymorphicDiscriminator: ChatRetentionPolicy.type.polymorphicDiscriminator,
|
|
1249
|
+
modelProperties: Object.assign(Object.assign({}, ChatRetentionPolicy.type.modelProperties), { deleteThreadAfterDays: {
|
|
1250
|
+
serializedName: "deleteThreadAfterDays",
|
|
1251
|
+
required: true,
|
|
1252
|
+
type: {
|
|
1253
|
+
name: "Number",
|
|
1254
|
+
},
|
|
1255
|
+
} }),
|
|
1256
|
+
},
|
|
1257
|
+
};
|
|
1258
|
+
const NoneRetentionPolicy = {
|
|
1259
|
+
serializedName: "none",
|
|
1260
|
+
type: {
|
|
1261
|
+
name: "Composite",
|
|
1262
|
+
className: "NoneRetentionPolicy",
|
|
1263
|
+
uberParent: "ChatRetentionPolicy",
|
|
1264
|
+
polymorphicDiscriminator: ChatRetentionPolicy.type.polymorphicDiscriminator,
|
|
1265
|
+
modelProperties: Object.assign({}, ChatRetentionPolicy.type.modelProperties),
|
|
1266
|
+
},
|
|
1267
|
+
};
|
|
1268
|
+
let discriminators = {
|
|
1269
|
+
ChatRetentionPolicy: ChatRetentionPolicy,
|
|
1270
|
+
"ChatRetentionPolicy.threadCreationDate": ThreadCreationDateRetentionPolicy,
|
|
1271
|
+
"ChatRetentionPolicy.none": NoneRetentionPolicy,
|
|
1272
|
+
};
|
|
985
1273
|
|
|
986
1274
|
var Mappers = /*#__PURE__*/Object.freeze({
|
|
987
1275
|
__proto__: null,
|
|
@@ -996,6 +1284,7 @@ var Mappers = /*#__PURE__*/Object.freeze({
|
|
|
996
1284
|
ChatMessagesCollection: ChatMessagesCollection,
|
|
997
1285
|
ChatParticipant: ChatParticipant,
|
|
998
1286
|
ChatParticipantsCollection: ChatParticipantsCollection,
|
|
1287
|
+
ChatRetentionPolicy: ChatRetentionPolicy,
|
|
999
1288
|
ChatThreadItem: ChatThreadItem,
|
|
1000
1289
|
ChatThreadProperties: ChatThreadProperties,
|
|
1001
1290
|
ChatThreadsItemCollection: ChatThreadsItemCollection,
|
|
@@ -1004,14 +1293,22 @@ var Mappers = /*#__PURE__*/Object.freeze({
|
|
|
1004
1293
|
CommunicationUserIdentifierModel: CommunicationUserIdentifierModel,
|
|
1005
1294
|
CreateChatThreadRequest: CreateChatThreadRequest,
|
|
1006
1295
|
CreateChatThreadResult: CreateChatThreadResult,
|
|
1296
|
+
ErrorDetail: ErrorDetail,
|
|
1297
|
+
ErrorModel: ErrorModel,
|
|
1298
|
+
ErrorResponse: ErrorResponse,
|
|
1299
|
+
MicrosoftTeamsAppIdentifierModel: MicrosoftTeamsAppIdentifierModel,
|
|
1007
1300
|
MicrosoftTeamsUserIdentifierModel: MicrosoftTeamsUserIdentifierModel,
|
|
1301
|
+
NoneRetentionPolicy: NoneRetentionPolicy,
|
|
1008
1302
|
PhoneNumberIdentifierModel: PhoneNumberIdentifierModel,
|
|
1009
1303
|
SendChatMessageRequest: SendChatMessageRequest,
|
|
1010
1304
|
SendChatMessageResult: SendChatMessageResult,
|
|
1011
1305
|
SendReadReceiptRequest: SendReadReceiptRequest,
|
|
1012
1306
|
SendTypingNotificationRequest: SendTypingNotificationRequest,
|
|
1307
|
+
ThreadCreationDateRetentionPolicy: ThreadCreationDateRetentionPolicy,
|
|
1013
1308
|
UpdateChatMessageRequest: UpdateChatMessageRequest,
|
|
1014
|
-
UpdateChatThreadRequest: UpdateChatThreadRequest
|
|
1309
|
+
UpdateChatThreadRequest: UpdateChatThreadRequest,
|
|
1310
|
+
UploadChatImageResult: UploadChatImageResult,
|
|
1311
|
+
discriminators: discriminators
|
|
1015
1312
|
});
|
|
1016
1313
|
|
|
1017
1314
|
/*
|
|
@@ -1074,7 +1371,7 @@ const skip = {
|
|
|
1074
1371
|
const apiVersion = {
|
|
1075
1372
|
parameterPath: "apiVersion",
|
|
1076
1373
|
mapper: {
|
|
1077
|
-
defaultValue: "2024-03-
|
|
1374
|
+
defaultValue: "2024-03-15-preview",
|
|
1078
1375
|
isConstant: true,
|
|
1079
1376
|
serializedName: "api-version",
|
|
1080
1377
|
type: {
|
|
@@ -1151,6 +1448,78 @@ const sendTypingNotificationRequest = {
|
|
|
1151
1448
|
parameterPath: ["options", "sendTypingNotificationRequest"],
|
|
1152
1449
|
mapper: SendTypingNotificationRequest,
|
|
1153
1450
|
};
|
|
1451
|
+
const contentType2 = {
|
|
1452
|
+
parameterPath: ["options", "contentType"],
|
|
1453
|
+
mapper: {
|
|
1454
|
+
defaultValue: "application/octet-stream",
|
|
1455
|
+
isConstant: true,
|
|
1456
|
+
serializedName: "Content-Type",
|
|
1457
|
+
type: {
|
|
1458
|
+
name: "String",
|
|
1459
|
+
},
|
|
1460
|
+
},
|
|
1461
|
+
};
|
|
1462
|
+
const chatImageFile = {
|
|
1463
|
+
parameterPath: "chatImageFile",
|
|
1464
|
+
mapper: {
|
|
1465
|
+
serializedName: "chatImageFile",
|
|
1466
|
+
required: true,
|
|
1467
|
+
type: {
|
|
1468
|
+
name: "Stream",
|
|
1469
|
+
},
|
|
1470
|
+
},
|
|
1471
|
+
};
|
|
1472
|
+
const accept1 = {
|
|
1473
|
+
parameterPath: "accept",
|
|
1474
|
+
mapper: {
|
|
1475
|
+
defaultValue: "application/json",
|
|
1476
|
+
isConstant: true,
|
|
1477
|
+
serializedName: "Accept",
|
|
1478
|
+
type: {
|
|
1479
|
+
name: "String",
|
|
1480
|
+
},
|
|
1481
|
+
},
|
|
1482
|
+
};
|
|
1483
|
+
const imageFilename = {
|
|
1484
|
+
parameterPath: ["options", "imageFilename"],
|
|
1485
|
+
mapper: {
|
|
1486
|
+
serializedName: "image-filename",
|
|
1487
|
+
type: {
|
|
1488
|
+
name: "String",
|
|
1489
|
+
},
|
|
1490
|
+
},
|
|
1491
|
+
};
|
|
1492
|
+
const accept2 = {
|
|
1493
|
+
parameterPath: "accept",
|
|
1494
|
+
mapper: {
|
|
1495
|
+
defaultValue: "application/json, image/gif, image/jpeg, image/png, image/bmp, image/tiff",
|
|
1496
|
+
isConstant: true,
|
|
1497
|
+
serializedName: "Accept",
|
|
1498
|
+
type: {
|
|
1499
|
+
name: "String",
|
|
1500
|
+
},
|
|
1501
|
+
},
|
|
1502
|
+
};
|
|
1503
|
+
const imageId = {
|
|
1504
|
+
parameterPath: "imageId",
|
|
1505
|
+
mapper: {
|
|
1506
|
+
serializedName: "imageId",
|
|
1507
|
+
required: true,
|
|
1508
|
+
type: {
|
|
1509
|
+
name: "String",
|
|
1510
|
+
},
|
|
1511
|
+
},
|
|
1512
|
+
};
|
|
1513
|
+
const imageViewType = {
|
|
1514
|
+
parameterPath: "imageViewType",
|
|
1515
|
+
mapper: {
|
|
1516
|
+
serializedName: "imageViewType",
|
|
1517
|
+
required: true,
|
|
1518
|
+
type: {
|
|
1519
|
+
name: "String",
|
|
1520
|
+
},
|
|
1521
|
+
},
|
|
1522
|
+
};
|
|
1154
1523
|
const nextLink = {
|
|
1155
1524
|
parameterPath: "nextLink",
|
|
1156
1525
|
mapper: {
|
|
@@ -1331,6 +1700,40 @@ class ChatThreadImpl {
|
|
|
1331
1700
|
return this.client.sendOperationRequest({ chatThreadId, options }, sendTypingNotificationOperationSpec);
|
|
1332
1701
|
});
|
|
1333
1702
|
}
|
|
1703
|
+
/**
|
|
1704
|
+
* Upload an image in a thread, on behalf of a user.
|
|
1705
|
+
* @param chatThreadId Thread id where the uploaded image belongs to. (Teams meeting only)
|
|
1706
|
+
* @param chatImageFile Image binary data, allowed image formats: jpeg, png, gif, heic, webp
|
|
1707
|
+
* @param options The options parameters.
|
|
1708
|
+
*/
|
|
1709
|
+
async uploadChatImage(chatThreadId, chatImageFile, options) {
|
|
1710
|
+
return tracingClient.withSpan("ChatApiClient.uploadChatImage", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1711
|
+
return this.client.sendOperationRequest({ chatThreadId, chatImageFile, options }, uploadChatImageOperationSpec);
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* Get an image by view type.
|
|
1716
|
+
* @param chatThreadId The thread id to which the message was sent.
|
|
1717
|
+
* @param imageId The image id.
|
|
1718
|
+
* @param imageViewType The view type of image.
|
|
1719
|
+
* @param options The options parameters.
|
|
1720
|
+
*/
|
|
1721
|
+
async getChatImage(chatThreadId, imageId, imageViewType, options) {
|
|
1722
|
+
return tracingClient.withSpan("ChatApiClient.getChatImage", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1723
|
+
return this.client.sendOperationRequest({ chatThreadId, imageId, imageViewType, options }, getChatImageOperationSpec);
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
/**
|
|
1727
|
+
* Deletes a image.
|
|
1728
|
+
* @param chatThreadId The thread id to which the message was sent.
|
|
1729
|
+
* @param imageId The image id.
|
|
1730
|
+
* @param options The options parameters.
|
|
1731
|
+
*/
|
|
1732
|
+
async deleteChatImage(chatThreadId, imageId, options) {
|
|
1733
|
+
return tracingClient.withSpan("ChatApiClient.deleteChatImage", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1734
|
+
return this.client.sendOperationRequest({ chatThreadId, imageId, options }, deleteChatImageOperationSpec);
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1334
1737
|
/**
|
|
1335
1738
|
* ListChatReadReceiptsNext
|
|
1336
1739
|
* @param chatThreadId Thread id to get the chat message read receipts for.
|
|
@@ -1770,6 +2173,70 @@ const sendTypingNotificationOperationSpec = {
|
|
|
1770
2173
|
mediaType: "json",
|
|
1771
2174
|
serializer: serializer$1,
|
|
1772
2175
|
};
|
|
2176
|
+
const uploadChatImageOperationSpec = {
|
|
2177
|
+
path: "/chat/threads/{chatThreadId}/images",
|
|
2178
|
+
httpMethod: "POST",
|
|
2179
|
+
responses: {
|
|
2180
|
+
201: {
|
|
2181
|
+
bodyMapper: UploadChatImageResult,
|
|
2182
|
+
},
|
|
2183
|
+
default: {
|
|
2184
|
+
bodyMapper: ErrorResponse,
|
|
2185
|
+
},
|
|
2186
|
+
},
|
|
2187
|
+
requestBody: chatImageFile,
|
|
2188
|
+
queryParameters: [apiVersion],
|
|
2189
|
+
urlParameters: [endpoint, chatThreadId],
|
|
2190
|
+
headerParameters: [
|
|
2191
|
+
contentType2,
|
|
2192
|
+
accept1,
|
|
2193
|
+
imageFilename,
|
|
2194
|
+
],
|
|
2195
|
+
mediaType: "binary",
|
|
2196
|
+
serializer: serializer$1,
|
|
2197
|
+
};
|
|
2198
|
+
const getChatImageOperationSpec = {
|
|
2199
|
+
path: "/chat/threads/{chatThreadId}/images/{imageId}/view/{imageViewType}",
|
|
2200
|
+
httpMethod: "GET",
|
|
2201
|
+
responses: {
|
|
2202
|
+
200: {
|
|
2203
|
+
bodyMapper: {
|
|
2204
|
+
type: { name: "Stream" },
|
|
2205
|
+
serializedName: "parsedResponse",
|
|
2206
|
+
},
|
|
2207
|
+
},
|
|
2208
|
+
default: {
|
|
2209
|
+
bodyMapper: ErrorResponse,
|
|
2210
|
+
},
|
|
2211
|
+
},
|
|
2212
|
+
queryParameters: [apiVersion],
|
|
2213
|
+
urlParameters: [
|
|
2214
|
+
endpoint,
|
|
2215
|
+
chatThreadId,
|
|
2216
|
+
imageId,
|
|
2217
|
+
imageViewType,
|
|
2218
|
+
],
|
|
2219
|
+
headerParameters: [accept2],
|
|
2220
|
+
serializer: serializer$1,
|
|
2221
|
+
};
|
|
2222
|
+
const deleteChatImageOperationSpec = {
|
|
2223
|
+
path: "/chat/threads/{chatThreadId}/images/{imageId}",
|
|
2224
|
+
httpMethod: "DELETE",
|
|
2225
|
+
responses: {
|
|
2226
|
+
204: {},
|
|
2227
|
+
default: {
|
|
2228
|
+
bodyMapper: ErrorResponse,
|
|
2229
|
+
},
|
|
2230
|
+
},
|
|
2231
|
+
queryParameters: [apiVersion],
|
|
2232
|
+
urlParameters: [
|
|
2233
|
+
endpoint,
|
|
2234
|
+
chatThreadId,
|
|
2235
|
+
imageId,
|
|
2236
|
+
],
|
|
2237
|
+
headerParameters: [accept],
|
|
2238
|
+
serializer: serializer$1,
|
|
2239
|
+
};
|
|
1773
2240
|
const listChatReadReceiptsNextOperationSpec = {
|
|
1774
2241
|
path: "{nextLink}",
|
|
1775
2242
|
httpMethod: "GET",
|
|
@@ -2074,7 +2541,7 @@ class ChatApiClient extends coreClient__namespace.ServiceClient {
|
|
|
2074
2541
|
const defaults = {
|
|
2075
2542
|
requestContentType: "application/json; charset=utf-8",
|
|
2076
2543
|
};
|
|
2077
|
-
const packageDetails = `azsdk-js-communication-chat/1.
|
|
2544
|
+
const packageDetails = `azsdk-js-communication-chat/1.6.0-beta.1`;
|
|
2078
2545
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
2079
2546
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
2080
2547
|
: `${packageDetails}`;
|
|
@@ -2085,7 +2552,7 @@ class ChatApiClient extends coreClient__namespace.ServiceClient {
|
|
|
2085
2552
|
// Parameter assignments
|
|
2086
2553
|
this.endpoint = endpoint;
|
|
2087
2554
|
// Assigning values to Constant parameters
|
|
2088
|
-
this.apiVersion = options.apiVersion || "2024-03-
|
|
2555
|
+
this.apiVersion = options.apiVersion || "2024-03-15-preview";
|
|
2089
2556
|
this.chatThread = new ChatThreadImpl(this);
|
|
2090
2557
|
this.chat = new ChatImpl(this);
|
|
2091
2558
|
this.addCustomApiVersionPolicy(options.apiVersion);
|
|
@@ -2121,6 +2588,190 @@ class ChatApiClient extends coreClient__namespace.ServiceClient {
|
|
|
2121
2588
|
// Licensed under the MIT license.
|
|
2122
2589
|
const logger = logger$1.createClientLogger("communication-chat");
|
|
2123
2590
|
|
|
2591
|
+
// Copyright (c) Microsoft Corporation.
|
|
2592
|
+
// Licensed under the MIT license.
|
|
2593
|
+
// Temporary workaround with local copy of XhrHttpClient
|
|
2594
|
+
function isNodeReadableStream(body) {
|
|
2595
|
+
return body && typeof body.pipe === "function";
|
|
2596
|
+
}
|
|
2597
|
+
/**
|
|
2598
|
+
* Checks if the body is a Blob or Blob-like
|
|
2599
|
+
* @internal
|
|
2600
|
+
*/
|
|
2601
|
+
function isBlob(body) {
|
|
2602
|
+
// File objects count as a type of Blob, so we want to use instanceof explicitly
|
|
2603
|
+
return (typeof Blob === "function" || typeof Blob === "object") && body instanceof Blob;
|
|
2604
|
+
}
|
|
2605
|
+
/**
|
|
2606
|
+
* Checks if the body is a ReadableStream supported by browsers
|
|
2607
|
+
* @internal
|
|
2608
|
+
*/
|
|
2609
|
+
function isReadableStream(body) {
|
|
2610
|
+
return Boolean(body &&
|
|
2611
|
+
typeof body.getReader === "function" &&
|
|
2612
|
+
typeof body.tee === "function");
|
|
2613
|
+
}
|
|
2614
|
+
/**
|
|
2615
|
+
* A HttpClient implementation that uses XMLHttpRequest to send HTTP requests.
|
|
2616
|
+
* @internal
|
|
2617
|
+
*/
|
|
2618
|
+
class XhrHttpClient {
|
|
2619
|
+
/**
|
|
2620
|
+
* Makes a request over an underlying transport layer and returns the response.
|
|
2621
|
+
* @param request - The request to be made.
|
|
2622
|
+
*/
|
|
2623
|
+
async sendRequest(request) {
|
|
2624
|
+
var _a;
|
|
2625
|
+
const url = new URL(request.url);
|
|
2626
|
+
const isInsecure = url.protocol !== "https:";
|
|
2627
|
+
if (isInsecure && !request.allowInsecureConnection) {
|
|
2628
|
+
throw new Error(`Cannot connect to ${request.url} while allowInsecureConnection is false.`);
|
|
2629
|
+
}
|
|
2630
|
+
const xhr = new XMLHttpRequest();
|
|
2631
|
+
if (request.proxySettings) {
|
|
2632
|
+
throw new Error("HTTP proxy is not supported in browser environment");
|
|
2633
|
+
}
|
|
2634
|
+
const abortSignal = request.abortSignal;
|
|
2635
|
+
if (abortSignal) {
|
|
2636
|
+
if (abortSignal.aborted) {
|
|
2637
|
+
throw new abortController.AbortError("The operation was aborted.");
|
|
2638
|
+
}
|
|
2639
|
+
const listener = () => {
|
|
2640
|
+
xhr.abort();
|
|
2641
|
+
};
|
|
2642
|
+
abortSignal.addEventListener("abort", listener);
|
|
2643
|
+
xhr.addEventListener("readystatechange", () => {
|
|
2644
|
+
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
2645
|
+
abortSignal.removeEventListener("abort", listener);
|
|
2646
|
+
}
|
|
2647
|
+
});
|
|
2648
|
+
}
|
|
2649
|
+
addProgressListener(xhr.upload, request.onUploadProgress);
|
|
2650
|
+
addProgressListener(xhr, request.onDownloadProgress);
|
|
2651
|
+
xhr.open(request.method, request.url);
|
|
2652
|
+
xhr.timeout = request.timeout;
|
|
2653
|
+
xhr.withCredentials = request.withCredentials;
|
|
2654
|
+
for (const [name, value] of request.headers) {
|
|
2655
|
+
xhr.setRequestHeader(name, value);
|
|
2656
|
+
}
|
|
2657
|
+
xhr.responseType = ((_a = request.streamResponseStatusCodes) === null || _a === void 0 ? void 0 : _a.size) ? "blob" : "text";
|
|
2658
|
+
const body = typeof request.body === "function" ? request.body() : request.body;
|
|
2659
|
+
if (isNodeReadableStream(body) || isReadableStream(body)) {
|
|
2660
|
+
throw new Error("Streams are not supported by xhrHttpClient.");
|
|
2661
|
+
}
|
|
2662
|
+
xhr.send(body === undefined ? null : body);
|
|
2663
|
+
if (xhr.responseType === "blob") {
|
|
2664
|
+
return new Promise((resolve, reject) => {
|
|
2665
|
+
handleBlobResponse(xhr, request, resolve, reject);
|
|
2666
|
+
rejectOnTerminalEvent(request, xhr, reject);
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
else {
|
|
2670
|
+
return new Promise(function (resolve, reject) {
|
|
2671
|
+
xhr.addEventListener("load", () => resolve({
|
|
2672
|
+
request,
|
|
2673
|
+
status: xhr.status,
|
|
2674
|
+
headers: parseHeaders(xhr),
|
|
2675
|
+
bodyAsText: xhr.responseText,
|
|
2676
|
+
}));
|
|
2677
|
+
rejectOnTerminalEvent(request, xhr, reject);
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
function handleBlobResponse(xhr, request, res, rej) {
|
|
2683
|
+
xhr.addEventListener("readystatechange", () => {
|
|
2684
|
+
var _a, _b;
|
|
2685
|
+
// Resolve as soon as headers are loaded
|
|
2686
|
+
if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
|
2687
|
+
if (
|
|
2688
|
+
// Value of POSITIVE_INFINITY in streamResponseStatusCodes is considered as any status code
|
|
2689
|
+
((_a = request.streamResponseStatusCodes) === null || _a === void 0 ? void 0 : _a.has(Number.POSITIVE_INFINITY)) ||
|
|
2690
|
+
((_b = request.streamResponseStatusCodes) === null || _b === void 0 ? void 0 : _b.has(xhr.status))) {
|
|
2691
|
+
const blobBody = new Promise((resolve, reject) => {
|
|
2692
|
+
xhr.addEventListener("load", () => {
|
|
2693
|
+
resolve(xhr.response);
|
|
2694
|
+
});
|
|
2695
|
+
rejectOnTerminalEvent(request, xhr, reject);
|
|
2696
|
+
});
|
|
2697
|
+
res({
|
|
2698
|
+
request,
|
|
2699
|
+
status: xhr.status,
|
|
2700
|
+
headers: parseHeaders(xhr),
|
|
2701
|
+
blobBody,
|
|
2702
|
+
});
|
|
2703
|
+
}
|
|
2704
|
+
else {
|
|
2705
|
+
xhr.addEventListener("load", () => {
|
|
2706
|
+
// xhr.response is of Blob type if the request is sent with xhr.responseType === "blob"
|
|
2707
|
+
// but the status code is not one of the stream response status codes,
|
|
2708
|
+
// so treat it as text and convert from Blob to text
|
|
2709
|
+
if (xhr.response) {
|
|
2710
|
+
xhr.response
|
|
2711
|
+
.text()
|
|
2712
|
+
.then((text) => {
|
|
2713
|
+
res({
|
|
2714
|
+
request: request,
|
|
2715
|
+
status: xhr.status,
|
|
2716
|
+
headers: parseHeaders(xhr),
|
|
2717
|
+
bodyAsText: text,
|
|
2718
|
+
});
|
|
2719
|
+
return;
|
|
2720
|
+
})
|
|
2721
|
+
.catch((e) => {
|
|
2722
|
+
rej(e);
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
else {
|
|
2726
|
+
res({
|
|
2727
|
+
request,
|
|
2728
|
+
status: xhr.status,
|
|
2729
|
+
headers: parseHeaders(xhr),
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
});
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
});
|
|
2736
|
+
}
|
|
2737
|
+
function addProgressListener(xhr, listener) {
|
|
2738
|
+
if (listener) {
|
|
2739
|
+
xhr.addEventListener("progress", (rawEvent) => listener({
|
|
2740
|
+
loadedBytes: rawEvent.loaded,
|
|
2741
|
+
}));
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
function parseHeaders(xhr) {
|
|
2745
|
+
const responseHeaders = coreRestPipeline.createHttpHeaders();
|
|
2746
|
+
const headerLines = xhr
|
|
2747
|
+
.getAllResponseHeaders()
|
|
2748
|
+
.trim()
|
|
2749
|
+
.split(/[\r\n]+/);
|
|
2750
|
+
for (const line of headerLines) {
|
|
2751
|
+
const index = line.indexOf(":");
|
|
2752
|
+
const headerName = line.slice(0, index);
|
|
2753
|
+
const headerValue = line.slice(index + 2);
|
|
2754
|
+
responseHeaders.set(headerName, headerValue);
|
|
2755
|
+
}
|
|
2756
|
+
return responseHeaders;
|
|
2757
|
+
}
|
|
2758
|
+
function rejectOnTerminalEvent(request, xhr, reject) {
|
|
2759
|
+
xhr.addEventListener("error", () => reject(new coreRestPipeline.RestError(`Failed to send request to ${request.url}`, {
|
|
2760
|
+
code: coreRestPipeline.RestError.REQUEST_SEND_ERROR,
|
|
2761
|
+
request,
|
|
2762
|
+
})));
|
|
2763
|
+
const abortError = new abortController.AbortError("The operation was aborted.");
|
|
2764
|
+
xhr.addEventListener("abort", () => reject(abortError));
|
|
2765
|
+
xhr.addEventListener("timeout", () => reject(abortError));
|
|
2766
|
+
}
|
|
2767
|
+
/**
|
|
2768
|
+
* Create a new HttpClient instance for the browser environment.
|
|
2769
|
+
* @internal
|
|
2770
|
+
*/
|
|
2771
|
+
function createXhrHttpClient() {
|
|
2772
|
+
return new XhrHttpClient();
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2124
2775
|
// Copyright (c) Microsoft Corporation.
|
|
2125
2776
|
// Licensed under the MIT license.
|
|
2126
2777
|
/**
|
|
@@ -2158,6 +2809,10 @@ class ChatThreadClient {
|
|
|
2158
2809
|
this.client = new ChatApiClient(this.endpoint, Object.assign({ endpoint: this.endpoint }, internalPipelineOptions));
|
|
2159
2810
|
const authPolicy = createCommunicationTokenCredentialPolicy(this.tokenCredential);
|
|
2160
2811
|
this.client.pipeline.addPolicy(authPolicy);
|
|
2812
|
+
if (typeof XMLHttpRequest !== "undefined") {
|
|
2813
|
+
this.xhrClient = new ChatApiClient(this.endpoint, Object.assign(Object.assign({ endpoint: this.endpoint }, internalPipelineOptions), { httpClient: createXhrHttpClient() }));
|
|
2814
|
+
this.xhrClient.pipeline.addPolicy(authPolicy);
|
|
2815
|
+
}
|
|
2161
2816
|
}
|
|
2162
2817
|
/**
|
|
2163
2818
|
* Gets a chat thread.
|
|
@@ -2199,7 +2854,7 @@ class ChatThreadClient {
|
|
|
2199
2854
|
return tracingClient.withSpan("ChatThreadClient-SendMessage", options, async (updatedOptions) => {
|
|
2200
2855
|
// reset typing notification clock
|
|
2201
2856
|
this.timeOfLastTypingRequest = undefined;
|
|
2202
|
-
const result = await this.client.chatThread.sendChatMessage(this.threadId,
|
|
2857
|
+
const result = await this.client.chatThread.sendChatMessage(this.threadId, mapToSendChatMessageRequestRestModel(request, options), updatedOptions);
|
|
2203
2858
|
return result;
|
|
2204
2859
|
});
|
|
2205
2860
|
}
|
|
@@ -2215,8 +2870,8 @@ class ChatThreadClient {
|
|
|
2215
2870
|
return mapToChatMessageSdkModel(result);
|
|
2216
2871
|
});
|
|
2217
2872
|
}
|
|
2218
|
-
listMessagesPage(
|
|
2219
|
-
return tslib.__asyncGenerator(this, arguments, function* listMessagesPage_1() {
|
|
2873
|
+
listMessagesPage(pageSettings_1) {
|
|
2874
|
+
return tslib.__asyncGenerator(this, arguments, function* listMessagesPage_1(pageSettings, options = {}) {
|
|
2220
2875
|
if (!pageSettings.continuationToken) {
|
|
2221
2876
|
const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatMessages(this.threadId, options));
|
|
2222
2877
|
pageSettings.continuationToken = currentSetResponse.nextLink;
|
|
@@ -2305,7 +2960,7 @@ class ChatThreadClient {
|
|
|
2305
2960
|
*/
|
|
2306
2961
|
async updateMessage(messageId, options = {}) {
|
|
2307
2962
|
return tracingClient.withSpan("ChatThreadClient-UpdateMessage", options, async (updatedOptions) => {
|
|
2308
|
-
await this.client.chatThread.updateChatMessage(this.threadId, messageId, options, updatedOptions);
|
|
2963
|
+
await this.client.chatThread.updateChatMessage(this.threadId, messageId, mapToUpdateChatMessageRequestRestModel(options), updatedOptions);
|
|
2309
2964
|
});
|
|
2310
2965
|
}
|
|
2311
2966
|
/**
|
|
@@ -2319,8 +2974,8 @@ class ChatThreadClient {
|
|
|
2319
2974
|
return result;
|
|
2320
2975
|
});
|
|
2321
2976
|
}
|
|
2322
|
-
listParticipantsPage(
|
|
2323
|
-
return tslib.__asyncGenerator(this, arguments, function* listParticipantsPage_1() {
|
|
2977
|
+
listParticipantsPage(continuationState_1) {
|
|
2978
|
+
return tslib.__asyncGenerator(this, arguments, function* listParticipantsPage_1(continuationState, options = {}) {
|
|
2324
2979
|
if (!continuationState.continuationToken) {
|
|
2325
2980
|
const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatParticipants(this.threadId, options));
|
|
2326
2981
|
continuationState.continuationToken = currentSetResponse.nextLink;
|
|
@@ -2431,8 +3086,8 @@ class ChatThreadClient {
|
|
|
2431
3086
|
await this.client.chatThread.sendChatReadReceipt(this.threadId, request, updatedOptions);
|
|
2432
3087
|
});
|
|
2433
3088
|
}
|
|
2434
|
-
listReadReceiptsPage(
|
|
2435
|
-
return tslib.__asyncGenerator(this, arguments, function* listReadReceiptsPage_1() {
|
|
3089
|
+
listReadReceiptsPage(continuationState_1) {
|
|
3090
|
+
return tslib.__asyncGenerator(this, arguments, function* listReadReceiptsPage_1(continuationState, options = {}) {
|
|
2436
3091
|
if (!continuationState.continuationToken) {
|
|
2437
3092
|
const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatReadReceipts(this.threadId, options));
|
|
2438
3093
|
continuationState.continuationToken = currentSetResponse.nextLink;
|
|
@@ -2514,6 +3169,72 @@ class ChatThreadClient {
|
|
|
2514
3169
|
}
|
|
2515
3170
|
return true;
|
|
2516
3171
|
}
|
|
3172
|
+
async uploadImage(image, imageFilename, imageBytesLengthOrOptions, options = {}) {
|
|
3173
|
+
let uploadImageOptions = {};
|
|
3174
|
+
if (imageBytesLengthOrOptions !== undefined) {
|
|
3175
|
+
if (typeof imageBytesLengthOrOptions === "number") {
|
|
3176
|
+
uploadImageOptions = Object.assign(Object.assign({}, options), { imageBytesLength: imageBytesLengthOrOptions });
|
|
3177
|
+
}
|
|
3178
|
+
else {
|
|
3179
|
+
uploadImageOptions = Object.assign(Object.assign({}, options), imageBytesLengthOrOptions);
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
return tracingClient.withSpan("ChatThreadClient-UploadImage", uploadImageOptions, async (updatedOptions) => {
|
|
3183
|
+
let result;
|
|
3184
|
+
if (this.xhrClient && // is browser
|
|
3185
|
+
((!this.supportsReadableStream() && isReadableStream(image)) || // is readable stream but no support, need to convert
|
|
3186
|
+
!isReadableStream(image))) {
|
|
3187
|
+
// use xhrClient if (to support onUploadProgress)
|
|
3188
|
+
// - is readable stream but no support => convert to ArrayBuffer (so will have content-length)
|
|
3189
|
+
// - is not readable stream
|
|
3190
|
+
result = await this.xhrClient.chatThread.uploadChatImage(this.threadId, isReadableStream(image) ? await this.getArrayBufferFromReadableStream(image) : image, Object.assign({ imageFilename }, updatedOptions));
|
|
3191
|
+
}
|
|
3192
|
+
else {
|
|
3193
|
+
// backend (node fetch client) or readable readable stream
|
|
3194
|
+
// Backend (no browser) need to convert Blob/ReadableStream to ArrayBuffer
|
|
3195
|
+
let chatImageFile = image;
|
|
3196
|
+
if (isBlob(image)) {
|
|
3197
|
+
chatImageFile = await this.getArrayBufferFromBlob(image);
|
|
3198
|
+
}
|
|
3199
|
+
else if (isReadableStream(image)) {
|
|
3200
|
+
chatImageFile = await this.getArrayBufferFromReadableStream(image);
|
|
3201
|
+
}
|
|
3202
|
+
result = await this.client.chatThread.uploadChatImage(this.threadId, chatImageFile, Object.assign({ imageFilename }, updatedOptions));
|
|
3203
|
+
}
|
|
3204
|
+
return result;
|
|
3205
|
+
});
|
|
3206
|
+
}
|
|
3207
|
+
/**
|
|
3208
|
+
* Deletes an image identified by threadId and imageId
|
|
3209
|
+
* @param imageId - The image id of the image.
|
|
3210
|
+
* @param options - Operation options.
|
|
3211
|
+
*/
|
|
3212
|
+
deleteImage(imageId, options = {}) {
|
|
3213
|
+
return tracingClient.withSpan("ChatThreadClient-DeleteImage", options, async (updatedOptions) => {
|
|
3214
|
+
await this.client.chatThread.deleteChatImage(this.threadId, imageId, updatedOptions);
|
|
3215
|
+
});
|
|
3216
|
+
}
|
|
3217
|
+
supportsReadableStream() {
|
|
3218
|
+
let duplexAccessed = false;
|
|
3219
|
+
const hasContentType = new Request("", {
|
|
3220
|
+
body: new ReadableStream(),
|
|
3221
|
+
method: "POST",
|
|
3222
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3223
|
+
// @ts-ignore
|
|
3224
|
+
get duplex() {
|
|
3225
|
+
duplexAccessed = true;
|
|
3226
|
+
return "half";
|
|
3227
|
+
},
|
|
3228
|
+
}).headers.has("Content-Type");
|
|
3229
|
+
return duplexAccessed && !hasContentType;
|
|
3230
|
+
}
|
|
3231
|
+
async getArrayBufferFromReadableStream(body) {
|
|
3232
|
+
const arrayBuffer = await new Response(body).arrayBuffer();
|
|
3233
|
+
return new Uint8Array(arrayBuffer);
|
|
3234
|
+
}
|
|
3235
|
+
async getArrayBufferFromBlob(body) {
|
|
3236
|
+
return new Uint8Array(await body.arrayBuffer());
|
|
3237
|
+
}
|
|
2517
3238
|
}
|
|
2518
3239
|
|
|
2519
3240
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -2564,16 +3285,16 @@ class ChatClient {
|
|
|
2564
3285
|
this.emitter = new events.EventEmitter();
|
|
2565
3286
|
this.isRealtimeNotificationsStarted = false;
|
|
2566
3287
|
this.tokenCredential = credential;
|
|
2567
|
-
this.clientOptions = Object.assign({}, options);
|
|
2568
3288
|
const internalPipelineOptions = Object.assign(Object.assign({}, options), {
|
|
2569
3289
|
loggingOptions: {
|
|
2570
3290
|
logger: logger.info,
|
|
2571
3291
|
},
|
|
2572
3292
|
});
|
|
2573
3293
|
this.client = new ChatApiClient(this.endpoint, Object.assign({ endpoint: this.endpoint }, internalPipelineOptions));
|
|
2574
|
-
this.clientOptions.signalingClientOptions = Object.assign(Object.assign({}, this.clientOptions.signalingClientOptions), { resourceEndpoint: this.endpoint, gatewayApiVersion: this.client.apiVersion });
|
|
2575
3294
|
const authPolicy = createCommunicationTokenCredentialPolicy(this.tokenCredential);
|
|
2576
3295
|
this.client.pipeline.addPolicy(authPolicy);
|
|
3296
|
+
this.clientOptions = Object.assign({}, options);
|
|
3297
|
+
this.clientOptions.signalingClientOptions = Object.assign(Object.assign({}, this.clientOptions.signalingClientOptions), { resourceEndpoint: this.endpoint, gatewayApiVersion: this.client.apiVersion });
|
|
2577
3298
|
this.signalingClient = getSignalingClient(credential, logger, this.clientOptions.signalingClientOptions);
|
|
2578
3299
|
}
|
|
2579
3300
|
/**
|
|
@@ -2599,12 +3320,13 @@ class ChatClient {
|
|
|
2599
3320
|
topic: request.topic,
|
|
2600
3321
|
participants: (_b = options.participants) === null || _b === void 0 ? void 0 : _b.map((participant) => mapToChatParticipantRestModel(participant)),
|
|
2601
3322
|
metadata: options.metadata,
|
|
3323
|
+
retentionPolicy: options.retentionPolicy,
|
|
2602
3324
|
}, updatedRestModelOptions);
|
|
2603
3325
|
return mapToCreateChatThreadResultSdkModel(result);
|
|
2604
3326
|
});
|
|
2605
3327
|
}
|
|
2606
|
-
listChatThreadsPage(
|
|
2607
|
-
return tslib.__asyncGenerator(this, arguments, function* listChatThreadsPage_1() {
|
|
3328
|
+
listChatThreadsPage(continuationState_1) {
|
|
3329
|
+
return tslib.__asyncGenerator(this, arguments, function* listChatThreadsPage_1(continuationState, options = {}) {
|
|
2608
3330
|
if (!continuationState.continuationToken) {
|
|
2609
3331
|
const currentSetResponse = yield tslib.__await(this.client.chat.listChatThreads(options));
|
|
2610
3332
|
continuationState.continuationToken = currentSetResponse.nextLink;
|