Loading fedify/federation/callback.ts +18 −9 Original line number Diff line number Diff line Loading @@ -278,53 +278,62 @@ export type ObjectAuthorizePredicate<TContextData, TParam extends string> = ( * A callback that dispatches a custom collection. * * @typeParam TItem The type of items in the collection. * @typeParam TParams The parameter names of the requested URL. * @typeParam TContext The type of the context. {@link Context} or * {@link RequestContext}. * @typeParam TContextData The context data to pass to the `TContext`. * @typeParam TFilter The type of the filter, if any. * @param context The context. * @param values The parameters of the requested URL. * @param cursor The cursor to start the collection from, or `null` to dispatch * the entire collection without pagination. * @param filter The filter to apply to the collection, if any. * @since 1.8.0 */ export type CustomCollectionDispatcher< TItem, TParams extends Record<string, string>, TContext extends Context<TContextData>, TContextData, TFilter, > = ( context: TContext, values: TParams, cursor: string | null, filter?: TFilter, ) => PageItems<TItem> | null | Promise<PageItems<TItem> | null>; /** * A callback that counts the number of items in a custom collection. * * @typeParam TParams The parameter names of the requested URL. * @typeParam TContextData The context data to pass to the {@link Context}. * @param context The context. * @param filter The filter to apply to the collection, if any. * @param values The parameters of the requested URL. * @since 1.8.0 */ export type CustomCollectionCounter<TContextData, TFilter> = ( export type CustomCollectionCounter< TParams extends Record<string, string>, TContextData, > = ( context: RequestContext<TContextData>, filter?: TFilter, values: TParams, ) => number | bigint | null | Promise<number | bigint | null>; /** * A callback that returns a cursor for a custom collection. * * @typeParam TParams The parameter names of the requested URL. * @typeParam TContext The type of the context. {@link Context} or * {@link RequestContext}. * @typeParam TContextData The context data to pass to the {@link Context}. * @typeParam TFilter The type of the filter, if any. * @param context The context. * @param filter The filter to apply to the collection, if any. * @param values The parameters of the requested URL. * @since 1.8.0 */ export type CustomCollectionCursor< TParams extends Record<string, string>, TContext extends Context<TContextData>, TContextData, TFilter, > = ( context: TContext, filter?: TFilter, values: TParams, ) => string | null | Promise<string | null>; fedify/federation/federation.ts +49 −21 Original line number Diff line number Diff line Loading @@ -464,21 +464,21 @@ export interface Federatable<TContextData> { */ setCollectionDispatcher< TObject extends Object, TParam extends Record<string, string>, TParams extends Record<string, string>, >( name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: ParamsKeyPath<TParam>, path: ParamsKeyPath<TParams>, dispatcher: CustomCollectionDispatcher< TObject, TParams, RequestContext<TContextData>, TContextData, void TContextData >, ): CustomCollectionCallbackSetters< TParams, RequestContext<TContextData>, TContextData, void TContextData >; /** Loading @@ -497,21 +497,21 @@ export interface Federatable<TContextData> { */ setOrderedCollectionDispatcher< TObject extends Object, TParam extends Record<string, string>, TParams extends Record<string, string>, >( name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: ParamsKeyPath<TParam>, path: ParamsKeyPath<TParams>, dispatcher: CustomCollectionDispatcher< TObject, TParams, RequestContext<TContextData>, TContextData, void TContextData >, ): CustomCollectionCallbackSetters< TParams, RequestContext<TContextData>, TContextData, void TContextData >; } Loading Loading @@ -1026,15 +1026,16 @@ export interface FederationFetchOptions<TContextData> { /** * Additional settings for a custom collection dispatcher. * * @typeParam TParams The type of the parameters in the URL path. * @typeParam TContext The type of the context. {@link Context} or * {@link RequestContext}. * @typeParam TContextData The context data to pass to the {@link Context}. * @typeParam TFilter The type of filter for the collection. */ export interface CustomCollectionCallbackSetters< TParams extends Record<string, string>, TContext extends Context<TContextData>, TContextData, TFilter, > { /** * Sets the counter for the custom collection. Loading @@ -1042,8 +1043,15 @@ export interface CustomCollectionCallbackSetters< * @returns The setters object so that settings can be chained. */ setCounter( counter: CustomCollectionCounter<TContextData, TFilter>, ): CustomCollectionCallbackSetters<TContext, TContextData, TFilter>; counter: CustomCollectionCounter< TParams, TContextData >, ): CustomCollectionCallbackSetters< TParams, TContext, TContextData >; /** * Sets the first cursor for the custom collection. Loading @@ -1051,8 +1059,16 @@ export interface CustomCollectionCallbackSetters< * @returns The setters object so that settings can be chained. */ setFirstCursor( cursor: CustomCollectionCursor<TContext, TContextData, TFilter>, ): CustomCollectionCallbackSetters<TContext, TContextData, TFilter>; cursor: CustomCollectionCursor< TParams, TContext, TContextData >, ): CustomCollectionCallbackSetters< TParams, TContext, TContextData >; /** * Sets the last cursor for the custom collection. Loading @@ -1060,8 +1076,16 @@ export interface CustomCollectionCallbackSetters< * @returns The setters object so that settings can be chained. */ setLastCursor( cursor: CustomCollectionCursor<TContext, TContextData, TFilter>, ): CustomCollectionCallbackSetters<TContext, TContextData, TFilter>; cursor: CustomCollectionCursor< TParams, TContext, TContextData >, ): CustomCollectionCallbackSetters< TParams, TContext, TContextData >; /** * Specifies the conditions under which requests are authorized. Loading @@ -1070,8 +1094,12 @@ export interface CustomCollectionCallbackSetters< * @since 0.7.0 */ authorize( predicate: AuthorizePredicate<TContextData>, ): CustomCollectionCallbackSetters<TContext, TContextData, TFilter>; predicate: ObjectAuthorizePredicate<TContextData, string>, ): CustomCollectionCallbackSetters< TParams, TContext, TContextData >; } /** Loading Loading
fedify/federation/callback.ts +18 −9 Original line number Diff line number Diff line Loading @@ -278,53 +278,62 @@ export type ObjectAuthorizePredicate<TContextData, TParam extends string> = ( * A callback that dispatches a custom collection. * * @typeParam TItem The type of items in the collection. * @typeParam TParams The parameter names of the requested URL. * @typeParam TContext The type of the context. {@link Context} or * {@link RequestContext}. * @typeParam TContextData The context data to pass to the `TContext`. * @typeParam TFilter The type of the filter, if any. * @param context The context. * @param values The parameters of the requested URL. * @param cursor The cursor to start the collection from, or `null` to dispatch * the entire collection without pagination. * @param filter The filter to apply to the collection, if any. * @since 1.8.0 */ export type CustomCollectionDispatcher< TItem, TParams extends Record<string, string>, TContext extends Context<TContextData>, TContextData, TFilter, > = ( context: TContext, values: TParams, cursor: string | null, filter?: TFilter, ) => PageItems<TItem> | null | Promise<PageItems<TItem> | null>; /** * A callback that counts the number of items in a custom collection. * * @typeParam TParams The parameter names of the requested URL. * @typeParam TContextData The context data to pass to the {@link Context}. * @param context The context. * @param filter The filter to apply to the collection, if any. * @param values The parameters of the requested URL. * @since 1.8.0 */ export type CustomCollectionCounter<TContextData, TFilter> = ( export type CustomCollectionCounter< TParams extends Record<string, string>, TContextData, > = ( context: RequestContext<TContextData>, filter?: TFilter, values: TParams, ) => number | bigint | null | Promise<number | bigint | null>; /** * A callback that returns a cursor for a custom collection. * * @typeParam TParams The parameter names of the requested URL. * @typeParam TContext The type of the context. {@link Context} or * {@link RequestContext}. * @typeParam TContextData The context data to pass to the {@link Context}. * @typeParam TFilter The type of the filter, if any. * @param context The context. * @param filter The filter to apply to the collection, if any. * @param values The parameters of the requested URL. * @since 1.8.0 */ export type CustomCollectionCursor< TParams extends Record<string, string>, TContext extends Context<TContextData>, TContextData, TFilter, > = ( context: TContext, filter?: TFilter, values: TParams, ) => string | null | Promise<string | null>;
fedify/federation/federation.ts +49 −21 Original line number Diff line number Diff line Loading @@ -464,21 +464,21 @@ export interface Federatable<TContextData> { */ setCollectionDispatcher< TObject extends Object, TParam extends Record<string, string>, TParams extends Record<string, string>, >( name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: ParamsKeyPath<TParam>, path: ParamsKeyPath<TParams>, dispatcher: CustomCollectionDispatcher< TObject, TParams, RequestContext<TContextData>, TContextData, void TContextData >, ): CustomCollectionCallbackSetters< TParams, RequestContext<TContextData>, TContextData, void TContextData >; /** Loading @@ -497,21 +497,21 @@ export interface Federatable<TContextData> { */ setOrderedCollectionDispatcher< TObject extends Object, TParam extends Record<string, string>, TParams extends Record<string, string>, >( name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: ParamsKeyPath<TParam>, path: ParamsKeyPath<TParams>, dispatcher: CustomCollectionDispatcher< TObject, TParams, RequestContext<TContextData>, TContextData, void TContextData >, ): CustomCollectionCallbackSetters< TParams, RequestContext<TContextData>, TContextData, void TContextData >; } Loading Loading @@ -1026,15 +1026,16 @@ export interface FederationFetchOptions<TContextData> { /** * Additional settings for a custom collection dispatcher. * * @typeParam TParams The type of the parameters in the URL path. * @typeParam TContext The type of the context. {@link Context} or * {@link RequestContext}. * @typeParam TContextData The context data to pass to the {@link Context}. * @typeParam TFilter The type of filter for the collection. */ export interface CustomCollectionCallbackSetters< TParams extends Record<string, string>, TContext extends Context<TContextData>, TContextData, TFilter, > { /** * Sets the counter for the custom collection. Loading @@ -1042,8 +1043,15 @@ export interface CustomCollectionCallbackSetters< * @returns The setters object so that settings can be chained. */ setCounter( counter: CustomCollectionCounter<TContextData, TFilter>, ): CustomCollectionCallbackSetters<TContext, TContextData, TFilter>; counter: CustomCollectionCounter< TParams, TContextData >, ): CustomCollectionCallbackSetters< TParams, TContext, TContextData >; /** * Sets the first cursor for the custom collection. Loading @@ -1051,8 +1059,16 @@ export interface CustomCollectionCallbackSetters< * @returns The setters object so that settings can be chained. */ setFirstCursor( cursor: CustomCollectionCursor<TContext, TContextData, TFilter>, ): CustomCollectionCallbackSetters<TContext, TContextData, TFilter>; cursor: CustomCollectionCursor< TParams, TContext, TContextData >, ): CustomCollectionCallbackSetters< TParams, TContext, TContextData >; /** * Sets the last cursor for the custom collection. Loading @@ -1060,8 +1076,16 @@ export interface CustomCollectionCallbackSetters< * @returns The setters object so that settings can be chained. */ setLastCursor( cursor: CustomCollectionCursor<TContext, TContextData, TFilter>, ): CustomCollectionCallbackSetters<TContext, TContextData, TFilter>; cursor: CustomCollectionCursor< TParams, TContext, TContextData >, ): CustomCollectionCallbackSetters< TParams, TContext, TContextData >; /** * Specifies the conditions under which requests are authorized. Loading @@ -1070,8 +1094,12 @@ export interface CustomCollectionCallbackSetters< * @since 0.7.0 */ authorize( predicate: AuthorizePredicate<TContextData>, ): CustomCollectionCallbackSetters<TContext, TContextData, TFilter>; predicate: ObjectAuthorizePredicate<TContextData, string>, ): CustomCollectionCallbackSetters< TParams, TContext, TContextData >; } /** Loading