@indreamai/client 0.4.0 → 0.5.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.cjs +9 -155
- package/dist/index.d.cts +212 -511
- package/dist/index.d.ts +212 -511
- package/dist/index.js +8 -153
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -39,9 +39,8 @@ __export(index_exports, {
|
|
|
39
39
|
AuthError: () => AuthError,
|
|
40
40
|
EditorResource: () => EditorResource,
|
|
41
41
|
ExportsResource: () => ExportsResource,
|
|
42
|
+
IllustrationsResource: () => IllustrationsResource,
|
|
42
43
|
IndreamClient: () => IndreamClient,
|
|
43
|
-
MaterialsResource: () => MaterialsResource,
|
|
44
|
-
MediaResource: () => MediaResource,
|
|
45
44
|
ProjectsResource: () => ProjectsResource,
|
|
46
45
|
RateLimitError: () => RateLimitError,
|
|
47
46
|
UploadsResource: () => UploadsResource,
|
|
@@ -246,161 +245,18 @@ var EditorResource = class {
|
|
|
246
245
|
}
|
|
247
246
|
};
|
|
248
247
|
|
|
249
|
-
// src/resources/
|
|
250
|
-
var
|
|
248
|
+
// src/resources/illustrations.ts
|
|
249
|
+
var IllustrationsResource = class {
|
|
251
250
|
constructor(client) {
|
|
252
251
|
this.client = client;
|
|
253
252
|
}
|
|
254
|
-
async
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
if (!q) {
|
|
258
|
-
throw new Error("q is required");
|
|
259
|
-
}
|
|
260
|
-
const search = new URLSearchParams({ q });
|
|
261
|
-
if (params.pageSize) {
|
|
262
|
-
search.set("pageSize", String(params.pageSize));
|
|
263
|
-
}
|
|
264
|
-
if (params.pageCursor) {
|
|
265
|
-
search.set("pageCursor", params.pageCursor);
|
|
266
|
-
}
|
|
267
|
-
const envelope = await this.client.requestEnvelope(
|
|
268
|
-
`/v1/illustrations?${search.toString()}`,
|
|
269
|
-
{
|
|
270
|
-
method: "GET",
|
|
271
|
-
signal: params.signal
|
|
272
|
-
}
|
|
273
|
-
);
|
|
274
|
-
return {
|
|
275
|
-
items: envelope.data || [],
|
|
276
|
-
nextPageCursor: typeof ((_a = envelope.meta) == null ? void 0 : _a.nextPageCursor) === "string" ? envelope.meta.nextPageCursor : null
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
async searchVoices(params = {}) {
|
|
280
|
-
var _a;
|
|
281
|
-
const search = new URLSearchParams();
|
|
282
|
-
const q = (_a = params.q) == null ? void 0 : _a.trim();
|
|
283
|
-
if (q) {
|
|
284
|
-
search.set("q", q);
|
|
285
|
-
}
|
|
286
|
-
if (params.pageSize) {
|
|
287
|
-
search.set("pageSize", String(params.pageSize));
|
|
288
|
-
}
|
|
289
|
-
if (params.scope) {
|
|
290
|
-
search.set("scope", params.scope);
|
|
291
|
-
}
|
|
292
|
-
const query = search.toString();
|
|
293
|
-
return await this.client.request(`/v1/voices${query ? `?${query}` : ""}`, {
|
|
253
|
+
async search(q, options = {}) {
|
|
254
|
+
const query = typeof q === "string" && q.trim() ? "?q=" + encodeURIComponent(q.trim()) : "";
|
|
255
|
+
return await this.client.request("/v1/illustrations" + query, {
|
|
294
256
|
method: "GET",
|
|
295
|
-
signal: params.signal
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
// src/resources/media.ts
|
|
301
|
-
var MediaResource = class {
|
|
302
|
-
constructor(client) {
|
|
303
|
-
this.client = client;
|
|
304
|
-
}
|
|
305
|
-
async listMediaModels(params) {
|
|
306
|
-
var _a, _b;
|
|
307
|
-
const search = new URLSearchParams({ type: params.type });
|
|
308
|
-
if (params.assetMode) {
|
|
309
|
-
search.set("assetMode", params.assetMode);
|
|
310
|
-
}
|
|
311
|
-
const q = (_a = params.q) == null ? void 0 : _a.trim();
|
|
312
|
-
if (q) {
|
|
313
|
-
search.set("q", q);
|
|
314
|
-
}
|
|
315
|
-
if (params.pageSize) {
|
|
316
|
-
search.set("pageSize", String(params.pageSize));
|
|
317
|
-
}
|
|
318
|
-
if (params.pageCursor) {
|
|
319
|
-
search.set("pageCursor", params.pageCursor);
|
|
320
|
-
}
|
|
321
|
-
const envelope = await this.client.requestEnvelope(
|
|
322
|
-
`/v1/media/models?${search.toString()}`,
|
|
323
|
-
{
|
|
324
|
-
method: "GET",
|
|
325
|
-
signal: params.signal
|
|
326
|
-
}
|
|
327
|
-
);
|
|
328
|
-
return {
|
|
329
|
-
items: envelope.data || [],
|
|
330
|
-
nextPageCursor: typeof ((_b = envelope.meta) == null ? void 0 : _b.nextPageCursor) === "string" ? envelope.meta.nextPageCursor : null
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
async getMediaModel(capabilityKey, options = {}) {
|
|
334
|
-
const key = capabilityKey.trim();
|
|
335
|
-
if (!key) {
|
|
336
|
-
throw new Error("capabilityKey is required");
|
|
337
|
-
}
|
|
338
|
-
return await this.client.request(
|
|
339
|
-
`/v1/media/models/${encodeURIComponent(key)}`,
|
|
340
|
-
{
|
|
341
|
-
method: "GET",
|
|
342
|
-
signal: options.signal
|
|
343
|
-
}
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
async recommendMediaModels(payload, options = {}) {
|
|
347
|
-
return await this.client.request(
|
|
348
|
-
"/v1/media/models/operations/recommend",
|
|
349
|
-
{
|
|
350
|
-
method: "POST",
|
|
351
|
-
body: payload,
|
|
352
|
-
signal: options.signal
|
|
353
|
-
}
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
async generateImage(payload, options = {}) {
|
|
357
|
-
var _a;
|
|
358
|
-
return await this.client.request("/v1/media/images/operations/generate", {
|
|
359
|
-
method: "POST",
|
|
360
|
-
body: payload,
|
|
361
|
-
idempotencyKey: ((_a = options.idempotencyKey) == null ? void 0 : _a.trim()) || void 0,
|
|
362
257
|
signal: options.signal
|
|
363
258
|
});
|
|
364
259
|
}
|
|
365
|
-
async generateVideo(payload, options = {}) {
|
|
366
|
-
var _a;
|
|
367
|
-
return await this.client.request("/v1/media/videos/operations/generate", {
|
|
368
|
-
method: "POST",
|
|
369
|
-
body: payload,
|
|
370
|
-
idempotencyKey: ((_a = options.idempotencyKey) == null ? void 0 : _a.trim()) || void 0,
|
|
371
|
-
signal: options.signal
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
async generateMusic(payload, options = {}) {
|
|
375
|
-
var _a;
|
|
376
|
-
return await this.client.request("/v1/media/musics/operations/generate", {
|
|
377
|
-
method: "POST",
|
|
378
|
-
body: payload,
|
|
379
|
-
idempotencyKey: ((_a = options.idempotencyKey) == null ? void 0 : _a.trim()) || void 0,
|
|
380
|
-
signal: options.signal
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
async createTts(payload, options = {}) {
|
|
384
|
-
var _a;
|
|
385
|
-
return await this.client.request("/v1/media/audios/operations/tts", {
|
|
386
|
-
method: "POST",
|
|
387
|
-
body: payload,
|
|
388
|
-
idempotencyKey: ((_a = options.idempotencyKey) == null ? void 0 : _a.trim()) || void 0,
|
|
389
|
-
signal: options.signal
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
async createAutoCaptions(payload, options = {}) {
|
|
393
|
-
var _a;
|
|
394
|
-
return await this.client.request(
|
|
395
|
-
"/v1/media/audios/operations/auto-captions",
|
|
396
|
-
{
|
|
397
|
-
method: "POST",
|
|
398
|
-
body: payload,
|
|
399
|
-
idempotencyKey: ((_a = options.idempotencyKey) == null ? void 0 : _a.trim()) || void 0,
|
|
400
|
-
signal: options.signal
|
|
401
|
-
}
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
260
|
};
|
|
405
261
|
|
|
406
262
|
// src/resources/projects.ts
|
|
@@ -616,8 +472,7 @@ var IndreamClient = class {
|
|
|
616
472
|
this.fetchImpl = options.fetch || fetch;
|
|
617
473
|
this.exports = new ExportsResource(this);
|
|
618
474
|
this.editor = new EditorResource(this);
|
|
619
|
-
this.
|
|
620
|
-
this.media = new MediaResource(this);
|
|
475
|
+
this.illustrations = new IllustrationsResource(this);
|
|
621
476
|
this.projects = new ProjectsResource(this);
|
|
622
477
|
this.uploads = new UploadsResource(this);
|
|
623
478
|
this.assets = new AssetsResource(this);
|
|
@@ -627,7 +482,7 @@ var IndreamClient = class {
|
|
|
627
482
|
return envelope.data;
|
|
628
483
|
}
|
|
629
484
|
async requestEnvelope(path, init) {
|
|
630
|
-
const url =
|
|
485
|
+
const url = this.baseURL + (path.startsWith("/") ? path : "/" + path);
|
|
631
486
|
const isJsonPayload = init.body !== void 0 && !isBodyInit(init.body);
|
|
632
487
|
let payload;
|
|
633
488
|
if (init.body !== void 0) {
|
|
@@ -883,9 +738,8 @@ var verifyExportWebhookRequest = async ({
|
|
|
883
738
|
AuthError,
|
|
884
739
|
EditorResource,
|
|
885
740
|
ExportsResource,
|
|
741
|
+
IllustrationsResource,
|
|
886
742
|
IndreamClient,
|
|
887
|
-
MaterialsResource,
|
|
888
|
-
MediaResource,
|
|
889
743
|
ProjectsResource,
|
|
890
744
|
RateLimitError,
|
|
891
745
|
UploadsResource,
|