@aviaryhq/cloudglue-js 0.1.2 → 0.1.4
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 +48 -373
- package/dist/generated/Collections.js +68 -46
- package/dist/generated/Extract.d.ts +12 -57
- package/dist/generated/Extract.js +3 -1
- package/dist/generated/Files.d.ts +1280 -0
- package/dist/generated/Files.js +87 -0
- package/dist/generated/Search.d.ts +190 -0
- package/dist/generated/Search.js +173 -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 +409 -20
- package/dist/src/client.js +63 -19
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +16 -7
- package/dist/src/types.d.ts +16 -2
- package/package.json +2 -2
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,12 +52,24 @@ 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
|
}
|
|
57
59
|
async updateFile(fileId, params) {
|
|
58
|
-
return this.api.updateFile(params, { params: { file_id: fileId } });
|
|
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
|
+
});
|
|
59
73
|
}
|
|
60
74
|
/**
|
|
61
75
|
* Waits for a file to finish processing by polling the getFile endpoint until the file
|
|
@@ -101,10 +115,13 @@ class EnhancedCollectionsApi {
|
|
|
101
115
|
});
|
|
102
116
|
}
|
|
103
117
|
async deleteCollection(collectionId) {
|
|
104
|
-
return this.api.deleteCollection(
|
|
118
|
+
return this.api.deleteCollection(undefined, { params: { collection_id: collectionId } });
|
|
119
|
+
}
|
|
120
|
+
async addVideoByUrl({ collectionId, url, params }) {
|
|
121
|
+
return this.api.addVideo({ url, ...params }, { params: { collection_id: collectionId, ...params } });
|
|
105
122
|
}
|
|
106
|
-
async addVideo(collectionId, fileId) {
|
|
107
|
-
return this.api.addVideo({ file_id: fileId }, { params: { collection_id: collectionId } });
|
|
123
|
+
async addVideo(collectionId, fileId, params = {}) {
|
|
124
|
+
return this.api.addVideo({ file_id: fileId, ...params }, { params: { collection_id: collectionId, ...params } });
|
|
108
125
|
}
|
|
109
126
|
async listVideos(collectionId, params = {}) {
|
|
110
127
|
return this.api.listVideos({
|
|
@@ -118,9 +135,7 @@ class EnhancedCollectionsApi {
|
|
|
118
135
|
});
|
|
119
136
|
}
|
|
120
137
|
async deleteVideo(collectionId, fileId) {
|
|
121
|
-
return this.api.deleteVideo({
|
|
122
|
-
params: { collection_id: collectionId, file_id: fileId },
|
|
123
|
-
}, { params: { collection_id: collectionId, file_id: fileId } });
|
|
138
|
+
return this.api.deleteVideo(undefined, { params: { collection_id: collectionId, file_id: fileId } });
|
|
124
139
|
}
|
|
125
140
|
async getEntities(collectionId, fileId) {
|
|
126
141
|
return this.api.getEntities({
|
|
@@ -133,8 +148,11 @@ class EnhancedCollectionsApi {
|
|
|
133
148
|
queries: { limit, offset, response_format },
|
|
134
149
|
});
|
|
135
150
|
}
|
|
136
|
-
|
|
137
|
-
|
|
151
|
+
/**
|
|
152
|
+
* @deprecated Use addVideoByUrl instead
|
|
153
|
+
*/
|
|
154
|
+
async addYouTubeVideo(collectionId, url, params = {}) {
|
|
155
|
+
return this.api.addYouTubeVideo({ url, ...params }, { params: { collection_id: collectionId, ...params } });
|
|
138
156
|
}
|
|
139
157
|
async listEntities(collectionId, params = {}) {
|
|
140
158
|
return this.api.listCollectionEntities({
|
|
@@ -279,6 +297,22 @@ class EnhancedExtractApi {
|
|
|
279
297
|
throw new CloudGlueError(`Timeout waiting for extraction job ${jobId} to process after ${maxAttempts} attempts`);
|
|
280
298
|
}
|
|
281
299
|
}
|
|
300
|
+
class EnhancedSegmentationsApi {
|
|
301
|
+
constructor(api) {
|
|
302
|
+
this.api = api;
|
|
303
|
+
}
|
|
304
|
+
async getSegmentation(segmentationId, params = {}) {
|
|
305
|
+
return this.api.getSegmentation({
|
|
306
|
+
params: { segmentation_id: segmentationId },
|
|
307
|
+
queries: params,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
async deleteSegmentation(segmentationId) {
|
|
311
|
+
return this.api.deleteSegmentation(undefined, {
|
|
312
|
+
params: { segmentation_id: segmentationId },
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
282
316
|
/**
|
|
283
317
|
* Main CloudGlue client class that provides access to all API functionality
|
|
284
318
|
* through enhanced, user-friendly interfaces
|
|
@@ -294,18 +328,27 @@ class CloudGlue {
|
|
|
294
328
|
const axiosConfig = {
|
|
295
329
|
headers: {
|
|
296
330
|
Authorization: `Bearer ${this.apiKey}`,
|
|
331
|
+
'x-sdk-client': 'cloudglue-js',
|
|
332
|
+
'x-sdk-version': '0.1.4',
|
|
297
333
|
},
|
|
298
334
|
baseURL: this.baseUrl,
|
|
299
335
|
timeout: this.timeout,
|
|
300
336
|
};
|
|
337
|
+
// Let all validation happen on the server side
|
|
338
|
+
const sharedConfig = {
|
|
339
|
+
validate: false,
|
|
340
|
+
transform: false,
|
|
341
|
+
sendDefaults: true,
|
|
342
|
+
};
|
|
301
343
|
// Initialize all API clients with the configured base URL and auth
|
|
302
|
-
const filesApi = (0, Files_1.createApiClient)(this.baseUrl);
|
|
303
|
-
const collectionsApi = (0, Collections_1.createApiClient)(this.baseUrl);
|
|
304
|
-
const chatApi = (0, Chat_1.createApiClient)(this.baseUrl);
|
|
305
|
-
const transcribeApi = (0, Transcribe_1.createApiClient)(this.baseUrl);
|
|
306
|
-
const extractApi = (0, Extract_1.createApiClient)(this.baseUrl);
|
|
344
|
+
const filesApi = (0, Files_1.createApiClient)(this.baseUrl, sharedConfig);
|
|
345
|
+
const collectionsApi = (0, Collections_1.createApiClient)(this.baseUrl, sharedConfig);
|
|
346
|
+
const chatApi = (0, Chat_1.createApiClient)(this.baseUrl, sharedConfig);
|
|
347
|
+
const transcribeApi = (0, Transcribe_1.createApiClient)(this.baseUrl, sharedConfig);
|
|
348
|
+
const extractApi = (0, Extract_1.createApiClient)(this.baseUrl, sharedConfig);
|
|
349
|
+
const segmentationsApi = (0, Segmentations_1.createApiClient)(this.baseUrl, sharedConfig);
|
|
307
350
|
// Configure base URL and axios config for all clients
|
|
308
|
-
[filesApi, collectionsApi, chatApi, transcribeApi, extractApi].forEach((client) => {
|
|
351
|
+
[filesApi, collectionsApi, chatApi, transcribeApi, extractApi, segmentationsApi].forEach((client) => {
|
|
309
352
|
Object.assign(client.axios.defaults, axiosConfig);
|
|
310
353
|
client.axios.interceptors.response.use((response) => {
|
|
311
354
|
return response;
|
|
@@ -314,10 +357,10 @@ class CloudGlue {
|
|
|
314
357
|
// The request was made and the server responded with a status code
|
|
315
358
|
// that falls out of the range of 2xx
|
|
316
359
|
const data = error.response.data;
|
|
317
|
-
return Promise.reject(new CloudGlueError(data.error, error.response.status, error.config.data, error.response.headers));
|
|
360
|
+
return Promise.reject(new CloudGlueError(data.error, error.response.status, error.config.data, error.response.headers, error.response.data));
|
|
318
361
|
}
|
|
319
362
|
// Something happened in setting up the request that triggered an Error
|
|
320
|
-
return Promise.reject(new CloudGlueError(error.message, error.statusCode ?? 500, error.data, error.headers));
|
|
363
|
+
return Promise.reject(new CloudGlueError(error.message, error.statusCode ?? 500, error.data, error.headers, error.response?.data));
|
|
321
364
|
});
|
|
322
365
|
});
|
|
323
366
|
// Create enhanced API clients
|
|
@@ -326,6 +369,7 @@ class CloudGlue {
|
|
|
326
369
|
this.chat = new EnhancedChatApi(chatApi);
|
|
327
370
|
this.transcribe = new EnhancedTranscribeApi(transcribeApi);
|
|
328
371
|
this.extract = new EnhancedExtractApi(extractApi);
|
|
372
|
+
this.segmentations = new EnhancedSegmentationsApi(segmentationsApi);
|
|
329
373
|
}
|
|
330
374
|
}
|
|
331
375
|
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,18 +3,23 @@ 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'];
|
|
11
17
|
/**
|
|
12
18
|
* Parameters for updating an existing file
|
|
13
19
|
*/
|
|
14
20
|
export interface UpdateFileParams {
|
|
15
21
|
filename?: string;
|
|
16
22
|
metadata?: Record<string, any>;
|
|
17
|
-
[key: string]: any;
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
25
|
* Parameters for creating a new collection
|
|
@@ -87,3 +92,12 @@ export type CollectionEntitiesList = z.infer<typeof collectionsSchemas.Collectio
|
|
|
87
92
|
* Represents a list of rich transcripts for files in a collection
|
|
88
93
|
*/
|
|
89
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.4",
|
|
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
|
},
|