@blitzreels/sdk 0.1.5 → 0.1.6
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/README.md +52 -0
- package/dist/client.d.ts +190 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +72 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +16 -1482
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1060
- package/dist/index.js.map +1 -1
- package/dist/resources/ai-edit.d.ts +2 -2
- package/dist/resources/ai-edit.d.ts.map +1 -1
- package/dist/resources/auth-projects.d.ts +24 -0
- package/dist/resources/auth-projects.d.ts.map +1 -0
- package/dist/resources/auth-projects.js +115 -0
- package/dist/resources/auth-projects.js.map +1 -0
- package/dist/resources/captions.d.ts +4 -5
- package/dist/resources/captions.d.ts.map +1 -1
- package/dist/resources/captions.js +8 -0
- package/dist/resources/captions.js.map +1 -1
- package/dist/resources/content-audio.d.ts +20 -0
- package/dist/resources/content-audio.d.ts.map +1 -0
- package/dist/resources/content-audio.js +98 -0
- package/dist/resources/content-audio.js.map +1 -0
- package/dist/resources/effects-workflows.d.ts +29 -0
- package/dist/resources/effects-workflows.d.ts.map +1 -0
- package/dist/resources/effects-workflows.js +154 -0
- package/dist/resources/effects-workflows.js.map +1 -0
- package/dist/resources/exports-jobs.d.ts +19 -0
- package/dist/resources/exports-jobs.d.ts.map +1 -0
- package/dist/resources/exports-jobs.js +88 -0
- package/dist/resources/exports-jobs.js.map +1 -0
- package/dist/resources/faceless.d.ts +18 -0
- package/dist/resources/faceless.d.ts.map +1 -0
- package/dist/resources/faceless.js +89 -0
- package/dist/resources/faceless.js.map +1 -0
- package/dist/resources/formats.d.ts +9 -0
- package/dist/resources/formats.d.ts.map +1 -0
- package/dist/resources/formats.js +21 -0
- package/dist/resources/formats.js.map +1 -0
- package/dist/resources/libraries.d.ts +19 -0
- package/dist/resources/libraries.d.ts.map +1 -0
- package/dist/resources/libraries.js +89 -0
- package/dist/resources/libraries.js.map +1 -0
- package/dist/resources/media-clips.d.ts +57 -0
- package/dist/resources/media-clips.d.ts.map +1 -0
- package/dist/resources/media-clips.js +346 -0
- package/dist/resources/media-clips.js.map +1 -0
- package/dist/resources/timeline.d.ts +10 -2
- package/dist/resources/timeline.d.ts.map +1 -1
- package/dist/resources/timeline.js +90 -45
- package/dist/resources/timeline.js.map +1 -1
- package/dist/resources/workspace-onboarding.d.ts +25 -0
- package/dist/resources/workspace-onboarding.d.ts.map +1 -0
- package/dist/resources/workspace-onboarding.js +99 -0
- package/dist/resources/workspace-onboarding.js.map +1 -0
- package/dist/transport.d.ts +22 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +189 -0
- package/dist/transport.js.map +1 -0
- package/dist/types/ai-edit.d.ts +180 -0
- package/dist/types/ai-edit.d.ts.map +1 -0
- package/dist/types/ai-edit.js +2 -0
- package/dist/types/ai-edit.js.map +1 -0
- package/dist/types/captions.d.ts +181 -0
- package/dist/types/captions.d.ts.map +1 -0
- package/dist/types/captions.js +2 -0
- package/dist/types/captions.js.map +1 -0
- package/dist/types/clips.d.ts +124 -0
- package/dist/types/clips.d.ts.map +1 -0
- package/dist/types/clips.js +2 -0
- package/dist/types/clips.js.map +1 -0
- package/dist/types/common.d.ts +241 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/{resources → types}/common.js.map +1 -1
- package/dist/types/exports.d.ts +62 -0
- package/dist/types/exports.d.ts.map +1 -0
- package/dist/types/exports.js +2 -0
- package/dist/types/exports.js.map +1 -0
- package/dist/types/faceless.d.ts +167 -0
- package/dist/types/faceless.d.ts.map +1 -0
- package/dist/types/faceless.js +2 -0
- package/dist/types/faceless.js.map +1 -0
- package/dist/types/formats.d.ts +40 -0
- package/dist/types/formats.d.ts.map +1 -0
- package/dist/types/formats.js +2 -0
- package/dist/types/formats.js.map +1 -0
- package/dist/types/libraries.d.ts +184 -0
- package/dist/types/libraries.d.ts.map +1 -0
- package/dist/types/libraries.js +2 -0
- package/dist/types/libraries.js.map +1 -0
- package/dist/types/media.d.ts +297 -0
- package/dist/types/media.d.ts.map +1 -0
- package/dist/types/media.js +2 -0
- package/dist/types/media.js.map +1 -0
- package/dist/types/projects.d.ts +185 -0
- package/dist/types/projects.d.ts.map +1 -0
- package/dist/types/projects.js +2 -0
- package/dist/types/projects.js.map +1 -0
- package/dist/types/timeline.d.ts +90 -0
- package/dist/types/timeline.d.ts.map +1 -0
- package/dist/types/timeline.js +2 -0
- package/dist/types/timeline.js.map +1 -0
- package/dist/types/workspace.d.ts +129 -0
- package/dist/types/workspace.d.ts.map +1 -0
- package/dist/types/workspace.js +2 -0
- package/dist/types/workspace.js.map +1 -0
- package/package.json +6 -1
- package/dist/resources/common.d.ts +0 -3
- package/dist/resources/common.d.ts.map +0 -1
- /package/dist/{resources → types}/common.js +0 -0
package/dist/index.js
CHANGED
|
@@ -1,1061 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const DEFAULT_BASE_URL = "https://www.blitzreels.com/api/v1";
|
|
5
|
-
export class BlitzReelsError extends Error {
|
|
6
|
-
status;
|
|
7
|
-
requestId;
|
|
8
|
-
body;
|
|
9
|
-
code;
|
|
10
|
-
retryable;
|
|
11
|
-
constructor(options) {
|
|
12
|
-
super(options.message);
|
|
13
|
-
this.name = "BlitzReelsError";
|
|
14
|
-
this.status = options.status;
|
|
15
|
-
this.requestId = options.requestId;
|
|
16
|
-
this.body = options.body;
|
|
17
|
-
this.code = options.code ?? classifyBlitzReelsErrorCode(options);
|
|
18
|
-
this.retryable = options.retryable ?? isRetryableBlitzReelsStatus(options);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function normalizeBaseUrl({ baseUrl, }) {
|
|
22
|
-
const value = String(baseUrl ?? DEFAULT_BASE_URL).trim();
|
|
23
|
-
return value.replace(/\/+$/, "");
|
|
24
|
-
}
|
|
25
|
-
function appendQuery({ url, query, }) {
|
|
26
|
-
if (query === undefined) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
for (const [key, value] of Object.entries(query)) {
|
|
30
|
-
const values = Array.isArray(value) ? value : [value];
|
|
31
|
-
for (const item of values) {
|
|
32
|
-
if (item === undefined || item === null) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
url.searchParams.append(key, String(item));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function classifyBlitzReelsErrorCode({ status, body, }) {
|
|
40
|
-
const bodyCode = extractErrorCode({ body });
|
|
41
|
-
if (bodyCode) {
|
|
42
|
-
return bodyCode;
|
|
43
|
-
}
|
|
44
|
-
if (status === 401 || status === 403) {
|
|
45
|
-
return "auth_error";
|
|
46
|
-
}
|
|
47
|
-
if (status === 404) {
|
|
48
|
-
return "not_found";
|
|
49
|
-
}
|
|
50
|
-
if (status === 409) {
|
|
51
|
-
return "conflict";
|
|
52
|
-
}
|
|
53
|
-
if (status === 408) {
|
|
54
|
-
return "timeout";
|
|
55
|
-
}
|
|
56
|
-
if (status === 400 || status === 422) {
|
|
57
|
-
return "validation_error";
|
|
58
|
-
}
|
|
59
|
-
if (status === 429) {
|
|
60
|
-
return "rate_limited";
|
|
61
|
-
}
|
|
62
|
-
if (status >= 500) {
|
|
63
|
-
return "server_error";
|
|
64
|
-
}
|
|
65
|
-
return "api_error";
|
|
66
|
-
}
|
|
67
|
-
function isRetryableBlitzReelsStatus({ status }) {
|
|
68
|
-
return status === 408 || status === 429 || status >= 500;
|
|
69
|
-
}
|
|
70
|
-
function extractErrorMessage({ body }) {
|
|
71
|
-
if (body === null || typeof body !== "object") {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
const record = body;
|
|
75
|
-
const message = record.message ?? record.error;
|
|
76
|
-
return typeof message === "string" ? message : null;
|
|
77
|
-
}
|
|
78
|
-
function extractErrorCode({ body, }) {
|
|
79
|
-
if (body === null || typeof body !== "object") {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
const value = body.code;
|
|
83
|
-
if (value === "api_error" ||
|
|
84
|
-
value === "auth_error" ||
|
|
85
|
-
value === "not_found" ||
|
|
86
|
-
value === "conflict" ||
|
|
87
|
-
value === "validation_error" ||
|
|
88
|
-
value === "rate_limited" ||
|
|
89
|
-
value === "timeout" ||
|
|
90
|
-
value === "server_error") {
|
|
91
|
-
return value;
|
|
92
|
-
}
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
function normalizeMediaPositionPreset({ value, }) {
|
|
96
|
-
if (value === "full-screen") {
|
|
97
|
-
return "fullscreen";
|
|
98
|
-
}
|
|
99
|
-
if (value === "top-left") {
|
|
100
|
-
return "pip-top-left";
|
|
101
|
-
}
|
|
102
|
-
if (value === "top-right") {
|
|
103
|
-
return "pip-top-right";
|
|
104
|
-
}
|
|
105
|
-
if (value === "bottom-left") {
|
|
106
|
-
return "pip-bottom-left";
|
|
107
|
-
}
|
|
108
|
-
if (value === "bottom-right") {
|
|
109
|
-
return "pip-bottom-right";
|
|
110
|
-
}
|
|
111
|
-
return value;
|
|
112
|
-
}
|
|
113
|
-
function normalizeMediaAnimationPreset({ value, }) {
|
|
114
|
-
return value === "slideIn" ? "slideUp" : value;
|
|
115
|
-
}
|
|
116
|
-
function sleep({ ms }) {
|
|
117
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
118
|
-
}
|
|
119
|
-
function deepCloneJson({ value }) {
|
|
120
|
-
return JSON.parse(JSON.stringify(value));
|
|
121
|
-
}
|
|
122
|
-
function replaceFirstTextContent({ value, text, }) {
|
|
123
|
-
if (!value || typeof value !== "object") {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
if (Array.isArray(value)) {
|
|
127
|
-
for (const item of value) {
|
|
128
|
-
if (replaceFirstTextContent({ value: item, text })) {
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
const record = value;
|
|
135
|
-
if (record.type === "text" && typeof record.content === "string") {
|
|
136
|
-
record.content = text;
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
for (const childKey of ["children", "elements"]) {
|
|
140
|
-
if (replaceFirstTextContent({ value: record[childKey], text })) {
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
function updateTextSpecContent({ spec, text, }) {
|
|
147
|
-
const next = deepCloneJson({ value: spec });
|
|
148
|
-
if (!replaceFirstTextContent({ value: next, text })) {
|
|
149
|
-
throw new BlitzReelsError({
|
|
150
|
-
message: "Content item spec does not contain editable text content.",
|
|
151
|
-
status: 422,
|
|
152
|
-
requestId: null,
|
|
153
|
-
body: { spec },
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
return next;
|
|
157
|
-
}
|
|
158
|
-
export class BlitzReelsClient {
|
|
159
|
-
apiKey;
|
|
160
|
-
baseUrl;
|
|
161
|
-
fetchFn;
|
|
162
|
-
userAgent;
|
|
163
|
-
auth;
|
|
164
|
-
projects;
|
|
165
|
-
timeline;
|
|
166
|
-
effects;
|
|
167
|
-
workspace;
|
|
168
|
-
media;
|
|
169
|
-
clips;
|
|
170
|
-
text;
|
|
171
|
-
audio;
|
|
172
|
-
audioLibrary;
|
|
173
|
-
stockMedia;
|
|
174
|
-
library;
|
|
175
|
-
silence;
|
|
176
|
-
mistakes;
|
|
177
|
-
aiEdit;
|
|
178
|
-
captions;
|
|
179
|
-
exports;
|
|
180
|
-
jobs;
|
|
181
|
-
constructor(config) {
|
|
182
|
-
this.apiKey = config.apiKey;
|
|
183
|
-
this.baseUrl = normalizeBaseUrl({ baseUrl: config.baseUrl });
|
|
184
|
-
this.fetchFn = config.fetchFn ?? fetch;
|
|
185
|
-
this.userAgent = config.userAgent ?? "blitzreels-sdk/0.0.0";
|
|
186
|
-
this.auth = {
|
|
187
|
-
validate: () => this.request({
|
|
188
|
-
method: "GET",
|
|
189
|
-
path: "/auth/validate",
|
|
190
|
-
query: undefined,
|
|
191
|
-
body: undefined,
|
|
192
|
-
}),
|
|
193
|
-
};
|
|
194
|
-
this.projects = {
|
|
195
|
-
list: (options) => this.request({
|
|
196
|
-
method: "GET",
|
|
197
|
-
path: "/projects",
|
|
198
|
-
query: {
|
|
199
|
-
limit: options.limit,
|
|
200
|
-
cursor: options.cursor,
|
|
201
|
-
offset: options.offset,
|
|
202
|
-
search: options.search,
|
|
203
|
-
status: options.status,
|
|
204
|
-
},
|
|
205
|
-
body: undefined,
|
|
206
|
-
}),
|
|
207
|
-
create: (options) => this.request({
|
|
208
|
-
method: "POST",
|
|
209
|
-
path: "/projects",
|
|
210
|
-
query: undefined,
|
|
211
|
-
body: {
|
|
212
|
-
name: options.name,
|
|
213
|
-
description: options.description,
|
|
214
|
-
aspect_ratio: options.aspectRatio,
|
|
215
|
-
project_type: options.projectType,
|
|
216
|
-
carousel_settings: options.carouselSettings,
|
|
217
|
-
},
|
|
218
|
-
}),
|
|
219
|
-
get: (options) => this.request({
|
|
220
|
-
method: "GET",
|
|
221
|
-
path: `/projects/${encodeURIComponent(options.projectId)}`,
|
|
222
|
-
query: undefined,
|
|
223
|
-
body: undefined,
|
|
224
|
-
}),
|
|
225
|
-
update: (options) => this.request({
|
|
226
|
-
method: "PATCH",
|
|
227
|
-
path: `/projects/${encodeURIComponent(options.projectId)}`,
|
|
228
|
-
query: undefined,
|
|
229
|
-
body: {
|
|
230
|
-
name: options.name,
|
|
231
|
-
description: options.description,
|
|
232
|
-
},
|
|
233
|
-
}),
|
|
234
|
-
delete: (options) => this.request({
|
|
235
|
-
method: "DELETE",
|
|
236
|
-
path: `/projects/${encodeURIComponent(options.projectId)}`,
|
|
237
|
-
query: undefined,
|
|
238
|
-
body: undefined,
|
|
239
|
-
}),
|
|
240
|
-
inspect: (options) => this.request({
|
|
241
|
-
method: "GET",
|
|
242
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/context`,
|
|
243
|
-
query: {
|
|
244
|
-
mode: options.mode,
|
|
245
|
-
asset_limit: options.assetLimit,
|
|
246
|
-
asset_offset: options.assetOffset,
|
|
247
|
-
timeline_limit: options.timelineLimit,
|
|
248
|
-
timeline_offset: options.timelineOffset,
|
|
249
|
-
transcript_limit: options.transcriptLimit,
|
|
250
|
-
transcript_offset: options.transcriptOffset,
|
|
251
|
-
caption_word_limit: options.captionWordLimit,
|
|
252
|
-
caption_word_offset: options.captionWordOffset,
|
|
253
|
-
},
|
|
254
|
-
body: undefined,
|
|
255
|
-
}),
|
|
256
|
-
timeline: (options) => this.request({
|
|
257
|
-
method: "GET",
|
|
258
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/context`,
|
|
259
|
-
query: {
|
|
260
|
-
mode: "timeline",
|
|
261
|
-
timeline_limit: options.limit,
|
|
262
|
-
timeline_offset: options.offset,
|
|
263
|
-
},
|
|
264
|
-
body: undefined,
|
|
265
|
-
}),
|
|
266
|
-
renderSnapshot: (options) => this.request({
|
|
267
|
-
method: "POST",
|
|
268
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/preview-frame`,
|
|
269
|
-
query: undefined,
|
|
270
|
-
body: {
|
|
271
|
-
time_seconds: options.atSeconds,
|
|
272
|
-
target_width: options.targetWidth,
|
|
273
|
-
image_format: options.imageFormat,
|
|
274
|
-
},
|
|
275
|
-
}),
|
|
276
|
-
renderSnapshots: (options) => this.request({
|
|
277
|
-
method: "POST",
|
|
278
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/preview-frames`,
|
|
279
|
-
query: undefined,
|
|
280
|
-
body: {
|
|
281
|
-
times_seconds: options.atSeconds,
|
|
282
|
-
target_width: options.targetWidth,
|
|
283
|
-
image_format: options.imageFormat,
|
|
284
|
-
},
|
|
285
|
-
}),
|
|
286
|
-
};
|
|
287
|
-
this.timeline = createTimelineResource({
|
|
288
|
-
request: (options) => this.request(options),
|
|
289
|
-
});
|
|
290
|
-
this.aiEdit = createAiEditResource({
|
|
291
|
-
request: (options) => this.request(options),
|
|
292
|
-
});
|
|
293
|
-
this.effects = {
|
|
294
|
-
zoom: {
|
|
295
|
-
add: (options) => this.request({
|
|
296
|
-
method: "POST",
|
|
297
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/effects/zoom`,
|
|
298
|
-
query: undefined,
|
|
299
|
-
body: {
|
|
300
|
-
timeline_item_id: options.timelineItemId,
|
|
301
|
-
content_item_id: options.contentItemId,
|
|
302
|
-
effect_id: options.effectId,
|
|
303
|
-
name: options.name,
|
|
304
|
-
start_time_seconds: options.startTimeSeconds,
|
|
305
|
-
duration_seconds: options.durationSeconds,
|
|
306
|
-
easing: options.easing,
|
|
307
|
-
layer_index: options.layerIndex,
|
|
308
|
-
order_index: options.orderIndex,
|
|
309
|
-
settings: options.settings,
|
|
310
|
-
},
|
|
311
|
-
}),
|
|
312
|
-
update: (options) => this.request({
|
|
313
|
-
method: "PATCH",
|
|
314
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/effects/zoom/${encodeURIComponent(options.timelineItemId)}`,
|
|
315
|
-
query: undefined,
|
|
316
|
-
body: {
|
|
317
|
-
duration_seconds: options.durationSeconds,
|
|
318
|
-
easing: options.easing,
|
|
319
|
-
settings: options.settings,
|
|
320
|
-
},
|
|
321
|
-
}),
|
|
322
|
-
},
|
|
323
|
-
mask: {
|
|
324
|
-
add: (options) => this.request({
|
|
325
|
-
method: "POST",
|
|
326
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/effects/mask`,
|
|
327
|
-
query: undefined,
|
|
328
|
-
body: {
|
|
329
|
-
timeline_item_id: options.timelineItemId,
|
|
330
|
-
content_item_id: options.contentItemId,
|
|
331
|
-
effect_id: options.effectId,
|
|
332
|
-
name: options.name,
|
|
333
|
-
start_time_seconds: options.startTimeSeconds,
|
|
334
|
-
duration_seconds: options.durationSeconds,
|
|
335
|
-
easing: options.easing,
|
|
336
|
-
layer_index: options.layerIndex,
|
|
337
|
-
order_index: options.orderIndex,
|
|
338
|
-
settings: options.settings,
|
|
339
|
-
},
|
|
340
|
-
}),
|
|
341
|
-
update: (options) => this.request({
|
|
342
|
-
method: "PATCH",
|
|
343
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/effects/mask/${encodeURIComponent(options.timelineItemId)}`,
|
|
344
|
-
query: undefined,
|
|
345
|
-
body: {
|
|
346
|
-
duration_seconds: options.durationSeconds,
|
|
347
|
-
easing: options.easing,
|
|
348
|
-
settings: options.settings,
|
|
349
|
-
},
|
|
350
|
-
}),
|
|
351
|
-
},
|
|
352
|
-
colorgrade: {
|
|
353
|
-
add: (options) => this.request({
|
|
354
|
-
method: "POST",
|
|
355
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/effects/colorgrade`,
|
|
356
|
-
query: undefined,
|
|
357
|
-
body: {
|
|
358
|
-
timeline_item_id: options.timelineItemId,
|
|
359
|
-
content_item_id: options.contentItemId,
|
|
360
|
-
effect_id: options.effectId,
|
|
361
|
-
name: options.name,
|
|
362
|
-
start_time_seconds: options.startTimeSeconds,
|
|
363
|
-
duration_seconds: options.durationSeconds,
|
|
364
|
-
easing: options.easing,
|
|
365
|
-
layer_index: options.layerIndex,
|
|
366
|
-
order_index: options.orderIndex,
|
|
367
|
-
settings: options.settings,
|
|
368
|
-
},
|
|
369
|
-
}),
|
|
370
|
-
update: (options) => this.request({
|
|
371
|
-
method: "PATCH",
|
|
372
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/effects/colorgrade/${encodeURIComponent(options.timelineItemId)}`,
|
|
373
|
-
query: undefined,
|
|
374
|
-
body: {
|
|
375
|
-
duration_seconds: options.durationSeconds,
|
|
376
|
-
easing: options.easing,
|
|
377
|
-
settings: options.settings,
|
|
378
|
-
},
|
|
379
|
-
}),
|
|
380
|
-
},
|
|
381
|
-
};
|
|
382
|
-
this.workspace = {
|
|
383
|
-
getSettings: () => this.request({
|
|
384
|
-
method: "GET",
|
|
385
|
-
path: "/workspace/settings",
|
|
386
|
-
query: undefined,
|
|
387
|
-
body: undefined,
|
|
388
|
-
}),
|
|
389
|
-
updateSettings: (options) => this.request({
|
|
390
|
-
method: "PATCH",
|
|
391
|
-
path: "/workspace/settings",
|
|
392
|
-
query: undefined,
|
|
393
|
-
body: {
|
|
394
|
-
name: options.name,
|
|
395
|
-
description: options.description,
|
|
396
|
-
protected_words: options.protectedWords,
|
|
397
|
-
icon_storage_key: options.iconStorageKey,
|
|
398
|
-
defaults: options.defaults === undefined
|
|
399
|
-
? undefined
|
|
400
|
-
: {
|
|
401
|
-
aspect_ratio: options.defaults.aspectRatio,
|
|
402
|
-
orientation: options.defaults.orientation,
|
|
403
|
-
resolution: options.defaults.resolution,
|
|
404
|
-
frame_rate: options.defaults.frameRate,
|
|
405
|
-
auto_manage_broll: options.defaults.autoManageBroll,
|
|
406
|
-
caption_theme_id: options.defaults.captionThemeId,
|
|
407
|
-
},
|
|
408
|
-
},
|
|
409
|
-
}),
|
|
410
|
-
};
|
|
411
|
-
this.media = {
|
|
412
|
-
list: (options) => this.request({
|
|
413
|
-
method: "GET",
|
|
414
|
-
path: "/workspace/media/assets",
|
|
415
|
-
query: {
|
|
416
|
-
folder_id: options.folderId,
|
|
417
|
-
asset_type: options.assetType,
|
|
418
|
-
search: options.search,
|
|
419
|
-
limit: options.limit,
|
|
420
|
-
offset: options.offset,
|
|
421
|
-
},
|
|
422
|
-
body: undefined,
|
|
423
|
-
}),
|
|
424
|
-
get: (options) => this.request({
|
|
425
|
-
method: "GET",
|
|
426
|
-
path: `/workspace/media/assets/${encodeURIComponent(options.assetId)}`,
|
|
427
|
-
query: undefined,
|
|
428
|
-
body: undefined,
|
|
429
|
-
}),
|
|
430
|
-
clippingStatus: (options) => this.request({
|
|
431
|
-
method: "GET",
|
|
432
|
-
path: `/workspace/media/assets/${encodeURIComponent(options.assetId)}/clipping-status`,
|
|
433
|
-
query: { project_id: options.projectId },
|
|
434
|
-
body: undefined,
|
|
435
|
-
}),
|
|
436
|
-
delete: (options) => this.request({
|
|
437
|
-
method: "POST",
|
|
438
|
-
path: `/workspace/media/assets/${encodeURIComponent(options.assetId)}/delete`,
|
|
439
|
-
query: undefined,
|
|
440
|
-
body: {},
|
|
441
|
-
}),
|
|
442
|
-
initUpload: (options) => this.request({
|
|
443
|
-
method: "POST",
|
|
444
|
-
path: "/workspace/media/upload/init",
|
|
445
|
-
query: undefined,
|
|
446
|
-
body: {
|
|
447
|
-
file_name: options.fileName,
|
|
448
|
-
content_type: options.contentType,
|
|
449
|
-
},
|
|
450
|
-
}),
|
|
451
|
-
finalizeUpload: (options) => this.request({
|
|
452
|
-
method: "POST",
|
|
453
|
-
path: "/workspace/media/upload/finalize",
|
|
454
|
-
query: undefined,
|
|
455
|
-
body: {
|
|
456
|
-
storage_key: options.storageKey,
|
|
457
|
-
file_name: options.fileName,
|
|
458
|
-
content_type: options.contentType,
|
|
459
|
-
file_size_bytes: options.fileSizeBytes,
|
|
460
|
-
auto_process_enabled: options.autoProcessEnabled,
|
|
461
|
-
auto_transcribe: options.autoTranscribe,
|
|
462
|
-
auto_describe_after_transcribe: options.autoDescribeAfterTranscribe,
|
|
463
|
-
auto_suggest_shorts: options.autoSuggestShorts,
|
|
464
|
-
},
|
|
465
|
-
}),
|
|
466
|
-
importYoutube: (options) => this.request({
|
|
467
|
-
method: "POST",
|
|
468
|
-
path: "/workspace/media/import/youtube",
|
|
469
|
-
query: undefined,
|
|
470
|
-
body: {
|
|
471
|
-
url: options.url,
|
|
472
|
-
folder_id: options.folderId,
|
|
473
|
-
quality: options.quality,
|
|
474
|
-
fps: options.fps,
|
|
475
|
-
audio_language: options.audioLanguage,
|
|
476
|
-
},
|
|
477
|
-
}),
|
|
478
|
-
update: (options) => this.request({
|
|
479
|
-
method: "PATCH",
|
|
480
|
-
path: `/workspace/media/assets/${encodeURIComponent(options.assetId)}`,
|
|
481
|
-
query: undefined,
|
|
482
|
-
body: {
|
|
483
|
-
name: options.name,
|
|
484
|
-
description: options.description,
|
|
485
|
-
folder_id: options.folderId,
|
|
486
|
-
allow_using_as_broll: options.allowUsingAsBroll,
|
|
487
|
-
},
|
|
488
|
-
}),
|
|
489
|
-
move: (options) => this.request({
|
|
490
|
-
method: "POST",
|
|
491
|
-
path: "/workspace/media/assets/move",
|
|
492
|
-
query: undefined,
|
|
493
|
-
body: {
|
|
494
|
-
asset_ids: options.assetIds,
|
|
495
|
-
target_folder_id: options.targetFolderId,
|
|
496
|
-
},
|
|
497
|
-
}),
|
|
498
|
-
attachToProject: (options) => this.request({
|
|
499
|
-
method: "POST",
|
|
500
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/timeline/media`,
|
|
501
|
-
query: undefined,
|
|
502
|
-
body: {
|
|
503
|
-
items: [
|
|
504
|
-
{
|
|
505
|
-
asset_id: options.assetId,
|
|
506
|
-
start_seconds: options.startSeconds ?? 0,
|
|
507
|
-
duration_seconds: options.durationSeconds,
|
|
508
|
-
position_preset: normalizeMediaPositionPreset({
|
|
509
|
-
value: options.positionPreset,
|
|
510
|
-
}),
|
|
511
|
-
position_x: options.positionX,
|
|
512
|
-
position_y: options.positionY,
|
|
513
|
-
width_px: options.widthPx,
|
|
514
|
-
height_px: options.heightPx,
|
|
515
|
-
keep_aspect_ratio: options.keepAspectRatio,
|
|
516
|
-
scale: options.scale,
|
|
517
|
-
opacity: options.opacity,
|
|
518
|
-
animation_preset: normalizeMediaAnimationPreset({
|
|
519
|
-
value: options.animationPreset,
|
|
520
|
-
}),
|
|
521
|
-
layer_index: options.layerIndex,
|
|
522
|
-
},
|
|
523
|
-
],
|
|
524
|
-
allow_duplicate: options.allowDuplicate,
|
|
525
|
-
},
|
|
526
|
-
}),
|
|
527
|
-
updateOverlay: (options) => this.request({
|
|
528
|
-
method: "PATCH",
|
|
529
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/timeline/media/${encodeURIComponent(options.timelineItemId)}`,
|
|
530
|
-
query: undefined,
|
|
531
|
-
body: {
|
|
532
|
-
position_preset: normalizeMediaPositionPreset({
|
|
533
|
-
value: options.positionPreset,
|
|
534
|
-
}),
|
|
535
|
-
position_x: options.positionX,
|
|
536
|
-
position_y: options.positionY,
|
|
537
|
-
width_px: options.widthPx,
|
|
538
|
-
height_px: options.heightPx,
|
|
539
|
-
keep_aspect_ratio: options.keepAspectRatio,
|
|
540
|
-
scale: options.scale,
|
|
541
|
-
opacity: options.opacity,
|
|
542
|
-
animation_preset: normalizeMediaAnimationPreset({
|
|
543
|
-
value: options.animationPreset,
|
|
544
|
-
}),
|
|
545
|
-
remove_animations: options.removeAnimations,
|
|
546
|
-
blurred_background: options.blurredBackground,
|
|
547
|
-
},
|
|
548
|
-
}),
|
|
549
|
-
shorts: {
|
|
550
|
-
list: (options) => this.request({
|
|
551
|
-
method: "GET",
|
|
552
|
-
path: `/workspace/media/assets/${encodeURIComponent(options.assetId)}/short-suggestions`,
|
|
553
|
-
query: undefined,
|
|
554
|
-
body: undefined,
|
|
555
|
-
}),
|
|
556
|
-
generate: (options) => this.request({
|
|
557
|
-
method: "POST",
|
|
558
|
-
path: `/workspace/media/assets/${encodeURIComponent(options.assetId)}/short-suggestions`,
|
|
559
|
-
query: undefined,
|
|
560
|
-
body: {
|
|
561
|
-
content_profile: options.contentProfile,
|
|
562
|
-
auto_trim_silence: options.autoTrimSilence,
|
|
563
|
-
},
|
|
564
|
-
}),
|
|
565
|
-
apply: (options) => this.request({
|
|
566
|
-
method: "POST",
|
|
567
|
-
path: `/workspace/media/assets/${encodeURIComponent(options.assetId)}/short-suggestions/${encodeURIComponent(options.suggestionId)}/apply`,
|
|
568
|
-
query: undefined,
|
|
569
|
-
body: {
|
|
570
|
-
project_id: options.projectId,
|
|
571
|
-
caption_style_id: options.captionStyleId,
|
|
572
|
-
mark_saved: options.markSaved,
|
|
573
|
-
allow_unverified_export: options.allowUnverifiedExport,
|
|
574
|
-
automatic_layout: options.automaticLayout,
|
|
575
|
-
},
|
|
576
|
-
}),
|
|
577
|
-
},
|
|
578
|
-
folders: {
|
|
579
|
-
list: (options) => this.request({
|
|
580
|
-
method: "GET",
|
|
581
|
-
path: "/workspace/media/folders",
|
|
582
|
-
query: { parent_folder_id: options.parentFolderId },
|
|
583
|
-
body: undefined,
|
|
584
|
-
}),
|
|
585
|
-
create: (options) => this.request({
|
|
586
|
-
method: "POST",
|
|
587
|
-
path: "/workspace/media/folders",
|
|
588
|
-
query: undefined,
|
|
589
|
-
body: {
|
|
590
|
-
name: options.name,
|
|
591
|
-
parent_folder_id: options.parentFolderId,
|
|
592
|
-
description: options.description,
|
|
593
|
-
icon_type: options.iconType,
|
|
594
|
-
},
|
|
595
|
-
}),
|
|
596
|
-
update: (options) => this.request({
|
|
597
|
-
method: "PATCH",
|
|
598
|
-
path: `/workspace/media/folders/${encodeURIComponent(options.folderId)}`,
|
|
599
|
-
query: undefined,
|
|
600
|
-
body: {
|
|
601
|
-
name: options.name,
|
|
602
|
-
parent_folder_id: options.parentFolderId,
|
|
603
|
-
description: options.description,
|
|
604
|
-
icon_type: options.iconType,
|
|
605
|
-
},
|
|
606
|
-
}),
|
|
607
|
-
delete: (options) => this.request({
|
|
608
|
-
method: "DELETE",
|
|
609
|
-
path: `/workspace/media/folders/${encodeURIComponent(options.folderId)}`,
|
|
610
|
-
query: { cascade: options.cascade },
|
|
611
|
-
body: undefined,
|
|
612
|
-
}),
|
|
613
|
-
},
|
|
614
|
-
};
|
|
615
|
-
this.clips = {
|
|
616
|
-
create: (options) => this.request({
|
|
617
|
-
method: "POST",
|
|
618
|
-
path: "/clips",
|
|
619
|
-
query: undefined,
|
|
620
|
-
body: {
|
|
621
|
-
project_name: options.projectName,
|
|
622
|
-
source: {
|
|
623
|
-
source_type: options.source.sourceType,
|
|
624
|
-
asset_id: options.source.assetId,
|
|
625
|
-
youtube_url: options.source.youtubeUrl,
|
|
626
|
-
},
|
|
627
|
-
selection: {
|
|
628
|
-
selection_mode: options.selection.mode,
|
|
629
|
-
suggestion_id: options.selection.suggestionId,
|
|
630
|
-
start_seconds: options.selection.startSeconds,
|
|
631
|
-
end_seconds: options.selection.endSeconds,
|
|
632
|
-
},
|
|
633
|
-
target: {
|
|
634
|
-
aspect_ratio: options.target.aspectRatio,
|
|
635
|
-
min_duration_seconds: options.target.minDurationSeconds,
|
|
636
|
-
max_duration_seconds: options.target.maxDurationSeconds,
|
|
637
|
-
},
|
|
638
|
-
layout: {
|
|
639
|
-
layout_mode: options.layout.mode,
|
|
640
|
-
content_type_hint: options.layout.contentTypeHint,
|
|
641
|
-
},
|
|
642
|
-
captions: {
|
|
643
|
-
enabled: options.captions.enabled,
|
|
644
|
-
style_id: options.captions.styleId,
|
|
645
|
-
},
|
|
646
|
-
qa: {
|
|
647
|
-
qa_mode: options.qa.mode,
|
|
648
|
-
},
|
|
649
|
-
export: {
|
|
650
|
-
auto_export: options.export.autoExport,
|
|
651
|
-
},
|
|
652
|
-
},
|
|
653
|
-
}),
|
|
654
|
-
get: (options) => this.request({
|
|
655
|
-
method: "GET",
|
|
656
|
-
path: `/clips/${encodeURIComponent(options.clipId)}`,
|
|
657
|
-
query: undefined,
|
|
658
|
-
body: undefined,
|
|
659
|
-
}),
|
|
660
|
-
reselect: (options) => this.request({
|
|
661
|
-
method: "POST",
|
|
662
|
-
path: `/clips/${encodeURIComponent(options.clipId)}/reselect`,
|
|
663
|
-
query: undefined,
|
|
664
|
-
body: {
|
|
665
|
-
selection: {
|
|
666
|
-
selection_mode: options.selection.mode,
|
|
667
|
-
suggestion_id: options.selection.suggestionId,
|
|
668
|
-
start_seconds: options.selection.startSeconds,
|
|
669
|
-
end_seconds: options.selection.endSeconds,
|
|
670
|
-
},
|
|
671
|
-
target: options.target === null || options.target === undefined
|
|
672
|
-
? null
|
|
673
|
-
: {
|
|
674
|
-
min_duration_seconds: options.target.minDurationSeconds,
|
|
675
|
-
max_duration_seconds: options.target.maxDurationSeconds,
|
|
676
|
-
},
|
|
677
|
-
},
|
|
678
|
-
}),
|
|
679
|
-
repair: (options) => this.request({
|
|
680
|
-
method: "POST",
|
|
681
|
-
path: `/clips/${encodeURIComponent(options.clipId)}/repair`,
|
|
682
|
-
query: undefined,
|
|
683
|
-
body: {
|
|
684
|
-
repair_mode: options.repairMode,
|
|
685
|
-
},
|
|
686
|
-
}),
|
|
687
|
-
export: (options) => this.request({
|
|
688
|
-
method: "POST",
|
|
689
|
-
path: `/clips/${encodeURIComponent(options.clipId)}/export`,
|
|
690
|
-
query: undefined,
|
|
691
|
-
body: {
|
|
692
|
-
resolution: options.resolution,
|
|
693
|
-
format: options.format,
|
|
694
|
-
allow_blocking_qa_bypass: options.allowBlockingQaBypass,
|
|
695
|
-
},
|
|
696
|
-
}),
|
|
697
|
-
};
|
|
698
|
-
this.text = {
|
|
699
|
-
add: (options) => this.request({
|
|
700
|
-
method: "POST",
|
|
701
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/content-items`,
|
|
702
|
-
query: undefined,
|
|
703
|
-
body: {
|
|
704
|
-
kind: "overlay",
|
|
705
|
-
text: options.text,
|
|
706
|
-
name: options.name,
|
|
707
|
-
spec: options.spec,
|
|
708
|
-
start_seconds: options.startSeconds,
|
|
709
|
-
duration_seconds: options.durationSeconds,
|
|
710
|
-
layer_index: options.layerIndex,
|
|
711
|
-
},
|
|
712
|
-
}),
|
|
713
|
-
list: (options) => this.request({
|
|
714
|
-
method: "GET",
|
|
715
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/content-items`,
|
|
716
|
-
query: undefined,
|
|
717
|
-
body: undefined,
|
|
718
|
-
}),
|
|
719
|
-
update: (options) => this.updateTextContentItem({
|
|
720
|
-
projectId: options.projectId,
|
|
721
|
-
contentItemId: options.contentItemId,
|
|
722
|
-
text: options.text,
|
|
723
|
-
name: options.name,
|
|
724
|
-
spec: options.spec,
|
|
725
|
-
durationSeconds: options.durationSeconds,
|
|
726
|
-
}),
|
|
727
|
-
remove: (options) => this.request({
|
|
728
|
-
method: "DELETE",
|
|
729
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/content-items/${encodeURIComponent(options.contentItemId)}`,
|
|
730
|
-
query: undefined,
|
|
731
|
-
body: undefined,
|
|
732
|
-
}),
|
|
733
|
-
};
|
|
734
|
-
this.audio = {
|
|
735
|
-
add: (options) => this.request({
|
|
736
|
-
method: "POST",
|
|
737
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/timeline/audio`,
|
|
738
|
-
query: undefined,
|
|
739
|
-
body: {
|
|
740
|
-
items: [
|
|
741
|
-
{
|
|
742
|
-
asset_id: options.assetId,
|
|
743
|
-
start_seconds: options.startSeconds,
|
|
744
|
-
duration_seconds: options.durationSeconds,
|
|
745
|
-
volume: options.volume,
|
|
746
|
-
fade_in_seconds: options.fadeInSeconds,
|
|
747
|
-
fade_out_seconds: options.fadeOutSeconds,
|
|
748
|
-
loop: options.loop,
|
|
749
|
-
},
|
|
750
|
-
],
|
|
751
|
-
},
|
|
752
|
-
}),
|
|
753
|
-
update: (options) => this.request({
|
|
754
|
-
method: "PATCH",
|
|
755
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/timeline/audio/${encodeURIComponent(options.timelineItemId)}`,
|
|
756
|
-
query: undefined,
|
|
757
|
-
body: {
|
|
758
|
-
duration_seconds: options.durationSeconds,
|
|
759
|
-
volume: options.volume,
|
|
760
|
-
fade_in_seconds: options.fadeInSeconds,
|
|
761
|
-
fade_out_seconds: options.fadeOutSeconds,
|
|
762
|
-
},
|
|
763
|
-
}),
|
|
764
|
-
};
|
|
765
|
-
this.audioLibrary = {
|
|
766
|
-
search: (options) => this.request({
|
|
767
|
-
method: "GET",
|
|
768
|
-
path: "/audio-library/search",
|
|
769
|
-
query: {
|
|
770
|
-
query: options.query,
|
|
771
|
-
provider: options.provider,
|
|
772
|
-
license: options.license,
|
|
773
|
-
audio_type: options.audioType,
|
|
774
|
-
min_duration_seconds: options.minDurationSeconds,
|
|
775
|
-
max_duration_seconds: options.maxDurationSeconds,
|
|
776
|
-
limit: options.limit,
|
|
777
|
-
page: options.page,
|
|
778
|
-
},
|
|
779
|
-
body: undefined,
|
|
780
|
-
}),
|
|
781
|
-
importAsset: (options) => this.request({
|
|
782
|
-
method: "POST",
|
|
783
|
-
path: "/audio-library/import",
|
|
784
|
-
query: undefined,
|
|
785
|
-
body: {
|
|
786
|
-
provider: options.provider,
|
|
787
|
-
external_id: options.externalId,
|
|
788
|
-
folder_id: options.folderId,
|
|
789
|
-
project_id: options.projectId,
|
|
790
|
-
start_seconds: options.startSeconds,
|
|
791
|
-
duration_seconds: options.durationSeconds,
|
|
792
|
-
volume: options.volume,
|
|
793
|
-
fade_in_seconds: options.fadeInSeconds,
|
|
794
|
-
fade_out_seconds: options.fadeOutSeconds,
|
|
795
|
-
loop: options.loop,
|
|
796
|
-
audio_type: options.audioType,
|
|
797
|
-
},
|
|
798
|
-
}),
|
|
799
|
-
};
|
|
800
|
-
this.stockMedia = {
|
|
801
|
-
search: (options) => this.request({
|
|
802
|
-
method: "GET",
|
|
803
|
-
path: "/workspace/stock-media/search",
|
|
804
|
-
query: {
|
|
805
|
-
query: options.query,
|
|
806
|
-
asset_type: options.assetType,
|
|
807
|
-
provider: options.provider,
|
|
808
|
-
orientation: options.orientation,
|
|
809
|
-
page: options.page,
|
|
810
|
-
limit: options.limit,
|
|
811
|
-
},
|
|
812
|
-
body: undefined,
|
|
813
|
-
}),
|
|
814
|
-
importAsset: (options) => this.request({
|
|
815
|
-
method: "POST",
|
|
816
|
-
path: "/workspace/stock-media/import",
|
|
817
|
-
query: undefined,
|
|
818
|
-
body: {
|
|
819
|
-
provider: options.provider,
|
|
820
|
-
provider_asset_id: options.providerAssetId,
|
|
821
|
-
asset_type: options.assetType,
|
|
822
|
-
variant_id: options.variantId,
|
|
823
|
-
folder_id: options.folderId,
|
|
824
|
-
audio_type: options.audioType,
|
|
825
|
-
},
|
|
826
|
-
}),
|
|
827
|
-
};
|
|
828
|
-
this.library = {
|
|
829
|
-
search: (options) => this.request({
|
|
830
|
-
method: "GET",
|
|
831
|
-
path: "/library/broll/search",
|
|
832
|
-
query: {
|
|
833
|
-
query: options.query,
|
|
834
|
-
asset_type: options.assetType,
|
|
835
|
-
audio_type: options.audioType,
|
|
836
|
-
limit: options.limit,
|
|
837
|
-
offset: options.offset,
|
|
838
|
-
},
|
|
839
|
-
body: undefined,
|
|
840
|
-
}),
|
|
841
|
-
importAsset: (options) => this.request({
|
|
842
|
-
method: "POST",
|
|
843
|
-
path: `/library/broll/${encodeURIComponent(options.libraryAssetId)}/import`,
|
|
844
|
-
query: undefined,
|
|
845
|
-
body: {
|
|
846
|
-
folder_id: options.folderId,
|
|
847
|
-
},
|
|
848
|
-
}),
|
|
849
|
-
};
|
|
850
|
-
this.silence = {
|
|
851
|
-
plan: (options) => this.request({
|
|
852
|
-
method: "POST",
|
|
853
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/silence/plan`,
|
|
854
|
-
query: undefined,
|
|
855
|
-
body: {
|
|
856
|
-
timeline_item_id: options.timelineItemId,
|
|
857
|
-
all_media_items: options.allMediaItems,
|
|
858
|
-
strategy: options.strategy,
|
|
859
|
-
padding_ms: options.paddingMs,
|
|
860
|
-
silence_threshold_db: options.silenceThresholdDb,
|
|
861
|
-
min_silence_duration_seconds: options.minSilenceDurationSeconds,
|
|
862
|
-
remove_blips_max_duration_seconds: options.removeBlipsMaxDurationSeconds,
|
|
863
|
-
use_caption_validation: options.useCaptionValidation,
|
|
864
|
-
},
|
|
865
|
-
}),
|
|
866
|
-
apply: (options) => this.request({
|
|
867
|
-
method: "POST",
|
|
868
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/silence/apply`,
|
|
869
|
-
query: undefined,
|
|
870
|
-
body: {
|
|
871
|
-
timeline_item_id: options.timelineItemId,
|
|
872
|
-
all_media_items: options.allMediaItems,
|
|
873
|
-
padding_ms: options.paddingMs,
|
|
874
|
-
silence_threshold_db: options.silenceThresholdDb,
|
|
875
|
-
min_silence_duration_seconds: options.minSilenceDurationSeconds,
|
|
876
|
-
remove_blips_max_duration_seconds: options.removeBlipsMaxDurationSeconds,
|
|
877
|
-
use_caption_validation: options.useCaptionValidation,
|
|
878
|
-
delete_silent_clips: options.deleteSilentClips,
|
|
879
|
-
manual_segment_overrides: options.manualSegmentOverrides,
|
|
880
|
-
segments: options.segments?.map((segment) => ({
|
|
881
|
-
timeline_item_id: segment.timelineItemId,
|
|
882
|
-
start_seconds: segment.startSeconds,
|
|
883
|
-
end_seconds: segment.endSeconds,
|
|
884
|
-
})),
|
|
885
|
-
preview_confirmed: options.previewConfirmed,
|
|
886
|
-
},
|
|
887
|
-
}),
|
|
888
|
-
};
|
|
889
|
-
this.mistakes = {
|
|
890
|
-
plan: (options) => this.request({
|
|
891
|
-
method: "POST",
|
|
892
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/mistakes/plan`,
|
|
893
|
-
query: undefined,
|
|
894
|
-
body: {
|
|
895
|
-
timeline_item_id: options.timelineItemId,
|
|
896
|
-
},
|
|
897
|
-
}),
|
|
898
|
-
apply: (options) => this.request({
|
|
899
|
-
method: "POST",
|
|
900
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/mistakes/apply`,
|
|
901
|
-
query: undefined,
|
|
902
|
-
body: {
|
|
903
|
-
timeline_item_id: options.timelineItemId,
|
|
904
|
-
plan: options.plan,
|
|
905
|
-
manual_verdicts: options.manualVerdicts,
|
|
906
|
-
delete_mistakes: options.deleteMistakes,
|
|
907
|
-
preview_confirmed: options.previewConfirmed,
|
|
908
|
-
},
|
|
909
|
-
}),
|
|
910
|
-
};
|
|
911
|
-
this.captions = createCaptionsResource({
|
|
912
|
-
request: (options) => this.request(options),
|
|
913
|
-
});
|
|
914
|
-
this.exports = {
|
|
915
|
-
start: (options) => this.request({
|
|
916
|
-
method: "POST",
|
|
917
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/export`,
|
|
918
|
-
query: undefined,
|
|
919
|
-
body: {
|
|
920
|
-
resolution: options.resolution,
|
|
921
|
-
format: options.format,
|
|
922
|
-
cover_frame_seconds: options.coverFrameSeconds,
|
|
923
|
-
},
|
|
924
|
-
}),
|
|
925
|
-
get: (options) => this.request({
|
|
926
|
-
method: "GET",
|
|
927
|
-
path: `/exports/${encodeURIComponent(options.exportId)}`,
|
|
928
|
-
query: undefined,
|
|
929
|
-
body: undefined,
|
|
930
|
-
}),
|
|
931
|
-
wait: (options) => this.waitForExport(options),
|
|
932
|
-
download: (options) => this.downloadExport(options),
|
|
933
|
-
};
|
|
934
|
-
this.jobs = {
|
|
935
|
-
get: (options) => this.request({
|
|
936
|
-
method: "GET",
|
|
937
|
-
path: `/jobs/${encodeURIComponent(options.jobId)}`,
|
|
938
|
-
query: undefined,
|
|
939
|
-
body: undefined,
|
|
940
|
-
}),
|
|
941
|
-
};
|
|
942
|
-
}
|
|
943
|
-
async request(options) {
|
|
944
|
-
const url = new URL(`${this.baseUrl}${options.path}`);
|
|
945
|
-
appendQuery({ url, query: options.query });
|
|
946
|
-
const headers = {
|
|
947
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
948
|
-
Accept: "application/json",
|
|
949
|
-
"X-BlitzReels-Client": this.userAgent,
|
|
950
|
-
};
|
|
951
|
-
let body;
|
|
952
|
-
if (options.body !== undefined) {
|
|
953
|
-
headers["Content-Type"] = "application/json";
|
|
954
|
-
body = JSON.stringify(options.body);
|
|
955
|
-
}
|
|
956
|
-
const response = await this.fetchFn(url, {
|
|
957
|
-
method: options.method,
|
|
958
|
-
headers,
|
|
959
|
-
body,
|
|
960
|
-
});
|
|
961
|
-
const requestId = response.headers.get("x-request-id") ??
|
|
962
|
-
response.headers.get("x-vercel-id") ??
|
|
963
|
-
null;
|
|
964
|
-
const text = await response.text();
|
|
965
|
-
const parsed = text.length > 0 ? parseJson({ text }) : null;
|
|
966
|
-
if (!response.ok) {
|
|
967
|
-
throw new BlitzReelsError({
|
|
968
|
-
message: extractErrorMessage({ body: parsed }) ??
|
|
969
|
-
`BlitzReels API request failed with ${response.status}`,
|
|
970
|
-
status: response.status,
|
|
971
|
-
requestId,
|
|
972
|
-
body: parsed,
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
return parsed;
|
|
976
|
-
}
|
|
977
|
-
async waitForExport(options) {
|
|
978
|
-
const startedAt = Date.now();
|
|
979
|
-
while (Date.now() - startedAt <= options.timeoutMs) {
|
|
980
|
-
const status = await this.exports.get({ exportId: options.exportId });
|
|
981
|
-
if (status.status === "completed") {
|
|
982
|
-
return status;
|
|
983
|
-
}
|
|
984
|
-
if (status.status === "failed" || status.status === "canceled") {
|
|
985
|
-
throw new BlitzReelsError({
|
|
986
|
-
message: `Export ${options.exportId} ended with status ${status.status}`,
|
|
987
|
-
status: 422,
|
|
988
|
-
requestId: null,
|
|
989
|
-
body: status,
|
|
990
|
-
});
|
|
991
|
-
}
|
|
992
|
-
await sleep({ ms: options.intervalMs });
|
|
993
|
-
}
|
|
994
|
-
throw new BlitzReelsError({
|
|
995
|
-
message: `Timed out waiting for export ${options.exportId}`,
|
|
996
|
-
status: 408,
|
|
997
|
-
requestId: null,
|
|
998
|
-
body: { export_id: options.exportId },
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
async updateTextContentItem(options) {
|
|
1002
|
-
let spec = options.spec;
|
|
1003
|
-
if (options.text !== undefined) {
|
|
1004
|
-
if (spec === undefined) {
|
|
1005
|
-
const items = await this.text.list({ projectId: options.projectId });
|
|
1006
|
-
const item = items.data.find((candidate) => candidate.content_item_id === options.contentItemId);
|
|
1007
|
-
if (!item?.spec) {
|
|
1008
|
-
throw new BlitzReelsError({
|
|
1009
|
-
message: `Content item ${options.contentItemId} has no editable text spec.`,
|
|
1010
|
-
status: 422,
|
|
1011
|
-
requestId: null,
|
|
1012
|
-
body: item ?? null,
|
|
1013
|
-
});
|
|
1014
|
-
}
|
|
1015
|
-
spec = item.spec;
|
|
1016
|
-
}
|
|
1017
|
-
spec = updateTextSpecContent({ spec, text: options.text });
|
|
1018
|
-
}
|
|
1019
|
-
return this.request({
|
|
1020
|
-
method: "PATCH",
|
|
1021
|
-
path: `/projects/${encodeURIComponent(options.projectId)}/content-items/${encodeURIComponent(options.contentItemId)}`,
|
|
1022
|
-
query: undefined,
|
|
1023
|
-
body: {
|
|
1024
|
-
name: options.name,
|
|
1025
|
-
spec,
|
|
1026
|
-
duration_seconds: options.durationSeconds,
|
|
1027
|
-
},
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
|
-
async downloadExport(options) {
|
|
1031
|
-
const status = await this.exports.get({ exportId: options.exportId });
|
|
1032
|
-
const downloadUrl = status.download_url ?? status.short_download_url;
|
|
1033
|
-
if (downloadUrl === null) {
|
|
1034
|
-
throw new BlitzReelsError({
|
|
1035
|
-
message: `Export ${options.exportId} is not ready for download`,
|
|
1036
|
-
status: 409,
|
|
1037
|
-
requestId: null,
|
|
1038
|
-
body: status,
|
|
1039
|
-
});
|
|
1040
|
-
}
|
|
1041
|
-
const response = await this.fetchFn(downloadUrl);
|
|
1042
|
-
if (!response.ok) {
|
|
1043
|
-
throw new BlitzReelsError({
|
|
1044
|
-
message: `Failed to download export ${options.exportId}`,
|
|
1045
|
-
status: response.status,
|
|
1046
|
-
requestId: response.headers.get("x-request-id"),
|
|
1047
|
-
body: null,
|
|
1048
|
-
});
|
|
1049
|
-
}
|
|
1050
|
-
return response.arrayBuffer();
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
function parseJson({ text }) {
|
|
1054
|
-
try {
|
|
1055
|
-
return JSON.parse(text);
|
|
1056
|
-
}
|
|
1057
|
-
catch {
|
|
1058
|
-
return text;
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1
|
+
export { getBlitzReelsErrorCliExitCode, getBlitzReelsErrorDefaultRetryable, getSequenceOperationDefinition, getSequenceOperationErrorDefinition, isBlitzReelsErrorCode, isSequenceOperationErrorCode, isSequenceOperationId, SEQUENCE_OPERATION_DEFINITIONS, SEQUENCE_OPERATION_ERROR_CODES, SEQUENCE_OPERATION_ERROR_DEFINITIONS, SEQUENCE_OPERATION_IDS, } from "@blitzreels/contracts";
|
|
2
|
+
export { BlitzReelsClient } from "./client.js";
|
|
3
|
+
export { BlitzReelsError } from "./transport.js";
|
|
1061
4
|
//# sourceMappingURL=index.js.map
|