@aviaryhq/cloudglue-js 0.1.9 → 0.2.1

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.
@@ -8,6 +8,7 @@ const Transcribe_1 = require("../generated/Transcribe");
8
8
  const Extract_1 = require("../generated/Extract");
9
9
  const Segmentations_1 = require("../generated/Segmentations");
10
10
  const Search_1 = require("../generated/Search");
11
+ const Describe_1 = require("../generated/Describe");
11
12
  class CloudGlueError extends Error {
12
13
  constructor(message, statusCode, data, headers, responseData) {
13
14
  super(message);
@@ -168,12 +169,6 @@ class EnhancedCollectionsApi {
168
169
  queries: { limit, offset, response_format },
169
170
  });
170
171
  }
171
- /**
172
- * @deprecated Use addVideoByUrl instead
173
- */
174
- async addYouTubeVideo(collectionId, url, params = {}) {
175
- return this.api.addYouTubeVideo({ url, ...params }, { params: { collection_id: collectionId, ...params } });
176
- }
177
172
  async listEntities(collectionId, params = {}) {
178
173
  return this.api.listCollectionEntities({
179
174
  params: { collection_id: collectionId },
@@ -186,6 +181,18 @@ class EnhancedCollectionsApi {
186
181
  queries: params,
187
182
  });
188
183
  }
184
+ async getMediaDescriptions(collectionId, fileId, response_format) {
185
+ return this.api.getMediaDescriptions({
186
+ params: { collection_id: collectionId, file_id: fileId },
187
+ queries: { response_format },
188
+ });
189
+ }
190
+ async listMediaDescriptions(collectionId, params = {}) {
191
+ return this.api.listCollectionMediaDescriptions({
192
+ params: { collection_id: collectionId },
193
+ queries: params,
194
+ });
195
+ }
189
196
  /**
190
197
  * Waits for a video in a collection to be ready by polling the getVideo endpoint until
191
198
  * the video reaches a terminal state (completed, failed, or not_applicable) or until maxAttempts is reached.
@@ -356,6 +363,53 @@ class EnhancedSearchApi {
356
363
  return this.api.searchContent(params);
357
364
  }
358
365
  }
366
+ class EnhancedDescribeApi {
367
+ constructor(api) {
368
+ this.api = api;
369
+ }
370
+ async createDescribe(url, options = {}) {
371
+ return this.api.createDescribe({
372
+ url,
373
+ ...options,
374
+ });
375
+ }
376
+ async getDescribe(jobId, options = {}) {
377
+ return this.api.getDescribe({
378
+ params: { job_id: jobId },
379
+ queries: { response_format: options.response_format },
380
+ });
381
+ }
382
+ async listDescribes(params = {}) {
383
+ return this.api.listDescribes({ queries: params });
384
+ }
385
+ /**
386
+ * Waits for a description job to be ready by polling the getDescribe endpoint until
387
+ * the job reaches a terminal state (completed, failed, or not_applicable) or until maxAttempts is reached.
388
+ *
389
+ * @param jobId - The ID of the description job to wait for
390
+ * @param options - Optional configuration for polling behavior and response format
391
+ * @returns The final description job object
392
+ * @throws {CloudGlueError} If the job fails to process or maxAttempts is reached
393
+ */
394
+ async waitForReady(jobId, options = {}) {
395
+ const { pollingInterval = 5000, maxAttempts = 36, response_format, } = options;
396
+ let attempts = 0;
397
+ while (attempts < maxAttempts) {
398
+ const job = await this.getDescribe(jobId, { response_format });
399
+ // If we've reached a terminal state, return the job
400
+ if (["completed", "failed", "not_applicable"].includes(job.status)) {
401
+ if (job.status === "failed") {
402
+ throw new CloudGlueError(`Description job failed: ${jobId}`);
403
+ }
404
+ return job;
405
+ }
406
+ // Wait for the polling interval before trying again
407
+ await new Promise((resolve) => setTimeout(resolve, pollingInterval));
408
+ attempts++;
409
+ }
410
+ throw new CloudGlueError(`Timeout waiting for description job ${jobId} to process after ${maxAttempts} attempts`);
411
+ }
412
+ }
359
413
  /**
360
414
  * Main CloudGlue client class that provides access to all API functionality
361
415
  * through enhanced, user-friendly interfaces
@@ -372,7 +426,7 @@ class CloudGlue {
372
426
  headers: {
373
427
  Authorization: `Bearer ${this.apiKey}`,
374
428
  'x-sdk-client': 'cloudglue-js',
375
- 'x-sdk-version': '0.1.9',
429
+ 'x-sdk-version': '0.2.1',
376
430
  },
377
431
  baseURL: this.baseUrl,
378
432
  timeout: this.timeout,
@@ -391,8 +445,9 @@ class CloudGlue {
391
445
  const extractApi = (0, Extract_1.createApiClient)(this.baseUrl, sharedConfig);
392
446
  const segmentationsApi = (0, Segmentations_1.createApiClient)(this.baseUrl, sharedConfig);
393
447
  const searchApi = (0, Search_1.createApiClient)(this.baseUrl, sharedConfig);
448
+ const describeApi = (0, Describe_1.createApiClient)(this.baseUrl, sharedConfig);
394
449
  // Configure base URL and axios config for all clients
395
- [filesApi, collectionsApi, chatApi, transcribeApi, extractApi, segmentationsApi, searchApi].forEach((client) => {
450
+ [filesApi, collectionsApi, chatApi, transcribeApi, extractApi, segmentationsApi, searchApi, describeApi].forEach((client) => {
396
451
  Object.assign(client.axios.defaults, axiosConfig);
397
452
  client.axios.interceptors.response.use((response) => {
398
453
  return response;
@@ -415,6 +470,7 @@ class CloudGlue {
415
470
  this.extract = new EnhancedExtractApi(extractApi);
416
471
  this.segmentations = new EnhancedSegmentationsApi(segmentationsApi);
417
472
  this.search = new EnhancedSearchApi(searchApi);
473
+ this.describe = new EnhancedDescribeApi(describeApi);
418
474
  }
419
475
  }
420
476
  exports.CloudGlue = CloudGlue;
@@ -4,6 +4,7 @@ import { schemas as chatSchemas } from '../generated/Chat';
4
4
  import { schemas as transcribeSchemas } from '../generated/Transcribe';
5
5
  import { schemas as extractSchemas } from '../generated/Extract';
6
6
  import { schemas as searchSchemas } from '../generated/Search';
7
+ import { schemas as describeSchemas } from '../generated/Describe';
7
8
  import { SegmentationUniformConfig as SegmentationUniformConfigType, SegmentationShotDetectorConfig as SegmentationShotDetectorConfigType, SegmentationConfig as SegmentationConfigType } from '../generated/common';
8
9
  /**
9
10
  * Represents a video file in the Cloudglue system
@@ -127,3 +128,20 @@ export type SearchFilterCriteria = z.infer<typeof searchSchemas.SearchFilterCrit
127
128
  * Represents search filter options for metadata, video info, and file properties
128
129
  */
129
130
  export type SearchFilter = z.infer<typeof searchSchemas.SearchFilter>;
131
+ /**
132
+ * Represents the result of a video description request
133
+ * Contains detailed information about the video content including speech, text, and visual descriptions
134
+ */
135
+ export type Describe = z.infer<typeof describeSchemas.Describe>;
136
+ /**
137
+ * Represents a list of description jobs
138
+ */
139
+ export type DescribeList = z.infer<typeof describeSchemas.DescribeList>;
140
+ /**
141
+ * Represents media description data for a video in a collection
142
+ */
143
+ export type CollectionMediaDescription = z.infer<typeof collectionsSchemas.MediaDescription>;
144
+ /**
145
+ * Represents a list of media descriptions for files in a collection
146
+ */
147
+ export type CollectionMediaDescriptionsList = z.infer<typeof collectionsSchemas.CollectionMediaDescriptionsList>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aviaryhq/cloudglue-js",
3
- "version": "0.1.9",
3
+ "version": "0.2.1",
4
4
  "description": "Cloudglue API client for Node.js",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",