import type { Survey, SurveyVersion, SurveyAnalytics, SurveyResponse, PaginatedResult, CreateSurveyInput, UpdateSurveyInput, StartResponseInput, UpdateResponseInput, ListSurveysQuery, ListResponsesQuery, AnalyticsQuery, LogicEvaluationResult, ValidationResult, ResponseValidationResult, UploadedFile, UploadFileOptions } from './types'; export interface SurveyEngineClientOptions { /** Base URL of the survey-engine instance, e.g. "http://survey-engine:3000" */ baseUrl: string; /** * Optional user ID forwarded as X-User-ID header. * Set this after authenticating the user in your application. */ userId?: string; /** * Optional HS256-signed JWT forwarded as X-User-Token. When the engine is * configured with USER_TOKEN_SECRET, it verifies the signature and uses the * token's `sub` claim as the userId — taking priority over `userId`. Mint * server-side with any JWT library using the same shared secret. */ userToken?: string; /** * Optional global API key when the server has API_KEY set — sent as X-API-Key. */ apiKey?: string; /** * Optional correlation ID forwarded as X-Correlation-ID header. * Useful for distributed tracing. */ correlationId?: string; /** Optional custom fetch implementation (useful for testing or edge runtimes) */ fetch?: typeof fetch; } export declare class SurveyEngineError extends Error { readonly status: number; readonly body: unknown; /** Stable machine-readable error code from the API (e.g. "SURVEY_NOT_FOUND") */ readonly code: string; constructor(status: number, body: unknown, message: string); } /** * Typed HTTP client for the Survey Engine API. * * @example * ```typescript * const client = new SurveyEngineClient({ baseUrl: 'http://localhost:3000', userId: 'user-1' }); * * const survey = await client.surveys.create({ name: 'NPS Survey', schemaJson: { ... } }); * await client.surveys.publish(survey.id); * * const response = await client.responses.start({ surveyId: survey.id }); * await client.responses.update(response.id, { answersJson: { q1: 5 } }); * await client.responses.complete(response.id); * ``` */ export declare class SurveyEngineClient { private readonly options; readonly surveys: SurveysClient; readonly responses: ResponsesClient; readonly files: FilesClient; constructor(options: SurveyEngineClientOptions); } declare class BaseClient { protected readonly options: SurveyEngineClientOptions; protected readonly baseUrl: string; protected readonly fetchFn: typeof fetch; constructor(options: SurveyEngineClientOptions); protected request(method: string, path: string, body?: unknown, query?: Record): Promise; protected buildHeaders(contentType?: string): Record; protected parseResponse(res: Response): Promise; } declare class SurveysClient extends BaseClient { create(input: CreateSurveyInput): Promise; list(query?: ListSurveysQuery): Promise>; get(id: string): Promise; update(id: string, input: UpdateSurveyInput): Promise; delete(id: string): Promise; publish(id: string): Promise; /** Duplicate a survey into a new draft — the copy gets "(copy)" appended to its name */ duplicate(id: string): Promise; listVersions(id: string): Promise; getVersion(id: string, versionId: string): Promise; /** Get the active published version — use this to load the schema into SurveyJS */ getRuntime(id: string): Promise; validate(id: string): Promise; evaluateLogic(id: string, answers: Record): Promise; getAnalytics(id: string, query?: AnalyticsQuery): Promise; } declare class ResponsesClient extends BaseClient { /** * Start a new response session. Posts to the canonical `/responses` route * and falls back to the deprecated `/responses/start` if the server returns * 404 — so the SDK works against both pre- and post-route-rename backends. */ start(input: StartResponseInput): Promise; list(query?: ListResponsesQuery): Promise>; get(id: string): Promise; update(id: string, input: UpdateResponseInput): Promise; complete(id: string): Promise; delete(id: string): Promise; validate(id: string): Promise; evaluateLogic(id: string): Promise; } /** Upload, download, and delete binaries for SurveyJS `file` questions (`POST/GET/DELETE /files`). */ declare class FilesClient extends BaseClient { /** * Multipart upload. When `surveyId` and `questionId` are set, the API applies the * survey question’s `acceptedTypes` / `maxSize` rules. */ upload(file: Blob | ArrayBuffer | Uint8Array, options?: UploadFileOptions): Promise; download(id: string): Promise; /** Remove an uploaded file (and backing object, when using cloud storage). */ delete(id: string): Promise; } export {}; //# sourceMappingURL=client.d.ts.map