stream-chat 9.5.1 → 9.6.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.cjs +107 -42
- package/dist/cjs/index.browser.cjs.map +3 -3
- package/dist/cjs/index.node.cjs +108 -42
- package/dist/cjs/index.node.cjs.map +3 -3
- package/dist/esm/index.js +107 -42
- package/dist/esm/index.js.map +3 -3
- package/dist/types/index.d.ts +1 -0
- package/dist/types/messageComposer/messageComposer.d.ts +8 -5
- package/dist/types/messageComposer/middleware/messageComposer/userDataInjection.d.ts +3 -0
- package/dist/types/notifications/configuration.d.ts +2 -0
- package/dist/types/notifications/types.d.ts +57 -18
- package/dist/types/poll_manager.d.ts +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/messageComposer/attachmentManager.ts +26 -19
- package/src/messageComposer/messageComposer.ts +26 -9
- package/src/messageComposer/middleware/messageComposer/MessageComposerMiddlewareExecutor.ts +2 -0
- package/src/messageComposer/middleware/messageComposer/cleanData.ts +0 -1
- package/src/messageComposer/middleware/messageComposer/messageComposerState.ts +16 -2
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +43 -0
- package/src/notifications/NotificationManager.ts +10 -15
- package/src/notifications/configuration.ts +12 -0
- package/src/notifications/types.ts +60 -18
- package/src/poll_manager.ts +7 -1
package/dist/cjs/index.node.cjs
CHANGED
|
@@ -10715,6 +10715,7 @@ __export(index_exports, {
|
|
|
10715
10715
|
MiddlewareExecutor: () => MiddlewareExecutor,
|
|
10716
10716
|
MinPriority: () => MinPriority,
|
|
10717
10717
|
Moderation: () => Moderation,
|
|
10718
|
+
NotificationManager: () => NotificationManager,
|
|
10718
10719
|
OfflineDBSyncManager: () => OfflineDBSyncManager,
|
|
10719
10720
|
OfflineError: () => OfflineError,
|
|
10720
10721
|
Permission: () => Permission,
|
|
@@ -16132,7 +16133,8 @@ var AttachmentManager = class {
|
|
|
16132
16133
|
if (!attachment.localMetadata?.file || !attachment.localMetadata.id) {
|
|
16133
16134
|
this.client.notifications.addError({
|
|
16134
16135
|
message: "File is required for upload attachment",
|
|
16135
|
-
origin: { emitter: "AttachmentManager", context: { attachment } }
|
|
16136
|
+
origin: { emitter: "AttachmentManager", context: { attachment } },
|
|
16137
|
+
options: { type: "validation:attachment:file:missing" }
|
|
16136
16138
|
});
|
|
16137
16139
|
return;
|
|
16138
16140
|
}
|
|
@@ -16182,8 +16184,17 @@ var AttachmentManager = class {
|
|
|
16182
16184
|
if (localAttachment.localMetadata.uploadState === "blocked") {
|
|
16183
16185
|
this.upsertAttachments([localAttachment]);
|
|
16184
16186
|
this.client.notifications.addError({
|
|
16185
|
-
message:
|
|
16186
|
-
origin: {
|
|
16187
|
+
message: `The attachment upload was blocked`,
|
|
16188
|
+
origin: {
|
|
16189
|
+
emitter: "AttachmentManager",
|
|
16190
|
+
context: { attachment, blockedAttachment: localAttachment }
|
|
16191
|
+
},
|
|
16192
|
+
options: {
|
|
16193
|
+
type: "validation:attachment:upload:blocked",
|
|
16194
|
+
metadata: {
|
|
16195
|
+
reason: localAttachment.localMetadata.uploadPermissionCheck?.reason
|
|
16196
|
+
}
|
|
16197
|
+
}
|
|
16187
16198
|
});
|
|
16188
16199
|
return localAttachment;
|
|
16189
16200
|
}
|
|
@@ -16200,19 +16211,7 @@ var AttachmentManager = class {
|
|
|
16200
16211
|
try {
|
|
16201
16212
|
response = await this.doUploadRequest(localAttachment.localMetadata.file);
|
|
16202
16213
|
} catch (error) {
|
|
16203
|
-
|
|
16204
|
-
message: "Error uploading attachment",
|
|
16205
|
-
name: "Error"
|
|
16206
|
-
};
|
|
16207
|
-
if (typeof error.message === "string") {
|
|
16208
|
-
finalError = error;
|
|
16209
|
-
} else if (typeof error === "object") {
|
|
16210
|
-
finalError = Object.assign(finalError, error);
|
|
16211
|
-
}
|
|
16212
|
-
this.client.notifications.addError({
|
|
16213
|
-
message: finalError.message,
|
|
16214
|
-
origin: { emitter: "AttachmentManager", context: { attachment } }
|
|
16215
|
-
});
|
|
16214
|
+
const reason = error instanceof Error ? error.message : "unknown error";
|
|
16216
16215
|
const failedAttachment = {
|
|
16217
16216
|
...attachment,
|
|
16218
16217
|
localMetadata: {
|
|
@@ -16220,6 +16219,18 @@ var AttachmentManager = class {
|
|
|
16220
16219
|
uploadState: "failed"
|
|
16221
16220
|
}
|
|
16222
16221
|
};
|
|
16222
|
+
this.client.notifications.addError({
|
|
16223
|
+
message: "Error uploading attachment",
|
|
16224
|
+
origin: {
|
|
16225
|
+
emitter: "AttachmentManager",
|
|
16226
|
+
context: { attachment, failedAttachment }
|
|
16227
|
+
},
|
|
16228
|
+
options: {
|
|
16229
|
+
type: "api:attachment:upload:failed",
|
|
16230
|
+
metadata: { reason },
|
|
16231
|
+
originalError: error instanceof Error ? error : void 0
|
|
16232
|
+
}
|
|
16233
|
+
});
|
|
16223
16234
|
this.updateAttachment(failedAttachment);
|
|
16224
16235
|
return failedAttachment;
|
|
16225
16236
|
}
|
|
@@ -17239,8 +17250,7 @@ var createCompositionDataCleanupMiddleware = (composer) => ({
|
|
|
17239
17250
|
localMessage: formatMessage({
|
|
17240
17251
|
...composer.editedMessage,
|
|
17241
17252
|
...state.localMessage,
|
|
17242
|
-
...common
|
|
17243
|
-
user: composer.client.user
|
|
17253
|
+
...common
|
|
17244
17254
|
}),
|
|
17245
17255
|
message: {
|
|
17246
17256
|
...editedMessagePayloadToBeSent,
|
|
@@ -17486,6 +17496,9 @@ var createMessageComposerStateCompositionMiddleware = (composer) => ({
|
|
|
17486
17496
|
if (composer.pollId) {
|
|
17487
17497
|
payload.poll_id = composer.pollId;
|
|
17488
17498
|
}
|
|
17499
|
+
if (composer.showReplyInChannel) {
|
|
17500
|
+
payload.show_in_channel = true;
|
|
17501
|
+
}
|
|
17489
17502
|
return next({
|
|
17490
17503
|
...state,
|
|
17491
17504
|
localMessage: {
|
|
@@ -17515,6 +17528,9 @@ var createDraftMessageComposerStateCompositionMiddleware = (composer) => ({
|
|
|
17515
17528
|
if (composer.pollId) {
|
|
17516
17529
|
payload.poll_id = composer.pollId;
|
|
17517
17530
|
}
|
|
17531
|
+
if (composer.showReplyInChannel) {
|
|
17532
|
+
payload.show_in_channel = true;
|
|
17533
|
+
}
|
|
17518
17534
|
return next({
|
|
17519
17535
|
...state,
|
|
17520
17536
|
draft: {
|
|
@@ -17526,6 +17542,31 @@ var createDraftMessageComposerStateCompositionMiddleware = (composer) => ({
|
|
|
17526
17542
|
}
|
|
17527
17543
|
});
|
|
17528
17544
|
|
|
17545
|
+
// src/messageComposer/middleware/messageComposer/userDataInjection.ts
|
|
17546
|
+
var createUserDataInjectionMiddleware = (composer) => ({
|
|
17547
|
+
id: "stream-io/message-composer-middleware/user-data-injection",
|
|
17548
|
+
handlers: {
|
|
17549
|
+
compose: ({
|
|
17550
|
+
state,
|
|
17551
|
+
next,
|
|
17552
|
+
forward
|
|
17553
|
+
}) => {
|
|
17554
|
+
if (!composer.client.user) {
|
|
17555
|
+
return forward();
|
|
17556
|
+
}
|
|
17557
|
+
const { channel_mutes, devices, mutes, ...messageUser } = composer.client.user;
|
|
17558
|
+
return next({
|
|
17559
|
+
...state,
|
|
17560
|
+
localMessage: {
|
|
17561
|
+
...state.localMessage,
|
|
17562
|
+
user: messageUser,
|
|
17563
|
+
user_id: messageUser.id
|
|
17564
|
+
}
|
|
17565
|
+
});
|
|
17566
|
+
}
|
|
17567
|
+
}
|
|
17568
|
+
});
|
|
17569
|
+
|
|
17529
17570
|
// src/messageComposer/middleware/messageComposer/pollOnly.ts
|
|
17530
17571
|
var pollLocalMessageNullifiedFields = {
|
|
17531
17572
|
attachments: [],
|
|
@@ -17567,6 +17608,7 @@ var MessageComposerMiddlewareExecutor = class extends MiddlewareExecutor {
|
|
|
17567
17608
|
constructor({ composer }) {
|
|
17568
17609
|
super();
|
|
17569
17610
|
this.use([
|
|
17611
|
+
createUserDataInjectionMiddleware(composer),
|
|
17570
17612
|
createPollOnlyCompositionMiddleware(composer),
|
|
17571
17613
|
createTextComposerCompositionMiddleware(composer),
|
|
17572
17614
|
createAttachmentsCompositionMiddleware(composer),
|
|
@@ -19141,10 +19183,11 @@ var initEditingAuditState = (composition) => {
|
|
|
19141
19183
|
var initState5 = (composition) => {
|
|
19142
19184
|
if (!composition) {
|
|
19143
19185
|
return {
|
|
19186
|
+
draftId: null,
|
|
19144
19187
|
id: MessageComposer.generateId(),
|
|
19145
|
-
quotedMessage: null,
|
|
19146
19188
|
pollId: null,
|
|
19147
|
-
|
|
19189
|
+
quotedMessage: null,
|
|
19190
|
+
showReplyInChannel: false
|
|
19148
19191
|
};
|
|
19149
19192
|
}
|
|
19150
19193
|
const quotedMessage = composition.quoted_message;
|
|
@@ -19161,8 +19204,9 @@ var initState5 = (composition) => {
|
|
|
19161
19204
|
return {
|
|
19162
19205
|
draftId,
|
|
19163
19206
|
id,
|
|
19207
|
+
pollId: message.poll_id ?? null,
|
|
19164
19208
|
quotedMessage: quotedMessage ? formatMessage(quotedMessage) : null,
|
|
19165
|
-
|
|
19209
|
+
showReplyInChannel: false
|
|
19166
19210
|
};
|
|
19167
19211
|
};
|
|
19168
19212
|
var noop3 = () => void 0;
|
|
@@ -19357,6 +19401,9 @@ var _MessageComposer = class _MessageComposer extends WithSubscriptions {
|
|
|
19357
19401
|
this.setQuotedMessage = (quotedMessage) => {
|
|
19358
19402
|
this.state.partialNext({ quotedMessage });
|
|
19359
19403
|
};
|
|
19404
|
+
this.toggleShowReplyInChannel = () => {
|
|
19405
|
+
this.state.partialNext({ showReplyInChannel: !this.showReplyInChannel });
|
|
19406
|
+
};
|
|
19360
19407
|
this.clear = () => {
|
|
19361
19408
|
this.initState();
|
|
19362
19409
|
};
|
|
@@ -19430,15 +19477,21 @@ var _MessageComposer = class _MessageComposer extends WithSubscriptions {
|
|
|
19430
19477
|
const composition = await this.pollComposer.compose();
|
|
19431
19478
|
if (!composition || !composition.data.id) return;
|
|
19432
19479
|
try {
|
|
19433
|
-
const
|
|
19434
|
-
this.state.partialNext({ pollId: poll
|
|
19435
|
-
this.pollComposer.initState();
|
|
19480
|
+
const poll = await this.client.polls.createPoll(composition.data);
|
|
19481
|
+
this.state.partialNext({ pollId: poll?.id });
|
|
19436
19482
|
} catch (error) {
|
|
19437
|
-
this.client.notifications.
|
|
19483
|
+
this.client.notifications.addError({
|
|
19438
19484
|
message: "Failed to create the poll",
|
|
19439
19485
|
origin: {
|
|
19440
19486
|
emitter: "MessageComposer",
|
|
19441
19487
|
context: { composer: this }
|
|
19488
|
+
},
|
|
19489
|
+
options: {
|
|
19490
|
+
type: "api:poll:create:failed",
|
|
19491
|
+
metadata: {
|
|
19492
|
+
reason: error.message
|
|
19493
|
+
},
|
|
19494
|
+
originalError: error instanceof Error ? error : void 0
|
|
19442
19495
|
}
|
|
19443
19496
|
});
|
|
19444
19497
|
throw error;
|
|
@@ -19543,6 +19596,9 @@ var _MessageComposer = class _MessageComposer extends WithSubscriptions {
|
|
|
19543
19596
|
get pollId() {
|
|
19544
19597
|
return this.state.getLatestValue().pollId;
|
|
19545
19598
|
}
|
|
19599
|
+
get showReplyInChannel() {
|
|
19600
|
+
return this.state.getLatestValue().showReplyInChannel;
|
|
19601
|
+
}
|
|
19546
19602
|
get hasSendableData() {
|
|
19547
19603
|
return !!(!this.attachmentManager.uploadsInProgressCount && (!this.textComposer.textIsEmpty || this.attachmentManager.successfulUploadsCount > 0) || this.pollId);
|
|
19548
19604
|
}
|
|
@@ -23119,7 +23175,11 @@ var PollManager = class extends WithSubscriptions {
|
|
|
23119
23175
|
};
|
|
23120
23176
|
this.createPoll = async (poll) => {
|
|
23121
23177
|
const { poll: createdPoll } = await this.client.createPoll(poll);
|
|
23122
|
-
|
|
23178
|
+
if (!createdPoll.vote_counts_by_option) {
|
|
23179
|
+
createdPoll.vote_counts_by_option = {};
|
|
23180
|
+
}
|
|
23181
|
+
this.setOrOverwriteInCache(createdPoll);
|
|
23182
|
+
return this.fromState(createdPoll.id);
|
|
23123
23183
|
};
|
|
23124
23184
|
this.getPoll = async (id) => {
|
|
23125
23185
|
const cachedPoll = this.fromState(id);
|
|
@@ -23657,21 +23717,23 @@ var ChannelManager = class extends WithSubscriptions {
|
|
|
23657
23717
|
}
|
|
23658
23718
|
};
|
|
23659
23719
|
|
|
23660
|
-
// src/notifications/
|
|
23661
|
-
var
|
|
23662
|
-
|
|
23663
|
-
|
|
23664
|
-
|
|
23665
|
-
|
|
23720
|
+
// src/notifications/configuration.ts
|
|
23721
|
+
var DURATION_MS = 3e3;
|
|
23722
|
+
var DEFAULT_NOTIFICATION_MANAGER_CONFIG = {
|
|
23723
|
+
durations: {
|
|
23724
|
+
error: DURATION_MS,
|
|
23725
|
+
info: DURATION_MS,
|
|
23726
|
+
success: DURATION_MS,
|
|
23727
|
+
warning: DURATION_MS
|
|
23728
|
+
}
|
|
23666
23729
|
};
|
|
23730
|
+
|
|
23731
|
+
// src/notifications/NotificationManager.ts
|
|
23667
23732
|
var NotificationManager = class {
|
|
23668
23733
|
constructor(config = {}) {
|
|
23669
23734
|
this.timeouts = /* @__PURE__ */ new Map();
|
|
23670
23735
|
this.store = new StateStore({ notifications: [] });
|
|
23671
|
-
this.config =
|
|
23672
|
-
...config,
|
|
23673
|
-
durations: config.durations || DURATIONS
|
|
23674
|
-
};
|
|
23736
|
+
this.config = mergeWith(DEFAULT_NOTIFICATION_MANAGER_CONFIG, config);
|
|
23675
23737
|
}
|
|
23676
23738
|
get notifications() {
|
|
23677
23739
|
return this.store.getLatestValue().notifications;
|
|
@@ -23691,21 +23753,24 @@ var NotificationManager = class {
|
|
|
23691
23753
|
add({ message, origin, options = {} }) {
|
|
23692
23754
|
const id = generateUUIDv4();
|
|
23693
23755
|
const now = Date.now();
|
|
23756
|
+
const severity = options.severity || "info";
|
|
23757
|
+
const duration = options.duration ?? this.config.durations[severity];
|
|
23694
23758
|
const notification = {
|
|
23695
23759
|
id,
|
|
23696
23760
|
message,
|
|
23697
23761
|
origin,
|
|
23698
|
-
|
|
23762
|
+
type: options?.type,
|
|
23763
|
+
severity,
|
|
23699
23764
|
createdAt: now,
|
|
23700
|
-
expiresAt:
|
|
23701
|
-
autoClose: options.autoClose ?? true,
|
|
23765
|
+
expiresAt: now + duration,
|
|
23702
23766
|
actions: options.actions,
|
|
23703
|
-
metadata: options.metadata
|
|
23767
|
+
metadata: options.metadata,
|
|
23768
|
+
originalError: options.originalError
|
|
23704
23769
|
};
|
|
23705
23770
|
this.store.partialNext({
|
|
23706
23771
|
notifications: [...this.store.getLatestValue().notifications, notification]
|
|
23707
23772
|
});
|
|
23708
|
-
if (notification.
|
|
23773
|
+
if (notification.expiresAt) {
|
|
23709
23774
|
const timeout = setTimeout(() => {
|
|
23710
23775
|
this.remove(id);
|
|
23711
23776
|
}, options.duration || this.config.durations[notification.severity]);
|
|
@@ -26414,7 +26479,7 @@ var StreamChat = class _StreamChat {
|
|
|
26414
26479
|
if (this.userAgent) {
|
|
26415
26480
|
return this.userAgent;
|
|
26416
26481
|
}
|
|
26417
|
-
const version = "9.
|
|
26482
|
+
const version = "9.6.0";
|
|
26418
26483
|
const clientBundle = "node-cjs";
|
|
26419
26484
|
let userAgentString = "";
|
|
26420
26485
|
if (this.sdkIdentifier) {
|
|
@@ -28492,6 +28557,7 @@ var FixedSizeQueueCache = class {
|
|
|
28492
28557
|
MiddlewareExecutor,
|
|
28493
28558
|
MinPriority,
|
|
28494
28559
|
Moderation,
|
|
28560
|
+
NotificationManager,
|
|
28495
28561
|
OfflineDBSyncManager,
|
|
28496
28562
|
OfflineError,
|
|
28497
28563
|
Permission,
|