import { type TextOptions } from "@clack/prompts"; import { z, type ZodType } from "zod"; import { type CliAuthSession } from "./lib/auth-client.js"; import { type ConfigDirMatch } from "./lib/config-dir.js"; export declare const REASONABLE_NAME_SCHEMA: z.ZodString; export declare const ORG_OPT: { org: { type: "string"; short: string; }; }; export declare const ORG_OPTION_DESCRIPTIONS: { org: string; }; export declare const API_KEY_OPT: { key: { type: "string"; short: string; }; }; export declare const API_KEY_OPTION_DESCRIPTIONS: { key: string; }; export declare const PROJECT_OPT: { project: { type: "string"; short: string; }; }; export declare const PROJECT_OPTION_DESCRIPTIONS: { project: string; }; export declare const AUTOMATION_OPT: { automation: { type: "string"; short: string; }; }; export declare const AUTOMATION_OPTION_DESCRIPTIONS: { automation: string; }; export declare const PAGINATION_OPTS: { cursor: { type: "string"; }; limit: { type: "string"; }; }; export declare const PAGINATION_OPTION_DESCRIPTIONS: { cursor: string; limit: string; }; export declare const CLI_PREFIX: string; /** Checks whether the current process can safely show interactive prompts. */ export declare function canPrompt(): boolean; /** * Makes an option nullable only when the CLI can ask for it interactively. * * @param schema - Schema for the option's explicit value. * @param optionName - Human-readable option name used in validation errors. */ export declare function promptableOption(schema: T, optionName?: string): z.ZodPrefault>; /** * Runs an interactive prompt and handles cancellation consistently. * * @param promptFactory - Function that starts the prompt. * @param optionName - Explicit option users can pass in non-interactive mode. * @throws {Error} When prompting is unavailable. */ export declare function safelyPrompt(promptFactory: () => Promise, optionName?: string): Promise; /** * Prompts for text, displays schema validation errors, and parses the result. * * @param promptOptions - Text prompt labels and defaults. * @param schema - Schema used to validate and transform the response. * @param optionName - Explicit option users can pass instead of prompting. */ export declare function safelyPromptTextWithValidation(promptOptions: TextOptions, schema: T, optionName?: string): Promise>; /** * Formats an error for human-readable CLI output. * * @param error - Error to format. */ export declare function formatErrorMessage(error: unknown): string; /** * Converts an error into the CLI's stable JSON error envelope. * * @param error - Error to serialize. */ export declare function formatJsonError(error: unknown): { error: { formErrors: string[]; fieldErrors: {}; message: string; }; } | { error: { message: string; data?: z.core.util.JSONType | undefined; status?: number | undefined; code: string; }; } | { error: { message: string; }; }; /** * Writes a serialized CLI error to stderr. * * @param error - Error to serialize and write. */ export declare function writeJsonError(error: unknown): void; export declare const output: { normal: (printFn: () => unknown) => /*elided*/ any; json: (value: unknown) => /*elided*/ any; }; /** * Returns the current session or asks the user to log in. * * @param action - User-facing action that requires authentication. * @throws {Error} When the current user is signed out. */ export declare function requireSession(action?: string): Promise; /** * Prints the CLI banner and current authentication identity. * * @param session - Session whose identity should be displayed. */ export declare function sessionIntro(session: CliAuthSession | null): void; /** Shared schema fragment for commands that operate on an organization. */ export declare const orgOptsSchema: z.ZodObject<{ org: z.ZodOptional; }, z.core.$strip>; /** Shared schema fragment for cursor-paginated list commands. */ export declare const paginationOptsSchema: z.ZodObject<{ cursor: z.ZodOptional; limit: z.ZodDefault>; }, z.core.$strip>; /** Shared schema fragment for commands that select an organization API key. */ export declare const apiKeyOptsSchema: z.ZodObject<{ org: z.ZodOptional; key: z.ZodOptional; }, z.core.$strip>; type OrgList = { id: string; name: string; plan?: string | null; }[]; export interface UseOrganizationOptions { /** What to do when the current user belongs to no organizations. */ whenEmpty?: "error" | "prompt-create"; } /** * Resolves an organization from CLI flags, the nearby project config, or an * interactive prompt. Callers opt into inline creation so destructive/update * flows don't create empty organizations. * * @param opts - Parsed organization CLI options. * @param options - Empty-organization behavior options. * @param options.whenEmpty - Behavior when the user belongs to no * organizations. */ export declare function useOrganization(opts: z.infer, { whenEmpty }?: UseOrganizationOptions): Promise<{ id: string; name: string; }>; /** * Resolves an API key owned by an organization from `--key` or an interactive * prompt. * * @param organizationId - Organization whose API keys may be selected. * @param opts - Parsed API key selector. */ export declare function useOrganizationApiKey(organizationId: string, opts: z.infer): Promise<{ id: string; name: string | null; start: string | null; createdAt: Date; updatedAt: Date; expiresAt: Date | null; }>; /** * Selects an existing organization without offering creation. * * @param organizations - Organizations available for selection. * @param options - Prompt options with creation disabled. * @param options.allowCreate - Disables inline organization creation. */ export declare function promptOrg(organizations: T[], options: { allowCreate: false; }): Promise; /** * Selects an organization and optionally offers inline creation. * * @param organizations - Organizations available for selection. * @param options - Prompt options. * @param options.allowCreate - Whether to offer inline organization creation. */ export declare function promptOrg(organizations: OrgList, options: { allowCreate: boolean; }): Promise; /** * Selects an organization, offering inline creation by default. * * @param organizations - Organizations available for selection. * @param options - Optional prompt behavior. * @param options.allowCreate - Whether to offer inline organization creation. */ export declare function promptOrg(organizations: OrgList, options?: { allowCreate?: true; }): Promise; /** * Asks whether to create the user's first organization, then creates it. * * @throws {Error} When the user declines creation. */ export declare function promptCreateOrganization(): Promise<{ id: string; name: string; }>; /** Shared schema fragment for commands that operate on a project. */ export declare const projectOptsSchema: z.ZodObject<{ project: z.ZodOptional; }, z.core.$strip>; /** Shared schema fragment for commands that select an automation. */ export declare const automationOptsSchema: z.ZodObject<{ project: z.ZodOptional; automation: z.ZodOptional; }, z.core.$strip>; /** Shared schema fragment for commands that operate on a config directory. */ export declare const configDirOptsSchema: z.ZodObject<{ dir: z.ZodOptional; }, z.core.$strip>; export interface UseProjectOptions { /** Whether project resolution may create a project interactively. */ mode?: "select" | "select-or-create"; /** Organization that selected or created projects must belong to. */ organizationId?: string; } interface ProjectScopeResolvers { resolveOrganization: typeof useOrganization; resolveProject: typeof useProject; } /** * Resolves a project from CLI flags, the nearby project config, or an * interactive prompt. Fetches projects across all organizations so the user * doesn't need to specify one. * * @param opts - Parsed project CLI options. * @param options - Project resolution behavior. * @param options.mode - Whether interactive project creation is allowed. * @param options.organizationId - Optional organization scope. */ export declare function useProject(opts: z.infer, { mode, organizationId }?: UseProjectOptions): Promise<{ activeDeploymentId: string | null; id: string; name: string; organizationId: string; createdAt: Date; createdBy: string | null; org: { id: string; name: string; }; activeAutomations: { description: string; id: string; identityKey: string; }[]; }>; /** * Resolves one active automation by ID, identity key, or interactive choice. * * @param opts - Automation and optional project selectors. */ export declare function useAutomation(opts: z.infer): Promise<{ accountBindings: { account: { checkedAt: Date | null; connectionMethodId: string; error: { code: string; message: string; } | null; id: string; label: string; scopes: string[]; serviceId: string; serviceSub: string; } | null; binding: string; serviceId: string; }[]; activeDeploymentId: string; createdAt: Date; description: string; enabled: boolean; id: string; identityKey: string; project: { id: string; name: string; organization: { id: string; name: string; }; }; triggers: { details: { value: string; label: string; copyable?: boolean | undefined; }[]; hookSlot: number; id: string; name: string; scopePath: number[]; type: string; primary?: { value: string; copyable?: boolean | undefined; } | undefined; }[]; updatedAt: Date; }>; /** * Resolves the project and its organization for commands with both options. * * @param opts - Explicit project and organization selectors. * @param opts.org - Optional organization name or ID. * @param opts.project - Optional project name or ID. * @param resolvers - Resource resolvers, replaceable for focused tests. */ export declare function useProjectScope(opts: { org?: string; project?: string; }, resolvers?: ProjectScopeResolvers): Promise<{ organization: { id: string; name: string; }; project: { activeDeploymentId: string | null; id: string; name: string; organizationId: string; createdAt: Date; createdBy: string | null; org: { id: string; name: string; }; activeAutomations: { description: string; id: string; identityKey: string; }[]; }; }>; /** * Resolves an explicit automation ID or unambiguous identity key. * * @param automations - Visible active automations matching the selector query. * @param selector - Stable automation ID or source identity key. * @throws When the identity key exists in more than one project. */ export declare function resolveAutomationSelector(automations: readonly T[], selector: string): T | undefined; /** * Resolves only a stable automation ID, leaving identity keys project-scoped. * * @param automations - Visible active automations matching the selector query. * @param selector - Possible stable automation ID. */ export declare function resolveAutomationId(automations: readonly T[], selector: string): T | undefined; /** * Resolves the config directory from a positional directory or config search. * Precedence: explicit directory > current directory > nearest parent > * downward search. Multiple downward matches are selected interactively. * * @param opts - Parsed config-directory CLI options. */ export declare function useConfigDir(opts: z.infer): Promise; /** * Selects a simple English singular or plural word form. * * @param count - Quantity determining which form to use. * @param singularWord - Singular noun to pluralize when needed. */ export declare function pluralize(count: number, singularWord: string): string; export {}; //# sourceMappingURL=utils.d.ts.map