@xmodeai/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["toQuery"],"sources":["../src/core/errors.ts","../src/core/retry.ts","../src/core/request.ts","../src/core/pagination.ts","../src/resources/balance.ts","../src/resources/end-users.ts","../src/core/poll.ts","../src/resources/generations.ts","../src/resources/videos.ts","../src/version.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["import type { ApiErrorBody, GenerationRecord, VideoRecord } from '../types';\n\n/** Base class for every error thrown by the SDK. */\nexport class XModeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'XModeError';\n }\n}\n\nexport interface XModeAPIErrorInit {\n status: number;\n code: string;\n message: string;\n fields?: Record<string, string>;\n requestId?: string;\n retryAfter?: number;\n}\n\n/**\n * An error response from the API. The concrete subclass is chosen by the stable\n * `error.code` contract; an unrecognized code yields a plain `XModeAPIError`\n * (forward-compat — a new server code never crashes error handling).\n */\nexport class XModeAPIError extends XModeError {\n readonly status: number;\n readonly code: string;\n readonly fields?: Record<string, string>;\n /** Value of the `X-XMode-Request-Id` response header, when present. */\n readonly requestId?: string;\n\n constructor(init: XModeAPIErrorInit) {\n super(init.message);\n this.name = 'XModeAPIError';\n this.status = init.status;\n this.code = init.code;\n this.fields = init.fields;\n this.requestId = init.requestId;\n }\n}\n\n/** 400 `validation_error` — request failed schema validation. `fields` lists offending paths. */\nexport class ValidationError extends XModeAPIError {\n constructor(init: XModeAPIErrorInit) {\n super(init);\n this.name = 'ValidationError';\n }\n}\n\n/** 401 `unauthorized` — missing or invalid API key. */\nexport class AuthenticationError extends XModeAPIError {\n constructor(init: XModeAPIErrorInit) {\n super(init);\n this.name = 'AuthenticationError';\n }\n}\n\n/** 403 `forbidden` / `account_blocked` — the action is not allowed. */\nexport class PermissionDeniedError extends XModeAPIError {\n constructor(init: XModeAPIErrorInit) {\n super(init);\n this.name = 'PermissionDeniedError';\n }\n}\n\n/** 404 `not_found` — the resource does not exist (scoped to your account). */\nexport class NotFoundError extends XModeAPIError {\n constructor(init: XModeAPIErrorInit) {\n super(init);\n this.name = 'NotFoundError';\n }\n}\n\n/** 409 `conflict` — e.g. deleting an end-user that still has pending generations. */\nexport class ConflictError extends XModeAPIError {\n constructor(init: XModeAPIErrorInit) {\n super(init);\n this.name = 'ConflictError';\n }\n}\n\n/** 429 `rate_limited` — too many requests. `retryAfter` (seconds) set when provided. */\nexport class RateLimitError extends XModeAPIError {\n readonly retryAfter?: number;\n constructor(init: XModeAPIErrorInit) {\n super(init);\n this.name = 'RateLimitError';\n this.retryAfter = init.retryAfter;\n }\n}\n\n/** 402 `payment_required` — insufficient xTokens balance. */\nexport class PaymentRequiredError extends XModeAPIError {\n constructor(init: XModeAPIErrorInit) {\n super(init);\n this.name = 'PaymentRequiredError';\n }\n}\n\n/** 422 `content_policy` — the prompt or inputs were rejected by the content filter. */\nexport class ContentPolicyError extends XModeAPIError {\n constructor(init: XModeAPIErrorInit) {\n super(init);\n this.name = 'ContentPolicyError';\n }\n}\n\n/** `provider_error` / `provider_timeout` — upstream generation failed; safe to retry. */\nexport class ProviderError extends XModeAPIError {\n constructor(init: XModeAPIErrorInit) {\n super(init);\n this.name = 'ProviderError';\n }\n}\n\n/** `internal_error` — unexpected server-side failure. */\nexport class InternalServerError extends XModeAPIError {\n constructor(init: XModeAPIErrorInit) {\n super(init);\n this.name = 'InternalServerError';\n }\n}\n\n/** A network-level failure (DNS, connection reset, fetch threw) before a response was received. */\nexport class APIConnectionError extends XModeError {\n override readonly cause?: unknown;\n constructor(message = 'Connection error', cause?: unknown) {\n super(message);\n this.name = 'APIConnectionError';\n this.cause = cause;\n }\n}\n\n/** The request exceeded the configured `timeout` before a response arrived. */\nexport class APIConnectionTimeoutError extends APIConnectionError {\n constructor(message = 'Request timed out') {\n super(message);\n this.name = 'APIConnectionTimeoutError';\n }\n}\n\n/** A `*.wait` / `*.createAndWait` poll did not reach a terminal status in time. */\nexport class XModePollTimeoutError extends XModeError {\n /** The most recent record observed before the timeout. */\n readonly lastRecord: GenerationRecord | VideoRecord;\n constructor(message: string, lastRecord: GenerationRecord | VideoRecord) {\n super(message);\n this.name = 'XModePollTimeoutError';\n this.lastRecord = lastRecord;\n }\n}\n\nconst CODE_TO_CLASS: Record<string, new (init: XModeAPIErrorInit) => XModeAPIError> = {\n validation_error: ValidationError,\n unauthorized: AuthenticationError,\n account_blocked: AuthenticationError,\n forbidden: PermissionDeniedError,\n not_found: NotFoundError,\n conflict: ConflictError,\n rate_limited: RateLimitError,\n payment_required: PaymentRequiredError,\n content_policy: ContentPolicyError,\n provider_error: ProviderError,\n provider_timeout: ProviderError,\n internal_error: InternalServerError,\n};\n\nfunction isErrorBody(value: unknown): value is ApiErrorBody {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'error' in value &&\n typeof (value as { error: unknown }).error === 'object' &&\n (value as { error: unknown }).error !== null\n );\n}\n\n/**\n * Build the right error instance from a non-2xx response. Tolerant: a non-JSON\n * body or an unknown `code` still yields a usable `XModeAPIError`, never a\n * secondary parse error.\n */\nexport function castAPIError(\n status: number,\n body: unknown,\n rawText: string,\n requestId: string | undefined,\n retryAfter: number | undefined,\n): XModeAPIError {\n let code = `http_${status}`;\n let message = rawText || `Request failed with status ${status}`;\n let fields: Record<string, string> | undefined;\n\n if (isErrorBody(body)) {\n const err = body.error;\n if (typeof err.code === 'string' && err.code) code = err.code;\n if (typeof err.message === 'string' && err.message) message = err.message;\n if (err.fields && typeof err.fields === 'object') fields = err.fields;\n }\n\n const init: XModeAPIErrorInit = { status, code, message, fields, requestId, retryAfter };\n const Cls = CODE_TO_CLASS[code];\n if (Cls) return new Cls(init);\n // Fall back to status-based mapping for unknown codes, else the base class.\n if (status === 429) return new RateLimitError(init);\n if (status === 404) return new NotFoundError(init);\n if (status === 401) return new AuthenticationError(init);\n if (status === 403) return new PermissionDeniedError(init);\n return new XModeAPIError(init);\n}\n","const MAX_BACKOFF_MS = 8_000;\nconst RETRY_AFTER_CAP_MS = 60_000;\n\n/**\n * Parse a `Retry-After` header into milliseconds. Supports both the\n * delta-seconds form (`\"3\"`) and the HTTP-date form. Returns null when absent\n * or unparseable.\n */\nexport function parseRetryAfterMs(header: string | null): number | null {\n if (!header) return null;\n const seconds = Number(header);\n if (Number.isFinite(seconds)) return Math.max(0, seconds * 1000);\n const date = Date.parse(header);\n if (!Number.isNaN(date)) return Math.max(0, date - Date.now());\n return null;\n}\n\n/** Same as {@link parseRetryAfterMs} but in whole seconds, for `RateLimitError.retryAfter`. */\nexport function parseRetryAfterSeconds(header: string | null): number | undefined {\n const ms = parseRetryAfterMs(header);\n return ms === null ? undefined : Math.ceil(ms / 1000);\n}\n\n/**\n * Exponential backoff with full jitter. `Retry-After`, when present, sets a\n * floor (capped at 60s) so we never retry sooner than the server asked.\n */\nexport function backoffDelay(attempt: number, retryAfterHeader: string | null): number {\n const exp = Math.min(MAX_BACKOFF_MS, 500 * 2 ** attempt);\n const jittered = exp / 2 + Math.random() * (exp / 2);\n const retryAfter = parseRetryAfterMs(retryAfterHeader);\n if (retryAfter !== null) return Math.min(RETRY_AFTER_CAP_MS, Math.max(retryAfter, jittered));\n return jittered;\n}\n\n/** Promise-based sleep that rejects if the (optional) signal aborts. */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (signal?.aborted) {\n reject(signal.reason ?? new Error('Aborted'));\n return;\n }\n const onAbort = () => {\n clearTimeout(timer);\n reject(signal?.reason ?? new Error('Aborted'));\n };\n const timer = setTimeout(() => {\n signal?.removeEventListener('abort', onAbort);\n resolve();\n }, ms);\n signal?.addEventListener('abort', onAbort, { once: true });\n });\n}\n","import { APIConnectionError, APIConnectionTimeoutError, castAPIError } from './errors';\nimport { backoffDelay, parseRetryAfterSeconds, sleep } from './retry';\n\nexport type HttpMethod = 'GET' | 'POST' | 'DELETE';\n\n/**\n * Retry policy for a request:\n * - `'idempotent'` — safe to retry on network errors / 408 / 429 / 5xx.\n * - `'create'` — non-idempotent (debits xTokens, no idempotency key);\n * retried ONLY on 429 (rejected before any debit).\n */\nexport type RetryPolicy = 'idempotent' | 'create';\n\nexport type QueryParams = Record<string, string | number | boolean | undefined>;\n\n/** Per-call overrides accepted by every resource method. */\nexport interface RequestOptions {\n signal?: AbortSignal;\n /** Per-attempt timeout in ms. Defaults to the client `timeout`. */\n timeout?: number;\n /** Overrides the client `maxRetries` for this call. */\n maxRetries?: number;\n /** Extra headers merged on top of the defaults. */\n headers?: Record<string, string>;\n}\n\n/** Arguments for the low-level escape hatch `client.request()`. */\nexport interface RequestArgs extends RequestOptions {\n method: HttpMethod;\n path: string;\n body?: unknown;\n query?: QueryParams;\n /** Defaults to `'idempotent'` for GET, `'create'` for POST/DELETE. */\n policy?: RetryPolicy;\n}\n\nexport interface ResolvedConfig {\n baseUrl: string;\n apiKey: string;\n timeout: number;\n maxRetries: number;\n fetch: typeof fetch;\n defaultHeaders: Record<string, string>;\n userAgent: string;\n}\n\nfunction defaultPolicy(method: HttpMethod): RetryPolicy {\n return method === 'GET' ? 'idempotent' : 'create';\n}\n\nfunction isRetryableStatus(status: number, policy: RetryPolicy): boolean {\n if (policy === 'create') return status === 429;\n return status === 408 || status === 429 || status >= 500;\n}\n\nfunction buildUrl(baseUrl: string, path: string, query: QueryParams | undefined): string {\n let url = baseUrl + path;\n if (query) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) params.append(key, String(value));\n }\n const qs = params.toString();\n if (qs) url += (url.includes('?') ? '&' : '?') + qs;\n }\n return url;\n}\n\nfunction buildHeaders(config: ResolvedConfig, args: RequestArgs): Record<string, string> {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${config.apiKey}`,\n Accept: 'application/json',\n 'User-Agent': config.userAgent,\n ...config.defaultHeaders,\n ...args.headers,\n };\n if (args.body !== undefined) headers['Content-Type'] = 'application/json';\n return headers;\n}\n\nfunction combineSignals(user: AbortSignal | undefined, timeout: AbortSignal): AbortSignal {\n if (!user) return timeout;\n if (typeof AbortSignal.any === 'function') return AbortSignal.any([user, timeout]);\n const controller = new AbortController();\n const relay = (s: AbortSignal) => controller.abort(s.reason);\n for (const s of [user, timeout]) {\n if (s.aborted) relay(s);\n else s.addEventListener('abort', () => relay(s), { once: true });\n }\n return controller.signal;\n}\n\nasync function parseSuccessBody<T>(res: Response): Promise<T> {\n if (res.status === 204) return undefined as T;\n const text = await res.text();\n if (!text) return undefined as T;\n return JSON.parse(text) as T;\n}\n\nfunction safeJsonParse(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Execute a single logical request, applying auth, timeout, the tolerant JSON\n * reader (responses are never schema-validated), and the retry loop.\n */\nexport async function execute<T>(config: ResolvedConfig, args: RequestArgs): Promise<T> {\n const policy = args.policy ?? defaultPolicy(args.method);\n const maxRetries = args.maxRetries ?? config.maxRetries;\n const url = buildUrl(config.baseUrl, args.path, args.query);\n const headers = buildHeaders(config, args);\n const body = args.body === undefined ? undefined : JSON.stringify(args.body);\n\n for (let attempt = 0; ; attempt++) {\n const timeoutSignal = AbortSignal.timeout(args.timeout ?? config.timeout);\n let res: Response;\n\n try {\n res = await config.fetch(url, {\n method: args.method,\n headers,\n body,\n signal: combineSignals(args.signal, timeoutSignal),\n });\n } catch (err) {\n // A caller-initiated abort is final — never retry, surface its reason.\n if (args.signal?.aborted) {\n throw args.signal.reason instanceof Error\n ? args.signal.reason\n : new APIConnectionError('Request aborted', err);\n }\n // Network failure or timeout: retry only when the request is idempotent.\n if (policy === 'idempotent' && attempt < maxRetries) {\n await sleep(backoffDelay(attempt, null), args.signal);\n continue;\n }\n if (timeoutSignal.aborted) throw new APIConnectionTimeoutError();\n throw new APIConnectionError('Connection error', err);\n }\n\n const requestId = res.headers.get('x-xmode-request-id') ?? undefined;\n\n if (res.ok) return await parseSuccessBody<T>(res);\n\n if (isRetryableStatus(res.status, policy) && attempt < maxRetries) {\n await sleep(backoffDelay(attempt, res.headers.get('retry-after')), args.signal);\n continue;\n }\n\n const rawText = await res.text().catch(() => '');\n throw castAPIError(\n res.status,\n safeJsonParse(rawText),\n rawText,\n requestId,\n parseRetryAfterSeconds(res.headers.get('retry-after')),\n );\n }\n}\n","import type { QueryParams } from './request';\n\ninterface ListShape<T> {\n items: T[];\n page: number;\n pageSize: number;\n hasMore: boolean;\n}\n\ntype PageFetcher<T> = (query: QueryParams) => Promise<ListShape<T>>;\n\n/**\n * One page of a paginated list, plus the ability to fetch the next page and to\n * iterate every item across all pages with `for await`.\n */\nexport class Page<T> implements AsyncIterable<T> {\n readonly items: T[];\n readonly page: number;\n readonly pageSize: number;\n readonly hasMore: boolean;\n\n private readonly fetcher: PageFetcher<T>;\n private readonly query: QueryParams;\n\n constructor(data: ListShape<T>, fetcher: PageFetcher<T>, query: QueryParams) {\n this.items = data.items;\n this.page = data.page;\n this.pageSize = data.pageSize;\n this.hasMore = data.hasMore;\n this.fetcher = fetcher;\n this.query = query;\n }\n\n /** Fetch the next page, or `null` when there are no more. */\n async getNextPage(): Promise<Page<T> | null> {\n if (!this.hasMore) return null;\n const nextQuery: QueryParams = { ...this.query, page: this.page + 1 };\n const data = await this.fetcher(nextQuery);\n return new Page<T>(data, this.fetcher, nextQuery);\n }\n\n async *[Symbol.asyncIterator](): AsyncIterableIterator<T> {\n let current: Page<T> | null = this;\n while (current) {\n for (const item of current.items) yield item;\n current = await current.getNextPage();\n }\n }\n}\n\n/**\n * The return type of `list()` methods. `await` it to get the first {@link Page};\n * `for await (... of ...)` it to stream every item across all pages.\n */\nexport class PagePromise<T> extends Promise<Page<T>> implements AsyncIterable<T> {\n // Ensure `.then`/`.catch`/`.finally` produce a plain Promise, not a PagePromise\n // (whose constructor signature differs), avoiding subclassing pitfalls.\n static override get [Symbol.species](): PromiseConstructor {\n return Promise;\n }\n\n async *[Symbol.asyncIterator](): AsyncIterableIterator<T> {\n const page = await this;\n yield* page;\n }\n}\n\n/** Build a {@link PagePromise} from a thunk that loads the first page. */\nexport function makePagePromise<T>(load: () => Promise<Page<T>>): PagePromise<T> {\n return new PagePromise<T>((resolve, reject) => {\n load().then(resolve, reject);\n });\n}\n","import type { XMode } from '../client';\nimport { makePagePromise, Page, type PagePromise } from '../core/pagination';\nimport type { QueryParams, RequestOptions } from '../core/request';\nimport type {\n BalanceHistoryParams,\n BalanceHistoryResponse,\n BalanceLedgerEntry,\n BalanceResponse,\n} from '../types';\n\nexport class Balance {\n constructor(private readonly client: XMode) {}\n\n /** Current xTokens balance. */\n get(options?: RequestOptions): Promise<BalanceResponse> {\n return this.client.request<BalanceResponse>({\n method: 'GET',\n path: '/v1/balance',\n policy: 'idempotent',\n ...options,\n });\n }\n\n /** Paginated ledger of balance changes. `await` for one page, or `for await` for all. */\n history(\n params: BalanceHistoryParams = {},\n options?: RequestOptions,\n ): PagePromise<BalanceLedgerEntry> {\n const query: QueryParams = { page: params.page, pageSize: params.pageSize };\n const fetcher = (q: QueryParams): Promise<BalanceHistoryResponse> =>\n this.client.request<BalanceHistoryResponse>({\n method: 'GET',\n path: '/v1/balance/history',\n query: q,\n policy: 'idempotent',\n ...options,\n });\n return makePagePromise(async () => new Page(await fetcher(query), fetcher, query));\n }\n}\n","import type { XMode } from '../client';\nimport { makePagePromise, Page, type PagePromise } from '../core/pagination';\nimport type { QueryParams, RequestOptions } from '../core/request';\nimport type {\n BlockEndUserResponse,\n DeleteEndUserResponse,\n EndUserListParams,\n EndUserListResponse,\n EndUserRecord,\n UnblockEndUserResponse,\n} from '../types';\n\nfunction toQuery(params: EndUserListParams): QueryParams {\n return {\n page: params.page,\n pageSize: params.pageSize,\n // Server expects the strict string enum 'true' | 'false'.\n blocked: params.blocked === undefined ? undefined : String(params.blocked),\n email: params.email,\n };\n}\n\nexport class EndUsers {\n constructor(private readonly client: XMode) {}\n\n /** List your downstream end-users. `await` for one page, or `for await` for all. */\n list(params: EndUserListParams = {}, options?: RequestOptions): PagePromise<EndUserRecord> {\n const query = toQuery(params);\n const fetcher = (q: QueryParams): Promise<EndUserListResponse> =>\n this.client.request<EndUserListResponse>({\n method: 'GET',\n path: '/v1/end-users',\n query: q,\n policy: 'idempotent',\n ...options,\n });\n return makePagePromise(async () => new Page(await fetcher(query), fetcher, query));\n }\n\n /** Block an end-user. New generations are refused; pending ones still finish. */\n block(email: string, options?: RequestOptions): Promise<BlockEndUserResponse> {\n return this.client.request<BlockEndUserResponse>({\n method: 'POST',\n path: `/v1/end-users/${encodeURIComponent(email)}/block`,\n policy: 'idempotent',\n ...options,\n });\n }\n\n /** Unblock a previously blocked end-user. */\n unblock(email: string, options?: RequestOptions): Promise<UnblockEndUserResponse> {\n return this.client.request<UnblockEndUserResponse>({\n method: 'POST',\n path: `/v1/end-users/${encodeURIComponent(email)}/unblock`,\n policy: 'idempotent',\n ...options,\n });\n }\n\n /**\n * Delete an end-user and all their generations and stored media. Fails with a\n * `ConflictError` (409) if the end-user still has pending generations.\n */\n delete(email: string, options?: RequestOptions): Promise<DeleteEndUserResponse> {\n return this.client.request<DeleteEndUserResponse>({\n method: 'DELETE',\n path: `/v1/end-users/${encodeURIComponent(email)}`,\n policy: 'idempotent',\n ...options,\n });\n }\n}\n","import type { GenerationRecord, VideoRecord } from '../types';\n\nimport { XModePollTimeoutError } from './errors';\nimport { sleep } from './retry';\n\nexport interface WaitOptions {\n /** How often to poll, in ms. Defaults to 5000 (the recommended interval). */\n pollInterval?: number;\n /** Overall budget before giving up, in ms. */\n timeout?: number;\n /** Abort the wait early. */\n signal?: AbortSignal;\n}\n\nexport const DEFAULT_POLL_INTERVAL_MS = 5_000;\nexport const DEFAULT_POLL_TIMEOUT_MS = 10 * 60_000;\n\nconst TERMINAL_STATUSES = new Set(['succeeded', 'failed', 'expired']);\n\n/** True once a record reaches a status from which it will not change. */\nexport function isTerminal(record: { status: string }): boolean {\n return TERMINAL_STATUSES.has(record.status);\n}\n\n/**\n * Poll `fetchRecord` until it returns a terminal record, then resolve with it.\n *\n * Tolerant of statuses this SDK version does not know: anything outside the\n * terminal set is treated as \"still in progress\", so a server-added status\n * never aborts a wait. Throws {@link XModePollTimeoutError} (carrying the last\n * record seen) if the budget elapses first.\n */\nexport async function pollUntilTerminal<T extends { status: string }>(\n fetchRecord: () => Promise<T>,\n options: WaitOptions = {},\n): Promise<T> {\n const pollInterval = options.pollInterval ?? DEFAULT_POLL_INTERVAL_MS;\n const timeout = options.timeout ?? DEFAULT_POLL_TIMEOUT_MS;\n const deadline = Date.now() + timeout;\n\n for (;;) {\n const record = await fetchRecord();\n if (isTerminal(record)) return record;\n if (Date.now() + pollInterval >= deadline) {\n throw new XModePollTimeoutError(\n `Did not reach a terminal status within ${timeout}ms (last status: ${record.status}).`,\n record as unknown as GenerationRecord | VideoRecord,\n );\n }\n await sleep(pollInterval, options.signal);\n }\n}\n","import type { XMode } from '../client';\nimport { makePagePromise, Page, type PagePromise } from '../core/pagination';\nimport { pollUntilTerminal, type WaitOptions } from '../core/poll';\nimport type { QueryParams, RequestOptions } from '../core/request';\nimport type {\n CreateGenerationInput,\n GenerationListParams,\n GenerationListResponse,\n GenerationRecord,\n QueuedGenerationRecord,\n} from '../types';\n\nfunction toQuery(params: GenerationListParams): QueryParams {\n return {\n page: params.page,\n pageSize: params.pageSize,\n endUserEmail: params.endUserEmail,\n status: params.status,\n createdAfter: params.createdAfter,\n };\n}\n\nexport class Generations {\n constructor(private readonly client: XMode) {}\n\n /** Enqueue an image generation. Resolves with the `queued` record (202). */\n create(input: CreateGenerationInput, options?: RequestOptions): Promise<QueuedGenerationRecord> {\n return this.client.request<QueuedGenerationRecord>({\n method: 'POST',\n path: '/v1/generations',\n body: input,\n policy: 'create',\n ...options,\n });\n }\n\n /** Fetch the current state of a generation. */\n get(requestId: string, options?: RequestOptions): Promise<GenerationRecord> {\n return this.client.request<GenerationRecord>({\n method: 'GET',\n path: `/v1/generations/${encodeURIComponent(requestId)}`,\n policy: 'idempotent',\n ...options,\n });\n }\n\n /** List generations. `await` for the first page, or `for await` to stream all items. */\n list(params: GenerationListParams = {}, options?: RequestOptions): PagePromise<GenerationRecord> {\n const query = toQuery(params);\n const fetcher = (q: QueryParams): Promise<GenerationListResponse> =>\n this.client.request<GenerationListResponse>({\n method: 'GET',\n path: '/v1/generations',\n query: q,\n policy: 'idempotent',\n ...options,\n });\n return makePagePromise(async () => new Page(await fetcher(query), fetcher, query));\n }\n\n /** Create a generation and poll until it reaches a terminal status. */\n async createAndWait(\n input: CreateGenerationInput,\n options?: WaitOptions,\n ): Promise<GenerationRecord> {\n const queued = await this.create(input, { signal: options?.signal });\n return this.wait(queued.requestId, options);\n }\n\n /** Poll an existing generation until it reaches a terminal status. */\n wait(requestId: string, options?: WaitOptions): Promise<GenerationRecord> {\n return pollUntilTerminal(() => this.get(requestId, { signal: options?.signal }), options);\n }\n}\n","import type { XMode } from '../client';\nimport { pollUntilTerminal, type WaitOptions } from '../core/poll';\nimport type { RequestOptions } from '../core/request';\nimport type { CreateVideoInput, QueuedVideoRecord, VideoRecord } from '../types';\n\nconst DEFAULT_VIDEO_TIMEOUT_MS = 20 * 60_000;\n\nexport class Videos {\n constructor(private readonly client: XMode) {}\n\n /** Enqueue a video generation. Resolves with the `queued` record (202). */\n create(input: CreateVideoInput, options?: RequestOptions): Promise<QueuedVideoRecord> {\n return this.client.request<QueuedVideoRecord>({\n method: 'POST',\n path: '/v1/videos',\n body: input,\n policy: 'create',\n ...options,\n });\n }\n\n /** Fetch the current state of a video. */\n get(requestId: string, options?: RequestOptions): Promise<VideoRecord> {\n return this.client.request<VideoRecord>({\n method: 'GET',\n path: `/v1/videos/${encodeURIComponent(requestId)}`,\n policy: 'idempotent',\n ...options,\n });\n }\n\n /** Create a video and poll until it reaches a terminal status. */\n async createAndWait(input: CreateVideoInput, options?: WaitOptions): Promise<VideoRecord> {\n const queued = await this.create(input, { signal: options?.signal });\n return this.wait(queued.requestId, options);\n }\n\n /** Poll an existing video until it reaches a terminal status. */\n wait(requestId: string, options?: WaitOptions): Promise<VideoRecord> {\n return pollUntilTerminal(() => this.get(requestId, { signal: options?.signal }), {\n ...options,\n timeout: options?.timeout ?? DEFAULT_VIDEO_TIMEOUT_MS,\n });\n }\n}\n","// `__SDK_VERSION__` is replaced with the package version at build time (tsdown `define`).\n// Declared here so type-checking passes without the build-time substitution.\ndeclare const __SDK_VERSION__: string;\n\nexport const VERSION: string = typeof __SDK_VERSION__ === 'string' ? __SDK_VERSION__ : '0.0.0';\n","import { XModeError } from './core/errors';\nimport { execute, type RequestArgs, type ResolvedConfig } from './core/request';\nimport { Balance } from './resources/balance';\nimport { EndUsers } from './resources/end-users';\nimport { Generations } from './resources/generations';\nimport { Videos } from './resources/videos';\nimport { VERSION } from './version';\n\nexport interface ClientOptions {\n /** API key (`xm_live_...`). Defaults to the `XMODE_API_KEY` environment variable. */\n apiKey?: string;\n /** API base URL. Defaults to `https://api.xmode.ai`. */\n baseUrl?: string;\n /** Per-attempt request timeout in ms. Defaults to 30000. */\n timeout?: number;\n /** Max automatic retries for retryable requests. Defaults to 2. */\n maxRetries?: number;\n /** Custom fetch implementation (for tests or runtimes without a global fetch). */\n fetch?: typeof fetch;\n /** Extra headers sent with every request. */\n defaultHeaders?: Record<string, string>;\n}\n\nconst DEFAULT_BASE_URL = 'https://api.xmode.ai';\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst DEFAULT_MAX_RETRIES = 2;\n\nfunction readEnv(key: string): string | undefined {\n const proc = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process;\n return proc?.env?.[key];\n}\n\nfunction normalizeBaseUrl(url: string): string {\n return url.replace(/\\/+$/, '');\n}\n\n/**\n * The xMode API client.\n *\n * ```ts\n * import XMode from '@xmodeai/sdk';\n * const client = new XMode({ apiKey: process.env.XMODE_API_KEY });\n * const result = await client.generations.createAndWait({\n * endUserEmail: 'alice@your-product.com',\n * model: 'xSD4.5',\n * prompt: 'a red panda astronaut, studio lighting',\n * });\n * ```\n */\nexport class XMode {\n readonly generations: Generations;\n readonly videos: Videos;\n readonly balance: Balance;\n readonly endUsers: EndUsers;\n\n private readonly config: ResolvedConfig;\n\n constructor(options: ClientOptions = {}) {\n const apiKey = options.apiKey ?? readEnv('XMODE_API_KEY');\n if (!apiKey) {\n throw new XModeError(\n 'Missing API key. Pass `apiKey` to new XMode({ apiKey }) or set the XMODE_API_KEY environment variable.',\n );\n }\n\n const fetchImpl =\n options.fetch ??\n (typeof globalThis.fetch === 'function' ? globalThis.fetch.bind(globalThis) : undefined);\n if (!fetchImpl) {\n throw new XModeError(\n 'No global fetch found. Use Node 18+, or pass a `fetch` implementation in the client options.',\n );\n }\n\n this.config = {\n apiKey,\n baseUrl: normalizeBaseUrl(options.baseUrl ?? DEFAULT_BASE_URL),\n timeout: options.timeout ?? DEFAULT_TIMEOUT_MS,\n maxRetries: options.maxRetries ?? DEFAULT_MAX_RETRIES,\n fetch: fetchImpl,\n defaultHeaders: options.defaultHeaders ?? {},\n userAgent: `xmode-sdk/${VERSION}`,\n };\n\n this.generations = new Generations(this);\n this.videos = new Videos(this);\n this.balance = new Balance(this);\n this.endUsers = new EndUsers(this);\n }\n\n /**\n * Low-level escape hatch. Call any endpoint / pass any body before a typed\n * method exists for it (e.g. a brand-new model parameter). Applies the same\n * auth, retry and error handling as the typed resource methods.\n *\n * ```ts\n * await client.request({\n * method: 'POST',\n * path: '/v1/videos',\n * body: { endUserEmail, model: 'xSV2.0', prompt, image, cameraMotion: 'orbit' },\n * });\n * ```\n */\n request<T = unknown>(args: RequestArgs): Promise<T> {\n return execute<T>(this.config, args);\n }\n}\n","import { XMode } from './client';\n\nexport { XMode };\nexport type { ClientOptions } from './client';\n\nexport { Page, PagePromise } from './core/pagination';\nexport {\n DEFAULT_POLL_INTERVAL_MS,\n DEFAULT_POLL_TIMEOUT_MS,\n isTerminal,\n pollUntilTerminal,\n type WaitOptions,\n} from './core/poll';\nexport type {\n HttpMethod,\n QueryParams,\n RequestArgs,\n RequestOptions,\n RetryPolicy,\n} from './core/request';\n\nexport {\n APIConnectionError,\n APIConnectionTimeoutError,\n AuthenticationError,\n ConflictError,\n ContentPolicyError,\n InternalServerError,\n NotFoundError,\n PaymentRequiredError,\n PermissionDeniedError,\n ProviderError,\n RateLimitError,\n ValidationError,\n XModeAPIError,\n XModeError,\n XModePollTimeoutError,\n} from './core/errors';\n\nexport * from './types';\nexport { VERSION } from './version';\n\nexport default XMode;\n"],"mappings":";;;;;;AAGA,IAAa,aAAb,cAAgC,MAAM;CACpC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;;;;AAgBA,IAAa,gBAAb,cAAmC,WAAW;CAC5C;CACA;CACA;;CAEA;CAEA,YAAY,MAAyB;EACnC,MAAM,KAAK,OAAO;EAClB,KAAK,OAAO;EACZ,KAAK,SAAS,KAAK;EACnB,KAAK,OAAO,KAAK;EACjB,KAAK,SAAS,KAAK;EACnB,KAAK,YAAY,KAAK;CACxB;AACF;;AAGA,IAAa,kBAAb,cAAqC,cAAc;CACjD,YAAY,MAAyB;EACnC,MAAM,IAAI;EACV,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,sBAAb,cAAyC,cAAc;CACrD,YAAY,MAAyB;EACnC,MAAM,IAAI;EACV,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,wBAAb,cAA2C,cAAc;CACvD,YAAY,MAAyB;EACnC,MAAM,IAAI;EACV,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,gBAAb,cAAmC,cAAc;CAC/C,YAAY,MAAyB;EACnC,MAAM,IAAI;EACV,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,gBAAb,cAAmC,cAAc;CAC/C,YAAY,MAAyB;EACnC,MAAM,IAAI;EACV,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,iBAAb,cAAoC,cAAc;CAChD;CACA,YAAY,MAAyB;EACnC,MAAM,IAAI;EACV,KAAK,OAAO;EACZ,KAAK,aAAa,KAAK;CACzB;AACF;;AAGA,IAAa,uBAAb,cAA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AkB,CAAC;GAC3C,WAAW,aAAa;EAC1B;EAEA,KAAK,cAAc,IAAI,YAAY,IAAI;EACvC,KAAK,SAAS,IAAI,OAAO,IAAI;EAC7B,KAAK,UAAU,IAAI,QAAQ,IAAI;EAC/B,KAAK,WAAW,IAAI,SAAS,IAAI;CACnC;;;;;;;;;;;;;;CAeA,QAAqB,MAA+B;EAClD,OAAO,QAAW,KAAK,QAAQ,IAAI;CACrC;AACF;;;AChEA,IAAA,cAAe"}
@@ -0,0 +1,288 @@
1
+ import { A as KnownImageModel, B as SucceededGenerationRecord, C as GenerationListParams, D as ImageRecord, E as ImageModel, F as QueuedGenerationRecord, G as VideoModel, H as UnblockEndUserResponse, I as QueuedVideoRecord, J as VideoResolution, K as VideoRecord, L as ResponseFormat, M as KnownVideoModel, N as ProcessingGenerationRecord, O as ImageSize, P as ProcessingVideoRecord, R as SizePreset, S as GenerationError, T as GenerationRecord, U as VideoCost, V as SucceededVideoRecord, W as VideoError, _ as ExpiredGenerationRecord, a as BalanceHistoryResponse, b as FailedVideoRecord, c as BalanceLedgerType, d as CreateGenerationInput, f as CreateVideoInput, g as EndUserRecord, h as EndUserListResponse, i as BalanceHistoryParams, j as KnownStatus, k as KnownApiErrorCode, l as BalanceResponse, m as EndUserListParams, n as ApiErrorCode, o as BalanceLedgerEntry, p as DeleteEndUserResponse, q as VideoRecordItem, r as AspectRatio, s as BalanceLedgerReason, t as ApiErrorBody, u as BlockEndUserResponse, v as ExpiredVideoRecord, w as GenerationListResponse, x as GenerationCost, y as FailedGenerationRecord, z as Status } from "./types-BLVayOx3.cjs";
2
+
3
+ //#region src/core/request.d.ts
4
+ type HttpMethod = 'GET' | 'POST' | 'DELETE';
5
+ /**
6
+ * Retry policy for a request:
7
+ * - `'idempotent'` — safe to retry on network errors / 408 / 429 / 5xx.
8
+ * - `'create'` — non-idempotent (debits xTokens, no idempotency key);
9
+ * retried ONLY on 429 (rejected before any debit).
10
+ */
11
+ type RetryPolicy = 'idempotent' | 'create';
12
+ type QueryParams = Record<string, string | number | boolean | undefined>;
13
+ /** Per-call overrides accepted by every resource method. */
14
+ interface RequestOptions {
15
+ signal?: AbortSignal;
16
+ /** Per-attempt timeout in ms. Defaults to the client `timeout`. */
17
+ timeout?: number;
18
+ /** Overrides the client `maxRetries` for this call. */
19
+ maxRetries?: number;
20
+ /** Extra headers merged on top of the defaults. */
21
+ headers?: Record<string, string>;
22
+ }
23
+ /** Arguments for the low-level escape hatch `client.request()`. */
24
+ interface RequestArgs extends RequestOptions {
25
+ method: HttpMethod;
26
+ path: string;
27
+ body?: unknown;
28
+ query?: QueryParams;
29
+ /** Defaults to `'idempotent'` for GET, `'create'` for POST/DELETE. */
30
+ policy?: RetryPolicy;
31
+ }
32
+ //#endregion
33
+ //#region src/core/pagination.d.ts
34
+ interface ListShape<T> {
35
+ items: T[];
36
+ page: number;
37
+ pageSize: number;
38
+ hasMore: boolean;
39
+ }
40
+ type PageFetcher<T> = (query: QueryParams) => Promise<ListShape<T>>;
41
+ /**
42
+ * One page of a paginated list, plus the ability to fetch the next page and to
43
+ * iterate every item across all pages with `for await`.
44
+ */
45
+ declare class Page<T> implements AsyncIterable<T> {
46
+ readonly items: T[];
47
+ readonly page: number;
48
+ readonly pageSize: number;
49
+ readonly hasMore: boolean;
50
+ private readonly fetcher;
51
+ private readonly query;
52
+ constructor(data: ListShape<T>, fetcher: PageFetcher<T>, query: QueryParams);
53
+ /** Fetch the next page, or `null` when there are no more. */
54
+ getNextPage(): Promise<Page<T> | null>;
55
+ [Symbol.asyncIterator](): AsyncIterableIterator<T>;
56
+ }
57
+ /**
58
+ * The return type of `list()` methods. `await` it to get the first {@link Page};
59
+ * `for await (... of ...)` it to stream every item across all pages.
60
+ */
61
+ declare class PagePromise<T> extends Promise<Page<T>> implements AsyncIterable<T> {
62
+ static get [Symbol.species](): PromiseConstructor;
63
+ [Symbol.asyncIterator](): AsyncIterableIterator<T>;
64
+ }
65
+ //#endregion
66
+ //#region src/resources/balance.d.ts
67
+ declare class Balance {
68
+ private readonly client;
69
+ constructor(client: XMode);
70
+ /** Current xTokens balance. */
71
+ get(options?: RequestOptions): Promise<BalanceResponse>;
72
+ /** Paginated ledger of balance changes. `await` for one page, or `for await` for all. */
73
+ history(params?: BalanceHistoryParams, options?: RequestOptions): PagePromise<BalanceLedgerEntry>;
74
+ }
75
+ //#endregion
76
+ //#region src/resources/end-users.d.ts
77
+ declare class EndUsers {
78
+ private readonly client;
79
+ constructor(client: XMode);
80
+ /** List your downstream end-users. `await` for one page, or `for await` for all. */
81
+ list(params?: EndUserListParams, options?: RequestOptions): PagePromise<EndUserRecord>;
82
+ /** Block an end-user. New generations are refused; pending ones still finish. */
83
+ block(email: string, options?: RequestOptions): Promise<BlockEndUserResponse>;
84
+ /** Unblock a previously blocked end-user. */
85
+ unblock(email: string, options?: RequestOptions): Promise<UnblockEndUserResponse>;
86
+ /**
87
+ * Delete an end-user and all their generations and stored media. Fails with a
88
+ * `ConflictError` (409) if the end-user still has pending generations.
89
+ */
90
+ delete(email: string, options?: RequestOptions): Promise<DeleteEndUserResponse>;
91
+ }
92
+ //#endregion
93
+ //#region src/core/poll.d.ts
94
+ interface WaitOptions {
95
+ /** How often to poll, in ms. Defaults to 5000 (the recommended interval). */
96
+ pollInterval?: number;
97
+ /** Overall budget before giving up, in ms. */
98
+ timeout?: number;
99
+ /** Abort the wait early. */
100
+ signal?: AbortSignal;
101
+ }
102
+ declare const DEFAULT_POLL_INTERVAL_MS = 5000;
103
+ declare const DEFAULT_POLL_TIMEOUT_MS: number;
104
+ /** True once a record reaches a status from which it will not change. */
105
+ declare function isTerminal(record: {
106
+ status: string;
107
+ }): boolean;
108
+ /**
109
+ * Poll `fetchRecord` until it returns a terminal record, then resolve with it.
110
+ *
111
+ * Tolerant of statuses this SDK version does not know: anything outside the
112
+ * terminal set is treated as "still in progress", so a server-added status
113
+ * never aborts a wait. Throws {@link XModePollTimeoutError} (carrying the last
114
+ * record seen) if the budget elapses first.
115
+ */
116
+ declare function pollUntilTerminal<T extends {
117
+ status: string;
118
+ }>(fetchRecord: () => Promise<T>, options?: WaitOptions): Promise<T>;
119
+ //#endregion
120
+ //#region src/resources/generations.d.ts
121
+ declare class Generations {
122
+ private readonly client;
123
+ constructor(client: XMode);
124
+ /** Enqueue an image generation. Resolves with the `queued` record (202). */
125
+ create(input: CreateGenerationInput, options?: RequestOptions): Promise<QueuedGenerationRecord>;
126
+ /** Fetch the current state of a generation. */
127
+ get(requestId: string, options?: RequestOptions): Promise<GenerationRecord>;
128
+ /** List generations. `await` for the first page, or `for await` to stream all items. */
129
+ list(params?: GenerationListParams, options?: RequestOptions): PagePromise<GenerationRecord>;
130
+ /** Create a generation and poll until it reaches a terminal status. */
131
+ createAndWait(input: CreateGenerationInput, options?: WaitOptions): Promise<GenerationRecord>;
132
+ /** Poll an existing generation until it reaches a terminal status. */
133
+ wait(requestId: string, options?: WaitOptions): Promise<GenerationRecord>;
134
+ }
135
+ //#endregion
136
+ //#region src/resources/videos.d.ts
137
+ declare class Videos {
138
+ private readonly client;
139
+ constructor(client: XMode);
140
+ /** Enqueue a video generation. Resolves with the `queued` record (202). */
141
+ create(input: CreateVideoInput, options?: RequestOptions): Promise<QueuedVideoRecord>;
142
+ /** Fetch the current state of a video. */
143
+ get(requestId: string, options?: RequestOptions): Promise<VideoRecord>;
144
+ /** Create a video and poll until it reaches a terminal status. */
145
+ createAndWait(input: CreateVideoInput, options?: WaitOptions): Promise<VideoRecord>;
146
+ /** Poll an existing video until it reaches a terminal status. */
147
+ wait(requestId: string, options?: WaitOptions): Promise<VideoRecord>;
148
+ }
149
+ //#endregion
150
+ //#region src/client.d.ts
151
+ interface ClientOptions {
152
+ /** API key (`xm_live_...`). Defaults to the `XMODE_API_KEY` environment variable. */
153
+ apiKey?: string;
154
+ /** API base URL. Defaults to `https://api.xmode.ai`. */
155
+ baseUrl?: string;
156
+ /** Per-attempt request timeout in ms. Defaults to 30000. */
157
+ timeout?: number;
158
+ /** Max automatic retries for retryable requests. Defaults to 2. */
159
+ maxRetries?: number;
160
+ /** Custom fetch implementation (for tests or runtimes without a global fetch). */
161
+ fetch?: typeof fetch;
162
+ /** Extra headers sent with every request. */
163
+ defaultHeaders?: Record<string, string>;
164
+ }
165
+ /**
166
+ * The xMode API client.
167
+ *
168
+ * ```ts
169
+ * import XMode from '@xmodeai/sdk';
170
+ * const client = new XMode({ apiKey: process.env.XMODE_API_KEY });
171
+ * const result = await client.generations.createAndWait({
172
+ * endUserEmail: 'alice@your-product.com',
173
+ * model: 'xSD4.5',
174
+ * prompt: 'a red panda astronaut, studio lighting',
175
+ * });
176
+ * ```
177
+ */
178
+ declare class XMode {
179
+ readonly generations: Generations;
180
+ readonly videos: Videos;
181
+ readonly balance: Balance;
182
+ readonly endUsers: EndUsers;
183
+ private readonly config;
184
+ constructor(options?: ClientOptions);
185
+ /**
186
+ * Low-level escape hatch. Call any endpoint / pass any body before a typed
187
+ * method exists for it (e.g. a brand-new model parameter). Applies the same
188
+ * auth, retry and error handling as the typed resource methods.
189
+ *
190
+ * ```ts
191
+ * await client.request({
192
+ * method: 'POST',
193
+ * path: '/v1/videos',
194
+ * body: { endUserEmail, model: 'xSV2.0', prompt, image, cameraMotion: 'orbit' },
195
+ * });
196
+ * ```
197
+ */
198
+ request<T = unknown>(args: RequestArgs): Promise<T>;
199
+ }
200
+ //#endregion
201
+ //#region src/core/errors.d.ts
202
+ /** Base class for every error thrown by the SDK. */
203
+ declare class XModeError extends Error {
204
+ constructor(message: string);
205
+ }
206
+ interface XModeAPIErrorInit {
207
+ status: number;
208
+ code: string;
209
+ message: string;
210
+ fields?: Record<string, string>;
211
+ requestId?: string;
212
+ retryAfter?: number;
213
+ }
214
+ /**
215
+ * An error response from the API. The concrete subclass is chosen by the stable
216
+ * `error.code` contract; an unrecognized code yields a plain `XModeAPIError`
217
+ * (forward-compat — a new server code never crashes error handling).
218
+ */
219
+ declare class XModeAPIError extends XModeError {
220
+ readonly status: number;
221
+ readonly code: string;
222
+ readonly fields?: Record<string, string>;
223
+ /** Value of the `X-XMode-Request-Id` response header, when present. */
224
+ readonly requestId?: string;
225
+ constructor(init: XModeAPIErrorInit);
226
+ }
227
+ /** 400 `validation_error` — request failed schema validation. `fields` lists offending paths. */
228
+ declare class ValidationError extends XModeAPIError {
229
+ constructor(init: XModeAPIErrorInit);
230
+ }
231
+ /** 401 `unauthorized` — missing or invalid API key. */
232
+ declare class AuthenticationError extends XModeAPIError {
233
+ constructor(init: XModeAPIErrorInit);
234
+ }
235
+ /** 403 `forbidden` / `account_blocked` — the action is not allowed. */
236
+ declare class PermissionDeniedError extends XModeAPIError {
237
+ constructor(init: XModeAPIErrorInit);
238
+ }
239
+ /** 404 `not_found` — the resource does not exist (scoped to your account). */
240
+ declare class NotFoundError extends XModeAPIError {
241
+ constructor(init: XModeAPIErrorInit);
242
+ }
243
+ /** 409 `conflict` — e.g. deleting an end-user that still has pending generations. */
244
+ declare class ConflictError extends XModeAPIError {
245
+ constructor(init: XModeAPIErrorInit);
246
+ }
247
+ /** 429 `rate_limited` — too many requests. `retryAfter` (seconds) set when provided. */
248
+ declare class RateLimitError extends XModeAPIError {
249
+ readonly retryAfter?: number;
250
+ constructor(init: XModeAPIErrorInit);
251
+ }
252
+ /** 402 `payment_required` — insufficient xTokens balance. */
253
+ declare class PaymentRequiredError extends XModeAPIError {
254
+ constructor(init: XModeAPIErrorInit);
255
+ }
256
+ /** 422 `content_policy` — the prompt or inputs were rejected by the content filter. */
257
+ declare class ContentPolicyError extends XModeAPIError {
258
+ constructor(init: XModeAPIErrorInit);
259
+ }
260
+ /** `provider_error` / `provider_timeout` — upstream generation failed; safe to retry. */
261
+ declare class ProviderError extends XModeAPIError {
262
+ constructor(init: XModeAPIErrorInit);
263
+ }
264
+ /** `internal_error` — unexpected server-side failure. */
265
+ declare class InternalServerError extends XModeAPIError {
266
+ constructor(init: XModeAPIErrorInit);
267
+ }
268
+ /** A network-level failure (DNS, connection reset, fetch threw) before a response was received. */
269
+ declare class APIConnectionError extends XModeError {
270
+ readonly cause?: unknown;
271
+ constructor(message?: string, cause?: unknown);
272
+ }
273
+ /** The request exceeded the configured `timeout` before a response arrived. */
274
+ declare class APIConnectionTimeoutError extends APIConnectionError {
275
+ constructor(message?: string);
276
+ }
277
+ /** A `*.wait` / `*.createAndWait` poll did not reach a terminal status in time. */
278
+ declare class XModePollTimeoutError extends XModeError {
279
+ /** The most recent record observed before the timeout. */
280
+ readonly lastRecord: GenerationRecord | VideoRecord;
281
+ constructor(message: string, lastRecord: GenerationRecord | VideoRecord);
282
+ }
283
+ //#endregion
284
+ //#region src/version.d.ts
285
+ declare const VERSION: string;
286
+ //#endregion
287
+ export { APIConnectionError, APIConnectionTimeoutError, ApiErrorBody, ApiErrorCode, AspectRatio, AuthenticationError, BalanceHistoryParams, BalanceHistoryResponse, BalanceLedgerEntry, BalanceLedgerReason, BalanceLedgerType, BalanceResponse, BlockEndUserResponse, type ClientOptions, ConflictError, ContentPolicyError, CreateGenerationInput, CreateVideoInput, DEFAULT_POLL_INTERVAL_MS, DEFAULT_POLL_TIMEOUT_MS, DeleteEndUserResponse, EndUserListParams, EndUserListResponse, EndUserRecord, ExpiredGenerationRecord, ExpiredVideoRecord, FailedGenerationRecord, FailedVideoRecord, GenerationCost, GenerationError, GenerationListParams, GenerationListResponse, GenerationRecord, type HttpMethod, ImageModel, ImageRecord, ImageSize, InternalServerError, KnownApiErrorCode, KnownImageModel, KnownStatus, KnownVideoModel, NotFoundError, Page, PagePromise, PaymentRequiredError, PermissionDeniedError, ProcessingGenerationRecord, ProcessingVideoRecord, ProviderError, type QueryParams, QueuedGenerationRecord, QueuedVideoRecord, RateLimitError, type RequestArgs, type RequestOptions, ResponseFormat, type RetryPolicy, SizePreset, Status, SucceededGenerationRecord, SucceededVideoRecord, UnblockEndUserResponse, VERSION, ValidationError, VideoCost, VideoError, VideoModel, VideoRecord, VideoRecordItem, VideoResolution, type WaitOptions, XMode, XMode as default, XModeAPIError, XModeError, XModePollTimeoutError, isTerminal, pollUntilTerminal };
288
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/core/request.ts","../src/core/pagination.ts","../src/resources/balance.ts","../src/resources/end-users.ts","../src/core/poll.ts","../src/resources/generations.ts","../src/resources/videos.ts","../src/client.ts","../src/core/errors.ts","../src/version.ts"],"mappings":";;;KAGY,UAAA;;;AAAZ;;;;KAQY,WAAA;AAAA,KAEA,WAAA,GAAc,MAAM;;UAGf,cAAA;EACf,MAAA,GAAS,WAAA;EANY;EAQrB,OAAA;EANqB;EAQrB,UAAA;EAR8B;EAU9B,OAAA,GAAU,MAAM;AAAA;;UAID,WAAA,SAAoB,cAAA;EACnC,MAAA,EAAQ,UAAA;EACR,IAAA;EACA,IAAA;EACA,KAAA,GAAQ,WAAA;EAVR;EAYA,MAAA,GAAS,WAAA;AAAA;;;UC/BD,SAAA;EACR,KAAA,EAAO,CAAC;EACR,IAAA;EACA,QAAA;EACA,OAAA;AAAA;AAAA,KAGG,WAAA,OAAkB,KAAA,EAAO,WAAA,KAAgB,OAAA,CAAQ,SAAA,CAAU,CAAA;ADEhE;;;;AAAA,cCIa,IAAA,eAAmB,aAAA,CAAc,CAAA;EAAA,SACnC,KAAA,EAAO,CAAA;EAAA,SACP,IAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,iBAEQ,OAAA;EAAA,iBACA,KAAA;cAEL,IAAA,EAAM,SAAA,CAAU,CAAA,GAAI,OAAA,EAAS,WAAA,CAAY,CAAA,GAAI,KAAA,EAAO,WAAA;;EAU1D,WAAA,IAAe,OAAA,CAAQ,IAAA,CAAK,CAAA;EAAA,CAO1B,MAAA,CAAO,aAAA,KAAkB,qBAAA,CAAsB,CAAA;AAAA;;;;;cAa5C,WAAA,YAAuB,OAAA,CAAQ,IAAA,CAAK,CAAA,cAAe,aAAA,CAAc,CAAA;EAAA,YAGvD,MAAA,CAAO,OAAA,KAAY,kBAAA;EAAA,CA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