@aviaryhq/cloudglue-js 0.1.1 → 0.1.3
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/generated/Collections.d.ts +46 -373
- package/dist/generated/Collections.js +67 -46
- package/dist/generated/Extract.d.ts +12 -57
- package/dist/generated/Extract.js +3 -1
- package/dist/generated/Files.d.ts +1526 -0
- package/dist/generated/Files.js +124 -0
- package/dist/generated/Segmentations.d.ts +1076 -0
- package/dist/generated/Segmentations.js +77 -0
- package/dist/generated/Transcribe.d.ts +13 -58
- package/dist/generated/Transcribe.js +14 -12
- package/dist/generated/Webhooks.d.ts +3 -3
- package/dist/generated/Webhooks.js +3 -3
- package/dist/generated/common.d.ts +894 -0
- package/dist/generated/common.js +70 -1
- package/dist/generated/index.d.ts +1 -0
- package/dist/generated/index.js +3 -1
- package/dist/src/client.d.ts +413 -20
- package/dist/src/client.js +59 -18
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +16 -7
- package/dist/src/types.d.ts +23 -1
- package/package.json +2 -2
- package/dist/generated/Describe.d.ts +0 -7027
- package/dist/generated/Describe.js +0 -159
package/dist/src/client.js
CHANGED
|
@@ -6,12 +6,14 @@ const Collections_1 = require("../generated/Collections");
|
|
|
6
6
|
const Chat_1 = require("../generated/Chat");
|
|
7
7
|
const Transcribe_1 = require("../generated/Transcribe");
|
|
8
8
|
const Extract_1 = require("../generated/Extract");
|
|
9
|
+
const Segmentations_1 = require("../generated/Segmentations");
|
|
9
10
|
class CloudGlueError extends Error {
|
|
10
|
-
constructor(message, statusCode, data, headers) {
|
|
11
|
+
constructor(message, statusCode, data, headers, responseData) {
|
|
11
12
|
super(message);
|
|
12
13
|
this.statusCode = statusCode;
|
|
13
14
|
this.data = data;
|
|
14
15
|
this.headers = headers;
|
|
16
|
+
this.responseData = responseData;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
exports.CloudGlueError = CloudGlueError;
|
|
@@ -50,10 +52,25 @@ class EnhancedFilesApi {
|
|
|
50
52
|
return this.api.getFile({ params: { file_id: fileId } });
|
|
51
53
|
}
|
|
52
54
|
async deleteFile(fileId) {
|
|
53
|
-
return this.api.deleteFile(
|
|
55
|
+
return this.api.deleteFile(undefined, {
|
|
54
56
|
params: { file_id: fileId },
|
|
55
57
|
});
|
|
56
58
|
}
|
|
59
|
+
async updateFile(fileId, params) {
|
|
60
|
+
return this.api.updateFile({ ...params, filename: params.filename ?? undefined }, { params: { file_id: fileId } });
|
|
61
|
+
}
|
|
62
|
+
async listFileSegmentations(fileId, params = {}) {
|
|
63
|
+
return this.api.listFileSegmentations({
|
|
64
|
+
params: { file_id: fileId },
|
|
65
|
+
queries: params,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async createFileSegmentation(fileId, params) {
|
|
69
|
+
return this.api.createFileSegmentation(params, {
|
|
70
|
+
params: { file_id: fileId },
|
|
71
|
+
body: params,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
57
74
|
/**
|
|
58
75
|
* Waits for a file to finish processing by polling the getFile endpoint until the file
|
|
59
76
|
* reaches a terminal state (completed, failed, or not_applicable) or until maxAttempts is reached.
|
|
@@ -98,10 +115,10 @@ class EnhancedCollectionsApi {
|
|
|
98
115
|
});
|
|
99
116
|
}
|
|
100
117
|
async deleteCollection(collectionId) {
|
|
101
|
-
return this.api.deleteCollection(
|
|
118
|
+
return this.api.deleteCollection(undefined, { params: { collection_id: collectionId } });
|
|
102
119
|
}
|
|
103
|
-
async addVideo(collectionId, fileId) {
|
|
104
|
-
return this.api.addVideo({ file_id: fileId }, { params: { collection_id: collectionId } });
|
|
120
|
+
async addVideo(collectionId, fileId, params = {}) {
|
|
121
|
+
return this.api.addVideo({ file_id: fileId, ...params }, { params: { collection_id: collectionId, ...params } });
|
|
105
122
|
}
|
|
106
123
|
async listVideos(collectionId, params = {}) {
|
|
107
124
|
return this.api.listVideos({
|
|
@@ -115,9 +132,7 @@ class EnhancedCollectionsApi {
|
|
|
115
132
|
});
|
|
116
133
|
}
|
|
117
134
|
async deleteVideo(collectionId, fileId) {
|
|
118
|
-
return this.api.deleteVideo({
|
|
119
|
-
params: { collection_id: collectionId, file_id: fileId },
|
|
120
|
-
}, { params: { collection_id: collectionId, file_id: fileId } });
|
|
135
|
+
return this.api.deleteVideo(undefined, { params: { collection_id: collectionId, file_id: fileId } });
|
|
121
136
|
}
|
|
122
137
|
async getEntities(collectionId, fileId) {
|
|
123
138
|
return this.api.getEntities({
|
|
@@ -130,8 +145,8 @@ class EnhancedCollectionsApi {
|
|
|
130
145
|
queries: { limit, offset, response_format },
|
|
131
146
|
});
|
|
132
147
|
}
|
|
133
|
-
async addYouTubeVideo(collectionId, url,
|
|
134
|
-
return this.api.addYouTubeVideo({ url,
|
|
148
|
+
async addYouTubeVideo(collectionId, url, params = {}) {
|
|
149
|
+
return this.api.addYouTubeVideo({ url, ...params }, { params: { collection_id: collectionId, ...params } });
|
|
135
150
|
}
|
|
136
151
|
async listEntities(collectionId, params = {}) {
|
|
137
152
|
return this.api.listCollectionEntities({
|
|
@@ -276,6 +291,22 @@ class EnhancedExtractApi {
|
|
|
276
291
|
throw new CloudGlueError(`Timeout waiting for extraction job ${jobId} to process after ${maxAttempts} attempts`);
|
|
277
292
|
}
|
|
278
293
|
}
|
|
294
|
+
class EnhancedSegmentationsApi {
|
|
295
|
+
constructor(api) {
|
|
296
|
+
this.api = api;
|
|
297
|
+
}
|
|
298
|
+
async getSegmentation(segmentationId, params = {}) {
|
|
299
|
+
return this.api.getSegmentation({
|
|
300
|
+
params: { segmentation_id: segmentationId },
|
|
301
|
+
queries: params,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
async deleteSegmentation(segmentationId) {
|
|
305
|
+
return this.api.deleteSegmentation(undefined, {
|
|
306
|
+
params: { segmentation_id: segmentationId },
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
279
310
|
/**
|
|
280
311
|
* Main CloudGlue client class that provides access to all API functionality
|
|
281
312
|
* through enhanced, user-friendly interfaces
|
|
@@ -291,18 +322,27 @@ class CloudGlue {
|
|
|
291
322
|
const axiosConfig = {
|
|
292
323
|
headers: {
|
|
293
324
|
Authorization: `Bearer ${this.apiKey}`,
|
|
325
|
+
'x-sdk-client': 'cloudglue-js',
|
|
326
|
+
'x-sdk-version': '0.1.3',
|
|
294
327
|
},
|
|
295
328
|
baseURL: this.baseUrl,
|
|
296
329
|
timeout: this.timeout,
|
|
297
330
|
};
|
|
331
|
+
// Let all validation happen on the server side
|
|
332
|
+
const sharedConfig = {
|
|
333
|
+
validate: false,
|
|
334
|
+
transform: false,
|
|
335
|
+
sendDefaults: true,
|
|
336
|
+
};
|
|
298
337
|
// Initialize all API clients with the configured base URL and auth
|
|
299
|
-
const filesApi = (0, Files_1.createApiClient)(this.baseUrl);
|
|
300
|
-
const collectionsApi = (0, Collections_1.createApiClient)(this.baseUrl);
|
|
301
|
-
const chatApi = (0, Chat_1.createApiClient)(this.baseUrl);
|
|
302
|
-
const transcribeApi = (0, Transcribe_1.createApiClient)(this.baseUrl);
|
|
303
|
-
const extractApi = (0, Extract_1.createApiClient)(this.baseUrl);
|
|
338
|
+
const filesApi = (0, Files_1.createApiClient)(this.baseUrl, sharedConfig);
|
|
339
|
+
const collectionsApi = (0, Collections_1.createApiClient)(this.baseUrl, sharedConfig);
|
|
340
|
+
const chatApi = (0, Chat_1.createApiClient)(this.baseUrl, sharedConfig);
|
|
341
|
+
const transcribeApi = (0, Transcribe_1.createApiClient)(this.baseUrl, sharedConfig);
|
|
342
|
+
const extractApi = (0, Extract_1.createApiClient)(this.baseUrl, sharedConfig);
|
|
343
|
+
const segmentationsApi = (0, Segmentations_1.createApiClient)(this.baseUrl, sharedConfig);
|
|
304
344
|
// Configure base URL and axios config for all clients
|
|
305
|
-
[filesApi, collectionsApi, chatApi, transcribeApi, extractApi].forEach((client) => {
|
|
345
|
+
[filesApi, collectionsApi, chatApi, transcribeApi, extractApi, segmentationsApi].forEach((client) => {
|
|
306
346
|
Object.assign(client.axios.defaults, axiosConfig);
|
|
307
347
|
client.axios.interceptors.response.use((response) => {
|
|
308
348
|
return response;
|
|
@@ -311,10 +351,10 @@ class CloudGlue {
|
|
|
311
351
|
// The request was made and the server responded with a status code
|
|
312
352
|
// that falls out of the range of 2xx
|
|
313
353
|
const data = error.response.data;
|
|
314
|
-
return Promise.reject(new CloudGlueError(data.error, error.response.status, error.config.data, error.response.headers));
|
|
354
|
+
return Promise.reject(new CloudGlueError(data.error, error.response.status, error.config.data, error.response.headers, error.response.data));
|
|
315
355
|
}
|
|
316
356
|
// Something happened in setting up the request that triggered an Error
|
|
317
|
-
return Promise.reject(new CloudGlueError(error.message, error.statusCode ?? 500, error.data, error.headers));
|
|
357
|
+
return Promise.reject(new CloudGlueError(error.message, error.statusCode ?? 500, error.data, error.headers, error.response?.data));
|
|
318
358
|
});
|
|
319
359
|
});
|
|
320
360
|
// Create enhanced API clients
|
|
@@ -323,6 +363,7 @@ class CloudGlue {
|
|
|
323
363
|
this.chat = new EnhancedChatApi(chatApi);
|
|
324
364
|
this.transcribe = new EnhancedTranscribeApi(transcribeApi);
|
|
325
365
|
this.extract = new EnhancedExtractApi(extractApi);
|
|
366
|
+
this.segmentations = new EnhancedSegmentationsApi(segmentationsApi);
|
|
326
367
|
}
|
|
327
368
|
}
|
|
328
369
|
exports.CloudGlue = CloudGlue;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export { CloudGlue, type CloudGlueConfig, type CloudGlueError } from './client';
|
|
|
6
6
|
* Generated API clients for advanced usage
|
|
7
7
|
* These provide direct access to the underlying API endpoints
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export * from '../generated';
|
|
10
10
|
/**
|
|
11
11
|
* Common type definitions used throughout the SDK
|
|
12
12
|
*/
|
|
13
|
-
export type
|
|
13
|
+
export type * from './types';
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
17
|
+
exports.CloudGlue = void 0;
|
|
4
18
|
/**
|
|
5
19
|
* Main CloudGlue client class and configuration types
|
|
6
20
|
*/
|
|
@@ -10,9 +24,4 @@ Object.defineProperty(exports, "CloudGlue", { enumerable: true, get: function ()
|
|
|
10
24
|
* Generated API clients for advanced usage
|
|
11
25
|
* These provide direct access to the underlying API endpoints
|
|
12
26
|
*/
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(exports, "FilesApi", { enumerable: true, get: function () { return generated_1.FilesApi; } });
|
|
15
|
-
Object.defineProperty(exports, "CollectionsApi", { enumerable: true, get: function () { return generated_1.CollectionsApi; } });
|
|
16
|
-
Object.defineProperty(exports, "ChatApi", { enumerable: true, get: function () { return generated_1.ChatApi; } });
|
|
17
|
-
Object.defineProperty(exports, "TranscribeApi", { enumerable: true, get: function () { return generated_1.TranscribeApi; } });
|
|
18
|
-
Object.defineProperty(exports, "ExtractApi", { enumerable: true, get: function () { return generated_1.ExtractApi; } });
|
|
27
|
+
__exportStar(require("../generated"), exports);
|
package/dist/src/types.d.ts
CHANGED
|
@@ -3,11 +3,24 @@ import { schemas as collectionsSchemas } from '../generated/Collections';
|
|
|
3
3
|
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
|
+
import { SegmentationUniformConfig as SegmentationUniformConfigType, SegmentationShotDetectorConfig as SegmentationShotDetectorConfigType, SegmentationConfig as SegmentationConfigType } from '../generated/common';
|
|
6
7
|
/**
|
|
7
|
-
* Represents a video file in the
|
|
8
|
+
* Represents a video file in the Cloudglue system
|
|
8
9
|
* Contains metadata about the file including its status, size, and video information
|
|
9
10
|
*/
|
|
10
11
|
export type { File } from '../generated/common';
|
|
12
|
+
/**
|
|
13
|
+
* Represents the status of a job
|
|
14
|
+
* TODO: would be better to use a common type for all jobs
|
|
15
|
+
*/
|
|
16
|
+
export type JobStatus = z.infer<typeof transcribeSchemas.Transcribe>['status'];
|
|
17
|
+
/**
|
|
18
|
+
* Parameters for updating an existing file
|
|
19
|
+
*/
|
|
20
|
+
export interface UpdateFileParams {
|
|
21
|
+
filename?: string;
|
|
22
|
+
metadata?: Record<string, any>;
|
|
23
|
+
}
|
|
11
24
|
/**
|
|
12
25
|
* Parameters for creating a new collection
|
|
13
26
|
*/
|
|
@@ -79,3 +92,12 @@ export type CollectionEntitiesList = z.infer<typeof collectionsSchemas.Collectio
|
|
|
79
92
|
* Represents a list of rich transcripts for files in a collection
|
|
80
93
|
*/
|
|
81
94
|
export type CollectionRichTranscriptsList = z.infer<typeof collectionsSchemas.CollectionRichTranscriptsList>;
|
|
95
|
+
/**
|
|
96
|
+
* Segmentation config for the Uniform strategy
|
|
97
|
+
*/
|
|
98
|
+
export type SegmentationUniformConfig = z.infer<typeof SegmentationUniformConfigType>;
|
|
99
|
+
/**
|
|
100
|
+
* Segmentation config for the Shot Detector strategy
|
|
101
|
+
*/
|
|
102
|
+
export type SegmentationShotDetectorConfig = z.infer<typeof SegmentationShotDetectorConfigType>;
|
|
103
|
+
export type SegmentationConfig = z.infer<typeof SegmentationConfigType>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aviaryhq/cloudglue-js",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Cloudglue API client for Node.js",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"clean": "rimraf dist",
|
|
12
12
|
"generate": "node generate.js",
|
|
13
|
-
"build": "tsc",
|
|
13
|
+
"build": "tsc && node scripts/build.js",
|
|
14
14
|
"watch": "tsc --watch",
|
|
15
15
|
"prepare": "npm run build"
|
|
16
16
|
},
|