stream-chat 10.2.0 → 10.3.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.
Files changed (108) hide show
  1. package/dist/cjs/index.browser.js +4712 -2818
  2. package/dist/cjs/index.browser.js.map +4 -4
  3. package/dist/cjs/index.node.js +4733 -2818
  4. package/dist/cjs/index.node.js.map +4 -4
  5. package/dist/esm/index.mjs +4712 -2818
  6. package/dist/esm/index.mjs.map +4 -4
  7. package/dist/types/channel.d.ts +62 -3
  8. package/dist/types/client.d.ts +9 -1
  9. package/dist/types/configuration/types.d.ts +2 -0
  10. package/dist/types/connection/ConnectionRecoveryManager.d.ts +1 -0
  11. package/dist/types/gen/chat/ChatApi.d.ts +12 -1
  12. package/dist/types/gen/models/index.d.ts +659 -11
  13. package/dist/types/gen/moderation/ModerationApi.d.ts +3 -1
  14. package/dist/types/index.d.ts +2 -0
  15. package/dist/types/messageComposer/attachmentManager.d.ts +2 -0
  16. package/dist/types/messageComposer/index.d.ts +1 -0
  17. package/dist/types/messageComposer/linkPreviewsManager.d.ts +1 -0
  18. package/dist/types/messageComposer/messageComposer.d.ts +33 -7
  19. package/dist/types/messageComposer/middleware/messageComposer/compositionValidation.d.ts +1 -2
  20. package/dist/types/messageComposer/middleware/messageComposer/index.d.ts +1 -0
  21. package/dist/types/messageComposer/middleware/messageComposer/scheduledMessage.d.ts +4 -0
  22. package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +1 -0
  23. package/dist/types/messageComposer/scheduledMessageComposition.d.ts +32 -0
  24. package/dist/types/messageMarks/MessageMarkManager.d.ts +44 -0
  25. package/dist/types/messageMarks/index.d.ts +1 -0
  26. package/dist/types/messageOperations/MessageOperations.d.ts +12 -1
  27. package/dist/types/messageOperations/index.d.ts +1 -0
  28. package/dist/types/messageOperations/reflectMessageMarkEvent.d.ts +9 -0
  29. package/dist/types/messageOperations/sendOrdering.d.ts +4 -3
  30. package/dist/types/messageOperations/types.d.ts +6 -2
  31. package/dist/types/notifications/types.d.ts +4 -0
  32. package/dist/types/offline-support/offline_support_api.d.ts +19 -1
  33. package/dist/types/offline-support/types.d.ts +19 -1
  34. package/dist/types/pagination/PaginatorView.d.ts +55 -0
  35. package/dist/types/pagination/index.d.ts +1 -0
  36. package/dist/types/pagination/paginators/BasePaginator.d.ts +41 -0
  37. package/dist/types/pagination/paginators/ChannelPaginator.d.ts +0 -9
  38. package/dist/types/pagination/paginators/MessageMarkPaginator.d.ts +61 -0
  39. package/dist/types/pagination/paginators/ScheduledMessagePaginator.d.ts +83 -0
  40. package/dist/types/pagination/paginators/index.d.ts +2 -0
  41. package/dist/types/scheduledMessages/ScheduledMessagePaginatorsManager.d.ts +47 -0
  42. package/dist/types/scheduledMessages/ScheduledMessageStatePolicy.d.ts +12 -0
  43. package/dist/types/scheduledMessages/ScheduledMessagesView.d.ts +38 -0
  44. package/dist/types/scheduledMessages/composition.d.ts +5 -0
  45. package/dist/types/scheduledMessages/constants.d.ts +56 -0
  46. package/dist/types/scheduledMessages/editResolvers.d.ts +4 -0
  47. package/dist/types/scheduledMessages/errors.d.ts +3 -0
  48. package/dist/types/scheduledMessages/eventHandlers.d.ts +8 -0
  49. package/dist/types/scheduledMessages/index.d.ts +7 -0
  50. package/dist/types/scheduledMessages/limits.d.ts +6 -0
  51. package/dist/types/scheduledMessages/types.d.ts +65 -0
  52. package/dist/types/thread.d.ts +12 -1
  53. package/dist/types/utils.d.ts +7 -0
  54. package/package.json +1 -1
  55. package/src/channel.ts +231 -7
  56. package/src/client.ts +46 -2
  57. package/src/configuration/keys.ts +2 -0
  58. package/src/configuration/shape.ts +15 -0
  59. package/src/configuration/types.ts +3 -1
  60. package/src/connection/ConnectionRecoveryManager.ts +7 -0
  61. package/src/errors.ts +11 -0
  62. package/src/gen/chat/ChatApi.ts +60 -3
  63. package/src/gen/models/index.ts +794 -23
  64. package/src/gen/moderation/ModerationApi.ts +24 -3
  65. package/src/index.ts +2 -0
  66. package/src/messageComposer/attachmentManager.ts +43 -24
  67. package/src/messageComposer/index.ts +1 -0
  68. package/src/messageComposer/messageComposer.ts +140 -32
  69. package/src/messageComposer/middleware/messageComposer/MessageComposerMiddlewareExecutor.ts +2 -0
  70. package/src/messageComposer/middleware/messageComposer/compositionValidation.ts +40 -47
  71. package/src/messageComposer/middleware/messageComposer/index.ts +1 -0
  72. package/src/messageComposer/middleware/messageComposer/scheduledMessage.ts +38 -0
  73. package/src/messageComposer/middleware/textComposer/commandUtils.ts +8 -0
  74. package/src/messageComposer/scheduledMessageComposition.ts +324 -0
  75. package/src/messageMarks/MessageMarkManager.ts +145 -0
  76. package/src/messageMarks/index.ts +1 -0
  77. package/src/messageOperations/MessageOperationStatePolicy.ts +7 -0
  78. package/src/messageOperations/MessageOperations.ts +154 -1
  79. package/src/messageOperations/index.ts +1 -0
  80. package/src/messageOperations/reflectMessageMarkEvent.ts +47 -0
  81. package/src/messageOperations/reflectReactionEvent.ts +3 -0
  82. package/src/messageOperations/sendOrdering.ts +11 -4
  83. package/src/messageOperations/types.ts +6 -2
  84. package/src/notifications/types.ts +4 -0
  85. package/src/offline-support/offline_support_api.ts +61 -1
  86. package/src/offline-support/queueableOperations.ts +6 -0
  87. package/src/offline-support/types.ts +28 -0
  88. package/src/pagination/PaginatorView.ts +103 -0
  89. package/src/pagination/index.ts +1 -0
  90. package/src/pagination/paginators/BasePaginator.ts +179 -27
  91. package/src/pagination/paginators/ChannelPaginator.ts +8 -28
  92. package/src/pagination/paginators/MessageIntervalPaginator.ts +4 -1
  93. package/src/pagination/paginators/MessageMarkPaginator.ts +222 -0
  94. package/src/pagination/paginators/ScheduledMessagePaginator.ts +352 -0
  95. package/src/pagination/paginators/index.ts +2 -0
  96. package/src/scheduledMessages/ScheduledMessagePaginatorsManager.ts +268 -0
  97. package/src/scheduledMessages/ScheduledMessageStatePolicy.ts +42 -0
  98. package/src/scheduledMessages/ScheduledMessagesView.ts +57 -0
  99. package/src/scheduledMessages/composition.ts +129 -0
  100. package/src/scheduledMessages/constants.ts +79 -0
  101. package/src/scheduledMessages/editResolvers.ts +51 -0
  102. package/src/scheduledMessages/errors.ts +45 -0
  103. package/src/scheduledMessages/eventHandlers.ts +58 -0
  104. package/src/scheduledMessages/index.ts +7 -0
  105. package/src/scheduledMessages/limits.ts +32 -0
  106. package/src/scheduledMessages/types.ts +124 -0
  107. package/src/thread.ts +41 -17
  108. package/src/utils.ts +18 -0
@@ -1,5 +1,5 @@
1
1
  import type { ApiClient, StreamRequestOptions, StreamResponse } from '../../gen-imports';
2
- import type { AppealRequest, AppealResponse, BanRequest, BulkActionAppealsRequest, BulkActionAppealsResponse, BulkDeleteActionConfigRequest, BulkDeleteActionConfigResponse, BulkUpsertActionConfigRequest, BulkUpsertActionConfigResponse, CreateQueueRequest, DeleteActionConfigResponse, DeleteModerationConfigResponse, DeleteQueueRequest, FlagItemResponse, FlagRequest, GetActionConfigResponse, GetAppealResponse, GetConfigResponse, GetConfigVersionResponse, ListConfigVersionsResponse, ListQueuesResponse, ModerationBanResponse, MuteRequest, MuteResponse, PublishConfigVersionRequest, PublishConfigVersionResponse, QueryAppealsRequest, QueryAppealsResponse, QueryModerationConfigsRequest, QueryModerationConfigsResponse, QueryReviewQueueRequest, QueryReviewQueueResponse, QueueResponse, RevealMediaRequest, RevealMediaResponse, SaveConfigVersionRequest, SaveConfigVersionResponse, SubmitActionRequest, SubmitActionResponse, UnbanRequest, UnbanResponse, UnmuteRequest, UnmuteResponse, UpdateQueueRequest, UpsertActionConfigRequest, UpsertActionConfigResponse, UpsertConfigRequest, UpsertConfigResponse } from '../models';
2
+ import type { AppealRequest, AppealResponse, BanRequest, BulkActionAppealsRequest, BulkActionAppealsResponse, BulkDeleteActionConfigRequest, BulkDeleteActionConfigResponse, BulkUpsertActionConfigRequest, BulkUpsertActionConfigResponse, CountReviewQueueRequest, CountReviewQueueResponse, CreateQueueRequest, DeleteActionConfigResponse, DeleteModerationConfigResponse, DeleteQueueRequest, FlagItemResponse, FlagRequest, GetActionConfigResponse, GetAppealResponse, GetConfigResponse, GetConfigVersionResponse, ListConfigVersionsResponse, ListQueuesResponse, ModerationBanResponse, MuteRequest, MuteResponse, PublishConfigVersionRequest, PublishConfigVersionResponse, QueryAppealsRequest, QueryAppealsResponse, QueryModerationConfigsRequest, QueryModerationConfigsResponse, QueryReviewQueueRequest, QueryReviewQueueResponse, QueueResponse, RevealMediaRequest, RevealMediaResponse, SaveConfigVersionRequest, SaveConfigVersionResponse, SubmitActionRequest, SubmitActionResponse, UnbanRequest, UnbanResponse, UnmuteRequest, UnmuteResponse, UpdateQueueRequest, UpsertActionConfigRequest, UpsertActionConfigResponse, UpsertConfigRequest, UpsertConfigResponse } from '../models';
3
3
  export declare class ModerationApi {
4
4
  readonly apiClient: ApiClient;
5
5
  constructor(apiClient: ApiClient);
@@ -65,10 +65,12 @@ export declare class ModerationApi {
65
65
  }, request?: DeleteQueueRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<QueueResponse>>;
66
66
  revealMedia(request: RevealMediaRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<RevealMediaResponse>>;
67
67
  queryReviewQueue(request?: QueryReviewQueueRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<QueryReviewQueueResponse>>;
68
+ countReviewQueue(request?: CountReviewQueueRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<CountReviewQueueResponse>>;
68
69
  submitAction(request: SubmitActionRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<SubmitActionResponse>>;
69
70
  unban(request: UnbanRequest & {
70
71
  target_user_id: string;
71
72
  channel_cid?: string;
73
+ remove_future_channels_ban?: boolean;
72
74
  }, requestOptions?: StreamRequestOptions): Promise<StreamResponse<UnbanResponse>>;
73
75
  unmute(request: UnmuteRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<UnmuteResponse>>;
74
76
  }
@@ -24,6 +24,8 @@ export * from './pagination';
24
24
  export * from './poll';
25
25
  export * from './poll_manager';
26
26
  export * from './reminders';
27
+ export * from './messageMarks';
28
+ export * from './scheduledMessages';
27
29
  export * from './search';
28
30
  export * from './signing';
29
31
  export * from './languageNames';
@@ -66,6 +66,7 @@ export declare class AttachmentManager {
66
66
  getUploadsByState(state: AttachmentLoadingState): LocalAttachment[];
67
67
  cancelAttachmentUploads: (attachments?: LocalAttachment[]) => void;
68
68
  private normalizeSnapshotAttachment;
69
+ private failUntrackedUpload;
69
70
  initState: ({ message }?: {
70
71
  message?: DraftMessage | LocalMessage;
71
72
  }) => void;
@@ -78,6 +79,7 @@ export declare class AttachmentManager {
78
79
  */
79
80
  takeOver: (source: AttachmentManager) => void;
80
81
  getSnapshot: () => AttachmentManagerSnapshot;
82
+ getSnapshotKeepingUploads: () => AttachmentManagerSnapshot;
81
83
  restoreSnapshot: (snapshot: AttachmentManagerSnapshot) => void;
82
84
  setAttachments: (attachments: LocalAttachment[]) => void;
83
85
  clearAttachments: () => void;
@@ -12,3 +12,4 @@ export * from './pollComposer';
12
12
  export * from './textComposer';
13
13
  export * from './types';
14
14
  export type { CustomTextComposerSuggestion } from './types.custom';
15
+ export type { ScheduledMessageSubmitResult } from './scheduledMessageComposition';
@@ -101,6 +101,7 @@ export declare class LinkPreviewsManager implements ILinkPreviewsManager {
101
101
  original_width?: number | undefined;
102
102
  pretext?: string | undefined;
103
103
  title_link?: string | undefined;
104
+ voice_transcript?: import("..").AttachmentTranscriptResponse | undefined;
104
105
  og_scrape_url: string;
105
106
  };
106
107
  }
@@ -1,3 +1,4 @@
1
+ import type { CoreNotificationType, NotificationOptions } from '../notifications';
1
2
  import { AttachmentManager } from './attachmentManager';
2
3
  import { CustomDataManager } from './CustomDataManager';
3
4
  import { LinkPreviewsManager } from './linkPreviewsManager';
@@ -11,7 +12,7 @@ import { StateStore } from '@stream-io/state-store';
11
12
  import { generateUUIDv4 } from '../utils';
12
13
  import { Channel } from '../channel';
13
14
  import { Thread } from '../thread';
14
- import type { ChannelStateResponseFields, Command, DraftResponse, LocalMessage, MessageResponse, TimestampNS } from '../types';
15
+ import type { ChannelStateResponseFields, Command, DraftResponse, LocalMessage, MessageResponse, SendMessageOptions, TimestampNS } from '../types';
15
16
  import { WithSubscriptions } from '../utils/WithSubscriptions';
16
17
  import type { StreamChat } from '../client';
17
18
  import type { CommandSendability, MessageComposerConfig } from './configuration/types';
@@ -23,6 +24,8 @@ import type { LocationComposerSnapshot } from './LocationComposer';
23
24
  import type { PollComposerSnapshot } from './pollComposer';
24
25
  import type { TextComposerSnapshot } from './textComposer';
25
26
  import type { DeepPartial } from '../types.utility';
27
+ import { CommandSearchSource } from './middleware/textComposer/commands';
28
+ import type { ScheduledMessageResponse } from '../gen/models';
26
29
  type UnregisterSubscriptions = Unsubscribe;
27
30
  /** Unix nanoseconds, directly comparable with server `created_at` / `updated_at`. */
28
31
  export type LastComposerChange = {
@@ -66,6 +69,10 @@ export type MessageComposerState = {
66
69
  showReplyInChannel: boolean;
67
70
  /** Baseline of the message being edited, unchanged during the session (for restore or cancel). */
68
71
  editedMessage: LocalMessage | null;
72
+ editedScheduledMessage: ScheduledMessageResponse | null;
73
+ };
74
+ export type MessageComposerComposeOptions = {
75
+ sendOptions?: SendMessageOptions;
69
76
  };
70
77
  export type MessageComposerOptions = {
71
78
  client: StreamChat;
@@ -87,7 +94,9 @@ export declare class MessageComposer extends WithSubscriptions {
87
94
  pollComposer: PollComposer;
88
95
  locationComposer: LocationComposer;
89
96
  customDataManager: CustomDataManager;
97
+ private readonly scheduledMessageComposition;
90
98
  private snapshots;
99
+ private _commandSearchSource?;
91
100
  private effectHandlers;
92
101
  private readonly configController;
93
102
  constructor({ composition, config, compositionContext, client, }: MessageComposerOptions);
@@ -98,6 +107,10 @@ export declare class MessageComposer extends WithSubscriptions {
98
107
  get editedMessage(): LocalMessage | undefined;
99
108
  set editedMessage(editedMessage: LocalMessage | undefined);
100
109
  setEditedMessage: (editedMessage: LocalMessage | null | undefined) => void;
110
+ get hasEditInProgress(): boolean;
111
+ private get pausesDrafts();
112
+ get editedScheduledMessage(): ScheduledMessageResponse | undefined;
113
+ get scheduleBlockReason(): import("..").ScheduledMessageBlockReason | undefined;
101
114
  get contextType(): "message" | "channel" | "thread";
102
115
  get tag(): `message_${string}` | `channel_${string}` | `thread_${string}`;
103
116
  get threadId(): string | null;
@@ -112,6 +125,7 @@ export declare class MessageComposer extends WithSubscriptions {
112
125
  isCommandDisabled: (command: Command) => boolean;
113
126
  validateCommandSendability: (command: Command, text?: string) => CommandSendability;
114
127
  get isCommandSendable(): boolean;
128
+ get commandSearchSource(): CommandSearchSource;
115
129
  /** See {@link AttachmentManagerConfig.pendingUploadsEnabled}. */
116
130
  get allowsPendingUploads(): boolean;
117
131
  /**
@@ -158,12 +172,13 @@ export declare class MessageComposer extends WithSubscriptions {
158
172
  applyServerRestrictions: () => void;
159
173
  refreshId: () => void;
160
174
  initState: ({ composition, }?: {
161
- composition?: DraftResponse | MessageResponse | LocalMessage;
175
+ composition?: DraftResponse | MessageResponse | LocalMessage | ScheduledMessageResponse;
162
176
  }) => void;
163
177
  initStateFromChannelResponse: (channelApiResponse: ChannelStateResponseFields) => void;
164
- initEditingAuditState: (composition?: DraftResponse | MessageResponse | LocalMessage) => EditingAuditState;
178
+ initEditingAuditState: (composition?: DraftResponse | MessageResponse | LocalMessage | ScheduledMessageResponse) => EditingAuditState;
165
179
  clearSnapshots: () => void;
166
180
  getSnapshot: () => MessageComposerSnapshot;
181
+ getSnapshotKeepingUploads: () => MessageComposerSnapshot;
167
182
  restoreSnapshot: (snapshot: MessageComposerSnapshot) => void;
168
183
  /**
169
184
  * Moves this composition into `target`, replacing what `target` held, and clears this composer.
@@ -202,15 +217,22 @@ export declare class MessageComposer extends WithSubscriptions {
202
217
  toggleShowReplyInChannel: () => void;
203
218
  clear: () => void;
204
219
  restore: () => void;
205
- compose: () => Promise<MessageComposerMiddlewareValue["state"] | undefined>;
220
+ compose: ({ sendOptions }?: MessageComposerComposeOptions) => Promise<MessageComposerMiddlewareValue["state"] | undefined>;
206
221
  composeDraft: () => Promise<import("..").MessageDraftComposerMiddlewareValueState | undefined>;
207
222
  createDraft: () => Promise<void>;
208
223
  deleteDraft: () => Promise<void>;
209
224
  getDraft: () => Promise<void>;
210
225
  createPoll: () => Promise<void>;
211
- /** Clears the composer, or only detaches the poll when `retainsCompositionOnSubmit`. */
212
- private releaseSubmittedComposition;
213
- private reportSubmitFailure;
226
+ /**
227
+ * Clears the composer, or only detaches the poll when `retainsCompositionOnSubmit`.
228
+ *
229
+ * @internal
230
+ */
231
+ releaseSubmittedComposition: () => void;
232
+ private get notificationOrigin();
233
+ notifyWarning: (message: string, options?: NotificationOptions) => void;
234
+ /** @internal */
235
+ reportSubmitFailure: (type: CoreNotificationType, message: string, error: unknown) => void;
214
236
  /**
215
237
  * Composes and sends the message. Never rejects: see {@link MessageComposerSubmitResult}. A failure is
216
238
  * reported through `client.notifications`.
@@ -218,6 +240,10 @@ export declare class MessageComposer extends WithSubscriptions {
218
240
  send: () => Promise<MessageComposerSubmitResult>;
219
241
  /** Composes and saves the edit, on the same terms as {@link send}. */
220
242
  update: () => Promise<MessageComposerSubmitResult>;
243
+ scheduleMessage: (scheduledAt: Date) => Promise<import("./scheduledMessageComposition").ScheduledMessageSubmitResult>;
244
+ editScheduledMessage: (scheduledMessage: ScheduledMessageResponse) => Promise<void>;
245
+ updateScheduledMessage: () => Promise<import("./scheduledMessageComposition").ScheduledMessageSubmitResult>;
246
+ cancelScheduledMessageEdit: () => void;
221
247
  sendLocation: () => Promise<void>;
222
248
  }
223
249
  export {};
@@ -1,5 +1,4 @@
1
- import { CommandSearchSource } from '../textComposer/commands';
2
1
  import type { MessageCompositionMiddleware, MessageDraftCompositionMiddleware } from './types';
3
2
  import type { MessageComposer } from '../../messageComposer';
4
- export declare const createCompositionValidationMiddleware: (composer: MessageComposer, commandSearchSource?: CommandSearchSource) => MessageCompositionMiddleware;
3
+ export declare const createCompositionValidationMiddleware: (composer: MessageComposer, commandSearchSource?: MessageComposer["commandSearchSource"]) => MessageCompositionMiddleware;
5
4
  export declare const createDraftCompositionValidationMiddleware: (composer: MessageComposer) => MessageDraftCompositionMiddleware;
@@ -6,6 +6,7 @@ export * from './linkPreviews';
6
6
  export * from './MessageComposerMiddlewareExecutor';
7
7
  export * from './messageComposerState';
8
8
  export * from './pollOnly';
9
+ export * from './scheduledMessage';
9
10
  export * from './sharedLocation';
10
11
  export * from './textComposer';
11
12
  export * from './types';
@@ -0,0 +1,4 @@
1
+ import type { MessageComposer } from '../../messageComposer';
2
+ import type { MessageCompositionMiddleware } from './types';
3
+ export declare const SCHEDULED_MESSAGE_COMPOSITION_MIDDLEWARE_ID = "stream-io/message-composer-middleware/scheduled-message";
4
+ export declare const createScheduledMessageCompositionMiddleware: (composer: MessageComposer) => MessageCompositionMiddleware;
@@ -13,6 +13,7 @@ export declare const commandTakesNoArguments: (command: Command) => boolean;
13
13
  export declare const stripMentionTokens: (text: string, mentionedUsersInText: UserResponse[], trigger?: string) => string;
14
14
  export declare const getMentionedUsersInText: (text: string, mentionedUsers: UserResponse[]) => UserResponse[];
15
15
  export declare const getCommandByName: (searchSource: CommandSearchSource, commandName?: string) => Command | undefined;
16
+ export declare const getCurrentCommand: (composer: MessageComposer, text?: string, commandSearchSource?: CommandSearchSource) => Command | undefined;
16
17
  export declare const notifyCommandDisabled: (composer: MessageComposer, command: Command) => true | undefined;
17
18
  export declare const notifyCommandNotReady: ({ composer, sendability, }: {
18
19
  composer: MessageComposer;
@@ -0,0 +1,32 @@
1
+ import { WithSubscriptions } from '../utils/WithSubscriptions';
2
+ import { ScheduledMessageBlockReason } from '../scheduledMessages/constants';
3
+ import type { Unsubscribe } from '@stream-io/state-store';
4
+ import type { ScheduledMessageResponse } from '../gen/models';
5
+ import type { MessageComposer } from './messageComposer';
6
+ export type ScheduledMessageSubmitResult = {
7
+ status: 'scheduled' | 'sent' | 'nothing-to-send' | 'blocked' | 'failed';
8
+ error?: unknown;
9
+ scheduledMessage?: ScheduledMessageResponse;
10
+ };
11
+ export type ScheduledMessageCompositionOptions = {
12
+ composer: MessageComposer;
13
+ };
14
+ export declare class ScheduledMessageComposition extends WithSubscriptions {
15
+ private readonly composer;
16
+ constructor({ composer }: ScheduledMessageCompositionOptions);
17
+ private get editedScheduledMessage();
18
+ private get failedScheduledMessage();
19
+ get scheduleBlockReason(): ScheduledMessageBlockReason | undefined;
20
+ get blocksNewComposition(): boolean;
21
+ claimSend: () => {
22
+ onSent: () => void;
23
+ } | null;
24
+ private removeFailedScheduledMessage;
25
+ private refreshEditedScheduledMessage;
26
+ private closeEditWhenMessageEnds;
27
+ registerSubscriptions: () => Unsubscribe;
28
+ editScheduledMessage: (scheduledMessage: ScheduledMessageResponse) => Promise<void>;
29
+ schedule: (scheduledAt: Date) => Promise<ScheduledMessageSubmitResult>;
30
+ update: () => Promise<ScheduledMessageSubmitResult>;
31
+ cancelEdit: () => void;
32
+ }
@@ -0,0 +1,44 @@
1
+ import type { StreamChat } from '../client';
2
+ import type { MessageMarkPaginator } from '../pagination/paginators/MessageMarkPaginator';
3
+ import { WithSubscriptions } from '../utils/WithSubscriptions';
4
+ /**
5
+ * Keeps the registered {@link MessageMarkPaginator}s current: `message.mark_added` adds the mark to
6
+ * the lists of its message, and a reconnect flags them stale, so each reloads when it is next
7
+ * active. Lists are registered by their `id` and stay until removed. Subscribes when the first list
8
+ * is registered.
9
+ */
10
+ export declare class MessageMarkManager extends WithSubscriptions {
11
+ private client;
12
+ private entries;
13
+ constructor({ client }: {
14
+ client: StreamChat;
15
+ });
16
+ /** The registered lists. */
17
+ get paginators(): MessageMarkPaginator[];
18
+ getPaginatorById(id: string): MessageMarkPaginator | undefined;
19
+ /**
20
+ * Registers a list, so it follows `message.mark_added` and reconnects. One already registered
21
+ * with the same ID is replaced. Display it between `paginator.activate()` and its release, so a
22
+ * stale list reloads while it is shown.
23
+ *
24
+ * @returns The registered paginator.
25
+ */
26
+ registerPaginator({ paginator, }: {
27
+ paginator: MessageMarkPaginator;
28
+ }): MessageMarkPaginator;
29
+ /**
30
+ * Unregisters a list: it stops following events, and its loaded marks stay.
31
+ *
32
+ * @param paginatorOrId - The paginator to remove, or its ID.
33
+ * @returns The removed paginator, or `undefined` when it was not registered.
34
+ */
35
+ removePaginator(paginatorOrId: MessageMarkPaginator | string): MessageMarkPaginator | undefined;
36
+ /**
37
+ * Empties and unregisters every list. Called by `client.disconnectUser()`: the marks belong to
38
+ * that user.
39
+ */
40
+ clear: () => void;
41
+ registerSubscriptions: () => void;
42
+ private addMark;
43
+ private dropPaginator;
44
+ }
@@ -0,0 +1 @@
1
+ export * from './MessageMarkManager';
@@ -1,6 +1,8 @@
1
- import type { ReactionRequest, SendReactionRequest } from '../types';
1
+ import type { ReactionRequest, SendReactionRequest, StreamResponse } from '../types';
2
2
  import type { StateStore } from '@stream-io/state-store';
3
+ import type { ScheduledMessageResponse, SendMessageResponse } from '../gen/models';
3
4
  import type { MessageOperationsContext, OperationParams } from './types';
5
+ import type { ScheduleMessageParams, UpdateScheduledMessageParams } from '../scheduledMessages/types';
4
6
  export type MessageOperationsConfig = {
5
7
  /** Most failed sends kept for retry; the oldest is evicted past this (defaults to 100). */
6
8
  failedSendCacheMaxSize: number;
@@ -16,6 +18,7 @@ export declare const DEFAULT_MESSAGE_OPERATIONS_CONFIG: MessageOperationsConfig;
16
18
  export declare class MessageOperations {
17
19
  private ctx;
18
20
  private policy;
21
+ private scheduledPolicy;
19
22
  private readonly failedSendCache;
20
23
  private readonly normalizeOutgoingMessage;
21
24
  private readonly sequenceRequests;
@@ -58,6 +61,14 @@ export declare class MessageOperations {
58
61
  private sendWithFailedSendCache;
59
62
  update(params: OperationParams<'update'>): Promise<void>;
60
63
  delete(params: OperationParams<'delete'>): Promise<void>;
64
+ ingestScheduledMessage(scheduledMessage: ScheduledMessageResponse): void;
65
+ private get scheduledRequestHandlers();
66
+ private resolveScheduledRequest;
67
+ private runScheduled;
68
+ scheduleMessage({ localMessage, message, options, }: ScheduleMessageParams): Promise<StreamResponse<SendMessageResponse>>;
69
+ updateScheduledMessage(id: string, { localMessage, request }: UpdateScheduledMessageParams): Promise<ScheduledMessageResponse>;
70
+ deleteScheduledMessage(id: string): Promise<ScheduledMessageResponse>;
71
+ sendScheduledMessageNow(id: string): Promise<ScheduledMessageResponse>;
61
72
  /**
62
73
  * Adds a reaction optimistically: it is applied to the cached message at once, then sent through the
63
74
  * offline queue. The response's counts reconcile; a definitive failure rolls it back, a request queued
@@ -3,6 +3,7 @@ export { createMessageOperations } from './createMessageOperations';
3
3
  export { MessageOperationStatePolicy } from './MessageOperationStatePolicy';
4
4
  export { applyReactionLocally } from './applyReactionLocally';
5
5
  export { reflectReactionEvent } from './reflectReactionEvent';
6
+ export { reflectMessageMarkEvent } from './reflectMessageMarkEvent';
6
7
  export type { OptimisticOutcome } from './MessageOperationStatePolicy';
7
8
  export type { DefaultOperationRequest, MessageOperationsContext, MessageOperationsHandlers, OperationKind, OperationParams, OperationRequestFn, OperationResponse, } from './types';
8
9
  export * from './settlePendingAttachmentUploads';
@@ -0,0 +1,9 @@
1
+ import type { StreamChat } from '../client';
2
+ import type { MessageMarkResponse } from '../types';
3
+ /**
4
+ * Applies a `message.mark_added` event to the canonical copy of the message, by ID, as an
5
+ * idempotent set-add keyed (message_id, user_id, type). The mark joins `mark_groups` on the
6
+ * current user's own message, or `own_marks` when the current user marked another user's message.
7
+ * No-op when nothing holds the message or the client has no user.
8
+ */
9
+ export declare const reflectMessageMarkEvent: (client: StreamChat, mark: MessageMarkResponse) => void;
@@ -1,9 +1,10 @@
1
1
  import type { MessageComposer } from '../messageComposer/messageComposer';
2
2
  import type { OperationKind } from './types';
3
3
  /**
4
- * The {@link MessageOperationsContext.sequenceRequests} policy of `Channel` and `Thread`. Sends and
5
- * retries wait for each other while the composer may hand over still-uploading files, so a short text
6
- * sent after a photo is not dated first. Edits and deletes never wait.
4
+ * The {@link MessageOperationsContext.sequenceRequests} policy of `Channel` and `Thread`. Sends,
5
+ * retries and schedules wait for each other while the composer may hand over still-uploading files, so
6
+ * a short text sent after a photo is not dated first. Edits, deletes and the other scheduled-message
7
+ * operations never wait.
7
8
  */
8
9
  export declare const keepSendOrderWhilePendingUploadsAllowed: <T>({ channelCid, composer, kind, request, }: {
9
10
  /** Scope of the ordering: a thread passes its channel's cid. */
@@ -2,7 +2,7 @@ import type { DeleteMessageOptions, LocalMessage, MessageRequest, MessageRespons
2
2
  import type { QueueableType } from '../offline-support/types';
3
3
  import type { Channel } from '../channel';
4
4
  import type { StreamChat } from '../client';
5
- export type OperationKind = 'send' | 'retry' | 'update' | 'delete';
5
+ export type OperationKind = 'send' | 'retry' | 'update' | 'delete' | 'schedule';
6
6
  export type MessageOperationSpec = {
7
7
  send: {
8
8
  options: SendMessageOptions;
@@ -22,11 +22,15 @@ export type MessageOperationSpec = {
22
22
  message: MessageResponse;
23
23
  };
24
24
  };
25
+ schedule: {
26
+ options: SendMessageOptions;
27
+ requestResult: SendMessageAPIResponse;
28
+ };
25
29
  };
26
30
  export type OperationParams<K extends OperationKind> = {
27
31
  localMessage: LocalMessage;
28
32
  options?: MessageOperationSpec[K]['options'];
29
- } & (K extends 'send' | 'retry' ? {
33
+ } & (K extends 'send' | 'retry' | 'schedule' ? {
30
34
  message?: MessageRequest;
31
35
  } : {});
32
36
  export type OperationResponse = {
@@ -33,6 +33,10 @@ export declare const CORE_NOTIFICATION_TYPE: {
33
33
  readonly messageUpdateFailed: "api:message:update:failed";
34
34
  readonly pollCastVoteLimit: "validation:poll:castVote:limit";
35
35
  readonly pollCreateFailed: "api:poll:create:failed";
36
+ readonly scheduledMessageBlocked: "validation:scheduled-message:blocked";
37
+ readonly scheduledMessageCompositionEnded: "validation:scheduled-message:composition:ended";
38
+ readonly scheduledMessageCreateFailed: "api:scheduled-message:create:failed";
39
+ readonly scheduledMessageUpdateFailed: "api:scheduled-message:update:failed";
36
40
  };
37
41
  /** A notification type emitted by `stream-chat` itself. See {@link CORE_NOTIFICATION_TYPE}. */
38
42
  export type CoreNotificationType = (typeof CORE_NOTIFICATION_TYPE)[keyof typeof CORE_NOTIFICATION_TYPE];
@@ -22,6 +22,7 @@ export declare abstract class AbstractOfflineDB implements OfflineDBApi {
22
22
  });
23
23
  /** Writes the reaction, the message carrying it and the associated users. */
24
24
  abstract insertReaction: OfflineDBApi['insertReaction'];
25
+ abstract insertMessageMark: OfflineDBApi['insertMessageMark'];
25
26
  /** Upserts the CIDs for a filter + sort query hash (cids table only). */
26
27
  abstract upsertCidsForQuery: OfflineDBApi['upsertCidsForQuery'];
27
28
  /**
@@ -75,6 +76,7 @@ export declare abstract class AbstractOfflineDB implements OfflineDBApi {
75
76
  /** The stored app settings. They only refresh when fetched again, so they can be stale. */
76
77
  abstract getAppSettings: OfflineDBApi['getAppSettings'];
77
78
  abstract getReactions: OfflineDBApi['getReactions'];
79
+ abstract getMessageMarks: OfflineDBApi['getMessageMarks'];
78
80
  /** Runs the queries in one transaction. */
79
81
  abstract executeSqlBatch: OfflineDBApi['executeSqlBatch'];
80
82
  /** Adds a pending task. Executing a task of an unsupported type throws. */
@@ -258,6 +260,20 @@ export declare abstract class AbstractOfflineDB implements OfflineDBApi {
258
260
  event: EventPayload<"message.updated" | "message.undeleted">;
259
261
  execute?: boolean;
260
262
  }) => Promise<PrepareBatchDBQueries[]>;
263
+ /**
264
+ * Stores the mark, and the message's mark summaries as the message store holds them: the event
265
+ * carries only the mark, which `Channel` has applied to that copy by the time a live event reaches
266
+ * the DB. A message the store does not hold, or a thread reply, is skipped and gets its marks
267
+ * stored with its next query.
268
+ *
269
+ * @param payload.event - The WS event we are trying to process.
270
+ * @param payload.execute - Whether to immediately execute the queries. Defaults to `true`.
271
+ * @returns The prepared queries.
272
+ */
273
+ handleMessageMarkAddedEvent: ({ event, execute, }: {
274
+ event: EventPayload<"message.mark_added">;
275
+ execute?: boolean;
276
+ }) => Promise<PrepareBatchDBQueries[]>;
261
277
  /**
262
278
  * Sets `hidden` from the event type, as the event's channel does not carry it.
263
279
  *
@@ -341,10 +357,12 @@ export declare abstract class AbstractOfflineDB implements OfflineDBApi {
341
357
  * plain spread: normalizing again would turn a flattened `mentioned_users` into `[undefined]`.
342
358
  */
343
359
  private handleUpdateMessagePendingTask;
360
+ /** Whether a mark of the same type is already queued for the message. */
361
+ private isMessageMarkQueued;
344
362
  /**
345
363
  * Stores the task. An edit of a never-sent message is folded into its queued send instead. With no
346
364
  * queued send, an edit `isMessageUpdateReplayable` refuses (attachments still on local URLs) is
347
- * dropped.
365
+ * dropped. A mark already queued for the message is not queued again.
348
366
  *
349
367
  * @param payload.task - The pending task to store.
350
368
  */
@@ -1,4 +1,4 @@
1
- import type { ChannelFilters, ChannelMemberResponse, ChannelOptions, ChannelResponse, ChannelStateResponseFields, DraftResponse, GetApplicationResponse, LocalMessage, MessageResponse, ParsedPredefinedFilterResponse, PollResponseData, QueryChannelsRequest, ReactionFilters, ReactionResponse, ReadStateResponse, SortParamRequest, TimestampNS } from '../types';
1
+ import type { ChannelFilters, ChannelMemberResponse, ChannelOptions, ChannelResponse, ChannelStateResponseFields, DraftResponse, GetApplicationResponse, LocalMessage, MessageMarkResponse, MessageMarkWithUserResponse, MessageResponse, ParsedPredefinedFilterResponse, PollResponseData, QueryChannelsRequest, QueryMessageMarksFilter, ReactionFilters, ReactionResponse, ReadStateResponse, SortParamRequest, TimestampNS, UserResponse } from '../types';
2
2
  import type { Channel } from '../channel';
3
3
  import type { StreamChat } from '../client';
4
4
  export type PrepareBatchDBQueries = [string] | [string, Array<unknown> | Array<Array<unknown>>];
@@ -7,6 +7,14 @@ export type DBInsertReactionType = {
7
7
  reaction: ReactionResponse;
8
8
  execute?: boolean;
9
9
  };
10
+ export type DBInsertMessageMarkType = {
11
+ /** The message as it holds the mark: its `mark_groups` and `own_marks` are stored. */
12
+ message: MessageResponse | LocalMessage;
13
+ mark: MessageMarkResponse;
14
+ /** Who made the mark, stored so the mark lists with their name. */
15
+ user?: UserResponse;
16
+ execute?: boolean;
17
+ };
10
18
  export type DBUpsertCidsForQueryType = {
11
19
  cids: string[];
12
20
  filters?: ChannelFilters;
@@ -101,6 +109,11 @@ export type DBGetReactionsType = {
101
109
  sort?: SortParamRequest[];
102
110
  limit?: number;
103
111
  };
112
+ export type DBGetMessageMarksType = {
113
+ messageId: string;
114
+ filter?: QueryMessageMarksFilter;
115
+ limit?: number;
116
+ };
104
117
  export type DBDeletePendingTaskType = {
105
118
  id: number;
106
119
  };
@@ -164,6 +177,7 @@ export type ExecuteBatchDBQueriesType = PrepareBatchDBQueries[];
164
177
  */
165
178
  export interface OfflineDBApi {
166
179
  insertReaction: (options: DBInsertReactionType) => Promise<ExecuteBatchDBQueriesType>;
180
+ insertMessageMark: (options: DBInsertMessageMarkType) => Promise<ExecuteBatchDBQueriesType>;
167
181
  upsertCidsForQuery: (options: DBUpsertCidsForQueryType) => Promise<ExecuteBatchDBQueriesType>;
168
182
  upsertChannels: (options: DBUpsertChannelsType) => Promise<ExecuteBatchDBQueriesType>;
169
183
  upsertUserSyncStatus: (options: DBUpsertUserSyncStatusType) => Promise<ExecuteBatchDBQueriesType>;
@@ -183,6 +197,8 @@ export interface OfflineDBApi {
183
197
  getLastSyncedAt: (options: DBGetLastSyncedAtType) => Promise<string | undefined>;
184
198
  getAppSettings: (options: DBGetAppSettingsType) => Promise<GetApplicationResponse | null>;
185
199
  getReactions: (options: DBGetReactionsType) => Promise<ReactionResponse[] | null>;
200
+ /** The stored marks on a message, newest first, with the users who made them. */
201
+ getMessageMarks: (options: DBGetMessageMarksType) => Promise<MessageMarkWithUserResponse[] | null>;
186
202
  executeSqlBatch: (queries: ExecuteBatchDBQueriesType) => Promise<unknown>;
187
203
  addPendingTask: (task: PendingTask) => Promise<() => Promise<void>>;
188
204
  getPendingTasks: (conditions?: DBGetPendingTasksType) => Promise<PendingTask[]>;
@@ -210,6 +226,7 @@ export type PendingTaskTypes = {
210
226
  deleteReaction: 'delete-reaction';
211
227
  sendReaction: 'send-reaction';
212
228
  sendMessage: 'send-message';
229
+ sendMessageMark: 'send-message-mark';
213
230
  createDraft: 'create-draft';
214
231
  deleteDraft: 'delete-draft';
215
232
  };
@@ -229,6 +246,7 @@ export type QueueableOperationSignatures = {
229
246
  'delete-message': StreamChat['deleteMessage'];
230
247
  'delete-reaction': StreamChat['deleteReaction'];
231
248
  'send-message': Channel['sendMessage'];
249
+ 'send-message-mark': StreamChat['createMessageMark'];
232
250
  'send-reaction': StreamChat['sendReaction'];
233
251
  'update-message': StreamChat['updateMessage'];
234
252
  };
@@ -0,0 +1,55 @@
1
+ import { StateStore } from '@stream-io/state-store';
2
+ import { WithSubscriptions } from '../utils/WithSubscriptions';
3
+ import type { BasePaginator } from './paginators/BasePaginator';
4
+ type Loader<T> = BasePaginator<T, any>['toTail'];
5
+ type DebouncedLoader<T> = BasePaginator<T, any>['toTailDebounced'];
6
+ export type PaginatorViewState<T> = {
7
+ /**
8
+ * The items of the paginator's active interval (`state.items`) the predicate accepts, in the
9
+ * paginator's order. `undefined` until the paginator has items.
10
+ */
11
+ items: T[] | undefined;
12
+ };
13
+ export type PaginatorViewPredicate<T> = (item: T) => boolean;
14
+ export type PaginatorViewOptions<T> = {
15
+ /** The list the items come from. The view only reads it. */
16
+ paginator: BasePaginator<T, any>;
17
+ /** Which items the view shows; all of them without it. */
18
+ predicate?: PaginatorViewPredicate<T>;
19
+ };
20
+ /**
21
+ * A subset of a paginator's loaded items, kept in step with it: a list derived from another, not a
22
+ * list of its own. Nothing is copied or queried, so every view of a paginator agrees with it. Use
23
+ * one when the server cannot filter what a UI shows, e.g. a thread's scheduled replies among a
24
+ * channel's scheduled messages.
25
+ *
26
+ * It narrows the active interval only (`state.items`). Not to be confused with the paginator's
27
+ * `intervalViews`, which project whole intervals. It never writes the paginator's items; its
28
+ * `toHead` / `toTail` (and their debounced versions) are the paginator's own, so a UI holding only
29
+ * the view can load further pages, in whichever direction that paginator grows.
30
+ *
31
+ * `state` follows the paginator while subscriptions are registered. Registering is ref-counted:
32
+ * each holder (an owning object, a UI showing the view) registers while it holds the view. On
33
+ * registering, `state` catches up at once.
34
+ */
35
+ export declare class PaginatorView<T> extends WithSubscriptions {
36
+ readonly paginator: BasePaginator<T, any>;
37
+ readonly state: StateStore<PaginatorViewState<T>>;
38
+ private readonly predicate?;
39
+ constructor({ paginator, predicate }: PaginatorViewOptions<T>);
40
+ /** The paginator's `toHead`: loads the page headward of the loaded items. */
41
+ toHead: Loader<T>;
42
+ /** The paginator's `toTail`: loads the page tailward of the loaded items. */
43
+ toTail: Loader<T>;
44
+ /** The paginator's `toHeadDebounced`. */
45
+ toHeadDebounced: DebouncedLoader<T>;
46
+ /** The paginator's `toTailDebounced`. */
47
+ toTailDebounced: DebouncedLoader<T>;
48
+ /** Whether the view takes an item, loaded or not. */
49
+ accepts: (item: T) => boolean;
50
+ registerSubscriptions: () => void;
51
+ private selectItems;
52
+ /** Writes the view's own `state` from the paginator's items; never the paginator. */
53
+ private syncItems;
54
+ }
55
+ export {};
@@ -1,3 +1,4 @@
1
1
  export * from './paginators';
2
2
  export * from './FilterBuilder';
3
3
  export type { FieldToDataResolver } from './types.normalization';
4
+ export * from './PaginatorView';