@aviaryhq/cloudglue-js 0.2.4 → 0.2.5

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.
@@ -1,6 +1,6 @@
1
- import { FilesApi, CollectionsApi, ChatApi, TranscribeApi, ExtractApi, SearchApi, DescribeApi } from "../generated";
1
+ import { FilesApi, CollectionsApi, ChatApi, TranscribeApi, ExtractApi, SearchApi, DescribeApi, SegmentsApi } from "../generated";
2
2
  import { FilterOperator } from "./types";
3
- import type { File, SegmentationConfig, UpdateFileParams } from "./types";
3
+ import type { File, NarrativeConfig, SegmentationConfig, ShotConfig, UpdateFileParams } from "./types";
4
4
  import { SegmentationsApi } from "../generated/Segmentations";
5
5
  import { ThumbnailsConfig } from "../generated/common";
6
6
  export declare class CloudGlueError extends Error {
@@ -308,17 +308,14 @@ declare class EnhancedFilesApi {
308
308
  hop_seconds: import("zod").ZodOptional<import("zod").ZodNumber>;
309
309
  }, import("zod").ZodTypeAny, "passthrough">>>;
310
310
  shot_detector_config: import("zod").ZodOptional<import("zod").ZodObject<{
311
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
312
311
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
313
312
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
314
313
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
315
314
  }, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
316
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
317
315
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
318
316
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
319
317
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
320
318
  }, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
321
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
322
319
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
323
320
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
324
321
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
@@ -338,17 +335,14 @@ declare class EnhancedFilesApi {
338
335
  hop_seconds: import("zod").ZodOptional<import("zod").ZodNumber>;
339
336
  }, import("zod").ZodTypeAny, "passthrough">>>;
340
337
  shot_detector_config: import("zod").ZodOptional<import("zod").ZodObject<{
341
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
342
338
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
343
339
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
344
340
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
345
341
  }, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
346
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
347
342
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
348
343
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
349
344
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
350
345
  }, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
351
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
352
346
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
353
347
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
354
348
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
@@ -368,17 +362,14 @@ declare class EnhancedFilesApi {
368
362
  hop_seconds: import("zod").ZodOptional<import("zod").ZodNumber>;
369
363
  }, import("zod").ZodTypeAny, "passthrough">>>;
370
364
  shot_detector_config: import("zod").ZodOptional<import("zod").ZodObject<{
371
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
372
365
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
373
366
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
374
367
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
375
368
  }, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
376
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
377
369
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
378
370
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
379
371
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
380
372
  }, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
381
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
382
373
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
383
374
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
384
375
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
@@ -2485,17 +2476,14 @@ declare class EnhancedSegmentationsApi {
2485
2476
  hop_seconds: import("zod").ZodOptional<import("zod").ZodNumber>;
2486
2477
  }, import("zod").ZodTypeAny, "passthrough">>>;
2487
2478
  shot_detector_config: import("zod").ZodOptional<import("zod").ZodObject<{
2488
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2489
2479
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2490
2480
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2491
2481
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
2492
2482
  }, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
2493
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2494
2483
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2495
2484
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2496
2485
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
2497
2486
  }, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
2498
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2499
2487
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2500
2488
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2501
2489
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
@@ -2515,17 +2503,14 @@ declare class EnhancedSegmentationsApi {
2515
2503
  hop_seconds: import("zod").ZodOptional<import("zod").ZodNumber>;
2516
2504
  }, import("zod").ZodTypeAny, "passthrough">>>;
2517
2505
  shot_detector_config: import("zod").ZodOptional<import("zod").ZodObject<{
2518
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2519
2506
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2520
2507
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2521
2508
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
2522
2509
  }, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
2523
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2524
2510
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2525
2511
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2526
2512
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
2527
2513
  }, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
2528
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2529
2514
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2530
2515
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2531
2516
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
@@ -2545,17 +2530,14 @@ declare class EnhancedSegmentationsApi {
2545
2530
  hop_seconds: import("zod").ZodOptional<import("zod").ZodNumber>;
2546
2531
  }, import("zod").ZodTypeAny, "passthrough">>>;
2547
2532
  shot_detector_config: import("zod").ZodOptional<import("zod").ZodObject<{
2548
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2549
2533
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2550
2534
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2551
2535
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
2552
2536
  }, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
2553
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2554
2537
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2555
2538
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2556
2539
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
2557
2540
  }, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
2558
- threshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2559
2541
  min_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2560
2542
  max_seconds: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
2561
2543
  detector: import("zod").ZodEnum<["adaptive", "content"]>;
@@ -2922,6 +2904,123 @@ declare class EnhancedDescribeApi {
2922
2904
  error?: string | undefined;
2923
2905
  }>;
2924
2906
  }
2907
+ declare class EnhancedSegmentsApi {
2908
+ private readonly api;
2909
+ constructor(api: typeof SegmentsApi);
2910
+ listSegmentJobs(data: {
2911
+ criteria: "shot" | "narrative";
2912
+ url?: string;
2913
+ status?: "pending" | "processing" | "completed" | "failed";
2914
+ limit?: number;
2915
+ offset?: number;
2916
+ created_before?: string;
2917
+ created_after?: string;
2918
+ order?: "created_at";
2919
+ sort?: "asc" | "desc";
2920
+ }): Promise<{
2921
+ object: "list";
2922
+ data: Array<{
2923
+ job_id: string;
2924
+ file_id: string;
2925
+ object: "segments";
2926
+ status: "pending" | "processing" | "completed" | "failed";
2927
+ criteria: "shot" | "narrative";
2928
+ created_at: number;
2929
+ shot_config?: Partial<{
2930
+ detector: "content" | "adaptive";
2931
+ max_duration_seconds: number;
2932
+ min_duration_seconds: number;
2933
+ }> | undefined;
2934
+ narrative_config?: Partial<{
2935
+ prompt: string;
2936
+ }> | undefined;
2937
+ total_segments?: number | undefined;
2938
+ segments?: Array<{
2939
+ start_time: number;
2940
+ end_time: number;
2941
+ description?: string | undefined;
2942
+ thumbnail_url?: string | undefined;
2943
+ }> | undefined;
2944
+ }>;
2945
+ total: number;
2946
+ limit: number;
2947
+ offset: number;
2948
+ }>;
2949
+ getSegmentJob(jobId: string): Promise<{
2950
+ job_id: string;
2951
+ file_id: string;
2952
+ object: "segments";
2953
+ status: "pending" | "processing" | "completed" | "failed";
2954
+ criteria: "shot" | "narrative";
2955
+ created_at: number;
2956
+ shot_config?: Partial<{
2957
+ detector: "content" | "adaptive";
2958
+ max_duration_seconds: number;
2959
+ min_duration_seconds: number;
2960
+ }> | undefined;
2961
+ narrative_config?: Partial<{
2962
+ prompt: string;
2963
+ }> | undefined;
2964
+ total_segments?: number | undefined;
2965
+ segments?: Array<{
2966
+ start_time: number;
2967
+ end_time: number;
2968
+ description?: string | undefined;
2969
+ thumbnail_url?: string | undefined;
2970
+ }> | undefined;
2971
+ }>;
2972
+ createSegmentJob(params: {
2973
+ url: string;
2974
+ criteria: "shot" | "narrative";
2975
+ shot_config?: ShotConfig;
2976
+ narrative_config?: NarrativeConfig;
2977
+ }): Promise<{
2978
+ job_id: string;
2979
+ file_id: string;
2980
+ object: "segments";
2981
+ status: "pending" | "processing" | "completed" | "failed";
2982
+ criteria: "shot" | "narrative";
2983
+ created_at: number;
2984
+ shot_config?: Partial<{
2985
+ detector: "content" | "adaptive";
2986
+ max_duration_seconds: number;
2987
+ min_duration_seconds: number;
2988
+ }> | undefined;
2989
+ narrative_config?: Partial<{
2990
+ prompt: string;
2991
+ }> | undefined;
2992
+ total_segments?: number | undefined;
2993
+ segments?: Array<{
2994
+ start_time: number;
2995
+ end_time: number;
2996
+ description?: string | undefined;
2997
+ thumbnail_url?: string | undefined;
2998
+ }> | undefined;
2999
+ }>;
3000
+ waitForReady(jobId: string, options?: WaitForReadyOptions): Promise<{
3001
+ job_id: string;
3002
+ file_id: string;
3003
+ object: "segments";
3004
+ status: "pending" | "processing" | "completed" | "failed";
3005
+ criteria: "shot" | "narrative";
3006
+ created_at: number;
3007
+ shot_config?: Partial<{
3008
+ detector: "content" | "adaptive";
3009
+ max_duration_seconds: number;
3010
+ min_duration_seconds: number;
3011
+ }> | undefined;
3012
+ narrative_config?: Partial<{
3013
+ prompt: string;
3014
+ }> | undefined;
3015
+ total_segments?: number | undefined;
3016
+ segments?: Array<{
3017
+ start_time: number;
3018
+ end_time: number;
3019
+ description?: string | undefined;
3020
+ thumbnail_url?: string | undefined;
3021
+ }> | undefined;
3022
+ }>;
3023
+ }
2925
3024
  /**
2926
3025
  * Main CloudGlue client class that provides access to all API functionality
2927
3026
  * through enhanced, user-friendly interfaces
@@ -2970,6 +3069,7 @@ export declare class CloudGlue {
2970
3069
  * Provides methods for getting detailed descriptions of video content
2971
3070
  */
2972
3071
  readonly describe: EnhancedDescribeApi;
3072
+ readonly segments: EnhancedSegmentsApi;
2973
3073
  constructor(config?: CloudGlueConfig);
2974
3074
  }
2975
3075
  export {};
@@ -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.2.5',
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;
@@ -5,6 +5,7 @@ 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
@@ -159,3 +160,5 @@ export type CollectionMediaDescription = z.infer<typeof collectionsSchemas.Media
159
160
  * Represents a list of media descriptions for files in a collection
160
161
  */
161
162
  export type CollectionMediaDescriptionsList = z.infer<typeof collectionsSchemas.CollectionMediaDescriptionsList>;
163
+ export type NarrativeConfig = z.infer<typeof segmentsSchemas.NarrativeConfig>;
164
+ export type ShotConfig = z.infer<typeof segmentsSchemas.ShotConfig>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aviaryhq/cloudglue-js",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
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",