@stream-io/feeds-client 1.1.0 → 1.3.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/CHANGELOG.md +19 -0
- package/dist/cjs/index.js +477 -466
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react-bindings.js +454 -449
- package/dist/cjs/react-bindings.js.map +1 -1
- package/dist/es/index.mjs +440 -466
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/react-bindings.mjs +447 -479
- package/dist/es/react-bindings.mjs.map +1 -1
- package/dist/feeds-client-CqD2zQW0.mjs +8791 -0
- package/dist/feeds-client-CqD2zQW0.mjs.map +1 -0
- package/dist/feeds-client-DXci2Pbn.js +8957 -0
- package/dist/feeds-client-DXci2Pbn.js.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/types/common/real-time/StableWSConnection.d.ts +3 -3
- package/dist/types/common/real-time/StableWSConnection.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/notification-feed/handle-notification-feed-updated.d.ts.map +1 -1
- package/dist/types/feed/feed.d.ts +2 -2
- package/dist/types/feed/feed.d.ts.map +1 -1
- package/dist/types/feeds-client/feeds-client.d.ts +3 -2
- package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
- package/dist/types/gen/feeds/FeedsApi.d.ts +4 -1
- package/dist/types/gen/feeds/FeedsApi.d.ts.map +1 -1
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts.map +1 -1
- package/dist/types/gen/models/index.d.ts +63 -1
- package/dist/types/gen/models/index.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/feed/event-handlers/notification-feed/handle-notification-feed-updated.ts +1 -5
- package/src/feed/feed.ts +1 -0
- package/src/feeds-client/feeds-client.ts +104 -45
- package/src/gen/feeds/FeedsApi.ts +26 -0
- package/src/gen/model-decoders/decoders.ts +20 -0
- package/src/gen/model-decoders/event-decoder-mapping.ts +3 -0
- package/src/gen/models/index.ts +105 -1
- package/dist/feeds-client-C1c6lcS3.js +0 -8799
- package/dist/feeds-client-C1c6lcS3.js.map +0 -1
- package/dist/feeds-client-jtUTE4AC.mjs +0 -8783
- package/dist/feeds-client-jtUTE4AC.mjs.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,479 +1,490 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
2
|
+
const require_feeds_client = require("../feeds-client-DXci2Pbn.js");
|
|
3
|
+
let _stream_io_state_store = require("@stream-io/state-store");
|
|
4
|
+
let _stream_io_logger = require("@stream-io/logger");
|
|
5
|
+
//#region src/gen/models/index.ts
|
|
6
|
+
var ChannelOwnCapability = {
|
|
7
|
+
BAN_CHANNEL_MEMBERS: "ban-channel-members",
|
|
8
|
+
CAST_POLL_VOTE: "cast-poll-vote",
|
|
9
|
+
CONNECT_EVENTS: "connect-events",
|
|
10
|
+
CREATE_ATTACHMENT: "create-attachment",
|
|
11
|
+
DELETE_ANY_MESSAGE: "delete-any-message",
|
|
12
|
+
DELETE_CHANNEL: "delete-channel",
|
|
13
|
+
DELETE_OWN_MESSAGE: "delete-own-message",
|
|
14
|
+
DELIVERY_EVENTS: "delivery-events",
|
|
15
|
+
FLAG_MESSAGE: "flag-message",
|
|
16
|
+
FREEZE_CHANNEL: "freeze-channel",
|
|
17
|
+
JOIN_CHANNEL: "join-channel",
|
|
18
|
+
LEAVE_CHANNEL: "leave-channel",
|
|
19
|
+
MUTE_CHANNEL: "mute-channel",
|
|
20
|
+
PIN_MESSAGE: "pin-message",
|
|
21
|
+
QUERY_POLL_VOTES: "query-poll-votes",
|
|
22
|
+
QUOTE_MESSAGE: "quote-message",
|
|
23
|
+
READ_EVENTS: "read-events",
|
|
24
|
+
SEARCH_MESSAGES: "search-messages",
|
|
25
|
+
SEND_CUSTOM_EVENTS: "send-custom-events",
|
|
26
|
+
SEND_LINKS: "send-links",
|
|
27
|
+
SEND_MESSAGE: "send-message",
|
|
28
|
+
SEND_POLL: "send-poll",
|
|
29
|
+
SEND_REACTION: "send-reaction",
|
|
30
|
+
SEND_REPLY: "send-reply",
|
|
31
|
+
SEND_RESTRICTED_VISIBILITY_MESSAGE: "send-restricted-visibility-message",
|
|
32
|
+
SEND_TYPING_EVENTS: "send-typing-events",
|
|
33
|
+
SET_CHANNEL_COOLDOWN: "set-channel-cooldown",
|
|
34
|
+
SHARE_LOCATION: "share-location",
|
|
35
|
+
SKIP_SLOW_MODE: "skip-slow-mode",
|
|
36
|
+
SLOW_MODE: "slow-mode",
|
|
37
|
+
TYPING_EVENTS: "typing-events",
|
|
38
|
+
UPDATE_ANY_MESSAGE: "update-any-message",
|
|
39
|
+
UPDATE_CHANNEL: "update-channel",
|
|
40
|
+
UPDATE_CHANNEL_MEMBERS: "update-channel-members",
|
|
41
|
+
UPDATE_OWN_MESSAGE: "update-own-message",
|
|
42
|
+
UPDATE_THREAD: "update-thread",
|
|
43
|
+
UPLOAD_FILE: "upload-file"
|
|
45
44
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
45
|
+
var FeedOwnCapability = {
|
|
46
|
+
ADD_ACTIVITY: "add-activity",
|
|
47
|
+
ADD_ACTIVITY_BOOKMARK: "add-activity-bookmark",
|
|
48
|
+
ADD_ACTIVITY_REACTION: "add-activity-reaction",
|
|
49
|
+
ADD_COMMENT: "add-comment",
|
|
50
|
+
ADD_COMMENT_REACTION: "add-comment-reaction",
|
|
51
|
+
CREATE_FEED: "create-feed",
|
|
52
|
+
DELETE_ANY_ACTIVITY: "delete-any-activity",
|
|
53
|
+
DELETE_ANY_COMMENT: "delete-any-comment",
|
|
54
|
+
DELETE_FEED: "delete-feed",
|
|
55
|
+
DELETE_OWN_ACTIVITY: "delete-own-activity",
|
|
56
|
+
DELETE_OWN_ACTIVITY_BOOKMARK: "delete-own-activity-bookmark",
|
|
57
|
+
DELETE_OWN_ACTIVITY_REACTION: "delete-own-activity-reaction",
|
|
58
|
+
DELETE_OWN_COMMENT: "delete-own-comment",
|
|
59
|
+
DELETE_OWN_COMMENT_REACTION: "delete-own-comment-reaction",
|
|
60
|
+
FOLLOW: "follow",
|
|
61
|
+
PIN_ACTIVITY: "pin-activity",
|
|
62
|
+
QUERY_FEED_MEMBERS: "query-feed-members",
|
|
63
|
+
QUERY_FOLLOWS: "query-follows",
|
|
64
|
+
READ_ACTIVITIES: "read-activities",
|
|
65
|
+
READ_FEED: "read-feed",
|
|
66
|
+
UNFOLLOW: "unfollow",
|
|
67
|
+
UPDATE_ANY_ACTIVITY: "update-any-activity",
|
|
68
|
+
UPDATE_ANY_COMMENT: "update-any-comment",
|
|
69
|
+
UPDATE_FEED: "update-feed",
|
|
70
|
+
UPDATE_FEED_FOLLOWERS: "update-feed-followers",
|
|
71
|
+
UPDATE_FEED_MEMBERS: "update-feed-members",
|
|
72
|
+
UPDATE_OWN_ACTIVITY: "update-own-activity",
|
|
73
|
+
UPDATE_OWN_ACTIVITY_BOOKMARK: "update-own-activity-bookmark",
|
|
74
|
+
UPDATE_OWN_COMMENT: "update-own-comment"
|
|
76
75
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
get searchQuery() {
|
|
175
|
-
return this.state.getLatestValue().searchQuery;
|
|
176
|
-
}
|
|
177
|
-
get searchSourceTypes() {
|
|
178
|
-
return this.sources.map((s) => s.type);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
const DEFAULT_SEARCH_SOURCE_OPTIONS = {
|
|
182
|
-
debounceMs: 300,
|
|
183
|
-
pageSize: 10,
|
|
184
|
-
allowEmptySearchString: false,
|
|
185
|
-
resetOnNewSearchQuery: true
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/common/search/SearchController.ts
|
|
78
|
+
var SearchController = class {
|
|
79
|
+
constructor({ config, sources } = {}) {
|
|
80
|
+
this.addSource = (source) => {
|
|
81
|
+
this.state.partialNext({ sources: [...this.sources, source] });
|
|
82
|
+
};
|
|
83
|
+
this.getSource = (sourceType) => this.sources.find((s) => s.type === sourceType);
|
|
84
|
+
this.removeSource = (sourceType) => {
|
|
85
|
+
const newSources = this.sources.filter((s) => s.type !== sourceType);
|
|
86
|
+
if (newSources.length === this.sources.length) return;
|
|
87
|
+
this.state.partialNext({ sources: newSources });
|
|
88
|
+
};
|
|
89
|
+
this.activateSource = (sourceType) => {
|
|
90
|
+
const source = this.getSource(sourceType);
|
|
91
|
+
if (!source || source.isActive) return;
|
|
92
|
+
if (this.config.keepSingleActiveSource) this.sources.forEach((s) => {
|
|
93
|
+
if (s.type !== sourceType) s.deactivate();
|
|
94
|
+
});
|
|
95
|
+
source.activate();
|
|
96
|
+
this.state.partialNext({ sources: [...this.sources] });
|
|
97
|
+
};
|
|
98
|
+
this.deactivateSource = (sourceType) => {
|
|
99
|
+
const source = this.getSource(sourceType);
|
|
100
|
+
if (!source?.isActive) return;
|
|
101
|
+
if (this.activeSources.length === 1) return;
|
|
102
|
+
source.deactivate();
|
|
103
|
+
this.state.partialNext({ sources: [...this.sources] });
|
|
104
|
+
};
|
|
105
|
+
this.activate = () => {
|
|
106
|
+
if (!this.activeSources.length) (this.config.keepSingleActiveSource ? this.sources.slice(0, 1) : this.sources).forEach((s) => s.activate());
|
|
107
|
+
if (this.isActive) return;
|
|
108
|
+
this.state.partialNext({ isActive: true });
|
|
109
|
+
};
|
|
110
|
+
this.search = async (searchQuery) => {
|
|
111
|
+
const searchedSources = this.activeSources;
|
|
112
|
+
this.state.partialNext({ searchQuery });
|
|
113
|
+
await Promise.all(searchedSources.map((source) => source.search(searchQuery)));
|
|
114
|
+
};
|
|
115
|
+
this.cancelSearchQueries = () => {
|
|
116
|
+
this.activeSources.forEach((s) => s.cancelScheduledQuery());
|
|
117
|
+
};
|
|
118
|
+
this.clear = () => {
|
|
119
|
+
this.cancelSearchQueries();
|
|
120
|
+
this.sources.forEach((source) => source.state.next({
|
|
121
|
+
...source.initialState,
|
|
122
|
+
isActive: source.isActive
|
|
123
|
+
}));
|
|
124
|
+
this.state.next((current) => ({
|
|
125
|
+
...current,
|
|
126
|
+
isActive: true,
|
|
127
|
+
queriesInProgress: [],
|
|
128
|
+
searchQuery: ""
|
|
129
|
+
}));
|
|
130
|
+
};
|
|
131
|
+
this.exit = () => {
|
|
132
|
+
this.cancelSearchQueries();
|
|
133
|
+
this.sources.forEach((source) => source.state.next({
|
|
134
|
+
...source.initialState,
|
|
135
|
+
isActive: source.isActive
|
|
136
|
+
}));
|
|
137
|
+
this.state.next((current) => ({
|
|
138
|
+
...current,
|
|
139
|
+
isActive: false,
|
|
140
|
+
queriesInProgress: [],
|
|
141
|
+
searchQuery: ""
|
|
142
|
+
}));
|
|
143
|
+
};
|
|
144
|
+
this.state = new _stream_io_state_store.StateStore({
|
|
145
|
+
isActive: false,
|
|
146
|
+
searchQuery: "",
|
|
147
|
+
sources: sources ?? []
|
|
148
|
+
});
|
|
149
|
+
this._internalState = new _stream_io_state_store.StateStore({});
|
|
150
|
+
this.config = {
|
|
151
|
+
keepSingleActiveSource: true,
|
|
152
|
+
...config
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
get hasNext() {
|
|
156
|
+
return this.sources.some((source) => source.hasNext);
|
|
157
|
+
}
|
|
158
|
+
get sources() {
|
|
159
|
+
return this.state.getLatestValue().sources;
|
|
160
|
+
}
|
|
161
|
+
get activeSources() {
|
|
162
|
+
return this.state.getLatestValue().sources.filter((s) => s.isActive);
|
|
163
|
+
}
|
|
164
|
+
get isActive() {
|
|
165
|
+
return this.state.getLatestValue().isActive;
|
|
166
|
+
}
|
|
167
|
+
get searchQuery() {
|
|
168
|
+
return this.state.getLatestValue().searchQuery;
|
|
169
|
+
}
|
|
170
|
+
get searchSourceTypes() {
|
|
171
|
+
return this.sources.map((s) => s.type);
|
|
172
|
+
}
|
|
186
173
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
exports.uniqueArrayMerge = feedsClient.uniqueArrayMerge;
|
|
459
|
-
exports.updateEntityInArray = feedsClient.updateEntityInArray;
|
|
460
|
-
Object.defineProperty(exports, "LogLevelEnum", {
|
|
461
|
-
enumerable: true,
|
|
462
|
-
get: () => loggerInternal.LogLevelEnum
|
|
463
|
-
});
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/common/search/BaseSearchSource.ts
|
|
176
|
+
var DEFAULT_SEARCH_SOURCE_OPTIONS = {
|
|
177
|
+
debounceMs: 300,
|
|
178
|
+
pageSize: 10,
|
|
179
|
+
allowEmptySearchString: false,
|
|
180
|
+
resetOnNewSearchQuery: true
|
|
181
|
+
};
|
|
182
|
+
var BaseSearchSourceBase = class {
|
|
183
|
+
constructor(options) {
|
|
184
|
+
this.activate = () => {
|
|
185
|
+
if (this.isActive) return;
|
|
186
|
+
this.state.partialNext({ isActive: true });
|
|
187
|
+
};
|
|
188
|
+
this.deactivate = () => {
|
|
189
|
+
if (!this.isActive) return;
|
|
190
|
+
this.state.partialNext({ isActive: false });
|
|
191
|
+
};
|
|
192
|
+
this.canExecuteQuery = (newSearchString) => {
|
|
193
|
+
const hasNewSearchQuery = typeof newSearchString !== "undefined";
|
|
194
|
+
const searchString = newSearchString ?? this.searchQuery;
|
|
195
|
+
return !!(this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery) && (this.allowEmptySearchString || searchString));
|
|
196
|
+
};
|
|
197
|
+
const { pageSize, allowEmptySearchString, resetOnNewSearchQuery } = {
|
|
198
|
+
...DEFAULT_SEARCH_SOURCE_OPTIONS,
|
|
199
|
+
...options
|
|
200
|
+
};
|
|
201
|
+
this.pageSize = pageSize;
|
|
202
|
+
this.allowEmptySearchString = allowEmptySearchString;
|
|
203
|
+
this.resetOnNewSearchQuery = resetOnNewSearchQuery;
|
|
204
|
+
this.state = new _stream_io_state_store.StateStore(this.initialState);
|
|
205
|
+
}
|
|
206
|
+
get lastQueryError() {
|
|
207
|
+
return this.state.getLatestValue().lastQueryError;
|
|
208
|
+
}
|
|
209
|
+
get hasNext() {
|
|
210
|
+
return this.state.getLatestValue().hasNext;
|
|
211
|
+
}
|
|
212
|
+
get hasResults() {
|
|
213
|
+
return Array.isArray(this.state.getLatestValue().items);
|
|
214
|
+
}
|
|
215
|
+
get isActive() {
|
|
216
|
+
return this.state.getLatestValue().isActive;
|
|
217
|
+
}
|
|
218
|
+
get isLoading() {
|
|
219
|
+
return this.state.getLatestValue().isLoading;
|
|
220
|
+
}
|
|
221
|
+
get initialState() {
|
|
222
|
+
return {
|
|
223
|
+
hasNext: true,
|
|
224
|
+
isActive: false,
|
|
225
|
+
isLoading: false,
|
|
226
|
+
items: void 0,
|
|
227
|
+
lastQueryError: void 0,
|
|
228
|
+
next: void 0,
|
|
229
|
+
offset: 0,
|
|
230
|
+
searchQuery: ""
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
get items() {
|
|
234
|
+
return this.state.getLatestValue().items;
|
|
235
|
+
}
|
|
236
|
+
get next() {
|
|
237
|
+
return this.state.getLatestValue().next;
|
|
238
|
+
}
|
|
239
|
+
get offset() {
|
|
240
|
+
return this.state.getLatestValue().offset;
|
|
241
|
+
}
|
|
242
|
+
get searchQuery() {
|
|
243
|
+
return this.state.getLatestValue().searchQuery;
|
|
244
|
+
}
|
|
245
|
+
getStateBeforeFirstQuery(newSearchString) {
|
|
246
|
+
const initialState = this.initialState;
|
|
247
|
+
const oldItems = this.items;
|
|
248
|
+
const items = this.resetOnNewSearchQuery ? initialState.items : oldItems;
|
|
249
|
+
return {
|
|
250
|
+
...this.initialState,
|
|
251
|
+
items,
|
|
252
|
+
isActive: this.isActive,
|
|
253
|
+
isLoading: this.resetOnNewSearchQuery ? true : !oldItems,
|
|
254
|
+
searchQuery: newSearchString
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
getStateAfterQuery(stateUpdate, isFirstPage) {
|
|
258
|
+
return {
|
|
259
|
+
...this.state.getLatestValue(),
|
|
260
|
+
lastQueryError: void 0,
|
|
261
|
+
...stateUpdate,
|
|
262
|
+
isLoading: false,
|
|
263
|
+
items: isFirstPage ? stateUpdate.items : [...this.items ?? [], ...stateUpdate.items || []]
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
prepareStateForQuery(newSearchString) {
|
|
267
|
+
const hasNewSearchQuery = typeof newSearchString !== "undefined";
|
|
268
|
+
const searchString = newSearchString ?? this.searchQuery;
|
|
269
|
+
if (hasNewSearchQuery) this.state.next(this.getStateBeforeFirstQuery(newSearchString ?? ""));
|
|
270
|
+
else this.state.partialNext({ isLoading: true });
|
|
271
|
+
return {
|
|
272
|
+
searchString,
|
|
273
|
+
hasNewSearchQuery
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
updatePaginationStateFromQuery(result) {
|
|
277
|
+
const { items, next } = result;
|
|
278
|
+
const stateUpdate = {};
|
|
279
|
+
if (Object.prototype.hasOwnProperty.call(result, "next")) {
|
|
280
|
+
stateUpdate.next = next;
|
|
281
|
+
stateUpdate.hasNext = !!next;
|
|
282
|
+
} else {
|
|
283
|
+
stateUpdate.offset = (this.offset ?? 0) + items.length;
|
|
284
|
+
stateUpdate.hasNext = items.length === this.pageSize;
|
|
285
|
+
}
|
|
286
|
+
return stateUpdate;
|
|
287
|
+
}
|
|
288
|
+
resetState() {
|
|
289
|
+
this.state.next(this.initialState);
|
|
290
|
+
}
|
|
291
|
+
resetStateAndActivate() {
|
|
292
|
+
this.resetState();
|
|
293
|
+
this.activate();
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
var BaseSearchSource = class extends BaseSearchSourceBase {
|
|
297
|
+
constructor(options) {
|
|
298
|
+
const { debounceMs } = {
|
|
299
|
+
...DEFAULT_SEARCH_SOURCE_OPTIONS,
|
|
300
|
+
...options
|
|
301
|
+
};
|
|
302
|
+
super(options);
|
|
303
|
+
this.setDebounceOptions = ({ debounceMs }) => {
|
|
304
|
+
this.searchDebounced = require_feeds_client.debounce(this.executeQuery.bind(this), debounceMs);
|
|
305
|
+
};
|
|
306
|
+
this.search = (searchQuery) => this.searchDebounced(searchQuery);
|
|
307
|
+
this.setDebounceOptions({ debounceMs });
|
|
308
|
+
}
|
|
309
|
+
async executeQuery(newSearchString) {
|
|
310
|
+
if (!this.canExecuteQuery(newSearchString)) return;
|
|
311
|
+
const { hasNewSearchQuery, searchString } = this.prepareStateForQuery(newSearchString);
|
|
312
|
+
let stateUpdate = {};
|
|
313
|
+
try {
|
|
314
|
+
const results = await this.query(searchString);
|
|
315
|
+
if (!results) return;
|
|
316
|
+
const { items } = results;
|
|
317
|
+
stateUpdate = this.updatePaginationStateFromQuery(results);
|
|
318
|
+
stateUpdate.items = await this.filterQueryResults(items);
|
|
319
|
+
} catch (e) {
|
|
320
|
+
stateUpdate.lastQueryError = e;
|
|
321
|
+
} finally {
|
|
322
|
+
this.state.next(this.getStateAfterQuery(stateUpdate, hasNewSearchQuery));
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
cancelScheduledQuery() {
|
|
326
|
+
this.searchDebounced.cancel();
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
var BaseSearchSourceSync = class extends BaseSearchSourceBase {
|
|
330
|
+
constructor(options) {
|
|
331
|
+
const { debounceMs } = {
|
|
332
|
+
...DEFAULT_SEARCH_SOURCE_OPTIONS,
|
|
333
|
+
...options
|
|
334
|
+
};
|
|
335
|
+
super(options);
|
|
336
|
+
this.setDebounceOptions = ({ debounceMs }) => {
|
|
337
|
+
this.searchDebounced = require_feeds_client.debounce(this.executeQuery.bind(this), debounceMs);
|
|
338
|
+
};
|
|
339
|
+
this.search = (searchQuery) => this.searchDebounced(searchQuery);
|
|
340
|
+
this.setDebounceOptions({ debounceMs });
|
|
341
|
+
}
|
|
342
|
+
executeQuery(newSearchString) {
|
|
343
|
+
if (!this.canExecuteQuery(newSearchString)) return;
|
|
344
|
+
const { hasNewSearchQuery, searchString } = this.prepareStateForQuery(newSearchString);
|
|
345
|
+
let stateUpdate = {};
|
|
346
|
+
try {
|
|
347
|
+
const results = this.query(searchString);
|
|
348
|
+
if (!results) return;
|
|
349
|
+
const { items } = results;
|
|
350
|
+
stateUpdate = this.updatePaginationStateFromQuery(results);
|
|
351
|
+
stateUpdate.items = this.filterQueryResults(items);
|
|
352
|
+
} catch (e) {
|
|
353
|
+
stateUpdate.lastQueryError = e;
|
|
354
|
+
} finally {
|
|
355
|
+
this.state.next(this.getStateAfterQuery(stateUpdate, hasNewSearchQuery));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
cancelScheduledQuery() {
|
|
359
|
+
this.searchDebounced.cancel();
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/common/search/ActivitySearchSource.ts
|
|
364
|
+
var ActivitySearchSource = class extends BaseSearchSource {
|
|
365
|
+
constructor(client, options) {
|
|
366
|
+
super(options);
|
|
367
|
+
this.type = "activity";
|
|
368
|
+
this.client = client;
|
|
369
|
+
}
|
|
370
|
+
async query(searchQuery) {
|
|
371
|
+
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
372
|
+
if (!connectedUser) return { items: [] };
|
|
373
|
+
const { activities: items, next } = await this.client.queryActivities({
|
|
374
|
+
sort: [{
|
|
375
|
+
direction: -1,
|
|
376
|
+
field: "created_at"
|
|
377
|
+
}],
|
|
378
|
+
...!this.allowEmptySearchString || searchQuery.length > 0 ? { filter: { text: { $autocomplete: searchQuery } } } : {},
|
|
379
|
+
limit: 10,
|
|
380
|
+
next: this.next ?? void 0
|
|
381
|
+
});
|
|
382
|
+
return {
|
|
383
|
+
items,
|
|
384
|
+
next
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
filterQueryResults(items) {
|
|
388
|
+
return items;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
//#endregion
|
|
392
|
+
//#region src/common/search/FeedSearchSource.ts
|
|
393
|
+
var FeedSearchSource = class extends BaseSearchSource {
|
|
394
|
+
constructor(client, options) {
|
|
395
|
+
super(options);
|
|
396
|
+
this.client = client;
|
|
397
|
+
this.feedGroupId = options?.groupId;
|
|
398
|
+
this.type = `${this.feedGroupId}-feed`;
|
|
399
|
+
}
|
|
400
|
+
async query(searchQuery) {
|
|
401
|
+
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
402
|
+
if (!connectedUser) return { items: [] };
|
|
403
|
+
const { feeds: items, next } = await this.client.queryFeeds({
|
|
404
|
+
filter: {
|
|
405
|
+
...this.feedGroupId ? { group_id: this.feedGroupId } : {},
|
|
406
|
+
...!this.allowEmptySearchString || searchQuery.length > 0 ? { $or: [
|
|
407
|
+
{ name: { $autocomplete: searchQuery } },
|
|
408
|
+
{ description: { $autocomplete: searchQuery } },
|
|
409
|
+
{ "created_by.name": { $autocomplete: searchQuery } }
|
|
410
|
+
] } : {}
|
|
411
|
+
},
|
|
412
|
+
next: this.next ?? void 0
|
|
413
|
+
});
|
|
414
|
+
return {
|
|
415
|
+
items,
|
|
416
|
+
next
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
filterQueryResults(items) {
|
|
420
|
+
return items;
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
//#endregion
|
|
424
|
+
//#region src/common/search/UserSearchSource.ts
|
|
425
|
+
var UserSearchSource = class extends BaseSearchSource {
|
|
426
|
+
constructor(client, options) {
|
|
427
|
+
super(options);
|
|
428
|
+
this.type = "user";
|
|
429
|
+
this.client = client;
|
|
430
|
+
}
|
|
431
|
+
async query(searchQuery) {
|
|
432
|
+
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
433
|
+
if (!connectedUser) return { items: [] };
|
|
434
|
+
const { users: items } = await this.client.queryUsers({ payload: { filter_conditions: { ...!this.allowEmptySearchString || searchQuery.length > 0 ? { name: { $autocomplete: searchQuery } } : {} } } });
|
|
435
|
+
return {
|
|
436
|
+
items,
|
|
437
|
+
next: void 0
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
filterQueryResults(items) {
|
|
441
|
+
return items;
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
//#endregion
|
|
464
445
|
exports.ActivitySearchSource = ActivitySearchSource;
|
|
446
|
+
exports.ActivityWithStateUpdates = require_feeds_client.ActivityWithStateUpdates;
|
|
465
447
|
exports.BaseSearchSource = BaseSearchSource;
|
|
466
448
|
exports.BaseSearchSourceSync = BaseSearchSourceSync;
|
|
467
449
|
exports.ChannelOwnCapability = ChannelOwnCapability;
|
|
450
|
+
exports.Constants = require_feeds_client.Constants;
|
|
451
|
+
exports.Feed = require_feeds_client.Feed;
|
|
468
452
|
exports.FeedOwnCapability = FeedOwnCapability;
|
|
469
453
|
exports.FeedSearchSource = FeedSearchSource;
|
|
454
|
+
exports.FeedsClient = require_feeds_client.FeedsClient;
|
|
455
|
+
Object.defineProperty(exports, "LogLevelEnum", {
|
|
456
|
+
enumerable: true,
|
|
457
|
+
get: function() {
|
|
458
|
+
return _stream_io_logger.LogLevelEnum;
|
|
459
|
+
}
|
|
460
|
+
});
|
|
470
461
|
exports.SearchController = SearchController;
|
|
462
|
+
exports.StreamApiError = require_feeds_client.StreamApiError;
|
|
463
|
+
exports.StreamPoll = require_feeds_client.StreamPoll;
|
|
471
464
|
exports.UserSearchSource = UserSearchSource;
|
|
472
|
-
exports.
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
465
|
+
exports.activityFilter = require_feeds_client.activityFilter;
|
|
466
|
+
exports.checkHasAnotherPage = require_feeds_client.checkHasAnotherPage;
|
|
467
|
+
exports.ensureExhausted = require_feeds_client.ensureExhausted;
|
|
468
|
+
exports.feedsLoggerSystem = require_feeds_client.feedsLoggerSystem;
|
|
469
|
+
exports.getStateUpdateQueueId = require_feeds_client.getStateUpdateQueueId;
|
|
470
|
+
exports.isCommentResponse = require_feeds_client.isCommentResponse;
|
|
471
|
+
exports.isFollowResponse = require_feeds_client.isFollowResponse;
|
|
472
|
+
exports.isImageFile = require_feeds_client.isImageFile;
|
|
473
|
+
exports.isReactionResponse = require_feeds_client.isReactionResponse;
|
|
474
|
+
exports.isVideoFile = require_feeds_client.isVideoFile;
|
|
475
|
+
exports.isVoteAnswer = require_feeds_client.isVoteAnswer;
|
|
476
|
+
exports.ownFeedFields = require_feeds_client.ownFeedFields;
|
|
477
|
+
exports.replaceUniqueArrayMerge = require_feeds_client.replaceUniqueArrayMerge;
|
|
478
|
+
exports.shouldUpdateState = require_feeds_client.shouldUpdateState;
|
|
479
|
+
exports.uniqueArrayMerge = require_feeds_client.uniqueArrayMerge;
|
|
480
|
+
exports.updateEntityInArray = require_feeds_client.updateEntityInArray;
|
|
481
|
+
Object.keys(_stream_io_state_store).forEach(function(k) {
|
|
482
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
483
|
+
enumerable: true,
|
|
484
|
+
get: function() {
|
|
485
|
+
return _stream_io_state_store[k];
|
|
486
|
+
}
|
|
487
|
+
});
|
|
478
488
|
});
|
|
479
|
-
|
|
489
|
+
|
|
490
|
+
//# sourceMappingURL=index.js.map
|