stream-chat 9.45.6 → 9.47.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.js +163 -119
- package/dist/cjs/index.browser.js.map +3 -3
- package/dist/cjs/index.node.js +160 -118
- package/dist/cjs/index.node.js.map +3 -3
- package/dist/esm/index.mjs +163 -119
- package/dist/esm/index.mjs.map +3 -3
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +1 -1
- package/dist/types/search/ChannelMemberSearchSource.d.ts +24 -0
- package/dist/types/search/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/messageComposer/middleware/textComposer/mentions.ts +14 -13
- package/src/search/ChannelMemberSearchSource.ts +85 -0
- package/src/search/MessageSearchSource.ts +1 -1
- package/src/search/index.ts +1 -0
package/dist/cjs/index.node.js
CHANGED
|
@@ -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,
|
|
@@ -175,6 +176,7 @@ __export(index_exports, {
|
|
|
175
176
|
extractPollEnrichedData: () => extractPollEnrichedData,
|
|
176
177
|
formatMessage: () => formatMessage,
|
|
177
178
|
generateFileName: () => generateFileName,
|
|
179
|
+
getAllowedMentionTypesFromCapabilities: () => getAllowedMentionTypesFromCapabilities,
|
|
178
180
|
getAttachmentTypeFromMimeType: () => getAttachmentTypeFromMimeType,
|
|
179
181
|
getCommandByName: () => getCommandByName,
|
|
180
182
|
getCompleteCommandInString: () => getCompleteCommandInString,
|
|
@@ -4578,110 +4580,6 @@ var BaseSearchSourceSync = class extends BaseSearchSourceBase {
|
|
|
4578
4580
|
}
|
|
4579
4581
|
};
|
|
4580
4582
|
|
|
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
4583
|
// src/pagination/BasePaginator.ts
|
|
4686
4584
|
var DEFAULT_PAGINATION_OPTIONS = {
|
|
4687
4585
|
debounceMs: 300,
|
|
@@ -4950,6 +4848,152 @@ var UserGroupPaginator = class extends BasePaginator {
|
|
|
4950
4848
|
}
|
|
4951
4849
|
};
|
|
4952
4850
|
|
|
4851
|
+
// src/search/ChannelMemberSearchSource.ts
|
|
4852
|
+
var ChannelMemberSearchSource = class extends BaseSearchSource {
|
|
4853
|
+
constructor(channel, options, filterBuilderOptions = {}) {
|
|
4854
|
+
super(options);
|
|
4855
|
+
this.type = "members";
|
|
4856
|
+
this.canExecuteQuery = (newSearchString) => {
|
|
4857
|
+
const hasNewSearchQuery = typeof newSearchString !== "undefined";
|
|
4858
|
+
return this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery);
|
|
4859
|
+
};
|
|
4860
|
+
this.channel = channel;
|
|
4861
|
+
this.filterBuilder = new FilterBuilder({
|
|
4862
|
+
initialFilterConfig: {
|
|
4863
|
+
default: {
|
|
4864
|
+
enabled: true,
|
|
4865
|
+
generate: ({ searchQuery }) => searchQuery ? {
|
|
4866
|
+
$or: [
|
|
4867
|
+
{ name: { $autocomplete: searchQuery } },
|
|
4868
|
+
{ id: { $eq: searchQuery } }
|
|
4869
|
+
]
|
|
4870
|
+
} : null
|
|
4871
|
+
}
|
|
4872
|
+
},
|
|
4873
|
+
...filterBuilderOptions
|
|
4874
|
+
});
|
|
4875
|
+
}
|
|
4876
|
+
async query(searchQuery) {
|
|
4877
|
+
const filters = this.filterBuilder.buildFilters({
|
|
4878
|
+
baseFilters: this.filters,
|
|
4879
|
+
context: {
|
|
4880
|
+
searchQuery
|
|
4881
|
+
}
|
|
4882
|
+
});
|
|
4883
|
+
const sort = this.sort ?? [];
|
|
4884
|
+
const options = { ...this.searchOptions, limit: this.pageSize, offset: this.offset };
|
|
4885
|
+
const { members } = await this.channel.queryMembers(filters ?? {}, sort, options);
|
|
4886
|
+
return { items: members };
|
|
4887
|
+
}
|
|
4888
|
+
filterQueryResults(items) {
|
|
4889
|
+
return items;
|
|
4890
|
+
}
|
|
4891
|
+
};
|
|
4892
|
+
|
|
4893
|
+
// src/search/SearchController.ts
|
|
4894
|
+
var SearchController = class {
|
|
4895
|
+
constructor({ config, sources } = {}) {
|
|
4896
|
+
this.addSource = (source) => {
|
|
4897
|
+
this.state.partialNext({
|
|
4898
|
+
sources: [...this.sources, source]
|
|
4899
|
+
});
|
|
4900
|
+
};
|
|
4901
|
+
this.getSource = (sourceType) => this.sources.find((s) => s.type === sourceType);
|
|
4902
|
+
this.removeSource = (sourceType) => {
|
|
4903
|
+
const newSources = this.sources.filter((s) => s.type !== sourceType);
|
|
4904
|
+
if (newSources.length === this.sources.length) return;
|
|
4905
|
+
this.state.partialNext({ sources: newSources });
|
|
4906
|
+
};
|
|
4907
|
+
this.activateSource = (sourceType) => {
|
|
4908
|
+
const source = this.getSource(sourceType);
|
|
4909
|
+
if (!source || source.isActive) return;
|
|
4910
|
+
if (this.config.keepSingleActiveSource) {
|
|
4911
|
+
this.sources.forEach((s) => {
|
|
4912
|
+
if (s.type !== sourceType) {
|
|
4913
|
+
s.deactivate();
|
|
4914
|
+
}
|
|
4915
|
+
});
|
|
4916
|
+
}
|
|
4917
|
+
source.activate();
|
|
4918
|
+
this.state.partialNext({ sources: [...this.sources] });
|
|
4919
|
+
};
|
|
4920
|
+
this.deactivateSource = (sourceType) => {
|
|
4921
|
+
const source = this.getSource(sourceType);
|
|
4922
|
+
if (!source?.isActive) return;
|
|
4923
|
+
if (this.activeSources.length === 1) return;
|
|
4924
|
+
source.deactivate();
|
|
4925
|
+
this.state.partialNext({ sources: [...this.sources] });
|
|
4926
|
+
};
|
|
4927
|
+
this.activate = () => {
|
|
4928
|
+
if (!this.activeSources.length) {
|
|
4929
|
+
const sourcesToActivate = this.config.keepSingleActiveSource ? this.sources.slice(0, 1) : this.sources;
|
|
4930
|
+
sourcesToActivate.forEach((s) => s.activate());
|
|
4931
|
+
}
|
|
4932
|
+
if (this.isActive) return;
|
|
4933
|
+
this.state.partialNext({ isActive: true });
|
|
4934
|
+
};
|
|
4935
|
+
this.search = async (searchQuery) => {
|
|
4936
|
+
const searchedSources = this.activeSources;
|
|
4937
|
+
this.state.partialNext({
|
|
4938
|
+
searchQuery
|
|
4939
|
+
});
|
|
4940
|
+
await Promise.all(searchedSources.map((source) => source.search(searchQuery)));
|
|
4941
|
+
};
|
|
4942
|
+
this.cancelSearchQueries = () => {
|
|
4943
|
+
this.activeSources.forEach((s) => s.cancelScheduledQuery());
|
|
4944
|
+
};
|
|
4945
|
+
this.clear = () => {
|
|
4946
|
+
this.cancelSearchQueries();
|
|
4947
|
+
this.sources.forEach(
|
|
4948
|
+
(source) => source.state.next({ ...source.initialState, isActive: source.isActive })
|
|
4949
|
+
);
|
|
4950
|
+
this.state.next((current) => ({
|
|
4951
|
+
...current,
|
|
4952
|
+
isActive: true,
|
|
4953
|
+
queriesInProgress: [],
|
|
4954
|
+
searchQuery: ""
|
|
4955
|
+
}));
|
|
4956
|
+
};
|
|
4957
|
+
this.exit = () => {
|
|
4958
|
+
this.cancelSearchQueries();
|
|
4959
|
+
this.sources.forEach(
|
|
4960
|
+
(source) => source.state.next({ ...source.initialState, isActive: source.isActive })
|
|
4961
|
+
);
|
|
4962
|
+
this.state.next((current) => ({
|
|
4963
|
+
...current,
|
|
4964
|
+
isActive: false,
|
|
4965
|
+
queriesInProgress: [],
|
|
4966
|
+
searchQuery: ""
|
|
4967
|
+
}));
|
|
4968
|
+
};
|
|
4969
|
+
this.state = new StateStore({
|
|
4970
|
+
isActive: false,
|
|
4971
|
+
searchQuery: "",
|
|
4972
|
+
sources: sources ?? []
|
|
4973
|
+
});
|
|
4974
|
+
this._internalState = new StateStore({});
|
|
4975
|
+
this.config = { keepSingleActiveSource: true, ...config };
|
|
4976
|
+
}
|
|
4977
|
+
get hasNext() {
|
|
4978
|
+
return this.sources.some((source) => source.hasNext);
|
|
4979
|
+
}
|
|
4980
|
+
get sources() {
|
|
4981
|
+
return this.state.getLatestValue().sources;
|
|
4982
|
+
}
|
|
4983
|
+
get activeSources() {
|
|
4984
|
+
return this.state.getLatestValue().sources.filter((s) => s.isActive);
|
|
4985
|
+
}
|
|
4986
|
+
get isActive() {
|
|
4987
|
+
return this.state.getLatestValue().isActive;
|
|
4988
|
+
}
|
|
4989
|
+
get searchQuery() {
|
|
4990
|
+
return this.state.getLatestValue().searchQuery;
|
|
4991
|
+
}
|
|
4992
|
+
get searchSourceTypes() {
|
|
4993
|
+
return this.sources.map((s) => s.type);
|
|
4994
|
+
}
|
|
4995
|
+
};
|
|
4996
|
+
|
|
4953
4997
|
// src/search/UserSearchSource.ts
|
|
4954
4998
|
var UserSearchSource = class extends BaseSearchSource {
|
|
4955
4999
|
constructor(client, options, filterBuilderOptions = {}) {
|
|
@@ -5056,7 +5100,7 @@ var MessageSearchSource = class extends BaseSearchSource {
|
|
|
5056
5100
|
});
|
|
5057
5101
|
}
|
|
5058
5102
|
async query(searchQuery) {
|
|
5059
|
-
if (!this.client.userID ||
|
|
5103
|
+
if (!this.client.userID || this.next === null) return { items: [] };
|
|
5060
5104
|
const channelFilters = this.messageSearchChannelFilterBuilder.buildFilters({
|
|
5061
5105
|
baseFilters: {
|
|
5062
5106
|
...this.client.userID ? { members: { $in: [this.client.userID] } } : {},
|
|
@@ -6261,13 +6305,14 @@ var calculateLevenshtein = (query, name) => {
|
|
|
6261
6305
|
}
|
|
6262
6306
|
return matrix[name.length][query.length];
|
|
6263
6307
|
};
|
|
6264
|
-
var
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6308
|
+
var hasOwnCapability = (ownCapabilities, capability) => ownCapabilities?.includes(capability) ?? false;
|
|
6309
|
+
var getAllowedMentionTypesFromCapabilities = (ownCapabilities) => ({
|
|
6310
|
+
channel: hasOwnCapability(ownCapabilities, "notify-channel"),
|
|
6311
|
+
here: hasOwnCapability(ownCapabilities, "notify-here"),
|
|
6312
|
+
role: hasOwnCapability(ownCapabilities, "notify-role"),
|
|
6268
6313
|
user: true,
|
|
6269
|
-
user_group:
|
|
6270
|
-
};
|
|
6314
|
+
user_group: hasOwnCapability(ownCapabilities, "notify-group")
|
|
6315
|
+
});
|
|
6271
6316
|
var decodeUserGroupCursor = (cursor) => {
|
|
6272
6317
|
if (!cursor) return void 0;
|
|
6273
6318
|
try {
|
|
@@ -6393,7 +6438,6 @@ var DEFAULT_SUGGESTION_FACTORY_MAPPERS = {
|
|
|
6393
6438
|
var MentionsSearchSource = class extends BaseSearchSource {
|
|
6394
6439
|
constructor(channel, options) {
|
|
6395
6440
|
const {
|
|
6396
|
-
allowedMentionTypes,
|
|
6397
6441
|
mentionAllAppUsers,
|
|
6398
6442
|
suggestionFactoryMappers,
|
|
6399
6443
|
textComposerText,
|
|
@@ -6425,7 +6469,7 @@ var MentionsSearchSource = class extends BaseSearchSource {
|
|
|
6425
6469
|
const finalQueryWord = normalizedQueryWords[normalizedQueryWords.length - 1];
|
|
6426
6470
|
return fullMatchWords.every((queryWord) => normalizedValueWords.includes(queryWord)) && normalizedValueWords.some((valueWord) => valueWord.startsWith(finalQueryWord));
|
|
6427
6471
|
};
|
|
6428
|
-
this.isMentionTypeAllowed = (mentionType) => this.
|
|
6472
|
+
this.isMentionTypeAllowed = (mentionType) => getAllowedMentionTypesFromCapabilities(this.channel.data?.own_capabilities)[mentionType];
|
|
6429
6473
|
this.mapMentionSuggestion = (mentionType, value, searchToken = this.searchQuery) => {
|
|
6430
6474
|
const mapper = this.config.suggestionFactoryMappers?.[mentionType] ?? DEFAULT_SUGGESTION_FACTORY_MAPPERS[mentionType];
|
|
6431
6475
|
return mapper(value, {
|
|
@@ -6609,10 +6653,6 @@ var MentionsSearchSource = class extends BaseSearchSource {
|
|
|
6609
6653
|
this.client = channel.getClient();
|
|
6610
6654
|
this.channel = channel;
|
|
6611
6655
|
this.config = {
|
|
6612
|
-
allowedMentionTypes: {
|
|
6613
|
-
...DEFAULT_ALLOWED_MENTION_TYPES,
|
|
6614
|
-
...allowedMentionTypes
|
|
6615
|
-
},
|
|
6616
6656
|
mentionAllAppUsers,
|
|
6617
6657
|
suggestionFactoryMappers,
|
|
6618
6658
|
textComposerText,
|
|
@@ -16679,7 +16719,7 @@ var StreamChat = class _StreamChat {
|
|
|
16679
16719
|
if (this.userAgent) {
|
|
16680
16720
|
return this.userAgent;
|
|
16681
16721
|
}
|
|
16682
|
-
const version = "9.
|
|
16722
|
+
const version = "9.47.0";
|
|
16683
16723
|
const clientBundle = "node-cjs";
|
|
16684
16724
|
let userAgentString = "";
|
|
16685
16725
|
if (this.sdkIdentifier) {
|
|
@@ -19296,6 +19336,7 @@ var LiveLocationManager = _LiveLocationManager;
|
|
|
19296
19336
|
Channel,
|
|
19297
19337
|
ChannelBatchUpdater,
|
|
19298
19338
|
ChannelManager,
|
|
19339
|
+
ChannelMemberSearchSource,
|
|
19299
19340
|
ChannelSearchSource,
|
|
19300
19341
|
ChannelState,
|
|
19301
19342
|
CheckSignature,
|
|
@@ -19424,6 +19465,7 @@ var LiveLocationManager = _LiveLocationManager;
|
|
|
19424
19465
|
extractPollEnrichedData,
|
|
19425
19466
|
formatMessage,
|
|
19426
19467
|
generateFileName,
|
|
19468
|
+
getAllowedMentionTypesFromCapabilities,
|
|
19427
19469
|
getAttachmentTypeFromMimeType,
|
|
19428
19470
|
getCommandByName,
|
|
19429
19471
|
getCompleteCommandInString,
|