@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
package/dist/resources/images.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** Image generation resources. */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Images = void 0;
|
|
5
|
-
const tasks_1 = require("../runtime/tasks");
|
|
6
|
-
class Images {
|
|
7
|
-
transport;
|
|
8
|
-
constructor(transport) {
|
|
9
|
-
this.transport = transport;
|
|
10
|
-
}
|
|
11
|
-
async generate(opts) {
|
|
12
|
-
const { prompt, model, negativePrompt, imageUrl, callbackUrl, wait: shouldWait, pollInterval, maxWait, ...rest } = opts;
|
|
13
|
-
const body = { prompt, ...rest };
|
|
14
|
-
if (model !== undefined)
|
|
15
|
-
body.model = model;
|
|
16
|
-
if (negativePrompt !== undefined)
|
|
17
|
-
body.negative_prompt = negativePrompt;
|
|
18
|
-
if (imageUrl !== undefined)
|
|
19
|
-
body.image_url = imageUrl;
|
|
20
|
-
if (callbackUrl !== undefined)
|
|
21
|
-
body.callback_url = callbackUrl;
|
|
22
|
-
const result = await this.transport.request('POST', '/nano-banana/images', { json: body });
|
|
23
|
-
const taskId = result.task_id;
|
|
24
|
-
if (!taskId || (result.data && !shouldWait))
|
|
25
|
-
return result;
|
|
26
|
-
const handle = new tasks_1.TaskHandle(taskId, '/nano-banana/tasks', this.transport);
|
|
27
|
-
if (shouldWait)
|
|
28
|
-
return handle.wait({ pollInterval, maxWait });
|
|
29
|
-
return handle;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.Images = Images;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/** OpenAI-compatible facade resources. */
|
|
2
|
-
import { Transport } from '../runtime/transport';
|
|
3
|
-
declare class Completions {
|
|
4
|
-
private transport;
|
|
5
|
-
constructor(transport: Transport);
|
|
6
|
-
create(opts: {
|
|
7
|
-
model: string;
|
|
8
|
-
messages: Array<Record<string, unknown>>;
|
|
9
|
-
stream?: false;
|
|
10
|
-
[key: string]: unknown;
|
|
11
|
-
}): Promise<Record<string, unknown>>;
|
|
12
|
-
create(opts: {
|
|
13
|
-
model: string;
|
|
14
|
-
messages: Array<Record<string, unknown>>;
|
|
15
|
-
stream: true;
|
|
16
|
-
[key: string]: unknown;
|
|
17
|
-
}): Promise<AsyncGenerator<Record<string, unknown>>>;
|
|
18
|
-
private streamResponse;
|
|
19
|
-
}
|
|
20
|
-
declare class ChatNamespace {
|
|
21
|
-
readonly completions: Completions;
|
|
22
|
-
constructor(transport: Transport);
|
|
23
|
-
}
|
|
24
|
-
declare class Responses {
|
|
25
|
-
private transport;
|
|
26
|
-
constructor(transport: Transport);
|
|
27
|
-
create(opts: {
|
|
28
|
-
model: string;
|
|
29
|
-
input: string | Array<Record<string, unknown>>;
|
|
30
|
-
stream?: false;
|
|
31
|
-
[key: string]: unknown;
|
|
32
|
-
}): Promise<Record<string, unknown>>;
|
|
33
|
-
create(opts: {
|
|
34
|
-
model: string;
|
|
35
|
-
input: string | Array<Record<string, unknown>>;
|
|
36
|
-
stream: true;
|
|
37
|
-
[key: string]: unknown;
|
|
38
|
-
}): Promise<AsyncGenerator<Record<string, unknown>>>;
|
|
39
|
-
private streamResponse;
|
|
40
|
-
}
|
|
41
|
-
export declare class OpenAI {
|
|
42
|
-
readonly chat: ChatNamespace;
|
|
43
|
-
readonly responses: Responses;
|
|
44
|
-
constructor(transport: Transport);
|
|
45
|
-
}
|
|
46
|
-
export {};
|
package/dist/resources/openai.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** OpenAI-compatible facade resources. */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.OpenAI = void 0;
|
|
5
|
-
class Completions {
|
|
6
|
-
transport;
|
|
7
|
-
constructor(transport) {
|
|
8
|
-
this.transport = transport;
|
|
9
|
-
}
|
|
10
|
-
async create(opts) {
|
|
11
|
-
const { model, messages, stream, ...rest } = opts;
|
|
12
|
-
const body = { model, messages, ...rest };
|
|
13
|
-
if (stream) {
|
|
14
|
-
body.stream = true;
|
|
15
|
-
return this.streamResponse(body);
|
|
16
|
-
}
|
|
17
|
-
return this.transport.request('POST', '/v1/chat/completions', { json: body });
|
|
18
|
-
}
|
|
19
|
-
async *streamResponse(body) {
|
|
20
|
-
for await (const chunk of this.transport.requestStream('POST', '/v1/chat/completions', { json: body })) {
|
|
21
|
-
yield JSON.parse(chunk);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
class ChatNamespace {
|
|
26
|
-
completions;
|
|
27
|
-
constructor(transport) {
|
|
28
|
-
this.completions = new Completions(transport);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
class Responses {
|
|
32
|
-
transport;
|
|
33
|
-
constructor(transport) {
|
|
34
|
-
this.transport = transport;
|
|
35
|
-
}
|
|
36
|
-
async create(opts) {
|
|
37
|
-
const { model, input, stream, ...rest } = opts;
|
|
38
|
-
const body = { model, input, ...rest };
|
|
39
|
-
if (stream) {
|
|
40
|
-
body.stream = true;
|
|
41
|
-
return this.streamResponse(body);
|
|
42
|
-
}
|
|
43
|
-
return this.transport.request('POST', '/openai/responses', { json: body });
|
|
44
|
-
}
|
|
45
|
-
async *streamResponse(body) {
|
|
46
|
-
for await (const chunk of this.transport.requestStream('POST', '/openai/responses', { json: body })) {
|
|
47
|
-
yield JSON.parse(chunk);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
class OpenAI {
|
|
52
|
-
chat;
|
|
53
|
-
responses;
|
|
54
|
-
constructor(transport) {
|
|
55
|
-
this.chat = new ChatNamespace(transport);
|
|
56
|
-
this.responses = new Responses(transport);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.OpenAI = OpenAI;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/** Management-plane resources. */
|
|
2
|
-
import { Transport } from '../runtime/transport';
|
|
3
|
-
declare class Applications {
|
|
4
|
-
private transport;
|
|
5
|
-
constructor(transport: Transport);
|
|
6
|
-
list(params?: Record<string, string>): Promise<Record<string, unknown>>;
|
|
7
|
-
create(opts: {
|
|
8
|
-
serviceId: string;
|
|
9
|
-
[key: string]: unknown;
|
|
10
|
-
}): Promise<Record<string, unknown>>;
|
|
11
|
-
get(applicationId: string): Promise<Record<string, unknown>>;
|
|
12
|
-
}
|
|
13
|
-
declare class Credentials {
|
|
14
|
-
private transport;
|
|
15
|
-
constructor(transport: Transport);
|
|
16
|
-
list(params?: Record<string, string>): Promise<Record<string, unknown>>;
|
|
17
|
-
create(opts: {
|
|
18
|
-
applicationId: string;
|
|
19
|
-
[key: string]: unknown;
|
|
20
|
-
}): Promise<Record<string, unknown>>;
|
|
21
|
-
rotate(credentialId: string): Promise<Record<string, unknown>>;
|
|
22
|
-
delete(credentialId: string): Promise<Record<string, unknown>>;
|
|
23
|
-
}
|
|
24
|
-
declare class Models {
|
|
25
|
-
private transport;
|
|
26
|
-
constructor(transport: Transport);
|
|
27
|
-
list(params?: Record<string, string>): Promise<Record<string, unknown>>;
|
|
28
|
-
}
|
|
29
|
-
declare class Config {
|
|
30
|
-
private transport;
|
|
31
|
-
constructor(transport: Transport);
|
|
32
|
-
get(): Promise<Record<string, unknown>>;
|
|
33
|
-
}
|
|
34
|
-
export declare class Platform {
|
|
35
|
-
readonly applications: Applications;
|
|
36
|
-
readonly credentials: Credentials;
|
|
37
|
-
readonly models: Models;
|
|
38
|
-
readonly config: Config;
|
|
39
|
-
constructor(transport: Transport);
|
|
40
|
-
}
|
|
41
|
-
export {};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** Management-plane resources. */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Platform = void 0;
|
|
5
|
-
class Applications {
|
|
6
|
-
transport;
|
|
7
|
-
constructor(transport) {
|
|
8
|
-
this.transport = transport;
|
|
9
|
-
}
|
|
10
|
-
async list(params) {
|
|
11
|
-
return this.transport.request('GET', '/api/v1/applications/', { params, platform: true });
|
|
12
|
-
}
|
|
13
|
-
async create(opts) {
|
|
14
|
-
const { serviceId, ...rest } = opts;
|
|
15
|
-
return this.transport.request('POST', '/api/v1/applications/', {
|
|
16
|
-
json: { service_id: serviceId, ...rest },
|
|
17
|
-
platform: true,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
async get(applicationId) {
|
|
21
|
-
return this.transport.request('GET', `/api/v1/applications/${applicationId}/`, { platform: true });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
class Credentials {
|
|
25
|
-
transport;
|
|
26
|
-
constructor(transport) {
|
|
27
|
-
this.transport = transport;
|
|
28
|
-
}
|
|
29
|
-
async list(params) {
|
|
30
|
-
return this.transport.request('GET', '/api/v1/credentials/', { params, platform: true });
|
|
31
|
-
}
|
|
32
|
-
async create(opts) {
|
|
33
|
-
const { applicationId, ...rest } = opts;
|
|
34
|
-
return this.transport.request('POST', '/api/v1/credentials/', {
|
|
35
|
-
json: { application_id: applicationId, ...rest },
|
|
36
|
-
platform: true,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
async rotate(credentialId) {
|
|
40
|
-
return this.transport.request('POST', `/api/v1/credentials/${credentialId}/rotate/`, { platform: true });
|
|
41
|
-
}
|
|
42
|
-
async delete(credentialId) {
|
|
43
|
-
return this.transport.request('DELETE', `/api/v1/credentials/${credentialId}/`, { platform: true });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
class Models {
|
|
47
|
-
transport;
|
|
48
|
-
constructor(transport) {
|
|
49
|
-
this.transport = transport;
|
|
50
|
-
}
|
|
51
|
-
async list(params) {
|
|
52
|
-
return this.transport.request('GET', '/api/v1/models/', { params, platform: true });
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
class Config {
|
|
56
|
-
transport;
|
|
57
|
-
constructor(transport) {
|
|
58
|
-
this.transport = transport;
|
|
59
|
-
}
|
|
60
|
-
async get() {
|
|
61
|
-
return this.transport.request('GET', '/api/v1/config/', { platform: true });
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
class Platform {
|
|
65
|
-
applications;
|
|
66
|
-
credentials;
|
|
67
|
-
models;
|
|
68
|
-
config;
|
|
69
|
-
constructor(transport) {
|
|
70
|
-
this.applications = new Applications(transport);
|
|
71
|
-
this.credentials = new Credentials(transport);
|
|
72
|
-
this.models = new Models(transport);
|
|
73
|
-
this.config = new Config(transport);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.Platform = Platform;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** Search resources. */
|
|
2
|
-
import { Transport } from '../runtime/transport';
|
|
3
|
-
export declare class Search {
|
|
4
|
-
private transport;
|
|
5
|
-
constructor(transport: Transport);
|
|
6
|
-
google(opts: {
|
|
7
|
-
query: string;
|
|
8
|
-
type?: string;
|
|
9
|
-
country?: string;
|
|
10
|
-
language?: string;
|
|
11
|
-
page?: number;
|
|
12
|
-
[key: string]: unknown;
|
|
13
|
-
}): Promise<Record<string, unknown>>;
|
|
14
|
-
}
|
package/dist/resources/search.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** Search resources. */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Search = void 0;
|
|
5
|
-
class Search {
|
|
6
|
-
transport;
|
|
7
|
-
constructor(transport) {
|
|
8
|
-
this.transport = transport;
|
|
9
|
-
}
|
|
10
|
-
async google(opts) {
|
|
11
|
-
const { query, type = 'search', country, language, page, ...rest } = opts;
|
|
12
|
-
const body = { query, type, ...rest };
|
|
13
|
-
if (country !== undefined)
|
|
14
|
-
body.country = country;
|
|
15
|
-
if (language !== undefined)
|
|
16
|
-
body.language = language;
|
|
17
|
-
if (page !== undefined)
|
|
18
|
-
body.page = page;
|
|
19
|
-
return this.transport.request('POST', '/serp/google', { json: body });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.Search = Search;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** Cross-service task retrieval. */
|
|
2
|
-
import { Transport } from '../runtime/transport';
|
|
3
|
-
export declare class Tasks {
|
|
4
|
-
private transport;
|
|
5
|
-
constructor(transport: Transport);
|
|
6
|
-
get(taskId: string, opts?: {
|
|
7
|
-
service?: string;
|
|
8
|
-
}): Promise<Record<string, unknown>>;
|
|
9
|
-
wait(taskId: string, opts?: {
|
|
10
|
-
service?: string;
|
|
11
|
-
pollInterval?: number;
|
|
12
|
-
maxWait?: number;
|
|
13
|
-
}): Promise<Record<string, unknown>>;
|
|
14
|
-
}
|
package/dist/resources/tasks.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** Cross-service task retrieval. */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Tasks = void 0;
|
|
5
|
-
const tasks_1 = require("../runtime/tasks");
|
|
6
|
-
const SERVICE_TASK_ENDPOINTS = {
|
|
7
|
-
suno: '/suno/tasks',
|
|
8
|
-
'nano-banana': '/nano-banana/tasks',
|
|
9
|
-
seedream: '/seedream/tasks',
|
|
10
|
-
seedance: '/seedance/tasks',
|
|
11
|
-
sora: '/sora/tasks',
|
|
12
|
-
midjourney: '/midjourney/tasks',
|
|
13
|
-
luma: '/luma/tasks',
|
|
14
|
-
veo: '/veo/tasks',
|
|
15
|
-
flux: '/flux/tasks',
|
|
16
|
-
};
|
|
17
|
-
class Tasks {
|
|
18
|
-
transport;
|
|
19
|
-
constructor(transport) {
|
|
20
|
-
this.transport = transport;
|
|
21
|
-
}
|
|
22
|
-
async get(taskId, opts = {}) {
|
|
23
|
-
const service = opts.service ?? 'suno';
|
|
24
|
-
const endpoint = SERVICE_TASK_ENDPOINTS[service] ?? `/${service}/tasks`;
|
|
25
|
-
return this.transport.request('POST', endpoint, {
|
|
26
|
-
json: { id: taskId, action: 'retrieve' },
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
async wait(taskId, opts = {}) {
|
|
30
|
-
const service = opts.service ?? 'suno';
|
|
31
|
-
const endpoint = SERVICE_TASK_ENDPOINTS[service] ?? `/${service}/tasks`;
|
|
32
|
-
const handle = new tasks_1.TaskHandle(taskId, endpoint, this.transport);
|
|
33
|
-
return handle.wait({ pollInterval: opts.pollInterval, maxWait: opts.maxWait });
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.Tasks = Tasks;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** Video generation resources. */
|
|
2
|
-
import { Transport } from '../runtime/transport';
|
|
3
|
-
import { TaskHandle } from '../runtime/tasks';
|
|
4
|
-
export declare class Video {
|
|
5
|
-
private transport;
|
|
6
|
-
constructor(transport: Transport);
|
|
7
|
-
generate(opts: {
|
|
8
|
-
prompt: string;
|
|
9
|
-
model?: string;
|
|
10
|
-
imageUrl?: 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/video.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** Video generation resources. */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Video = void 0;
|
|
5
|
-
const tasks_1 = require("../runtime/tasks");
|
|
6
|
-
class Video {
|
|
7
|
-
transport;
|
|
8
|
-
constructor(transport) {
|
|
9
|
-
this.transport = transport;
|
|
10
|
-
}
|
|
11
|
-
async generate(opts) {
|
|
12
|
-
const { prompt, model, imageUrl, callbackUrl, wait: shouldWait, pollInterval, maxWait, ...rest } = opts;
|
|
13
|
-
const body = { prompt, ...rest };
|
|
14
|
-
if (model !== undefined)
|
|
15
|
-
body.model = model;
|
|
16
|
-
if (imageUrl !== undefined)
|
|
17
|
-
body.image_url = imageUrl;
|
|
18
|
-
if (callbackUrl !== undefined)
|
|
19
|
-
body.callback_url = callbackUrl;
|
|
20
|
-
const result = await this.transport.request('POST', '/sora/videos', { 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, '/sora/tasks', this.transport);
|
|
25
|
-
if (shouldWait)
|
|
26
|
-
return handle.wait({ pollInterval, maxWait });
|
|
27
|
-
return handle;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.Video = Video;
|
package/dist/runtime/errors.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/** AceDataCloud SDK errors. */
|
|
2
|
-
export declare class AceDataCloudError extends Error {
|
|
3
|
-
constructor(message: string);
|
|
4
|
-
}
|
|
5
|
-
export declare class TransportError extends AceDataCloudError {
|
|
6
|
-
constructor(message: string);
|
|
7
|
-
}
|
|
8
|
-
export declare class APIError extends AceDataCloudError {
|
|
9
|
-
statusCode: number;
|
|
10
|
-
code: string;
|
|
11
|
-
traceId?: string;
|
|
12
|
-
body: Record<string, unknown>;
|
|
13
|
-
constructor(opts: {
|
|
14
|
-
message: string;
|
|
15
|
-
statusCode: number;
|
|
16
|
-
code: string;
|
|
17
|
-
traceId?: string;
|
|
18
|
-
body?: Record<string, unknown>;
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
export declare class AuthenticationError extends APIError {
|
|
22
|
-
constructor(opts: ConstructorParameters<typeof APIError>[0]);
|
|
23
|
-
}
|
|
24
|
-
export declare class TokenMismatchError extends APIError {
|
|
25
|
-
constructor(opts: ConstructorParameters<typeof APIError>[0]);
|
|
26
|
-
}
|
|
27
|
-
export declare class RateLimitError extends APIError {
|
|
28
|
-
constructor(opts: ConstructorParameters<typeof APIError>[0]);
|
|
29
|
-
}
|
|
30
|
-
export declare class ValidationError extends APIError {
|
|
31
|
-
constructor(opts: ConstructorParameters<typeof APIError>[0]);
|
|
32
|
-
}
|
|
33
|
-
export declare class InsufficientBalanceError extends APIError {
|
|
34
|
-
constructor(opts: ConstructorParameters<typeof APIError>[0]);
|
|
35
|
-
}
|
|
36
|
-
export declare class ResourceDisabledError extends APIError {
|
|
37
|
-
constructor(opts: ConstructorParameters<typeof APIError>[0]);
|
|
38
|
-
}
|
|
39
|
-
export declare class ModerationError extends APIError {
|
|
40
|
-
constructor(opts: ConstructorParameters<typeof APIError>[0]);
|
|
41
|
-
}
|
|
42
|
-
export declare class TimeoutError extends APIError {
|
|
43
|
-
constructor(opts: ConstructorParameters<typeof APIError>[0]);
|
|
44
|
-
}
|
package/dist/runtime/errors.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** AceDataCloud SDK errors. */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.TimeoutError = exports.ModerationError = exports.ResourceDisabledError = exports.InsufficientBalanceError = exports.ValidationError = exports.RateLimitError = exports.TokenMismatchError = exports.AuthenticationError = exports.APIError = exports.TransportError = exports.AceDataCloudError = void 0;
|
|
5
|
-
class AceDataCloudError extends Error {
|
|
6
|
-
constructor(message) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.name = 'AceDataCloudError';
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.AceDataCloudError = AceDataCloudError;
|
|
12
|
-
class TransportError extends AceDataCloudError {
|
|
13
|
-
constructor(message) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.name = 'TransportError';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.TransportError = TransportError;
|
|
19
|
-
class APIError extends AceDataCloudError {
|
|
20
|
-
statusCode;
|
|
21
|
-
code;
|
|
22
|
-
traceId;
|
|
23
|
-
body;
|
|
24
|
-
constructor(opts) {
|
|
25
|
-
super(opts.message);
|
|
26
|
-
this.name = 'APIError';
|
|
27
|
-
this.statusCode = opts.statusCode;
|
|
28
|
-
this.code = opts.code;
|
|
29
|
-
this.traceId = opts.traceId;
|
|
30
|
-
this.body = opts.body ?? {};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.APIError = APIError;
|
|
34
|
-
class AuthenticationError extends APIError {
|
|
35
|
-
constructor(opts) {
|
|
36
|
-
super(opts);
|
|
37
|
-
this.name = 'AuthenticationError';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.AuthenticationError = AuthenticationError;
|
|
41
|
-
class TokenMismatchError extends APIError {
|
|
42
|
-
constructor(opts) {
|
|
43
|
-
super(opts);
|
|
44
|
-
this.name = 'TokenMismatchError';
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.TokenMismatchError = TokenMismatchError;
|
|
48
|
-
class RateLimitError extends APIError {
|
|
49
|
-
constructor(opts) {
|
|
50
|
-
super(opts);
|
|
51
|
-
this.name = 'RateLimitError';
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.RateLimitError = RateLimitError;
|
|
55
|
-
class ValidationError extends APIError {
|
|
56
|
-
constructor(opts) {
|
|
57
|
-
super(opts);
|
|
58
|
-
this.name = 'ValidationError';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.ValidationError = ValidationError;
|
|
62
|
-
class InsufficientBalanceError extends APIError {
|
|
63
|
-
constructor(opts) {
|
|
64
|
-
super(opts);
|
|
65
|
-
this.name = 'InsufficientBalanceError';
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.InsufficientBalanceError = InsufficientBalanceError;
|
|
69
|
-
class ResourceDisabledError extends APIError {
|
|
70
|
-
constructor(opts) {
|
|
71
|
-
super(opts);
|
|
72
|
-
this.name = 'ResourceDisabledError';
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.ResourceDisabledError = ResourceDisabledError;
|
|
76
|
-
class ModerationError extends APIError {
|
|
77
|
-
constructor(opts) {
|
|
78
|
-
super(opts);
|
|
79
|
-
this.name = 'ModerationError';
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.ModerationError = ModerationError;
|
|
83
|
-
class TimeoutError extends APIError {
|
|
84
|
-
constructor(opts) {
|
|
85
|
-
super(opts);
|
|
86
|
-
this.name = 'TimeoutError';
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.TimeoutError = TimeoutError;
|
package/dist/runtime/index.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { Transport, TransportOptions } from './transport';
|
|
2
|
-
export { TaskHandle, TaskHandleOptions } from './tasks';
|
|
3
|
-
export { AceDataCloudError, APIError, AuthenticationError, InsufficientBalanceError, ModerationError, RateLimitError, ResourceDisabledError, TimeoutError, TokenMismatchError, TransportError, ValidationError, } from './errors';
|
package/dist/runtime/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValidationError = exports.TransportError = exports.TokenMismatchError = exports.TimeoutError = exports.ResourceDisabledError = exports.RateLimitError = exports.ModerationError = exports.InsufficientBalanceError = exports.AuthenticationError = exports.APIError = exports.AceDataCloudError = exports.TaskHandle = exports.Transport = void 0;
|
|
4
|
-
var transport_1 = require("./transport");
|
|
5
|
-
Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return transport_1.Transport; } });
|
|
6
|
-
var tasks_1 = require("./tasks");
|
|
7
|
-
Object.defineProperty(exports, "TaskHandle", { enumerable: true, get: function () { return tasks_1.TaskHandle; } });
|
|
8
|
-
var errors_1 = require("./errors");
|
|
9
|
-
Object.defineProperty(exports, "AceDataCloudError", { enumerable: true, get: function () { return errors_1.AceDataCloudError; } });
|
|
10
|
-
Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return errors_1.APIError; } });
|
|
11
|
-
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return errors_1.AuthenticationError; } });
|
|
12
|
-
Object.defineProperty(exports, "InsufficientBalanceError", { enumerable: true, get: function () { return errors_1.InsufficientBalanceError; } });
|
|
13
|
-
Object.defineProperty(exports, "ModerationError", { enumerable: true, get: function () { return errors_1.ModerationError; } });
|
|
14
|
-
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_1.RateLimitError; } });
|
|
15
|
-
Object.defineProperty(exports, "ResourceDisabledError", { enumerable: true, get: function () { return errors_1.ResourceDisabledError; } });
|
|
16
|
-
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_1.TimeoutError; } });
|
|
17
|
-
Object.defineProperty(exports, "TokenMismatchError", { enumerable: true, get: function () { return errors_1.TokenMismatchError; } });
|
|
18
|
-
Object.defineProperty(exports, "TransportError", { enumerable: true, get: function () { return errors_1.TransportError; } });
|
|
19
|
-
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_1.ValidationError; } });
|
package/dist/runtime/tasks.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** Task polling abstraction. */
|
|
2
|
-
import { Transport } from './transport';
|
|
3
|
-
export interface TaskHandleOptions {
|
|
4
|
-
pollInterval?: number;
|
|
5
|
-
maxWait?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare class TaskHandle {
|
|
8
|
-
readonly id: string;
|
|
9
|
-
private pollEndpoint;
|
|
10
|
-
private transport;
|
|
11
|
-
private _result;
|
|
12
|
-
constructor(taskId: string, pollEndpoint: string, transport: Transport);
|
|
13
|
-
get(): Promise<Record<string, unknown>>;
|
|
14
|
-
isCompleted(): Promise<boolean>;
|
|
15
|
-
wait(opts?: TaskHandleOptions): Promise<Record<string, unknown>>;
|
|
16
|
-
get result(): Record<string, unknown> | null;
|
|
17
|
-
}
|
package/dist/runtime/tasks.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** Task polling abstraction. */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.TaskHandle = void 0;
|
|
5
|
-
class TaskHandle {
|
|
6
|
-
id;
|
|
7
|
-
pollEndpoint;
|
|
8
|
-
transport;
|
|
9
|
-
_result = null;
|
|
10
|
-
constructor(taskId, pollEndpoint, transport) {
|
|
11
|
-
this.id = taskId;
|
|
12
|
-
this.pollEndpoint = pollEndpoint;
|
|
13
|
-
this.transport = transport;
|
|
14
|
-
}
|
|
15
|
-
async get() {
|
|
16
|
-
return this.transport.request('POST', this.pollEndpoint, {
|
|
17
|
-
json: { id: this.id, action: 'retrieve' },
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
async isCompleted() {
|
|
21
|
-
const state = await this.get();
|
|
22
|
-
const response = (state.response ?? state);
|
|
23
|
-
const status = response.status;
|
|
24
|
-
return status === 'succeeded' || status === 'failed';
|
|
25
|
-
}
|
|
26
|
-
async wait(opts = {}) {
|
|
27
|
-
const pollInterval = opts.pollInterval ?? 3000;
|
|
28
|
-
const maxWait = opts.maxWait ?? 600_000;
|
|
29
|
-
const start = Date.now();
|
|
30
|
-
while (Date.now() - start < maxWait) {
|
|
31
|
-
const state = await this.get();
|
|
32
|
-
const response = (state.response ?? state);
|
|
33
|
-
const status = response.status;
|
|
34
|
-
if (status === 'succeeded' || status === 'failed') {
|
|
35
|
-
this._result = state;
|
|
36
|
-
return state;
|
|
37
|
-
}
|
|
38
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
39
|
-
}
|
|
40
|
-
throw new Error(`Task ${this.id} did not complete within ${maxWait}ms`);
|
|
41
|
-
}
|
|
42
|
-
get result() {
|
|
43
|
-
return this._result;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.TaskHandle = TaskHandle;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/** HTTP transport for AceDataCloud SDK. Uses native fetch (Node 18+). */
|
|
2
|
-
export interface TransportOptions {
|
|
3
|
-
apiToken?: string;
|
|
4
|
-
baseURL?: string;
|
|
5
|
-
platformBaseURL?: string;
|
|
6
|
-
timeout?: number;
|
|
7
|
-
maxRetries?: number;
|
|
8
|
-
headers?: Record<string, string>;
|
|
9
|
-
}
|
|
10
|
-
export declare class Transport {
|
|
11
|
-
private baseURL;
|
|
12
|
-
private platformBaseURL;
|
|
13
|
-
private timeout;
|
|
14
|
-
private maxRetries;
|
|
15
|
-
private headers;
|
|
16
|
-
constructor(opts?: TransportOptions);
|
|
17
|
-
request(method: string, path: string, opts?: {
|
|
18
|
-
json?: Record<string, unknown>;
|
|
19
|
-
params?: Record<string, string>;
|
|
20
|
-
platform?: boolean;
|
|
21
|
-
timeout?: number;
|
|
22
|
-
headers?: Record<string, string>;
|
|
23
|
-
}): Promise<Record<string, unknown>>;
|
|
24
|
-
requestStream(method: string, path: string, opts?: {
|
|
25
|
-
json?: Record<string, unknown>;
|
|
26
|
-
timeout?: number;
|
|
27
|
-
}): AsyncGenerator<string, void, unknown>;
|
|
28
|
-
upload(path: string, fileData: Buffer | Uint8Array, filename: string, opts?: {
|
|
29
|
-
timeout?: number;
|
|
30
|
-
}): Promise<Record<string, unknown>>;
|
|
31
|
-
}
|