@remcostoeten/fync
Version:
Unified TypeScript library for 9 popular APIs with consistent functional architecture
19 lines • 1.04 kB
TypeScript
import type { TApiClient } from "./api-factory";
type TMethodDefinition = {
path: string;
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
transform?: (response: any) => any;
};
type TResourceMethods = Record<string, TMethodDefinition>;
type TResourceConfig<TMethods extends TResourceMethods = TResourceMethods> = {
name: string;
basePath: string;
methods: TMethods;
};
type TResource<TMethods extends TResourceMethods> = {
[K in keyof TMethods]: TMethods[K]["method"] extends "POST" | "PUT" | "PATCH" ? (data?: any, options?: any) => Promise<any> : (options?: any) => Promise<any>;
};
export declare function createFyncResource<TMethods extends TResourceMethods>(config: TResourceConfig<TMethods>, apiClient: TApiClient): TResource<TMethods>;
export declare function defineResource<TMethods extends TResourceMethods>(config: TResourceConfig<TMethods>): TResourceConfig<TMethods>;
export type { TMethodDefinition, TResource, TResourceConfig, TResourceMethods };
//# sourceMappingURL=resource-factory.d.ts.map