@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.js CHANGED
@@ -203,161 +203,18 @@ var EditorResource = class {
203
203
  }
204
204
  };
205
205
 
206
- // src/resources/materials.ts
207
- var MaterialsResource = class {
206
+ // src/resources/illustrations.ts
207
+ var IllustrationsResource = class {
208
208
  constructor(client) {
209
209
  this.client = client;
210
210
  }
211
- async searchIllustrations(params) {
212
- var _a;
213
- const q = params.q.trim();
214
- if (!q) {
215
- throw new Error("q is required");
216
- }
217
- const search = new URLSearchParams({ q });
218
- if (params.pageSize) {
219
- search.set("pageSize", String(params.pageSize));
220
- }
221
- if (params.pageCursor) {
222
- search.set("pageCursor", params.pageCursor);
223
- }
224
- const envelope = await this.client.requestEnvelope(
225
- `/v1/illustrations?${search.toString()}`,
226
- {
227
- method: "GET",
228
- signal: params.signal
229
- }
230
- );
231
- return {
232
- items: envelope.data || [],
233
- nextPageCursor: typeof ((_a = envelope.meta) == null ? void 0 : _a.nextPageCursor) === "string" ? envelope.meta.nextPageCursor : null
234
- };
235
- }
236
- async searchVoices(params = {}) {
237
- var _a;
238
- const search = new URLSearchParams();
239
- const q = (_a = params.q) == null ? void 0 : _a.trim();
240
- if (q) {
241
- search.set("q", q);
242
- }
243
- if (params.pageSize) {
244
- search.set("pageSize", String(params.pageSize));
245
- }
246
- if (params.scope) {
247
- search.set("scope", params.scope);
248
- }
249
- const query = search.toString();
250
- return await this.client.request(`/v1/voices${query ? `?${query}` : ""}`, {
211
+ async search(q, options = {}) {
212
+ const query = typeof q === "string" && q.trim() ? "?q=" + encodeURIComponent(q.trim()) : "";
213
+ return await this.client.request("/v1/illustrations" + query, {
251
214
  method: "GET",
252
- signal: params.signal
253
- });
254
- }
255
- };
256
-
257
- // src/resources/media.ts
258
- var MediaResource = class {
259
- constructor(client) {
260
- this.client = client;
261
- }
262
- async listMediaModels(params) {
263
- var _a, _b;
264
- const search = new URLSearchParams({ type: params.type });
265
- if (params.assetMode) {
266
- search.set("assetMode", params.assetMode);
267
- }
268
- const q = (_a = params.q) == null ? void 0 : _a.trim();
269
- if (q) {
270
- search.set("q", q);
271
- }
272
- if (params.pageSize) {
273
- search.set("pageSize", String(params.pageSize));
274
- }
275
- if (params.pageCursor) {
276
- search.set("pageCursor", params.pageCursor);
277
- }
278
- const envelope = await this.client.requestEnvelope(
279
- `/v1/media/models?${search.toString()}`,
280
- {
281
- method: "GET",
282
- signal: params.signal
283
- }
284
- );
285
- return {
286
- items: envelope.data || [],
287
- nextPageCursor: typeof ((_b = envelope.meta) == null ? void 0 : _b.nextPageCursor) === "string" ? envelope.meta.nextPageCursor : null
288
- };
289
- }
290
- async getMediaModel(capabilityKey, options = {}) {
291
- const key = capabilityKey.trim();
292
- if (!key) {
293
- throw new Error("capabilityKey is required");
294
- }
295
- return await this.client.request(
296
- `/v1/media/models/${encodeURIComponent(key)}`,
297
- {
298
- method: "GET",
299
- signal: options.signal
300
- }
301
- );
302
- }
303
- async recommendMediaModels(payload, options = {}) {
304
- return await this.client.request(
305
- "/v1/media/models/operations/recommend",
306
- {
307
- method: "POST",
308
- body: payload,
309
- signal: options.signal
310
- }
311
- );
312
- }
313
- async generateImage(payload, options = {}) {
314
- var _a;
315
- return await this.client.request("/v1/media/images/operations/generate", {
316
- method: "POST",
317
- body: payload,
318
- idempotencyKey: ((_a = options.idempotencyKey) == null ? void 0 : _a.trim()) || void 0,
319
215
  signal: options.signal
320
216
  });
321
217
  }
322
- async generateVideo(payload, options = {}) {
323
- var _a;
324
- return await this.client.request("/v1/media/videos/operations/generate", {
325
- method: "POST",
326
- body: payload,
327
- idempotencyKey: ((_a = options.idempotencyKey) == null ? void 0 : _a.trim()) || void 0,
328
- signal: options.signal
329
- });
330
- }
331
- async generateMusic(payload, options = {}) {
332
- var _a;
333
- return await this.client.request("/v1/media/musics/operations/generate", {
334
- method: "POST",
335
- body: payload,
336
- idempotencyKey: ((_a = options.idempotencyKey) == null ? void 0 : _a.trim()) || void 0,
337
- signal: options.signal
338
- });
339
- }
340
- async createTts(payload, options = {}) {
341
- var _a;
342
- return await this.client.request("/v1/media/audios/operations/tts", {
343
- method: "POST",
344
- body: payload,
345
- idempotencyKey: ((_a = options.idempotencyKey) == null ? void 0 : _a.trim()) || void 0,
346
- signal: options.signal
347
- });
348
- }
349
- async createAutoCaptions(payload, options = {}) {
350
- var _a;
351
- return await this.client.request(
352
- "/v1/media/audios/operations/auto-captions",
353
- {
354
- method: "POST",
355
- body: payload,
356
- idempotencyKey: ((_a = options.idempotencyKey) == null ? void 0 : _a.trim()) || void 0,
357
- signal: options.signal
358
- }
359
- );
360
- }
361
218
  };
362
219
 
363
220
  // src/resources/projects.ts
@@ -573,8 +430,7 @@ var IndreamClient = class {
573
430
  this.fetchImpl = options.fetch || fetch;
574
431
  this.exports = new ExportsResource(this);
575
432
  this.editor = new EditorResource(this);
576
- this.materials = new MaterialsResource(this);
577
- this.media = new MediaResource(this);
433
+ this.illustrations = new IllustrationsResource(this);
578
434
  this.projects = new ProjectsResource(this);
579
435
  this.uploads = new UploadsResource(this);
580
436
  this.assets = new AssetsResource(this);
@@ -584,7 +440,7 @@ var IndreamClient = class {
584
440
  return envelope.data;
585
441
  }
586
442
  async requestEnvelope(path, init) {
587
- const url = `${this.baseURL}${path.startsWith("/") ? path : `/${path}`}`;
443
+ const url = this.baseURL + (path.startsWith("/") ? path : "/" + path);
588
444
  const isJsonPayload = init.body !== void 0 && !isBodyInit(init.body);
589
445
  let payload;
590
446
  if (init.body !== void 0) {
@@ -839,9 +695,8 @@ export {
839
695
  AuthError,
840
696
  EditorResource,
841
697
  ExportsResource,
698
+ IllustrationsResource,
842
699
  IndreamClient,
843
- MaterialsResource,
844
- MediaResource,
845
700
  ProjectsResource,
846
701
  RateLimitError,
847
702
  UploadsResource,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indreamai/client",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Official JavaScript client for Indream Open API (Node.js and Edge runtimes)",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",