@ewanc26/atproto 0.2.6 → 0.2.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEX,4BAA4B,EAC5B,oBAAoB,EACpB,yBAAyB,EAIzB,QAAQ,EACR,MAAM,YAAY,CAAC;AAiEpB,wBAAsB,iBAAiB,CACtC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC,4BAA4B,CAAC,CAgEvC;AAED,wBAAsB,cAAc,CACnC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC,yBAAyB,CAAC,CA+EpC;AAED,wBAAsB,oBAAoB,CACzC,GAAG,EAAE,MAAM,EACX,KAAK,SAAI,EACT,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAGjC;AAED,wBAAsB,cAAc,CACnC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC;IAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAC,CAiBhC"}
1
+ {"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEX,4BAA4B,EAC5B,oBAAoB,EACpB,yBAAyB,EAIzB,QAAQ,EACR,MAAM,YAAY,CAAC;AAiEpB,wBAAsB,iBAAiB,CACtC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC,4BAA4B,CAAC,CAwDvC;AAED,wBAAsB,cAAc,CACnC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC,yBAAyB,CAAC,CAuEpC;AAED,wBAAsB,oBAAoB,CACzC,GAAG,EAAE,MAAM,EACX,KAAK,SAAI,EACT,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAGjC;AAED,wBAAsB,cAAc,CACnC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC;IAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAC,CAiBhC"}
package/dist/documents.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { cache } from './cache.js';
2
- import { withFallback, resolveIdentity } from './agents.js';
2
+ import { resolveIdentity } from './agents.js';
3
3
  import { buildPdsBlobUrl } from './media.js';
4
+ import { fetchAllRecords } from './pagination/index.js';
4
5
  async function getBlobUrl(did, blob, fetchFn) {
5
6
  try {
6
7
  const cid = blob.ref?.$link || blob.cid;
@@ -34,14 +35,11 @@ export async function fetchPublications(did, fetchFn) {
34
35
  return cached;
35
36
  const publications = [];
36
37
  try {
37
- const publicationsRecords = await withFallback(did, async (agent) => {
38
- const response = await agent.com.atproto.repo.listRecords({
39
- repo: did,
40
- collection: 'site.standard.publication',
41
- limit: 100
42
- });
43
- return response.data.records;
44
- }, true, fetchFn);
38
+ const publicationsRecords = await fetchAllRecords({
39
+ repo: did,
40
+ collection: 'site.standard.publication',
41
+ fetchFn
42
+ });
45
43
  for (const pubRecord of publicationsRecords) {
46
44
  const pubValue = pubRecord.value;
47
45
  const rkey = pubRecord.uri.split('/').pop() || '';
@@ -94,14 +92,11 @@ export async function fetchDocuments(did, fetchFn) {
94
92
  for (const pub of publicationsData.publications) {
95
93
  publicationsMap.set(pub.uri, pub);
96
94
  }
97
- const documentsRecords = await withFallback(did, async (agent) => {
98
- const response = await agent.com.atproto.repo.listRecords({
99
- repo: did,
100
- collection: 'site.standard.document',
101
- limit: 100
102
- });
103
- return response.data.records;
104
- }, true, fetchFn);
95
+ const documentsRecords = await fetchAllRecords({
96
+ repo: did,
97
+ collection: 'site.standard.document',
98
+ fetchFn
99
+ });
105
100
  for (const docRecord of documentsRecords) {
106
101
  const docValue = docRecord.value;
107
102
  const rkey = docRecord.uri.split('/').pop() || '';
package/dist/fetch.d.ts CHANGED
@@ -4,6 +4,6 @@ export declare function fetchSiteInfo(did: string, fetchFn?: typeof fetch): Prom
4
4
  export declare function fetchLinks(did: string, fetchFn?: typeof fetch): Promise<LinkData | null>;
5
5
  export declare function fetchMusicStatus(did: string, fetchFn?: typeof fetch): Promise<MusicStatusData | null>;
6
6
  export declare function fetchKibunStatus(did: string, fetchFn?: typeof fetch): Promise<KibunStatusData | null>;
7
- export declare function fetchLatestPopfeedReview(did: string, fetchFn?: typeof fetch): Promise<PopfeedReview | null>;
7
+ export declare function fetchRecentPopfeedReviews(did: string, limit?: number, fetchFn?: typeof fetch): Promise<PopfeedReview[]>;
8
8
  export declare function fetchTangledRepos(did: string, fetchFn?: typeof fetch): Promise<TangledReposData | null>;
9
9
  //# sourceMappingURL=fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,eAAe,EAEf,gBAAgB,EAChB,aAAa,EAGb,MAAM,YAAY,CAAC;AAEpB,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,CAgD5F;AAED,wBAAsB,aAAa,CAClC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAgC9B;AAED,wBAAsB,UAAU,CAC/B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CA2B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CAkIjC;AAED,wBAAsB,gBAAgB,CACrC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAmCjC;AAED,wBAAsB,yBAAyB,CAC9C,GAAG,EAAE,MAAM,EACX,KAAK,SAAI,EACT,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC,aAAa,EAAE,CAAC,CAgD1B;AAED,wBAAsB,iBAAiB,CACtC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,OAAO,KAAK,GACpB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CA2ClC"}
package/dist/fetch.js CHANGED
@@ -240,8 +240,8 @@ export async function fetchKibunStatus(did, fetchFn) {
240
240
  return null;
241
241
  }
242
242
  }
243
- export async function fetchLatestPopfeedReview(did, fetchFn) {
244
- const cacheKey = `popfeed-review:${did}`;
243
+ export async function fetchRecentPopfeedReviews(did, limit = 5, fetchFn) {
244
+ const cacheKey = `popfeed-reviews:${did}:${limit}`;
245
245
  const cached = cache.get(cacheKey);
246
246
  if (cached)
247
247
  return cached;
@@ -250,36 +250,37 @@ export async function fetchLatestPopfeedReview(did, fetchFn) {
250
250
  const response = await agent.com.atproto.repo.listRecords({
251
251
  repo: did,
252
252
  collection: 'social.popfeed.feed.review',
253
- limit: 1
253
+ limit
254
254
  });
255
255
  return response.data.records;
256
256
  }, true, fetchFn);
257
257
  if (!records?.length)
258
- return null;
259
- const record = records[0];
260
- const value = record.value;
261
- const rkey = record.uri.split('/').pop() ?? record.uri;
262
- const data = {
263
- rkey,
264
- uri: record.uri,
265
- title: value.title,
266
- creativeWorkType: value.creativeWorkType,
267
- rating: value.rating,
268
- text: value.text,
269
- posterUrl: value.posterUrl,
270
- mainCredit: value.mainCredit,
271
- mainCreditRole: value.mainCreditRole,
272
- genres: value.genres,
273
- tags: value.tags,
274
- createdAt: value.createdAt,
275
- containsSpoilers: value.containsSpoilers,
276
- isRevisit: value.isRevisit
277
- };
258
+ return [];
259
+ const data = records.map((record) => {
260
+ const value = record.value;
261
+ const rkey = record.uri.split('/').pop() ?? record.uri;
262
+ return {
263
+ rkey,
264
+ uri: record.uri,
265
+ title: value.title,
266
+ creativeWorkType: value.creativeWorkType,
267
+ rating: value.rating,
268
+ text: value.text,
269
+ posterUrl: value.posterUrl,
270
+ mainCredit: value.mainCredit,
271
+ mainCreditRole: value.mainCreditRole,
272
+ genres: value.genres,
273
+ tags: value.tags,
274
+ createdAt: value.createdAt,
275
+ containsSpoilers: value.containsSpoilers,
276
+ isRevisit: value.isRevisit
277
+ };
278
+ });
278
279
  cache.set(cacheKey, data);
279
280
  return data;
280
281
  }
281
282
  catch {
282
- return null;
283
+ return [];
283
284
  }
284
285
  }
285
286
  export async function fetchTangledRepos(did, fetchFn) {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { PopfeedReview, PopfeedCreativeWorkType, PopfeedMainCreditRole, ProfileData, StatusData, SiteInfoData, LinkData, LinkCard, BlueskyPost, BlogPost, BlogPostsData, PostAuthor, ExternalLink, Facet, Technology, License, BasedOnItem, RelatedService, Repository, Credit, SectionLicense, ResolvedIdentity, CacheEntry, MusicStatusData, MusicArtist, KibunStatusData, TangledRepo, TangledReposData, StandardSitePublication, StandardSitePublicationsData, StandardSiteDocument, StandardSiteDocumentsData, StandardSiteBasicTheme, StandardSiteThemeColor } from './types.js';
2
- export { fetchProfile, fetchSiteInfo, fetchLinks, fetchMusicStatus, fetchKibunStatus, fetchTangledRepos, fetchLatestPopfeedReview } from './fetch.js';
2
+ export { fetchProfile, fetchSiteInfo, fetchLinks, fetchMusicStatus, fetchKibunStatus, fetchTangledRepos, fetchRecentPopfeedReviews } from './fetch.js';
3
3
  export { fetchPublications, fetchDocuments, fetchRecentDocuments, fetchBlogPosts } from './documents.js';
4
4
  export { fetchLatestBlueskyPost, fetchPostFromUri } from './posts.js';
5
5
  export { buildPdsBlobUrl, extractCidFromImageObject, extractImageUrlsFromValue } from './media.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,YAAY,EACX,aAAa,EACb,uBAAuB,EACvB,qBAAqB,EACrB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,aAAa,EACb,UAAU,EACV,YAAY,EACZ,KAAK,EACL,UAAU,EACV,OAAO,EACP,WAAW,EACX,cAAc,EACd,UAAU,EACV,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,4BAA4B,EAC5B,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,YAAY,EACZ,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEnG,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAErJ,OAAO,EACN,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,gCAAgC,EAAE,kBAAkB,EAAE,MAAM,iBAAiB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AO,EACN,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,gCAAgC,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEvF,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // Key API difference from the app's src/lib/services/atproto:
3
3
  // All functions that previously read PUBLIC_ATPROTO_DID from the environment
4
4
  // now accept `did: string` as their first argument.
5
- export { fetchProfile, fetchSiteInfo, fetchLinks, fetchMusicStatus, fetchKibunStatus, fetchTangledRepos, fetchLatestPopfeedReview } from './fetch.js';
5
+ export { fetchProfile, fetchSiteInfo, fetchLinks, fetchMusicStatus, fetchKibunStatus, fetchTangledRepos, fetchRecentPopfeedReviews } from './fetch.js';
6
6
  export { fetchPublications, fetchDocuments, fetchRecentDocuments, fetchBlogPosts } from './documents.js';
7
7
  export { fetchLatestBlueskyPost, fetchPostFromUri } from './posts.js';
8
8
  export { buildPdsBlobUrl, extractCidFromImageObject, extractImageUrlsFromValue } from './media.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ewanc26/atproto",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "AT Protocol service layer extracted from ewancroft.uk",
5
5
  "author": "Ewan Croft",
6
6
  "license": "AGPL-3.0-only",
package/src/documents.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { cache } from './cache.js';
2
2
  import { withFallback, resolveIdentity } from './agents.js';
3
3
  import { buildPdsBlobUrl } from './media.js';
4
+ import { fetchAllRecords } from './pagination/index.js';
4
5
  import type {
5
6
  StandardSitePublication,
6
7
  StandardSitePublicationsData,
@@ -86,19 +87,11 @@ export async function fetchPublications(
86
87
  const publications: StandardSitePublication[] = [];
87
88
 
88
89
  try {
89
- const publicationsRecords = await withFallback(
90
- did,
91
- async (agent) => {
92
- const response = await agent.com.atproto.repo.listRecords({
93
- repo: did,
94
- collection: 'site.standard.publication',
95
- limit: 100
96
- });
97
- return response.data.records;
98
- },
99
- true,
90
+ const publicationsRecords = await fetchAllRecords({
91
+ repo: did,
92
+ collection: 'site.standard.publication',
100
93
  fetchFn
101
- );
94
+ });
102
95
 
103
96
  for (const pubRecord of publicationsRecords) {
104
97
  const pubValue = pubRecord.value as unknown as PublicationRecord;
@@ -161,19 +154,11 @@ export async function fetchDocuments(
161
154
  publicationsMap.set(pub.uri, pub);
162
155
  }
163
156
 
164
- const documentsRecords = await withFallback(
165
- did,
166
- async (agent) => {
167
- const response = await agent.com.atproto.repo.listRecords({
168
- repo: did,
169
- collection: 'site.standard.document',
170
- limit: 100
171
- });
172
- return response.data.records;
173
- },
174
- true,
157
+ const documentsRecords = await fetchAllRecords({
158
+ repo: did,
159
+ collection: 'site.standard.document',
175
160
  fetchFn
176
- );
161
+ });
177
162
 
178
163
  for (const docRecord of documentsRecords) {
179
164
  const docValue = docRecord.value as unknown as DocumentRecord;
package/src/fetch.ts CHANGED
@@ -309,12 +309,13 @@ export async function fetchKibunStatus(
309
309
  }
310
310
  }
311
311
 
312
- export async function fetchLatestPopfeedReview(
312
+ export async function fetchRecentPopfeedReviews(
313
313
  did: string,
314
+ limit = 5,
314
315
  fetchFn?: typeof fetch
315
- ): Promise<PopfeedReview | null> {
316
- const cacheKey = `popfeed-review:${did}`;
317
- const cached = cache.get<PopfeedReview>(cacheKey);
316
+ ): Promise<PopfeedReview[]> {
317
+ const cacheKey = `popfeed-reviews:${did}:${limit}`;
318
+ const cached = cache.get<PopfeedReview[]>(cacheKey);
318
319
  if (cached) return cached;
319
320
 
320
321
  try {
@@ -324,7 +325,7 @@ export async function fetchLatestPopfeedReview(
324
325
  const response = await agent.com.atproto.repo.listRecords({
325
326
  repo: did,
326
327
  collection: 'social.popfeed.feed.review',
327
- limit: 1
328
+ limit
328
329
  });
329
330
  return response.data.records;
330
331
  },
@@ -332,33 +333,33 @@ export async function fetchLatestPopfeedReview(
332
333
  fetchFn
333
334
  );
334
335
 
335
- if (!records?.length) return null;
336
-
337
- const record = records[0];
338
- const value = record.value as any;
339
- const rkey = record.uri.split('/').pop() ?? record.uri;
340
-
341
- const data: PopfeedReview = {
342
- rkey,
343
- uri: record.uri,
344
- title: value.title,
345
- creativeWorkType: value.creativeWorkType as PopfeedCreativeWorkType,
346
- rating: value.rating,
347
- text: value.text,
348
- posterUrl: value.posterUrl,
349
- mainCredit: value.mainCredit,
350
- mainCreditRole: value.mainCreditRole as PopfeedMainCreditRole | undefined,
351
- genres: value.genres,
352
- tags: value.tags,
353
- createdAt: value.createdAt,
354
- containsSpoilers: value.containsSpoilers,
355
- isRevisit: value.isRevisit
356
- };
336
+ if (!records?.length) return [];
337
+
338
+ const data: PopfeedReview[] = records.map((record) => {
339
+ const value = record.value as any;
340
+ const rkey = record.uri.split('/').pop() ?? record.uri;
341
+ return {
342
+ rkey,
343
+ uri: record.uri,
344
+ title: value.title,
345
+ creativeWorkType: value.creativeWorkType as PopfeedCreativeWorkType,
346
+ rating: value.rating,
347
+ text: value.text,
348
+ posterUrl: value.posterUrl,
349
+ mainCredit: value.mainCredit,
350
+ mainCreditRole: value.mainCreditRole as PopfeedMainCreditRole | undefined,
351
+ genres: value.genres,
352
+ tags: value.tags,
353
+ createdAt: value.createdAt,
354
+ containsSpoilers: value.containsSpoilers,
355
+ isRevisit: value.isRevisit
356
+ };
357
+ });
357
358
 
358
359
  cache.set(cacheKey, data);
359
360
  return data;
360
361
  } catch {
361
- return null;
362
+ return [];
362
363
  }
363
364
  }
364
365
 
package/src/index.ts CHANGED
@@ -47,7 +47,7 @@ export {
47
47
  fetchMusicStatus,
48
48
  fetchKibunStatus,
49
49
  fetchTangledRepos,
50
- fetchLatestPopfeedReview
50
+ fetchRecentPopfeedReviews
51
51
  } from './fetch.js';
52
52
 
53
53
  export {