Loading fedify/federation/federation.ts +2 −2 Original line number Diff line number Diff line Loading @@ -1121,8 +1121,8 @@ export type ConstructorWithTypeId<TObject extends Object> = * ```ts * type UserPostPath = ParamsKeyPath<{ userId: string; postId: string }>; * let userPostPath: UserPostPath; * userPostPath = "/posts/{postId}"; // invalid * userPostPath = "/users/{userId}"; // invalid * // userPostPath = "/posts/{postId}"; // invalid - does not contain `{userId}` * // userPostPath = "/users/{userId}"; // invalid - does not contain `{postId}` * userPostPath = "/users/{userId}/posts/{postId}"; // valid * userPostPath = "/posts/{postId}/users/{userId}"; // valid * ``` Loading fedify/federation/handler.test.ts +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import type { import type { RequestContext } from "./context.ts"; import { acceptsJsonLd, type CustomCollectionCallbacks, handleActor, handleCollection, handleCustomCollection, Loading fedify/federation/handler.ts +0 −1 Original line number Diff line number Diff line Loading @@ -1287,7 +1287,6 @@ class CustomCollectionHandler< cursor = null, }) => async (span: Span): Promise<PageItems<TItem>> => { // suggestion: Make as a wrapper around the dispatcher try { if (totalItems !== null) { span.setAttribute(this.ATTRS.TOTAL_ITEMS, totalItems); Loading fedify/federation/middleware.test.ts +4 −0 Original line number Diff line number Diff line Loading @@ -258,6 +258,10 @@ test({ assertThrows(() => ctx.getLikedUri("handle"), RouterError); assertThrows(() => ctx.getFeaturedUri("handle"), RouterError); assertThrows(() => ctx.getFeaturedTagsUri("handle"), RouterError); assertThrows( () => ctx.getCollectionUri("test", { id: "123" }), RouterError, ); assertEquals(ctx.parseUri(new URL("https://example.com/")), null); assertEquals(ctx.parseUri(null), null); assertEquals(await ctx.getActorKeyPairs("handle"), []); Loading testing/context.ts +4 −2 Original line number Diff line number Diff line import { trace } from "@opentelemetry/api"; import type { Context, Federation, InboxContext, RequestContext, } from "@fedify/fedify/federation"; import type { Federation } from "@fedify/fedify/federation"; import { RouterError } from "@fedify/fedify/federation"; import { lookupObject as globalLookupObject, traverseCollection as globalTraverseCollection, } from "@fedify/fedify/vocab"; import { lookupWebFinger as globalLookupWebFinger } from "@fedify/fedify/webfinger"; import { trace } from "@opentelemetry/api"; import { mockDocumentLoader } from "./docloader.ts"; // NOTE: Copied from @fedify/fedify/testing/context.ts Loading @@ -34,6 +34,7 @@ export function createContext<TContextData>( getNodeInfoUri, getActorUri, getObjectUri, getCollectionUri, getOutboxUri, getInboxUri, getFollowingUri, Loading Loading @@ -68,6 +69,7 @@ export function createContext<TContextData>( getNodeInfoUri: getNodeInfoUri ?? throwRouteError, getActorUri: getActorUri ?? throwRouteError, getObjectUri: getObjectUri ?? throwRouteError, getCollectionUri: getCollectionUri ?? throwRouteError, getOutboxUri: getOutboxUri ?? throwRouteError, getInboxUri: getInboxUri ?? throwRouteError, getFollowingUri: getFollowingUri ?? throwRouteError, Loading Loading
fedify/federation/federation.ts +2 −2 Original line number Diff line number Diff line Loading @@ -1121,8 +1121,8 @@ export type ConstructorWithTypeId<TObject extends Object> = * ```ts * type UserPostPath = ParamsKeyPath<{ userId: string; postId: string }>; * let userPostPath: UserPostPath; * userPostPath = "/posts/{postId}"; // invalid * userPostPath = "/users/{userId}"; // invalid * // userPostPath = "/posts/{postId}"; // invalid - does not contain `{userId}` * // userPostPath = "/users/{userId}"; // invalid - does not contain `{postId}` * userPostPath = "/users/{userId}/posts/{postId}"; // valid * userPostPath = "/posts/{postId}/users/{userId}"; // valid * ``` Loading
fedify/federation/handler.test.ts +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import type { import type { RequestContext } from "./context.ts"; import { acceptsJsonLd, type CustomCollectionCallbacks, handleActor, handleCollection, handleCustomCollection, Loading
fedify/federation/handler.ts +0 −1 Original line number Diff line number Diff line Loading @@ -1287,7 +1287,6 @@ class CustomCollectionHandler< cursor = null, }) => async (span: Span): Promise<PageItems<TItem>> => { // suggestion: Make as a wrapper around the dispatcher try { if (totalItems !== null) { span.setAttribute(this.ATTRS.TOTAL_ITEMS, totalItems); Loading
fedify/federation/middleware.test.ts +4 −0 Original line number Diff line number Diff line Loading @@ -258,6 +258,10 @@ test({ assertThrows(() => ctx.getLikedUri("handle"), RouterError); assertThrows(() => ctx.getFeaturedUri("handle"), RouterError); assertThrows(() => ctx.getFeaturedTagsUri("handle"), RouterError); assertThrows( () => ctx.getCollectionUri("test", { id: "123" }), RouterError, ); assertEquals(ctx.parseUri(new URL("https://example.com/")), null); assertEquals(ctx.parseUri(null), null); assertEquals(await ctx.getActorKeyPairs("handle"), []); Loading
testing/context.ts +4 −2 Original line number Diff line number Diff line import { trace } from "@opentelemetry/api"; import type { Context, Federation, InboxContext, RequestContext, } from "@fedify/fedify/federation"; import type { Federation } from "@fedify/fedify/federation"; import { RouterError } from "@fedify/fedify/federation"; import { lookupObject as globalLookupObject, traverseCollection as globalTraverseCollection, } from "@fedify/fedify/vocab"; import { lookupWebFinger as globalLookupWebFinger } from "@fedify/fedify/webfinger"; import { trace } from "@opentelemetry/api"; import { mockDocumentLoader } from "./docloader.ts"; // NOTE: Copied from @fedify/fedify/testing/context.ts Loading @@ -34,6 +34,7 @@ export function createContext<TContextData>( getNodeInfoUri, getActorUri, getObjectUri, getCollectionUri, getOutboxUri, getInboxUri, getFollowingUri, Loading Loading @@ -68,6 +69,7 @@ export function createContext<TContextData>( getNodeInfoUri: getNodeInfoUri ?? throwRouteError, getActorUri: getActorUri ?? throwRouteError, getObjectUri: getObjectUri ?? throwRouteError, getCollectionUri: getCollectionUri ?? throwRouteError, getOutboxUri: getOutboxUri ?? throwRouteError, getInboxUri: getInboxUri ?? throwRouteError, getFollowingUri: getFollowingUri ?? throwRouteError, Loading