|
| 1 | +<!-- deno-fmt-ignore-file --> |
| 2 | + |
| 3 | +@fedify/backfill: ActivityPub backfill for Fedify |
| 4 | +================================================= |
| 5 | + |
| 6 | +[![JSR][JSR badge]][JSR] |
| 7 | +[![npm][npm badge]][npm] |
| 8 | +[![Follow @fedify@hollo.social][@fedify@hollo.social badge]][@fedify@hollo.social] |
| 9 | + |
| 10 | +*This package is available since Fedify 2.3.0.* |
| 11 | + |
| 12 | +This package provides ActivityPub conversation backfill support for the |
| 13 | +[Fedify] ecosystem. It can retrieve post-like objects from a seed object's |
| 14 | +context collection, following the direct FEP-f228-style path where the |
| 15 | +context dereferences to a `Collection`, `OrderedCollection`, `CollectionPage`, |
| 16 | +or `OrderedCollectionPage`. |
| 17 | + |
| 18 | +[JSR badge]: https://jsr.io/badges/@fedify/backfill |
| 19 | +[JSR]: https://jsr.io/@fedify/backfill |
| 20 | +[npm badge]: https://img.shields.io/npm/v/@fedify/backfill?logo=npm |
| 21 | +[npm]: https://www.npmjs.com/package/@fedify/backfill |
| 22 | +[@fedify@hollo.social badge]: https://fedi-badge.deno.dev/@fedify@hollo.social/followers.svg |
| 23 | +[@fedify@hollo.social]: https://hollo.social/@fedify |
| 24 | +[Fedify]: https://fedify.dev/ |
| 25 | + |
| 26 | + |
| 27 | +Installation |
| 28 | +------------ |
| 29 | + |
| 30 | +~~~~ sh |
| 31 | +deno add jsr:@fedify/backfill |
| 32 | +npm add @fedify/backfill |
| 33 | +pnpm add @fedify/backfill |
| 34 | +yarn add @fedify/backfill |
| 35 | +bun add @fedify/backfill |
| 36 | +~~~~ |
| 37 | + |
| 38 | + |
| 39 | +Usage |
| 40 | +----- |
| 41 | + |
| 42 | +The `backfill()` function accepts a backfill context, a seed object, and |
| 43 | +traversal options: |
| 44 | + |
| 45 | +~~~~ typescript |
| 46 | +import { backfill } from "@fedify/backfill"; |
| 47 | +import { lookupObject } from "@fedify/vocab"; |
| 48 | + |
| 49 | +const documentLoader = (iri: URL, options?: { signal?: AbortSignal }) => |
| 50 | + lookupObject(iri, { signal: options?.signal }); |
| 51 | + |
| 52 | +for await ( |
| 53 | + const item of backfill({ documentLoader }, note, { |
| 54 | + maxItems: 20, |
| 55 | + maxRequests: 50, |
| 56 | + }) |
| 57 | +) { |
| 58 | + console.log(item.id?.href); |
| 59 | +} |
| 60 | +~~~~ |
| 61 | + |
| 62 | +The seed object itself is not yielded. If it appears in the discovered |
| 63 | +collection, it is skipped by ID. |
0 commit comments