Unverified Commit 166a8e4d authored by Hong Minhee's avatar Hong Minhee
Browse files
parent 28b78a8c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -21,6 +21,10 @@ To be released.
     -  Added `{ type: "liked"; handle: string }` case to `ParseUriResult` type.
     -  Renamed `linked` property (which was a typo) to `liked` in
        `Application`, `Group`, `Organization`, `Person`, and `Service` classes.
     -  Added `Federation.setFeaturedDispatcher()` method.
     -  Added `Context.getFeaturedUri()` method.
     -  Added `{ type: "featured"; handle: string }` case to `ParseUriResult`
        type.

 -  Frequently used JSON-LD contexts are now preloaded.  [[74]]

+759 −29

File changed.

Preview size limit exceeded, changes collapsed.

+15 −1
Original line number Diff line number Diff line
@@ -106,6 +106,15 @@ export interface Context<TContextData> {
   */
  getLikedUri(handle: string): URL;

  /**
   * Builds the URI of an actor's featured collection with the given handle.
   * @param handle The actor's handle.
   * @returns The actor's featured collection URI.
   * @throws {RouterError} If no featured collection is available.
   * @since 0.11.0
   */
  getFeaturedUri(handle: string): URL;

  /**
   * Determines the type of the URI and extracts the associated data.
   * @param uri The URI to parse.
@@ -318,7 +327,12 @@ export type ParseUriResult =
   * The case of a liked collection URI.
   * @since 0.11.0
   */
  | { type: "liked"; handle: string };
  | { type: "liked"; handle: string }
  /**
   * The case of a featured collection URI.
   * @since 0.11.0
   */
  | { type: "featured"; handle: string };

/**
 * Options for {@link Context.sendActivity} method and
+8 −0
Original line number Diff line number Diff line
@@ -175,6 +175,10 @@ test("handleActor()", async () => {
      "https://w3id.org/security/multikey/v1",
      {
        manuallyApprovesFollowers: "as:manuallyApprovesFollowers",
        featured: {
          "@id": "toot:featured",
          "@type": "@id",
        },
        discoverable: "toot:discoverable",
        indexable: "toot:indexable",
        memorial: "toot:memorial",
@@ -261,6 +265,10 @@ test("handleActor()", async () => {
      "https://w3id.org/security/multikey/v1",
      {
        manuallyApprovesFollowers: "as:manuallyApprovesFollowers",
        featured: {
          "@id": "toot:featured",
          "@type": "@id",
        },
        discoverable: "toot:discoverable",
        indexable: "toot:indexable",
        memorial: "toot:memorial",
+15 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ test("Federation.createContext()", async (t) => {
    assertThrows(() => ctx.getFollowingUri("handle"), RouterError);
    assertThrows(() => ctx.getFollowersUri("handle"), RouterError);
    assertThrows(() => ctx.getLikedUri("handle"), RouterError);
    assertThrows(() => ctx.getFeaturedUri("handle"), RouterError);
    assertEquals(ctx.parseUri(new URL("https://example.com/")), null);
    assertEquals(
      ctx.getHandleFromActorUri(new URL("https://example.com/")),
@@ -303,6 +304,20 @@ test("Federation.createContext()", async (t) => {
      ctx.parseUri(new URL("https://example.com/users/handle/liked")),
      { type: "liked", handle: "handle" },
    );

    federation.setFeaturedDispatcher(
      "/users/{handle}/featured",
      () => ({ items: [] }),
    );
    ctx = federation.createContext(new URL("https://example.com/"), 123);
    assertEquals(
      ctx.getFeaturedUri("handle"),
      new URL("https://example.com/users/handle/featured"),
    );
    assertEquals(
      ctx.parseUri(new URL("https://example.com/users/handle/featured")),
      { type: "featured", handle: "handle" },
    );
  });

  await t.step("RequestContext", async () => {
Loading