@audialize/sdk 0.1.0 → 1.0.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/README.md +32 -0
- package/dist/index.cjs +807 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +506 -3
- package/dist/index.d.ts +506 -3
- package/dist/index.js +765 -9
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -71,6 +71,7 @@ var HttpClient = class {
|
|
|
71
71
|
baseUrl;
|
|
72
72
|
timeout;
|
|
73
73
|
maxRetries;
|
|
74
|
+
defaultHeaders;
|
|
74
75
|
fetchImpl;
|
|
75
76
|
constructor(options) {
|
|
76
77
|
if (!options.apiKey) {
|
|
@@ -80,12 +81,27 @@ var HttpClient = class {
|
|
|
80
81
|
this.baseUrl = options.baseUrl || "https://api.audialize.com";
|
|
81
82
|
this.timeout = options.timeout || 3e4;
|
|
82
83
|
this.maxRetries = options.maxRetries ?? 3;
|
|
84
|
+
this.defaultHeaders = options.defaultHeaders ?? {};
|
|
83
85
|
this.fetchImpl = options.fetch || globalThis.fetch.bind(globalThis);
|
|
84
86
|
}
|
|
85
87
|
async request(path, options = {}) {
|
|
88
|
+
const response = await this.execute(path, options);
|
|
89
|
+
if (response.status === 204) {
|
|
90
|
+
return {};
|
|
91
|
+
}
|
|
92
|
+
return await response.json();
|
|
93
|
+
}
|
|
94
|
+
async requestRaw(path, options = {}) {
|
|
95
|
+
return this.execute(path, options);
|
|
96
|
+
}
|
|
97
|
+
async execute(path, options = {}) {
|
|
86
98
|
const url = new URL(path, this.baseUrl).toString();
|
|
87
|
-
const headers = new Headers(
|
|
88
|
-
|
|
99
|
+
const headers = new Headers(this.defaultHeaders);
|
|
100
|
+
const requestHeaders = new Headers(options.headers);
|
|
101
|
+
requestHeaders.forEach((value, key) => {
|
|
102
|
+
headers.set(key, value);
|
|
103
|
+
});
|
|
104
|
+
headers.set("x-api-key", this.apiKey);
|
|
89
105
|
if (!headers.has("Content-Type") && options.body && typeof options.body === "string") {
|
|
90
106
|
headers.set("Content-Type", "application/json");
|
|
91
107
|
}
|
|
@@ -101,10 +117,7 @@ var HttpClient = class {
|
|
|
101
117
|
});
|
|
102
118
|
clearTimeout(timeoutId);
|
|
103
119
|
if (response.ok) {
|
|
104
|
-
|
|
105
|
-
return {};
|
|
106
|
-
}
|
|
107
|
-
return await response.json();
|
|
120
|
+
return response;
|
|
108
121
|
}
|
|
109
122
|
await this.handleErrorResponse(response);
|
|
110
123
|
} catch (error) {
|
|
@@ -295,15 +308,152 @@ var JobsResource = class {
|
|
|
295
308
|
constructor(client) {
|
|
296
309
|
this.client = client;
|
|
297
310
|
}
|
|
311
|
+
async start(request) {
|
|
312
|
+
return this.client.request("/jobs/start", {
|
|
313
|
+
method: "POST",
|
|
314
|
+
body: JSON.stringify(request)
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
async create(options) {
|
|
318
|
+
const response = await this.client.request("/jobs", {
|
|
319
|
+
method: "POST",
|
|
320
|
+
body: JSON.stringify({
|
|
321
|
+
fileName: options.fileName,
|
|
322
|
+
languages: options.languages,
|
|
323
|
+
...options.sourceLanguage !== void 0 && { sourceLanguage: options.sourceLanguage }
|
|
324
|
+
})
|
|
325
|
+
});
|
|
326
|
+
const jobId = getStringField(response, "jobId") ?? getStringField(response, "id");
|
|
327
|
+
if (!jobId) {
|
|
328
|
+
throw new AudiolizeValidationError("Create job response did not include a job identifier.");
|
|
329
|
+
}
|
|
330
|
+
const success = getBooleanField(response, "success");
|
|
331
|
+
const message = getStringField(response, "message");
|
|
332
|
+
return {
|
|
333
|
+
jobId,
|
|
334
|
+
...success !== void 0 && { success },
|
|
335
|
+
...message !== void 0 && { message }
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
async updateSubtitles(jobId, payload) {
|
|
339
|
+
return this.client.request(`/jobs/${jobId}/subtitles`, {
|
|
340
|
+
method: "PUT",
|
|
341
|
+
body: JSON.stringify(payload)
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
async updateSubtitlesForLanguage(jobId, language, body, contentType) {
|
|
345
|
+
const response = await this.client.requestRaw(`/jobs/${jobId}/subtitles/${language}`, {
|
|
346
|
+
method: "PUT",
|
|
347
|
+
headers: {
|
|
348
|
+
"Content-Type": contentType
|
|
349
|
+
},
|
|
350
|
+
body
|
|
351
|
+
});
|
|
352
|
+
return {
|
|
353
|
+
body: await response.text(),
|
|
354
|
+
contentType: response.headers.get("content-type") || "application/json",
|
|
355
|
+
statusCode: response.status
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
async getSubtitles(jobId, language) {
|
|
359
|
+
return this.client.request(`/jobs/${jobId}/subtitles/${language}`);
|
|
360
|
+
}
|
|
361
|
+
async getSummary(jobId, language) {
|
|
362
|
+
const query = new URLSearchParams();
|
|
363
|
+
if (language) query.set("language", language);
|
|
364
|
+
const path = `/jobs/${jobId}/summary${query.toString() ? `?${query.toString()}` : ""}`;
|
|
365
|
+
return this.client.request(path);
|
|
366
|
+
}
|
|
367
|
+
async generateSummary(jobId, payload) {
|
|
368
|
+
return this.client.request(`/jobs/${jobId}/summary`, {
|
|
369
|
+
method: "POST",
|
|
370
|
+
body: JSON.stringify(payload)
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
async cleanSubtitles(jobId, payload) {
|
|
374
|
+
return this.client.request(`/jobs/${jobId}/subtitles/clean`, {
|
|
375
|
+
method: "POST",
|
|
376
|
+
body: JSON.stringify(payload)
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
async getThumbnail(jobId) {
|
|
380
|
+
return this.client.request(`/jobs/${jobId}/thumbnail`);
|
|
381
|
+
}
|
|
382
|
+
async getVideo(jobId) {
|
|
383
|
+
return this.client.request(`/jobs/${jobId}/video`);
|
|
384
|
+
}
|
|
385
|
+
async getAudio(jobId, language) {
|
|
386
|
+
return this.client.requestRaw(`/audio/${jobId}/${language}`);
|
|
387
|
+
}
|
|
388
|
+
async updateSpeakerNames(payload) {
|
|
389
|
+
return this.client.request("/jobs/update-speaker-names", {
|
|
390
|
+
method: "POST",
|
|
391
|
+
body: JSON.stringify(payload)
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
async pauseResume(jobId, payload) {
|
|
395
|
+
return this.client.request(`/jobs/${jobId}/pause-resume`, {
|
|
396
|
+
method: "POST",
|
|
397
|
+
body: JSON.stringify(payload)
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
async submitFeedback(jobId, payload) {
|
|
401
|
+
return this.client.request(`/jobs/${jobId}/feedback`, {
|
|
402
|
+
method: "POST",
|
|
403
|
+
body: JSON.stringify(payload)
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
async generateQualityAiInsights(jobId, payload) {
|
|
407
|
+
return this.client.request(`/jobs/${jobId}/quality/ai-insights`, {
|
|
408
|
+
method: "POST",
|
|
409
|
+
body: JSON.stringify(payload)
|
|
410
|
+
});
|
|
411
|
+
}
|
|
298
412
|
async get(jobId) {
|
|
299
413
|
return this.client.request(`/jobs/${jobId}/status`);
|
|
300
414
|
}
|
|
415
|
+
async delete(jobId) {
|
|
416
|
+
return this.client.request(`/jobs/${jobId}`, {
|
|
417
|
+
method: "DELETE"
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
async getCapabilityReadiness(jobId) {
|
|
421
|
+
return this.client.request(`/jobs/${jobId}/capabilities`);
|
|
422
|
+
}
|
|
423
|
+
async listArtifacts(jobId, options = {}) {
|
|
424
|
+
const query = new URLSearchParams();
|
|
425
|
+
if (options.type) query.set("type", options.type);
|
|
426
|
+
if (options.language) query.set("language", options.language);
|
|
427
|
+
if (options.status) query.set("status", options.status);
|
|
428
|
+
const path = `/jobs/${jobId}/artifacts${query.toString() ? `?${query.toString()}` : ""}`;
|
|
429
|
+
return this.client.request(path);
|
|
430
|
+
}
|
|
431
|
+
async startCapabilityRun(jobId, capability, request = {}) {
|
|
432
|
+
return this.client.request(`/jobs/${jobId}/capabilities/${capability}/runs`, {
|
|
433
|
+
method: "POST",
|
|
434
|
+
body: JSON.stringify(request)
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
async listHighlights(jobId) {
|
|
438
|
+
return this.client.request(`/jobs/${jobId}/highlights`);
|
|
439
|
+
}
|
|
440
|
+
async listCommentary(jobId) {
|
|
441
|
+
return this.client.request(`/jobs/${jobId}/commentary`);
|
|
442
|
+
}
|
|
443
|
+
async listExports(jobId, options = {}) {
|
|
444
|
+
const query = new URLSearchParams();
|
|
445
|
+
if (options.status) query.set("status", options.status);
|
|
446
|
+
if (options.packageFormat) query.set("packageFormat", options.packageFormat);
|
|
447
|
+
const path = `/jobs/${jobId}/exports${query.toString() ? `?${query.toString()}` : ""}`;
|
|
448
|
+
return this.client.request(path);
|
|
449
|
+
}
|
|
301
450
|
async list(options) {
|
|
302
451
|
const query = new URLSearchParams();
|
|
303
452
|
if (options?.limit) query.set("limit", options.limit.toString());
|
|
304
453
|
if (options?.pageToken) query.set("pageToken", options.pageToken);
|
|
305
454
|
const path = `/jobs${query.toString() ? `?${query.toString()}` : ""}`;
|
|
306
|
-
|
|
455
|
+
const raw = await this.client.request(path);
|
|
456
|
+
return normalizeJobList(raw);
|
|
307
457
|
}
|
|
308
458
|
/**
|
|
309
459
|
* Polls until the job reaches `completed` or `failed`, then returns the final job.
|
|
@@ -331,6 +481,235 @@ var JobsResource = class {
|
|
|
331
481
|
return new JobPoller(jobId, this, options);
|
|
332
482
|
}
|
|
333
483
|
};
|
|
484
|
+
function getStringField(record, key) {
|
|
485
|
+
const value = record[key];
|
|
486
|
+
return typeof value === "string" ? value : void 0;
|
|
487
|
+
}
|
|
488
|
+
function getBooleanField(record, key) {
|
|
489
|
+
const value = record[key];
|
|
490
|
+
return typeof value === "boolean" ? value : void 0;
|
|
491
|
+
}
|
|
492
|
+
function normalizeJobList(raw) {
|
|
493
|
+
if (!isRecord2(raw)) {
|
|
494
|
+
return { items: [] };
|
|
495
|
+
}
|
|
496
|
+
const explicitItems = raw.items;
|
|
497
|
+
if (Array.isArray(explicitItems)) {
|
|
498
|
+
return {
|
|
499
|
+
items: explicitItems,
|
|
500
|
+
...typeof raw.nextPageToken === "string" ? { nextPageToken: raw.nextPageToken } : {}
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
const jobs = raw.jobs;
|
|
504
|
+
const pagination = isRecord2(raw.pagination) ? raw.pagination : void 0;
|
|
505
|
+
const nextPageToken = typeof raw.nextPageToken === "string" ? raw.nextPageToken : typeof pagination?.nextStartAfter === "string" ? pagination.nextStartAfter : typeof raw.lastEvaluatedKey === "string" ? raw.lastEvaluatedKey : void 0;
|
|
506
|
+
if (Array.isArray(jobs)) {
|
|
507
|
+
return {
|
|
508
|
+
items: jobs,
|
|
509
|
+
...nextPageToken !== void 0 ? { nextPageToken } : {}
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
return { items: [] };
|
|
513
|
+
}
|
|
514
|
+
function isRecord2(value) {
|
|
515
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// src/resources/highlights.ts
|
|
519
|
+
var HighlightsResource = class {
|
|
520
|
+
constructor(client) {
|
|
521
|
+
this.client = client;
|
|
522
|
+
}
|
|
523
|
+
async create(request) {
|
|
524
|
+
return this.client.request("/highlights", {
|
|
525
|
+
method: "POST",
|
|
526
|
+
body: JSON.stringify(request)
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
async list(options = {}) {
|
|
530
|
+
const query = new URLSearchParams();
|
|
531
|
+
if (options.sourceKind) query.set("sourceKind", options.sourceKind);
|
|
532
|
+
if (options.sourceId) query.set("sourceId", options.sourceId);
|
|
533
|
+
if (options.status) query.set("status", options.status);
|
|
534
|
+
const path = `/highlights${query.toString() ? `?${query.toString()}` : ""}`;
|
|
535
|
+
return this.client.request(path);
|
|
536
|
+
}
|
|
537
|
+
async get(runId) {
|
|
538
|
+
return this.client.request(`/highlights/${runId}`);
|
|
539
|
+
}
|
|
540
|
+
async listClips(runId) {
|
|
541
|
+
return this.client.request(`/highlights/${runId}/clips`);
|
|
542
|
+
}
|
|
543
|
+
async getClip(clipId) {
|
|
544
|
+
return this.client.request(`/clips/${clipId}`);
|
|
545
|
+
}
|
|
546
|
+
async createVariant(clipId, request) {
|
|
547
|
+
return this.client.request(`/clips/${clipId}/variants`, {
|
|
548
|
+
method: "POST",
|
|
549
|
+
body: JSON.stringify(request)
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
async approve(clipId, request) {
|
|
553
|
+
return this.client.request(`/clips/${clipId}/approval`, {
|
|
554
|
+
method: "POST",
|
|
555
|
+
body: JSON.stringify(request)
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
async socialExport(clipId) {
|
|
559
|
+
return this.client.request(`/clips/${clipId}/social-export`, {
|
|
560
|
+
method: "POST"
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
// src/resources/liveSessions.ts
|
|
566
|
+
var LiveSessionsResource = class {
|
|
567
|
+
constructor(client) {
|
|
568
|
+
this.client = client;
|
|
569
|
+
}
|
|
570
|
+
async create(request) {
|
|
571
|
+
return this.client.request("/live-sessions", {
|
|
572
|
+
method: "POST",
|
|
573
|
+
body: JSON.stringify(request)
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
async list(options) {
|
|
577
|
+
const query = new URLSearchParams();
|
|
578
|
+
if (options?.limit) query.set("limit", options.limit.toString());
|
|
579
|
+
if (options?.pageToken) query.set("pageToken", options.pageToken);
|
|
580
|
+
if (options?.status) query.set("status", options.status);
|
|
581
|
+
const path = `/live-sessions${query.toString() ? `?${query.toString()}` : ""}`;
|
|
582
|
+
return this.client.request(path);
|
|
583
|
+
}
|
|
584
|
+
async get(sessionId) {
|
|
585
|
+
return this.client.request(`/live-sessions/${sessionId}`);
|
|
586
|
+
}
|
|
587
|
+
async getRollingSubtitles(sessionId) {
|
|
588
|
+
return this.client.request(
|
|
589
|
+
`/live-sessions/${sessionId}/rolling-subtitles`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
async publishRollingSubtitles(sessionId, request) {
|
|
593
|
+
return this.client.request(
|
|
594
|
+
`/live-sessions/${sessionId}/rolling-subtitles`,
|
|
595
|
+
{
|
|
596
|
+
method: "POST",
|
|
597
|
+
body: JSON.stringify(request)
|
|
598
|
+
}
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
async stop(sessionId, request = {}) {
|
|
602
|
+
return this.client.request(`/live-sessions/${sessionId}/stop`, {
|
|
603
|
+
method: "POST",
|
|
604
|
+
body: JSON.stringify(request)
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
// src/resources/commentary.ts
|
|
610
|
+
var CommentaryResource = class {
|
|
611
|
+
constructor(client) {
|
|
612
|
+
this.client = client;
|
|
613
|
+
}
|
|
614
|
+
async create(request) {
|
|
615
|
+
return this.client.request("/commentary", {
|
|
616
|
+
method: "POST",
|
|
617
|
+
body: JSON.stringify(request)
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
async list(options = {}) {
|
|
621
|
+
const query = new URLSearchParams();
|
|
622
|
+
if (options?.limit) query.set("limit", options.limit.toString());
|
|
623
|
+
if (options?.pageToken) query.set("pageToken", options.pageToken);
|
|
624
|
+
if (options?.sourceKind) query.set("sourceKind", options.sourceKind);
|
|
625
|
+
if (options?.sourceId) query.set("sourceId", options.sourceId);
|
|
626
|
+
if (options?.status) query.set("status", options.status);
|
|
627
|
+
const path = `/commentary${query.toString() ? `?${query.toString()}` : ""}`;
|
|
628
|
+
return this.client.request(path);
|
|
629
|
+
}
|
|
630
|
+
async get(runId) {
|
|
631
|
+
return this.client.request(`/commentary/${runId}`);
|
|
632
|
+
}
|
|
633
|
+
async listOutputs(runId) {
|
|
634
|
+
return this.client.request(`/commentary/${runId}/outputs`);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
// src/resources/dubbing.ts
|
|
639
|
+
var DubbingResource = class {
|
|
640
|
+
constructor(client) {
|
|
641
|
+
this.client = client;
|
|
642
|
+
}
|
|
643
|
+
async list(options = {}) {
|
|
644
|
+
const query = new URLSearchParams();
|
|
645
|
+
if (options.sourceId) query.set("sourceId", options.sourceId);
|
|
646
|
+
if (options.status) query.set("status", options.status);
|
|
647
|
+
if (options.limit) query.set("limit", options.limit.toString());
|
|
648
|
+
if (options.pageToken) query.set("pageToken", options.pageToken);
|
|
649
|
+
const path = `/dubbing${query.toString() ? `?${query.toString()}` : ""}`;
|
|
650
|
+
return this.client.request(path);
|
|
651
|
+
}
|
|
652
|
+
async get(runId) {
|
|
653
|
+
return this.client.request(`/dubbing/${runId}`);
|
|
654
|
+
}
|
|
655
|
+
async getForJob(jobId) {
|
|
656
|
+
return this.client.request(`/jobs/${jobId}/dubbing`);
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
// src/resources/artifacts.ts
|
|
661
|
+
var ArtifactsResource = class {
|
|
662
|
+
constructor(client) {
|
|
663
|
+
this.client = client;
|
|
664
|
+
}
|
|
665
|
+
async list(options = {}) {
|
|
666
|
+
const query = new URLSearchParams();
|
|
667
|
+
if (options.limit) query.set("limit", options.limit.toString());
|
|
668
|
+
if (options.pageToken) query.set("pageToken", options.pageToken);
|
|
669
|
+
if (options.ownerKind) query.set("ownerKind", options.ownerKind);
|
|
670
|
+
if (options.ownerId) query.set("ownerId", options.ownerId);
|
|
671
|
+
if (options.type) query.set("type", options.type);
|
|
672
|
+
if (options.language) query.set("language", options.language);
|
|
673
|
+
if (options.status) query.set("status", options.status);
|
|
674
|
+
if (options.releaseStage) query.set("releaseStage", options.releaseStage);
|
|
675
|
+
const path = `/artifacts${query.toString() ? `?${query.toString()}` : ""}`;
|
|
676
|
+
return this.client.request(path);
|
|
677
|
+
}
|
|
678
|
+
async get(artifactId) {
|
|
679
|
+
return this.client.request(`/artifacts/${artifactId}`);
|
|
680
|
+
}
|
|
681
|
+
async createSignedUrl(artifactId) {
|
|
682
|
+
return this.client.request(`/artifacts/${artifactId}/signed-url`, {
|
|
683
|
+
method: "POST"
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
// src/resources/exportPackages.ts
|
|
689
|
+
var ExportPackagesResource = class {
|
|
690
|
+
constructor(client) {
|
|
691
|
+
this.client = client;
|
|
692
|
+
}
|
|
693
|
+
async list(options = {}) {
|
|
694
|
+
const query = new URLSearchParams();
|
|
695
|
+
if (options.limit) query.set("limit", options.limit.toString());
|
|
696
|
+
if (options.pageToken) query.set("pageToken", options.pageToken);
|
|
697
|
+
if (options.ownerKind) query.set("ownerKind", options.ownerKind);
|
|
698
|
+
if (options.ownerId) query.set("ownerId", options.ownerId);
|
|
699
|
+
if (options.status) query.set("status", options.status);
|
|
700
|
+
if (options.packageFormat) query.set("packageFormat", options.packageFormat);
|
|
701
|
+
const path = `/exports${query.toString() ? `?${query.toString()}` : ""}`;
|
|
702
|
+
return this.client.request(path);
|
|
703
|
+
}
|
|
704
|
+
async get(exportPackageId) {
|
|
705
|
+
return this.client.request(`/exports/${exportPackageId}`);
|
|
706
|
+
}
|
|
707
|
+
async createSignedUrl(exportPackageId) {
|
|
708
|
+
return this.client.request(`/exports/${exportPackageId}/signed-url`, {
|
|
709
|
+
method: "POST"
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
};
|
|
334
713
|
|
|
335
714
|
// src/resources/languages.ts
|
|
336
715
|
var LanguagesResource = class {
|
|
@@ -338,9 +717,38 @@ var LanguagesResource = class {
|
|
|
338
717
|
this.client = client;
|
|
339
718
|
}
|
|
340
719
|
async list() {
|
|
341
|
-
|
|
720
|
+
const raw = await this.client.request("/supported-languages");
|
|
721
|
+
return extractLanguages(raw);
|
|
342
722
|
}
|
|
343
723
|
};
|
|
724
|
+
function extractLanguages(raw) {
|
|
725
|
+
if (Array.isArray(raw)) {
|
|
726
|
+
return raw.filter(isLanguage);
|
|
727
|
+
}
|
|
728
|
+
if (!isRecord3(raw)) {
|
|
729
|
+
return [];
|
|
730
|
+
}
|
|
731
|
+
const languages = raw.languages;
|
|
732
|
+
if (Array.isArray(languages)) {
|
|
733
|
+
return languages.filter(isLanguage);
|
|
734
|
+
}
|
|
735
|
+
if (isRecord3(languages)) {
|
|
736
|
+
const merged = [];
|
|
737
|
+
for (const value of Object.values(languages)) {
|
|
738
|
+
if (Array.isArray(value)) {
|
|
739
|
+
merged.push(...value.filter(isLanguage));
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
return merged;
|
|
743
|
+
}
|
|
744
|
+
return [];
|
|
745
|
+
}
|
|
746
|
+
function isLanguage(value) {
|
|
747
|
+
return isRecord3(value) && typeof value.code === "string" && typeof value.name === "string";
|
|
748
|
+
}
|
|
749
|
+
function isRecord3(value) {
|
|
750
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
751
|
+
}
|
|
344
752
|
|
|
345
753
|
// src/resources/subtitles.ts
|
|
346
754
|
var SubtitlesResource = class {
|
|
@@ -467,6 +875,12 @@ var FilesResource = class {
|
|
|
467
875
|
constructor(client) {
|
|
468
876
|
this.client = client;
|
|
469
877
|
}
|
|
878
|
+
async createPresignedUrl(request) {
|
|
879
|
+
return this.client.request("/presigned-url", {
|
|
880
|
+
method: "POST",
|
|
881
|
+
body: JSON.stringify(request)
|
|
882
|
+
});
|
|
883
|
+
}
|
|
470
884
|
async upload(file, options) {
|
|
471
885
|
const response = await this.client.request("/presigned-url", {
|
|
472
886
|
method: "POST",
|
|
@@ -592,6 +1006,12 @@ function getFileSize(file) {
|
|
|
592
1006
|
var AudiolizeClient = class {
|
|
593
1007
|
http;
|
|
594
1008
|
jobs;
|
|
1009
|
+
highlights;
|
|
1010
|
+
liveSessions;
|
|
1011
|
+
commentary;
|
|
1012
|
+
dubbing;
|
|
1013
|
+
artifacts;
|
|
1014
|
+
exportPackages;
|
|
595
1015
|
languages;
|
|
596
1016
|
subtitles;
|
|
597
1017
|
files;
|
|
@@ -605,8 +1025,15 @@ var AudiolizeClient = class {
|
|
|
605
1025
|
};
|
|
606
1026
|
if (options.timeout !== void 0) httpOptions.timeout = options.timeout;
|
|
607
1027
|
if (options.maxRetries !== void 0) httpOptions.maxRetries = options.maxRetries;
|
|
1028
|
+
if (options.defaultHeaders !== void 0) httpOptions.defaultHeaders = options.defaultHeaders;
|
|
608
1029
|
this.http = new HttpClient(httpOptions);
|
|
609
1030
|
this.jobs = new JobsResource(this.http);
|
|
1031
|
+
this.highlights = new HighlightsResource(this.http);
|
|
1032
|
+
this.liveSessions = new LiveSessionsResource(this.http);
|
|
1033
|
+
this.commentary = new CommentaryResource(this.http);
|
|
1034
|
+
this.dubbing = new DubbingResource(this.http);
|
|
1035
|
+
this.artifacts = new ArtifactsResource(this.http);
|
|
1036
|
+
this.exportPackages = new ExportPackagesResource(this.http);
|
|
610
1037
|
this.languages = new LanguagesResource(this.http);
|
|
611
1038
|
this.subtitles = new SubtitlesResource(this.http);
|
|
612
1039
|
this.files = new FilesResource(this.http);
|
|
@@ -621,6 +1048,335 @@ var AudiolizeClient = class {
|
|
|
621
1048
|
}
|
|
622
1049
|
};
|
|
623
1050
|
|
|
624
|
-
|
|
1051
|
+
// src/types/domain.ts
|
|
1052
|
+
var DOMAIN_ENTITY_KINDS = [
|
|
1053
|
+
"job",
|
|
1054
|
+
"live_session",
|
|
1055
|
+
"highlight_run",
|
|
1056
|
+
"dubbing_run",
|
|
1057
|
+
"clip_artifact",
|
|
1058
|
+
"commentary_run",
|
|
1059
|
+
"artifact",
|
|
1060
|
+
"export_package"
|
|
1061
|
+
];
|
|
1062
|
+
var CAPABILITY_READINESS_STATES = [
|
|
1063
|
+
"unavailable",
|
|
1064
|
+
"queued",
|
|
1065
|
+
"processing",
|
|
1066
|
+
"partial",
|
|
1067
|
+
"review_required",
|
|
1068
|
+
"ready",
|
|
1069
|
+
"failed"
|
|
1070
|
+
];
|
|
1071
|
+
var CANONICAL_JOB_STATUSES = [
|
|
1072
|
+
"created",
|
|
1073
|
+
"queued",
|
|
1074
|
+
"processing",
|
|
1075
|
+
"completed",
|
|
1076
|
+
"failed",
|
|
1077
|
+
"cancelled"
|
|
1078
|
+
];
|
|
1079
|
+
var LEGACY_JOB_STATUSES = [
|
|
1080
|
+
"pending",
|
|
1081
|
+
"processing",
|
|
1082
|
+
"completed",
|
|
1083
|
+
"failed",
|
|
1084
|
+
"created",
|
|
1085
|
+
"uploaded",
|
|
1086
|
+
"initializing",
|
|
1087
|
+
"transcribing",
|
|
1088
|
+
"translating",
|
|
1089
|
+
"paused"
|
|
1090
|
+
];
|
|
1091
|
+
var LEGACY_TO_CANONICAL_JOB_STATUS = {
|
|
1092
|
+
pending: "queued",
|
|
1093
|
+
processing: "processing",
|
|
1094
|
+
completed: "completed",
|
|
1095
|
+
failed: "failed",
|
|
1096
|
+
created: "created",
|
|
1097
|
+
uploaded: "queued",
|
|
1098
|
+
initializing: "queued",
|
|
1099
|
+
transcribing: "processing",
|
|
1100
|
+
translating: "processing",
|
|
1101
|
+
paused: "processing"
|
|
1102
|
+
};
|
|
1103
|
+
var CANONICAL_JOB_CURRENT_STEPS = [
|
|
1104
|
+
"awaiting_upload",
|
|
1105
|
+
"initializing",
|
|
1106
|
+
"extracting_audio",
|
|
1107
|
+
"transcribing",
|
|
1108
|
+
"translating",
|
|
1109
|
+
"generating_subtitles",
|
|
1110
|
+
"generating_summary",
|
|
1111
|
+
"generating_dubbing",
|
|
1112
|
+
"packaging_exports",
|
|
1113
|
+
"finalizing"
|
|
1114
|
+
];
|
|
1115
|
+
var LEGACY_JOB_CURRENT_STEPS = [
|
|
1116
|
+
"initializing",
|
|
1117
|
+
"extracting_audio",
|
|
1118
|
+
"transcribing",
|
|
1119
|
+
"translating",
|
|
1120
|
+
"cleaning_subtitles",
|
|
1121
|
+
"generating_summary",
|
|
1122
|
+
"completing"
|
|
1123
|
+
];
|
|
1124
|
+
var LEGACY_TO_CANONICAL_JOB_CURRENT_STEP = {
|
|
1125
|
+
initializing: "initializing",
|
|
1126
|
+
extracting_audio: "extracting_audio",
|
|
1127
|
+
transcribing: "transcribing",
|
|
1128
|
+
translating: "translating",
|
|
1129
|
+
cleaning_subtitles: "generating_subtitles",
|
|
1130
|
+
generating_summary: "generating_summary",
|
|
1131
|
+
completing: "finalizing"
|
|
1132
|
+
};
|
|
1133
|
+
var LIVE_SESSION_STATUSES = [
|
|
1134
|
+
"scheduled",
|
|
1135
|
+
"starting",
|
|
1136
|
+
"live",
|
|
1137
|
+
"finalizing",
|
|
1138
|
+
"completed",
|
|
1139
|
+
"failed",
|
|
1140
|
+
"cancelled"
|
|
1141
|
+
];
|
|
1142
|
+
var LIVE_SESSION_CURRENT_STEPS = [
|
|
1143
|
+
"provisioning_stream",
|
|
1144
|
+
"connecting_inputs",
|
|
1145
|
+
"capturing_audio",
|
|
1146
|
+
"transcribing_live",
|
|
1147
|
+
"translating_live",
|
|
1148
|
+
"publishing_live_subtitles",
|
|
1149
|
+
"finalizing_session",
|
|
1150
|
+
"archiving_outputs"
|
|
1151
|
+
];
|
|
1152
|
+
var HIGHLIGHT_RUN_STATUSES = [
|
|
1153
|
+
"queued",
|
|
1154
|
+
"processing",
|
|
1155
|
+
"completed",
|
|
1156
|
+
"failed",
|
|
1157
|
+
"cancelled"
|
|
1158
|
+
];
|
|
1159
|
+
var HIGHLIGHT_RUN_CURRENT_STEPS = [
|
|
1160
|
+
"loading_source_context",
|
|
1161
|
+
"detecting_candidates",
|
|
1162
|
+
"scoring_candidates",
|
|
1163
|
+
"selecting_moments",
|
|
1164
|
+
"rendering_clips",
|
|
1165
|
+
"indexing_results"
|
|
1166
|
+
];
|
|
1167
|
+
var DUBBING_RUN_STATUSES = [
|
|
1168
|
+
"queued",
|
|
1169
|
+
"processing",
|
|
1170
|
+
"partial",
|
|
1171
|
+
"completed",
|
|
1172
|
+
"failed",
|
|
1173
|
+
"cancelled"
|
|
1174
|
+
];
|
|
1175
|
+
var DUBBING_RUN_CURRENT_STEPS = [
|
|
1176
|
+
"loading_source_media",
|
|
1177
|
+
"requesting_dubbing",
|
|
1178
|
+
"dubbing_languages",
|
|
1179
|
+
"storing_dubbed_artifacts",
|
|
1180
|
+
"finalizing_outputs"
|
|
1181
|
+
];
|
|
1182
|
+
var CLIP_ARTIFACT_STATUSES = [
|
|
1183
|
+
"queued",
|
|
1184
|
+
"processing",
|
|
1185
|
+
"review_required",
|
|
1186
|
+
"ready",
|
|
1187
|
+
"failed",
|
|
1188
|
+
"cancelled"
|
|
1189
|
+
];
|
|
1190
|
+
var CLIP_ARTIFACT_CURRENT_STEPS = [
|
|
1191
|
+
"queued_for_render",
|
|
1192
|
+
"extracting_media_window",
|
|
1193
|
+
"rendering_clip",
|
|
1194
|
+
"burning_subtitles",
|
|
1195
|
+
"rendering_variant",
|
|
1196
|
+
"generating_thumbnail",
|
|
1197
|
+
"awaiting_review",
|
|
1198
|
+
"publishing_clip"
|
|
1199
|
+
];
|
|
1200
|
+
var COMMENTARY_RUN_STATUSES = [
|
|
1201
|
+
"queued",
|
|
1202
|
+
"processing",
|
|
1203
|
+
"review_required",
|
|
1204
|
+
"completed",
|
|
1205
|
+
"failed",
|
|
1206
|
+
"cancelled"
|
|
1207
|
+
];
|
|
1208
|
+
var COMMENTARY_RUN_CURRENT_STEPS = [
|
|
1209
|
+
"loading_context",
|
|
1210
|
+
"assembling_prompt",
|
|
1211
|
+
"generating_outputs",
|
|
1212
|
+
"normalizing_outputs",
|
|
1213
|
+
"awaiting_review",
|
|
1214
|
+
"publishing_outputs"
|
|
1215
|
+
];
|
|
1216
|
+
var ARTIFACT_STATUSES = [
|
|
1217
|
+
"unavailable",
|
|
1218
|
+
"queued",
|
|
1219
|
+
"processing",
|
|
1220
|
+
"partial",
|
|
1221
|
+
"review_required",
|
|
1222
|
+
"ready",
|
|
1223
|
+
"failed",
|
|
1224
|
+
"cancelled"
|
|
1225
|
+
];
|
|
1226
|
+
var ARTIFACT_TYPES = [
|
|
1227
|
+
"source_media",
|
|
1228
|
+
"extracted_audio",
|
|
1229
|
+
"transcript_json",
|
|
1230
|
+
"subtitle_json",
|
|
1231
|
+
"subtitle_srt",
|
|
1232
|
+
"subtitle_vtt",
|
|
1233
|
+
"subtitle_ttml",
|
|
1234
|
+
"subtitle_stl",
|
|
1235
|
+
"summary_text",
|
|
1236
|
+
"summary_json",
|
|
1237
|
+
"dubbed_audio",
|
|
1238
|
+
"highlight_clip",
|
|
1239
|
+
"highlight_clip_subtitled",
|
|
1240
|
+
"social_variant",
|
|
1241
|
+
"thumbnail_image",
|
|
1242
|
+
"commentary_text",
|
|
1243
|
+
"commentary_json",
|
|
1244
|
+
"export_bundle",
|
|
1245
|
+
"live_segment",
|
|
1246
|
+
"quality_report"
|
|
1247
|
+
];
|
|
1248
|
+
var ARTIFACT_FORMATS = [
|
|
1249
|
+
"json",
|
|
1250
|
+
"txt",
|
|
1251
|
+
"md",
|
|
1252
|
+
"srt",
|
|
1253
|
+
"vtt",
|
|
1254
|
+
"ttml",
|
|
1255
|
+
"xml",
|
|
1256
|
+
"stl",
|
|
1257
|
+
"wav",
|
|
1258
|
+
"mp3",
|
|
1259
|
+
"mp4",
|
|
1260
|
+
"jpg",
|
|
1261
|
+
"png",
|
|
1262
|
+
"zip"
|
|
1263
|
+
];
|
|
1264
|
+
var ARTIFACT_REVIEW_STATUSES = [
|
|
1265
|
+
"not_required",
|
|
1266
|
+
"pending",
|
|
1267
|
+
"approved",
|
|
1268
|
+
"rejected"
|
|
1269
|
+
];
|
|
1270
|
+
var ARTIFACT_CURRENT_STEPS = [
|
|
1271
|
+
"awaiting_source",
|
|
1272
|
+
"generating",
|
|
1273
|
+
"validating",
|
|
1274
|
+
"awaiting_review",
|
|
1275
|
+
"publishing",
|
|
1276
|
+
"indexed"
|
|
1277
|
+
];
|
|
1278
|
+
var EXPORT_PACKAGE_STATUSES = [
|
|
1279
|
+
"queued",
|
|
1280
|
+
"processing",
|
|
1281
|
+
"partial",
|
|
1282
|
+
"ready",
|
|
1283
|
+
"failed",
|
|
1284
|
+
"cancelled"
|
|
1285
|
+
];
|
|
1286
|
+
var EXPORT_PACKAGE_FORMATS = [
|
|
1287
|
+
"zip",
|
|
1288
|
+
"manifest",
|
|
1289
|
+
"deliverable_bundle"
|
|
1290
|
+
];
|
|
1291
|
+
var EXPORT_PACKAGE_CURRENT_STEPS = [
|
|
1292
|
+
"collecting_artifacts",
|
|
1293
|
+
"validating_contents",
|
|
1294
|
+
"packaging_bundle",
|
|
1295
|
+
"publishing_package",
|
|
1296
|
+
"indexed"
|
|
1297
|
+
];
|
|
1298
|
+
var JOB_STATUS_TRANSITIONS = {
|
|
1299
|
+
created: ["queued", "cancelled"],
|
|
1300
|
+
queued: ["processing", "failed", "cancelled"],
|
|
1301
|
+
processing: ["completed", "failed", "cancelled"],
|
|
1302
|
+
completed: [],
|
|
1303
|
+
failed: ["queued"],
|
|
1304
|
+
cancelled: ["queued"]
|
|
1305
|
+
};
|
|
1306
|
+
var LIVE_SESSION_STATUS_TRANSITIONS = {
|
|
1307
|
+
scheduled: ["starting", "cancelled"],
|
|
1308
|
+
starting: ["live", "failed", "cancelled"],
|
|
1309
|
+
live: ["finalizing", "failed", "cancelled"],
|
|
1310
|
+
finalizing: ["completed", "failed", "cancelled"],
|
|
1311
|
+
completed: [],
|
|
1312
|
+
failed: ["starting"],
|
|
1313
|
+
cancelled: ["starting"]
|
|
1314
|
+
};
|
|
1315
|
+
var HIGHLIGHT_RUN_STATUS_TRANSITIONS = {
|
|
1316
|
+
queued: ["processing", "failed", "cancelled"],
|
|
1317
|
+
processing: ["completed", "failed", "cancelled"],
|
|
1318
|
+
completed: [],
|
|
1319
|
+
failed: ["queued"],
|
|
1320
|
+
cancelled: ["queued"]
|
|
1321
|
+
};
|
|
1322
|
+
var DUBBING_RUN_STATUS_TRANSITIONS = {
|
|
1323
|
+
queued: ["processing", "failed", "cancelled"],
|
|
1324
|
+
processing: ["partial", "completed", "failed", "cancelled"],
|
|
1325
|
+
partial: ["processing", "completed", "failed", "cancelled"],
|
|
1326
|
+
completed: [],
|
|
1327
|
+
failed: ["queued"],
|
|
1328
|
+
cancelled: ["queued"]
|
|
1329
|
+
};
|
|
1330
|
+
var CLIP_ARTIFACT_STATUS_TRANSITIONS = {
|
|
1331
|
+
queued: ["processing", "failed", "cancelled"],
|
|
1332
|
+
processing: ["review_required", "ready", "failed", "cancelled"],
|
|
1333
|
+
review_required: ["ready", "failed", "cancelled"],
|
|
1334
|
+
ready: [],
|
|
1335
|
+
failed: ["queued"],
|
|
1336
|
+
cancelled: ["queued"]
|
|
1337
|
+
};
|
|
1338
|
+
var COMMENTARY_RUN_STATUS_TRANSITIONS = {
|
|
1339
|
+
queued: ["processing", "failed", "cancelled"],
|
|
1340
|
+
processing: ["review_required", "completed", "failed", "cancelled"],
|
|
1341
|
+
review_required: ["completed", "failed", "cancelled"],
|
|
1342
|
+
completed: [],
|
|
1343
|
+
failed: ["queued"],
|
|
1344
|
+
cancelled: ["queued"]
|
|
1345
|
+
};
|
|
1346
|
+
var ARTIFACT_STATUS_TRANSITIONS = {
|
|
1347
|
+
unavailable: ["queued", "failed"],
|
|
1348
|
+
queued: ["processing", "failed", "cancelled"],
|
|
1349
|
+
processing: ["partial", "review_required", "ready", "failed", "cancelled"],
|
|
1350
|
+
partial: ["ready", "failed", "cancelled"],
|
|
1351
|
+
review_required: ["ready", "failed", "cancelled"],
|
|
1352
|
+
ready: [],
|
|
1353
|
+
failed: ["queued"],
|
|
1354
|
+
cancelled: ["queued"]
|
|
1355
|
+
};
|
|
1356
|
+
var EXPORT_PACKAGE_STATUS_TRANSITIONS = {
|
|
1357
|
+
queued: ["processing", "failed", "cancelled"],
|
|
1358
|
+
processing: ["partial", "ready", "failed", "cancelled"],
|
|
1359
|
+
partial: ["ready", "failed", "cancelled"],
|
|
1360
|
+
ready: [],
|
|
1361
|
+
failed: ["queued"],
|
|
1362
|
+
cancelled: ["queued"]
|
|
1363
|
+
};
|
|
1364
|
+
function normalizeJobStatus(status) {
|
|
1365
|
+
if (CANONICAL_JOB_STATUSES.includes(status)) {
|
|
1366
|
+
return status;
|
|
1367
|
+
}
|
|
1368
|
+
return LEGACY_TO_CANONICAL_JOB_STATUS[status];
|
|
1369
|
+
}
|
|
1370
|
+
function normalizeJobCurrentStep(step) {
|
|
1371
|
+
if (CANONICAL_JOB_CURRENT_STEPS.includes(step)) {
|
|
1372
|
+
return step;
|
|
1373
|
+
}
|
|
1374
|
+
return LEGACY_TO_CANONICAL_JOB_CURRENT_STEP[step];
|
|
1375
|
+
}
|
|
1376
|
+
function isValidTransition(transitionMap, from, to) {
|
|
1377
|
+
return transitionMap[from]?.includes(to) ?? false;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
export { ARTIFACT_CURRENT_STEPS, ARTIFACT_FORMATS, ARTIFACT_REVIEW_STATUSES, ARTIFACT_STATUSES, ARTIFACT_STATUS_TRANSITIONS, ARTIFACT_TYPES, ArtifactsResource, AudiolizeApiError, AudiolizeClient, AudiolizeError, AudiolizeTimeoutError, AudiolizeUploadError, AudiolizeValidationError, AuthenticationError, AuthorizationError, CANONICAL_JOB_CURRENT_STEPS, CANONICAL_JOB_STATUSES, CAPABILITY_READINESS_STATES, CLIP_ARTIFACT_CURRENT_STEPS, CLIP_ARTIFACT_STATUSES, CLIP_ARTIFACT_STATUS_TRANSITIONS, COMMENTARY_RUN_CURRENT_STEPS, COMMENTARY_RUN_STATUSES, COMMENTARY_RUN_STATUS_TRANSITIONS, CommentaryResource, DEFAULT_MULTIPART_THRESHOLD, DOMAIN_ENTITY_KINDS, DUBBING_RUN_CURRENT_STEPS, DUBBING_RUN_STATUSES, DUBBING_RUN_STATUS_TRANSITIONS, DubbingResource, EXPORT_PACKAGE_CURRENT_STEPS, EXPORT_PACKAGE_FORMATS, EXPORT_PACKAGE_STATUSES, EXPORT_PACKAGE_STATUS_TRANSITIONS, ExportPackagesResource, FilesResource, HIGHLIGHT_RUN_CURRENT_STEPS, HIGHLIGHT_RUN_STATUSES, HIGHLIGHT_RUN_STATUS_TRANSITIONS, HighlightsResource, JOB_STATUS_TRANSITIONS, JobPoller, JobsResource, LEGACY_JOB_CURRENT_STEPS, LEGACY_JOB_STATUSES, LEGACY_TO_CANONICAL_JOB_CURRENT_STEP, LEGACY_TO_CANONICAL_JOB_STATUS, LIVE_SESSION_CURRENT_STEPS, LIVE_SESSION_STATUSES, LIVE_SESSION_STATUS_TRANSITIONS, LanguagesResource, LiveSessionsResource, NotFoundError, PaywallError, RateLimitError, ServerError, SubtitlesResource, getBackoffDelay, isValidTransition, localize, normalizeJobCurrentStep, normalizeJobStatus, withRetry };
|
|
625
1381
|
//# sourceMappingURL=index.js.map
|
|
626
1382
|
//# sourceMappingURL=index.js.map
|