stream-chat 9.45.6 → 9.46.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.
@@ -47,6 +47,7 @@ __export(index_exports, {
47
47
  Channel: () => Channel,
48
48
  ChannelBatchUpdater: () => ChannelBatchUpdater,
49
49
  ChannelManager: () => ChannelManager,
50
+ ChannelMemberSearchSource: () => ChannelMemberSearchSource,
50
51
  ChannelSearchSource: () => ChannelSearchSource,
51
52
  ChannelState: () => ChannelState,
52
53
  CheckSignature: () => CheckSignature,
@@ -4578,110 +4579,6 @@ var BaseSearchSourceSync = class extends BaseSearchSourceBase {
4578
4579
  }
4579
4580
  };
4580
4581
 
4581
- // src/search/SearchController.ts
4582
- var SearchController = class {
4583
- constructor({ config, sources } = {}) {
4584
- this.addSource = (source) => {
4585
- this.state.partialNext({
4586
- sources: [...this.sources, source]
4587
- });
4588
- };
4589
- this.getSource = (sourceType) => this.sources.find((s) => s.type === sourceType);
4590
- this.removeSource = (sourceType) => {
4591
- const newSources = this.sources.filter((s) => s.type !== sourceType);
4592
- if (newSources.length === this.sources.length) return;
4593
- this.state.partialNext({ sources: newSources });
4594
- };
4595
- this.activateSource = (sourceType) => {
4596
- const source = this.getSource(sourceType);
4597
- if (!source || source.isActive) return;
4598
- if (this.config.keepSingleActiveSource) {
4599
- this.sources.forEach((s) => {
4600
- if (s.type !== sourceType) {
4601
- s.deactivate();
4602
- }
4603
- });
4604
- }
4605
- source.activate();
4606
- this.state.partialNext({ sources: [...this.sources] });
4607
- };
4608
- this.deactivateSource = (sourceType) => {
4609
- const source = this.getSource(sourceType);
4610
- if (!source?.isActive) return;
4611
- if (this.activeSources.length === 1) return;
4612
- source.deactivate();
4613
- this.state.partialNext({ sources: [...this.sources] });
4614
- };
4615
- this.activate = () => {
4616
- if (!this.activeSources.length) {
4617
- const sourcesToActivate = this.config.keepSingleActiveSource ? this.sources.slice(0, 1) : this.sources;
4618
- sourcesToActivate.forEach((s) => s.activate());
4619
- }
4620
- if (this.isActive) return;
4621
- this.state.partialNext({ isActive: true });
4622
- };
4623
- this.search = async (searchQuery) => {
4624
- const searchedSources = this.activeSources;
4625
- this.state.partialNext({
4626
- searchQuery
4627
- });
4628
- await Promise.all(searchedSources.map((source) => source.search(searchQuery)));
4629
- };
4630
- this.cancelSearchQueries = () => {
4631
- this.activeSources.forEach((s) => s.cancelScheduledQuery());
4632
- };
4633
- this.clear = () => {
4634
- this.cancelSearchQueries();
4635
- this.sources.forEach(
4636
- (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4637
- );
4638
- this.state.next((current) => ({
4639
- ...current,
4640
- isActive: true,
4641
- queriesInProgress: [],
4642
- searchQuery: ""
4643
- }));
4644
- };
4645
- this.exit = () => {
4646
- this.cancelSearchQueries();
4647
- this.sources.forEach(
4648
- (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4649
- );
4650
- this.state.next((current) => ({
4651
- ...current,
4652
- isActive: false,
4653
- queriesInProgress: [],
4654
- searchQuery: ""
4655
- }));
4656
- };
4657
- this.state = new StateStore({
4658
- isActive: false,
4659
- searchQuery: "",
4660
- sources: sources ?? []
4661
- });
4662
- this._internalState = new StateStore({});
4663
- this.config = { keepSingleActiveSource: true, ...config };
4664
- }
4665
- get hasNext() {
4666
- return this.sources.some((source) => source.hasNext);
4667
- }
4668
- get sources() {
4669
- return this.state.getLatestValue().sources;
4670
- }
4671
- get activeSources() {
4672
- return this.state.getLatestValue().sources.filter((s) => s.isActive);
4673
- }
4674
- get isActive() {
4675
- return this.state.getLatestValue().isActive;
4676
- }
4677
- get searchQuery() {
4678
- return this.state.getLatestValue().searchQuery;
4679
- }
4680
- get searchSourceTypes() {
4681
- return this.sources.map((s) => s.type);
4682
- }
4683
- };
4684
-
4685
4582
  // src/pagination/BasePaginator.ts
4686
4583
  var DEFAULT_PAGINATION_OPTIONS = {
4687
4584
  debounceMs: 300,
@@ -4950,6 +4847,152 @@ var UserGroupPaginator = class extends BasePaginator {
4950
4847
  }
4951
4848
  };
4952
4849
 
4850
+ // src/search/ChannelMemberSearchSource.ts
4851
+ var ChannelMemberSearchSource = class extends BaseSearchSource {
4852
+ constructor(channel, options, filterBuilderOptions = {}) {
4853
+ super(options);
4854
+ this.type = "members";
4855
+ this.canExecuteQuery = (newSearchString) => {
4856
+ const hasNewSearchQuery = typeof newSearchString !== "undefined";
4857
+ return this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery);
4858
+ };
4859
+ this.channel = channel;
4860
+ this.filterBuilder = new FilterBuilder({
4861
+ initialFilterConfig: {
4862
+ default: {
4863
+ enabled: true,
4864
+ generate: ({ searchQuery }) => searchQuery ? {
4865
+ $or: [
4866
+ { name: { $autocomplete: searchQuery } },
4867
+ { id: { $eq: searchQuery } }
4868
+ ]
4869
+ } : null
4870
+ }
4871
+ },
4872
+ ...filterBuilderOptions
4873
+ });
4874
+ }
4875
+ async query(searchQuery) {
4876
+ const filters = this.filterBuilder.buildFilters({
4877
+ baseFilters: this.filters,
4878
+ context: {
4879
+ searchQuery
4880
+ }
4881
+ });
4882
+ const sort = this.sort ?? [];
4883
+ const options = { ...this.searchOptions, limit: this.pageSize, offset: this.offset };
4884
+ const { members } = await this.channel.queryMembers(filters ?? {}, sort, options);
4885
+ return { items: members };
4886
+ }
4887
+ filterQueryResults(items) {
4888
+ return items;
4889
+ }
4890
+ };
4891
+
4892
+ // src/search/SearchController.ts
4893
+ var SearchController = class {
4894
+ constructor({ config, sources } = {}) {
4895
+ this.addSource = (source) => {
4896
+ this.state.partialNext({
4897
+ sources: [...this.sources, source]
4898
+ });
4899
+ };
4900
+ this.getSource = (sourceType) => this.sources.find((s) => s.type === sourceType);
4901
+ this.removeSource = (sourceType) => {
4902
+ const newSources = this.sources.filter((s) => s.type !== sourceType);
4903
+ if (newSources.length === this.sources.length) return;
4904
+ this.state.partialNext({ sources: newSources });
4905
+ };
4906
+ this.activateSource = (sourceType) => {
4907
+ const source = this.getSource(sourceType);
4908
+ if (!source || source.isActive) return;
4909
+ if (this.config.keepSingleActiveSource) {
4910
+ this.sources.forEach((s) => {
4911
+ if (s.type !== sourceType) {
4912
+ s.deactivate();
4913
+ }
4914
+ });
4915
+ }
4916
+ source.activate();
4917
+ this.state.partialNext({ sources: [...this.sources] });
4918
+ };
4919
+ this.deactivateSource = (sourceType) => {
4920
+ const source = this.getSource(sourceType);
4921
+ if (!source?.isActive) return;
4922
+ if (this.activeSources.length === 1) return;
4923
+ source.deactivate();
4924
+ this.state.partialNext({ sources: [...this.sources] });
4925
+ };
4926
+ this.activate = () => {
4927
+ if (!this.activeSources.length) {
4928
+ const sourcesToActivate = this.config.keepSingleActiveSource ? this.sources.slice(0, 1) : this.sources;
4929
+ sourcesToActivate.forEach((s) => s.activate());
4930
+ }
4931
+ if (this.isActive) return;
4932
+ this.state.partialNext({ isActive: true });
4933
+ };
4934
+ this.search = async (searchQuery) => {
4935
+ const searchedSources = this.activeSources;
4936
+ this.state.partialNext({
4937
+ searchQuery
4938
+ });
4939
+ await Promise.all(searchedSources.map((source) => source.search(searchQuery)));
4940
+ };
4941
+ this.cancelSearchQueries = () => {
4942
+ this.activeSources.forEach((s) => s.cancelScheduledQuery());
4943
+ };
4944
+ this.clear = () => {
4945
+ this.cancelSearchQueries();
4946
+ this.sources.forEach(
4947
+ (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4948
+ );
4949
+ this.state.next((current) => ({
4950
+ ...current,
4951
+ isActive: true,
4952
+ queriesInProgress: [],
4953
+ searchQuery: ""
4954
+ }));
4955
+ };
4956
+ this.exit = () => {
4957
+ this.cancelSearchQueries();
4958
+ this.sources.forEach(
4959
+ (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4960
+ );
4961
+ this.state.next((current) => ({
4962
+ ...current,
4963
+ isActive: false,
4964
+ queriesInProgress: [],
4965
+ searchQuery: ""
4966
+ }));
4967
+ };
4968
+ this.state = new StateStore({
4969
+ isActive: false,
4970
+ searchQuery: "",
4971
+ sources: sources ?? []
4972
+ });
4973
+ this._internalState = new StateStore({});
4974
+ this.config = { keepSingleActiveSource: true, ...config };
4975
+ }
4976
+ get hasNext() {
4977
+ return this.sources.some((source) => source.hasNext);
4978
+ }
4979
+ get sources() {
4980
+ return this.state.getLatestValue().sources;
4981
+ }
4982
+ get activeSources() {
4983
+ return this.state.getLatestValue().sources.filter((s) => s.isActive);
4984
+ }
4985
+ get isActive() {
4986
+ return this.state.getLatestValue().isActive;
4987
+ }
4988
+ get searchQuery() {
4989
+ return this.state.getLatestValue().searchQuery;
4990
+ }
4991
+ get searchSourceTypes() {
4992
+ return this.sources.map((s) => s.type);
4993
+ }
4994
+ };
4995
+
4953
4996
  // src/search/UserSearchSource.ts
4954
4997
  var UserSearchSource = class extends BaseSearchSource {
4955
4998
  constructor(client, options, filterBuilderOptions = {}) {
@@ -5056,7 +5099,7 @@ var MessageSearchSource = class extends BaseSearchSource {
5056
5099
  });
5057
5100
  }
5058
5101
  async query(searchQuery) {
5059
- if (!this.client.userID || !searchQuery || this.next === null) return { items: [] };
5102
+ if (!this.client.userID || this.next === null) return { items: [] };
5060
5103
  const channelFilters = this.messageSearchChannelFilterBuilder.buildFilters({
5061
5104
  baseFilters: {
5062
5105
  ...this.client.userID ? { members: { $in: [this.client.userID] } } : {},
@@ -16679,7 +16722,7 @@ var StreamChat = class _StreamChat {
16679
16722
  if (this.userAgent) {
16680
16723
  return this.userAgent;
16681
16724
  }
16682
- const version = "9.45.6";
16725
+ const version = "9.46.0";
16683
16726
  const clientBundle = "node-cjs";
16684
16727
  let userAgentString = "";
16685
16728
  if (this.sdkIdentifier) {
@@ -19296,6 +19339,7 @@ var LiveLocationManager = _LiveLocationManager;
19296
19339
  Channel,
19297
19340
  ChannelBatchUpdater,
19298
19341
  ChannelManager,
19342
+ ChannelMemberSearchSource,
19299
19343
  ChannelSearchSource,
19300
19344
  ChannelState,
19301
19345
  CheckSignature,