import * as trpcServer from '@trpc/server'; import { Migrator } from './migrator'; import { Confirm } from './types'; export interface MigratorRouterContext { migrator: Migrator; confirm: Confirm; } /** Based on `cleye`'s `HelpOptions` */ export interface MigratorRouterMeta { /** Description of the script or command to display in `--help` output. */ description?: string; /** Usage code examples to display in `--help` output. */ usage?: false | string | string[]; /** Example code snippets to display in `--help` output. */ examples?: string | string[]; } /** Helper type that IMO should exist in trpc. Basically a type which a trpc-procedure with context of type `Ctx` will satisfy */ export type TRPCProcedureLike = { mutation: (resolver: (opts: { ctx: Ctx; input: any; }) => any) => any; }; /** Parameters needed for a helper function returning a router, which can be used as a sub-router for another. */ export interface TRPCHelperParams { /** The `trpc.procedure` function. A middleware can be used to align context types. */ procedure: TRPCProcedureLike; } export declare const migratorTrpc: { _config: import("@trpc/server/unstable-core-do-not-import").RootConfig<{ ctx: MigratorRouterContext; meta: MigratorRouterMeta; errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape; transformer: false; }>; procedure: import("@trpc/server/unstable-core-do-not-import").ProcedureBuilder; middleware: <$ContextOverrides>(fn: import("@trpc/server/unstable-core-do-not-import").MiddlewareFunction) => import("@trpc/server/unstable-core-do-not-import").MiddlewareBuilder; router: (input: TInput) => import("@trpc/server/unstable-core-do-not-import").BuiltRouter<{ ctx: MigratorRouterContext; meta: MigratorRouterMeta; errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape; transformer: false; }, import("@trpc/server/unstable-core-do-not-import").DecorateCreateRouterOptions>; mergeRouters: typeof import("@trpc/server/unstable-core-do-not-import").mergeRouters; createCallerFactory: (router: Pick, "_def">) => import("@trpc/server/unstable-core-do-not-import").RouterCaller<{ ctx: MigratorRouterContext; meta: MigratorRouterMeta; errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape; transformer: false; }, TRecord>; }; /** * Get a router with procedures needed to manage migrations. * * @param procedure - TRPC procedure builder for the router this will be attached to. Must have the correct context type * * @example * import {createMigratorRouter, Migrator} from '@pgkit/migrator' * import {initTRPC} from '@trpc/server' * * const t = initTRPC.context().create() * * export const yourAppRouter = t.router({ * yourProcedeure: t.procedure.query(async () => 'Hello, world!'), * migrations: getMigrationsRouter(), * }) * * function getMigrationsRouter() { * return createMigratorRouter( * t.procedure.use(async ({ctx, next}) => { * return next({ * ctx: { * migrator: new Migrator(___), * confirm: async (sql: string) => { * return ctx.whitelistedSql.includes(sql) * }, * } * }) * }) * ) * } */ export declare const createMigratorRouter: (procedure?: TRPCProcedureLike) => import("@trpc/server/unstable-core-do-not-import").BuiltRouter<{ ctx: MigratorRouterContext; meta: MigratorRouterMeta; errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape; transformer: false; }, import("@trpc/server/unstable-core-do-not-import").DecorateCreateRouterOptions<{ up: trpcServer.TRPCMutationProcedure<{ input: {} | { to: string; } | { step: number; } | undefined; output: void; }>; create: trpcServer.TRPCMutationProcedure<{ input: { content?: string | undefined; name?: string | undefined; }; output: { name: string; path: string; content: string; }; }>; list: trpcServer.TRPCQueryProcedure<{ input: { status?: "pending" | "executed" | undefined; query?: string | undefined; result?: "first" | "last" | "one" | "maybeOne" | "all" | undefined; output?: "object" | "path" | "content" | "name" | undefined; }; output: string | import("./types").ListedMigration | (string | import("./types").ListedMigration)[] | undefined; }>; latest: trpcServer.TRPCQueryProcedure<{ input: { skipCheck?: boolean | undefined; }; output: import("./types").ExecutedMigration | undefined; }>; check: trpcServer.TRPCMutationProcedure<{ input: void; output: string; }>; repair: trpcServer.TRPCMutationProcedure<{ input: void; output: { drifted: boolean; updated: boolean; }; }>; goto: trpcServer.TRPCMutationProcedure<{ input: { name: string; }; output: void; }>; baseline: trpcServer.TRPCMutationProcedure<{ input: { to: string; purgeDisk?: boolean | undefined; }; output: void; }>; rebase: trpcServer.TRPCMutationProcedure<{ input: { from: string; }; output: import("./types").ListedMigration[]; }>; definitions: import("@trpc/server/unstable-core-do-not-import").BuiltRouter<{ ctx: MigratorRouterContext; meta: MigratorRouterMeta; errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape; transformer: false; }, import("@trpc/server/unstable-core-do-not-import").DecorateCreateRouterOptions<{ filepath: trpcServer.TRPCQueryProcedure<{ input: void; output: { path: string; content: string | null; }; }>; updateDb: trpcServer.TRPCMutationProcedure<{ input: void; output: void; }>; updateFile: trpcServer.TRPCMutationProcedure<{ input: void; output: { path: string; changed: boolean; updated: string | null; content: string; }; }>; }>>; unlock: trpcServer.TRPCMutationProcedure<{ input: void; output: void; }>; wipe: trpcServer.TRPCMutationProcedure<{ input: void; output: void; }>; sql: trpcServer.TRPCMutationProcedure<{ input: [string, { singlequote?: string | undefined; doublequote?: string | undefined; method?: "many" | "query" | "one" | "maybeOne" | "any" | "anyFirst" | "oneFirst" | "maybeOneFirst" | undefined; }]; output: unknown; }>; }>>; //# sourceMappingURL=router.d.ts.map