@aviaryhq/cloudglue-js 0.2.4 → 0.3.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.
@@ -9,6 +9,7 @@ const Extract_1 = require("../generated/Extract");
9
9
  const Segmentations_1 = require("../generated/Segmentations");
10
10
  const Search_1 = require("../generated/Search");
11
11
  const Describe_1 = require("../generated/Describe");
12
+ const Segments_1 = require("../generated/Segments");
12
13
  class CloudGlueError extends Error {
13
14
  constructor(message, statusCode, data, headers, responseData) {
14
15
  super(message);
@@ -426,6 +427,38 @@ class EnhancedDescribeApi {
426
427
  throw new CloudGlueError(`Timeout waiting for description job ${jobId} to process after ${maxAttempts} attempts`);
427
428
  }
428
429
  }
430
+ class EnhancedSegmentsApi {
431
+ constructor(api) {
432
+ this.api = api;
433
+ }
434
+ async listSegmentJobs(data) {
435
+ return this.api.listSegments({ queries: data });
436
+ }
437
+ async getSegmentJob(jobId) {
438
+ return this.api.getSegments({ params: { job_id: jobId } });
439
+ }
440
+ async createSegmentJob(params) {
441
+ return this.api.createSegments(params);
442
+ }
443
+ async waitForReady(jobId, options = {}) {
444
+ const { pollingInterval = 5000, maxAttempts = 36, } = options;
445
+ let attempts = 0;
446
+ while (attempts < maxAttempts) {
447
+ const job = await this.getSegmentJob(jobId);
448
+ // If we've reached a terminal state, return the job
449
+ if (["completed", "failed", "not_applicable"].includes(job.status)) {
450
+ if (job.status === "failed") {
451
+ throw new CloudGlueError(`Segment job failed: ${jobId}`);
452
+ }
453
+ return job;
454
+ }
455
+ // Wait for the polling interval before trying again
456
+ await new Promise((resolve) => setTimeout(resolve, pollingInterval));
457
+ attempts++;
458
+ }
459
+ throw new CloudGlueError(`Timeout waiting for segment job ${jobId} to process after ${maxAttempts} attempts`);
460
+ }
461
+ }
429
462
  /**
430
463
  * Main CloudGlue client class that provides access to all API functionality
431
464
  * through enhanced, user-friendly interfaces
@@ -442,7 +475,7 @@ class CloudGlue {
442
475
  headers: {
443
476
  Authorization: `Bearer ${this.apiKey}`,
444
477
  'x-sdk-client': 'cloudglue-js',
445
- 'x-sdk-version': '0.2.4',
478
+ 'x-sdk-version': '0.3.0',
446
479
  },
447
480
  baseURL: this.baseUrl,
448
481
  timeout: this.timeout,
@@ -462,8 +495,9 @@ class CloudGlue {
462
495
  const segmentationsApi = (0, Segmentations_1.createApiClient)(this.baseUrl, sharedConfig);
463
496
  const searchApi = (0, Search_1.createApiClient)(this.baseUrl, sharedConfig);
464
497
  const describeApi = (0, Describe_1.createApiClient)(this.baseUrl, sharedConfig);
498
+ const segmentsApi = (0, Segments_1.createApiClient)(this.baseUrl, sharedConfig);
465
499
  // Configure base URL and axios config for all clients
466
- [filesApi, collectionsApi, chatApi, transcribeApi, extractApi, segmentationsApi, searchApi, describeApi].forEach((client) => {
500
+ [filesApi, collectionsApi, chatApi, transcribeApi, extractApi, segmentationsApi, searchApi, describeApi, segmentsApi].forEach((client) => {
467
501
  Object.assign(client.axios.defaults, axiosConfig);
468
502
  client.axios.interceptors.response.use((response) => {
469
503
  return response;
@@ -487,6 +521,7 @@ class CloudGlue {
487
521
  this.segmentations = new EnhancedSegmentationsApi(segmentationsApi);
488
522
  this.search = new EnhancedSearchApi(searchApi);
489
523
  this.describe = new EnhancedDescribeApi(describeApi);
524
+ this.segments = new EnhancedSegmentsApi(segmentsApi);
490
525
  }
491
526
  }
492
527
  exports.CloudGlue = CloudGlue;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Filter operators for metadata, video info, and file property filtering
3
+ * Used across different APIs for consistent filtering behavior
4
+ */
5
+ export declare enum FilterOperator {
6
+ NotEqual = "NotEqual",
7
+ Equal = "Equal",
8
+ LessThan = "LessThan",
9
+ GreaterThan = "GreaterThan",
10
+ ContainsAny = "ContainsAny",
11
+ ContainsAll = "ContainsAll",
12
+ In = "In",
13
+ Like = "Like"
14
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilterOperator = void 0;
4
+ /**
5
+ * Filter operators for metadata, video info, and file property filtering
6
+ * Used across different APIs for consistent filtering behavior
7
+ */
8
+ var FilterOperator;
9
+ (function (FilterOperator) {
10
+ FilterOperator["NotEqual"] = "NotEqual";
11
+ FilterOperator["Equal"] = "Equal";
12
+ FilterOperator["LessThan"] = "LessThan";
13
+ FilterOperator["GreaterThan"] = "GreaterThan";
14
+ FilterOperator["ContainsAny"] = "ContainsAny";
15
+ FilterOperator["ContainsAll"] = "ContainsAll";
16
+ FilterOperator["In"] = "In";
17
+ FilterOperator["Like"] = "Like";
18
+ })(FilterOperator || (exports.FilterOperator = FilterOperator = {}));
@@ -11,3 +11,4 @@ export * from '../generated';
11
11
  * Common type definitions used throughout the SDK
12
12
  */
13
13
  export type * from './types';
14
+ export * from './enums';
package/dist/src/index.js CHANGED
@@ -23,3 +23,4 @@ __exportStar(require("./client"), exports);
23
23
  * These provide direct access to the underlying API endpoints
24
24
  */
25
25
  __exportStar(require("../generated"), exports);
26
+ __exportStar(require("./enums"), exports);
@@ -5,26 +5,13 @@ 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
7
  import { schemas as describeSchemas } from '../generated/Describe';
8
+ import { schemas as segmentsSchemas } from '../generated/Segments';
8
9
  import { SegmentationUniformConfig as SegmentationUniformConfigType, SegmentationShotDetectorConfig as SegmentationShotDetectorConfigType, SegmentationConfig as SegmentationConfigType } from '../generated/common';
9
10
  /**
10
11
  * Represents a video file in the Cloudglue system
11
12
  * Contains metadata about the file including its status, size, and video information
12
13
  */
13
14
  export type { File } from '../generated/common';
14
- /**
15
- * Filter operators for metadata, video info, and file property filtering
16
- * Used across different APIs for consistent filtering behavior
17
- */
18
- export declare enum FilterOperator {
19
- NotEqual = "NotEqual",
20
- Equal = "Equal",
21
- LessThan = "LessThan",
22
- GreaterThan = "GreaterThan",
23
- ContainsAny = "ContainsAny",
24
- ContainsAll = "ContainsAll",
25
- In = "In",
26
- Like = "Like"
27
- }
28
15
  /**
29
16
  * Represents the status of a job
30
17
  * TODO: would be better to use a common type for all jobs
@@ -159,3 +146,5 @@ export type CollectionMediaDescription = z.infer<typeof collectionsSchemas.Media
159
146
  * Represents a list of media descriptions for files in a collection
160
147
  */
161
148
  export type CollectionMediaDescriptionsList = z.infer<typeof collectionsSchemas.CollectionMediaDescriptionsList>;
149
+ export type NarrativeConfig = z.infer<typeof segmentsSchemas.NarrativeConfig>;
150
+ export type ShotConfig = z.infer<typeof segmentsSchemas.ShotConfig>;
package/dist/src/types.js CHANGED
@@ -1,18 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FilterOperator = void 0;
4
- /**
5
- * Filter operators for metadata, video info, and file property filtering
6
- * Used across different APIs for consistent filtering behavior
7
- */
8
- var FilterOperator;
9
- (function (FilterOperator) {
10
- FilterOperator["NotEqual"] = "NotEqual";
11
- FilterOperator["Equal"] = "Equal";
12
- FilterOperator["LessThan"] = "LessThan";
13
- FilterOperator["GreaterThan"] = "GreaterThan";
14
- FilterOperator["ContainsAny"] = "ContainsAny";
15
- FilterOperator["ContainsAll"] = "ContainsAll";
16
- FilterOperator["In"] = "In";
17
- FilterOperator["Like"] = "Like";
18
- })(FilterOperator || (exports.FilterOperator = FilterOperator = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aviaryhq/cloudglue-js",
3
- "version": "0.2.4",
3
+ "version": "0.3.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",
@@ -12,7 +12,8 @@
12
12
  "generate": "node generate.js",
13
13
  "build": "tsc && node scripts/build.js",
14
14
  "watch": "tsc --watch",
15
- "prepare": "npm run build"
15
+ "prepare": "npm run build",
16
+ "publish": "npm run build && npm publish"
16
17
  },
17
18
  "repository": {
18
19
  "type": "git",