stream-chat 9.15.0 → 9.17.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.
@@ -11877,6 +11877,7 @@ __export(index_exports, {
11877
11877
  DevToken: () => DevToken,
11878
11878
  EVENT_MAP: () => EVENT_MAP,
11879
11879
  ErrorFromResponse: () => ErrorFromResponse,
11880
+ FilterBuilder: () => FilterBuilder,
11880
11881
  FixedSizeQueueCache: () => FixedSizeQueueCache,
11881
11882
  InsightMetrics: () => InsightMetrics,
11882
11883
  JWTServerToken: () => JWTServerToken,
@@ -15357,6 +15358,58 @@ var toUpdatedMessagePayload = (message) => {
15357
15358
  )
15358
15359
  };
15359
15360
  };
15361
+ var toDeletedMessage = ({
15362
+ message,
15363
+ deletedAt,
15364
+ hardDelete = false
15365
+ }) => {
15366
+ if (hardDelete) {
15367
+ return {
15368
+ attachments: [],
15369
+ cid: message.cid,
15370
+ created_at: message.created_at,
15371
+ deleted_at: deletedAt,
15372
+ id: message.id,
15373
+ latest_reactions: [],
15374
+ mentioned_users: [],
15375
+ own_reactions: [],
15376
+ parent_id: message.parent_id,
15377
+ reply_count: message.reply_count,
15378
+ status: message.status,
15379
+ thread_participants: message.thread_participants,
15380
+ type: "deleted",
15381
+ updated_at: message.updated_at,
15382
+ user: message.user
15383
+ };
15384
+ } else {
15385
+ return {
15386
+ ...message,
15387
+ attachments: [],
15388
+ type: "deleted",
15389
+ deleted_at: deletedAt
15390
+ };
15391
+ }
15392
+ };
15393
+ var deleteUserMessages = ({
15394
+ messages,
15395
+ user,
15396
+ hardDelete = false,
15397
+ deletedAt
15398
+ }) => {
15399
+ for (let i = 0; i < messages.length; i++) {
15400
+ const message = messages[i];
15401
+ if (message.user?.id === user.id) {
15402
+ messages[i] = message.type === "deleted" ? message : toDeletedMessage({ message, hardDelete, deletedAt });
15403
+ }
15404
+ if (message.quoted_message?.user?.id === user.id) {
15405
+ messages[i].quoted_message = message.quoted_message.type === "deleted" ? message.quoted_message : toDeletedMessage({
15406
+ message: messages[i].quoted_message,
15407
+ hardDelete,
15408
+ deletedAt
15409
+ });
15410
+ }
15411
+ }
15412
+ };
15360
15413
  var findIndexInSortedArray = ({
15361
15414
  needle,
15362
15415
  sortedArray,
@@ -15891,46 +15944,24 @@ var ChannelState = class {
15891
15944
  * @param {UserResponse} user
15892
15945
  * @param {boolean} hardDelete
15893
15946
  */
15894
- this.deleteUserMessages = (user, hardDelete = false) => {
15895
- const _deleteUserMessages = (messages, user2, hardDelete2 = false) => {
15896
- for (let i = 0; i < messages.length; i++) {
15897
- const m = messages[i];
15898
- if (m.user?.id !== user2.id) {
15899
- continue;
15900
- }
15901
- if (hardDelete2) {
15902
- messages[i] = {
15903
- cid: m.cid,
15904
- created_at: m.created_at,
15905
- deleted_at: user2.deleted_at,
15906
- id: m.id,
15907
- latest_reactions: [],
15908
- mentioned_users: [],
15909
- own_reactions: [],
15910
- parent_id: m.parent_id,
15911
- reply_count: m.reply_count,
15912
- status: m.status,
15913
- thread_participants: m.thread_participants,
15914
- type: "deleted",
15915
- updated_at: m.updated_at,
15916
- user: m.user
15917
- };
15918
- } else {
15919
- messages[i] = {
15920
- ...m,
15921
- type: "deleted",
15922
- deleted_at: user2.deleted_at ? new Date(user2.deleted_at) : null
15923
- };
15924
- }
15925
- }
15926
- };
15947
+ this.deleteUserMessages = (user, hardDelete = false, deletedAt) => {
15927
15948
  this.messageSets.forEach(
15928
- (set) => _deleteUserMessages(set.messages, user, hardDelete)
15949
+ ({ messages }) => deleteUserMessages({ messages, user, hardDelete, deletedAt: deletedAt ?? null })
15929
15950
  );
15930
15951
  for (const parentId in this.threads) {
15931
- _deleteUserMessages(this.threads[parentId], user, hardDelete);
15952
+ deleteUserMessages({
15953
+ messages: this.threads[parentId],
15954
+ user,
15955
+ hardDelete,
15956
+ deletedAt: deletedAt ?? null
15957
+ });
15932
15958
  }
15933
- _deleteUserMessages(this.pinnedMessages, user, hardDelete);
15959
+ deleteUserMessages({
15960
+ messages: this.pinnedMessages,
15961
+ user,
15962
+ hardDelete,
15963
+ deletedAt: deletedAt ?? null
15964
+ });
15934
15965
  };
15935
15966
  this._channel = channel;
15936
15967
  this.watcher_count = 0;
@@ -19521,21 +19552,242 @@ var SearchController = class {
19521
19552
  }
19522
19553
  };
19523
19554
 
19555
+ // src/pagination/BasePaginator.ts
19556
+ var DEFAULT_PAGINATION_OPTIONS = {
19557
+ debounceMs: 300,
19558
+ pageSize: 10
19559
+ };
19560
+ var BasePaginator = class {
19561
+ constructor(options) {
19562
+ this._isCursorPagination = false;
19563
+ this.setDebounceOptions = ({ debounceMs }) => {
19564
+ this._executeQueryDebounced = debounce(this.executeQuery.bind(this), debounceMs);
19565
+ };
19566
+ this.canExecuteQuery = (direction) => !this.isLoading && direction === "next" && this.hasNext || direction === "prev" && this.hasPrev;
19567
+ this.next = () => this.executeQuery({ direction: "next" });
19568
+ this.prev = () => this.executeQuery({ direction: "prev" });
19569
+ this.nextDebounced = () => {
19570
+ this._executeQueryDebounced({ direction: "next" });
19571
+ };
19572
+ this.prevDebounced = () => {
19573
+ this._executeQueryDebounced({ direction: "prev" });
19574
+ };
19575
+ const { debounceMs, pageSize } = { ...DEFAULT_PAGINATION_OPTIONS, ...options };
19576
+ this.pageSize = pageSize;
19577
+ this.state = new StateStore(this.initialState);
19578
+ this.setDebounceOptions({ debounceMs });
19579
+ }
19580
+ get lastQueryError() {
19581
+ return this.state.getLatestValue().lastQueryError;
19582
+ }
19583
+ get hasNext() {
19584
+ return this.state.getLatestValue().hasNext;
19585
+ }
19586
+ get hasPrev() {
19587
+ return this.state.getLatestValue().hasPrev;
19588
+ }
19589
+ get hasResults() {
19590
+ return Array.isArray(this.state.getLatestValue().items);
19591
+ }
19592
+ get isLoading() {
19593
+ return this.state.getLatestValue().isLoading;
19594
+ }
19595
+ get initialState() {
19596
+ return {
19597
+ hasNext: true,
19598
+ hasPrev: true,
19599
+ //todo: check if optimistic value does not cause problems in UI
19600
+ isLoading: false,
19601
+ items: void 0,
19602
+ lastQueryError: void 0,
19603
+ cursor: void 0,
19604
+ offset: 0
19605
+ };
19606
+ }
19607
+ get items() {
19608
+ return this.state.getLatestValue().items;
19609
+ }
19610
+ get cursor() {
19611
+ return this.state.getLatestValue().cursor;
19612
+ }
19613
+ get offset() {
19614
+ return this.state.getLatestValue().offset;
19615
+ }
19616
+ getStateBeforeFirstQuery() {
19617
+ return {
19618
+ ...this.initialState,
19619
+ isLoading: true
19620
+ };
19621
+ }
19622
+ getStateAfterQuery(stateUpdate, isFirstPage) {
19623
+ const current = this.state.getLatestValue();
19624
+ return {
19625
+ ...current,
19626
+ lastQueryError: void 0,
19627
+ // reset lastQueryError that can be overridden by the stateUpdate
19628
+ ...stateUpdate,
19629
+ isLoading: false,
19630
+ items: isFirstPage ? stateUpdate.items : [...this.items ?? [], ...stateUpdate.items || []]
19631
+ };
19632
+ }
19633
+ async executeQuery({ direction }) {
19634
+ if (!this.canExecuteQuery(direction)) return;
19635
+ const isFirstPage = typeof this.items === "undefined";
19636
+ if (isFirstPage) {
19637
+ this.state.next(this.getStateBeforeFirstQuery());
19638
+ } else {
19639
+ this.state.partialNext({ isLoading: true });
19640
+ }
19641
+ const stateUpdate = {};
19642
+ try {
19643
+ const results = await this.query({ direction });
19644
+ if (!results) return;
19645
+ const { items, next, prev } = results;
19646
+ if (isFirstPage && (next || prev)) {
19647
+ this._isCursorPagination = true;
19648
+ }
19649
+ if (this._isCursorPagination) {
19650
+ stateUpdate.cursor = { next: next || null, prev: prev || null };
19651
+ stateUpdate.hasNext = !!next;
19652
+ stateUpdate.hasPrev = !!prev;
19653
+ } else {
19654
+ stateUpdate.offset = (this.offset ?? 0) + items.length;
19655
+ stateUpdate.hasNext = items.length === this.pageSize;
19656
+ }
19657
+ stateUpdate.items = await this.filterQueryResults(items);
19658
+ } catch (e) {
19659
+ stateUpdate.lastQueryError = e;
19660
+ } finally {
19661
+ this.state.next(this.getStateAfterQuery(stateUpdate, isFirstPage));
19662
+ }
19663
+ }
19664
+ cancelScheduledQuery() {
19665
+ this._executeQueryDebounced.cancel();
19666
+ }
19667
+ resetState() {
19668
+ this.state.next(this.initialState);
19669
+ }
19670
+ };
19671
+
19672
+ // src/pagination/FilterBuilder.ts
19673
+ var FilterBuilder = class {
19674
+ constructor(params) {
19675
+ this.context = new StateStore(params?.initialContext ?? {});
19676
+ this.filterConfig = new StateStore(
19677
+ params?.initialFilterConfig ?? {}
19678
+ );
19679
+ }
19680
+ updateFilterConfig(config) {
19681
+ this.filterConfig.partialNext(config);
19682
+ }
19683
+ enableFilter(filterKey) {
19684
+ const config = this.filterConfig.getLatestValue();
19685
+ if (config[filterKey]) {
19686
+ this.filterConfig.partialNext({
19687
+ [filterKey]: {
19688
+ ...config[filterKey],
19689
+ enabled: true
19690
+ }
19691
+ });
19692
+ }
19693
+ }
19694
+ disableFilter(filterKey) {
19695
+ const config = this.filterConfig.getLatestValue();
19696
+ if (config[filterKey]) {
19697
+ this.filterConfig.partialNext({
19698
+ [filterKey]: {
19699
+ ...config[filterKey],
19700
+ enabled: false
19701
+ }
19702
+ });
19703
+ }
19704
+ }
19705
+ updateContext(newContext) {
19706
+ this.context.partialNext(newContext);
19707
+ }
19708
+ buildFilters(params) {
19709
+ const filters = {
19710
+ ...params?.baseFilters ?? {}
19711
+ };
19712
+ const filterConfig = this.filterConfig.getLatestValue();
19713
+ for (const key in filterConfig) {
19714
+ const configItem = filterConfig[key];
19715
+ if (!configItem?.enabled) continue;
19716
+ const generated = configItem.generate({
19717
+ ...this.context.getLatestValue(),
19718
+ ...params?.context ?? {}
19719
+ });
19720
+ if (generated) Object.assign(filters, generated);
19721
+ }
19722
+ return filters;
19723
+ }
19724
+ };
19725
+
19726
+ // src/pagination/ReminderPaginator.ts
19727
+ var ReminderPaginator = class extends BasePaginator {
19728
+ constructor(client, options) {
19729
+ super(options);
19730
+ this.query = async ({
19731
+ direction
19732
+ }) => {
19733
+ const cursor = this.cursor?.[direction];
19734
+ const {
19735
+ reminders: items,
19736
+ next,
19737
+ prev
19738
+ } = await this.client.queryReminders({
19739
+ filter: this.filters,
19740
+ sort: this.sort,
19741
+ limit: this.pageSize,
19742
+ [direction]: cursor
19743
+ });
19744
+ return { items, next, prev };
19745
+ };
19746
+ this.filterQueryResults = (items) => items;
19747
+ this.client = client;
19748
+ }
19749
+ get filters() {
19750
+ return this._filters;
19751
+ }
19752
+ get sort() {
19753
+ return this._sort;
19754
+ }
19755
+ set filters(filters) {
19756
+ this._filters = filters;
19757
+ this.resetState();
19758
+ }
19759
+ set sort(sort) {
19760
+ this._sort = sort;
19761
+ this.resetState();
19762
+ }
19763
+ };
19764
+
19524
19765
  // src/search/UserSearchSource.ts
19525
19766
  var UserSearchSource = class extends BaseSearchSource {
19526
- constructor(client, options) {
19767
+ constructor(client, options, filterBuilderOptions = {}) {
19527
19768
  super(options);
19528
19769
  this.type = "users";
19529
19770
  this.client = client;
19771
+ this.filterBuilder = new FilterBuilder({
19772
+ initialFilterConfig: {
19773
+ $or: {
19774
+ enabled: true,
19775
+ generate: ({ searchQuery }) => searchQuery ? {
19776
+ $or: [
19777
+ { id: { $autocomplete: searchQuery } },
19778
+ { name: { $autocomplete: searchQuery } }
19779
+ ]
19780
+ } : null
19781
+ }
19782
+ },
19783
+ ...filterBuilderOptions
19784
+ });
19530
19785
  }
19531
19786
  async query(searchQuery) {
19532
- const filters = {
19533
- $or: [
19534
- { id: { $autocomplete: searchQuery } },
19535
- { name: { $autocomplete: searchQuery } }
19536
- ],
19537
- ...this.filters
19538
- };
19787
+ const filters = this.filterBuilder.buildFilters({
19788
+ baseFilters: this.filters,
19789
+ context: { searchQuery }
19790
+ });
19539
19791
  const sort = { id: 1, ...this.sort };
19540
19792
  const options = { ...this.searchOptions, limit: this.pageSize, offset: this.offset };
19541
19793
  const { users } = await this.client.queryUsers(filters, sort, options);
@@ -19548,17 +19800,29 @@ var UserSearchSource = class extends BaseSearchSource {
19548
19800
 
19549
19801
  // src/search/ChannelSearchSource.ts
19550
19802
  var ChannelSearchSource = class extends BaseSearchSource {
19551
- constructor(client, options) {
19803
+ constructor(client, options, filterBuilderOptions = {}) {
19552
19804
  super(options);
19553
19805
  this.type = "channels";
19554
19806
  this.client = client;
19807
+ this.filterBuilder = new FilterBuilder({
19808
+ ...filterBuilderOptions,
19809
+ initialFilterConfig: {
19810
+ name: {
19811
+ enabled: true,
19812
+ generate: ({ searchQuery }) => searchQuery ? { name: { $autocomplete: searchQuery } } : null
19813
+ },
19814
+ ...filterBuilderOptions.initialFilterConfig
19815
+ }
19816
+ });
19555
19817
  }
19556
19818
  async query(searchQuery) {
19557
- const filters = {
19558
- members: { $in: [this.client.userID] },
19559
- name: { $autocomplete: searchQuery },
19560
- ...this.filters
19561
- };
19819
+ const filters = this.filterBuilder.buildFilters({
19820
+ baseFilters: {
19821
+ ...this.client.userID ? { members: { $in: [this.client.userID] } } : {},
19822
+ ...this.filters
19823
+ },
19824
+ context: { searchQuery }
19825
+ });
19562
19826
  const sort = this.sort ?? {};
19563
19827
  const options = { ...this.searchOptions, limit: this.pageSize, offset: this.offset };
19564
19828
  const items = await this.client.queryChannels(filters, sort, options);
@@ -19571,23 +19835,48 @@ var ChannelSearchSource = class extends BaseSearchSource {
19571
19835
 
19572
19836
  // src/search/MessageSearchSource.ts
19573
19837
  var MessageSearchSource = class extends BaseSearchSource {
19574
- constructor(client, options) {
19838
+ constructor(client, options, filterBuilderOptions) {
19575
19839
  super(options);
19576
19840
  this.type = "messages";
19577
19841
  this.client = client;
19842
+ this.messageSearchChannelFilterBuilder = new FilterBuilder(filterBuilderOptions?.messageSearchChannel);
19843
+ this.messageSearchFilterBuilder = new FilterBuilder({
19844
+ ...filterBuilderOptions?.messageSearch,
19845
+ initialFilterConfig: {
19846
+ text: {
19847
+ enabled: true,
19848
+ generate: ({ searchQuery }) => searchQuery ? { text: searchQuery } : null
19849
+ },
19850
+ ...filterBuilderOptions?.messageSearch?.initialFilterConfig
19851
+ }
19852
+ });
19853
+ this.channelQueryFilterBuilder = new FilterBuilder({
19854
+ ...filterBuilderOptions?.channelQuery,
19855
+ initialFilterConfig: {
19856
+ cid: {
19857
+ enabled: true,
19858
+ generate: ({ cids }) => cids ? { cid: { $in: cids } } : null
19859
+ },
19860
+ ...filterBuilderOptions?.channelQuery?.initialFilterConfig
19861
+ }
19862
+ });
19578
19863
  }
19579
19864
  async query(searchQuery) {
19580
- if (!this.client.userID) return { items: [] };
19581
- const channelFilters = {
19582
- members: { $in: [this.client.userID] },
19583
- ...this.messageSearchChannelFilters
19584
- };
19585
- const messageFilters = {
19586
- text: searchQuery,
19587
- type: "regular",
19588
- // FIXME: type: 'reply' resp. do not filter by type and allow to jump to a message in a thread - missing support
19589
- ...this.messageSearchFilters
19590
- };
19865
+ if (!this.client.userID || !searchQuery || this.next === null) return { items: [] };
19866
+ const channelFilters = this.messageSearchChannelFilterBuilder.buildFilters({
19867
+ baseFilters: {
19868
+ ...this.client.userID ? { members: { $in: [this.client.userID] } } : {},
19869
+ ...this.messageSearchChannelFilters
19870
+ },
19871
+ context: { searchQuery }
19872
+ });
19873
+ const messageFilters = this.messageSearchFilterBuilder.buildFilters({
19874
+ baseFilters: {
19875
+ type: "regular",
19876
+ ...this.messageSearchFilters
19877
+ },
19878
+ context: { searchQuery }
19879
+ });
19591
19880
  const sort = {
19592
19881
  created_at: -1,
19593
19882
  ...this.messageSearchSort
@@ -19608,15 +19897,14 @@ var MessageSearchSource = class extends BaseSearchSource {
19608
19897
  if (message.cid && !this.client.activeChannels[message.cid]) acc.add(message.cid);
19609
19898
  return acc;
19610
19899
  }, /* @__PURE__ */ new Set())
19611
- // keep the cids unique
19612
19900
  );
19613
- const allChannelsLoadedLocally = cids.length === 0;
19614
- if (!allChannelsLoadedLocally) {
19901
+ if (cids.length > 0) {
19902
+ const channelQueryFilters = this.channelQueryFilterBuilder.buildFilters({
19903
+ baseFilters: this.channelQueryFilters,
19904
+ context: { cids }
19905
+ });
19615
19906
  await this.client.queryChannels(
19616
- {
19617
- cid: { $in: cids },
19618
- ...this.channelQueryFilters
19619
- },
19907
+ channelQueryFilters,
19620
19908
  {
19621
19909
  last_message_at: -1,
19622
19910
  ...this.channelQuerySort
@@ -23014,6 +23302,15 @@ var Channel = class {
23014
23302
  }
23015
23303
  }
23016
23304
  break;
23305
+ case "user.messages.deleted":
23306
+ if (event.user) {
23307
+ this.state.deleteUserMessages(
23308
+ event.user,
23309
+ !!event.hard_delete,
23310
+ new Date(event.created_at ?? Date.now())
23311
+ );
23312
+ }
23313
+ break;
23017
23314
  case "message.new":
23018
23315
  if (event.message) {
23019
23316
  const ownMessage = event.user?.id === this.getClient().user?.id;
@@ -25920,162 +26217,6 @@ _Reminder.toStateValue = (data) => ({
25920
26217
  });
25921
26218
  var Reminder = _Reminder;
25922
26219
 
25923
- // src/pagination/BasePaginator.ts
25924
- var DEFAULT_PAGINATION_OPTIONS = {
25925
- debounceMs: 300,
25926
- pageSize: 10
25927
- };
25928
- var BasePaginator = class {
25929
- constructor(options) {
25930
- this._isCursorPagination = false;
25931
- this.setDebounceOptions = ({ debounceMs }) => {
25932
- this._executeQueryDebounced = debounce(this.executeQuery.bind(this), debounceMs);
25933
- };
25934
- this.canExecuteQuery = (direction) => !this.isLoading && direction === "next" && this.hasNext || direction === "prev" && this.hasPrev;
25935
- this.next = () => this.executeQuery({ direction: "next" });
25936
- this.prev = () => this.executeQuery({ direction: "prev" });
25937
- this.nextDebounced = () => {
25938
- this._executeQueryDebounced({ direction: "next" });
25939
- };
25940
- this.prevDebounced = () => {
25941
- this._executeQueryDebounced({ direction: "prev" });
25942
- };
25943
- const { debounceMs, pageSize } = { ...DEFAULT_PAGINATION_OPTIONS, ...options };
25944
- this.pageSize = pageSize;
25945
- this.state = new StateStore(this.initialState);
25946
- this.setDebounceOptions({ debounceMs });
25947
- }
25948
- get lastQueryError() {
25949
- return this.state.getLatestValue().lastQueryError;
25950
- }
25951
- get hasNext() {
25952
- return this.state.getLatestValue().hasNext;
25953
- }
25954
- get hasPrev() {
25955
- return this.state.getLatestValue().hasPrev;
25956
- }
25957
- get hasResults() {
25958
- return Array.isArray(this.state.getLatestValue().items);
25959
- }
25960
- get isLoading() {
25961
- return this.state.getLatestValue().isLoading;
25962
- }
25963
- get initialState() {
25964
- return {
25965
- hasNext: true,
25966
- hasPrev: true,
25967
- //todo: check if optimistic value does not cause problems in UI
25968
- isLoading: false,
25969
- items: void 0,
25970
- lastQueryError: void 0,
25971
- cursor: void 0,
25972
- offset: 0
25973
- };
25974
- }
25975
- get items() {
25976
- return this.state.getLatestValue().items;
25977
- }
25978
- get cursor() {
25979
- return this.state.getLatestValue().cursor;
25980
- }
25981
- get offset() {
25982
- return this.state.getLatestValue().offset;
25983
- }
25984
- getStateBeforeFirstQuery() {
25985
- return {
25986
- ...this.initialState,
25987
- isLoading: true
25988
- };
25989
- }
25990
- getStateAfterQuery(stateUpdate, isFirstPage) {
25991
- const current = this.state.getLatestValue();
25992
- return {
25993
- ...current,
25994
- lastQueryError: void 0,
25995
- // reset lastQueryError that can be overridden by the stateUpdate
25996
- ...stateUpdate,
25997
- isLoading: false,
25998
- items: isFirstPage ? stateUpdate.items : [...this.items ?? [], ...stateUpdate.items || []]
25999
- };
26000
- }
26001
- async executeQuery({ direction }) {
26002
- if (!this.canExecuteQuery(direction)) return;
26003
- const isFirstPage = typeof this.items === "undefined";
26004
- if (isFirstPage) {
26005
- this.state.next(this.getStateBeforeFirstQuery());
26006
- } else {
26007
- this.state.partialNext({ isLoading: true });
26008
- }
26009
- const stateUpdate = {};
26010
- try {
26011
- const results = await this.query({ direction });
26012
- if (!results) return;
26013
- const { items, next, prev } = results;
26014
- if (isFirstPage && (next || prev)) {
26015
- this._isCursorPagination = true;
26016
- }
26017
- if (this._isCursorPagination) {
26018
- stateUpdate.cursor = { next: next || null, prev: prev || null };
26019
- stateUpdate.hasNext = !!next;
26020
- stateUpdate.hasPrev = !!prev;
26021
- } else {
26022
- stateUpdate.offset = (this.offset ?? 0) + items.length;
26023
- stateUpdate.hasNext = items.length === this.pageSize;
26024
- }
26025
- stateUpdate.items = await this.filterQueryResults(items);
26026
- } catch (e) {
26027
- stateUpdate.lastQueryError = e;
26028
- } finally {
26029
- this.state.next(this.getStateAfterQuery(stateUpdate, isFirstPage));
26030
- }
26031
- }
26032
- cancelScheduledQuery() {
26033
- this._executeQueryDebounced.cancel();
26034
- }
26035
- resetState() {
26036
- this.state.next(this.initialState);
26037
- }
26038
- };
26039
-
26040
- // src/pagination/ReminderPaginator.ts
26041
- var ReminderPaginator = class extends BasePaginator {
26042
- constructor(client, options) {
26043
- super(options);
26044
- this.query = async ({
26045
- direction
26046
- }) => {
26047
- const cursor = this.cursor?.[direction];
26048
- const {
26049
- reminders: items,
26050
- next,
26051
- prev
26052
- } = await this.client.queryReminders({
26053
- filter: this.filters,
26054
- sort: this.sort,
26055
- limit: this.pageSize,
26056
- [direction]: cursor
26057
- });
26058
- return { items, next, prev };
26059
- };
26060
- this.filterQueryResults = (items) => items;
26061
- this.client = client;
26062
- }
26063
- get filters() {
26064
- return this._filters;
26065
- }
26066
- get sort() {
26067
- return this._sort;
26068
- }
26069
- set filters(filters) {
26070
- this._filters = filters;
26071
- this.resetState();
26072
- }
26073
- set sort(sort) {
26074
- this._sort = sort;
26075
- this.resetState();
26076
- }
26077
- };
26078
-
26079
26220
  // src/reminders/ReminderManager.ts
26080
26221
  var oneMinute2 = 60 * 1e3;
26081
26222
  var oneHour2 = 60 * oneMinute2;
@@ -26638,13 +26779,13 @@ var StreamChat = class _StreamChat {
26638
26779
  * @param {UserResponse} user
26639
26780
  * @param {boolean} hardDelete
26640
26781
  */
26641
- this._deleteUserMessageReference = (user, hardDelete = false) => {
26782
+ this._deleteUserMessageReference = (user, hardDelete = false, deletedAt) => {
26642
26783
  const refMap = this.state.userChannelReferences[user.id] || {};
26643
26784
  for (const channelID in refMap) {
26644
26785
  const channel = this.activeChannels[channelID];
26645
26786
  if (channel) {
26646
26787
  const state = channel.state;
26647
- state?.deleteUserMessages(user, hardDelete);
26788
+ state?.deleteUserMessages(user, hardDelete, deletedAt);
26648
26789
  }
26649
26790
  }
26650
26791
  };
@@ -26690,7 +26831,11 @@ var StreamChat = class _StreamChat {
26690
26831
  this._updateUserMessageReferences(event.user);
26691
26832
  }
26692
26833
  if (event.type === "user.deleted" && event.user.deleted_at && (event.mark_messages_deleted || event.hard_delete)) {
26693
- this._deleteUserMessageReference(event.user, event.hard_delete);
26834
+ this._deleteUserMessageReference(
26835
+ event.user,
26836
+ event.hard_delete,
26837
+ event.user.deleted_at ? new Date(event.user.deleted_at) : null
26838
+ );
26694
26839
  }
26695
26840
  };
26696
26841
  this._callClientListeners = (event) => {
@@ -27260,6 +27405,13 @@ var StreamChat = class _StreamChat {
27260
27405
  if (event.type === "user.presence.changed" || event.type === "user.updated" || event.type === "user.deleted") {
27261
27406
  this._handleUserEvent(event);
27262
27407
  }
27408
+ if (event.type === "user.messages.deleted" && !event.cid && event.user) {
27409
+ this._deleteUserMessageReference(
27410
+ event.user,
27411
+ event.hard_delete,
27412
+ event.created_at ? new Date(event.created_at) : null
27413
+ );
27414
+ }
27263
27415
  if (event.type === "health.check" && event.me) {
27264
27416
  client.user = event.me;
27265
27417
  client.state.updateUser(event.me);
@@ -28520,7 +28672,7 @@ var StreamChat = class _StreamChat {
28520
28672
  if (this.userAgent) {
28521
28673
  return this.userAgent;
28522
28674
  }
28523
- const version = "9.15.0";
28675
+ const version = "9.17.0";
28524
28676
  const clientBundle = "node-cjs";
28525
28677
  let userAgentString = "";
28526
28678
  if (this.sdkIdentifier) {
@@ -29718,6 +29870,7 @@ var EVENT_MAP = {
29718
29870
  "typing.stop": true,
29719
29871
  "user.banned": true,
29720
29872
  "user.deleted": true,
29873
+ "user.messages.deleted": true,
29721
29874
  "user.presence.changed": true,
29722
29875
  "user.unbanned": true,
29723
29876
  "user.unread_message_reminder": true,
@@ -30882,6 +31035,7 @@ var FixedSizeQueueCache = class {
30882
31035
  DevToken,
30883
31036
  EVENT_MAP,
30884
31037
  ErrorFromResponse,
31038
+ FilterBuilder,
30885
31039
  FixedSizeQueueCache,
30886
31040
  InsightMetrics,
30887
31041
  JWTServerToken,