@recursiv/sdk 0.7.20 → 0.7.21
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 +14 -3
- package/dist/resources/protocols.js +23 -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, 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';
|
|
@@ -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;
|
|
@@ -261,7 +268,11 @@ export interface SocialAuthorFeed {
|
|
|
261
268
|
}
|
|
262
269
|
export declare class ProtocolsResource {
|
|
263
270
|
private client;
|
|
271
|
+
private subscriptionListeners;
|
|
264
272
|
constructor(client: HttpClient);
|
|
273
|
+
/** Confirmed changes from this SDK instance only. Unsubscribe when a view unmounts or its account changes. */
|
|
274
|
+
onSubscriptionChange(listener: (change: SocialSubscriptionChange) => void): () => void;
|
|
275
|
+
private subscriptionChanged;
|
|
265
276
|
publicNetworks(): Promise<SingleResponse<SocialNetwork[]>>;
|
|
266
277
|
/** Query the live public network. It does not import users or posts. */
|
|
267
278
|
searchPublicProfiles(params: SearchPublicProfilesParams): Promise<SingleResponse<SocialProfilePage>>;
|
|
@@ -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
|
}
|
|
@@ -61,13 +76,19 @@ export class ProtocolsResource {
|
|
|
61
76
|
}
|
|
62
77
|
/** Save a private reading subscription after resolving the immutable native ID. */
|
|
63
78
|
subscribeToProfile(input) {
|
|
64
|
-
return this.client.post('/protocols/social/subscriptions', input)
|
|
79
|
+
return this.client.post('/protocols/social/subscriptions', input).then(result => {
|
|
80
|
+
this.subscriptionChanged({ type: 'subscribed', subscription: result.data });
|
|
81
|
+
return result;
|
|
82
|
+
});
|
|
65
83
|
}
|
|
66
84
|
unsubscribeFromProfile(id) {
|
|
67
85
|
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
86
|
throw new ValidationError({ type: 'validation_error', code: 'invalid_subscription_id', message: 'A valid subscription ID is required' });
|
|
69
87
|
}
|
|
70
|
-
return this.client.delete(`/protocols/social/subscriptions/${encodeURIComponent(id)}`)
|
|
88
|
+
return this.client.delete(`/protocols/social/subscriptions/${encodeURIComponent(id)}`).then(result => {
|
|
89
|
+
this.subscriptionChanged({ type: 'unsubscribed', id });
|
|
90
|
+
return result;
|
|
91
|
+
});
|
|
71
92
|
}
|
|
72
93
|
/** List adapters with truthful capability, maturity, and limitation metadata. */
|
|
73
94
|
list() {
|