@stream-io/feeds-client 0.3.13 → 0.3.15
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 +17 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react-bindings.js +11 -5
- package/dist/cjs/react-bindings.js.map +1 -1
- package/dist/es/index.mjs +2 -2
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/react-bindings.mjs +11 -5
- package/dist/es/react-bindings.mjs.map +1 -1
- package/dist/{feeds-client-B6dsdSNW.mjs → feeds-client-B00fi-i4.mjs} +44 -9
- package/dist/feeds-client-B00fi-i4.mjs.map +1 -0
- package/dist/{feeds-client-DaiBvVCs.js → feeds-client-DTDDoiJL.js} +44 -9
- package/dist/feeds-client-DTDDoiJL.js.map +1 -0
- package/dist/types/bindings/react/hooks/useCreateFeedsClient.d.ts +3 -3
- package/dist/types/bindings/react/hooks/useCreateFeedsClient.d.ts.map +1 -1
- package/dist/types/common/ApiClient.d.ts.map +1 -1
- package/dist/types/common/ConnectionIdManager.d.ts +3 -3
- package/dist/types/common/ConnectionIdManager.d.ts.map +1 -1
- package/dist/types/common/TokenManager.d.ts +3 -3
- package/dist/types/common/TokenManager.d.ts.map +1 -1
- package/dist/types/feeds-client/feeds-client.d.ts +5 -1
- package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
- package/dist/types/gen/feeds/FeedsApi.d.ts.map +1 -1
- package/dist/types/gen/models/index.d.ts +27 -0
- package/dist/types/gen/models/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bindings/react/hooks/useCreateFeedsClient.ts +23 -12
- package/src/common/ApiClient.ts +4 -2
- package/src/common/ConnectionIdManager.ts +9 -7
- package/src/common/TokenManager.ts +19 -3
- package/src/common/real-time/StableWSConnection.ts +1 -1
- package/src/feeds-client/feeds-client.ts +22 -1
- package/src/gen/feeds/FeedsApi.ts +2 -0
- package/src/gen/models/index.ts +50 -0
- package/dist/feeds-client-B6dsdSNW.mjs.map +0 -1
- package/dist/feeds-client-DaiBvVCs.js.map +0 -1
|
@@ -11,6 +11,7 @@ export class TokenManager {
|
|
|
11
11
|
type: 'static' | 'provider';
|
|
12
12
|
token?: string;
|
|
13
13
|
tokenProvider?: string | (() => Promise<string>);
|
|
14
|
+
private _isAnonymous: boolean = false;
|
|
14
15
|
private readonly logger = feedsLoggerSystem.getLogger('token-manager');
|
|
15
16
|
|
|
16
17
|
constructor() {
|
|
@@ -19,15 +20,24 @@ export class TokenManager {
|
|
|
19
20
|
this.type = 'static';
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
get isAnonymous() {
|
|
24
|
+
return this._isAnonymous;
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
/**
|
|
23
28
|
* Set the static string token or token provider.
|
|
24
29
|
* Token provider should return a token string or a promise which resolves to string token.
|
|
25
30
|
*
|
|
26
|
-
* @param {TokenOrProvider} tokenOrProvider - the token or token provider.
|
|
27
|
-
* @param {UserResponse} user - the user object.
|
|
28
|
-
* @param {boolean} isAnonymous - whether the user is anonymous or not.
|
|
31
|
+
* @param {TokenOrProvider} tokenOrProvider - the token or token provider. Providing `undefined` will set the token manager to anonymous mode.
|
|
29
32
|
*/
|
|
30
33
|
setTokenOrProvider = (tokenOrProvider?: string | (() => Promise<string>)) => {
|
|
34
|
+
if (tokenOrProvider === undefined) {
|
|
35
|
+
this._isAnonymous = true;
|
|
36
|
+
tokenOrProvider = '';
|
|
37
|
+
} else {
|
|
38
|
+
this._isAnonymous = false;
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
if (isFunction(tokenOrProvider)) {
|
|
32
42
|
this.tokenProvider = tokenOrProvider;
|
|
33
43
|
this.type = 'provider';
|
|
@@ -44,7 +54,9 @@ export class TokenManager {
|
|
|
44
54
|
* Useful for client disconnection or switching user.
|
|
45
55
|
*/
|
|
46
56
|
reset = () => {
|
|
57
|
+
this._isAnonymous = false;
|
|
47
58
|
this.token = undefined;
|
|
59
|
+
this.tokenProvider = undefined;
|
|
48
60
|
this.loadTokenPromise = null;
|
|
49
61
|
};
|
|
50
62
|
|
|
@@ -96,6 +108,10 @@ export class TokenManager {
|
|
|
96
108
|
|
|
97
109
|
// Returns the current token, or fetches in a new one if there is no current token
|
|
98
110
|
getToken = () => {
|
|
111
|
+
if (this._isAnonymous) {
|
|
112
|
+
return '';
|
|
113
|
+
}
|
|
114
|
+
|
|
99
115
|
if (this.token) {
|
|
100
116
|
return this.token;
|
|
101
117
|
}
|
|
@@ -93,6 +93,7 @@ import { getFeed } from '../activity-with-state-updates/get-feed';
|
|
|
93
93
|
|
|
94
94
|
export type FeedsClientState = {
|
|
95
95
|
connected_user: ConnectedUser | undefined;
|
|
96
|
+
is_anonymous: boolean;
|
|
96
97
|
is_ws_connection_healthy: boolean;
|
|
97
98
|
own_capabilities_by_fid: Record<string, FeedResponse['own_capabilities']>;
|
|
98
99
|
};
|
|
@@ -136,6 +137,7 @@ export class FeedsClient extends FeedsApi {
|
|
|
136
137
|
super(apiClient);
|
|
137
138
|
this.state = new StateStore<FeedsClientState>({
|
|
138
139
|
connected_user: undefined,
|
|
140
|
+
is_anonymous: false,
|
|
139
141
|
is_ws_connection_healthy: false,
|
|
140
142
|
own_capabilities_by_fid: {},
|
|
141
143
|
});
|
|
@@ -391,7 +393,25 @@ export class FeedsClient extends FeedsApi {
|
|
|
391
393
|
this.state.partialNext({ own_capabilities_by_fid: ownCapabilitiesCache });
|
|
392
394
|
}
|
|
393
395
|
|
|
394
|
-
|
|
396
|
+
connectAnonymous = () => {
|
|
397
|
+
this.connectionIdManager.resolveConnectionidPromise();
|
|
398
|
+
this.tokenManager.setTokenOrProvider(undefined);
|
|
399
|
+
this.setGetBatchOwnCapabilitiesThrottlingInterval(
|
|
400
|
+
this.query_batch_own_capabilties_throttling_interval,
|
|
401
|
+
);
|
|
402
|
+
this.state.partialNext({
|
|
403
|
+
connected_user: undefined,
|
|
404
|
+
is_anonymous: true,
|
|
405
|
+
is_ws_connection_healthy: false,
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
return Promise.resolve();
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
connectUser = async (
|
|
412
|
+
user: UserRequest | { id: '!anon' },
|
|
413
|
+
tokenProvider?: TokenOrProvider,
|
|
414
|
+
) => {
|
|
395
415
|
if (
|
|
396
416
|
this.state.getLatestValue().connected_user !== undefined ||
|
|
397
417
|
this.wsConnection
|
|
@@ -631,6 +651,7 @@ export class FeedsClient extends FeedsApi {
|
|
|
631
651
|
await this.wsConnection?.disconnect();
|
|
632
652
|
this.wsConnection = undefined;
|
|
633
653
|
}
|
|
654
|
+
|
|
634
655
|
removeConnectionEventListeners(this.updateNetworkConnectionStatus);
|
|
635
656
|
|
|
636
657
|
this.connectionIdManager.reset();
|
|
@@ -1281,12 +1281,14 @@ export class FeedsApi {
|
|
|
1281
1281
|
feed_id: request?.feed_id,
|
|
1282
1282
|
};
|
|
1283
1283
|
const body = {
|
|
1284
|
+
id_around: request?.id_around,
|
|
1284
1285
|
limit: request?.limit,
|
|
1285
1286
|
next: request?.next,
|
|
1286
1287
|
prev: request?.prev,
|
|
1287
1288
|
view: request?.view,
|
|
1288
1289
|
watch: request?.watch,
|
|
1289
1290
|
data: request?.data,
|
|
1291
|
+
enrichment_options: request?.enrichment_options,
|
|
1290
1292
|
external_ranking: request?.external_ranking,
|
|
1291
1293
|
filter: request?.filter,
|
|
1292
1294
|
followers_pagination: request?.followers_pagination,
|
package/src/gen/models/index.ts
CHANGED
|
@@ -2412,6 +2412,42 @@ export interface EnrichedReaction {
|
|
|
2412
2412
|
user?: Data;
|
|
2413
2413
|
}
|
|
2414
2414
|
|
|
2415
|
+
export interface EnrichmentOptions {
|
|
2416
|
+
skip_activity?: boolean;
|
|
2417
|
+
|
|
2418
|
+
skip_activity_collections?: boolean;
|
|
2419
|
+
|
|
2420
|
+
skip_activity_comments?: boolean;
|
|
2421
|
+
|
|
2422
|
+
skip_activity_current_feed?: boolean;
|
|
2423
|
+
|
|
2424
|
+
skip_activity_mentioned_users?: boolean;
|
|
2425
|
+
|
|
2426
|
+
skip_activity_own_bookmarks?: boolean;
|
|
2427
|
+
|
|
2428
|
+
skip_activity_parents?: boolean;
|
|
2429
|
+
|
|
2430
|
+
skip_activity_poll?: boolean;
|
|
2431
|
+
|
|
2432
|
+
skip_activity_reactions?: boolean;
|
|
2433
|
+
|
|
2434
|
+
skip_activity_refresh_image_urls?: boolean;
|
|
2435
|
+
|
|
2436
|
+
skip_all?: boolean;
|
|
2437
|
+
|
|
2438
|
+
skip_feed_member_user?: boolean;
|
|
2439
|
+
|
|
2440
|
+
skip_followers?: boolean;
|
|
2441
|
+
|
|
2442
|
+
skip_following?: boolean;
|
|
2443
|
+
|
|
2444
|
+
skip_own_capabilities?: boolean;
|
|
2445
|
+
|
|
2446
|
+
skip_own_follows?: boolean;
|
|
2447
|
+
|
|
2448
|
+
skip_pins?: boolean;
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2415
2451
|
export interface EntityCreatorResponse {
|
|
2416
2452
|
ban_count: number;
|
|
2417
2453
|
|
|
@@ -2905,6 +2941,10 @@ export interface FilterConfigResponse {
|
|
|
2905
2941
|
ai_text_labels?: string[];
|
|
2906
2942
|
}
|
|
2907
2943
|
|
|
2944
|
+
export interface FlagCountRuleParameters {
|
|
2945
|
+
threshold?: number;
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2908
2948
|
export interface FlagRequest {
|
|
2909
2949
|
entity_id: string;
|
|
2910
2950
|
|
|
@@ -3208,6 +3248,8 @@ export interface GetOGResponse {
|
|
|
3208
3248
|
}
|
|
3209
3249
|
|
|
3210
3250
|
export interface GetOrCreateFeedRequest {
|
|
3251
|
+
id_around?: string;
|
|
3252
|
+
|
|
3211
3253
|
limit?: number;
|
|
3212
3254
|
|
|
3213
3255
|
next?: string;
|
|
@@ -3220,6 +3262,8 @@ export interface GetOrCreateFeedRequest {
|
|
|
3220
3262
|
|
|
3221
3263
|
data?: FeedInput;
|
|
3222
3264
|
|
|
3265
|
+
enrichment_options?: EnrichmentOptions;
|
|
3266
|
+
|
|
3223
3267
|
external_ranking?: Record<string, any>;
|
|
3224
3268
|
|
|
3225
3269
|
filter?: Record<string, any>;
|
|
@@ -3924,6 +3968,8 @@ export interface NotificationTrigger {
|
|
|
3924
3968
|
text: string;
|
|
3925
3969
|
|
|
3926
3970
|
type: string;
|
|
3971
|
+
|
|
3972
|
+
comment?: NotificationComment;
|
|
3927
3973
|
}
|
|
3928
3974
|
|
|
3929
3975
|
export interface OCRRule {
|
|
@@ -5023,6 +5069,8 @@ export interface RuleBuilderCondition {
|
|
|
5023
5069
|
|
|
5024
5070
|
content_count_rule_params?: ContentCountRuleParameters;
|
|
5025
5071
|
|
|
5072
|
+
content_flag_count_rule_params?: FlagCountRuleParameters;
|
|
5073
|
+
|
|
5026
5074
|
image_content_params?: ImageContentParameters;
|
|
5027
5075
|
|
|
5028
5076
|
image_rule_params?: ImageRuleParameters;
|
|
@@ -5035,6 +5083,8 @@ export interface RuleBuilderCondition {
|
|
|
5035
5083
|
|
|
5036
5084
|
user_custom_property_params?: UserCustomPropertyParameters;
|
|
5037
5085
|
|
|
5086
|
+
user_flag_count_rule_params?: FlagCountRuleParameters;
|
|
5087
|
+
|
|
5038
5088
|
user_rule_params?: UserRuleParameters;
|
|
5039
5089
|
|
|
5040
5090
|
video_content_params?: VideoContentParameters;
|