UNPKG

convex

Version:

Client for the Convex Cloud

49 lines 2.86 kB
import { AxiosInstance, AxiosResponse, Method } from "axios"; import type { ProjectConfig } from "./config.js"; import { Context } from "./context.js"; export declare const productionProvisionHost = "https://provision.convex.dev"; export declare const provisionHost: string; /** Prompt for keyboard input with the given `query` string and return a promise * that resolves to the input. */ export declare function prompt(query: string): Promise<unknown>; export declare function fatalServerErr(ctx: Context, err: any): Promise<never>; export declare function deprecationCheckWarning(ctx: Context, resp: AxiosResponse<any, any>): void; export declare function validateOrSelectTeam(ctx: Context, teamSlug: string | null, promptMessage: string): Promise<string>; export declare function validateOrSelectProject(ctx: Context, projectSlug: string | null, teamSlug: string, singleProjectPrompt: string, multiProjectPrompt: string): Promise<string | null>; export interface Package { name: string; version: string; } export declare function loadPackageJson(ctx: Context): Promise<Package[]>; export declare function ensureHasConvexDependency(ctx: Context, cmd: string): Promise<undefined>; /** Return a new array with elements of the passed in array sorted by a key lambda */ export declare const sorted: <T>(arr: T[], key: (el: T) => any) => T[]; export declare function functionsDir(configPath: string, projectConfig: ProjectConfig): string; export declare function rootDirectory(): string; export declare function globalConfigPath(): string; export declare function getAuthHeader(ctx: Context): Promise<string | null>; export declare function bigBrainClient(ctx: Context): Promise<AxiosInstance>; export declare function bigBrainAPI(ctx: Context, method: Method, url: string, data?: any): Promise<any>; export declare type GlobalConfig = { accessToken: string; }; /** * Polls an arbitrary function until a condition is met. * * @param fetch Function performing a fetch, returning resulting data. * @param condition This function will terminate polling when it returns `true`. * @param waitMs How long to wait in between fetches. * @returns The resulting data from `fetch`. */ export declare const poll: <Result>(fetch: () => Promise<Result>, condition: (data: Result) => boolean, waitMs?: number) => Promise<Result>; export declare function formatSize(n: number): string; export declare function formatDuration(ms: number): string; /** * Ensures the current working directory contains package.json and convex.json * files by printing error messages or interactively offering to run `init()`. * * @param ctx * @param ensureConvexJson Offer to run init() if no convex.json file is present. */ export declare function ensureProjectDirectory(ctx: Context, ensureConvexJson?: boolean): Promise<undefined>; //# sourceMappingURL=utils.d.ts.map