Skip to content

Commit 1a0b46d

Browse files
authored
Merge pull request #779 from sij411/feat/backfill
Add initial backfill package
2 parents 8db5848 + 5d2a8ed commit 1a0b46d

12 files changed

Lines changed: 952 additions & 0 deletions

File tree

deno.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"workspace": [
33
"./packages/amqp",
44
"./packages/astro",
5+
"./packages/backfill",
56
"./packages/cfworkers",
67
"./packages/cli",
78
"./packages/debugger",

packages/backfill/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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.

packages/backfill/deno.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "@fedify/backfill",
3+
"version": "2.3.0",
4+
"license": "MIT",
5+
"exports": {
6+
".": "./src/mod.ts"
7+
},
8+
"exclude": [
9+
"dist/",
10+
"node_modules/"
11+
],
12+
"publish": {
13+
"exclude": [
14+
"**/*.test.ts",
15+
"tsdown.config.ts"
16+
]
17+
},
18+
"tasks": {
19+
"check": "deno fmt --check && deno lint && deno check src/**/*.ts",
20+
"test": "deno test"
21+
}
22+
}

packages/backfill/package.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"name": "@fedify/backfill",
3+
"version": "2.3.0",
4+
"description": "ActivityPub backfill support for Fedify",
5+
"keywords": [
6+
"Fedify",
7+
"ActivityPub",
8+
"Fediverse",
9+
"Backfill"
10+
],
11+
"author": {
12+
"name": "Jiwon Kwon",
13+
"email": "work@kwonjiwon.org"
14+
},
15+
"homepage": "https://fedify.dev/",
16+
"repository": {
17+
"type": "git",
18+
"url": "git+https://github.com/fedify-dev/fedify.git",
19+
"directory": "packages/backfill"
20+
},
21+
"license": "MIT",
22+
"bugs": {
23+
"url": "https://github.com/fedify-dev/fedify/issues"
24+
},
25+
"funding": [
26+
"https://opencollective.com/fedify",
27+
"https://github.com/sponsors/dahlia"
28+
],
29+
"type": "module",
30+
"main": "./dist/mod.cjs",
31+
"module": "./dist/mod.js",
32+
"types": "./dist/mod.d.ts",
33+
"exports": {
34+
".": {
35+
"types": {
36+
"import": "./dist/mod.d.ts",
37+
"require": "./dist/mod.d.cts",
38+
"default": "./dist/mod.d.ts"
39+
},
40+
"import": "./dist/mod.js",
41+
"require": "./dist/mod.cjs",
42+
"default": "./dist/mod.js"
43+
},
44+
"./package.json": "./package.json"
45+
},
46+
"files": [
47+
"dist/",
48+
"package.json",
49+
"README.md"
50+
],
51+
"dependencies": {
52+
"@fedify/vocab": "workspace:*"
53+
},
54+
"devDependencies": {
55+
"tsdown": "catalog:",
56+
"typescript": "catalog:"
57+
},
58+
"scripts": {
59+
"build:self": "tsdown",
60+
"build": "pnpm --filter @fedify/backfill... run build:self",
61+
"prepack": "pnpm build",
62+
"prepublish": "pnpm build",
63+
"pretest": "pnpm build",
64+
"test": "cd dist/ && node --test",
65+
"pretest:bun": "pnpm build",
66+
"test:bun": "cd dist/ && bun test --timeout 60000"
67+
}
68+
}

0 commit comments

Comments
 (0)