@aviaryhq/cloudglue-js 0.5.9 → 0.6.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.
- package/dist/generated/Collections.d.ts +3 -1
- package/dist/generated/Collections.js +13 -11
- package/dist/generated/Describe.d.ts +7722 -43
- package/dist/generated/Describe.js +4 -64
- package/dist/generated/Files.d.ts +1097 -27
- package/dist/generated/Files.js +174 -0
- package/dist/generated/Response.d.ts +727 -0
- package/dist/generated/Response.js +318 -0
- package/dist/generated/Search.js +3 -3
- package/dist/generated/Segmentations.d.ts +6311 -933
- package/dist/generated/Segmentations.js +48 -0
- package/dist/generated/Segments.d.ts +4 -21
- package/dist/generated/Segments.js +8 -16
- package/dist/generated/common.d.ts +3745 -22
- package/dist/generated/common.js +86 -2
- package/dist/generated/index.d.ts +1 -0
- package/dist/generated/index.js +3 -1
- package/dist/src/api/describe.api.d.ts +1546 -109
- package/dist/src/api/files.api.d.ts +236 -3
- package/dist/src/api/files.api.js +27 -0
- package/dist/src/api/response.api.d.ts +269 -0
- package/dist/src/api/response.api.js +85 -0
- package/dist/src/api/segmentations.api.d.ts +896 -3
- package/dist/src/api/segmentations.api.js +13 -0
- package/dist/src/api/segments.api.d.ts +10 -28
- package/dist/src/client.d.ts +6 -0
- package/dist/src/client.js +6 -1
- package/dist/src/types.d.ts +42 -5
- package/package.json +1 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnhancedResponseApi = void 0;
|
|
4
|
+
const error_1 = require("../error");
|
|
5
|
+
class EnhancedResponseApi {
|
|
6
|
+
constructor(api) {
|
|
7
|
+
this.api = api;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create a new response using the Response API.
|
|
11
|
+
* This provides an OpenAI Responses-compatible interface for chat completions with video collections.
|
|
12
|
+
*
|
|
13
|
+
* @param params - Response creation parameters
|
|
14
|
+
* @returns The created response
|
|
15
|
+
*/
|
|
16
|
+
async createResponse(params) {
|
|
17
|
+
return this.api.createResponse(params);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* List all responses with pagination and filtering options.
|
|
21
|
+
*
|
|
22
|
+
* @param params - Optional pagination and filtering parameters
|
|
23
|
+
* @returns Paginated list of responses
|
|
24
|
+
*/
|
|
25
|
+
async listResponses(params = {}) {
|
|
26
|
+
return this.api.listResponses({ queries: params });
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Retrieve a specific response by its ID.
|
|
30
|
+
*
|
|
31
|
+
* @param responseId - The ID of the response to retrieve
|
|
32
|
+
* @returns The response object
|
|
33
|
+
*/
|
|
34
|
+
async getResponse(responseId) {
|
|
35
|
+
return this.api.getResponse({ params: { id: responseId } });
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Delete a response by ID.
|
|
39
|
+
* This operation is idempotent - deleting a non-existent response returns success.
|
|
40
|
+
*
|
|
41
|
+
* @param responseId - The ID of the response to delete
|
|
42
|
+
* @returns Deletion confirmation
|
|
43
|
+
*/
|
|
44
|
+
async deleteResponse(responseId) {
|
|
45
|
+
return this.api.deleteResponse(undefined, { params: { id: responseId } });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Cancel a background response that is in progress.
|
|
49
|
+
* If the response is already completed, failed, or cancelled, this returns the response as-is.
|
|
50
|
+
*
|
|
51
|
+
* @param responseId - The ID of the response to cancel
|
|
52
|
+
* @returns The response object
|
|
53
|
+
*/
|
|
54
|
+
async cancelResponse(responseId) {
|
|
55
|
+
return this.api.cancelResponse(undefined, { params: { id: responseId } });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Waits for a background response to complete by polling until it reaches
|
|
59
|
+
* a terminal state (completed, failed, or cancelled) or until maxAttempts is reached.
|
|
60
|
+
*
|
|
61
|
+
* @param responseId - The ID of the response to wait for
|
|
62
|
+
* @param options - Optional configuration for polling behavior
|
|
63
|
+
* @returns The final response object
|
|
64
|
+
* @throws {CloudGlueError} If the response fails or maxAttempts is reached
|
|
65
|
+
*/
|
|
66
|
+
async waitForReady(responseId, options = {}) {
|
|
67
|
+
const { pollingInterval = 5000, maxAttempts = 36 } = options;
|
|
68
|
+
let attempts = 0;
|
|
69
|
+
while (attempts < maxAttempts) {
|
|
70
|
+
const response = await this.getResponse(responseId);
|
|
71
|
+
// If we've reached a terminal state, return the response
|
|
72
|
+
if (['completed', 'failed', 'cancelled'].includes(response.status)) {
|
|
73
|
+
if (response.status === 'failed') {
|
|
74
|
+
throw new error_1.CloudGlueError(`Response generation failed: ${response.error?.message || responseId}`);
|
|
75
|
+
}
|
|
76
|
+
return response;
|
|
77
|
+
}
|
|
78
|
+
// Wait for the polling interval before trying again
|
|
79
|
+
await new Promise((resolve) => setTimeout(resolve, pollingInterval));
|
|
80
|
+
attempts++;
|
|
81
|
+
}
|
|
82
|
+
throw new error_1.CloudGlueError(`Timeout waiting for response ${responseId} to complete after ${maxAttempts} attempts`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.EnhancedResponseApi = EnhancedResponseApi;
|