UNPKG

@mastra/core

Version:

The core foundation of the Mastra framework, providing essential components and interfaces for building AI-powered applications.

30 lines 1.49 kB
import type { Context, Handler, MiddlewareHandler } from 'hono'; import type { DescribeRouteOptions } from 'hono-openapi'; import type { Mastra } from '../mastra'; import type { ApiRoute, MastraAuthConfig, Methods } from './types'; export type { MastraAuthConfig, ContextWithMastra } from './types'; export { MastraAuthProvider } from './auth'; export type { MastraAuthProviderOptions } from './auth'; type ParamsFromPath<P extends string> = { [K in P extends `${string}:${infer Param}/${string}` | `${string}:${infer Param}` ? Param : never]: string; }; type RegisterApiRoutePathError = `Param 'path' must not start with '/api', it is reserved for internal API routes.`; type ValidatePath<P extends string, T> = P extends `/api/${string}` ? RegisterApiRoutePathError : T; type RegisterApiRouteOptions<P extends string> = { method: Methods; openapi?: DescribeRouteOptions; handler?: Handler<{ Variables: { mastra: Mastra; }; }, P, ParamsFromPath<P>>; createHandler?: (c: Context) => Promise<Handler<{ Variables: { mastra: Mastra; }; }, P, ParamsFromPath<P>>>; middleware?: MiddlewareHandler | MiddlewareHandler[]; }; export declare function registerApiRoute<P extends string>(path: P, options: ValidatePath<P, RegisterApiRouteOptions<P>>): ValidatePath<P, ApiRoute>; export declare function defineAuth<TUser>(config: MastraAuthConfig<TUser>): MastraAuthConfig<TUser>; //# sourceMappingURL=index.d.ts.map