@@ -275,6 +275,21 @@ const binaryResponse = (data: Uint8Array, contentType: string, status = 200) =>
275275 )
276276 )
277277
278+ /**
279+ * Serializes a federation JSON-LD document with the ForgeFed response content type.
280+ *
281+ * @param data - JSON-LD payload that satisfies the JSON.stringify serializability precondition.
282+ * @param status - HTTP status code assigned to the response.
283+ * @returns Effect that yields an HTTP text response containing the serialized JSON-LD document.
284+ *
285+ * @pure false
286+ * @effect Delegates response allocation to textResponse and preserves no-store HTTP headers.
287+ * @invariant successful responses always use federationJsonLdResponseContentType.
288+ * @precondition data is JSON.stringify-serializable and status is a valid HTTP status code.
289+ * @postcondition response body equals JSON.stringify(data) and response status equals status.
290+ * @complexity O(n) time and O(n) space where n is the serialized JSON-LD payload size.
291+ * @throws TypeError when data violates the JSON.stringify serializability precondition.
292+ */
278293const jsonLdResponse = ( data : unknown , status : number ) =>
279294 textResponse ( JSON . stringify ( data ) , federationJsonLdResponseContentType , status )
280295
@@ -595,34 +610,99 @@ export const federationExchangeStatusResponse = () =>
595610 return yield * _ ( jsonResponse ( makeFederationExchangeStatus ( context ) , 200 ) )
596611 } ) . pipe ( Effect . catchAll ( errorResponse ) )
597612
613+ /**
614+ * Builds the federation actor JSON-LD HTTP handler.
615+ *
616+ * @returns Effect that yields the local ActivityPub actor document response.
617+ *
618+ * @pure false
619+ * @effect Reads HttpServerRequest, resolves federation context, renders makeFederationActorDocument, serializes with jsonLdResponse, and maps failures through errorResponse.
620+ * @invariant successful responses contain the actor id derived from the resolved federation context.
621+ * @precondition request headers or configured env provide a non-empty public origin.
622+ * @postcondition successful responses contain a JSON-LD Person document with HTTP 200.
623+ * @complexity O(1) time and O(1) space for document construction, excluding serialization size.
624+ * @throws Never; failures are represented through the Effect error channel and converted by errorResponse.
625+ */
598626export const federationActorDocumentResponse = ( ) =>
599627 Effect . gen ( function * ( _ ) {
600628 const request = yield * _ ( HttpServerRequest . HttpServerRequest )
601629 const context = yield * _ ( resolveFederationContext ( request ) )
602630 return yield * _ ( jsonLdResponse ( makeFederationActorDocument ( context ) , 200 ) )
603631 } ) . pipe ( Effect . catchAll ( errorResponse ) )
604632
633+ /**
634+ * Builds the federation outbox JSON-LD HTTP handler.
635+ *
636+ * @returns Effect that yields the local ActivityPub outbox collection response.
637+ *
638+ * @pure false
639+ * @effect Reads HttpServerRequest, resolves federation context, renders makeFederationOutboxCollection, serializes with jsonLdResponse, and maps failures through errorResponse.
640+ * @invariant successful responses contain the outbox id derived from the resolved federation context.
641+ * @precondition request headers or configured env provide a non-empty public origin.
642+ * @postcondition successful responses contain a JSON-LD OrderedCollection document with HTTP 200.
643+ * @complexity O(1) time and O(1) space for document construction, excluding serialization size.
644+ * @throws Never; failures are represented through the Effect error channel and converted by errorResponse.
645+ */
605646export const federationOutboxDocumentResponse = ( ) =>
606647 Effect . gen ( function * ( _ ) {
607648 const request = yield * _ ( HttpServerRequest . HttpServerRequest )
608649 const context = yield * _ ( resolveFederationContext ( request ) )
609650 return yield * _ ( jsonLdResponse ( makeFederationOutboxCollection ( context ) , 200 ) )
610651 } ) . pipe ( Effect . catchAll ( errorResponse ) )
611652
653+ /**
654+ * Builds the federation followers JSON-LD HTTP handler.
655+ *
656+ * @returns Effect that yields the local ActivityPub followers collection response.
657+ *
658+ * @pure false
659+ * @effect Reads HttpServerRequest, resolves federation context, renders makeFederationFollowersCollection, serializes with jsonLdResponse, and maps failures through errorResponse.
660+ * @invariant successful responses contain the followers id derived from the resolved federation context.
661+ * @precondition request headers or configured env provide a non-empty public origin.
662+ * @postcondition successful responses contain a JSON-LD OrderedCollection document with HTTP 200.
663+ * @complexity O(1) time and O(1) space for document construction, excluding serialization size.
664+ * @throws Never; failures are represented through the Effect error channel and converted by errorResponse.
665+ */
612666export const federationFollowersDocumentResponse = ( ) =>
613667 Effect . gen ( function * ( _ ) {
614668 const request = yield * _ ( HttpServerRequest . HttpServerRequest )
615669 const context = yield * _ ( resolveFederationContext ( request ) )
616670 return yield * _ ( jsonLdResponse ( makeFederationFollowersCollection ( context ) , 200 ) )
617671 } ) . pipe ( Effect . catchAll ( errorResponse ) )
618672
673+ /**
674+ * Builds the federation following JSON-LD HTTP handler.
675+ *
676+ * @returns Effect that yields the local ActivityPub following collection response.
677+ *
678+ * @pure false
679+ * @effect Reads HttpServerRequest, resolves federation context, renders makeFederationFollowingCollection, serializes with jsonLdResponse, and maps failures through errorResponse.
680+ * @invariant successful responses contain the following id derived from the resolved federation context.
681+ * @precondition request headers or configured env provide a non-empty public origin.
682+ * @postcondition successful responses contain a JSON-LD OrderedCollection document with HTTP 200.
683+ * @complexity O(1) time and O(1) space for document construction, excluding serialization size.
684+ * @throws Never; failures are represented through the Effect error channel and converted by errorResponse.
685+ */
619686export const federationFollowingDocumentResponse = ( ) =>
620687 Effect . gen ( function * ( _ ) {
621688 const request = yield * _ ( HttpServerRequest . HttpServerRequest )
622689 const context = yield * _ ( resolveFederationContext ( request ) )
623690 return yield * _ ( jsonLdResponse ( makeFederationFollowingCollection ( context ) , 200 ) )
624691 } ) . pipe ( Effect . catchAll ( errorResponse ) )
625692
693+ /**
694+ * Builds the federation liked JSON-LD HTTP handler.
695+ *
696+ * @returns Effect that yields the local ActivityPub liked collection response.
697+ *
698+ * @pure false
699+ * @effect Reads HttpServerRequest, resolves federation context, renders makeFederationLikedCollection, serializes with jsonLdResponse, and maps failures through errorResponse.
700+ * @invariant successful responses contain the liked collection id derived from the resolved federation context.
701+ * @precondition request headers or configured env provide a non-empty public origin.
702+ * @postcondition successful responses contain a JSON-LD OrderedCollection document with HTTP 200.
703+ * @complexity O(1) time and O(1) space for document construction, excluding serialization size.
704+ * @throws Never; failures are represented through the Effect error channel and converted by errorResponse.
705+ */
626706export const federationLikedDocumentResponse = ( ) =>
627707 Effect . gen ( function * ( _ ) {
628708 const request = yield * _ ( HttpServerRequest . HttpServerRequest )
0 commit comments