Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"./packages/sqlite",
"./packages/sveltekit",
"./packages/testing",
"./packages/vocab",
"./packages/vocab-runtime",
"./packages/vocab-tools",
"./examples/hono-sample"
Expand Down
63 changes: 58 additions & 5 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions docs/manual/access-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ authorized fetch for the actor dispatcher:

~~~~ typescript{9-11} twoslash
// @noErrors: 2307 2345
import type { Actor, Federation } from "@fedify/fedify";
import type { Federation } from "@fedify/fedify";
import type { Actor } from "@fedify/vocab";
/**
* A hypothetical `Federation` instance.
*/
Expand Down Expand Up @@ -68,7 +69,8 @@ The equivalent method is available for collections as well:

~~~~ typescript{9-11} twoslash
// @noErrors: 2307 2345
import type { Actor, Federation } from "@fedify/fedify";
import type { Federation } from "@fedify/fedify";
import type { Actor } from "@fedify/vocab";
/**
* A hypothetical `Federation` instance.
*/
Expand Down Expand Up @@ -116,7 +118,8 @@ actor). The below pseudo code shows how to filter out private posts:

~~~~ typescript{7} twoslash
// @noErrors: 2307
import type { Actor, Create, Federation } from "@fedify/fedify";
import type { Federation } from "@fedify/fedify";
import type { Actor, Create } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
interface Post {
/**
Expand Down Expand Up @@ -177,7 +180,8 @@ domain name, such as `example.com@example.com`. Here is an example of how to
implement an instance actor:

~~~~ typescript{3-11,20-27} twoslash
import { type Actor, Application, type Federation, Person } from "@fedify/fedify";
import { type Federation } from "@fedify/fedify";
import { type Actor, Application, Person } from "@fedify/vocab";
/**
* A hypothetical `Federation` instance.
*/
Expand Down
12 changes: 8 additions & 4 deletions docs/manual/actor.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const federation = null as unknown as Federation<void>;
interface User { }
const user = null as User | null;
// ---cut-before---
import { createFederation, Person } from "@fedify/fedify";
import { createFederation } from "@fedify/fedify";
import { Person } from "@fedify/vocab";

const federation = createFederation({
// Omitted for brevity; see the related section for details.
Expand Down Expand Up @@ -196,7 +197,8 @@ the URIs of the actor's endpoints. The most important endpoint is the `sharedIn
to generate the URI of the actor's shared inbox:

~~~~ typescript twoslash
import { Endpoints, Context } from "@fedify/fedify";
import { Context } from "@fedify/fedify";
import { Endpoints } from "@fedify/vocab";
const ctx = null as unknown as Context<void>;
// ---cut-before---
new Endpoints({ sharedInbox: ctx.getInboxUri() })
Expand Down Expand Up @@ -245,7 +247,8 @@ the `~ActorCallbackSetters.setKeyPairsDispatcher()` method so that Fedify can
dispatch appropriate key pairs by the actor's identifier:

~~~~ typescript{4-6,10-14,17-26} twoslash
import { type Federation, Person } from "@fedify/fedify";
import { type Federation } from "@fedify/fedify";
import { Person } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
interface User {}
const user = null as User | null;
Expand Down Expand Up @@ -514,7 +517,8 @@ If you want to provide links with other `rel` than
`url` property:

~~~~ typescript{8-16} twoslash
import { type Federation, Person, Link } from "@fedify/fedify";
import { type Federation } from "@fedify/fedify";
import { Link, Person } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
// ---cut-before---
federation
Expand Down
44 changes: 28 additions & 16 deletions docs/manual/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ interface Post {
*/
function getPostsByUserId(userId: string): Post[] { return []; }
// ---cut-before---
import { Article, Create } from "@fedify/fedify";
import { Article, Create } from "@fedify/vocab";

federation
.setOutboxDispatcher("/users/{identifier}/outbox", async (ctx, identifier) => {
Expand Down Expand Up @@ -178,7 +178,8 @@ Here's an example of how to implement collection pages for the outbox collection
with assuming that the database system supports cursor-based pagination:

~~~~ typescript twoslash
import { Article, Create, type Federation } from "@fedify/fedify";
import { type Federation } from "@fedify/fedify";
import { Article, Create } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
/**
* A hypothetical type that represents a post.
Expand Down Expand Up @@ -290,7 +291,8 @@ The value for the first cursor is determined by
`~CollectionCallbackSetters.setFirstCursor()` method:

~~~~ typescript twoslash
import { Article, Create, type Federation } from "@fedify/fedify";
import { type Federation } from "@fedify/fedify";
import { Article, Create } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
/**
* A hypothetical type that represents a post.
Expand Down Expand Up @@ -447,7 +449,8 @@ So, the below example assumes that the database system supports offset-based
pagination, which is easy to implement backward pagination:

~~~~ typescript twoslash
import { Article, Create, type Federation } from "@fedify/fedify";
import { type Federation } from "@fedify/fedify";
import { Article, Create } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
/**
* A hypothetical type that represents a post.
Expand Down Expand Up @@ -610,7 +613,7 @@ async function countInboxByUserId(userId: string): Promise<number> {
return 0;
}
// ---cut-before---
import { Activity } from "@fedify/fedify";
import { Activity } from "@fedify/vocab";

federation
.setInboxDispatcher("/users/{identifier}/inbox", async (ctx, identifier) => {
Expand Down Expand Up @@ -790,7 +793,8 @@ has to consist of `Recipient` objects that represent the actors.
The below example shows how to construct a followers collection:

~~~~ typescript twoslash
import type { Federation, Recipient } from "@fedify/fedify";
import type { Federation } from "@fedify/fedify";
import type { Recipient } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
/**
* A hypothetical type that represents an actor in the database.
Expand Down Expand Up @@ -904,7 +908,8 @@ the `Context.sendActivity()` method, you should return the entire followers
collection when the `cursor` parameter is `null`:

~~~~ typescript{5-17} twoslash
import type { Federation, Recipient } from "@fedify/fedify";
import type { Federation } from "@fedify/fedify";
import type { Recipient } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
/**
* A hypothetical type that represents an actor in the database.
Expand Down Expand Up @@ -1031,7 +1036,8 @@ The following example shows how to filter the followers collection by the
server:

~~~~ typescript{8-11} twoslash
import type { Federation, Recipient } from "@fedify/fedify";
import type { Federation } from "@fedify/fedify";
import type { Recipient } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
/**
* A hypothetical type that represents an actor in the database.
Expand Down Expand Up @@ -1146,7 +1152,7 @@ async function getLikedByUserId(userId: string): Promise<Object[]> {
return [];
}
// ---cut-before---
import type { Object } from "@fedify/fedify";
import type { Object } from "@fedify/vocab";

federation
.setLikedDispatcher("/users/{identifier}/liked", async (ctx, identifier, cursor) => {
Expand All @@ -1171,7 +1177,7 @@ async function getLikedByUserId(userId: string): Promise<Object[]> {
return [];
}
// ---cut-before---
import type { Object } from "@fedify/fedify";
import type { Object } from "@fedify/vocab";

federation
.setLikedDispatcher("/users/{identifier}/liked", async (ctx, identifier, cursor) => {
Expand Down Expand Up @@ -1238,7 +1244,8 @@ as the outbox collection, so we don't repeat the explanation here.
The below example shows how to construct a featured collection:

~~~~ typescript twoslash
import type { Object, Federation } from "@fedify/fedify";
import type { Federation } from "@fedify/fedify";
import type { Object } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
/**
* A hypothetical function that returns the objects that an actor has featured.
Expand Down Expand Up @@ -1312,7 +1319,8 @@ way as the outbox collection, so we don't repeat the explanation here.
The below example shows how to construct a featured tags collection:

~~~~ typescript twoslash
import { Hashtag, type Federation } from "@fedify/fedify";
import { type Federation } from "@fedify/fedify";
import { Hashtag } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
/**
* A hypothetical function that returns the tags that an actor has featured.
Expand Down Expand Up @@ -1401,7 +1409,8 @@ collections. Both methods work similarly to the built-in collection dispatchers.
Here's an example of creating a custom collection of bookmarked posts:

~~~~ typescript twoslash
import { Article, type Federation } from "@fedify/fedify";
import { type Federation } from "@fedify/fedify";
import { Article } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
/**
* A hypothetical type that represents a bookmarked post.
Expand Down Expand Up @@ -1476,7 +1485,8 @@ federation
For ordered collections, simply use `setOrderedCollectionDispatcher()` instead:

~~~~ typescript twoslash
import { Article, type Federation } from "@fedify/fedify";
import { type Federation } from "@fedify/fedify";
import { Article } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
/**
* A hypothetical type that represents a bookmarked post.
Expand Down Expand Up @@ -1560,7 +1570,8 @@ Custom collections support the same callback methods as built-in collections:
Custom collections can have multiple parameters in their URI patterns:

~~~~ typescript twoslash
import { Note, type Federation } from "@fedify/fedify";
import { type Federation } from "@fedify/fedify";
import { Note } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
/**
* A hypothetical function that returns posts by category.
Expand Down Expand Up @@ -1628,7 +1639,8 @@ ctx.getCollectionUri("category-posts", {
You can restrict access to custom collections using the `.authorize()` method:

~~~~ typescript twoslash
import { Article, type Federation } from "@fedify/fedify";
import { type Federation } from "@fedify/fedify";
import { Article } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
/**
* A hypothetical function that checks if a user can access another user's bookmarks.
Expand Down
Loading
Loading