stream-chat 9.26.0 → 9.27.0
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/cjs/index.browser.js +78 -15
- package/dist/cjs/index.browser.js.map +2 -2
- package/dist/cjs/index.node.js +84 -15
- package/dist/cjs/index.node.js.map +2 -2
- package/dist/esm/index.mjs +78 -15
- package/dist/esm/index.mjs.map +2 -2
- package/dist/types/client.d.ts +23 -42
- package/dist/types/messageComposer/attachmentManager.d.ts +4 -2
- package/dist/types/messageComposer/middleware/index.d.ts +1 -0
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +5 -0
- package/dist/types/types.d.ts +41 -4
- package/package.json +5 -3
- package/src/client.ts +40 -10
- package/src/messageComposer/middleware/index.ts +1 -0
- package/src/messageDelivery/MessageDeliveryReporter.ts +55 -13
- package/src/types.ts +41 -5
- package/src/utils.ts +1 -0
|
@@ -57,6 +57,8 @@ __export(index_exports, {
|
|
|
57
57
|
AnyResource: () => AnyResource,
|
|
58
58
|
AnyRole: () => AnyRole,
|
|
59
59
|
AttachmentManager: () => AttachmentManager,
|
|
60
|
+
AttachmentPostUploadMiddlewareExecutor: () => AttachmentPostUploadMiddlewareExecutor,
|
|
61
|
+
AttachmentPreUploadMiddlewareExecutor: () => AttachmentPreUploadMiddlewareExecutor,
|
|
60
62
|
BasePaginator: () => BasePaginator,
|
|
61
63
|
BaseSearchSource: () => BaseSearchSource,
|
|
62
64
|
BaseSearchSourceSync: () => BaseSearchSourceSync,
|
|
@@ -147,6 +149,7 @@ __export(index_exports, {
|
|
|
147
149
|
chatCodes: () => chatCodes,
|
|
148
150
|
createActiveCommandGuardMiddleware: () => createActiveCommandGuardMiddleware,
|
|
149
151
|
createAttachmentsCompositionMiddleware: () => createAttachmentsCompositionMiddleware,
|
|
152
|
+
createBlockedAttachmentUploadNotificationMiddleware: () => createBlockedAttachmentUploadNotificationMiddleware,
|
|
150
153
|
createCommandInjectionMiddleware: () => createCommandInjectionMiddleware,
|
|
151
154
|
createCommandStringExtractionMiddleware: () => createCommandStringExtractionMiddleware,
|
|
152
155
|
createCommandsMiddleware: () => createCommandsMiddleware,
|
|
@@ -165,9 +168,12 @@ __export(index_exports, {
|
|
|
165
168
|
createMentionsMiddleware: () => createMentionsMiddleware,
|
|
166
169
|
createMessageComposerStateCompositionMiddleware: () => createMessageComposerStateCompositionMiddleware,
|
|
167
170
|
createPollComposerStateMiddleware: () => createPollComposerStateMiddleware,
|
|
171
|
+
createPostUploadAttachmentEnrichmentMiddleware: () => createPostUploadAttachmentEnrichmentMiddleware,
|
|
168
172
|
createSharedLocationCompositionMiddleware: () => createSharedLocationCompositionMiddleware,
|
|
169
173
|
createTextComposerCompositionMiddleware: () => createTextComposerCompositionMiddleware,
|
|
170
174
|
createTextComposerPreValidationMiddleware: () => createTextComposerPreValidationMiddleware,
|
|
175
|
+
createUploadConfigCheckMiddleware: () => createUploadConfigCheckMiddleware,
|
|
176
|
+
createUploadErrorHandlerMiddleware: () => createUploadErrorHandlerMiddleware,
|
|
171
177
|
decodeBase64: () => decodeBase64,
|
|
172
178
|
defaultPollFieldBlurEventValidators: () => defaultPollFieldBlurEventValidators,
|
|
173
179
|
defaultPollFieldChangeEventValidators: () => defaultPollFieldChangeEventValidators,
|
|
@@ -415,7 +421,8 @@ function isOwnUserBaseProperty(property) {
|
|
|
415
421
|
invisible: true,
|
|
416
422
|
privacy_settings: true,
|
|
417
423
|
roles: true,
|
|
418
|
-
push_preferences: true
|
|
424
|
+
push_preferences: true,
|
|
425
|
+
total_unread_count_by_team: true
|
|
419
426
|
};
|
|
420
427
|
return ownUserBaseProperties[property];
|
|
421
428
|
}
|
|
@@ -7234,6 +7241,7 @@ var MessageComposer = _MessageComposer;
|
|
|
7234
7241
|
var MAX_DELIVERED_MESSAGE_COUNT_IN_PAYLOAD = 100;
|
|
7235
7242
|
var MARK_AS_DELIVERED_BUFFER_TIMEOUT = 1e3;
|
|
7236
7243
|
var MARK_AS_READ_THROTTLE_TIMEOUT2 = 1e3;
|
|
7244
|
+
var RETRY_COUNT_LIMIT_FOR_TIMEOUT_INCREASE = 3;
|
|
7237
7245
|
var isChannel = (item) => item instanceof Channel;
|
|
7238
7246
|
var isThread = (item) => item instanceof Thread;
|
|
7239
7247
|
var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
@@ -7242,6 +7250,9 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
|
7242
7250
|
this.nextDeliveryReportCandidates = /* @__PURE__ */ new Map();
|
|
7243
7251
|
this.markDeliveredRequestPromise = null;
|
|
7244
7252
|
this.markDeliveredTimeout = null;
|
|
7253
|
+
this.requestTimeoutMs = MARK_AS_DELIVERED_BUFFER_TIMEOUT;
|
|
7254
|
+
// increased up to RETRY_COUNT_LIMIT_FOR_TIMEOUT_INCREASE
|
|
7255
|
+
this.requestRetryCount = 0;
|
|
7245
7256
|
/**
|
|
7246
7257
|
* Retrieve the reference to the latest message in the state that is nor read neither reported as delivered
|
|
7247
7258
|
* @param collection
|
|
@@ -7282,35 +7293,46 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
|
7282
7293
|
* @param options
|
|
7283
7294
|
*/
|
|
7284
7295
|
this.announceDelivery = (options) => {
|
|
7285
|
-
if (
|
|
7296
|
+
if (!this.canExecuteRequest) return;
|
|
7286
7297
|
const { latest_delivered_messages, sendBuffer } = this.confirmationsFromDeliveryReportCandidates();
|
|
7287
7298
|
if (!latest_delivered_messages.length) return;
|
|
7288
7299
|
const payload = { ...options, latest_delivered_messages };
|
|
7289
|
-
const postFlightReconcile = (
|
|
7300
|
+
const postFlightReconcile = ({
|
|
7301
|
+
preventSchedulingRetry
|
|
7302
|
+
} = {}) => {
|
|
7290
7303
|
this.markDeliveredRequestPromise = null;
|
|
7291
7304
|
for (const [k, v] of this.nextDeliveryReportCandidates.entries()) {
|
|
7292
7305
|
this.deliveryReportCandidates.set(k, v);
|
|
7293
7306
|
}
|
|
7294
7307
|
this.nextDeliveryReportCandidates = /* @__PURE__ */ new Map();
|
|
7308
|
+
if (preventSchedulingRetry) return;
|
|
7295
7309
|
this.announceDeliveryBuffered(options);
|
|
7296
7310
|
};
|
|
7297
|
-
const
|
|
7298
|
-
|
|
7299
|
-
if (!this.deliveryReportCandidates.has(k)) {
|
|
7300
|
-
this.deliveryReportCandidates.set(k, v);
|
|
7301
|
-
}
|
|
7302
|
-
}
|
|
7311
|
+
const handleSuccess = () => {
|
|
7312
|
+
this.resetBackOff();
|
|
7303
7313
|
postFlightReconcile();
|
|
7304
7314
|
};
|
|
7305
|
-
|
|
7315
|
+
const handleError = (error) => {
|
|
7316
|
+
const newDeliveryReportCandidates = new Map(sendBuffer);
|
|
7317
|
+
for (const [k, v] of this.deliveryReportCandidates.entries()) {
|
|
7318
|
+
newDeliveryReportCandidates.set(k, v);
|
|
7319
|
+
}
|
|
7320
|
+
this.deliveryReportCandidates = newDeliveryReportCandidates;
|
|
7321
|
+
if (isAPIError(error) && isErrorRetryable(error) || error.status >= 500) {
|
|
7322
|
+
this.increaseBackOff();
|
|
7323
|
+
postFlightReconcile();
|
|
7324
|
+
} else {
|
|
7325
|
+
postFlightReconcile({ preventSchedulingRetry: true });
|
|
7326
|
+
}
|
|
7327
|
+
};
|
|
7328
|
+
this.markDeliveredRequestPromise = this.client.markChannelsDelivered(payload).then(handleSuccess, handleError);
|
|
7306
7329
|
};
|
|
7307
7330
|
this.announceDeliveryBuffered = (options) => {
|
|
7308
|
-
if (this.hasTimer ||
|
|
7309
|
-
return;
|
|
7331
|
+
if (this.hasTimer || !this.canExecuteRequest) return;
|
|
7310
7332
|
this.markDeliveredTimeout = setTimeout(() => {
|
|
7311
7333
|
this.markDeliveredTimeout = null;
|
|
7312
7334
|
this.announceDelivery(options);
|
|
7313
|
-
},
|
|
7335
|
+
}, this.requestTimeoutMs);
|
|
7314
7336
|
};
|
|
7315
7337
|
/**
|
|
7316
7338
|
* Delegates the mark-read call to the Channel or Thread instance
|
|
@@ -7350,10 +7372,22 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
|
7350
7372
|
get hasDeliveryCandidates() {
|
|
7351
7373
|
return this.deliveryReportCandidates.size > 0;
|
|
7352
7374
|
}
|
|
7375
|
+
get canExecuteRequest() {
|
|
7376
|
+
return !this.markDeliveredRequestInFlight && this.hasDeliveryCandidates;
|
|
7377
|
+
}
|
|
7353
7378
|
static hasPermissionToReportDeliveryFor(collection) {
|
|
7354
7379
|
if (isChannel(collection)) return !!collection.getConfig()?.delivery_events;
|
|
7355
7380
|
if (isThread(collection)) return !!collection.channel.getConfig()?.delivery_events;
|
|
7356
7381
|
}
|
|
7382
|
+
increaseBackOff() {
|
|
7383
|
+
if (this.requestRetryCount >= RETRY_COUNT_LIMIT_FOR_TIMEOUT_INCREASE) return;
|
|
7384
|
+
this.requestRetryCount = this.requestRetryCount + 1;
|
|
7385
|
+
this.requestTimeoutMs = this.requestTimeoutMs * 2;
|
|
7386
|
+
}
|
|
7387
|
+
resetBackOff() {
|
|
7388
|
+
this.requestTimeoutMs = MARK_AS_DELIVERED_BUFFER_TIMEOUT;
|
|
7389
|
+
this.requestRetryCount = 0;
|
|
7390
|
+
}
|
|
7357
7391
|
/**
|
|
7358
7392
|
* Build latest_delivered_messages payload from an arbitrary buffer (deliveryReportCandidates / nextDeliveryReportCandidates)
|
|
7359
7393
|
*/
|
|
@@ -13912,7 +13946,9 @@ var StreamChat = class _StreamChat {
|
|
|
13912
13946
|
}
|
|
13913
13947
|
userMap[userObject.id] = userObject;
|
|
13914
13948
|
}
|
|
13915
|
-
return await this.post(this.baseURL + "/users", {
|
|
13949
|
+
return await this.post(this.baseURL + "/users", {
|
|
13950
|
+
users: userMap
|
|
13951
|
+
});
|
|
13916
13952
|
}
|
|
13917
13953
|
/**
|
|
13918
13954
|
* upsertUser - Update or Create the given user object
|
|
@@ -14472,6 +14508,33 @@ var StreamChat = class _StreamChat {
|
|
|
14472
14508
|
}
|
|
14473
14509
|
);
|
|
14474
14510
|
}
|
|
14511
|
+
/**
|
|
14512
|
+
* Updates message fields without storing them in the database, only sends update event.
|
|
14513
|
+
*
|
|
14514
|
+
* Available only on the server-side.
|
|
14515
|
+
*
|
|
14516
|
+
* @param messageId the message id to update.
|
|
14517
|
+
* @param partialMessageObject the message payload.
|
|
14518
|
+
* @param partialUserOrUserId the user id linked to this action.
|
|
14519
|
+
* @param options additional options.
|
|
14520
|
+
*/
|
|
14521
|
+
async ephemeralUpdateMessage(messageId, partialMessageObject, partialUserOrUserId, options) {
|
|
14522
|
+
if (!messageId) throw Error("messageId is required");
|
|
14523
|
+
let user = void 0;
|
|
14524
|
+
if (typeof partialUserOrUserId === "string") {
|
|
14525
|
+
user = { id: partialUserOrUserId };
|
|
14526
|
+
} else if (typeof partialUserOrUserId?.id === "string") {
|
|
14527
|
+
user = { id: partialUserOrUserId.id };
|
|
14528
|
+
}
|
|
14529
|
+
return await this.patch(
|
|
14530
|
+
`${this.baseURL}/messages/${encodeURIComponent(messageId)}/ephemeral`,
|
|
14531
|
+
{
|
|
14532
|
+
...partialMessageObject,
|
|
14533
|
+
...options,
|
|
14534
|
+
user
|
|
14535
|
+
}
|
|
14536
|
+
);
|
|
14537
|
+
}
|
|
14475
14538
|
/**
|
|
14476
14539
|
* deleteMessage - Delete a message
|
|
14477
14540
|
*
|
|
@@ -14671,7 +14734,7 @@ var StreamChat = class _StreamChat {
|
|
|
14671
14734
|
if (this.userAgent) {
|
|
14672
14735
|
return this.userAgent;
|
|
14673
14736
|
}
|
|
14674
|
-
const version = "9.
|
|
14737
|
+
const version = "9.27.0";
|
|
14675
14738
|
const clientBundle = "browser-cjs";
|
|
14676
14739
|
let userAgentString = "";
|
|
14677
14740
|
if (this.sdkIdentifier) {
|