@stream-io/feeds-client 0.1.9 → 0.1.10
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/@react-bindings/hooks/search-state-hooks/index.ts +3 -0
- package/@react-bindings/index.ts +5 -0
- package/CHANGELOG.md +7 -0
- package/dist/@react-bindings/contexts/StreamSearchContext.d.ts +12 -0
- package/dist/@react-bindings/contexts/StreamSearchResultsContext.d.ts +12 -0
- package/dist/@react-bindings/hooks/search-state-hooks/index.d.ts +3 -0
- package/dist/@react-bindings/hooks/search-state-hooks/useSearchQuery.d.ts +4 -0
- package/dist/@react-bindings/hooks/search-state-hooks/useSearchResult.d.ts +8 -0
- package/dist/@react-bindings/hooks/search-state-hooks/useSearchSources.d.ts +4 -0
- package/dist/@react-bindings/index.d.ts +5 -0
- package/dist/@react-bindings/wrappers/StreamSearch.d.ts +12 -0
- package/dist/@react-bindings/wrappers/StreamSearchResults.d.ts +12 -0
- package/dist/index-react-bindings.browser.cjs +85 -16
- package/dist/index-react-bindings.browser.cjs.map +1 -1
- package/dist/index-react-bindings.browser.js +77 -17
- package/dist/index-react-bindings.browser.js.map +1 -1
- package/dist/index-react-bindings.node.cjs +85 -16
- package/dist/index-react-bindings.node.cjs.map +1 -1
- package/dist/index-react-bindings.node.js +77 -17
- package/dist/index-react-bindings.node.js.map +1 -1
- package/dist/index.browser.cjs +26 -125
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +26 -125
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +26 -125
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +26 -125
- package/dist/index.node.js.map +1 -1
- package/dist/src/common/BaseSearchSource.d.ts +3 -1
- package/dist/src/common/FeedSearchSource.d.ts +5 -1
- package/dist/src/common/SearchController.d.ts +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/ActivitySearchSource.ts +5 -15
- package/src/common/BaseSearchSource.ts +9 -9
- package/src/common/FeedSearchSource.ts +20 -65
- package/src/common/SearchController.ts +2 -0
- package/src/common/UserSearchSource.ts +9 -61
package/dist/index.browser.js
CHANGED
|
@@ -5759,6 +5759,7 @@ const FeedOwnCapability = {
|
|
|
5759
5759
|
const DEFAULT_SEARCH_SOURCE_OPTIONS = {
|
|
5760
5760
|
debounceMs: 300,
|
|
5761
5761
|
pageSize: 10,
|
|
5762
|
+
allowEmptySearchString: false,
|
|
5762
5763
|
};
|
|
5763
5764
|
class BaseSearchSource {
|
|
5764
5765
|
constructor(options) {
|
|
@@ -5781,14 +5782,15 @@ class BaseSearchSource {
|
|
|
5781
5782
|
return !!(this.isActive &&
|
|
5782
5783
|
!this.isLoading &&
|
|
5783
5784
|
(this.hasNext || hasNewSearchQuery) &&
|
|
5784
|
-
searchString);
|
|
5785
|
+
(this.allowEmptySearchString || searchString));
|
|
5785
5786
|
};
|
|
5786
5787
|
this.search = (searchQuery) => this.searchDebounced(searchQuery);
|
|
5787
|
-
const { debounceMs, pageSize } = {
|
|
5788
|
+
const { debounceMs, pageSize, allowEmptySearchString } = {
|
|
5788
5789
|
...DEFAULT_SEARCH_SOURCE_OPTIONS,
|
|
5789
5790
|
...options,
|
|
5790
5791
|
};
|
|
5791
5792
|
this.pageSize = pageSize;
|
|
5793
|
+
this.allowEmptySearchString = allowEmptySearchString;
|
|
5792
5794
|
this.state = new StateStore(this.initialState);
|
|
5793
5795
|
this.setDebounceOptions({ debounceMs });
|
|
5794
5796
|
}
|
|
@@ -6004,12 +6006,6 @@ class SearchController {
|
|
|
6004
6006
|
}
|
|
6005
6007
|
|
|
6006
6008
|
class ActivitySearchSource extends BaseSearchSource {
|
|
6007
|
-
// messageSearchChannelFilters: ChannelFilters | undefined;
|
|
6008
|
-
// messageSearchFilters: MessageFilters | undefined;
|
|
6009
|
-
// messageSearchSort: SearchMessageSort | undefined;
|
|
6010
|
-
// channelQueryFilters: ChannelFilters | undefined;
|
|
6011
|
-
// channelQuerySort: ChannelSort | undefined;
|
|
6012
|
-
// channelQueryOptions: Omit<ChannelOptions, 'limit' | 'offset'> | undefined;
|
|
6013
6009
|
constructor(client, options) {
|
|
6014
6010
|
super(options);
|
|
6015
6011
|
this.type = 'activity';
|
|
@@ -6021,7 +6017,9 @@ class ActivitySearchSource extends BaseSearchSource {
|
|
|
6021
6017
|
return { items: [] };
|
|
6022
6018
|
const { activities: items, next } = await this.client.queryActivities({
|
|
6023
6019
|
sort: [{ direction: -1, field: 'created_at' }],
|
|
6024
|
-
|
|
6020
|
+
...(!this.allowEmptySearchString || searchQuery.length > 0
|
|
6021
|
+
? { filter: { text: { $autocomplete: searchQuery } } }
|
|
6022
|
+
: {}),
|
|
6025
6023
|
limit: 10,
|
|
6026
6024
|
next: this.next ?? undefined,
|
|
6027
6025
|
});
|
|
@@ -6031,19 +6029,8 @@ class ActivitySearchSource extends BaseSearchSource {
|
|
|
6031
6029
|
return items;
|
|
6032
6030
|
}
|
|
6033
6031
|
}
|
|
6034
|
-
// filter: {
|
|
6035
|
-
// 'feed.name': { $autocomplete: searchQuery }
|
|
6036
|
-
// 'feed.description': { $autocomplete: searchQuery }
|
|
6037
|
-
// 'created_by.name': { $autocomplete: searchQuery }
|
|
6038
|
-
// },
|
|
6039
6032
|
|
|
6040
6033
|
class UserSearchSource extends BaseSearchSource {
|
|
6041
|
-
// messageSearchChannelFilters: ChannelFilters | undefined;
|
|
6042
|
-
// messageSearchFilters: MessageFilters | undefined;
|
|
6043
|
-
// messageSearchSort: SearchMessageSort | undefined;
|
|
6044
|
-
// channelQueryFilters: ChannelFilters | undefined;
|
|
6045
|
-
// channelQuerySort: ChannelSort | undefined;
|
|
6046
|
-
// channelQueryOptions: Omit<ChannelOptions, 'limit' | 'offset'> | undefined;
|
|
6047
6034
|
constructor(client, options) {
|
|
6048
6035
|
super(options);
|
|
6049
6036
|
this.type = 'user';
|
|
@@ -6053,57 +6040,16 @@ class UserSearchSource extends BaseSearchSource {
|
|
|
6053
6040
|
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
6054
6041
|
if (!connectedUser)
|
|
6055
6042
|
return { items: [] };
|
|
6056
|
-
// const channelFilters: ChannelFilters = {
|
|
6057
|
-
// members: { $in: [this.client.userID] },
|
|
6058
|
-
// ...this.messageSearchChannelFilters,
|
|
6059
|
-
// } as ChannelFilters;
|
|
6060
|
-
// const messageFilters: MessageFilters = {
|
|
6061
|
-
// text: searchQuery,
|
|
6062
|
-
// type: 'regular', // FIXME: type: 'reply' resp. do not filter by type and allow to jump to a message in a thread - missing support
|
|
6063
|
-
// ...this.messageSearchFilters,
|
|
6064
|
-
// } as MessageFilters;
|
|
6065
|
-
// const sort: SearchMessageSort = {
|
|
6066
|
-
// created_at: -1,
|
|
6067
|
-
// ...this.messageSearchSort,
|
|
6068
|
-
// };
|
|
6069
|
-
// const options = {
|
|
6070
|
-
// limit: this.pageSize,
|
|
6071
|
-
// next: this.next,
|
|
6072
|
-
// sort,
|
|
6073
|
-
// } as SearchOptions;
|
|
6074
|
-
// const { next, results } = await this.client.search(
|
|
6075
|
-
// channelFilters,
|
|
6076
|
-
// messageFilters,
|
|
6077
|
-
// options,
|
|
6078
|
-
// );
|
|
6079
|
-
// const items = results.map(({ message }) => message);
|
|
6080
|
-
// const cids = Array.from(
|
|
6081
|
-
// items.reduce((acc, message) => {
|
|
6082
|
-
// if (message.cid && !this.client.activeChannels[message.cid])
|
|
6083
|
-
// acc.add(message.cid);
|
|
6084
|
-
// return acc;
|
|
6085
|
-
// }, new Set<string>()), // keep the cids unique
|
|
6086
|
-
// );
|
|
6087
|
-
// const allChannelsLoadedLocally = cids.length === 0;
|
|
6088
|
-
// if (!allChannelsLoadedLocally) {
|
|
6089
|
-
// await this.client.queryChannels(
|
|
6090
|
-
// {
|
|
6091
|
-
// cid: { $in: cids },
|
|
6092
|
-
// ...this.channelQueryFilters,
|
|
6093
|
-
// } as ChannelFilters,
|
|
6094
|
-
// {
|
|
6095
|
-
// last_message_at: -1,
|
|
6096
|
-
// ...this.channelQuerySort,
|
|
6097
|
-
// },
|
|
6098
|
-
// this.channelQueryOptions,
|
|
6099
|
-
// );
|
|
6100
|
-
// }
|
|
6101
6043
|
const { users: items } = await this.client.queryUsers({
|
|
6102
6044
|
payload: {
|
|
6103
6045
|
filter_conditions: {
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6046
|
+
...(!this.allowEmptySearchString || searchQuery.length > 0
|
|
6047
|
+
? {
|
|
6048
|
+
name: {
|
|
6049
|
+
$autocomplete: searchQuery,
|
|
6050
|
+
},
|
|
6051
|
+
}
|
|
6052
|
+
: {}),
|
|
6107
6053
|
},
|
|
6108
6054
|
},
|
|
6109
6055
|
});
|
|
@@ -6115,75 +6061,30 @@ class UserSearchSource extends BaseSearchSource {
|
|
|
6115
6061
|
}
|
|
6116
6062
|
|
|
6117
6063
|
class FeedSearchSource extends BaseSearchSource {
|
|
6118
|
-
// messageSearchChannelFilters: ChannelFilters | undefined;
|
|
6119
|
-
// messageSearchFilters: MessageFilters | undefined;
|
|
6120
|
-
// messageSearchSort: SearchMessageSort | undefined;
|
|
6121
|
-
// channelQueryFilters: ChannelFilters | undefined;
|
|
6122
|
-
// channelQuerySort: ChannelSort | undefined;
|
|
6123
|
-
// channelQueryOptions: Omit<ChannelOptions, 'limit' | 'offset'> | undefined;
|
|
6124
6064
|
constructor(client, options) {
|
|
6125
6065
|
super(options);
|
|
6126
6066
|
this.type = 'feed';
|
|
6127
6067
|
this.client = client;
|
|
6068
|
+
this.feedGroupId = options?.groupId;
|
|
6128
6069
|
}
|
|
6129
6070
|
async query(searchQuery) {
|
|
6130
6071
|
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
6131
6072
|
if (!connectedUser)
|
|
6132
6073
|
return { items: [] };
|
|
6133
|
-
// const channelFilters: ChannelFilters = {
|
|
6134
|
-
// members: { $in: [this.client.userID] },
|
|
6135
|
-
// ...this.messageSearchChannelFilters,
|
|
6136
|
-
// } as ChannelFilters;
|
|
6137
|
-
// const messageFilters: MessageFilters = {
|
|
6138
|
-
// text: searchQuery,
|
|
6139
|
-
// type: 'regular', // FIXME: type: 'reply' resp. do not filter by type and allow to jump to a message in a thread - missing support
|
|
6140
|
-
// ...this.messageSearchFilters,
|
|
6141
|
-
// } as MessageFilters;
|
|
6142
|
-
// const sort: SearchMessageSort = {
|
|
6143
|
-
// created_at: -1,
|
|
6144
|
-
// ...this.messageSearchSort,
|
|
6145
|
-
// };
|
|
6146
|
-
// const options = {
|
|
6147
|
-
// limit: this.pageSize,
|
|
6148
|
-
// next: this.next,
|
|
6149
|
-
// sort,
|
|
6150
|
-
// } as SearchOptions;
|
|
6151
|
-
// const { next, results } = await this.client.search(
|
|
6152
|
-
// channelFilters,
|
|
6153
|
-
// messageFilters,
|
|
6154
|
-
// options,
|
|
6155
|
-
// );
|
|
6156
|
-
// const items = results.map(({ message }) => message);
|
|
6157
|
-
// const cids = Array.from(
|
|
6158
|
-
// items.reduce((acc, message) => {
|
|
6159
|
-
// if (message.cid && !this.client.activeChannels[message.cid])
|
|
6160
|
-
// acc.add(message.cid);
|
|
6161
|
-
// return acc;
|
|
6162
|
-
// }, new Set<string>()), // keep the cids unique
|
|
6163
|
-
// );
|
|
6164
|
-
// const allChannelsLoadedLocally = cids.length === 0;
|
|
6165
|
-
// if (!allChannelsLoadedLocally) {
|
|
6166
|
-
// await this.client.queryChannels(
|
|
6167
|
-
// {
|
|
6168
|
-
// cid: { $in: cids },
|
|
6169
|
-
// ...this.channelQueryFilters,
|
|
6170
|
-
// } as ChannelFilters,
|
|
6171
|
-
// {
|
|
6172
|
-
// last_message_at: -1,
|
|
6173
|
-
// ...this.channelQuerySort,
|
|
6174
|
-
// },
|
|
6175
|
-
// this.channelQueryOptions,
|
|
6176
|
-
// );
|
|
6177
|
-
// }
|
|
6178
6074
|
const { feeds: items, next } = await this.client.queryFeeds({
|
|
6179
6075
|
filter: {
|
|
6180
|
-
group_id:
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6076
|
+
...(this.feedGroupId ? { group_id: this.feedGroupId } : {}),
|
|
6077
|
+
...(!this.allowEmptySearchString || searchQuery.length > 0
|
|
6078
|
+
? {
|
|
6079
|
+
$or: [
|
|
6080
|
+
{ name: { $autocomplete: searchQuery } },
|
|
6081
|
+
{ description: { $autocomplete: searchQuery } },
|
|
6082
|
+
{ 'created_by.name': { $autocomplete: searchQuery } },
|
|
6083
|
+
],
|
|
6084
|
+
}
|
|
6085
|
+
: {}),
|
|
6186
6086
|
},
|
|
6087
|
+
next: this.next ?? undefined,
|
|
6187
6088
|
});
|
|
6188
6089
|
return { items, next };
|
|
6189
6090
|
}
|