@wave-av/sdk 2.0.0 → 2.0.2
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/CHANGELOG.md +1 -1
- package/README.md +27 -23
- package/dist/audience.js +93 -0
- package/dist/audience.mjs +9 -0
- package/dist/camera-control.js +95 -0
- package/dist/camera-control.mjs +71 -0
- package/dist/captions-types.js +18 -0
- package/dist/captions-types.mjs +0 -0
- package/dist/captions.js +266 -0
- package/dist/captions.mjs +9 -0
- package/dist/chapters-types.js +18 -0
- package/dist/chapters-types.mjs +0 -0
- package/dist/chapters.js +280 -0
- package/dist/chapters.mjs +9 -0
- package/dist/chunk-362MRITF.mjs +46 -0
- package/dist/chunk-3ZLK4J3V.mjs +69 -0
- package/dist/chunk-4DG4OBRD.mjs +52 -0
- package/dist/chunk-4G7FMCMJ.mjs +68 -0
- package/dist/chunk-4KD5F6E3.mjs +0 -0
- package/dist/chunk-7M6XVUUK.mjs +241 -0
- package/dist/chunk-A344OOT7.mjs +243 -0
- package/dist/chunk-AI64YR5W.mjs +173 -0
- package/dist/chunk-C2GQ756E.mjs +57 -0
- package/dist/chunk-CO2VB72Z.mjs +255 -0
- package/dist/chunk-DWXWAILB.mjs +44 -0
- package/dist/chunk-FLEFYLDM.mjs +71 -0
- package/dist/chunk-H2YYTNUH.mjs +266 -0
- package/dist/chunk-IGDBED5P.mjs +246 -0
- package/dist/chunk-IL2SGWBC.mjs +0 -0
- package/dist/chunk-IVFZ5X4W.mjs +68 -0
- package/dist/chunk-JC32PG3T.mjs +114 -0
- package/dist/chunk-K5X42NLD.mjs +54 -0
- package/dist/chunk-KCEPNS2U.mjs +276 -0
- package/dist/chunk-LVOVF6XC.mjs +54 -0
- package/dist/chunk-M4Z33V3N.mjs +247 -0
- package/dist/chunk-M6FKIX75.mjs +0 -0
- package/dist/chunk-M744Z327.mjs +244 -0
- package/dist/chunk-MRFDPPFK.mjs +61 -0
- package/dist/chunk-MXU3Q23F.mjs +68 -0
- package/dist/chunk-NCVUZ746.mjs +60 -0
- package/dist/chunk-NLQVD2LF.mjs +210 -0
- package/dist/chunk-O6DOGYP5.mjs +238 -0
- package/dist/chunk-S25NY5GE.mjs +124 -0
- package/dist/chunk-TFHXBICQ.mjs +305 -0
- package/dist/chunk-TXWOA2VR.mjs +57 -0
- package/dist/chunk-UCDSNV22.mjs +63 -0
- package/dist/chunk-V5DWA5P4.mjs +279 -0
- package/dist/chunk-VLQQDYGP.mjs +173 -0
- package/dist/chunk-VPKZUXZW.mjs +53 -0
- package/dist/chunk-WS3PEFYJ.mjs +60 -0
- package/dist/chunk-XGAYMWRH.mjs +74 -0
- package/dist/chunk-XMM5J57W.mjs +0 -0
- package/dist/chunk-XWABBOSX.mjs +278 -0
- package/dist/chunk-Y6FXYEAI.mjs +10 -0
- package/dist/chunk-YBLXHI3M.mjs +257 -0
- package/dist/chunk-YEK26SSO.mjs +100 -0
- package/dist/chunk-YLCQKCZL.mjs +0 -0
- package/dist/chunk-YRKO4XI7.mjs +0 -0
- package/dist/chunk-ZJO7AP4Q.mjs +0 -0
- package/dist/client-types.js +18 -0
- package/dist/client-types.mjs +0 -0
- package/dist/client.js +311 -0
- package/dist/client.mjs +14 -0
- package/dist/clips-types.js +18 -0
- package/dist/clips-types.mjs +0 -0
- package/dist/clips.js +198 -0
- package/dist/clips.mjs +9 -0
- package/dist/cloud-switcher.js +80 -0
- package/dist/cloud-switcher.mjs +56 -0
- package/dist/collab-types.js +18 -0
- package/dist/collab-types.mjs +1 -0
- package/dist/collab.js +304 -0
- package/dist/collab.mjs +10 -0
- package/dist/connect.js +85 -0
- package/dist/connect.mjs +9 -0
- package/dist/creator.js +79 -0
- package/dist/creator.mjs +9 -0
- package/dist/desktop.js +77 -0
- package/dist/desktop.mjs +9 -0
- package/dist/distribution.js +88 -0
- package/dist/distribution.mjs +9 -0
- package/dist/drm.js +85 -0
- package/dist/drm.mjs +9 -0
- package/dist/edge.js +93 -0
- package/dist/edge.mjs +9 -0
- package/dist/editor-types.js +18 -0
- package/dist/editor-types.mjs +1 -0
- package/dist/editor.js +330 -0
- package/dist/editor.mjs +10 -0
- package/dist/fleet.js +149 -0
- package/dist/fleet.mjs +9 -0
- package/dist/ghost.js +139 -0
- package/dist/ghost.mjs +9 -0
- package/dist/index.js +0 -250
- package/dist/index.mjs +161 -5445
- package/dist/marketplace.js +82 -0
- package/dist/marketplace.mjs +9 -0
- package/dist/mesh.js +198 -0
- package/dist/mesh.mjs +9 -0
- package/dist/notifications.js +79 -0
- package/dist/notifications.mjs +9 -0
- package/dist/phone-types.js +18 -0
- package/dist/phone-types.mjs +0 -0
- package/dist/phone.js +269 -0
- package/dist/phone.mjs +9 -0
- package/dist/pipeline-types.js +18 -0
- package/dist/pipeline-types.mjs +0 -0
- package/dist/pipeline.js +263 -0
- package/dist/pipeline.mjs +9 -0
- package/dist/podcast.js +94 -0
- package/dist/podcast.mjs +9 -0
- package/dist/prism.js +82 -0
- package/dist/prism.mjs +9 -0
- package/dist/prompter.js +99 -0
- package/dist/prompter.mjs +76 -0
- package/dist/pulse.js +99 -0
- package/dist/pulse.mjs +9 -0
- package/dist/qr.js +71 -0
- package/dist/qr.mjs +9 -0
- package/dist/replay.js +62 -0
- package/dist/replay.mjs +38 -0
- package/dist/scene-types.js +18 -0
- package/dist/scene-types.mjs +1 -0
- package/dist/scene.js +271 -0
- package/dist/scene.mjs +10 -0
- package/dist/search-types.js +18 -0
- package/dist/search-types.mjs +1 -0
- package/dist/search.js +268 -0
- package/dist/search.mjs +10 -0
- package/dist/sentiment-types.js +18 -0
- package/dist/sentiment-types.mjs +0 -0
- package/dist/sentiment.js +235 -0
- package/dist/sentiment.mjs +9 -0
- package/dist/signage.js +93 -0
- package/dist/signage.mjs +9 -0
- package/dist/slides.js +78 -0
- package/dist/slides.mjs +9 -0
- package/dist/studio-ai-types.js +18 -0
- package/dist/studio-ai-types.mjs +1 -0
- package/dist/studio-ai.js +301 -0
- package/dist/studio-ai.mjs +10 -0
- package/dist/studio-types.js +18 -0
- package/dist/studio-types.mjs +1 -0
- package/dist/studio.js +303 -0
- package/dist/studio.mjs +10 -0
- package/dist/telemetry.js +124 -0
- package/dist/telemetry.mjs +15 -0
- package/dist/transcribe-types.js +18 -0
- package/dist/transcribe-types.mjs +1 -0
- package/dist/transcribe.js +282 -0
- package/dist/transcribe.mjs +10 -0
- package/dist/usb.js +69 -0
- package/dist/usb.mjs +9 -0
- package/dist/vault.js +96 -0
- package/dist/vault.mjs +9 -0
- package/dist/voice-types.js +18 -0
- package/dist/voice-types.mjs +0 -0
- package/dist/voice.js +272 -0
- package/dist/voice.mjs +9 -0
- package/dist/zoom.js +86 -0
- package/dist/zoom.mjs +9 -0
- package/package.json +3 -3
package/dist/client.js
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/client.ts
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
RateLimitError: () => RateLimitError,
|
|
24
|
+
WaveClient: () => WaveClient,
|
|
25
|
+
WaveError: () => WaveError,
|
|
26
|
+
createClient: () => createClient
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(client_exports);
|
|
29
|
+
var import_eventemitter3 = require("eventemitter3");
|
|
30
|
+
|
|
31
|
+
// src/telemetry.ts
|
|
32
|
+
var resolvedTracer = null;
|
|
33
|
+
var telemetryEnabled = false;
|
|
34
|
+
function initTelemetry(config) {
|
|
35
|
+
if (!config.enabled) {
|
|
36
|
+
telemetryEnabled = false;
|
|
37
|
+
resolvedTracer = null;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const otelApi = require("@opentelemetry/api");
|
|
42
|
+
const serviceName = config.serviceName ?? "@wave/sdk";
|
|
43
|
+
resolvedTracer = otelApi.trace.getTracer(serviceName, "2.0.0");
|
|
44
|
+
telemetryEnabled = true;
|
|
45
|
+
} catch {
|
|
46
|
+
telemetryEnabled = false;
|
|
47
|
+
resolvedTracer = null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/client.ts
|
|
52
|
+
var WaveError = class extends Error {
|
|
53
|
+
code;
|
|
54
|
+
statusCode;
|
|
55
|
+
requestId;
|
|
56
|
+
details;
|
|
57
|
+
retryable;
|
|
58
|
+
constructor(message, code, statusCode, requestId, details) {
|
|
59
|
+
super(message);
|
|
60
|
+
this.name = "WaveError";
|
|
61
|
+
this.code = code;
|
|
62
|
+
this.statusCode = statusCode;
|
|
63
|
+
this.requestId = requestId;
|
|
64
|
+
this.details = details;
|
|
65
|
+
this.retryable = this.isRetryable(statusCode, code);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var RateLimitError = class extends WaveError {
|
|
69
|
+
retryAfter;
|
|
70
|
+
constructor(message, retryAfter, requestId) {
|
|
71
|
+
super(message, "RATE_LIMITED", 429, requestId);
|
|
72
|
+
this.name = "RateLimitError";
|
|
73
|
+
this.retryAfter = retryAfter;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var WaveClient = class extends import_eventemitter3.EventEmitter {
|
|
77
|
+
config;
|
|
78
|
+
constructor(config) {
|
|
79
|
+
super();
|
|
80
|
+
if (!config.apiKey) {
|
|
81
|
+
throw new Error("WAVE SDK: apiKey is required");
|
|
82
|
+
}
|
|
83
|
+
this.config = {
|
|
84
|
+
apiKey: config.apiKey,
|
|
85
|
+
organizationId: config.organizationId || "",
|
|
86
|
+
baseUrl: config.baseUrl || "https://api.wave.online",
|
|
87
|
+
timeout: config.timeout || 3e4,
|
|
88
|
+
maxRetries: config.maxRetries ?? 3,
|
|
89
|
+
debug: config.debug || false,
|
|
90
|
+
customHeaders: config.customHeaders || {},
|
|
91
|
+
telemetry: config.telemetry
|
|
92
|
+
};
|
|
93
|
+
if (config.telemetry) {
|
|
94
|
+
initTelemetry(config.telemetry);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Make a GET request
|
|
99
|
+
*/
|
|
100
|
+
async get(path, options) {
|
|
101
|
+
return this.request(path, { ...options, method: "GET" });
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Make a POST request
|
|
105
|
+
*/
|
|
106
|
+
async post(path, body, options) {
|
|
107
|
+
return this.request(path, {
|
|
108
|
+
...options,
|
|
109
|
+
method: "POST",
|
|
110
|
+
body: body ? JSON.stringify(body) : void 0
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Make a PUT request
|
|
115
|
+
*/
|
|
116
|
+
async put(path, body, options) {
|
|
117
|
+
return this.request(path, {
|
|
118
|
+
...options,
|
|
119
|
+
method: "PUT",
|
|
120
|
+
body: body ? JSON.stringify(body) : void 0
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Make a PATCH request
|
|
125
|
+
*/
|
|
126
|
+
async patch(path, body, options) {
|
|
127
|
+
return this.request(path, {
|
|
128
|
+
...options,
|
|
129
|
+
method: "PATCH",
|
|
130
|
+
body: body ? JSON.stringify(body) : void 0
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Make a DELETE request
|
|
135
|
+
*/
|
|
136
|
+
async delete(path, options) {
|
|
137
|
+
return this.request(path, { ...options, method: "DELETE" });
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Make an API request with retry logic
|
|
141
|
+
*/
|
|
142
|
+
async request(path, options = {}) {
|
|
143
|
+
const { params, noRetry, timeout: requestTimeout, ...fetchOptions } = options;
|
|
144
|
+
let url = `${this.config.baseUrl}${path}`;
|
|
145
|
+
if (params) {
|
|
146
|
+
const searchParams = new URLSearchParams();
|
|
147
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
148
|
+
if (value !== void 0) {
|
|
149
|
+
searchParams.set(key, String(value));
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
const queryString = searchParams.toString();
|
|
153
|
+
if (queryString) {
|
|
154
|
+
url += `?${queryString}`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return this.executeWithRetry(
|
|
158
|
+
url,
|
|
159
|
+
{
|
|
160
|
+
...fetchOptions,
|
|
161
|
+
headers: this.buildHeaders(fetchOptions.headers)
|
|
162
|
+
},
|
|
163
|
+
noRetry ? 0 : this.config.maxRetries,
|
|
164
|
+
requestTimeout || this.config.timeout
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Execute request with exponential backoff retry
|
|
169
|
+
*/
|
|
170
|
+
async executeWithRetry(url, options, maxRetries, timeout) {
|
|
171
|
+
const method = options.method || "GET";
|
|
172
|
+
let lastError = null;
|
|
173
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
174
|
+
try {
|
|
175
|
+
this.emit("request.start", url, method);
|
|
176
|
+
const startTime = Date.now();
|
|
177
|
+
const response = await this.fetchWithTimeout(url, options, timeout);
|
|
178
|
+
const duration = Date.now() - startTime;
|
|
179
|
+
if (response.status === 429) {
|
|
180
|
+
const retryAfter = this.parseRetryAfter(response);
|
|
181
|
+
this.emit("rate_limit.hit", retryAfter);
|
|
182
|
+
if (attempt < maxRetries) {
|
|
183
|
+
this.emit("request.retry", url, method, attempt + 1, retryAfter);
|
|
184
|
+
await this.sleep(retryAfter);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
throw new RateLimitError(
|
|
188
|
+
"Rate limit exceeded",
|
|
189
|
+
retryAfter,
|
|
190
|
+
response.headers.get("x-request-id") || void 0
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
if (!response.ok) {
|
|
194
|
+
const error = await this.parseErrorResponse(response);
|
|
195
|
+
if (error.retryable && attempt < maxRetries) {
|
|
196
|
+
const delay = this.calculateBackoff(attempt);
|
|
197
|
+
this.emit("request.retry", url, method, attempt + 1, delay);
|
|
198
|
+
await this.sleep(delay);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
this.emit("request.success", url, method, duration);
|
|
204
|
+
const contentType = response.headers.get("content-type");
|
|
205
|
+
if (contentType?.includes("application/json")) {
|
|
206
|
+
return response.json();
|
|
207
|
+
}
|
|
208
|
+
return {};
|
|
209
|
+
} catch (error) {
|
|
210
|
+
lastError = error;
|
|
211
|
+
if (error instanceof WaveError && !error.retryable) {
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
if (error instanceof TypeError || error instanceof Error && error.name === "AbortError") {
|
|
215
|
+
if (attempt < maxRetries) {
|
|
216
|
+
const delay = this.calculateBackoff(attempt);
|
|
217
|
+
this.emit("request.retry", url, method, attempt + 1, delay);
|
|
218
|
+
await this.sleep(delay);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
this.emit("request.error", url, method, error);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
throw lastError || new WaveError("Request failed after retries", "UNKNOWN_ERROR", 0);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Fetch with timeout
|
|
229
|
+
*/
|
|
230
|
+
async fetchWithTimeout(url, options, timeout) {
|
|
231
|
+
const controller = new AbortController();
|
|
232
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
233
|
+
try {
|
|
234
|
+
const response = await fetch(url, {
|
|
235
|
+
...options,
|
|
236
|
+
signal: controller.signal
|
|
237
|
+
});
|
|
238
|
+
return response;
|
|
239
|
+
} finally {
|
|
240
|
+
clearTimeout(timeoutId);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Build request headers
|
|
245
|
+
*/
|
|
246
|
+
buildHeaders(additionalHeaders) {
|
|
247
|
+
const headers = {
|
|
248
|
+
"Authorization": `Bearer ${this.config.apiKey}`,
|
|
249
|
+
"Content-Type": "application/json",
|
|
250
|
+
"Accept": "application/json",
|
|
251
|
+
"User-Agent": `wave-sdk-typescript/1.0.0`,
|
|
252
|
+
...this.config.customHeaders
|
|
253
|
+
};
|
|
254
|
+
if (this.config.organizationId) {
|
|
255
|
+
headers["X-Organization-Id"] = this.config.organizationId;
|
|
256
|
+
}
|
|
257
|
+
if (additionalHeaders) {
|
|
258
|
+
if (additionalHeaders instanceof Headers) {
|
|
259
|
+
additionalHeaders.forEach((value, key) => {
|
|
260
|
+
headers[key] = value;
|
|
261
|
+
});
|
|
262
|
+
} else if (Array.isArray(additionalHeaders)) {
|
|
263
|
+
additionalHeaders.forEach(([key, value]) => {
|
|
264
|
+
headers[key] = value;
|
|
265
|
+
});
|
|
266
|
+
} else {
|
|
267
|
+
Object.assign(headers, additionalHeaders);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return headers;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Parse error response
|
|
274
|
+
*/
|
|
275
|
+
/**
|
|
276
|
+
* Parse Retry-After header
|
|
277
|
+
*/
|
|
278
|
+
/**
|
|
279
|
+
* Calculate exponential backoff delay
|
|
280
|
+
*/
|
|
281
|
+
calculateBackoff(attempt) {
|
|
282
|
+
const baseDelay = 1e3;
|
|
283
|
+
const maxDelay = 3e4;
|
|
284
|
+
const delay = Math.min(baseDelay * Math.pow(2, attempt), maxDelay);
|
|
285
|
+
return delay + Math.random() * delay * 0.25;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Sleep utility
|
|
289
|
+
*/
|
|
290
|
+
sleep(ms) {
|
|
291
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Log debug message
|
|
295
|
+
*/
|
|
296
|
+
log(message, ...args) {
|
|
297
|
+
if (this.config.debug) {
|
|
298
|
+
console.log(`[WaveSDK] ${message}`, ...args);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
function createClient(config) {
|
|
303
|
+
return new WaveClient(config);
|
|
304
|
+
}
|
|
305
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
306
|
+
0 && (module.exports = {
|
|
307
|
+
RateLimitError,
|
|
308
|
+
WaveClient,
|
|
309
|
+
WaveError,
|
|
310
|
+
createClient
|
|
311
|
+
});
|
package/dist/client.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/clips-types.ts
|
|
17
|
+
var clips_types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(clips_types_exports);
|
|
File without changes
|
package/dist/clips.js
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/clips.ts
|
|
21
|
+
var clips_exports = {};
|
|
22
|
+
__export(clips_exports, {
|
|
23
|
+
ClipsAPI: () => ClipsAPI,
|
|
24
|
+
createClipsAPI: () => createClipsAPI
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(clips_exports);
|
|
27
|
+
var ClipsAPI = class {
|
|
28
|
+
client;
|
|
29
|
+
basePath = "/v1/clips";
|
|
30
|
+
constructor(client) {
|
|
31
|
+
this.client = client;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a new clip
|
|
35
|
+
*
|
|
36
|
+
* Requires: clips:create permission
|
|
37
|
+
*/
|
|
38
|
+
async create(request) {
|
|
39
|
+
return this.client.post(this.basePath, request);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get a clip by ID
|
|
43
|
+
*
|
|
44
|
+
* Requires: clips:read permission
|
|
45
|
+
*/
|
|
46
|
+
async get(clipId) {
|
|
47
|
+
return this.client.get(`${this.basePath}/${clipId}`);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Update a clip
|
|
51
|
+
*
|
|
52
|
+
* Requires: clips:update permission
|
|
53
|
+
*/
|
|
54
|
+
async update(clipId, request) {
|
|
55
|
+
return this.client.patch(`${this.basePath}/${clipId}`, request);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Remove a clip
|
|
59
|
+
*
|
|
60
|
+
* Requires: clips:remove permission (server-side RBAC enforced)
|
|
61
|
+
*/
|
|
62
|
+
async remove(clipId) {
|
|
63
|
+
await this.client.delete(`${this.basePath}/${clipId}`);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* List clips with optional filters
|
|
67
|
+
*
|
|
68
|
+
* Requires: clips:read permission
|
|
69
|
+
*/
|
|
70
|
+
async list(params) {
|
|
71
|
+
const queryParams = {
|
|
72
|
+
limit: params?.limit,
|
|
73
|
+
offset: params?.offset,
|
|
74
|
+
cursor: params?.cursor,
|
|
75
|
+
status: params?.status,
|
|
76
|
+
source_type: params?.source_type,
|
|
77
|
+
source_id: params?.source_id,
|
|
78
|
+
created_after: params?.created_after,
|
|
79
|
+
created_before: params?.created_before,
|
|
80
|
+
order_by: params?.order_by,
|
|
81
|
+
order: params?.order
|
|
82
|
+
};
|
|
83
|
+
if (params?.tags?.length) {
|
|
84
|
+
queryParams["tags"] = params.tags.join(",");
|
|
85
|
+
}
|
|
86
|
+
return this.client.get(this.basePath, {
|
|
87
|
+
params: queryParams
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Export a clip to a different format
|
|
92
|
+
*
|
|
93
|
+
* Requires: clips:export permission
|
|
94
|
+
*/
|
|
95
|
+
async exportClip(clipId, request) {
|
|
96
|
+
return this.client.post(
|
|
97
|
+
`${this.basePath}/${clipId}/export`,
|
|
98
|
+
request
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get export job status
|
|
103
|
+
*
|
|
104
|
+
* Requires: clips:read permission
|
|
105
|
+
*/
|
|
106
|
+
async getExport(clipId, exportId) {
|
|
107
|
+
return this.client.get(
|
|
108
|
+
`${this.basePath}/${clipId}/exports/${exportId}`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* List all exports for a clip
|
|
113
|
+
*
|
|
114
|
+
* Requires: clips:read permission
|
|
115
|
+
*/
|
|
116
|
+
async listExports(clipId, params) {
|
|
117
|
+
return this.client.get(
|
|
118
|
+
`${this.basePath}/${clipId}/exports`,
|
|
119
|
+
{ params }
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Detect highlights in source content
|
|
124
|
+
*
|
|
125
|
+
* Requires: clips:analyze permission
|
|
126
|
+
*/
|
|
127
|
+
async detectHighlights(sourceType, sourceId, options) {
|
|
128
|
+
return this.client.post(
|
|
129
|
+
`${this.basePath}/highlights/detect`,
|
|
130
|
+
{
|
|
131
|
+
source_type: sourceType,
|
|
132
|
+
source_id: sourceId,
|
|
133
|
+
...options
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Generate clips from detected highlights
|
|
139
|
+
*
|
|
140
|
+
* Requires: clips:create permission
|
|
141
|
+
*/
|
|
142
|
+
async createFromHighlights(sourceType, sourceId, options) {
|
|
143
|
+
return this.client.post(`${this.basePath}/highlights/create`, {
|
|
144
|
+
source_type: sourceType,
|
|
145
|
+
source_id: sourceId,
|
|
146
|
+
...options
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Wait for a clip to be ready
|
|
151
|
+
*/
|
|
152
|
+
async waitForReady(clipId, options) {
|
|
153
|
+
const pollInterval = options?.pollInterval || 2e3;
|
|
154
|
+
const timeout = options?.timeout || 3e5;
|
|
155
|
+
const startTime = Date.now();
|
|
156
|
+
while (Date.now() - startTime < timeout) {
|
|
157
|
+
const clip = await this.get(clipId);
|
|
158
|
+
if (options?.onProgress) {
|
|
159
|
+
options.onProgress(clip);
|
|
160
|
+
}
|
|
161
|
+
if (clip.status === "ready") {
|
|
162
|
+
return clip;
|
|
163
|
+
}
|
|
164
|
+
if (clip.status === "failed") {
|
|
165
|
+
throw new Error(`Clip processing failed: ${clip.error || "Unknown error"}`);
|
|
166
|
+
}
|
|
167
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
168
|
+
}
|
|
169
|
+
throw new Error(`Clip processing timed out after ${timeout}ms`);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Wait for an export to be ready
|
|
173
|
+
*/
|
|
174
|
+
async waitForExport(clipId, exportId, options) {
|
|
175
|
+
const pollInterval = options?.pollInterval || 2e3;
|
|
176
|
+
const timeout = options?.timeout || 3e5;
|
|
177
|
+
const startTime = Date.now();
|
|
178
|
+
while (Date.now() - startTime < timeout) {
|
|
179
|
+
const exportJob = await this.getExport(clipId, exportId);
|
|
180
|
+
if (exportJob.status === "ready") {
|
|
181
|
+
return exportJob;
|
|
182
|
+
}
|
|
183
|
+
if (exportJob.status === "failed") {
|
|
184
|
+
throw new Error(`Export failed: ${exportJob.error || "Unknown error"}`);
|
|
185
|
+
}
|
|
186
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
187
|
+
}
|
|
188
|
+
throw new Error(`Export timed out after ${timeout}ms`);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
function createClipsAPI(client) {
|
|
192
|
+
return new ClipsAPI(client);
|
|
193
|
+
}
|
|
194
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
195
|
+
0 && (module.exports = {
|
|
196
|
+
ClipsAPI,
|
|
197
|
+
createClipsAPI
|
|
198
|
+
});
|
package/dist/clips.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/cloud-switcher.ts
|
|
21
|
+
var cloud_switcher_exports = {};
|
|
22
|
+
__export(cloud_switcher_exports, {
|
|
23
|
+
CloudSwitcherAPI: () => CloudSwitcherAPI,
|
|
24
|
+
createCloudSwitcherAPI: () => createCloudSwitcherAPI
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(cloud_switcher_exports);
|
|
27
|
+
var CloudSwitcherAPI = class {
|
|
28
|
+
client;
|
|
29
|
+
basePath = "/v1/switcher";
|
|
30
|
+
constructor(client) {
|
|
31
|
+
this.client = client;
|
|
32
|
+
}
|
|
33
|
+
async create(options) {
|
|
34
|
+
return this.client.post(this.basePath, options);
|
|
35
|
+
}
|
|
36
|
+
async get(switcherId) {
|
|
37
|
+
return this.client.get(`${this.basePath}/${switcherId}`);
|
|
38
|
+
}
|
|
39
|
+
async list() {
|
|
40
|
+
return this.client.get(this.basePath);
|
|
41
|
+
}
|
|
42
|
+
async remove(switcherId) {
|
|
43
|
+
await this.client.delete(`${this.basePath}/${switcherId}`);
|
|
44
|
+
}
|
|
45
|
+
async addSource(switcherId, options) {
|
|
46
|
+
return this.client.post(`${this.basePath}/${switcherId}/sources`, options);
|
|
47
|
+
}
|
|
48
|
+
async removeSource(switcherId, sourceId) {
|
|
49
|
+
await this.client.delete(`${this.basePath}/${switcherId}/sources/${sourceId}`);
|
|
50
|
+
}
|
|
51
|
+
async switchTo(switcherId, sourceId) {
|
|
52
|
+
await this.client.post(`${this.basePath}/${switcherId}/control`, { type: "switch", sourceId });
|
|
53
|
+
}
|
|
54
|
+
async transition(switcherId, options) {
|
|
55
|
+
await this.client.post(`${this.basePath}/${switcherId}/control`, { type: "transition", config: options });
|
|
56
|
+
}
|
|
57
|
+
async addOutput(switcherId, options) {
|
|
58
|
+
return this.client.post(`${this.basePath}/${switcherId}/outputs`, options);
|
|
59
|
+
}
|
|
60
|
+
async startStreaming(switcherId, outputId) {
|
|
61
|
+
await this.client.post(`${this.basePath}/${switcherId}/outputs/${outputId}/start`, {});
|
|
62
|
+
}
|
|
63
|
+
async stopStreaming(switcherId, outputId) {
|
|
64
|
+
await this.client.post(`${this.basePath}/${switcherId}/outputs/${outputId}/stop`, {});
|
|
65
|
+
}
|
|
66
|
+
async startRecording(switcherId) {
|
|
67
|
+
await this.client.post(`${this.basePath}/${switcherId}/record/start`, {});
|
|
68
|
+
}
|
|
69
|
+
async stopRecording(switcherId) {
|
|
70
|
+
await this.client.post(`${this.basePath}/${switcherId}/record/stop`, {});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
function createCloudSwitcherAPI(client) {
|
|
74
|
+
return new CloudSwitcherAPI(client);
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
CloudSwitcherAPI,
|
|
79
|
+
createCloudSwitcherAPI
|
|
80
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import "./chunk-Y6FXYEAI.mjs";
|
|
2
|
+
|
|
3
|
+
// src/cloud-switcher.ts
|
|
4
|
+
var CloudSwitcherAPI = class {
|
|
5
|
+
client;
|
|
6
|
+
basePath = "/v1/switcher";
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
async create(options) {
|
|
11
|
+
return this.client.post(this.basePath, options);
|
|
12
|
+
}
|
|
13
|
+
async get(switcherId) {
|
|
14
|
+
return this.client.get(`${this.basePath}/${switcherId}`);
|
|
15
|
+
}
|
|
16
|
+
async list() {
|
|
17
|
+
return this.client.get(this.basePath);
|
|
18
|
+
}
|
|
19
|
+
async remove(switcherId) {
|
|
20
|
+
await this.client.delete(`${this.basePath}/${switcherId}`);
|
|
21
|
+
}
|
|
22
|
+
async addSource(switcherId, options) {
|
|
23
|
+
return this.client.post(`${this.basePath}/${switcherId}/sources`, options);
|
|
24
|
+
}
|
|
25
|
+
async removeSource(switcherId, sourceId) {
|
|
26
|
+
await this.client.delete(`${this.basePath}/${switcherId}/sources/${sourceId}`);
|
|
27
|
+
}
|
|
28
|
+
async switchTo(switcherId, sourceId) {
|
|
29
|
+
await this.client.post(`${this.basePath}/${switcherId}/control`, { type: "switch", sourceId });
|
|
30
|
+
}
|
|
31
|
+
async transition(switcherId, options) {
|
|
32
|
+
await this.client.post(`${this.basePath}/${switcherId}/control`, { type: "transition", config: options });
|
|
33
|
+
}
|
|
34
|
+
async addOutput(switcherId, options) {
|
|
35
|
+
return this.client.post(`${this.basePath}/${switcherId}/outputs`, options);
|
|
36
|
+
}
|
|
37
|
+
async startStreaming(switcherId, outputId) {
|
|
38
|
+
await this.client.post(`${this.basePath}/${switcherId}/outputs/${outputId}/start`, {});
|
|
39
|
+
}
|
|
40
|
+
async stopStreaming(switcherId, outputId) {
|
|
41
|
+
await this.client.post(`${this.basePath}/${switcherId}/outputs/${outputId}/stop`, {});
|
|
42
|
+
}
|
|
43
|
+
async startRecording(switcherId) {
|
|
44
|
+
await this.client.post(`${this.basePath}/${switcherId}/record/start`, {});
|
|
45
|
+
}
|
|
46
|
+
async stopRecording(switcherId) {
|
|
47
|
+
await this.client.post(`${this.basePath}/${switcherId}/record/stop`, {});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
function createCloudSwitcherAPI(client) {
|
|
51
|
+
return new CloudSwitcherAPI(client);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
CloudSwitcherAPI,
|
|
55
|
+
createCloudSwitcherAPI
|
|
56
|
+
};
|