@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.
- package/LICENSE +21 -0
- package/README.md +210 -0
- package/dist/index.cjs +694 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +288 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +288 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +667 -0
- package/dist/index.js.map +1 -0
- package/dist/types-BLVayOx3.d.cts +286 -0
- package/dist/types-BLVayOx3.d.cts.map +1 -0
- package/dist/types-BLVayOx3.d.ts +286 -0
- package/dist/types-BLVayOx3.d.ts.map +1 -0
- package/dist/webhooks.cjs +90 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +45 -0
- package/dist/webhooks.d.cts.map +1 -0
- package/dist/webhooks.d.ts +45 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +86 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","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,OAA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B;AAEA,SAAS,iBAAiB,KAAqB;CAC7C,OAAO,IAAI,QAAQ,QAAQ,EAAE;AAC/B;;;;;;;;;;;;;;AAeA,IAAa,QAAb,MAAmB;CACjB;CACA;CACA;CACA;CAEA;CAEA,YAAY,UAAyB,CAAC,GAAG;EACvC,MAAM,SAAS,QAAQ,UAAU,QAAQ,eAAe;EACxD,IAAI,CAAC,QACH,MAAM,IAAI,WACR,wGACF;EAGF,MAAM,YACJ,QAAQ,UACP,OAAO,WAAW,UAAU,aAAa,WAAW,MAAM,KAAK,UAAU,IAAI,KAAA;EAChF,IAAI,CAAC,WACH,MAAM,IAAI,WACR,8FACF;EAGF,KAAK,SAAS;GACZ;GACA,SAAS,iBAAiB,QAAQ,WAAW,gBAAgB;GAC7D,SAAS,QAAQ,WAAW;GAC5B,YAAY,QAAQ,cAAc;GAClC,OAAO;GACP,gBAAgB,QAAQ,kBAAkB,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,286 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Public wire types for the xMode API.
|
|
4
|
+
*
|
|
5
|
+
* These are hand-written and deliberately decoupled from the server's internal
|
|
6
|
+
* schemas so that:
|
|
7
|
+
* - the published package carries ZERO runtime dependencies (no zod), and
|
|
8
|
+
* - new server capabilities never break older SDK versions (forward-compat).
|
|
9
|
+
*
|
|
10
|
+
* Forward-compat rules applied below:
|
|
11
|
+
* - "enum-ish" fields the caller SENDS (model, size) are widened with
|
|
12
|
+
* `| (string & {})` so any future alias compiles while keeping autocomplete.
|
|
13
|
+
* - response unions keep literal `status` branches so `switch (record.status)`
|
|
14
|
+
* narrows cleanly; unknown statuses are handled by BEHAVIOR (polling treats
|
|
15
|
+
* anything outside the terminal set as "in progress"), never by throwing.
|
|
16
|
+
*
|
|
17
|
+
* The `src/__contract__/shared-contract.ts` file statically checks these types
|
|
18
|
+
* against the server's zod schemas, so drift is caught at type-check time.
|
|
19
|
+
*/
|
|
20
|
+
type KnownImageModel = 'xSD4.5';
|
|
21
|
+
type KnownVideoModel = 'xW2.7S';
|
|
22
|
+
/** Image model alias. Known values autocomplete; any future alias also compiles. */
|
|
23
|
+
type ImageModel = KnownImageModel | (string & {});
|
|
24
|
+
/** Video model alias. Known values autocomplete; any future alias also compiles. */
|
|
25
|
+
type VideoModel = KnownVideoModel | (string & {});
|
|
26
|
+
type SizePreset = '2K' | '4K';
|
|
27
|
+
/** Either a preset (`2K`, `4K`) or explicit `WxH` pixels (e.g. `2048x2048`). */
|
|
28
|
+
type ImageSize = SizePreset | (string & {});
|
|
29
|
+
type AspectRatio = 'auto' | 'square' | 'landscape' | 'portrait';
|
|
30
|
+
type ResponseFormat = 'url' | 'b64_json';
|
|
31
|
+
type VideoResolution = '720p' | '1080p';
|
|
32
|
+
type KnownStatus = 'queued' | 'processing' | 'succeeded' | 'failed' | 'expired';
|
|
33
|
+
/** Widened status for filters and forward-compat reads. */
|
|
34
|
+
type Status = KnownStatus | (string & {});
|
|
35
|
+
interface CreateGenerationInput {
|
|
36
|
+
/** Email of YOUR end-user who triggered this generation. Stored lowercase server-side. */
|
|
37
|
+
endUserEmail: string;
|
|
38
|
+
/** English text prompt. 1–8000 chars. */
|
|
39
|
+
prompt: string;
|
|
40
|
+
/** Public model alias, e.g. `'xSD4.5'`. */
|
|
41
|
+
model: ImageModel;
|
|
42
|
+
/** Reference image(s): a single HTTPS URL or an array of 1–10 URLs. */
|
|
43
|
+
references?: string | string[];
|
|
44
|
+
/** Output dimensions: preset (`2K`/`4K`) or explicit `WxH`. Defaults to `2K`. */
|
|
45
|
+
size?: ImageSize;
|
|
46
|
+
/** Aspect-ratio shortcut. Combined with a preset `size`, resolves to explicit pixels. */
|
|
47
|
+
aspectRatio?: AspectRatio;
|
|
48
|
+
/** How many images to generate, 1–15. Each is billed separately. */
|
|
49
|
+
n?: number;
|
|
50
|
+
/** Determinism seed. Omit for a random seed (returned in the record). */
|
|
51
|
+
seed?: number;
|
|
52
|
+
/** Add a small watermark. Defaults to false. */
|
|
53
|
+
watermark?: boolean;
|
|
54
|
+
/** Prompt-adherence strength, 1–20 (typical 5–10). */
|
|
55
|
+
guidanceScale?: number;
|
|
56
|
+
/** `'url'` (signed CDN URLs, default) or `'b64_json'` (inline base64). */
|
|
57
|
+
responseFormat?: ResponseFormat;
|
|
58
|
+
/** `'auto'` to produce a connected series (requires `sequentialOptions.maxImages`). */
|
|
59
|
+
sequential?: 'auto' | 'disabled';
|
|
60
|
+
/** Series length when `sequential: 'auto'`. */
|
|
61
|
+
sequentialOptions?: {
|
|
62
|
+
maxImages: number;
|
|
63
|
+
};
|
|
64
|
+
/** HTTPS URL we POST to once this generation reaches a terminal status. */
|
|
65
|
+
webhookUrl?: string;
|
|
66
|
+
}
|
|
67
|
+
interface ImageRecord {
|
|
68
|
+
/** Stable image id. */
|
|
69
|
+
id: string;
|
|
70
|
+
/** Signed URL, valid ~23h. Absent when `error` is set. */
|
|
71
|
+
url?: string;
|
|
72
|
+
/** Present only when the image is unavailable. Mutually exclusive with `url`. */
|
|
73
|
+
error?: {
|
|
74
|
+
code: 'storage_failed' | (string & {});
|
|
75
|
+
};
|
|
76
|
+
/** Actual dimensions returned by the model. */
|
|
77
|
+
size?: string;
|
|
78
|
+
/** When the signed URL stops working (ISO 8601). */
|
|
79
|
+
expiresAt: string;
|
|
80
|
+
}
|
|
81
|
+
interface GenerationCost {
|
|
82
|
+
xTokens: number;
|
|
83
|
+
}
|
|
84
|
+
interface GenerationError {
|
|
85
|
+
/** Stable error code, e.g. `content_policy`, `provider_error`. */
|
|
86
|
+
code: string;
|
|
87
|
+
/** Human-readable message, safe to surface to end-users. */
|
|
88
|
+
message: string;
|
|
89
|
+
}
|
|
90
|
+
interface GenerationRecordBase {
|
|
91
|
+
requestId: string;
|
|
92
|
+
model: string;
|
|
93
|
+
prompt: string;
|
|
94
|
+
referencesCount: number;
|
|
95
|
+
endUserEmail: string;
|
|
96
|
+
createdAt: string;
|
|
97
|
+
}
|
|
98
|
+
interface QueuedGenerationRecord extends GenerationRecordBase {
|
|
99
|
+
status: 'queued';
|
|
100
|
+
/** Path to GET to poll for status. */
|
|
101
|
+
pollUrl: string;
|
|
102
|
+
}
|
|
103
|
+
interface ProcessingGenerationRecord extends GenerationRecordBase {
|
|
104
|
+
status: 'processing';
|
|
105
|
+
}
|
|
106
|
+
interface SucceededGenerationRecord extends GenerationRecordBase {
|
|
107
|
+
status: 'succeeded';
|
|
108
|
+
images: ImageRecord[];
|
|
109
|
+
cost: GenerationCost;
|
|
110
|
+
finishedAt: string;
|
|
111
|
+
}
|
|
112
|
+
interface FailedGenerationRecord extends GenerationRecordBase {
|
|
113
|
+
status: 'failed';
|
|
114
|
+
error: GenerationError;
|
|
115
|
+
finishedAt: string;
|
|
116
|
+
}
|
|
117
|
+
interface ExpiredGenerationRecord extends GenerationRecordBase {
|
|
118
|
+
status: 'expired';
|
|
119
|
+
finishedAt: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Discriminated by `status`. Returned by `generations.get`, the items of
|
|
123
|
+
* `generations.list`, and the outbound webhook body. At runtime `status` may
|
|
124
|
+
* carry a value newer than this SDK version knows — handle the `default` branch.
|
|
125
|
+
*/
|
|
126
|
+
type GenerationRecord = QueuedGenerationRecord | ProcessingGenerationRecord | SucceededGenerationRecord | FailedGenerationRecord | ExpiredGenerationRecord;
|
|
127
|
+
interface GenerationListParams {
|
|
128
|
+
page?: number;
|
|
129
|
+
pageSize?: number;
|
|
130
|
+
endUserEmail?: string;
|
|
131
|
+
status?: Status;
|
|
132
|
+
/** ISO 8601 — only generations created strictly after this instant. */
|
|
133
|
+
createdAfter?: string;
|
|
134
|
+
}
|
|
135
|
+
interface GenerationListResponse {
|
|
136
|
+
items: GenerationRecord[];
|
|
137
|
+
page: number;
|
|
138
|
+
pageSize: number;
|
|
139
|
+
hasMore: boolean;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Body for `POST /v1/videos` with `model: 'xW2.7S'`. Other video models, when
|
|
143
|
+
* added, may carry different params — send those via `client.request()` until
|
|
144
|
+
* a typed method ships.
|
|
145
|
+
*/
|
|
146
|
+
interface CreateVideoInput {
|
|
147
|
+
endUserEmail: string;
|
|
148
|
+
model: VideoModel;
|
|
149
|
+
prompt: string;
|
|
150
|
+
/** Input image to animate (HTTPS URL). */
|
|
151
|
+
image: string;
|
|
152
|
+
negative_prompt?: string;
|
|
153
|
+
/** Optional audio URL (HTTPS) to drive motion. */
|
|
154
|
+
audio_url?: string;
|
|
155
|
+
/** `'720p'` or `'1080p'`. Defaults to `'1080p'`. */
|
|
156
|
+
resolution?: VideoResolution;
|
|
157
|
+
/** Seconds, 2–15. Defaults to 5. Billed per second. */
|
|
158
|
+
duration?: number;
|
|
159
|
+
/** Auto-expand the prompt before generation. Defaults to true. */
|
|
160
|
+
prompt_extend?: boolean;
|
|
161
|
+
/** Determinism seed, 0–2147483647, or null for auto. */
|
|
162
|
+
seed?: number | null;
|
|
163
|
+
webhookUrl?: string;
|
|
164
|
+
}
|
|
165
|
+
interface VideoRecordItem {
|
|
166
|
+
id: string;
|
|
167
|
+
url?: string;
|
|
168
|
+
error?: {
|
|
169
|
+
code: 'storage_failed' | (string & {});
|
|
170
|
+
};
|
|
171
|
+
duration?: number;
|
|
172
|
+
resolution?: VideoResolution;
|
|
173
|
+
expiresAt: string;
|
|
174
|
+
}
|
|
175
|
+
interface VideoCost {
|
|
176
|
+
xTokens: number;
|
|
177
|
+
}
|
|
178
|
+
interface VideoError {
|
|
179
|
+
code: string;
|
|
180
|
+
message: string;
|
|
181
|
+
}
|
|
182
|
+
interface VideoRecordBase {
|
|
183
|
+
requestId: string;
|
|
184
|
+
model: string;
|
|
185
|
+
prompt: string;
|
|
186
|
+
endUserEmail: string;
|
|
187
|
+
createdAt: string;
|
|
188
|
+
}
|
|
189
|
+
interface QueuedVideoRecord extends VideoRecordBase {
|
|
190
|
+
status: 'queued';
|
|
191
|
+
pollUrl: string;
|
|
192
|
+
}
|
|
193
|
+
interface ProcessingVideoRecord extends VideoRecordBase {
|
|
194
|
+
status: 'processing';
|
|
195
|
+
}
|
|
196
|
+
interface SucceededVideoRecord extends VideoRecordBase {
|
|
197
|
+
status: 'succeeded';
|
|
198
|
+
videos: VideoRecordItem[];
|
|
199
|
+
cost: VideoCost;
|
|
200
|
+
finishedAt: string;
|
|
201
|
+
}
|
|
202
|
+
interface FailedVideoRecord extends VideoRecordBase {
|
|
203
|
+
status: 'failed';
|
|
204
|
+
error: VideoError;
|
|
205
|
+
finishedAt: string;
|
|
206
|
+
}
|
|
207
|
+
interface ExpiredVideoRecord extends VideoRecordBase {
|
|
208
|
+
status: 'expired';
|
|
209
|
+
finishedAt: string;
|
|
210
|
+
}
|
|
211
|
+
type VideoRecord = QueuedVideoRecord | ProcessingVideoRecord | SucceededVideoRecord | FailedVideoRecord | ExpiredVideoRecord;
|
|
212
|
+
interface BalanceResponse {
|
|
213
|
+
xTokens: number;
|
|
214
|
+
updatedAt: string;
|
|
215
|
+
}
|
|
216
|
+
type BalanceLedgerType = 'debit' | 'credit';
|
|
217
|
+
type BalanceLedgerReason = 'generation' | 'refund' | 'topup' | 'admin_adjustment';
|
|
218
|
+
interface BalanceLedgerEntry {
|
|
219
|
+
id: string;
|
|
220
|
+
type: BalanceLedgerType;
|
|
221
|
+
amount: number;
|
|
222
|
+
reason: BalanceLedgerReason;
|
|
223
|
+
reference: string;
|
|
224
|
+
balanceAfter: number;
|
|
225
|
+
createdAt: string;
|
|
226
|
+
}
|
|
227
|
+
interface BalanceHistoryParams {
|
|
228
|
+
page?: number;
|
|
229
|
+
pageSize?: number;
|
|
230
|
+
}
|
|
231
|
+
interface BalanceHistoryResponse {
|
|
232
|
+
items: BalanceLedgerEntry[];
|
|
233
|
+
page: number;
|
|
234
|
+
pageSize: number;
|
|
235
|
+
hasMore: boolean;
|
|
236
|
+
}
|
|
237
|
+
interface EndUserRecord {
|
|
238
|
+
email: string;
|
|
239
|
+
createdAt: string;
|
|
240
|
+
lastActiveAt: string;
|
|
241
|
+
totalRequests: number;
|
|
242
|
+
totalXTokensSpent: number;
|
|
243
|
+
/** When the owner blocked this end-user (ISO 8601), or null when active. */
|
|
244
|
+
blockedAt: string | null;
|
|
245
|
+
}
|
|
246
|
+
interface EndUserListParams {
|
|
247
|
+
page?: number;
|
|
248
|
+
pageSize?: number;
|
|
249
|
+
/** Filter to only blocked (`true`) or only active (`false`) end-users. */
|
|
250
|
+
blocked?: boolean;
|
|
251
|
+
/** Case-insensitive substring match on email. */
|
|
252
|
+
email?: string;
|
|
253
|
+
}
|
|
254
|
+
interface EndUserListResponse {
|
|
255
|
+
items: EndUserRecord[];
|
|
256
|
+
page: number;
|
|
257
|
+
pageSize: number;
|
|
258
|
+
hasMore: boolean;
|
|
259
|
+
}
|
|
260
|
+
interface BlockEndUserResponse {
|
|
261
|
+
email: string;
|
|
262
|
+
blockedAt: string;
|
|
263
|
+
}
|
|
264
|
+
interface UnblockEndUserResponse {
|
|
265
|
+
email: string;
|
|
266
|
+
blockedAt: null;
|
|
267
|
+
}
|
|
268
|
+
interface DeleteEndUserResponse {
|
|
269
|
+
email: string;
|
|
270
|
+
deleted: true;
|
|
271
|
+
removedRequests: number;
|
|
272
|
+
removedObjects: number;
|
|
273
|
+
}
|
|
274
|
+
type KnownApiErrorCode = 'validation_error' | 'unauthorized' | 'forbidden' | 'not_found' | 'conflict' | 'rate_limited' | 'payment_required' | 'content_policy' | 'provider_timeout' | 'provider_error' | 'internal_error' | 'account_blocked';
|
|
275
|
+
/** Widened so a server-added code never breaks error handling in older SDKs. */
|
|
276
|
+
type ApiErrorCode = KnownApiErrorCode | (string & {});
|
|
277
|
+
interface ApiErrorBody {
|
|
278
|
+
error: {
|
|
279
|
+
code: ApiErrorCode;
|
|
280
|
+
message: string;
|
|
281
|
+
fields?: Record<string, string>;
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//#endregion
|
|
285
|
+
export { KnownImageModel as A, SucceededGenerationRecord as B, GenerationListParams as C, ImageRecord as D, ImageModel as E, QueuedGenerationRecord as F, VideoModel as G, UnblockEndUserResponse as H, QueuedVideoRecord as I, VideoResolution as J, VideoRecord as K, ResponseFormat as L, KnownVideoModel as M, ProcessingGenerationRecord as N, ImageSize as O, ProcessingVideoRecord as P, SizePreset as R, GenerationError as S, GenerationRecord as T, VideoCost as U, SucceededVideoRecord as V, VideoError as W, ExpiredGenerationRecord as _, BalanceHistoryResponse as a, FailedVideoRecord as b, BalanceLedgerType as c, CreateGenerationInput as d, CreateVideoInput as f, EndUserRecord as g, EndUserListResponse as h, BalanceHistoryParams as i, KnownStatus as j, KnownApiErrorCode as k, BalanceResponse as l, EndUserListParams as m, ApiErrorCode as n, BalanceLedgerEntry as o, DeleteEndUserResponse as p, VideoRecordItem as q, AspectRatio as r, BalanceLedgerReason as s, ApiErrorBody as t, BlockEndUserResponse as u, ExpiredVideoRecord as v, GenerationListResponse as w, GenerationCost as x, FailedGenerationRecord as y, Status as z };
|
|
286
|
+
//# sourceMappingURL=types-BLVayOx3.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BLVayOx3.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;AAuBA;;;;AAA2B;AAC3B;;;;AAA2B;AAG3B;;;;AAAwC;AAExC;;KANY,eAAA;AAAA,KACA,eAAA;AAK4B;AAAA,KAF5B,UAAA,GAAa,eAAe;;KAE5B,UAAA,GAAa,eAAe;AAAA,KAM5B,UAAA;AAAU;AAAA,KAEV,SAAA,GAAY,UAAU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