@editframe/api 0.12.0-beta.2 → 0.12.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ProgressIterator.d.ts +1 -1
- package/dist/ProgressIterator.js +14 -2
- package/dist/StreamEventSource.d.ts +2 -3
- package/dist/StreamEventSource.js +0 -2
- package/dist/client.d.ts +1 -1
- package/dist/index.d.ts +13 -10
- package/dist/index.js +5 -3
- package/dist/node.d.ts +6 -0
- package/dist/node.js +92 -0
- package/dist/resources/caption-file.d.ts +32 -4
- package/dist/resources/caption-file.js +9 -0
- package/dist/resources/image-file.d.ts +35 -11
- package/dist/resources/image-file.js +22 -4
- package/dist/resources/isobmff-file.d.ts +37 -4
- package/dist/resources/isobmff-file.js +20 -0
- package/dist/resources/isobmff-track.d.ts +277 -13
- package/dist/resources/isobmff-track.js +20 -18
- package/dist/resources/process-isobmff.d.ts +2 -2
- package/dist/resources/renders.d.ts +9 -8
- package/dist/resources/transcriptions.d.ts +4 -3
- package/dist/resources/unprocessed-file.d.ts +9 -8
- package/dist/resources/unprocessed-file.js +8 -8
- package/dist/resources/url-token.d.ts +1 -1
- package/dist/uploadChunks.d.ts +4 -1
- package/dist/utils/assertTypesMatch.d.ts +3 -0
- package/dist/utils/createReadableStreamFromReadable.d.ts +4 -0
- package/dist/utils/createReadableStreamFromReadable.js +82 -0
- package/docs/packages/api/docs/.nojekyll +1 -0
- package/docs/packages/api/docs/assets/highlight.css +71 -0
- package/docs/packages/api/docs/assets/icons.js +18 -0
- package/docs/packages/api/docs/assets/icons.svg +1 -0
- package/docs/packages/api/docs/assets/main.js +60 -0
- package/docs/packages/api/docs/assets/navigation.js +1 -0
- package/docs/packages/api/docs/assets/search.js +1 -0
- package/docs/packages/api/docs/assets/style.css +1493 -0
- package/docs/packages/api/docs/classes/Client.html +4 -0
- package/docs/packages/api/docs/functions/createCaptionFile.html +8 -0
- package/docs/packages/api/docs/functions/createISOBMFFFile.html +1 -0
- package/docs/packages/api/docs/functions/createISOBMFFTrack.html +1 -0
- package/docs/packages/api/docs/functions/createImageFile.html +1 -0
- package/docs/packages/api/docs/functions/createRender.html +1 -0
- package/docs/packages/api/docs/functions/createTranscription.html +1 -0
- package/docs/packages/api/docs/functions/createURLToken.html +1 -0
- package/docs/packages/api/docs/functions/createUnprocessedFile.html +1 -0
- package/docs/packages/api/docs/functions/getISOBMFFFileTranscription.html +1 -0
- package/docs/packages/api/docs/functions/getIsobmffProcessInfo.html +1 -0
- package/docs/packages/api/docs/functions/getIsobmffProcessProgress.html +1 -0
- package/docs/packages/api/docs/functions/getTranscriptionInfo.html +1 -0
- package/docs/packages/api/docs/functions/getTranscriptionProgress.html +1 -0
- package/docs/packages/api/docs/functions/lookupCaptionFileByMd5.html +1 -0
- package/docs/packages/api/docs/functions/lookupISOBMFFFileByMd5.html +1 -0
- package/docs/packages/api/docs/functions/lookupImageFileByMd5.html +1 -0
- package/docs/packages/api/docs/functions/lookupRenderByMd5.html +1 -0
- package/docs/packages/api/docs/functions/lookupUnprocessedFileByMd5.html +1 -0
- package/docs/packages/api/docs/functions/processIsobmffFile.html +1 -0
- package/docs/packages/api/docs/functions/transcribeISOBMFFFile.html +1 -0
- package/docs/packages/api/docs/functions/uploadCaptionFile.html +1 -0
- package/docs/packages/api/docs/functions/uploadFragmentIndex.html +1 -0
- package/docs/packages/api/docs/functions/uploadISOBMFFTrack.html +1 -0
- package/docs/packages/api/docs/functions/uploadImageFile.html +1 -0
- package/docs/packages/api/docs/functions/uploadRender.html +1 -0
- package/docs/packages/api/docs/functions/uploadUnprocessedReadableStream.html +1 -0
- package/docs/packages/api/docs/index.html +39 -0
- package/docs/packages/api/docs/interfaces/CreateCaptionFileResult.html +4 -0
- package/docs/packages/api/docs/interfaces/CreateISOBMFFFileResult.html +5 -0
- package/docs/packages/api/docs/interfaces/CreateISOBMFFTrackResult.html +6 -0
- package/docs/packages/api/docs/interfaces/CreateImageFileResult.html +5 -0
- package/docs/packages/api/docs/interfaces/CreateRenderResult.html +4 -0
- package/docs/packages/api/docs/interfaces/CreateTranscriptionResult.html +3 -0
- package/docs/packages/api/docs/interfaces/CreateUnprocessedFileResult.html +6 -0
- package/docs/packages/api/docs/interfaces/GetISOBMFFFileTranscriptionResult.html +4 -0
- package/docs/packages/api/docs/interfaces/IsobmffProcessInfoResult.html +7 -0
- package/docs/packages/api/docs/interfaces/LookupCaptionFileByMd5Result.html +4 -0
- package/docs/packages/api/docs/interfaces/LookupISOBMFFFileByMd5Result.html +5 -0
- package/docs/packages/api/docs/interfaces/LookupImageFileByMd5Result.html +5 -0
- package/docs/packages/api/docs/interfaces/LookupRenderByMd5Result.html +4 -0
- package/docs/packages/api/docs/interfaces/LookupUnprocessedFileByMd5Result.html +6 -0
- package/docs/packages/api/docs/interfaces/ProcessIsobmffFileResult.html +2 -0
- package/docs/packages/api/docs/interfaces/TranscribeISOBMFFFileResult.html +4 -0
- package/docs/packages/api/docs/interfaces/TranscriptionInfoResult.html +3 -0
- package/docs/packages/api/docs/interfaces/URLTokenResult.html +2 -0
- package/docs/packages/api/docs/modules.html +54 -0
- package/docs/packages/api/docs/variables/CreateCaptionFilePayload.html +1 -0
- package/docs/packages/api/docs/variables/CreateISOBMFFFilePayload.html +1 -0
- package/docs/packages/api/docs/variables/CreateISOBMFFTrackPayload.html +1 -0
- package/docs/packages/api/docs/variables/CreateImageFilePayload.html +1 -0
- package/docs/packages/api/docs/variables/CreateRenderPayload.html +1 -0
- package/docs/packages/api/docs/variables/CreateTranscriptionPayload.html +1 -0
- package/docs/packages/api/docs/variables/CreateUnprocessedFilePayload.html +1 -0
- package/docs/packages/api/docs/variables/TranscribeISOBMFFFilePayload.html +1 -0
- package/package.json +12 -4
- package/src/resources/caption-file.test.ts +3 -3
- package/src/resources/caption-file.ts +31 -2
- package/src/resources/image-file.test.ts +6 -9
- package/src/resources/image-file.ts +32 -8
- package/src/resources/isobmff-file.test.ts +3 -3
- package/src/resources/isobmff-file.ts +58 -2
- package/src/resources/isobmff-track.test.ts +4 -4
- package/src/resources/isobmff-track.ts +33 -21
- package/src/resources/process-isobmff.test.ts +3 -3
- package/src/resources/process-isobmff.ts +2 -2
- package/src/resources/renders.test.ts +3 -3
- package/src/resources/renders.ts +3 -2
- package/src/resources/transcriptions.test.ts +2 -2
- package/src/resources/transcriptions.ts +7 -3
- package/src/resources/unprocessed-file.test.ts +8 -10
- package/src/resources/unprocessed-file.ts +21 -16
- package/src/resources/url-token.test.ts +3 -3
- package/src/resources/url-token.ts +1 -1
- package/src/utils/assertTypesMatch.ts +10 -0
- package/src/utils/createReadableStreamFromReadable.ts +117 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CompleteEvent, ProgressEvent, StreamEventSource } from './StreamEventSource.
|
|
1
|
+
import { CompleteEvent, ProgressEvent, StreamEventSource } from './StreamEventSource.js';
|
|
2
2
|
declare abstract class BaseEventIterator<T extends CompleteEvent | any> implements AsyncIterable<T> {
|
|
3
3
|
protected eventSource: StreamEventSource;
|
|
4
4
|
protected queue: T[];
|
package/dist/ProgressIterator.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
const promiseWithResolvers = () => {
|
|
2
|
+
if (typeof Promise.withResolvers === "function") {
|
|
3
|
+
return Promise.withResolvers();
|
|
4
|
+
}
|
|
5
|
+
let resolve;
|
|
6
|
+
let reject;
|
|
7
|
+
const promise = new Promise((res, rej) => {
|
|
8
|
+
resolve = res;
|
|
9
|
+
reject = rej;
|
|
10
|
+
});
|
|
11
|
+
return { promise, resolve, reject };
|
|
12
|
+
};
|
|
1
13
|
class BaseEventIterator {
|
|
2
14
|
constructor(eventSource) {
|
|
3
15
|
this.queue = [];
|
|
4
16
|
this.index = 0;
|
|
5
17
|
this.isComplete = false;
|
|
6
|
-
this.resolversNext =
|
|
18
|
+
this.resolversNext = promiseWithResolvers();
|
|
7
19
|
this.eventSource = eventSource;
|
|
8
20
|
}
|
|
9
21
|
async whenComplete() {
|
|
@@ -14,7 +26,7 @@ class BaseEventIterator {
|
|
|
14
26
|
push(event) {
|
|
15
27
|
this.queue.push(event);
|
|
16
28
|
this.resolversNext.resolve();
|
|
17
|
-
this.resolversNext =
|
|
29
|
+
this.resolversNext = promiseWithResolvers();
|
|
18
30
|
}
|
|
19
31
|
get queueLength() {
|
|
20
32
|
return this.queue.length - this.index;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type EventCallback<T> = (event: T) => void;
|
|
1
|
+
export type EventCallback<T> = (event: T) => void;
|
|
2
2
|
export type StreamEventSourceEventMap = {
|
|
3
3
|
progress: ProgressEvent;
|
|
4
4
|
complete: CompleteEvent;
|
|
@@ -8,7 +8,7 @@ export type StreamEventSourceEventMap = {
|
|
|
8
8
|
id: string | undefined;
|
|
9
9
|
data: string;
|
|
10
10
|
};
|
|
11
|
-
end:
|
|
11
|
+
end: Array<unknown>;
|
|
12
12
|
error: Error;
|
|
13
13
|
};
|
|
14
14
|
export type ProgressEvent = {
|
|
@@ -47,4 +47,3 @@ export declare class StreamEventSource {
|
|
|
47
47
|
private startReading;
|
|
48
48
|
close(): void;
|
|
49
49
|
}
|
|
50
|
-
export {};
|
|
@@ -105,7 +105,6 @@ class StreamEventSource {
|
|
|
105
105
|
}
|
|
106
106
|
this.parser.feed(chunk);
|
|
107
107
|
}
|
|
108
|
-
this.activeReader.releaseLock();
|
|
109
108
|
this.activeReader = null;
|
|
110
109
|
this.emit("end", []);
|
|
111
110
|
} catch (error) {
|
|
@@ -119,7 +118,6 @@ class StreamEventSource {
|
|
|
119
118
|
}
|
|
120
119
|
close() {
|
|
121
120
|
if (this.activeReader) {
|
|
122
|
-
this.activeReader.releaseLock();
|
|
123
121
|
this.activeReader = null;
|
|
124
122
|
}
|
|
125
123
|
this.parser.reset();
|
package/dist/client.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export { createCaptionFile, CreateCaptionFilePayload, type CreateCaptionFileResult, uploadCaptionFile, type LookupCaptionFileByMd5Result, lookupCaptionFileByMd5, } from './resources/caption-file.
|
|
2
|
-
export { createImageFile, CreateImageFilePayload, type CreateImageFileResult, uploadImageFile, type LookupImageFileByMd5Result, lookupImageFileByMd5, } from './resources/image-file.
|
|
3
|
-
export { createISOBMFFFile, CreateISOBMFFFilePayload, type CreateISOBMFFFileResult, uploadFragmentIndex, type LookupISOBMFFFileByMd5Result, lookupISOBMFFFileByMd5, type GetISOBMFFFileTranscriptionResult, getISOBMFFFileTranscription, } from './resources/isobmff-file.
|
|
4
|
-
export { createISOBMFFTrack, CreateISOBMFFTrackPayload, type CreateISOBMFFTrackResult, uploadISOBMFFTrack, } from './resources/isobmff-track.
|
|
5
|
-
export { createRender, CreateRenderPayload, type CreateRenderResult, uploadRender, type LookupRenderByMd5Result, lookupRenderByMd5, } from './resources/renders.
|
|
6
|
-
export { createTranscription, CreateTranscriptionPayload, type CreateTranscriptionResult, getTranscriptionInfo, getTranscriptionProgress, type TranscriptionInfoResult, } from './resources/transcriptions.
|
|
7
|
-
export { createURLToken, type URLTokenResult, } from './resources/url-token.
|
|
8
|
-
export { createUnprocessedFile, CreateUnprocessedFilePayload, type CreateUnprocessedFileResult,
|
|
9
|
-
export { getIsobmffProcessInfo, getIsobmffProcessProgress, type IsobmffProcessInfoResult, } from './resources/process-isobmff.
|
|
10
|
-
export { Client } from './client.
|
|
1
|
+
export { createCaptionFile, CreateCaptionFilePayload, type CreateCaptionFileResult, uploadCaptionFile, type LookupCaptionFileByMd5Result, lookupCaptionFileByMd5, } from './resources/caption-file.js';
|
|
2
|
+
export { createImageFile, CreateImageFilePayload, type CreateImageFileResult, uploadImageFile, type LookupImageFileByMd5Result, lookupImageFileByMd5, } from './resources/image-file.js';
|
|
3
|
+
export { createISOBMFFFile, CreateISOBMFFFilePayload, type CreateISOBMFFFileResult, uploadFragmentIndex, type LookupISOBMFFFileByMd5Result, lookupISOBMFFFileByMd5, type GetISOBMFFFileTranscriptionResult, getISOBMFFFileTranscription, type TranscribeISOBMFFFileResult, transcribeISOBMFFFile, TranscribeISOBMFFFilePayload, } from './resources/isobmff-file.js';
|
|
4
|
+
export { createISOBMFFTrack, CreateISOBMFFTrackPayload, type CreateISOBMFFTrackResult, uploadISOBMFFTrack, } from './resources/isobmff-track.js';
|
|
5
|
+
export { createRender, CreateRenderPayload, type CreateRenderResult, uploadRender, type LookupRenderByMd5Result, lookupRenderByMd5, } from './resources/renders.js';
|
|
6
|
+
export { createTranscription, CreateTranscriptionPayload, type CreateTranscriptionResult, getTranscriptionInfo, getTranscriptionProgress, type TranscriptionInfoResult, } from './resources/transcriptions.js';
|
|
7
|
+
export { createURLToken, type URLTokenResult, } from './resources/url-token.js';
|
|
8
|
+
export { createUnprocessedFile, CreateUnprocessedFilePayload, type CreateUnprocessedFileResult, uploadUnprocessedReadableStream, type LookupUnprocessedFileByMd5Result, lookupUnprocessedFileByMd5, processIsobmffFile, type ProcessIsobmffFileResult, type UnprocessedFileUploadDetails, type UnprocessedFile, } from './resources/unprocessed-file.js';
|
|
9
|
+
export { getIsobmffProcessInfo, getIsobmffProcessProgress, type IsobmffProcessInfoResult, } from './resources/process-isobmff.js';
|
|
10
|
+
export { Client } from './client.js';
|
|
11
|
+
export type { IteratorWithPromise, UploadChunkEvent } from './uploadChunks.js';
|
|
12
|
+
export type { ProgressIterator, CompletionIterator, } from './ProgressIterator.js';
|
|
13
|
+
export type { StreamEventSource, ProgressEvent, CompletionEvent, StreamEventSourceEventMap, EventCallback, } from './StreamEventSource.js';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CreateCaptionFilePayload, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile } from "./resources/caption-file.js";
|
|
2
2
|
import { CreateImageFilePayload, createImageFile, lookupImageFileByMd5, uploadImageFile } from "./resources/image-file.js";
|
|
3
|
-
import { CreateISOBMFFFilePayload, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, uploadFragmentIndex } from "./resources/isobmff-file.js";
|
|
3
|
+
import { CreateISOBMFFFilePayload, TranscribeISOBMFFFilePayload, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex } from "./resources/isobmff-file.js";
|
|
4
4
|
import { CreateISOBMFFTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
|
|
5
5
|
import { CreateRenderPayload, createRender, lookupRenderByMd5, uploadRender } from "./resources/renders.js";
|
|
6
6
|
import { CreateTranscriptionPayload, createTranscription, getTranscriptionInfo, getTranscriptionProgress } from "./resources/transcriptions.js";
|
|
7
7
|
import { createURLToken } from "./resources/url-token.js";
|
|
8
|
-
import { CreateUnprocessedFilePayload, createUnprocessedFile, lookupUnprocessedFileByMd5, processIsobmffFile,
|
|
8
|
+
import { CreateUnprocessedFilePayload, createUnprocessedFile, lookupUnprocessedFileByMd5, processIsobmffFile, uploadUnprocessedReadableStream } from "./resources/unprocessed-file.js";
|
|
9
9
|
import { getIsobmffProcessInfo, getIsobmffProcessProgress } from "./resources/process-isobmff.js";
|
|
10
10
|
import { Client } from "./client.js";
|
|
11
11
|
export {
|
|
@@ -17,6 +17,7 @@ export {
|
|
|
17
17
|
CreateRenderPayload,
|
|
18
18
|
CreateTranscriptionPayload,
|
|
19
19
|
CreateUnprocessedFilePayload,
|
|
20
|
+
TranscribeISOBMFFFilePayload,
|
|
20
21
|
createCaptionFile,
|
|
21
22
|
createISOBMFFFile,
|
|
22
23
|
createISOBMFFTrack,
|
|
@@ -36,10 +37,11 @@ export {
|
|
|
36
37
|
lookupRenderByMd5,
|
|
37
38
|
lookupUnprocessedFileByMd5,
|
|
38
39
|
processIsobmffFile,
|
|
40
|
+
transcribeISOBMFFFile,
|
|
39
41
|
uploadCaptionFile,
|
|
40
42
|
uploadFragmentIndex,
|
|
41
43
|
uploadISOBMFFTrack,
|
|
42
44
|
uploadImageFile,
|
|
43
45
|
uploadRender,
|
|
44
|
-
|
|
46
|
+
uploadUnprocessedReadableStream
|
|
45
47
|
};
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Client } from './client.js';
|
|
2
|
+
import { UnprocessedFileUploadDetails } from './resources/unprocessed-file.js';
|
|
3
|
+
export declare const createImageFileFromPath: (client: Client, path: string) => Promise<import('./index.js').CreateImageFileResult>;
|
|
4
|
+
export declare const createUnprocessedFileFromPath: (client: Client, path: string) => Promise<import('./index.js').CreateUnprocessedFileResult>;
|
|
5
|
+
export declare const uploadUnprocessedFile: (client: Client, uploadDetails: UnprocessedFileUploadDetails, path: string) => Promise<import('./uploadChunks.ts').IteratorWithPromise<import('./uploadChunks.ts').UploadChunkEvent>>;
|
|
6
|
+
export * from './index.js';
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { stat } from "node:fs/promises";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import mime from "mime";
|
|
4
|
+
import { md5FilePath } from "@editframe/assets";
|
|
5
|
+
import { createImageFile, CreateImageFilePayload } from "./resources/image-file.js";
|
|
6
|
+
import { lookupImageFileByMd5, uploadImageFile } from "./resources/image-file.js";
|
|
7
|
+
import { createUnprocessedFile, uploadUnprocessedReadableStream } from "./resources/unprocessed-file.js";
|
|
8
|
+
import { CreateUnprocessedFilePayload, lookupUnprocessedFileByMd5, processIsobmffFile } from "./resources/unprocessed-file.js";
|
|
9
|
+
import { CreateCaptionFilePayload, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile } from "./resources/caption-file.js";
|
|
10
|
+
import { CreateISOBMFFFilePayload, TranscribeISOBMFFFilePayload, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex } from "./resources/isobmff-file.js";
|
|
11
|
+
import { CreateISOBMFFTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
|
|
12
|
+
import { CreateRenderPayload, createRender, lookupRenderByMd5, uploadRender } from "./resources/renders.js";
|
|
13
|
+
import { CreateTranscriptionPayload, createTranscription, getTranscriptionInfo, getTranscriptionProgress } from "./resources/transcriptions.js";
|
|
14
|
+
import { createURLToken } from "./resources/url-token.js";
|
|
15
|
+
import { getIsobmffProcessInfo, getIsobmffProcessProgress } from "./resources/process-isobmff.js";
|
|
16
|
+
import { Client } from "./client.js";
|
|
17
|
+
const createImageFileFromPath = async (client, path) => {
|
|
18
|
+
const fileInfo = await stat(path);
|
|
19
|
+
const byte_size = fileInfo.size;
|
|
20
|
+
const md5 = await md5FilePath(path);
|
|
21
|
+
const mime_type = mime.getType(path);
|
|
22
|
+
return createImageFile(client, {
|
|
23
|
+
...CreateImageFilePayload.parse({
|
|
24
|
+
md5,
|
|
25
|
+
height: 0,
|
|
26
|
+
width: 0,
|
|
27
|
+
mime_type,
|
|
28
|
+
filename: basename(path),
|
|
29
|
+
byte_size
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
const createUnprocessedFileFromPath = async (client, path) => {
|
|
34
|
+
const fileInfo = await stat(path);
|
|
35
|
+
const byte_size = fileInfo.size;
|
|
36
|
+
const md5 = await md5FilePath(path);
|
|
37
|
+
return createUnprocessedFile(client, {
|
|
38
|
+
md5,
|
|
39
|
+
filename: basename(path),
|
|
40
|
+
byte_size
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const uploadUnprocessedFile = async (client, uploadDetails, path) => {
|
|
44
|
+
const { createReadStream } = await import("node:fs");
|
|
45
|
+
const readStream = createReadStream(path);
|
|
46
|
+
const { createReadableStreamFromReadable } = await import("./utils/createReadableStreamFromReadable.js");
|
|
47
|
+
return uploadUnprocessedReadableStream(
|
|
48
|
+
client,
|
|
49
|
+
uploadDetails,
|
|
50
|
+
createReadableStreamFromReadable(readStream)
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
Client,
|
|
55
|
+
CreateCaptionFilePayload,
|
|
56
|
+
CreateISOBMFFFilePayload,
|
|
57
|
+
CreateISOBMFFTrackPayload,
|
|
58
|
+
CreateImageFilePayload,
|
|
59
|
+
CreateRenderPayload,
|
|
60
|
+
CreateTranscriptionPayload,
|
|
61
|
+
CreateUnprocessedFilePayload,
|
|
62
|
+
TranscribeISOBMFFFilePayload,
|
|
63
|
+
createCaptionFile,
|
|
64
|
+
createISOBMFFFile,
|
|
65
|
+
createISOBMFFTrack,
|
|
66
|
+
createImageFile,
|
|
67
|
+
createImageFileFromPath,
|
|
68
|
+
createRender,
|
|
69
|
+
createTranscription,
|
|
70
|
+
createURLToken,
|
|
71
|
+
createUnprocessedFile,
|
|
72
|
+
createUnprocessedFileFromPath,
|
|
73
|
+
getISOBMFFFileTranscription,
|
|
74
|
+
getIsobmffProcessInfo,
|
|
75
|
+
getIsobmffProcessProgress,
|
|
76
|
+
getTranscriptionInfo,
|
|
77
|
+
getTranscriptionProgress,
|
|
78
|
+
lookupCaptionFileByMd5,
|
|
79
|
+
lookupISOBMFFFileByMd5,
|
|
80
|
+
lookupImageFileByMd5,
|
|
81
|
+
lookupRenderByMd5,
|
|
82
|
+
lookupUnprocessedFileByMd5,
|
|
83
|
+
processIsobmffFile,
|
|
84
|
+
transcribeISOBMFFFile,
|
|
85
|
+
uploadCaptionFile,
|
|
86
|
+
uploadFragmentIndex,
|
|
87
|
+
uploadISOBMFFTrack,
|
|
88
|
+
uploadImageFile,
|
|
89
|
+
uploadRender,
|
|
90
|
+
uploadUnprocessedFile,
|
|
91
|
+
uploadUnprocessedReadableStream
|
|
92
|
+
};
|
|
@@ -1,26 +1,54 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { Client } from '../client.
|
|
2
|
+
import { Client } from '../client.js';
|
|
3
3
|
export declare const CreateCaptionFilePayload: z.ZodObject<{
|
|
4
|
+
/**
|
|
5
|
+
* The md5 hash of the caption file
|
|
6
|
+
*/
|
|
4
7
|
md5: z.ZodString;
|
|
8
|
+
/**
|
|
9
|
+
* The filename of the caption file
|
|
10
|
+
*/
|
|
5
11
|
filename: z.ZodString;
|
|
12
|
+
/**
|
|
13
|
+
* The size of the caption file in bytes
|
|
14
|
+
*/
|
|
6
15
|
byte_size: z.ZodNumber;
|
|
7
16
|
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
md5: string;
|
|
9
17
|
filename: string;
|
|
18
|
+
md5: string;
|
|
10
19
|
byte_size: number;
|
|
11
20
|
}, {
|
|
12
|
-
md5: string;
|
|
13
21
|
filename: string;
|
|
22
|
+
md5: string;
|
|
14
23
|
byte_size: number;
|
|
15
24
|
}>;
|
|
25
|
+
export type CreateCaptionFilePayload = z.infer<typeof CreateCaptionFilePayload>;
|
|
16
26
|
export interface CreateCaptionFileResult {
|
|
27
|
+
/**
|
|
28
|
+
* Whether the caption file is complete
|
|
29
|
+
*/
|
|
17
30
|
complete: boolean | null;
|
|
31
|
+
/**
|
|
32
|
+
* The id of the caption file
|
|
33
|
+
*/
|
|
18
34
|
id: string;
|
|
35
|
+
/**
|
|
36
|
+
* The md5 hash of the caption file
|
|
37
|
+
*/
|
|
19
38
|
md5: string;
|
|
20
39
|
}
|
|
21
40
|
export interface LookupCaptionFileByMd5Result {
|
|
41
|
+
/**
|
|
42
|
+
* Whether the caption file is complete
|
|
43
|
+
*/
|
|
22
44
|
complete: boolean | null;
|
|
45
|
+
/**
|
|
46
|
+
* The id of the caption file
|
|
47
|
+
*/
|
|
23
48
|
id: string;
|
|
49
|
+
/**
|
|
50
|
+
* The md5 hash of the caption file
|
|
51
|
+
*/
|
|
24
52
|
md5: string;
|
|
25
53
|
}
|
|
26
54
|
/**
|
|
@@ -40,6 +68,6 @@ export interface LookupCaptionFileByMd5Result {
|
|
|
40
68
|
* @resource
|
|
41
69
|
* @beta
|
|
42
70
|
*/
|
|
43
|
-
export declare const createCaptionFile: (client: Client, payload:
|
|
71
|
+
export declare const createCaptionFile: (client: Client, payload: CreateCaptionFilePayload) => Promise<CreateCaptionFileResult>;
|
|
44
72
|
export declare const uploadCaptionFile: (client: Client, fileId: string, fileStream: ReadableStream, fileSize: number) => Promise<any>;
|
|
45
73
|
export declare const lookupCaptionFileByMd5: (client: Client, md5: string) => Promise<LookupCaptionFileByMd5Result | null>;
|
|
@@ -3,8 +3,17 @@ import { z } from "zod";
|
|
|
3
3
|
const log = debug("ef:api:caption-file");
|
|
4
4
|
const MAX_CAPTION_SIZE = 1024 * 1024 * 2;
|
|
5
5
|
const CreateCaptionFilePayload = z.object({
|
|
6
|
+
/**
|
|
7
|
+
* The md5 hash of the caption file
|
|
8
|
+
*/
|
|
6
9
|
md5: z.string(),
|
|
10
|
+
/**
|
|
11
|
+
* The filename of the caption file
|
|
12
|
+
*/
|
|
7
13
|
filename: z.string(),
|
|
14
|
+
/**
|
|
15
|
+
* The size of the caption file in bytes
|
|
16
|
+
*/
|
|
8
17
|
byte_size: z.number().int().max(MAX_CAPTION_SIZE)
|
|
9
18
|
});
|
|
10
19
|
const restrictSize = (size) => {
|
|
@@ -1,37 +1,61 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { Client } from '../client.
|
|
2
|
+
import { Client } from '../client.js';
|
|
3
3
|
export declare const CreateImageFilePayload: z.ZodObject<{
|
|
4
|
+
/**
|
|
5
|
+
* The md5 hash of the image file.
|
|
6
|
+
*/
|
|
4
7
|
md5: z.ZodString;
|
|
8
|
+
/**
|
|
9
|
+
* The height of the image file in pixels.
|
|
10
|
+
*/
|
|
5
11
|
height: z.ZodNumber;
|
|
12
|
+
/**
|
|
13
|
+
* The width of the image file in pixels.
|
|
14
|
+
*/
|
|
6
15
|
width: z.ZodNumber;
|
|
16
|
+
/**
|
|
17
|
+
* The mime type of the image file.
|
|
18
|
+
*/
|
|
7
19
|
mime_type: z.ZodEnum<["image/jpeg", "image/png", "image/jpg", "image/webp"]>;
|
|
20
|
+
/**
|
|
21
|
+
* The filename of the image file.
|
|
22
|
+
*/
|
|
8
23
|
filename: z.ZodString;
|
|
24
|
+
/**
|
|
25
|
+
* The byte size of the image file.
|
|
26
|
+
*/
|
|
9
27
|
byte_size: z.ZodNumber;
|
|
10
28
|
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
md5: string;
|
|
12
|
-
filename: string;
|
|
13
|
-
byte_size: number;
|
|
14
|
-
height: number;
|
|
15
29
|
width: number;
|
|
16
|
-
|
|
17
|
-
}, {
|
|
18
|
-
md5: string;
|
|
30
|
+
height: number;
|
|
19
31
|
filename: string;
|
|
32
|
+
md5: string;
|
|
33
|
+
mime_type: "image/jpeg" | "image/png" | "image/jpg" | "image/webp";
|
|
20
34
|
byte_size: number;
|
|
21
|
-
|
|
35
|
+
}, {
|
|
22
36
|
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
filename: string;
|
|
39
|
+
md5: string;
|
|
23
40
|
mime_type: "image/jpeg" | "image/png" | "image/jpg" | "image/webp";
|
|
41
|
+
byte_size: number;
|
|
24
42
|
}>;
|
|
43
|
+
export type CreateImageFilePayload = z.infer<typeof CreateImageFilePayload>;
|
|
25
44
|
export interface CreateImageFileResult {
|
|
26
45
|
complete: boolean | null;
|
|
46
|
+
byte_size: number;
|
|
27
47
|
id: string;
|
|
28
48
|
md5: string;
|
|
29
49
|
}
|
|
30
50
|
export interface LookupImageFileByMd5Result {
|
|
31
51
|
complete: boolean | null;
|
|
52
|
+
byte_size: number;
|
|
32
53
|
id: string;
|
|
33
54
|
md5: string;
|
|
34
55
|
}
|
|
35
|
-
export declare const createImageFile: (client: Client, payload:
|
|
36
|
-
export declare const uploadImageFile: (client: Client,
|
|
56
|
+
export declare const createImageFile: (client: Client, payload: CreateImageFilePayload) => Promise<CreateImageFileResult>;
|
|
57
|
+
export declare const uploadImageFile: (client: Client, uploadDetails: {
|
|
58
|
+
id: string;
|
|
59
|
+
byte_size: number;
|
|
60
|
+
}, fileStream: ReadableStream) => import('../uploadChunks.js').IteratorWithPromise<import('../uploadChunks.js').UploadChunkEvent>;
|
|
37
61
|
export declare const lookupImageFileByMd5: (client: Client, md5: string) => Promise<LookupImageFileByMd5Result | null>;
|
|
@@ -4,11 +4,29 @@ import { uploadChunks } from "../uploadChunks.js";
|
|
|
4
4
|
const log = debug("ef:api:image-file");
|
|
5
5
|
const MAX_IMAGE_SIZE = 1024 * 1024 * 16;
|
|
6
6
|
const CreateImageFilePayload = z.object({
|
|
7
|
+
/**
|
|
8
|
+
* The md5 hash of the image file.
|
|
9
|
+
*/
|
|
7
10
|
md5: z.string(),
|
|
11
|
+
/**
|
|
12
|
+
* The height of the image file in pixels.
|
|
13
|
+
*/
|
|
8
14
|
height: z.number().int(),
|
|
15
|
+
/**
|
|
16
|
+
* The width of the image file in pixels.
|
|
17
|
+
*/
|
|
9
18
|
width: z.number().int(),
|
|
19
|
+
/**
|
|
20
|
+
* The mime type of the image file.
|
|
21
|
+
*/
|
|
10
22
|
mime_type: z.enum(["image/jpeg", "image/png", "image/jpg", "image/webp"]),
|
|
23
|
+
/**
|
|
24
|
+
* The filename of the image file.
|
|
25
|
+
*/
|
|
11
26
|
filename: z.string(),
|
|
27
|
+
/**
|
|
28
|
+
* The byte size of the image file.
|
|
29
|
+
*/
|
|
12
30
|
byte_size: z.number().int().max(MAX_IMAGE_SIZE)
|
|
13
31
|
});
|
|
14
32
|
const createImageFile = async (client, payload) => {
|
|
@@ -26,11 +44,11 @@ const createImageFile = async (client, payload) => {
|
|
|
26
44
|
`Failed to create file ${response.status} ${response.statusText}`
|
|
27
45
|
);
|
|
28
46
|
};
|
|
29
|
-
const uploadImageFile = (client,
|
|
30
|
-
log("Uploading image file",
|
|
47
|
+
const uploadImageFile = (client, uploadDetails, fileStream) => {
|
|
48
|
+
log("Uploading image file", uploadDetails.id);
|
|
31
49
|
return uploadChunks(client, {
|
|
32
|
-
url: `/api/v1/image_files/${
|
|
33
|
-
fileSize,
|
|
50
|
+
url: `/api/v1/image_files/${uploadDetails.id}/upload`,
|
|
51
|
+
fileSize: uploadDetails.byte_size,
|
|
34
52
|
fileStream,
|
|
35
53
|
maxSize: MAX_IMAGE_SIZE
|
|
36
54
|
});
|
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { Client } from '../client.
|
|
2
|
+
import { Client } from '../client.js';
|
|
3
3
|
export declare const CreateISOBMFFFilePayload: z.ZodObject<{
|
|
4
4
|
md5: z.ZodString;
|
|
5
5
|
filename: z.ZodString;
|
|
6
6
|
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
md5: string;
|
|
8
7
|
filename: string;
|
|
9
|
-
}, {
|
|
10
8
|
md5: string;
|
|
9
|
+
}, {
|
|
11
10
|
filename: string;
|
|
11
|
+
md5: string;
|
|
12
12
|
}>;
|
|
13
|
+
export type CreateISOBMFFFilePayload = z.infer<typeof CreateISOBMFFFilePayload>;
|
|
13
14
|
export interface CreateISOBMFFFileResult {
|
|
15
|
+
/**
|
|
16
|
+
* Whether the fragment index is complete. The fragment index is used internally by editframe to efficiently seek within files.
|
|
17
|
+
*/
|
|
14
18
|
fragment_index_complete: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The filename of the isobmff file
|
|
21
|
+
*/
|
|
15
22
|
filename: string;
|
|
23
|
+
/**
|
|
24
|
+
* The id of the isobmff file
|
|
25
|
+
*/
|
|
16
26
|
id: string;
|
|
27
|
+
/**
|
|
28
|
+
* The md5 hash of the isobmff file
|
|
29
|
+
*/
|
|
17
30
|
md5: string;
|
|
18
31
|
}
|
|
19
32
|
export interface LookupISOBMFFFileByMd5Result {
|
|
33
|
+
/**
|
|
34
|
+
* Whether the fragment index is complete
|
|
35
|
+
*/
|
|
20
36
|
fragment_index_complete: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The filename of the isobmff file
|
|
39
|
+
*/
|
|
21
40
|
filename: string;
|
|
22
41
|
id: string;
|
|
23
42
|
md5: string;
|
|
@@ -29,7 +48,21 @@ export interface GetISOBMFFFileTranscriptionResult {
|
|
|
29
48
|
duration_ms: number;
|
|
30
49
|
};
|
|
31
50
|
}
|
|
32
|
-
export declare const createISOBMFFFile: (client: Client, payload:
|
|
51
|
+
export declare const createISOBMFFFile: (client: Client, payload: CreateISOBMFFFilePayload) => Promise<CreateISOBMFFFileResult>;
|
|
33
52
|
export declare const uploadFragmentIndex: (client: Client, fileId: string, fileStream: ReadableStream, fileSize: number) => Promise<any>;
|
|
34
53
|
export declare const lookupISOBMFFFileByMd5: (client: Client, md5: string) => Promise<LookupISOBMFFFileByMd5Result | null>;
|
|
35
54
|
export declare const getISOBMFFFileTranscription: (client: Client, id: string) => Promise<GetISOBMFFFileTranscriptionResult | null>;
|
|
55
|
+
export declare const TranscribeISOBMFFFilePayload: z.ZodObject<{
|
|
56
|
+
trackId: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
trackId?: string | undefined;
|
|
59
|
+
}, {
|
|
60
|
+
trackId?: string | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
export type TranscribeISOBMFFFilePayload = z.infer<typeof TranscribeISOBMFFFilePayload>;
|
|
63
|
+
export interface TranscribeISOBMFFFileResult {
|
|
64
|
+
id: string;
|
|
65
|
+
file_id: string;
|
|
66
|
+
track_id: number;
|
|
67
|
+
}
|
|
68
|
+
export declare const transcribeISOBMFFFile: (client: Client, id: string, payload?: TranscribeISOBMFFFilePayload) => Promise<TranscribeISOBMFFFileResult>;
|
|
@@ -73,10 +73,30 @@ const getISOBMFFFileTranscription = async (client, id) => {
|
|
|
73
73
|
`Failed to get isobmff file transcription ${id} ${response.status} ${response.statusText}`
|
|
74
74
|
);
|
|
75
75
|
};
|
|
76
|
+
const TranscribeISOBMFFFilePayload = z.object({
|
|
77
|
+
trackId: z.string().optional()
|
|
78
|
+
});
|
|
79
|
+
const transcribeISOBMFFFile = async (client, id, payload = {}) => {
|
|
80
|
+
const response = await client.authenticatedFetch(
|
|
81
|
+
`/api/v1/isobmff_files/${id}/transcribe`,
|
|
82
|
+
{
|
|
83
|
+
method: "POST",
|
|
84
|
+
body: JSON.stringify(payload)
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
if (response.ok) {
|
|
88
|
+
return await response.json();
|
|
89
|
+
}
|
|
90
|
+
throw new Error(
|
|
91
|
+
`Failed to transcribe isobmff file ${id} ${response.status} ${response.statusText}`
|
|
92
|
+
);
|
|
93
|
+
};
|
|
76
94
|
export {
|
|
77
95
|
CreateISOBMFFFilePayload,
|
|
96
|
+
TranscribeISOBMFFFilePayload,
|
|
78
97
|
createISOBMFFFile,
|
|
79
98
|
getISOBMFFFileTranscription,
|
|
80
99
|
lookupISOBMFFFileByMd5,
|
|
100
|
+
transcribeISOBMFFFile,
|
|
81
101
|
uploadFragmentIndex
|
|
82
102
|
};
|