@recursiv/sdk 0.7.19 → 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 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, 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';
@@ -192,6 +192,18 @@ export interface PublishHostedPostInput extends PreviewHostedPostInput {
192
192
  /** Explicitly publish the previewed text publicly in this app. */
193
193
  publishPublicly: true;
194
194
  }
195
+ /** Installed on-demand reading clients, their source coverage and supported UI. */
196
+ export interface SocialNetwork {
197
+ protocol: string;
198
+ name: string;
199
+ provider: {
200
+ name: string;
201
+ url: string;
202
+ };
203
+ coverage: string;
204
+ capabilities: Array<'profile_search' | 'profile_read' | 'original_author_posts' | 'minds_subscription'>;
205
+ profileSearchPagination: boolean;
206
+ }
195
207
  /** Public source identity, independent of any local Minds user or handle. */
196
208
  export interface SocialProfile {
197
209
  protocol: string;
@@ -214,6 +226,13 @@ export interface SocialSubscription {
214
226
  kind: 'minds_feed';
215
227
  createdAt: string;
216
228
  }
229
+ export type SocialSubscriptionChange = {
230
+ type: 'subscribed';
231
+ subscription: SocialSubscription;
232
+ } | {
233
+ type: 'unsubscribed';
234
+ id: string;
235
+ };
217
236
  export interface SearchPublicProfilesParams {
218
237
  protocol: string;
219
238
  query: string;
@@ -232,9 +251,9 @@ export interface SocialPost {
232
251
  author: Omit<SocialProfile, 'subscription'>;
233
252
  text: string;
234
253
  createdAt: string;
235
- replyCount: number;
236
- likeCount: number;
237
- repostCount: number;
254
+ replyCount: number | null;
255
+ likeCount: number | null;
256
+ repostCount: number | null;
238
257
  media: Array<{
239
258
  type: 'image';
240
259
  url: string;
@@ -249,7 +268,12 @@ export interface SocialAuthorFeed {
249
268
  }
250
269
  export declare class ProtocolsResource {
251
270
  private client;
271
+ private subscriptionListeners;
252
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;
276
+ publicNetworks(): Promise<SingleResponse<SocialNetwork[]>>;
253
277
  /** Query the live public network. It does not import users or posts. */
254
278
  searchPublicProfiles(params: SearchPublicProfilesParams): Promise<SingleResponse<SocialProfilePage>>;
255
279
  getPublicProfile(protocol: string, actor: string): Promise<SingleResponse<SocialProfile>>;
@@ -36,9 +36,27 @@ 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
+ }
57
+ publicNetworks() {
58
+ return this.client.get('/protocols/social/networks');
59
+ }
42
60
  /** Query the live public network. It does not import users or posts. */
43
61
  searchPublicProfiles(params) {
44
62
  return this.client.get('/protocols/social/profiles', {
@@ -58,13 +76,19 @@ export class ProtocolsResource {
58
76
  }
59
77
  /** Save a private reading subscription after resolving the immutable native ID. */
60
78
  subscribeToProfile(input) {
61
- 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
+ });
62
83
  }
63
84
  unsubscribeFromProfile(id) {
64
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)) {
65
86
  throw new ValidationError({ type: 'validation_error', code: 'invalid_subscription_id', message: 'A valid subscription ID is required' });
66
87
  }
67
- 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
+ });
68
92
  }
69
93
  /** List adapters with truthful capability, maturity, and limitation metadata. */
70
94
  list() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recursiv/sdk",
3
- "version": "0.7.19",
3
+ "version": "0.7.21",
4
4
  "description": "TypeScript SDK for the Recursiv API",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "type": "module",