type FarmIntegrationAPIMethod = "GET" | "QUERY" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD";
type FarmIntegrationAPIBodyFormat = "json" | "form" | "none";
type FarmIntegrationAPIResponseFormat = "json" | "text" | "response";
interface FarmIntegrationAPIOperation
{
readonly kind: "farm-integration-api-operation";
path: string;
method: TMethod;
bodyFormat?: FarmIntegrationAPIBodyFormat;
responseFormat?: FarmIntegrationAPIResponseFormat;
headers?: Record;
credentials?: RequestCredentials;
isServer?: TServer;
__pathless?: boolean;
__types?: {
body: TBody;
query: TQuery;
response: TResponse;
};
}
type FarmIntegrationAPI = {
[key: string]: FarmIntegrationAPI | FarmIntegrationAPIOperation;
};
type FarmIntegrationRouteOperationCarrier = FarmIntegrationAPIOperation> = {
path: TPath;
__operation: TOperation;
};
type IntegrationAPIBuilderOptions = Omit, "kind" | "method" | "path" | "__pathless" | "__types">;
declare function defineIntegrationAPIOperation(operation: Omit, "kind" | "__types">): FarmIntegrationAPIOperation;
declare function defineIntegrationAPI(api: TAPI): TAPI;
declare function get(path: string, options?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
declare function get(path: string, options?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
declare function get(options?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
declare function get(options?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
type RouteOperationsToAPI[]> = {
[TMethod in Lowercase]: Extract;
}>;
};
type StripRouteClientPrefix = TPath extends `/api/${string}/${infer TRest}` ? TRest : TPath extends `/${string}/${infer TRest}` ? TRest : TPath extends `/${infer TRest}` ? TRest : TPath;
type NormalizeRouteSegment = TSegment extends `[...${infer TName}]` ? TName : TSegment extends `[${infer TName}]` ? TName : TSegment extends `${infer TName}(${string}` ? TName : CamelCaseRouteSegment;
type CamelCaseRouteSegment = TSegment extends `${infer THead}-${infer TTail}` ? `${THead}${Capitalize>}` : TSegment;
type RouteNamespaceFromPath> = TPath extends `${infer THead}/${infer TTail}` ? {
[TKey in NormalizeRouteSegment]: RouteNamespaceFromPath;
} : {
[TKey in NormalizeRouteSegment]: {
[TMethod in Lowercase]: TOperation;
};
};
type UnionToIntersection = (TUnion extends unknown ? (value: TUnion) => void : never) extends (value: infer TIntersection) => void ? TIntersection : never;
type ExpandRecursively = TValue extends (...args: any[]) => any ? TValue : TValue extends object ? {
[TKey in keyof TValue]: ExpandRecursively;
} : TValue;
type RoutesToAPI[]> = ExpandRecursively ? RouteNamespaceFromPath, TOperation> : never>>;
type InferIntegrationAPIFromRoutes[]> = RoutesToAPI;
declare function route(path: string, definition: TAPI): TAPI;
declare function route[]>(path: string, ...operations: TOperations): RouteOperationsToAPI;
declare function fromRoutes[]>(routes: TRoutes): RoutesToAPI;
declare const api: {
get: typeof get;
route: typeof route;
fromRoutes: typeof fromRoutes;
query(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
post(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
put(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
patch(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
delete(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
options(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
head(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
form: {
query(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
post(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
put(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
patch(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
delete(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
};
};
declare const endpoint: {
get: typeof get;
route: typeof route;
fromRoutes: typeof fromRoutes;
query(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
post(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
put(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
patch(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
delete(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
options(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
head(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
form: {
query(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
post(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
put(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
patch(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
delete(pathOrOptions?: string | IntegrationAPIBuilderOptions, maybeOptions?: IntegrationAPIBuilderOptions): FarmIntegrationAPIOperation;
};
};
export { type FarmIntegrationAPI as F, type InferIntegrationAPIFromRoutes as I, api as a, defineIntegrationAPIOperation as b, type FarmIntegrationAPIBodyFormat as c, defineIntegrationAPI as d, type FarmIntegrationAPIMethod as e, type FarmIntegrationAPIOperation as f, type FarmIntegrationAPIResponseFormat as g, type FarmIntegrationRouteOperationCarrier as h, endpoint as i };