@recursiv/sdk 0.7.20 → 0.7.22
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/index.d.ts +1 -1
- package/dist/resources/protocols.d.ts +37 -4
- package/dist/resources/protocols.js +27 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -189,7 +189,7 @@ export type { UploadMediaInput, UploadUrlInput, UploadUrlResult } from './resour
|
|
|
189
189
|
export { WalletResource } from './resources/wallet.js';
|
|
190
190
|
export { ProtocolsResource } from './resources/protocols.js';
|
|
191
191
|
export { PROTOCOL_ADAPTER_MATURITIES, PROTOCOL_CAPABILITY_OPERATIONS, PROTOCOL_CAPABILITY_STATUSES, } from './resources/protocols.js';
|
|
192
|
-
export type { SocialProfile, SocialSubscription, SocialProfilePage, SocialNetwork, SocialPost, SocialAuthorFeed, SearchPublicProfilesParams, HostedProtocolConnections, HostedProtocol, HostedProtocolIdentity, HostedNostrChallenge, HostedNostrIdentityProof, HostedPostPreview, ConnectHostedIdentityInput, PreviewHostedPostInput, PublishHostedPostInput, ListProtocolCandidatesParams, ProtocolAdapterMaturity, ProtocolAdapterMetadata, ProtocolCandidateListResponse, ProtocolCandidatePageMeta, ProtocolCapabilityOperation, ProtocolCapabilityStatus, ProtocolCollectionStatus, ProtocolQuarantinedCandidate, ProtocolRefreshResult, ProtocolSettings, ProtocolSettingsUpdateResult, UpdateSettingsInput as UpdateProtocolSettingsInput, } from './resources/protocols.js';
|
|
192
|
+
export type { SocialProfile, SocialSubscription, SocialSubscriptionChange, SocialProfilePage, SocialNetwork, SocialPost, SocialAuthorFeed, SocialFollowingFeed, SocialFollowingSource, SearchPublicProfilesParams, HostedProtocolConnections, HostedProtocol, HostedProtocolIdentity, HostedNostrChallenge, HostedNostrIdentityProof, HostedPostPreview, ConnectHostedIdentityInput, PreviewHostedPostInput, PublishHostedPostInput, ListProtocolCandidatesParams, ProtocolAdapterMaturity, ProtocolAdapterMetadata, ProtocolCandidateListResponse, ProtocolCandidatePageMeta, ProtocolCapabilityOperation, ProtocolCapabilityStatus, ProtocolCollectionStatus, ProtocolQuarantinedCandidate, ProtocolRefreshResult, ProtocolSettings, ProtocolSettingsUpdateResult, UpdateSettingsInput as UpdateProtocolSettingsInput, } from './resources/protocols.js';
|
|
193
193
|
export { InboxResource } from './resources/inbox.js';
|
|
194
194
|
export { NetworkResource } from './resources/network.js';
|
|
195
195
|
export { SimulatorResource } from './resources/simulator.js';
|
|
@@ -201,7 +201,7 @@ export interface SocialNetwork {
|
|
|
201
201
|
url: string;
|
|
202
202
|
};
|
|
203
203
|
coverage: string;
|
|
204
|
-
capabilities: Array<'profile_search' | 'profile_read' | 'original_author_posts' | 'minds_subscription'>;
|
|
204
|
+
capabilities: Array<'profile_search' | 'profile_read' | 'original_author_posts' | 'minds_subscription' | 'following_feed'>;
|
|
205
205
|
profileSearchPagination: boolean;
|
|
206
206
|
}
|
|
207
207
|
/** Public source identity, independent of any local Minds user or handle. */
|
|
@@ -226,6 +226,13 @@ export interface SocialSubscription {
|
|
|
226
226
|
kind: 'minds_feed';
|
|
227
227
|
createdAt: string;
|
|
228
228
|
}
|
|
229
|
+
export type SocialSubscriptionChange = {
|
|
230
|
+
type: 'subscribed';
|
|
231
|
+
subscription: SocialSubscription;
|
|
232
|
+
} | {
|
|
233
|
+
type: 'unsubscribed';
|
|
234
|
+
id: string;
|
|
235
|
+
};
|
|
229
236
|
export interface SearchPublicProfilesParams {
|
|
230
237
|
protocol: string;
|
|
231
238
|
query: string;
|
|
@@ -244,9 +251,9 @@ export interface SocialPost {
|
|
|
244
251
|
author: Omit<SocialProfile, 'subscription'>;
|
|
245
252
|
text: string;
|
|
246
253
|
createdAt: string;
|
|
247
|
-
replyCount: number;
|
|
248
|
-
likeCount: number;
|
|
249
|
-
repostCount: number;
|
|
254
|
+
replyCount: number | null;
|
|
255
|
+
likeCount: number | null;
|
|
256
|
+
repostCount: number | null;
|
|
250
257
|
media: Array<{
|
|
251
258
|
type: 'image';
|
|
252
259
|
url: string;
|
|
@@ -259,9 +266,30 @@ export interface SocialAuthorFeed {
|
|
|
259
266
|
cursor: string | null;
|
|
260
267
|
coverage: 'original_posts';
|
|
261
268
|
}
|
|
269
|
+
export interface SocialFollowingSource {
|
|
270
|
+
subscriptionId: string;
|
|
271
|
+
protocol: string;
|
|
272
|
+
nativeId: string;
|
|
273
|
+
status: 'ok' | 'unavailable' | 'rate_limited' | 'unsupported_protocol';
|
|
274
|
+
moreAvailable: boolean | null;
|
|
275
|
+
}
|
|
276
|
+
/** A bounded batch of recent author windows. Continue the cursor to read more followed accounts. */
|
|
277
|
+
export interface SocialFollowingFeed {
|
|
278
|
+
items: SocialPost[];
|
|
279
|
+
cursor: string | null;
|
|
280
|
+
sources: SocialFollowingSource[];
|
|
281
|
+
accountsRead: number;
|
|
282
|
+
totalAccounts: number;
|
|
283
|
+
postsPerAccount: number;
|
|
284
|
+
coverage: 'recent_original_posts';
|
|
285
|
+
}
|
|
262
286
|
export declare class ProtocolsResource {
|
|
263
287
|
private client;
|
|
288
|
+
private subscriptionListeners;
|
|
264
289
|
constructor(client: HttpClient);
|
|
290
|
+
/** Confirmed changes from this SDK instance only. Unsubscribe when a view unmounts or its account changes. */
|
|
291
|
+
onSubscriptionChange(listener: (change: SocialSubscriptionChange) => void): () => void;
|
|
292
|
+
private subscriptionChanged;
|
|
265
293
|
publicNetworks(): Promise<SingleResponse<SocialNetwork[]>>;
|
|
266
294
|
/** Query the live public network. It does not import users or posts. */
|
|
267
295
|
searchPublicProfiles(params: SearchPublicProfilesParams): Promise<SingleResponse<SocialProfilePage>>;
|
|
@@ -273,6 +301,11 @@ export declare class ProtocolsResource {
|
|
|
273
301
|
cursor?: string;
|
|
274
302
|
}): Promise<SingleResponse<SocialAuthorFeed>>;
|
|
275
303
|
listSubscriptions(): Promise<SingleResponse<SocialSubscription[]>>;
|
|
304
|
+
/** Recent originals from the current app user's followed accounts, with explicit source failures. */
|
|
305
|
+
getFollowingFeed(params?: {
|
|
306
|
+
protocol?: string;
|
|
307
|
+
cursor?: string;
|
|
308
|
+
}): Promise<SingleResponse<SocialFollowingFeed>>;
|
|
276
309
|
/** Save a private reading subscription after resolving the immutable native ID. */
|
|
277
310
|
subscribeToProfile(input: {
|
|
278
311
|
protocol: string;
|
|
@@ -36,9 +36,24 @@ function hostedIdentityPath(id) {
|
|
|
36
36
|
}
|
|
37
37
|
export class ProtocolsResource {
|
|
38
38
|
client;
|
|
39
|
+
subscriptionListeners = new Set();
|
|
39
40
|
constructor(client) {
|
|
40
41
|
this.client = client;
|
|
41
42
|
}
|
|
43
|
+
/** Confirmed changes from this SDK instance only. Unsubscribe when a view unmounts or its account changes. */
|
|
44
|
+
onSubscriptionChange(listener) {
|
|
45
|
+
this.subscriptionListeners.add(listener);
|
|
46
|
+
return () => { this.subscriptionListeners.delete(listener); };
|
|
47
|
+
}
|
|
48
|
+
subscriptionChanged(change) {
|
|
49
|
+
for (const listener of [...this.subscriptionListeners]) {
|
|
50
|
+
// A view failure must not turn a confirmed server write into a failed mutation.
|
|
51
|
+
try {
|
|
52
|
+
listener(change);
|
|
53
|
+
}
|
|
54
|
+
catch { /* Other mounted views still receive the change. */ }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
42
57
|
publicNetworks() {
|
|
43
58
|
return this.client.get('/protocols/social/networks');
|
|
44
59
|
}
|
|
@@ -59,15 +74,25 @@ export class ProtocolsResource {
|
|
|
59
74
|
listSubscriptions() {
|
|
60
75
|
return this.client.get('/protocols/social/subscriptions');
|
|
61
76
|
}
|
|
77
|
+
/** Recent originals from the current app user's followed accounts, with explicit source failures. */
|
|
78
|
+
getFollowingFeed(params = {}) {
|
|
79
|
+
return this.client.get('/protocols/social/following-feed', { protocol: params.protocol, cursor: params.cursor });
|
|
80
|
+
}
|
|
62
81
|
/** Save a private reading subscription after resolving the immutable native ID. */
|
|
63
82
|
subscribeToProfile(input) {
|
|
64
|
-
return this.client.post('/protocols/social/subscriptions', input)
|
|
83
|
+
return this.client.post('/protocols/social/subscriptions', input).then(result => {
|
|
84
|
+
this.subscriptionChanged({ type: 'subscribed', subscription: result.data });
|
|
85
|
+
return result;
|
|
86
|
+
});
|
|
65
87
|
}
|
|
66
88
|
unsubscribeFromProfile(id) {
|
|
67
89
|
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id)) {
|
|
68
90
|
throw new ValidationError({ type: 'validation_error', code: 'invalid_subscription_id', message: 'A valid subscription ID is required' });
|
|
69
91
|
}
|
|
70
|
-
return this.client.delete(`/protocols/social/subscriptions/${encodeURIComponent(id)}`)
|
|
92
|
+
return this.client.delete(`/protocols/social/subscriptions/${encodeURIComponent(id)}`).then(result => {
|
|
93
|
+
this.subscriptionChanged({ type: 'unsubscribed', id });
|
|
94
|
+
return result;
|
|
95
|
+
});
|
|
71
96
|
}
|
|
72
97
|
/** List adapters with truthful capability, maturity, and limitation metadata. */
|
|
73
98
|
list() {
|