stream-chat 8.52.3 → 8.54.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/src/client.ts CHANGED
@@ -141,6 +141,7 @@ import {
141
141
  PollVote,
142
142
  PollVoteData,
143
143
  PollVotesAPIResponse,
144
+ PushPreference,
144
145
  PushProvider,
145
146
  PushProviderConfig,
146
147
  PushProviderID,
@@ -201,6 +202,7 @@ import {
201
202
  UpdatePollAPIResponse,
202
203
  UpdatePollOptionAPIResponse,
203
204
  UpdateSegmentData,
205
+ UpsertPushPreferencesResponse,
204
206
  UserCustomEvent,
205
207
  UserFilters,
206
208
  UserOptions,
@@ -1666,6 +1668,7 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
1666
1668
  c.data = channelState.channel;
1667
1669
  c.offlineMode = offlineMode;
1668
1670
  c.initialized = !offlineMode;
1671
+ c.push_preferences = channelState.push_preferences;
1669
1672
 
1670
1673
  let updatedMessagesSet;
1671
1674
  if (skipInitialization === undefined) {
@@ -1805,6 +1808,17 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
1805
1808
  return await this.post<GetUnreadCountBatchAPIResponse>(this.baseURL + '/unread_batch', { user_ids: userIDs });
1806
1809
  }
1807
1810
 
1811
+ /**
1812
+ * setPushPreferences - Applies the list of push preferences.
1813
+ *
1814
+ * @param {PushPreference[]} A list of push preferences.
1815
+ *
1816
+ * @return {<UpsertPushPreferencesResponse>}
1817
+ */
1818
+ async setPushPreferences(preferences: PushPreference[]) {
1819
+ return await this.post<UpsertPushPreferencesResponse>(this.baseURL + '/push_preferences', { preferences });
1820
+ }
1821
+
1808
1822
  /**
1809
1823
  * removeDevice - Removes the device with the given id. Clientside users can only delete their own devices
1810
1824
  *
@@ -3087,26 +3101,73 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
3087
3101
  });
3088
3102
  }
3089
3103
 
3104
+ /**
3105
+ * Creates a new block list
3106
+ *
3107
+ * @param {BlockList} blockList - The block list to create
3108
+ * @param {string} blockList.name - The name of the block list
3109
+ * @param {string[]} blockList.words - List of words to block
3110
+ * @param {string} [blockList.team] - Team ID the block list belongs to
3111
+ *
3112
+ * @returns {Promise<APIResponse>} The server response
3113
+ */
3090
3114
  createBlockList(blockList: BlockList) {
3091
3115
  return this.post<APIResponse>(`${this.baseURL}/blocklists`, blockList);
3092
3116
  }
3093
3117
 
3094
- listBlockLists() {
3095
- return this.get<APIResponse & { blocklists: BlockListResponse[] }>(`${this.baseURL}/blocklists`);
3118
+ /**
3119
+ * Lists all block lists
3120
+ *
3121
+ * @param {Object} [data] - Query parameters
3122
+ * @param {string} [data.team] - Team ID to filter block lists by
3123
+ *
3124
+ * @returns {Promise<APIResponse & {blocklists: BlockListResponse[]}>} Response containing array of block lists
3125
+ */
3126
+ listBlockLists(data?: { team?: string }) {
3127
+ return this.get<APIResponse & { blocklists: BlockListResponse[] }>(`${this.baseURL}/blocklists`, data);
3096
3128
  }
3097
3129
 
3098
- getBlockList(name: string) {
3130
+ /**
3131
+ * Gets a specific block list
3132
+ *
3133
+ * @param {string} name - The name of the block list to retrieve
3134
+ * @param {Object} [data] - Query parameters
3135
+ * @param {string} [data.team] - Team ID that blocklist belongs to
3136
+ *
3137
+ * @returns {Promise<APIResponse & {blocklist: BlockListResponse}>} Response containing the block list
3138
+ */
3139
+ getBlockList(name: string, data?: { team?: string }) {
3099
3140
  return this.get<APIResponse & { blocklist: BlockListResponse }>(
3100
3141
  `${this.baseURL}/blocklists/${encodeURIComponent(name)}`,
3142
+ data,
3101
3143
  );
3102
3144
  }
3103
3145
 
3104
- updateBlockList(name: string, data: { words: string[] }) {
3146
+ /**
3147
+ * Updates an existing block list
3148
+ *
3149
+ * @param {string} name - The name of the block list to update
3150
+ * @param {Object} data - The update data
3151
+ * @param {string[]} data.words - New list of words to block
3152
+ * @param {string} [data.team] - Team ID that blocklist belongs to
3153
+ *
3154
+ * @returns {Promise<APIResponse>} The server response
3155
+ */
3156
+ updateBlockList(name: string, data: { words: string[]; team?: string }) {
3105
3157
  return this.put<APIResponse>(`${this.baseURL}/blocklists/${encodeURIComponent(name)}`, data);
3106
3158
  }
3107
3159
 
3108
- deleteBlockList(name: string) {
3109
- return this.delete<APIResponse>(`${this.baseURL}/blocklists/${encodeURIComponent(name)}`);
3160
+ /**
3161
+ * Deletes a block list
3162
+ *
3163
+ * @param {string} name - The name of the block list to delete
3164
+ * @param {Object} [data] - Query parameters
3165
+ * @param {string} [data.team] - Team ID that blocklist belongs to
3166
+ *
3167
+ * @returns {Promise<APIResponse>} The server response
3168
+ */
3169
+ deleteBlockList(name: string, data?: { team?: string }) {
3170
+ return this.delete<APIResponse>(`${this.baseURL}/blocklists/${encodeURIComponent(name)}`, data);
3110
3171
  }
3111
3172
 
3112
3173
  exportChannels(request: Array<ExportChannelRequest>, options: ExportChannelOptions = {}) {
package/src/constants.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export const DEFAULT_QUERY_CHANNELS_MESSAGE_LIST_PAGE_SIZE = 25;
2
2
  export const DEFAULT_QUERY_CHANNEL_MESSAGE_LIST_PAGE_SIZE = 100;
3
3
 
4
- export const DEFAULT_MESSAGE_SET_PAGINATION = { hasNext: true, hasPrev: true };
4
+ export const DEFAULT_MESSAGE_SET_PAGINATION = { hasNext: false, hasPrev: false };
package/src/types.ts CHANGED
@@ -323,6 +323,7 @@ export type ChannelAPIResponse<StreamChatGenerics extends ExtendableGenerics = D
323
323
  hidden?: boolean;
324
324
  membership?: ChannelMemberResponse<StreamChatGenerics> | null;
325
325
  pending_messages?: PendingMessageResponse<StreamChatGenerics>[];
326
+ push_preferences?: PushPreference;
326
327
  read?: ReadResponse<StreamChatGenerics>[];
327
328
  threads?: ThreadResponse[];
328
329
  watcher_count?: number;
@@ -633,6 +634,27 @@ export type GetUnreadCountAPIResponse = APIResponse & {
633
634
  total_unread_threads_count: number;
634
635
  };
635
636
 
637
+ export type ChatLevelPushPreference = 'all' | 'none' | 'mentions' | (string & {});
638
+
639
+ export type PushPreference = {
640
+ callLevel?: 'all' | 'none' | (string & {});
641
+ chatLevel?: ChatLevelPushPreference;
642
+ disabledUntil?: string; // snooze till this time
643
+ removeDisable?: boolean; // Temporary flag for resetting disabledUntil
644
+ };
645
+
646
+ export type ChannelPushPreference = {
647
+ chatLevel?: ChatLevelPushPreference; // "all", "none", "mentions", or other custom strings
648
+ disabledUntil?: string;
649
+ removeDisable?: boolean; // Temporary flag for resetting disabledUntil
650
+ };
651
+
652
+ export type UpsertPushPreferencesResponse = APIResponse & {
653
+ // Mapping of user IDs to their push preferences
654
+ userChannelPreferences: Record<string, Record<string, ChannelPushPreference>>;
655
+ userPreferences: Record<string, PushPreference>; // Mapping of user -> channel id -> push preferences
656
+ };
657
+
636
658
  export type GetUnreadCountBatchAPIResponse = APIResponse & {
637
659
  counts_by_user: { [userId: string]: GetUnreadCountAPIResponse };
638
660
  };
@@ -773,6 +795,7 @@ export type OwnUserBase<StreamChatGenerics extends ExtendableGenerics = DefaultG
773
795
  unread_threads: number;
774
796
  invisible?: boolean;
775
797
  privacy_settings?: PrivacySettings;
798
+ push_preferences?: PushPreference;
776
799
  roles?: string[];
777
800
  };
778
801
 
@@ -2205,6 +2228,7 @@ export type OGAttachment = {
2205
2228
  export type BlockList = {
2206
2229
  name: string;
2207
2230
  words: string[];
2231
+ team?: string;
2208
2232
  type?: string;
2209
2233
  validate?: boolean;
2210
2234
  };
@@ -2620,6 +2644,7 @@ export type MessageBase<
2620
2644
  pinned_at?: string | null;
2621
2645
  poll_id?: string;
2622
2646
  quoted_message_id?: string;
2647
+ restricted_visibility?: string[];
2623
2648
  show_in_channel?: boolean;
2624
2649
  silent?: boolean;
2625
2650
  text?: string;
package/src/utils.ts CHANGED
@@ -92,6 +92,7 @@ export function isOwnUserBaseProperty(property: string) {
92
92
  invisible: true,
93
93
  privacy_settings: true,
94
94
  roles: true,
95
+ push_preferences: true,
95
96
  };
96
97
 
97
98
  return ownUserBaseProperties[property as keyof OwnUserBase];