@acedatacloud/sdk 2026.322.0 → 2026.418.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/dist/index.d.mts +336 -0
- package/dist/index.d.ts +336 -4
- package/dist/index.js +713 -19
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +665 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +19 -5
- package/src/index.ts +4 -0
- package/src/resources/audio.ts +6 -3
- package/src/resources/images.ts +7 -3
- package/src/resources/tasks.ts +6 -0
- package/src/resources/video.ts +6 -3
- package/src/runtime/transport.ts +9 -6
- package/dist/client.d.ts +0 -31
- package/dist/client.js +0 -46
- package/dist/resources/audio.d.ts +0 -17
- package/dist/resources/audio.js +0 -30
- package/dist/resources/chat.d.ts +0 -30
- package/dist/resources/chat.js +0 -38
- package/dist/resources/files.d.ts +0 -9
- package/dist/resources/files.js +0 -59
- package/dist/resources/images.d.ts +0 -18
- package/dist/resources/images.js +0 -32
- package/dist/resources/openai.d.ts +0 -46
- package/dist/resources/openai.js +0 -59
- package/dist/resources/platform.d.ts +0 -41
- package/dist/resources/platform.js +0 -76
- package/dist/resources/search.d.ts +0 -14
- package/dist/resources/search.js +0 -22
- package/dist/resources/tasks.d.ts +0 -14
- package/dist/resources/tasks.js +0 -36
- package/dist/resources/video.d.ts +0 -17
- package/dist/resources/video.js +0 -30
- package/dist/runtime/errors.d.ts +0 -44
- package/dist/runtime/errors.js +0 -89
- package/dist/runtime/index.d.ts +0 -3
- package/dist/runtime/index.js +0 -19
- package/dist/runtime/tasks.d.ts +0 -17
- package/dist/runtime/tasks.js +0 -46
- package/dist/runtime/transport.d.ts +0 -31
- package/dist/runtime/transport.js +0 -210
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/errors.ts","../src/runtime/transport.ts","../src/resources/chat.ts","../src/runtime/tasks.ts","../src/resources/images.ts","../src/resources/audio.ts","../src/resources/video.ts","../src/resources/search.ts","../src/resources/tasks.ts","../src/resources/files.ts","../src/resources/platform.ts","../src/resources/openai.ts","../src/client.ts"],"sourcesContent":["/** AceDataCloud SDK errors. */\n\nexport class AceDataCloudError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'AceDataCloudError';\n }\n}\n\nexport class TransportError extends AceDataCloudError {\n constructor(message: string) {\n super(message);\n this.name = 'TransportError';\n }\n}\n\nexport class APIError extends AceDataCloudError {\n statusCode: number;\n code: string;\n traceId?: string;\n body: Record<string, unknown>;\n\n constructor(opts: {\n message: string;\n statusCode: number;\n code: string;\n traceId?: string;\n body?: Record<string, unknown>;\n }) {\n super(opts.message);\n this.name = 'APIError';\n this.statusCode = opts.statusCode;\n this.code = opts.code;\n this.traceId = opts.traceId;\n this.body = opts.body ?? {};\n }\n}\n\nexport class AuthenticationError extends APIError {\n constructor(opts: ConstructorParameters<typeof APIError>[0]) {\n super(opts);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class TokenMismatchError extends APIError {\n constructor(opts: ConstructorParameters<typeof APIError>[0]) {\n super(opts);\n this.name = 'TokenMismatchError';\n }\n}\n\nexport class RateLimitError extends APIError {\n constructor(opts: ConstructorParameters<typeof APIError>[0]) {\n super(opts);\n this.name = 'RateLimitError';\n }\n}\n\nexport class ValidationError extends APIError {\n constructor(opts: ConstructorParameters<typeof APIError>[0]) {\n super(opts);\n this.name = 'ValidationError';\n }\n}\n\nexport class InsufficientBalanceError extends APIError {\n constructor(opts: ConstructorParameters<typeof APIError>[0]) {\n super(opts);\n this.name = 'InsufficientBalanceError';\n }\n}\n\nexport class ResourceDisabledError extends APIError {\n constructor(opts: ConstructorParameters<typeof APIError>[0]) {\n super(opts);\n this.name = 'ResourceDisabledError';\n }\n}\n\nexport class ModerationError extends APIError {\n constructor(opts: ConstructorParameters<typeof APIError>[0]) {\n super(opts);\n this.name = 'ModerationError';\n }\n}\n\nexport class TimeoutError extends APIError {\n constructor(opts: ConstructorParameters<typeof APIError>[0]) {\n super(opts);\n this.name = 'TimeoutError';\n }\n}\n","/** HTTP transport for AceDataCloud SDK. Uses native fetch (Node 18+). */\n\nimport {\n APIError,\n AuthenticationError,\n InsufficientBalanceError,\n ModerationError,\n RateLimitError,\n ResourceDisabledError,\n TimeoutError,\n TokenMismatchError,\n TransportError,\n ValidationError,\n} from './errors';\n\nconst ERROR_CODE_MAP: Record<string, typeof APIError> = {\n invalid_token: AuthenticationError,\n token_expired: AuthenticationError,\n no_token: AuthenticationError,\n token_mismatched: TokenMismatchError,\n used_up: InsufficientBalanceError,\n disabled: ResourceDisabledError,\n too_many_requests: RateLimitError,\n bad_request: ValidationError,\n};\n\nconst RETRY_STATUS_CODES = new Set([408, 409, 429, 500, 502, 503, 504]);\n\nfunction mapError(statusCode: number, body: Record<string, unknown>): APIError {\n const errorData = (body.error ?? {}) as Record<string, unknown>;\n const code = (errorData.code ?? '') as string;\n const message = (errorData.message ?? '') as string;\n const traceId = body.trace_id as string | undefined;\n\n let ErrorClass = ERROR_CODE_MAP[code];\n if (!ErrorClass) {\n if (statusCode === 403) ErrorClass = ModerationError;\n else if (statusCode === 401) ErrorClass = AuthenticationError;\n else if (statusCode === 429) ErrorClass = RateLimitError;\n else if (statusCode === 400) ErrorClass = ValidationError;\n else ErrorClass = APIError;\n }\n\n return new ErrorClass({ message, statusCode, code, traceId, body });\n}\n\nfunction backoffDelay(attempt: number): number {\n const base = Math.min(2 ** attempt, 8);\n return base + Math.random() * 0.5;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport interface TransportOptions {\n apiToken?: string;\n baseURL?: string;\n platformBaseURL?: string;\n timeout?: number;\n maxRetries?: number;\n headers?: Record<string, string>;\n}\n\nexport class Transport {\n private baseURL: string;\n private platformBaseURL: string;\n private timeout: number;\n private maxRetries: number;\n private headers: Record<string, string>;\n\n constructor(opts: TransportOptions = {}) {\n const token = opts.apiToken ?? process.env.ACEDATACLOUD_API_TOKEN ?? '';\n if (!token) {\n throw new AuthenticationError({\n message: 'apiToken is required. Pass it to the client or set ACEDATACLOUD_API_TOKEN.',\n statusCode: 0,\n code: 'no_token',\n });\n }\n this.baseURL = (opts.baseURL ?? 'https://api.acedata.cloud').replace(/\\/+$/, '');\n this.platformBaseURL = (opts.platformBaseURL ?? 'https://platform.acedata.cloud').replace(/\\/+$/, '');\n this.timeout = opts.timeout ?? 300_000;\n this.maxRetries = opts.maxRetries ?? 2;\n this.headers = {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n 'content-type': 'application/json',\n 'user-agent': 'acedatacloud-node/0.1.0',\n ...(opts.headers ?? {}),\n };\n }\n\n async request(\n method: string,\n path: string,\n opts: {\n json?: Record<string, unknown>;\n params?: Record<string, string>;\n platform?: boolean;\n timeout?: number;\n headers?: Record<string, string>;\n } = {}\n ): Promise<Record<string, unknown>> {\n const base = opts.platform ? this.platformBaseURL : this.baseURL;\n let url = `${base}${path}`;\n if (opts.params) {\n const qs = new URLSearchParams(opts.params).toString();\n url += `?${qs}`;\n }\n const headers = { ...this.headers, ...(opts.headers ?? {}) };\n const timeoutMs = opts.timeout ?? this.timeout;\n\n let lastError: Error | null = null;\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n const resp = await fetch(url, {\n method,\n headers,\n body: opts.json ? JSON.stringify(opts.json) : undefined,\n signal: controller.signal,\n });\n clearTimeout(timer);\n\n if (resp.status >= 400) {\n const text = await resp.text();\n let body: Record<string, unknown>;\n try {\n body = JSON.parse(text) as Record<string, unknown>;\n } catch {\n body = { error: { code: 'unknown', message: text } };\n }\n if (RETRY_STATUS_CODES.has(resp.status) && attempt < this.maxRetries) {\n await sleep(backoffDelay(attempt) * 1000);\n continue;\n }\n throw mapError(resp.status, body);\n }\n\n return (await resp.json()) as Record<string, unknown>;\n } catch (err) {\n clearTimeout(timer);\n if (err instanceof APIError) throw err;\n lastError = err as Error;\n if (attempt < this.maxRetries) {\n await sleep(backoffDelay(attempt) * 1000);\n continue;\n }\n }\n }\n throw lastError ?? new TransportError('Request failed after retries');\n }\n\n async *requestStream(\n method: string,\n path: string,\n opts: { json?: Record<string, unknown>; timeout?: number } = {}\n ): AsyncGenerator<string, void, unknown> {\n const url = `${this.baseURL}${path}`;\n const headers = { ...this.headers, accept: 'text/event-stream' };\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), opts.timeout ?? this.timeout);\n\n try {\n const resp = await fetch(url, {\n method,\n headers,\n body: opts.json ? JSON.stringify(opts.json) : undefined,\n signal: controller.signal,\n });\n\n if (resp.status >= 400) {\n const text = await resp.text();\n let body: Record<string, unknown>;\n try {\n body = JSON.parse(text) as Record<string, unknown>;\n } catch {\n body = { error: { code: 'unknown', message: text } };\n }\n throw mapError(resp.status, body);\n }\n\n if (!resp.body) throw new TransportError('No response body for stream');\n\n const reader = resp.body.getReader();\n const decoder = new TextDecoder();\n let buffer = '';\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n buffer += decoder.decode(value, { stream: true });\n\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n const data = line.slice(6);\n if (data === '[DONE]') return;\n yield data;\n }\n }\n }\n } finally {\n clearTimeout(timer);\n }\n }\n\n async upload(\n path: string,\n fileData: Buffer | Uint8Array,\n filename: string,\n opts: { timeout?: number } = {}\n ): Promise<Record<string, unknown>> {\n const url = `${this.platformBaseURL}${path}`;\n const boundary = `----AceDataCloudBoundary${Date.now()}`;\n const headers = {\n ...this.headers,\n 'content-type': `multipart/form-data; boundary=${boundary}`,\n };\n delete (headers as Record<string, string>)['content-type'];\n\n const body = new FormData();\n body.append('file', new Blob([fileData]), filename);\n\n const authHeaders: Record<string, string> = {\n authorization: this.headers.authorization,\n 'user-agent': this.headers['user-agent'],\n };\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), opts.timeout ?? this.timeout);\n try {\n const resp = await fetch(url, {\n method: 'POST',\n headers: authHeaders,\n body,\n signal: controller.signal,\n });\n clearTimeout(timer);\n\n if (resp.status >= 400) {\n const text = await resp.text();\n let respBody: Record<string, unknown>;\n try {\n respBody = JSON.parse(text) as Record<string, unknown>;\n } catch {\n respBody = { error: { code: 'unknown', message: text } };\n }\n throw mapError(resp.status, respBody);\n }\n return (await resp.json()) as Record<string, unknown>;\n } finally {\n clearTimeout(timer);\n }\n }\n}\n","/** Chat resources — native provider APIs (Claude Messages). */\n\nimport { Transport } from '../runtime/transport';\n\nexport class Messages {\n constructor(private transport: Transport) {}\n\n async create(opts: {\n model: string;\n messages: Array<Record<string, unknown>>;\n maxTokens?: number;\n stream?: false;\n [key: string]: unknown;\n }): Promise<Record<string, unknown>>;\n async create(opts: {\n model: string;\n messages: Array<Record<string, unknown>>;\n maxTokens?: number;\n stream: true;\n [key: string]: unknown;\n }): Promise<AsyncGenerator<Record<string, unknown>>>;\n async create(opts: {\n model: string;\n messages: Array<Record<string, unknown>>;\n maxTokens?: number;\n stream?: boolean;\n [key: string]: unknown;\n }): Promise<Record<string, unknown> | AsyncGenerator<Record<string, unknown>>> {\n const { model, messages, maxTokens = 4096, stream, ...rest } = opts;\n const body: Record<string, unknown> = { model, messages, max_tokens: maxTokens, ...rest };\n\n if (stream) {\n body.stream = true;\n return this.stream(body);\n }\n return this.transport.request('POST', '/v1/messages', { json: body });\n }\n\n private async *stream(body: Record<string, unknown>): AsyncGenerator<Record<string, unknown>> {\n for await (const chunk of this.transport.requestStream('POST', '/v1/messages', { json: body })) {\n yield JSON.parse(chunk);\n }\n }\n\n async countTokens(opts: {\n model: string;\n messages: Array<Record<string, unknown>>;\n [key: string]: unknown;\n }): Promise<Record<string, unknown>> {\n const { model, messages, ...rest } = opts;\n return this.transport.request('POST', '/v1/messages/count_tokens', {\n json: { model, messages, ...rest },\n });\n }\n}\n\nexport class Chat {\n readonly messages: Messages;\n\n constructor(transport: Transport) {\n this.messages = new Messages(transport);\n }\n}\n","/** Task polling abstraction. */\n\nimport { Transport } from './transport';\n\nexport interface TaskHandleOptions {\n pollInterval?: number;\n maxWait?: number;\n}\n\nexport class TaskHandle {\n readonly id: string;\n private pollEndpoint: string;\n private transport: Transport;\n private _result: Record<string, unknown> | null = null;\n\n constructor(taskId: string, pollEndpoint: string, transport: Transport) {\n this.id = taskId;\n this.pollEndpoint = pollEndpoint;\n this.transport = transport;\n }\n\n async get(): Promise<Record<string, unknown>> {\n return this.transport.request('POST', this.pollEndpoint, {\n json: { id: this.id, action: 'retrieve' },\n });\n }\n\n async isCompleted(): Promise<boolean> {\n const state = await this.get();\n const response = (state.response ?? state) as Record<string, unknown>;\n const status = response.status as string;\n return status === 'succeeded' || status === 'failed';\n }\n\n async wait(opts: TaskHandleOptions = {}): Promise<Record<string, unknown>> {\n const pollInterval = opts.pollInterval ?? 3000;\n const maxWait = opts.maxWait ?? 600_000;\n const start = Date.now();\n\n while (Date.now() - start < maxWait) {\n const state = await this.get();\n const response = (state.response ?? state) as Record<string, unknown>;\n const status = response.status as string;\n\n if (status === 'succeeded' || status === 'failed') {\n this._result = state;\n return state;\n }\n await new Promise((resolve) => setTimeout(resolve, pollInterval));\n }\n throw new Error(`Task ${this.id} did not complete within ${maxWait}ms`);\n }\n\n get result(): Record<string, unknown> | null {\n return this._result;\n }\n}\n","/** Image generation resources. */\n\nimport { Transport } from '../runtime/transport';\nimport { TaskHandle } from '../runtime/tasks';\n\nexport type ImageProvider = 'nano-banana' | 'midjourney' | 'flux' | 'seedream' | (string & {});\n\nexport class Images {\n constructor(private transport: Transport) {}\n\n async generate(opts: {\n prompt: string;\n provider?: ImageProvider;\n model?: string;\n negativePrompt?: string;\n imageUrl?: string;\n callbackUrl?: string;\n wait?: boolean;\n pollInterval?: number;\n maxWait?: number;\n [key: string]: unknown;\n }): Promise<Record<string, unknown> | TaskHandle> {\n const { prompt, provider = 'nano-banana', model, negativePrompt, imageUrl, callbackUrl, wait: shouldWait, pollInterval, maxWait, ...rest } = opts;\n const body: Record<string, unknown> = { prompt, ...rest };\n if (model !== undefined) body.model = model;\n if (negativePrompt !== undefined) body.negative_prompt = negativePrompt;\n if (imageUrl !== undefined) body.image_url = imageUrl;\n if (callbackUrl !== undefined) body.callback_url = callbackUrl;\n\n const endpoint = provider === 'midjourney' ? '/midjourney/imagine' : `/${provider}/images`;\n const result = await this.transport.request('POST', endpoint, { json: body });\n const taskId = result.task_id as string | undefined;\n\n if (!taskId || (result.data && !shouldWait)) return result;\n\n const handle = new TaskHandle(taskId, `/${provider}/tasks`, this.transport);\n if (shouldWait) return handle.wait({ pollInterval, maxWait });\n return handle;\n }\n}\n","/** Audio/music generation resources. */\n\nimport { Transport } from '../runtime/transport';\nimport { TaskHandle } from '../runtime/tasks';\n\nexport type AudioProvider = 'suno' | 'producer' | (string & {});\n\nexport class Audio {\n constructor(private transport: Transport) {}\n\n async generate(opts: {\n prompt: string;\n provider?: AudioProvider;\n model?: string;\n tags?: string;\n callbackUrl?: string;\n wait?: boolean;\n pollInterval?: number;\n maxWait?: number;\n [key: string]: unknown;\n }): Promise<Record<string, unknown> | TaskHandle> {\n const { prompt, provider = 'suno', model, tags, callbackUrl, wait: shouldWait, pollInterval, maxWait, ...rest } = opts;\n const body: Record<string, unknown> = { prompt, ...rest };\n if (model !== undefined) body.model = model;\n if (tags !== undefined) body.tags = tags;\n if (callbackUrl !== undefined) body.callback_url = callbackUrl;\n\n const result = await this.transport.request('POST', `/${provider}/audios`, { json: body });\n const taskId = result.task_id as string | undefined;\n\n if (!taskId || (result.data && !shouldWait)) return result;\n\n const handle = new TaskHandle(taskId, `/${provider}/tasks`, this.transport);\n if (shouldWait) return handle.wait({ pollInterval, maxWait });\n return handle;\n }\n}\n","/** Video generation resources. */\n\nimport { Transport } from '../runtime/transport';\nimport { TaskHandle } from '../runtime/tasks';\n\nexport type VideoProvider = 'sora' | 'luma' | 'veo' | 'kling' | 'hailuo' | 'seedance' | 'wan' | 'pika' | 'pixverse' | (string & {});\n\nexport class Video {\n constructor(private transport: Transport) {}\n\n async generate(opts: {\n prompt: string;\n provider?: VideoProvider;\n model?: string;\n imageUrl?: string;\n callbackUrl?: string;\n wait?: boolean;\n pollInterval?: number;\n maxWait?: number;\n [key: string]: unknown;\n }): Promise<Record<string, unknown> | TaskHandle> {\n const { prompt, provider = 'sora', model, imageUrl, callbackUrl, wait: shouldWait, pollInterval, maxWait, ...rest } = opts;\n const body: Record<string, unknown> = { prompt, ...rest };\n if (model !== undefined) body.model = model;\n if (imageUrl !== undefined) body.image_url = imageUrl;\n if (callbackUrl !== undefined) body.callback_url = callbackUrl;\n\n const result = await this.transport.request('POST', `/${provider}/videos`, { json: body });\n const taskId = result.task_id as string | undefined;\n\n if (!taskId || (result.data && !shouldWait)) return result;\n\n const handle = new TaskHandle(taskId, `/${provider}/tasks`, this.transport);\n if (shouldWait) return handle.wait({ pollInterval, maxWait });\n return handle;\n }\n}\n","/** Search resources. */\n\nimport { Transport } from '../runtime/transport';\n\nexport class Search {\n constructor(private transport: Transport) {}\n\n async google(opts: {\n query: string;\n type?: string;\n country?: string;\n language?: string;\n page?: number;\n [key: string]: unknown;\n }): Promise<Record<string, unknown>> {\n const { query, type = 'search', country, language, page, ...rest } = opts;\n const body: Record<string, unknown> = { query, type, ...rest };\n if (country !== undefined) body.country = country;\n if (language !== undefined) body.language = language;\n if (page !== undefined) body.page = page;\n return this.transport.request('POST', '/serp/google', { json: body });\n }\n}\n","/** Cross-service task retrieval. */\n\nimport { Transport } from '../runtime/transport';\nimport { TaskHandle } from '../runtime/tasks';\n\nconst SERVICE_TASK_ENDPOINTS: Record<string, string> = {\n suno: '/suno/tasks',\n producer: '/producer/tasks',\n 'nano-banana': '/nano-banana/tasks',\n seedream: '/seedream/tasks',\n seedance: '/seedance/tasks',\n sora: '/sora/tasks',\n midjourney: '/midjourney/tasks',\n luma: '/luma/tasks',\n veo: '/veo/tasks',\n flux: '/flux/tasks',\n kling: '/kling/tasks',\n hailuo: '/hailuo/tasks',\n wan: '/wan/tasks',\n pika: '/pika/tasks',\n pixverse: '/pixverse/tasks',\n};\n\nexport class Tasks {\n constructor(private transport: Transport) {}\n\n async get(taskId: string, opts: { service?: string } = {}): Promise<Record<string, unknown>> {\n const service = opts.service ?? 'suno';\n const endpoint = SERVICE_TASK_ENDPOINTS[service] ?? `/${service}/tasks`;\n return this.transport.request('POST', endpoint, {\n json: { id: taskId, action: 'retrieve' },\n });\n }\n\n async wait(\n taskId: string,\n opts: { service?: string; pollInterval?: number; maxWait?: number } = {}\n ): Promise<Record<string, unknown>> {\n const service = opts.service ?? 'suno';\n const endpoint = SERVICE_TASK_ENDPOINTS[service] ?? `/${service}/tasks`;\n const handle = new TaskHandle(taskId, endpoint, this.transport);\n return handle.wait({ pollInterval: opts.pollInterval, maxWait: opts.maxWait });\n }\n}\n","/** File upload resources. */\n\nimport { Transport } from '../runtime/transport';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nexport class Files {\n constructor(private transport: Transport) {}\n\n async upload(\n file: string | Buffer | Uint8Array,\n opts: { filename?: string } = {}\n ): Promise<Record<string, unknown>> {\n let data: Buffer | Uint8Array;\n let filename: string;\n\n if (typeof file === 'string') {\n data = fs.readFileSync(file);\n filename = opts.filename ?? path.basename(file);\n } else {\n data = file;\n filename = opts.filename ?? 'upload';\n }\n\n return this.transport.upload('/api/v1/files/', data, filename);\n }\n}\n","/** Management-plane resources. */\n\nimport { Transport } from '../runtime/transport';\n\nclass Applications {\n constructor(private transport: Transport) {}\n\n async list(params?: Record<string, string>): Promise<Record<string, unknown>> {\n return this.transport.request('GET', '/api/v1/applications/', { params, platform: true });\n }\n\n async create(opts: { serviceId: string; [key: string]: unknown }): Promise<Record<string, unknown>> {\n const { serviceId, ...rest } = opts;\n return this.transport.request('POST', '/api/v1/applications/', {\n json: { service_id: serviceId, ...rest },\n platform: true,\n });\n }\n\n async get(applicationId: string): Promise<Record<string, unknown>> {\n return this.transport.request('GET', `/api/v1/applications/${applicationId}/`, { platform: true });\n }\n}\n\nclass Credentials {\n constructor(private transport: Transport) {}\n\n async list(params?: Record<string, string>): Promise<Record<string, unknown>> {\n return this.transport.request('GET', '/api/v1/credentials/', { params, platform: true });\n }\n\n async create(opts: { applicationId: string; [key: string]: unknown }): Promise<Record<string, unknown>> {\n const { applicationId, ...rest } = opts;\n return this.transport.request('POST', '/api/v1/credentials/', {\n json: { application_id: applicationId, ...rest },\n platform: true,\n });\n }\n\n async rotate(credentialId: string): Promise<Record<string, unknown>> {\n return this.transport.request('POST', `/api/v1/credentials/${credentialId}/rotate/`, { platform: true });\n }\n\n async delete(credentialId: string): Promise<Record<string, unknown>> {\n return this.transport.request('DELETE', `/api/v1/credentials/${credentialId}/`, { platform: true });\n }\n}\n\nclass Models {\n constructor(private transport: Transport) {}\n\n async list(params?: Record<string, string>): Promise<Record<string, unknown>> {\n return this.transport.request('GET', '/api/v1/models/', { params, platform: true });\n }\n}\n\nclass Config {\n constructor(private transport: Transport) {}\n\n async get(): Promise<Record<string, unknown>> {\n return this.transport.request('GET', '/api/v1/config/', { platform: true });\n }\n}\n\nexport class Platform {\n readonly applications: Applications;\n readonly credentials: Credentials;\n readonly models: Models;\n readonly config: Config;\n\n constructor(transport: Transport) {\n this.applications = new Applications(transport);\n this.credentials = new Credentials(transport);\n this.models = new Models(transport);\n this.config = new Config(transport);\n }\n}\n","/** OpenAI-compatible facade resources. */\n\nimport { Transport } from '../runtime/transport';\n\nclass Completions {\n constructor(private transport: Transport) {}\n\n async create(opts: {\n model: string;\n messages: Array<Record<string, unknown>>;\n stream?: false;\n [key: string]: unknown;\n }): Promise<Record<string, unknown>>;\n async create(opts: {\n model: string;\n messages: Array<Record<string, unknown>>;\n stream: true;\n [key: string]: unknown;\n }): Promise<AsyncGenerator<Record<string, unknown>>>;\n async create(opts: {\n model: string;\n messages: Array<Record<string, unknown>>;\n stream?: boolean;\n [key: string]: unknown;\n }): Promise<Record<string, unknown> | AsyncGenerator<Record<string, unknown>>> {\n const { model, messages, stream, ...rest } = opts;\n const body: Record<string, unknown> = { model, messages, ...rest };\n\n if (stream) {\n body.stream = true;\n return this.streamResponse(body);\n }\n return this.transport.request('POST', '/v1/chat/completions', { json: body });\n }\n\n private async *streamResponse(body: Record<string, unknown>): AsyncGenerator<Record<string, unknown>> {\n for await (const chunk of this.transport.requestStream('POST', '/v1/chat/completions', { json: body })) {\n yield JSON.parse(chunk);\n }\n }\n}\n\nclass ChatNamespace {\n readonly completions: Completions;\n constructor(transport: Transport) {\n this.completions = new Completions(transport);\n }\n}\n\nclass Responses {\n constructor(private transport: Transport) {}\n\n async create(opts: {\n model: string;\n input: string | Array<Record<string, unknown>>;\n stream?: false;\n [key: string]: unknown;\n }): Promise<Record<string, unknown>>;\n async create(opts: {\n model: string;\n input: string | Array<Record<string, unknown>>;\n stream: true;\n [key: string]: unknown;\n }): Promise<AsyncGenerator<Record<string, unknown>>>;\n async create(opts: {\n model: string;\n input: string | Array<Record<string, unknown>>;\n stream?: boolean;\n [key: string]: unknown;\n }): Promise<Record<string, unknown> | AsyncGenerator<Record<string, unknown>>> {\n const { model, input, stream, ...rest } = opts;\n const body: Record<string, unknown> = { model, input, ...rest };\n\n if (stream) {\n body.stream = true;\n return this.streamResponse(body);\n }\n return this.transport.request('POST', '/openai/responses', { json: body });\n }\n\n private async *streamResponse(body: Record<string, unknown>): AsyncGenerator<Record<string, unknown>> {\n for await (const chunk of this.transport.requestStream('POST', '/openai/responses', { json: body })) {\n yield JSON.parse(chunk);\n }\n }\n}\n\nexport class OpenAI {\n readonly chat: ChatNamespace;\n readonly responses: Responses;\n\n constructor(transport: Transport) {\n this.chat = new ChatNamespace(transport);\n this.responses = new Responses(transport);\n }\n}\n","/** Top-level AceDataCloud client for TypeScript. */\n\nimport { Transport, TransportOptions } from './runtime/transport';\nimport { Chat } from './resources/chat';\nimport { Images } from './resources/images';\nimport { Audio } from './resources/audio';\nimport { Video } from './resources/video';\nimport { Search } from './resources/search';\nimport { Tasks } from './resources/tasks';\nimport { Files } from './resources/files';\nimport { Platform } from './resources/platform';\nimport { OpenAI } from './resources/openai';\n\nexport interface AceDataCloudOptions {\n apiToken?: string;\n baseURL?: string;\n platformBaseURL?: string;\n timeout?: number;\n maxRetries?: number;\n headers?: Record<string, string>;\n}\n\nexport class AceDataCloud {\n readonly chat: Chat;\n readonly images: Images;\n readonly audio: Audio;\n readonly video: Video;\n readonly search: Search;\n readonly tasks: Tasks;\n readonly files: Files;\n readonly platform: Platform;\n readonly openai: OpenAI;\n\n private transport: Transport;\n\n constructor(opts: AceDataCloudOptions = {}) {\n this.transport = new Transport({\n apiToken: opts.apiToken,\n baseURL: opts.baseURL,\n platformBaseURL: opts.platformBaseURL,\n timeout: opts.timeout,\n maxRetries: opts.maxRetries,\n headers: opts.headers,\n });\n\n this.chat = new Chat(this.transport);\n this.images = new Images(this.transport);\n this.audio = new Audio(this.transport);\n this.video = new Video(this.transport);\n this.search = new Search(this.transport);\n this.tasks = new Tasks(this.transport);\n this.files = new Files(this.transport);\n this.platform = new Platform(this.transport);\n this.openai = new OpenAI(this.transport);\n }\n}\n"],"mappings":";AAEO,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAC3C,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,kBAAkB;AAAA,EACpD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,WAAN,cAAuB,kBAAkB;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,MAMT;AACD,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AACZ,SAAK,aAAa,KAAK;AACvB,SAAK,OAAO,KAAK;AACjB,SAAK,UAAU,KAAK;AACpB,SAAK,OAAO,KAAK,QAAQ,CAAC;AAAA,EAC5B;AACF;AAEO,IAAM,sBAAN,cAAkC,SAAS;AAAA,EAChD,YAAY,MAAiD;AAC3D,UAAM,IA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,MAAM,KAAK,SAAS;AACrC,SAAK,QAAQ,IAAI,MAAM,KAAK,SAAS;AACrC,SAAK,WAAW,IAAI,SAAS,KAAK,SAAS;AAC3C,SAAK,SAAS,IAAI,OAAO,KAAK,SAAS;AAAA,EACzC;AACF;","names":["path"]}
|
package/package.json
CHANGED
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acedatacloud/sdk",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.418.0",
|
|
4
4
|
"description": "Official TypeScript SDK for AceDataCloud — AI-powered data services",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
7
20
|
"license": "MIT",
|
|
8
21
|
"scripts": {
|
|
9
|
-
"build": "
|
|
22
|
+
"build": "tsup",
|
|
10
23
|
"test": "jest --forceExit",
|
|
11
24
|
"lint": "tsc --noEmit"
|
|
12
25
|
},
|
|
13
|
-
"dependencies": {},
|
|
14
26
|
"devDependencies": {
|
|
15
|
-
"
|
|
27
|
+
"@types/jest": "^29.0.0",
|
|
16
28
|
"@types/node": "^20.0.0",
|
|
29
|
+
"dotenv": "^17.3.1",
|
|
17
30
|
"jest": "^29.0.0",
|
|
18
31
|
"ts-jest": "^29.0.0",
|
|
19
|
-
"
|
|
32
|
+
"tsup": "^8.5.1",
|
|
33
|
+
"typescript": "^5.0.0"
|
|
20
34
|
},
|
|
21
35
|
"files": [
|
|
22
36
|
"dist",
|
package/src/index.ts
CHANGED
|
@@ -17,3 +17,7 @@ export {
|
|
|
17
17
|
} from './runtime/errors';
|
|
18
18
|
|
|
19
19
|
export { TaskHandle, TaskHandleOptions } from './runtime/tasks';
|
|
20
|
+
|
|
21
|
+
export type { ImageProvider } from './resources/images';
|
|
22
|
+
export type { VideoProvider } from './resources/video';
|
|
23
|
+
export type { AudioProvider } from './resources/audio';
|
package/src/resources/audio.ts
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
import { Transport } from '../runtime/transport';
|
|
4
4
|
import { TaskHandle } from '../runtime/tasks';
|
|
5
5
|
|
|
6
|
+
export type AudioProvider = 'suno' | 'producer' | (string & {});
|
|
7
|
+
|
|
6
8
|
export class Audio {
|
|
7
9
|
constructor(private transport: Transport) {}
|
|
8
10
|
|
|
9
11
|
async generate(opts: {
|
|
10
12
|
prompt: string;
|
|
13
|
+
provider?: AudioProvider;
|
|
11
14
|
model?: string;
|
|
12
15
|
tags?: string;
|
|
13
16
|
callbackUrl?: string;
|
|
@@ -16,18 +19,18 @@ export class Audio {
|
|
|
16
19
|
maxWait?: number;
|
|
17
20
|
[key: string]: unknown;
|
|
18
21
|
}): Promise<Record<string, unknown> | TaskHandle> {
|
|
19
|
-
const { prompt, model, tags, callbackUrl, wait: shouldWait, pollInterval, maxWait, ...rest } = opts;
|
|
22
|
+
const { prompt, provider = 'suno', model, tags, callbackUrl, wait: shouldWait, pollInterval, maxWait, ...rest } = opts;
|
|
20
23
|
const body: Record<string, unknown> = { prompt, ...rest };
|
|
21
24
|
if (model !== undefined) body.model = model;
|
|
22
25
|
if (tags !== undefined) body.tags = tags;
|
|
23
26
|
if (callbackUrl !== undefined) body.callback_url = callbackUrl;
|
|
24
27
|
|
|
25
|
-
const result = await this.transport.request('POST',
|
|
28
|
+
const result = await this.transport.request('POST', `/${provider}/audios`, { json: body });
|
|
26
29
|
const taskId = result.task_id as string | undefined;
|
|
27
30
|
|
|
28
31
|
if (!taskId || (result.data && !shouldWait)) return result;
|
|
29
32
|
|
|
30
|
-
const handle = new TaskHandle(taskId,
|
|
33
|
+
const handle = new TaskHandle(taskId, `/${provider}/tasks`, this.transport);
|
|
31
34
|
if (shouldWait) return handle.wait({ pollInterval, maxWait });
|
|
32
35
|
return handle;
|
|
33
36
|
}
|
package/src/resources/images.ts
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
import { Transport } from '../runtime/transport';
|
|
4
4
|
import { TaskHandle } from '../runtime/tasks';
|
|
5
5
|
|
|
6
|
+
export type ImageProvider = 'nano-banana' | 'midjourney' | 'flux' | 'seedream' | (string & {});
|
|
7
|
+
|
|
6
8
|
export class Images {
|
|
7
9
|
constructor(private transport: Transport) {}
|
|
8
10
|
|
|
9
11
|
async generate(opts: {
|
|
10
12
|
prompt: string;
|
|
13
|
+
provider?: ImageProvider;
|
|
11
14
|
model?: string;
|
|
12
15
|
negativePrompt?: string;
|
|
13
16
|
imageUrl?: string;
|
|
@@ -17,19 +20,20 @@ export class Images {
|
|
|
17
20
|
maxWait?: number;
|
|
18
21
|
[key: string]: unknown;
|
|
19
22
|
}): Promise<Record<string, unknown> | TaskHandle> {
|
|
20
|
-
const { prompt, model, negativePrompt, imageUrl, callbackUrl, wait: shouldWait, pollInterval, maxWait, ...rest } = opts;
|
|
23
|
+
const { prompt, provider = 'nano-banana', model, negativePrompt, imageUrl, callbackUrl, wait: shouldWait, pollInterval, maxWait, ...rest } = opts;
|
|
21
24
|
const body: Record<string, unknown> = { prompt, ...rest };
|
|
22
25
|
if (model !== undefined) body.model = model;
|
|
23
26
|
if (negativePrompt !== undefined) body.negative_prompt = negativePrompt;
|
|
24
27
|
if (imageUrl !== undefined) body.image_url = imageUrl;
|
|
25
28
|
if (callbackUrl !== undefined) body.callback_url = callbackUrl;
|
|
26
29
|
|
|
27
|
-
const
|
|
30
|
+
const endpoint = provider === 'midjourney' ? '/midjourney/imagine' : `/${provider}/images`;
|
|
31
|
+
const result = await this.transport.request('POST', endpoint, { json: body });
|
|
28
32
|
const taskId = result.task_id as string | undefined;
|
|
29
33
|
|
|
30
34
|
if (!taskId || (result.data && !shouldWait)) return result;
|
|
31
35
|
|
|
32
|
-
const handle = new TaskHandle(taskId,
|
|
36
|
+
const handle = new TaskHandle(taskId, `/${provider}/tasks`, this.transport);
|
|
33
37
|
if (shouldWait) return handle.wait({ pollInterval, maxWait });
|
|
34
38
|
return handle;
|
|
35
39
|
}
|
package/src/resources/tasks.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { TaskHandle } from '../runtime/tasks';
|
|
|
5
5
|
|
|
6
6
|
const SERVICE_TASK_ENDPOINTS: Record<string, string> = {
|
|
7
7
|
suno: '/suno/tasks',
|
|
8
|
+
producer: '/producer/tasks',
|
|
8
9
|
'nano-banana': '/nano-banana/tasks',
|
|
9
10
|
seedream: '/seedream/tasks',
|
|
10
11
|
seedance: '/seedance/tasks',
|
|
@@ -13,6 +14,11 @@ const SERVICE_TASK_ENDPOINTS: Record<string, string> = {
|
|
|
13
14
|
luma: '/luma/tasks',
|
|
14
15
|
veo: '/veo/tasks',
|
|
15
16
|
flux: '/flux/tasks',
|
|
17
|
+
kling: '/kling/tasks',
|
|
18
|
+
hailuo: '/hailuo/tasks',
|
|
19
|
+
wan: '/wan/tasks',
|
|
20
|
+
pika: '/pika/tasks',
|
|
21
|
+
pixverse: '/pixverse/tasks',
|
|
16
22
|
};
|
|
17
23
|
|
|
18
24
|
export class Tasks {
|
package/src/resources/video.ts
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
import { Transport } from '../runtime/transport';
|
|
4
4
|
import { TaskHandle } from '../runtime/tasks';
|
|
5
5
|
|
|
6
|
+
export type VideoProvider = 'sora' | 'luma' | 'veo' | 'kling' | 'hailuo' | 'seedance' | 'wan' | 'pika' | 'pixverse' | (string & {});
|
|
7
|
+
|
|
6
8
|
export class Video {
|
|
7
9
|
constructor(private transport: Transport) {}
|
|
8
10
|
|
|
9
11
|
async generate(opts: {
|
|
10
12
|
prompt: string;
|
|
13
|
+
provider?: VideoProvider;
|
|
11
14
|
model?: string;
|
|
12
15
|
imageUrl?: string;
|
|
13
16
|
callbackUrl?: string;
|
|
@@ -16,18 +19,18 @@ export class Video {
|
|
|
16
19
|
maxWait?: number;
|
|
17
20
|
[key: string]: unknown;
|
|
18
21
|
}): Promise<Record<string, unknown> | TaskHandle> {
|
|
19
|
-
const { prompt, model, imageUrl, callbackUrl, wait: shouldWait, pollInterval, maxWait, ...rest } = opts;
|
|
22
|
+
const { prompt, provider = 'sora', model, imageUrl, callbackUrl, wait: shouldWait, pollInterval, maxWait, ...rest } = opts;
|
|
20
23
|
const body: Record<string, unknown> = { prompt, ...rest };
|
|
21
24
|
if (model !== undefined) body.model = model;
|
|
22
25
|
if (imageUrl !== undefined) body.image_url = imageUrl;
|
|
23
26
|
if (callbackUrl !== undefined) body.callback_url = callbackUrl;
|
|
24
27
|
|
|
25
|
-
const result = await this.transport.request('POST',
|
|
28
|
+
const result = await this.transport.request('POST', `/${provider}/videos`, { json: body });
|
|
26
29
|
const taskId = result.task_id as string | undefined;
|
|
27
30
|
|
|
28
31
|
if (!taskId || (result.data && !shouldWait)) return result;
|
|
29
32
|
|
|
30
|
-
const handle = new TaskHandle(taskId,
|
|
33
|
+
const handle = new TaskHandle(taskId, `/${provider}/tasks`, this.transport);
|
|
31
34
|
if (shouldWait) return handle.wait({ pollInterval, maxWait });
|
|
32
35
|
return handle;
|
|
33
36
|
}
|
package/src/runtime/transport.ts
CHANGED
|
@@ -125,11 +125,12 @@ export class Transport {
|
|
|
125
125
|
clearTimeout(timer);
|
|
126
126
|
|
|
127
127
|
if (resp.status >= 400) {
|
|
128
|
+
const text = await resp.text();
|
|
128
129
|
let body: Record<string, unknown>;
|
|
129
130
|
try {
|
|
130
|
-
body =
|
|
131
|
+
body = JSON.parse(text) as Record<string, unknown>;
|
|
131
132
|
} catch {
|
|
132
|
-
body = { error: { code: 'unknown', message:
|
|
133
|
+
body = { error: { code: 'unknown', message: text } };
|
|
133
134
|
}
|
|
134
135
|
if (RETRY_STATUS_CODES.has(resp.status) && attempt < this.maxRetries) {
|
|
135
136
|
await sleep(backoffDelay(attempt) * 1000);
|
|
@@ -171,11 +172,12 @@ export class Transport {
|
|
|
171
172
|
});
|
|
172
173
|
|
|
173
174
|
if (resp.status >= 400) {
|
|
175
|
+
const text = await resp.text();
|
|
174
176
|
let body: Record<string, unknown>;
|
|
175
177
|
try {
|
|
176
|
-
body =
|
|
178
|
+
body = JSON.parse(text) as Record<string, unknown>;
|
|
177
179
|
} catch {
|
|
178
|
-
body = { error: { code: 'unknown', message:
|
|
180
|
+
body = { error: { code: 'unknown', message: text } };
|
|
179
181
|
}
|
|
180
182
|
throw mapError(resp.status, body);
|
|
181
183
|
}
|
|
@@ -241,11 +243,12 @@ export class Transport {
|
|
|
241
243
|
clearTimeout(timer);
|
|
242
244
|
|
|
243
245
|
if (resp.status >= 400) {
|
|
246
|
+
const text = await resp.text();
|
|
244
247
|
let respBody: Record<string, unknown>;
|
|
245
248
|
try {
|
|
246
|
-
respBody =
|
|
249
|
+
respBody = JSON.parse(text) as Record<string, unknown>;
|
|
247
250
|
} catch {
|
|
248
|
-
respBody = { error: { code: 'unknown', message:
|
|
251
|
+
respBody = { error: { code: 'unknown', message: text } };
|
|
249
252
|
}
|
|
250
253
|
throw mapError(resp.status, respBody);
|
|
251
254
|
}
|
package/dist/client.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/** Top-level AceDataCloud client for TypeScript. */
|
|
2
|
-
import { Chat } from './resources/chat';
|
|
3
|
-
import { Images } from './resources/images';
|
|
4
|
-
import { Audio } from './resources/audio';
|
|
5
|
-
import { Video } from './resources/video';
|
|
6
|
-
import { Search } from './resources/search';
|
|
7
|
-
import { Tasks } from './resources/tasks';
|
|
8
|
-
import { Files } from './resources/files';
|
|
9
|
-
import { Platform } from './resources/platform';
|
|
10
|
-
import { OpenAI } from './resources/openai';
|
|
11
|
-
export interface AceDataCloudOptions {
|
|
12
|
-
apiToken?: string;
|
|
13
|
-
baseURL?: string;
|
|
14
|
-
platformBaseURL?: string;
|
|
15
|
-
timeout?: number;
|
|
16
|
-
maxRetries?: number;
|
|
17
|
-
headers?: Record<string, string>;
|
|
18
|
-
}
|
|
19
|
-
export declare class AceDataCloud {
|
|
20
|
-
readonly chat: Chat;
|
|
21
|
-
readonly images: Images;
|
|
22
|
-
readonly audio: Audio;
|
|
23
|
-
readonly video: Video;
|
|
24
|
-
readonly search: Search;
|
|
25
|
-
readonly tasks: Tasks;
|
|
26
|
-
readonly files: Files;
|
|
27
|
-
readonly platform: Platform;
|
|
28
|
-
readonly openai: OpenAI;
|
|
29
|
-
private transport;
|
|
30
|
-
constructor(opts?: AceDataCloudOptions);
|
|
31
|
-
}
|
package/dist/client.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** Top-level AceDataCloud client for TypeScript. */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.AceDataCloud = void 0;
|
|
5
|
-
const transport_1 = require("./runtime/transport");
|
|
6
|
-
const chat_1 = require("./resources/chat");
|
|
7
|
-
const images_1 = require("./resources/images");
|
|
8
|
-
const audio_1 = require("./resources/audio");
|
|
9
|
-
const video_1 = require("./resources/video");
|
|
10
|
-
const search_1 = require("./resources/search");
|
|
11
|
-
const tasks_1 = require("./resources/tasks");
|
|
12
|
-
const files_1 = require("./resources/files");
|
|
13
|
-
const platform_1 = require("./resources/platform");
|
|
14
|
-
const openai_1 = require("./resources/openai");
|
|
15
|
-
class AceDataCloud {
|
|
16
|
-
chat;
|
|
17
|
-
images;
|
|
18
|
-
audio;
|
|
19
|
-
video;
|
|
20
|
-
search;
|
|
21
|
-
tasks;
|
|
22
|
-
files;
|
|
23
|
-
platform;
|
|
24
|
-
openai;
|
|
25
|
-
transport;
|
|
26
|
-
constructor(opts = {}) {
|
|
27
|
-
this.transport = new transport_1.Transport({
|
|
28
|
-
apiToken: opts.apiToken,
|
|
29
|
-
baseURL: opts.baseURL,
|
|
30
|
-
platformBaseURL: opts.platformBaseURL,
|
|
31
|
-
timeout: opts.timeout,
|
|
32
|
-
maxRetries: opts.maxRetries,
|
|
33
|
-
headers: opts.headers,
|
|
34
|
-
});
|
|
35
|
-
this.chat = new chat_1.Chat(this.transport);
|
|
36
|
-
this.images = new images_1.Images(this.transport);
|
|
37
|
-
this.audio = new audio_1.Audio(this.transport);
|
|
38
|
-
this.video = new video_1.Video(this.transport);
|
|
39
|
-
this.search = new search_1.Search(this.transport);
|
|
40
|
-
this.tasks = new tasks_1.Tasks(this.transport);
|
|
41
|
-
this.files = new files_1.Files(this.transport);
|
|
42
|
-
this.platform = new platform_1.Platform(this.transport);
|
|
43
|
-
this.openai = new openai_1.OpenAI(this.transport);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.AceDataCloud = AceDataCloud;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** Audio/music generation resources. */
|
|
2
|
-
import { Transport } from '../runtime/transport';
|
|
3
|
-
import { TaskHandle } from '../runtime/tasks';
|
|
4
|
-
export declare class Audio {
|
|
5
|
-
private transport;
|
|
6
|
-
constructor(transport: Transport);
|
|
7
|
-
generate(opts: {
|
|
8
|
-
prompt: string;
|
|
9
|
-
model?: string;
|
|
10
|
-
tags?: string;
|
|
11
|
-
callbackUrl?: string;
|
|
12
|
-
wait?: boolean;
|
|
13
|
-
pollInterval?: number;
|
|
14
|
-
maxWait?: number;
|
|
15
|
-
[key: string]: unknown;
|
|
16
|
-
}): Promise<Record<string, unknown> | TaskHandle>;
|
|
17
|
-
}
|
package/dist/resources/audio.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** Audio/music generation resources. */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Audio = void 0;
|
|
5
|
-
const tasks_1 = require("../runtime/tasks");
|
|
6
|
-
class Audio {
|
|
7
|
-
transport;
|
|
8
|
-
constructor(transport) {
|
|
9
|
-
this.transport = transport;
|
|
10
|
-
}
|
|
11
|
-
async generate(opts) {
|
|
12
|
-
const { prompt, model, tags, callbackUrl, wait: shouldWait, pollInterval, maxWait, ...rest } = opts;
|
|
13
|
-
const body = { prompt, ...rest };
|
|
14
|
-
if (model !== undefined)
|
|
15
|
-
body.model = model;
|
|
16
|
-
if (tags !== undefined)
|
|
17
|
-
body.tags = tags;
|
|
18
|
-
if (callbackUrl !== undefined)
|
|
19
|
-
body.callback_url = callbackUrl;
|
|
20
|
-
const result = await this.transport.request('POST', '/suno/audios', { json: body });
|
|
21
|
-
const taskId = result.task_id;
|
|
22
|
-
if (!taskId || (result.data && !shouldWait))
|
|
23
|
-
return result;
|
|
24
|
-
const handle = new tasks_1.TaskHandle(taskId, '/suno/tasks', this.transport);
|
|
25
|
-
if (shouldWait)
|
|
26
|
-
return handle.wait({ pollInterval, maxWait });
|
|
27
|
-
return handle;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.Audio = Audio;
|
package/dist/resources/chat.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/** Chat resources — native provider APIs (Claude Messages). */
|
|
2
|
-
import { Transport } from '../runtime/transport';
|
|
3
|
-
export declare class Messages {
|
|
4
|
-
private transport;
|
|
5
|
-
constructor(transport: Transport);
|
|
6
|
-
create(opts: {
|
|
7
|
-
model: string;
|
|
8
|
-
messages: Array<Record<string, unknown>>;
|
|
9
|
-
maxTokens?: number;
|
|
10
|
-
stream?: false;
|
|
11
|
-
[key: string]: unknown;
|
|
12
|
-
}): Promise<Record<string, unknown>>;
|
|
13
|
-
create(opts: {
|
|
14
|
-
model: string;
|
|
15
|
-
messages: Array<Record<string, unknown>>;
|
|
16
|
-
maxTokens?: number;
|
|
17
|
-
stream: true;
|
|
18
|
-
[key: string]: unknown;
|
|
19
|
-
}): Promise<AsyncGenerator<Record<string, unknown>>>;
|
|
20
|
-
private stream;
|
|
21
|
-
countTokens(opts: {
|
|
22
|
-
model: string;
|
|
23
|
-
messages: Array<Record<string, unknown>>;
|
|
24
|
-
[key: string]: unknown;
|
|
25
|
-
}): Promise<Record<string, unknown>>;
|
|
26
|
-
}
|
|
27
|
-
export declare class Chat {
|
|
28
|
-
readonly messages: Messages;
|
|
29
|
-
constructor(transport: Transport);
|
|
30
|
-
}
|
package/dist/resources/chat.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** Chat resources — native provider APIs (Claude Messages). */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Chat = exports.Messages = void 0;
|
|
5
|
-
class Messages {
|
|
6
|
-
transport;
|
|
7
|
-
constructor(transport) {
|
|
8
|
-
this.transport = transport;
|
|
9
|
-
}
|
|
10
|
-
async create(opts) {
|
|
11
|
-
const { model, messages, maxTokens = 4096, stream, ...rest } = opts;
|
|
12
|
-
const body = { model, messages, max_tokens: maxTokens, ...rest };
|
|
13
|
-
if (stream) {
|
|
14
|
-
body.stream = true;
|
|
15
|
-
return this.stream(body);
|
|
16
|
-
}
|
|
17
|
-
return this.transport.request('POST', '/v1/messages', { json: body });
|
|
18
|
-
}
|
|
19
|
-
async *stream(body) {
|
|
20
|
-
for await (const chunk of this.transport.requestStream('POST', '/v1/messages', { json: body })) {
|
|
21
|
-
yield JSON.parse(chunk);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async countTokens(opts) {
|
|
25
|
-
const { model, messages, ...rest } = opts;
|
|
26
|
-
return this.transport.request('POST', '/v1/messages/count_tokens', {
|
|
27
|
-
json: { model, messages, ...rest },
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.Messages = Messages;
|
|
32
|
-
class Chat {
|
|
33
|
-
messages;
|
|
34
|
-
constructor(transport) {
|
|
35
|
-
this.messages = new Messages(transport);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.Chat = Chat;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** File upload resources. */
|
|
2
|
-
import { Transport } from '../runtime/transport';
|
|
3
|
-
export declare class Files {
|
|
4
|
-
private transport;
|
|
5
|
-
constructor(transport: Transport);
|
|
6
|
-
upload(file: string | Buffer | Uint8Array, opts?: {
|
|
7
|
-
filename?: string;
|
|
8
|
-
}): Promise<Record<string, unknown>>;
|
|
9
|
-
}
|
package/dist/resources/files.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** File upload resources. */
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.Files = void 0;
|
|
38
|
-
const fs = __importStar(require("fs"));
|
|
39
|
-
const path = __importStar(require("path"));
|
|
40
|
-
class Files {
|
|
41
|
-
transport;
|
|
42
|
-
constructor(transport) {
|
|
43
|
-
this.transport = transport;
|
|
44
|
-
}
|
|
45
|
-
async upload(file, opts = {}) {
|
|
46
|
-
let data;
|
|
47
|
-
let filename;
|
|
48
|
-
if (typeof file === 'string') {
|
|
49
|
-
data = fs.readFileSync(file);
|
|
50
|
-
filename = opts.filename ?? path.basename(file);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
data = file;
|
|
54
|
-
filename = opts.filename ?? 'upload';
|
|
55
|
-
}
|
|
56
|
-
return this.transport.upload('/api/v1/files/', data, filename);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.Files = Files;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/** Image generation resources. */
|
|
2
|
-
import { Transport } from '../runtime/transport';
|
|
3
|
-
import { TaskHandle } from '../runtime/tasks';
|
|
4
|
-
export declare class Images {
|
|
5
|
-
private transport;
|
|
6
|
-
constructor(transport: Transport);
|
|
7
|
-
generate(opts: {
|
|
8
|
-
prompt: string;
|
|
9
|
-
model?: string;
|
|
10
|
-
negativePrompt?: string;
|
|
11
|
-
imageUrl?: string;
|
|
12
|
-
callbackUrl?: string;
|
|
13
|
-
wait?: boolean;
|
|
14
|
-
pollInterval?: number;
|
|
15
|
-
maxWait?: number;
|
|
16
|
-
[key: string]: unknown;
|
|
17
|
-
}): Promise<Record<string, unknown> | TaskHandle>;
|
|
18
|
-
}
|