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
package/dist/cjs/index.node.js
CHANGED
|
@@ -36,6 +36,8 @@ __export(index_exports, {
|
|
|
36
36
|
AnyResource: () => AnyResource,
|
|
37
37
|
AnyRole: () => AnyRole,
|
|
38
38
|
AttachmentManager: () => AttachmentManager,
|
|
39
|
+
AttachmentPostUploadMiddlewareExecutor: () => AttachmentPostUploadMiddlewareExecutor,
|
|
40
|
+
AttachmentPreUploadMiddlewareExecutor: () => AttachmentPreUploadMiddlewareExecutor,
|
|
39
41
|
BasePaginator: () => BasePaginator,
|
|
40
42
|
BaseSearchSource: () => BaseSearchSource,
|
|
41
43
|
BaseSearchSourceSync: () => BaseSearchSourceSync,
|
|
@@ -126,6 +128,7 @@ __export(index_exports, {
|
|
|
126
128
|
chatCodes: () => chatCodes,
|
|
127
129
|
createActiveCommandGuardMiddleware: () => createActiveCommandGuardMiddleware,
|
|
128
130
|
createAttachmentsCompositionMiddleware: () => createAttachmentsCompositionMiddleware,
|
|
131
|
+
createBlockedAttachmentUploadNotificationMiddleware: () => createBlockedAttachmentUploadNotificationMiddleware,
|
|
129
132
|
createCommandInjectionMiddleware: () => createCommandInjectionMiddleware,
|
|
130
133
|
createCommandStringExtractionMiddleware: () => createCommandStringExtractionMiddleware,
|
|
131
134
|
createCommandsMiddleware: () => createCommandsMiddleware,
|
|
@@ -144,9 +147,12 @@ __export(index_exports, {
|
|
|
144
147
|
createMentionsMiddleware: () => createMentionsMiddleware,
|
|
145
148
|
createMessageComposerStateCompositionMiddleware: () => createMessageComposerStateCompositionMiddleware,
|
|
146
149
|
createPollComposerStateMiddleware: () => createPollComposerStateMiddleware,
|
|
150
|
+
createPostUploadAttachmentEnrichmentMiddleware: () => createPostUploadAttachmentEnrichmentMiddleware,
|
|
147
151
|
createSharedLocationCompositionMiddleware: () => createSharedLocationCompositionMiddleware,
|
|
148
152
|
createTextComposerCompositionMiddleware: () => createTextComposerCompositionMiddleware,
|
|
149
153
|
createTextComposerPreValidationMiddleware: () => createTextComposerPreValidationMiddleware,
|
|
154
|
+
createUploadConfigCheckMiddleware: () => createUploadConfigCheckMiddleware,
|
|
155
|
+
createUploadErrorHandlerMiddleware: () => createUploadErrorHandlerMiddleware,
|
|
150
156
|
decodeBase64: () => decodeBase64,
|
|
151
157
|
defaultPollFieldBlurEventValidators: () => defaultPollFieldBlurEventValidators,
|
|
152
158
|
defaultPollFieldChangeEventValidators: () => defaultPollFieldChangeEventValidators,
|
|
@@ -394,7 +400,8 @@ function isOwnUserBaseProperty(property) {
|
|
|
394
400
|
invisible: true,
|
|
395
401
|
privacy_settings: true,
|
|
396
402
|
roles: true,
|
|
397
|
-
push_preferences: true
|
|
403
|
+
push_preferences: true,
|
|
404
|
+
total_unread_count_by_team: true
|
|
398
405
|
};
|
|
399
406
|
return ownUserBaseProperties[property];
|
|
400
407
|
}
|
|
@@ -1341,10 +1348,8 @@ var ChannelState = class {
|
|
|
1341
1348
|
if (initializing && message.id && this.threads[message.id]) {
|
|
1342
1349
|
delete this.threads[message.id];
|
|
1343
1350
|
}
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
}
|
|
1347
|
-
if (message.created_at.getTime() > this.last_message_at.getTime()) {
|
|
1351
|
+
const shouldSkipLastMessageAtUpdate = this._channel.getConfig()?.skip_last_msg_update_for_system_msgs && message.type === "system";
|
|
1352
|
+
if (!shouldSkipLastMessageAtUpdate && (!this.last_message_at || message.created_at.getTime() > this.last_message_at.getTime())) {
|
|
1348
1353
|
this.last_message_at = new Date(message.created_at.getTime());
|
|
1349
1354
|
}
|
|
1350
1355
|
}
|
|
@@ -7215,6 +7220,7 @@ var MessageComposer = _MessageComposer;
|
|
|
7215
7220
|
var MAX_DELIVERED_MESSAGE_COUNT_IN_PAYLOAD = 100;
|
|
7216
7221
|
var MARK_AS_DELIVERED_BUFFER_TIMEOUT = 1e3;
|
|
7217
7222
|
var MARK_AS_READ_THROTTLE_TIMEOUT2 = 1e3;
|
|
7223
|
+
var RETRY_COUNT_LIMIT_FOR_TIMEOUT_INCREASE = 3;
|
|
7218
7224
|
var isChannel = (item) => item instanceof Channel;
|
|
7219
7225
|
var isThread = (item) => item instanceof Thread;
|
|
7220
7226
|
var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
@@ -7223,6 +7229,9 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
|
7223
7229
|
this.nextDeliveryReportCandidates = /* @__PURE__ */ new Map();
|
|
7224
7230
|
this.markDeliveredRequestPromise = null;
|
|
7225
7231
|
this.markDeliveredTimeout = null;
|
|
7232
|
+
this.requestTimeoutMs = MARK_AS_DELIVERED_BUFFER_TIMEOUT;
|
|
7233
|
+
// increased up to RETRY_COUNT_LIMIT_FOR_TIMEOUT_INCREASE
|
|
7234
|
+
this.requestRetryCount = 0;
|
|
7226
7235
|
/**
|
|
7227
7236
|
* Retrieve the reference to the latest message in the state that is nor read neither reported as delivered
|
|
7228
7237
|
* @param collection
|
|
@@ -7263,35 +7272,46 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
|
7263
7272
|
* @param options
|
|
7264
7273
|
*/
|
|
7265
7274
|
this.announceDelivery = (options) => {
|
|
7266
|
-
if (
|
|
7275
|
+
if (!this.canExecuteRequest) return;
|
|
7267
7276
|
const { latest_delivered_messages, sendBuffer } = this.confirmationsFromDeliveryReportCandidates();
|
|
7268
7277
|
if (!latest_delivered_messages.length) return;
|
|
7269
7278
|
const payload = { ...options, latest_delivered_messages };
|
|
7270
|
-
const postFlightReconcile = (
|
|
7279
|
+
const postFlightReconcile = ({
|
|
7280
|
+
preventSchedulingRetry
|
|
7281
|
+
} = {}) => {
|
|
7271
7282
|
this.markDeliveredRequestPromise = null;
|
|
7272
7283
|
for (const [k, v] of this.nextDeliveryReportCandidates.entries()) {
|
|
7273
7284
|
this.deliveryReportCandidates.set(k, v);
|
|
7274
7285
|
}
|
|
7275
7286
|
this.nextDeliveryReportCandidates = /* @__PURE__ */ new Map();
|
|
7287
|
+
if (preventSchedulingRetry) return;
|
|
7276
7288
|
this.announceDeliveryBuffered(options);
|
|
7277
7289
|
};
|
|
7278
|
-
const
|
|
7279
|
-
|
|
7280
|
-
if (!this.deliveryReportCandidates.has(k)) {
|
|
7281
|
-
this.deliveryReportCandidates.set(k, v);
|
|
7282
|
-
}
|
|
7283
|
-
}
|
|
7290
|
+
const handleSuccess = () => {
|
|
7291
|
+
this.resetBackOff();
|
|
7284
7292
|
postFlightReconcile();
|
|
7285
7293
|
};
|
|
7286
|
-
|
|
7294
|
+
const handleError = (error) => {
|
|
7295
|
+
const newDeliveryReportCandidates = new Map(sendBuffer);
|
|
7296
|
+
for (const [k, v] of this.deliveryReportCandidates.entries()) {
|
|
7297
|
+
newDeliveryReportCandidates.set(k, v);
|
|
7298
|
+
}
|
|
7299
|
+
this.deliveryReportCandidates = newDeliveryReportCandidates;
|
|
7300
|
+
if (isAPIError(error) && isErrorRetryable(error) || error.status >= 500) {
|
|
7301
|
+
this.increaseBackOff();
|
|
7302
|
+
postFlightReconcile();
|
|
7303
|
+
} else {
|
|
7304
|
+
postFlightReconcile({ preventSchedulingRetry: true });
|
|
7305
|
+
}
|
|
7306
|
+
};
|
|
7307
|
+
this.markDeliveredRequestPromise = this.client.markChannelsDelivered(payload).then(handleSuccess, handleError);
|
|
7287
7308
|
};
|
|
7288
7309
|
this.announceDeliveryBuffered = (options) => {
|
|
7289
|
-
if (this.hasTimer ||
|
|
7290
|
-
return;
|
|
7310
|
+
if (this.hasTimer || !this.canExecuteRequest) return;
|
|
7291
7311
|
this.markDeliveredTimeout = setTimeout(() => {
|
|
7292
7312
|
this.markDeliveredTimeout = null;
|
|
7293
7313
|
this.announceDelivery(options);
|
|
7294
|
-
},
|
|
7314
|
+
}, this.requestTimeoutMs);
|
|
7295
7315
|
};
|
|
7296
7316
|
/**
|
|
7297
7317
|
* Delegates the mark-read call to the Channel or Thread instance
|
|
@@ -7331,10 +7351,22 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
|
7331
7351
|
get hasDeliveryCandidates() {
|
|
7332
7352
|
return this.deliveryReportCandidates.size > 0;
|
|
7333
7353
|
}
|
|
7354
|
+
get canExecuteRequest() {
|
|
7355
|
+
return !this.markDeliveredRequestInFlight && this.hasDeliveryCandidates;
|
|
7356
|
+
}
|
|
7334
7357
|
static hasPermissionToReportDeliveryFor(collection) {
|
|
7335
7358
|
if (isChannel(collection)) return !!collection.getConfig()?.delivery_events;
|
|
7336
7359
|
if (isThread(collection)) return !!collection.channel.getConfig()?.delivery_events;
|
|
7337
7360
|
}
|
|
7361
|
+
increaseBackOff() {
|
|
7362
|
+
if (this.requestRetryCount >= RETRY_COUNT_LIMIT_FOR_TIMEOUT_INCREASE) return;
|
|
7363
|
+
this.requestRetryCount = this.requestRetryCount + 1;
|
|
7364
|
+
this.requestTimeoutMs = this.requestTimeoutMs * 2;
|
|
7365
|
+
}
|
|
7366
|
+
resetBackOff() {
|
|
7367
|
+
this.requestTimeoutMs = MARK_AS_DELIVERED_BUFFER_TIMEOUT;
|
|
7368
|
+
this.requestRetryCount = 0;
|
|
7369
|
+
}
|
|
7338
7370
|
/**
|
|
7339
7371
|
* Build latest_delivered_messages payload from an arbitrary buffer (deliveryReportCandidates / nextDeliveryReportCandidates)
|
|
7340
7372
|
*/
|
|
@@ -8238,6 +8270,28 @@ var Channel = class {
|
|
|
8238
8270
|
async addMembers(members, message, options = {}) {
|
|
8239
8271
|
return await this._update({ add_members: members, message, ...options });
|
|
8240
8272
|
}
|
|
8273
|
+
/**
|
|
8274
|
+
* addFilterTags - add filter tags to the channel
|
|
8275
|
+
*
|
|
8276
|
+
* @param {string[]} tags An array of tags to add to the channel
|
|
8277
|
+
* @param {Message} [message] Optional message object for channel members notification
|
|
8278
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
8279
|
+
* @return {Promise<UpdateChannelAPIResponse>} The server response
|
|
8280
|
+
*/
|
|
8281
|
+
async addFilterTags(tags, message, options = {}) {
|
|
8282
|
+
return await this._update({ add_filter_tags: tags, message, ...options });
|
|
8283
|
+
}
|
|
8284
|
+
/**
|
|
8285
|
+
* removeFilterTags - remove filter tags from the channel
|
|
8286
|
+
*
|
|
8287
|
+
* @param {string[]} tags An array of tags to remove from the channel
|
|
8288
|
+
* @param {Message} [message] Optional message object for channel members notification
|
|
8289
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
8290
|
+
* @return {Promise<UpdateChannelAPIResponse>} The server response
|
|
8291
|
+
*/
|
|
8292
|
+
async removeFilterTags(tags, message, options = {}) {
|
|
8293
|
+
return await this._update({ remove_filter_tags: tags, message, ...options });
|
|
8294
|
+
}
|
|
8241
8295
|
/**
|
|
8242
8296
|
* addModerators - add moderators to the channel
|
|
8243
8297
|
*
|
|
@@ -9181,6 +9235,11 @@ var Channel = class {
|
|
|
9181
9235
|
deliveredAt: event.created_at,
|
|
9182
9236
|
lastDeliveredMessageId: event.last_delivered_message_id
|
|
9183
9237
|
});
|
|
9238
|
+
const client = this.getClient();
|
|
9239
|
+
const isOwnEvent = event.user?.id === client.user?.id;
|
|
9240
|
+
if (isOwnEvent) {
|
|
9241
|
+
client.syncDeliveredCandidates([this]);
|
|
9242
|
+
}
|
|
9184
9243
|
}
|
|
9185
9244
|
break;
|
|
9186
9245
|
case "user.watching.start":
|
|
@@ -13866,7 +13925,9 @@ var StreamChat = class _StreamChat {
|
|
|
13866
13925
|
}
|
|
13867
13926
|
userMap[userObject.id] = userObject;
|
|
13868
13927
|
}
|
|
13869
|
-
return await this.post(this.baseURL + "/users", {
|
|
13928
|
+
return await this.post(this.baseURL + "/users", {
|
|
13929
|
+
users: userMap
|
|
13930
|
+
});
|
|
13870
13931
|
}
|
|
13871
13932
|
/**
|
|
13872
13933
|
* upsertUser - Update or Create the given user object
|
|
@@ -14625,7 +14686,7 @@ var StreamChat = class _StreamChat {
|
|
|
14625
14686
|
if (this.userAgent) {
|
|
14626
14687
|
return this.userAgent;
|
|
14627
14688
|
}
|
|
14628
|
-
const version = "9.
|
|
14689
|
+
const version = "9.26.1";
|
|
14629
14690
|
const clientBundle = "node-cjs";
|
|
14630
14691
|
let userAgentString = "";
|
|
14631
14692
|
if (this.sdkIdentifier) {
|
|
@@ -16977,6 +17038,8 @@ var FixedSizeQueueCache = class {
|
|
|
16977
17038
|
AnyResource,
|
|
16978
17039
|
AnyRole,
|
|
16979
17040
|
AttachmentManager,
|
|
17041
|
+
AttachmentPostUploadMiddlewareExecutor,
|
|
17042
|
+
AttachmentPreUploadMiddlewareExecutor,
|
|
16980
17043
|
BasePaginator,
|
|
16981
17044
|
BaseSearchSource,
|
|
16982
17045
|
BaseSearchSourceSync,
|
|
@@ -17067,6 +17130,7 @@ var FixedSizeQueueCache = class {
|
|
|
17067
17130
|
chatCodes,
|
|
17068
17131
|
createActiveCommandGuardMiddleware,
|
|
17069
17132
|
createAttachmentsCompositionMiddleware,
|
|
17133
|
+
createBlockedAttachmentUploadNotificationMiddleware,
|
|
17070
17134
|
createCommandInjectionMiddleware,
|
|
17071
17135
|
createCommandStringExtractionMiddleware,
|
|
17072
17136
|
createCommandsMiddleware,
|
|
@@ -17085,9 +17149,12 @@ var FixedSizeQueueCache = class {
|
|
|
17085
17149
|
createMentionsMiddleware,
|
|
17086
17150
|
createMessageComposerStateCompositionMiddleware,
|
|
17087
17151
|
createPollComposerStateMiddleware,
|
|
17152
|
+
createPostUploadAttachmentEnrichmentMiddleware,
|
|
17088
17153
|
createSharedLocationCompositionMiddleware,
|
|
17089
17154
|
createTextComposerCompositionMiddleware,
|
|
17090
17155
|
createTextComposerPreValidationMiddleware,
|
|
17156
|
+
createUploadConfigCheckMiddleware,
|
|
17157
|
+
createUploadErrorHandlerMiddleware,
|
|
17091
17158
|
decodeBase64,
|
|
17092
17159
|
defaultPollFieldBlurEventValidators,
|
|
17093
17160
|
defaultPollFieldChangeEventValidators,
|