Unverified Commit 8cb8c8e9 authored by Hong Minhee's avatar Hong Minhee
Browse files

Add typeId static property to vocab classes

parent 12b6044c
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ To be released.
    option now responds with `Vary: Accept, Signature` header.

 -  Added log messages using the [LogTape] library.  Currently the below
    categories are used:
    logger categories are used:

     -  `["fedify"]`
     -  `["fedify", "federation"]`
@@ -35,6 +35,8 @@ To be released.

 -  Added `RequestContext.getActor()` method.

 -  Activity Vocabulary classes now have `typeId` static property.

[public addressing]: https://www.w3.org/TR/activitypub/#public-addressing
[authorized fetch]: https://swicg.github.io/activitypub-http-signature/#authorized-fetch
[LogTape]: https://github.com/dahlia/logtape
+318 −17

File changed.

Preview size limit exceeded, changes collapsed.

+8 −0
Original line number Diff line number Diff line
@@ -55,6 +55,14 @@ async function* generateClass(
    }
    `;
  }
  yield `
    /**
     * The type URI of {@link ${type.name}}: \`${typeUri}\`.
     */
    static get typeId(): URL {
      return new URL(${JSON.stringify(typeUri)});
    }
  `;
  for await (const code of generateFields(typeUri, types)) yield code;
  for await (const code of generateConstructor(typeUri, types)) yield code;
  for await (const code of generateCloner(typeUri, types)) yield code;
+4 −0
Original line number Diff line number Diff line
@@ -766,4 +766,8 @@ for (const typeUri in types) {
      await assertSnapshot(t, Deno.inspect(instance3));
    });
  }

  Deno.test(`${type.name}.typeId`, () => {
    assertEquals(cls.typeId, new URL(type.uri));
  });
}