stream-chat 9.25.0 → 9.26.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/cjs/index.browser.js +80 -19
- package/dist/cjs/index.browser.js.map +2 -2
- package/dist/cjs/index.node.js +86 -19
- package/dist/cjs/index.node.js.map +2 -2
- package/dist/esm/index.mjs +80 -19
- package/dist/esm/index.mjs.map +2 -2
- package/dist/types/channel.d.ts +18 -0
- package/dist/types/client.d.ts +10 -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 +54 -4
- package/package.json +5 -3
- package/src/channel.ts +41 -0
- package/src/channel_state.ts +9 -5
- package/src/client.ts +5 -10
- package/src/messageComposer/middleware/index.ts +1 -0
- package/src/messageDelivery/MessageDeliveryReporter.ts +55 -13
- package/src/types.ts +54 -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
|
}
|
|
@@ -1362,10 +1369,8 @@ var ChannelState = class {
|
|
|
1362
1369
|
if (initializing && message.id && this.threads[message.id]) {
|
|
1363
1370
|
delete this.threads[message.id];
|
|
1364
1371
|
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
}
|
|
1368
|
-
if (message.created_at.getTime() > this.last_message_at.getTime()) {
|
|
1372
|
+
const shouldSkipLastMessageAtUpdate = this._channel.getConfig()?.skip_last_msg_update_for_system_msgs && message.type === "system";
|
|
1373
|
+
if (!shouldSkipLastMessageAtUpdate && (!this.last_message_at || message.created_at.getTime() > this.last_message_at.getTime())) {
|
|
1369
1374
|
this.last_message_at = new Date(message.created_at.getTime());
|
|
1370
1375
|
}
|
|
1371
1376
|
}
|
|
@@ -7236,6 +7241,7 @@ var MessageComposer = _MessageComposer;
|
|
|
7236
7241
|
var MAX_DELIVERED_MESSAGE_COUNT_IN_PAYLOAD = 100;
|
|
7237
7242
|
var MARK_AS_DELIVERED_BUFFER_TIMEOUT = 1e3;
|
|
7238
7243
|
var MARK_AS_READ_THROTTLE_TIMEOUT2 = 1e3;
|
|
7244
|
+
var RETRY_COUNT_LIMIT_FOR_TIMEOUT_INCREASE = 3;
|
|
7239
7245
|
var isChannel = (item) => item instanceof Channel;
|
|
7240
7246
|
var isThread = (item) => item instanceof Thread;
|
|
7241
7247
|
var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
@@ -7244,6 +7250,9 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
|
7244
7250
|
this.nextDeliveryReportCandidates = /* @__PURE__ */ new Map();
|
|
7245
7251
|
this.markDeliveredRequestPromise = null;
|
|
7246
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;
|
|
7247
7256
|
/**
|
|
7248
7257
|
* Retrieve the reference to the latest message in the state that is nor read neither reported as delivered
|
|
7249
7258
|
* @param collection
|
|
@@ -7284,35 +7293,46 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
|
7284
7293
|
* @param options
|
|
7285
7294
|
*/
|
|
7286
7295
|
this.announceDelivery = (options) => {
|
|
7287
|
-
if (
|
|
7296
|
+
if (!this.canExecuteRequest) return;
|
|
7288
7297
|
const { latest_delivered_messages, sendBuffer } = this.confirmationsFromDeliveryReportCandidates();
|
|
7289
7298
|
if (!latest_delivered_messages.length) return;
|
|
7290
7299
|
const payload = { ...options, latest_delivered_messages };
|
|
7291
|
-
const postFlightReconcile = (
|
|
7300
|
+
const postFlightReconcile = ({
|
|
7301
|
+
preventSchedulingRetry
|
|
7302
|
+
} = {}) => {
|
|
7292
7303
|
this.markDeliveredRequestPromise = null;
|
|
7293
7304
|
for (const [k, v] of this.nextDeliveryReportCandidates.entries()) {
|
|
7294
7305
|
this.deliveryReportCandidates.set(k, v);
|
|
7295
7306
|
}
|
|
7296
7307
|
this.nextDeliveryReportCandidates = /* @__PURE__ */ new Map();
|
|
7308
|
+
if (preventSchedulingRetry) return;
|
|
7297
7309
|
this.announceDeliveryBuffered(options);
|
|
7298
7310
|
};
|
|
7299
|
-
const
|
|
7300
|
-
|
|
7301
|
-
if (!this.deliveryReportCandidates.has(k)) {
|
|
7302
|
-
this.deliveryReportCandidates.set(k, v);
|
|
7303
|
-
}
|
|
7304
|
-
}
|
|
7311
|
+
const handleSuccess = () => {
|
|
7312
|
+
this.resetBackOff();
|
|
7305
7313
|
postFlightReconcile();
|
|
7306
7314
|
};
|
|
7307
|
-
|
|
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);
|
|
7308
7329
|
};
|
|
7309
7330
|
this.announceDeliveryBuffered = (options) => {
|
|
7310
|
-
if (this.hasTimer ||
|
|
7311
|
-
return;
|
|
7331
|
+
if (this.hasTimer || !this.canExecuteRequest) return;
|
|
7312
7332
|
this.markDeliveredTimeout = setTimeout(() => {
|
|
7313
7333
|
this.markDeliveredTimeout = null;
|
|
7314
7334
|
this.announceDelivery(options);
|
|
7315
|
-
},
|
|
7335
|
+
}, this.requestTimeoutMs);
|
|
7316
7336
|
};
|
|
7317
7337
|
/**
|
|
7318
7338
|
* Delegates the mark-read call to the Channel or Thread instance
|
|
@@ -7352,10 +7372,22 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
|
7352
7372
|
get hasDeliveryCandidates() {
|
|
7353
7373
|
return this.deliveryReportCandidates.size > 0;
|
|
7354
7374
|
}
|
|
7375
|
+
get canExecuteRequest() {
|
|
7376
|
+
return !this.markDeliveredRequestInFlight && this.hasDeliveryCandidates;
|
|
7377
|
+
}
|
|
7355
7378
|
static hasPermissionToReportDeliveryFor(collection) {
|
|
7356
7379
|
if (isChannel(collection)) return !!collection.getConfig()?.delivery_events;
|
|
7357
7380
|
if (isThread(collection)) return !!collection.channel.getConfig()?.delivery_events;
|
|
7358
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
|
+
}
|
|
7359
7391
|
/**
|
|
7360
7392
|
* Build latest_delivered_messages payload from an arbitrary buffer (deliveryReportCandidates / nextDeliveryReportCandidates)
|
|
7361
7393
|
*/
|
|
@@ -8259,6 +8291,28 @@ var Channel = class {
|
|
|
8259
8291
|
async addMembers(members, message, options = {}) {
|
|
8260
8292
|
return await this._update({ add_members: members, message, ...options });
|
|
8261
8293
|
}
|
|
8294
|
+
/**
|
|
8295
|
+
* addFilterTags - add filter tags to the channel
|
|
8296
|
+
*
|
|
8297
|
+
* @param {string[]} tags An array of tags to add to the channel
|
|
8298
|
+
* @param {Message} [message] Optional message object for channel members notification
|
|
8299
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
8300
|
+
* @return {Promise<UpdateChannelAPIResponse>} The server response
|
|
8301
|
+
*/
|
|
8302
|
+
async addFilterTags(tags, message, options = {}) {
|
|
8303
|
+
return await this._update({ add_filter_tags: tags, message, ...options });
|
|
8304
|
+
}
|
|
8305
|
+
/**
|
|
8306
|
+
* removeFilterTags - remove filter tags from the channel
|
|
8307
|
+
*
|
|
8308
|
+
* @param {string[]} tags An array of tags to remove from the channel
|
|
8309
|
+
* @param {Message} [message] Optional message object for channel members notification
|
|
8310
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
8311
|
+
* @return {Promise<UpdateChannelAPIResponse>} The server response
|
|
8312
|
+
*/
|
|
8313
|
+
async removeFilterTags(tags, message, options = {}) {
|
|
8314
|
+
return await this._update({ remove_filter_tags: tags, message, ...options });
|
|
8315
|
+
}
|
|
8262
8316
|
/**
|
|
8263
8317
|
* addModerators - add moderators to the channel
|
|
8264
8318
|
*
|
|
@@ -9202,6 +9256,11 @@ var Channel = class {
|
|
|
9202
9256
|
deliveredAt: event.created_at,
|
|
9203
9257
|
lastDeliveredMessageId: event.last_delivered_message_id
|
|
9204
9258
|
});
|
|
9259
|
+
const client = this.getClient();
|
|
9260
|
+
const isOwnEvent = event.user?.id === client.user?.id;
|
|
9261
|
+
if (isOwnEvent) {
|
|
9262
|
+
client.syncDeliveredCandidates([this]);
|
|
9263
|
+
}
|
|
9205
9264
|
}
|
|
9206
9265
|
break;
|
|
9207
9266
|
case "user.watching.start":
|
|
@@ -13887,7 +13946,9 @@ var StreamChat = class _StreamChat {
|
|
|
13887
13946
|
}
|
|
13888
13947
|
userMap[userObject.id] = userObject;
|
|
13889
13948
|
}
|
|
13890
|
-
return await this.post(this.baseURL + "/users", {
|
|
13949
|
+
return await this.post(this.baseURL + "/users", {
|
|
13950
|
+
users: userMap
|
|
13951
|
+
});
|
|
13891
13952
|
}
|
|
13892
13953
|
/**
|
|
13893
13954
|
* upsertUser - Update or Create the given user object
|
|
@@ -14646,7 +14707,7 @@ var StreamChat = class _StreamChat {
|
|
|
14646
14707
|
if (this.userAgent) {
|
|
14647
14708
|
return this.userAgent;
|
|
14648
14709
|
}
|
|
14649
|
-
const version = "9.
|
|
14710
|
+
const version = "9.26.1";
|
|
14650
14711
|
const clientBundle = "browser-cjs";
|
|
14651
14712
|
let userAgentString = "";
|
|
14652
14713
|
if (this.sdkIdentifier) {
|