@aviaryhq/cloudglue-js 0.1.2 → 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 +1280 -0
- package/dist/generated/Files.js +87 -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 +385 -20
- package/dist/src/client.js +57 -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/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,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,10 @@ 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 } });
|
|
105
119
|
}
|
|
106
|
-
async addVideo(collectionId, fileId) {
|
|
107
|
-
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 } });
|
|
108
122
|
}
|
|
109
123
|
async listVideos(collectionId, params = {}) {
|
|
110
124
|
return this.api.listVideos({
|
|
@@ -118,9 +132,7 @@ class EnhancedCollectionsApi {
|
|
|
118
132
|
});
|
|
119
133
|
}
|
|
120
134
|
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 } });
|
|
135
|
+
return this.api.deleteVideo(undefined, { params: { collection_id: collectionId, file_id: fileId } });
|
|
124
136
|
}
|
|
125
137
|
async getEntities(collectionId, fileId) {
|
|
126
138
|
return this.api.getEntities({
|
|
@@ -133,8 +145,8 @@ class EnhancedCollectionsApi {
|
|
|
133
145
|
queries: { limit, offset, response_format },
|
|
134
146
|
});
|
|
135
147
|
}
|
|
136
|
-
async addYouTubeVideo(collectionId, url,
|
|
137
|
-
return this.api.addYouTubeVideo({ url,
|
|
148
|
+
async addYouTubeVideo(collectionId, url, params = {}) {
|
|
149
|
+
return this.api.addYouTubeVideo({ url, ...params }, { params: { collection_id: collectionId, ...params } });
|
|
138
150
|
}
|
|
139
151
|
async listEntities(collectionId, params = {}) {
|
|
140
152
|
return this.api.listCollectionEntities({
|
|
@@ -279,6 +291,22 @@ class EnhancedExtractApi {
|
|
|
279
291
|
throw new CloudGlueError(`Timeout waiting for extraction job ${jobId} to process after ${maxAttempts} attempts`);
|
|
280
292
|
}
|
|
281
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
|
+
}
|
|
282
310
|
/**
|
|
283
311
|
* Main CloudGlue client class that provides access to all API functionality
|
|
284
312
|
* through enhanced, user-friendly interfaces
|
|
@@ -294,18 +322,27 @@ class CloudGlue {
|
|
|
294
322
|
const axiosConfig = {
|
|
295
323
|
headers: {
|
|
296
324
|
Authorization: `Bearer ${this.apiKey}`,
|
|
325
|
+
'x-sdk-client': 'cloudglue-js',
|
|
326
|
+
'x-sdk-version': '0.1.3',
|
|
297
327
|
},
|
|
298
328
|
baseURL: this.baseUrl,
|
|
299
329
|
timeout: this.timeout,
|
|
300
330
|
};
|
|
331
|
+
// Let all validation happen on the server side
|
|
332
|
+
const sharedConfig = {
|
|
333
|
+
validate: false,
|
|
334
|
+
transform: false,
|
|
335
|
+
sendDefaults: true,
|
|
336
|
+
};
|
|
301
337
|
// 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);
|
|
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);
|
|
307
344
|
// Configure base URL and axios config for all clients
|
|
308
|
-
[filesApi, collectionsApi, chatApi, transcribeApi, extractApi].forEach((client) => {
|
|
345
|
+
[filesApi, collectionsApi, chatApi, transcribeApi, extractApi, segmentationsApi].forEach((client) => {
|
|
309
346
|
Object.assign(client.axios.defaults, axiosConfig);
|
|
310
347
|
client.axios.interceptors.response.use((response) => {
|
|
311
348
|
return response;
|
|
@@ -314,10 +351,10 @@ class CloudGlue {
|
|
|
314
351
|
// The request was made and the server responded with a status code
|
|
315
352
|
// that falls out of the range of 2xx
|
|
316
353
|
const data = error.response.data;
|
|
317
|
-
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));
|
|
318
355
|
}
|
|
319
356
|
// 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));
|
|
357
|
+
return Promise.reject(new CloudGlueError(error.message, error.statusCode ?? 500, error.data, error.headers, error.response?.data));
|
|
321
358
|
});
|
|
322
359
|
});
|
|
323
360
|
// Create enhanced API clients
|
|
@@ -326,6 +363,7 @@ class CloudGlue {
|
|
|
326
363
|
this.chat = new EnhancedChatApi(chatApi);
|
|
327
364
|
this.transcribe = new EnhancedTranscribeApi(transcribeApi);
|
|
328
365
|
this.extract = new EnhancedExtractApi(extractApi);
|
|
366
|
+
this.segmentations = new EnhancedSegmentationsApi(segmentationsApi);
|
|
329
367
|
}
|
|
330
368
|
}
|
|
331
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,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.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
|
},
|