#!/usr/bin/env node import { Command } from 'commander'; import { type ActiveContext } from './authStore.js'; import { type SourceFile, type SyncManifest } from './localSync.js'; import { type GitHubStatusResponse } from './githubOutput.js'; import { syncGitHubDraftIfConnected } from './githubSyncFlow.js'; import { type DocsExitCode } from './docsOutput.js'; import { type DocsDiagnostic, type DocsStatus } from './docsTransaction.js'; import { type FunnelValidationExitCode, type FunnelValidationResult } from './diagnosticOutput.js'; import { type StepContractMigrationApplyResult, type StepContractMigrationCheckResult, type StepContractMigrationTargetVersion, type StepContractMigrationValidationResult } from './stepContractMigration.js'; import { type AnalyticsOutputFormat, type AnalyticsStepDropoffResponse, type PublishedFunnelFlowResponse } from './analyticsOutput.js'; export declare const CANONICAL_CREATE_TEMPLATE_SLUG = "template"; export declare const SCAFFOLD_TRANSIENT_PATHS: readonly ["node_modules", ".next", "out", "tsconfig.tsbuildinfo", ".funnelsgrove-scaffold.json"]; export declare class CliContractError extends Error { readonly code: string; constructor(code: string, message: string); } export declare const assertCanonicalCreateTemplateSlug: (slug: string) => void; export declare const resolveCreateTemplatePath: (slug?: string) => string; export type DocsCommandOptions = { check?: boolean; diff?: boolean; json?: boolean; replaceManaged?: boolean; resolve?: string; }; export type DocsCommandMode = { mode: 'apply'; json: boolean; } | { mode: 'check'; json: boolean; } | { mode: 'diff'; json: boolean; } | { mode: 'resolve'; json: boolean; path: string; }; export declare function resolveDocsCommandMode(options: DocsCommandOptions): DocsCommandMode; export type DocsCommandBackend = { recover: (targetDir: string) => Promise; inspect: (targetDir: string) => Promise; apply: (targetDir: string, status: DocsStatus) => Promise; resolve: (targetDir: string, relativePath: string) => Promise; }; export type DocsCommandResult = { exitCode: DocsExitCode; output: string; }; export declare const docsResolveConfirmation: (relativePath: string) => string; export declare function executeDocsCommand(input: { targetDir: string; options: DocsCommandOptions; backend?: DocsCommandBackend; auditLegacy?: (targetDir: string) => Promise; isTTY?: boolean; prompt?: (question: string) => Promise; }): Promise; type FunnelValidator = (targetDir: string) => Promise; export type ValidateCommandResult = { exitCode: FunnelValidationExitCode; output: string; }; export declare function executeValidateCommand(input: { targetDir: string; json?: boolean; validate?: FunnelValidator; }): Promise; export declare function auditLegacyFunnel(targetDir: string, validate?: FunnelValidator): Promise; export declare class FunnelValidationError extends CliContractError { readonly result: FunnelValidationResult; constructor(result: FunnelValidationResult); } export declare function runValidatedFunnelMutation(input: { targetDir: string; validate?: FunnelValidator; mutate: () => Promise; }): Promise; export declare const toMigrationValidationResult: (result: FunnelValidationResult) => StepContractMigrationValidationResult; export type StepContractMigrationCommandOptions = { check?: boolean; apply?: boolean; json?: boolean; }; export type StepContractMigrationBackend = { recoverMigration: (targetDir: string, targetVersion: StepContractMigrationTargetVersion) => Promise; recoverDocs: (targetDir: string) => Promise; check: (targetDir: string, targetVersion: StepContractMigrationTargetVersion) => Promise; apply: (targetDir: string, targetVersion: StepContractMigrationTargetVersion) => Promise; }; export type StepContractMigrationCommandResult = { exitCode: 0 | 1 | 2; output: string; }; export declare const copyManagedValidationFiles: (targetDir: string, sourceDir?: string, options?: { replaceConflicts?: boolean; }) => Promise; export declare const repairDownloadedManagedFiles: (targetDir: string, options?: { docsSourceDir?: string; validationSourceDir?: string; }) => Promise; export type BoundedNpmCommandOptions = { timeoutMs?: number; terminationGraceMs?: number; finalizationGraceMs?: number; }; export declare const runBoundedNpmCommand: (targetDir: string, args: readonly string[], options?: BoundedNpmCommandOptions) => Promise; export declare function executeStepContractMigrationCommand(input: { targetDir: string; to: string | number; options: StepContractMigrationCommandOptions; backend?: StepContractMigrationBackend; }): Promise; export type CreateFunnelHooks = { verifyScaffold: (templatePath: string) => Promise; materializeAliases: (stageDir: string) => Promise; reskin: (stageDir: string, appName: string) => Promise; installManagedFiles: (stageDir: string) => Promise; installDependencies: (stageDir: string) => Promise; validate: FunnelValidator; beforeCommit?: (outputPath: string) => Promise; }; export type CreateFunnelResult = { outputPath: string; updatedFiles: string[]; }; export declare const verifyPackagedScaffold: (templatePath: string) => Promise; export declare const materializePackagedScaffoldAliases: (stageDir: string) => Promise; export declare function executeCreateFunnel(input: { templateSlug: string; templatePath?: string; outputPath: string; appName: string; hooks?: CreateFunnelHooks; }): Promise; type AnalyticsCommandInput = { date: string; from: string; to: string; format: AnalyticsOutputFormat; timezone?: string; }; type SyncTargetIdInput = { explicitWorkspaceId?: string; explicitFunnelId?: string; manifest?: Pick | null; active?: Pick | null; defaultWorkspaceId?: string; }; type GeneratedConfigKind = 'experiments'; export declare const EXPERIMENT_TRANSACTION_RECOVERY_COMMANDS: readonly ["sync down", "sync rebase", "sync up", "experiments sync"]; export declare function resolveSyncTargetIds(input: SyncTargetIdInput): { workspaceId: string; funnelId?: string; }; export declare function isCliEntrypoint(invokedPath: string | undefined, modulePath: string, realpath?: (filePath: string) => string): boolean; export declare function buildAnalyticsCommandInput(options: { date: string; format?: string; timezone?: string; }): AnalyticsCommandInput; export declare function buildPatchSourceInput(input: { workspaceId: string; funnelId: string; message?: string; baseDraftVersionId?: string; files: SourceFile[]; deletedPaths: string[]; }): { workspaceId: string; funnelId: string; message?: string; baseDraftVersionId?: string; files: SourceFile[]; deletedPaths: string[]; }; export declare function formatSourceCandidateSyncSuccess(input: { syncedFileCount: number; deletedFileCount: number; versionId: string; }): string; export declare function buildGeneratedConfigSyncInput(input: { workspaceId: string; funnelId: string; kinds: GeneratedConfigKind[]; }): { workspaceId: string; funnelId: string; kinds: GeneratedConfigKind[]; }; export declare function selectGeneratedConfigFiles(files: SourceFile[], kinds: GeneratedConfigKind[]): SourceFile[]; export declare function assertCanDraftSyncSource(status: GitHubStatusResponse): void; type PublishDeploymentStatus = { id: string; state: string; deployment_url?: string | null; version_id?: string | null; metadata?: unknown; }; type PublishAcknowledgement = { deploymentUrl: string; publishedVersionId: string | null; publishedVersionSeq: number | null; }; export declare const formatPublishTerminalFailure: (deployment: PublishDeploymentStatus) => string; export declare const formatPublishTerminalSuccess: (input: { acknowledgement: PublishAcknowledgement; deployment: PublishDeploymentStatus; }) => string; type FunnelDetailResponse = { deployments: PublishDeploymentStatus[]; }; type PublishCommandBackend = { publish: (input: { token: string; workspaceId: string; funnelId: string; message?: string; domains?: string[]; }) => Promise; detail: (input: { token: string; workspaceId: string; funnelId: string; }) => Promise; }; export type PublishProgressReporter = (message: string) => void; export declare const formatPublishProgress: (deployment: PublishDeploymentStatus) => string; export declare const executePublishAndWait: (input: { token: string; workspaceId: string; funnelId: string; message?: string; domains?: string[]; backend?: PublishCommandBackend; onProgress?: PublishProgressReporter; }) => Promise; export declare const buildCloneFunnelMutationInput: (input: { workspaceId: string; funnelId: string; name: string; }, createIdempotencyKey?: () => string) => { idempotencyKey: string; workspaceId: string; funnelId: string; name: string; }; export type GitHubSyncTimeoutPolicy = 'strict' | 'continue'; export declare const PUBLISH_GITHUB_SYNC_TIMEOUT_POLICY: GitHubSyncTimeoutPolicy; export declare const SYNC_UP_NO_LOCAL_CHANGES_GITHUB_SYNC_TIMEOUT_POLICY: GitHubSyncTimeoutPolicy; export declare const SYNC_UP_COMMITTED_CHANGES_GITHUB_SYNC_TIMEOUT_POLICY: GitHubSyncTimeoutPolicy; export declare const GITHUB_SYNC_TIMEOUT_POLICIES: { readonly publish: "continue"; readonly syncUpNoLocalChanges: "strict"; readonly syncUpCommittedChanges: "strict"; }; export declare const syncGitHubDraftForCli: (input: { token: string; workspaceId: string; funnelId: string; timeoutPolicy: GitHubSyncTimeoutPolicy; sync?: typeof syncGitHubDraftIfConnected; warn?: (message: string) => void; }) => Promise; export declare const shouldSyncGitHubDraft: (options: { githubSync?: boolean; }) => boolean; type ExperimentLifecycleAction = 'start' | 'stop' | 'restart' | 'end'; type ExperimentLifecycleResult = { id: string; funnel_id: string; name?: string | null; status: string; }; export declare const formatExperimentLifecycleSuccess: (action: ExperimentLifecycleAction, result: ExperimentLifecycleResult, json: boolean) => string; export declare const program: Command; type AnalyticsApiCall = (input: { path: string; type: 'query' | 'mutation'; data?: unknown; token?: string | null; }) => Promise; type FunnelPathAnalyticsInput = { token: string; workspaceId: string; projectId: string; funnelId: string; commandInput: AnalyticsCommandInput; }; export declare const fetchFunnelPathAnalytics: (input: FunnelPathAnalyticsInput, apiCall?: AnalyticsApiCall) => Promise<{ stepDropoff: AnalyticsStepDropoffResponse; publishedFunnelFlow: PublishedFunnelFlowResponse; }>; export {};