@aviaryhq/cloudglue-js 0.1.9 → 0.2.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.
@@ -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);
@@ -186,6 +187,18 @@ class EnhancedCollectionsApi {
186
187
  queries: params,
187
188
  });
188
189
  }
190
+ async getMediaDescriptions(collectionId, fileId, response_format) {
191
+ return this.api.getMediaDescriptions({
192
+ params: { collection_id: collectionId, file_id: fileId },
193
+ queries: { response_format },
194
+ });
195
+ }
196
+ async listMediaDescriptions(collectionId, params = {}) {
197
+ return this.api.listCollectionMediaDescriptions({
198
+ params: { collection_id: collectionId },
199
+ queries: params,
200
+ });
201
+ }
189
202
  /**
190
203
  * Waits for a video in a collection to be ready by polling the getVideo endpoint until
191
204
  * the video reaches a terminal state (completed, failed, or not_applicable) or until maxAttempts is reached.
@@ -356,6 +369,53 @@ class EnhancedSearchApi {
356
369
  return this.api.searchContent(params);
357
370
  }
358
371
  }
372
+ class EnhancedDescribeApi {
373
+ constructor(api) {
374
+ this.api = api;
375
+ }
376
+ async createDescribe(url, options = {}) {
377
+ return this.api.createDescribe({
378
+ url,
379
+ ...options,
380
+ });
381
+ }
382
+ async getDescribe(jobId, options = {}) {
383
+ return this.api.getDescribe({
384
+ params: { job_id: jobId },
385
+ queries: { response_format: options.response_format },
386
+ });
387
+ }
388
+ async listDescribes(params = {}) {
389
+ return this.api.listDescribes({ queries: params });
390
+ }
391
+ /**
392
+ * Waits for a description job to be ready by polling the getDescribe endpoint until
393
+ * the job reaches a terminal state (completed, failed, or not_applicable) or until maxAttempts is reached.
394
+ *
395
+ * @param jobId - The ID of the description job to wait for
396
+ * @param options - Optional configuration for polling behavior and response format
397
+ * @returns The final description job object
398
+ * @throws {CloudGlueError} If the job fails to process or maxAttempts is reached
399
+ */
400
+ async waitForReady(jobId, options = {}) {
401
+ const { pollingInterval = 5000, maxAttempts = 36, response_format, } = options;
402
+ let attempts = 0;
403
+ while (attempts < maxAttempts) {
404
+ const job = await this.getDescribe(jobId, { response_format });
405
+ // If we've reached a terminal state, return the job
406
+ if (["completed", "failed", "not_applicable"].includes(job.status)) {
407
+ if (job.status === "failed") {
408
+ throw new CloudGlueError(`Description job failed: ${jobId}`);
409
+ }
410
+ return job;
411
+ }
412
+ // Wait for the polling interval before trying again
413
+ await new Promise((resolve) => setTimeout(resolve, pollingInterval));
414
+ attempts++;
415
+ }
416
+ throw new CloudGlueError(`Timeout waiting for description job ${jobId} to process after ${maxAttempts} attempts`);
417
+ }
418
+ }
359
419
  /**
360
420
  * Main CloudGlue client class that provides access to all API functionality
361
421
  * through enhanced, user-friendly interfaces
@@ -372,7 +432,7 @@ class CloudGlue {
372
432
  headers: {
373
433
  Authorization: `Bearer ${this.apiKey}`,
374
434
  'x-sdk-client': 'cloudglue-js',
375
- 'x-sdk-version': '0.1.9',
435
+ 'x-sdk-version': '0.2.0',
376
436
  },
377
437
  baseURL: this.baseUrl,
378
438
  timeout: this.timeout,
@@ -391,8 +451,9 @@ class CloudGlue {
391
451
  const extractApi = (0, Extract_1.createApiClient)(this.baseUrl, sharedConfig);
392
452
  const segmentationsApi = (0, Segmentations_1.createApiClient)(this.baseUrl, sharedConfig);
393
453
  const searchApi = (0, Search_1.createApiClient)(this.baseUrl, sharedConfig);
454
+ const describeApi = (0, Describe_1.createApiClient)(this.baseUrl, sharedConfig);
394
455
  // Configure base URL and axios config for all clients
395
- [filesApi, collectionsApi, chatApi, transcribeApi, extractApi, segmentationsApi, searchApi].forEach((client) => {
456
+ [filesApi, collectionsApi, chatApi, transcribeApi, extractApi, segmentationsApi, searchApi, describeApi].forEach((client) => {
396
457
  Object.assign(client.axios.defaults, axiosConfig);
397
458
  client.axios.interceptors.response.use((response) => {
398
459
  return response;
@@ -415,6 +476,7 @@ class CloudGlue {
415
476
  this.extract = new EnhancedExtractApi(extractApi);
416
477
  this.segmentations = new EnhancedSegmentationsApi(segmentationsApi);
417
478
  this.search = new EnhancedSearchApi(searchApi);
479
+ this.describe = new EnhancedDescribeApi(describeApi);
418
480
  }
419
481
  }
420
482
  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.0",
4
4
  "description": "Cloudglue API client for Node.js",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",