/** * Structured error returned by the public API. */ type ApiErrorBody = { error: { type: string; code: string; message: string; param?: string; details?: string; }; }; /** * Wrapper error thrown when the API returns a non-2xx response. */ export declare class SitepagerApiError extends Error { readonly status: number; readonly errorType: string; readonly errorCode: string; constructor(status: number, body: ApiErrorBody); } type SingleResponse = T & { object: string; dashboardUrl?: string; }; type ListResponse = { object: "list"; data: T[]; hasMore: boolean; total: number; }; export type ScreenshotResult = { url: string; width: number; height: number; fileSizeBytes: number; format: string; }; export type DiffResult = { exceedsThreshold: boolean; diff: { pixelDiffCount: number; totalPixels: number; diffRatio: number; diffPercentage: number; }; images: { diffImageUrl: string; diffImagePath: string; }; dimensions: { baseline: { width: number; height: number; }; current: { width: number; height: number; }; normalized: { width: number; height: number; }; }; processing: { durationMs: number; engine: string; }; }; export type LighthouseAuditResult = { url: string; scores?: { performance: number; accessibility: number; bestPractices: number; seo: number; pwa: number; }; coreWebVitals?: { firstContentfulPaint: number; largestContentfulPaint: number; cumulativeLayoutShift: number; timeToInteractive: number; totalBlockingTime: number; speedIndex: number; }; reportUrls?: { html: string; json: string; }; metadata?: { timestamp: string; executionDuration: number; lighthouseVersion: string; userAgent: string; }; }; type SaveFlowResponse = { object: "flow"; id: string; name: string; slug: string; stepCount: number; isNewFlow: boolean; stepsCreated: number; dashboardUrl?: string; }; type FlowStepResponse = { id: string; order: number; actionType: string; selector?: string | null; value?: string | null; description: string; snapshotName: string; waitAfterMs: number; selectorContext?: Record | null; }; type GetFlowResponse = { object: "flow"; id: string; name: string; slug: string; startUrl: string; viewportWidth: number; viewportHeight: number; steps: FlowStepResponse[]; dashboardUrl?: string; }; type FlowSummaryResponse = { object: "flow"; id: string; name: string; slug: string; stepCount: number; lastRunStatus: string | null; lastRunAt: string | null; }; type RunFlowResponse = { object: "flow_run"; runId: string; flow: { id: string; name: string; slug: string; startUrl: string; viewportWidth: number; viewportHeight: number; }; steps: FlowStepResponse[]; variablesRequired: string[]; dashboardUrl?: string; }; type SubmitFlowResultsResponse = { object: "flow_run"; runId: string; status: string; summary: { totalSteps: number; compared: number; passed: number; changed: number; new: number; failed: number; skipped: number; }; stepResults: Array<{ stepOrder: number; status: string; executionStatus: string; errorMessage?: string; comparison?: { result: string; diffPercentage?: number; screenshotUrl?: string; baselineUrl?: string; diffUrl?: string; }; }>; failures: Array<{ stepOrder: number; description: string; executionStatus: string; errorMessage: string; }>; durationMs?: number; dashboardUrl?: string; }; export declare class SitepagerApiClient { private readonly baseUrl; private readonly apiKey; constructor(apiKey?: string, apiUrl?: string); private headers; private request; private requestMultipart; /** * Poll an async job until it reaches a terminal status. * Returns the job result on completion, throws on failure or timeout. */ private pollJob; screenshotUrl(input: { url: string; viewport?: { width?: number; height?: number; }; device?: string; fullPage?: boolean; waitFor?: number; }): Promise>; diffImages(input: { image1Url: string; image2Url: string; threshold?: number; engine?: string; }): Promise>; lighthouseAudit(input: { url: string; categories?: string[]; device?: string; }): Promise>; listScans(options?: { page?: number; limit?: number; search?: string; enabled?: boolean; }): Promise>>; createScan(input: { name: string; url: string; deviceType?: string; maxPages?: number; features?: string[]; includeUrls?: string[]; excludePatterns?: string[]; crawlIncludedUrls?: boolean; region?: string; }): Promise>; getScan(id: string): Promise>; runScan(scanId: string): Promise>; listScanRuns(options?: { page?: number; limit?: number; scanId?: string; status?: string; }): Promise>>; getScanRun(id: string): Promise>; cancelScanRun(id: string): Promise>; getScanResults(runId: string, options?: { sections?: string[]; severity?: string; issueType?: string; changeType?: string; linkType?: string; pagePath?: string; includeMatched?: boolean; limit?: number; offset?: number; }): Promise>; getCreditsBalance(): Promise>; saveFlow(input: { name: string; startUrl: string; viewportWidth?: number; viewportHeight?: number; steps: Array<{ order: number; actionType: string; selector?: string; value?: string; description: string; waitAfterMs?: number; screenshotPath: string; selectorContext?: Record; }>; }): Promise; getFlow(flowIdOrSlug: string): Promise; listFlows(): Promise>; runFlow(input: { flow: string; }): Promise; submitFlowResults(input: { runId: string; steps: Array<{ stepOrder: number; status: string; screenshotPath?: string; errorMessage?: string; executedSelector?: string; durationMs?: number; }>; durationMs?: number; }): Promise; approveAllFlowRun(runId: string): Promise<{ runId: string; approvedCount: number; }>; approveFlowRunStep(stepId: string): Promise<{ stepId: string; approved: boolean; }>; } export {};