@editframe/api 0.24.1-beta.0 → 0.25.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CHUNK_SIZE_BYTES.js +4 -0
- package/dist/CHUNK_SIZE_BYTES.js.map +1 -0
- package/dist/ProgressIterator.d.ts +26 -22
- package/dist/ProgressIterator.js +5 -1
- package/dist/ProgressIterator.js.map +1 -0
- package/dist/StreamEventSource.d.ts +58 -54
- package/dist/StreamEventSource.js +6 -1
- package/dist/StreamEventSource.js.map +1 -0
- package/dist/client.d.ts +13 -8
- package/dist/client.js +6 -1
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +14 -13
- package/dist/index.js +4 -3
- package/dist/node.d.ts +22 -7
- package/dist/node.js +8 -3
- package/dist/node.js.map +1 -0
- package/dist/resources/caption-file.d.ts +56 -51
- package/dist/resources/caption-file.js +25 -3
- package/dist/resources/caption-file.js.map +1 -0
- package/dist/resources/image-file.d.ts +109 -104
- package/dist/resources/image-file.js +8 -3
- package/dist/resources/image-file.js.map +1 -0
- package/dist/resources/isobmff-file.d.ts +63 -58
- package/dist/resources/isobmff-file.js +7 -2
- package/dist/resources/isobmff-file.js.map +1 -0
- package/dist/resources/isobmff-track.d.ts +604 -598
- package/dist/resources/isobmff-track.js +7 -2
- package/dist/resources/isobmff-track.js.map +1 -0
- package/dist/resources/process-isobmff.d.ts +16 -11
- package/dist/resources/process-isobmff.js +5 -0
- package/dist/resources/process-isobmff.js.map +1 -0
- package/dist/resources/renders.bundle.d.ts +7 -4
- package/dist/resources/renders.bundle.js +6 -1
- package/dist/resources/renders.bundle.js.map +1 -0
- package/dist/resources/renders.d.ts +229 -367
- package/dist/resources/renders.js +13 -8
- package/dist/resources/renders.js.map +1 -0
- package/dist/resources/transcriptions.d.ts +25 -20
- package/dist/resources/transcriptions.js +6 -1
- package/dist/resources/transcriptions.js.map +1 -0
- package/dist/resources/unprocessed-file.d.ts +36 -35
- package/dist/resources/unprocessed-file.js +8 -3
- package/dist/resources/unprocessed-file.js.map +1 -0
- package/dist/resources/url-token.d.ts +9 -4
- package/dist/resources/url-token.js +6 -1
- package/dist/resources/url-token.js.map +1 -0
- package/dist/streamChunker.js +5 -0
- package/dist/streamChunker.js.map +1 -0
- package/dist/uploadChunks.d.ts +9 -16
- package/dist/uploadChunks.js +7 -2
- package/dist/uploadChunks.js.map +1 -0
- package/dist/utils/assertTypesMatch.js +4 -0
- package/dist/utils/assertTypesMatch.js.map +1 -0
- package/dist/utils/createReadableStreamFromReadable.d.ts +8 -3
- package/dist/utils/createReadableStreamFromReadable.js +5 -0
- package/dist/utils/createReadableStreamFromReadable.js.map +1 -0
- package/package.json +14 -33
- package/src/resources/renders.bundle.ts +1 -1
- package/tsdown.config.ts +10 -0
- package/dist/CHUNK_SIZE_BYTES.d.ts +0 -1
- package/dist/ProgressIterator.test.d.ts +0 -1
- package/dist/StreamEventSource.test.d.ts +0 -1
- package/dist/client.test.d.ts +0 -1
- package/dist/readableFromBuffers.d.ts +0 -1
- package/dist/resources/caption-file.test.d.ts +0 -1
- package/dist/resources/image-file.test.d.ts +0 -1
- package/dist/resources/isobmff-file.test.d.ts +0 -1
- package/dist/resources/isobmff-track.test.d.ts +0 -1
- package/dist/resources/process-isobmff.test.d.ts +0 -1
- package/dist/resources/renders.test.d.ts +0 -1
- package/dist/resources/transcriptions.test.d.ts +0 -1
- package/dist/resources/unprocessed-file.test.d.ts +0 -1
- package/dist/resources/url-token.test.d.ts +0 -1
- package/dist/streamChunker.d.ts +0 -1
- package/dist/streamChunker.test.d.ts +0 -1
- package/dist/uploadChunks.test.d.ts +0 -1
- package/dist/utils/assertTypesMatch.d.ts +0 -3
package/dist/CHUNK_SIZE_BYTES.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
//#region src/CHUNK_SIZE_BYTES.ts
|
|
1
2
|
let CHUNK_SIZE_BYTES = 8 * 1024 * 1024;
|
|
2
3
|
if ("process" in globalThis && process.env.CHUNK_SIZE_BYTES) CHUNK_SIZE_BYTES = Number.parseInt(process.env.CHUNK_SIZE_BYTES, 10);
|
|
4
|
+
|
|
5
|
+
//#endregion
|
|
3
6
|
export { CHUNK_SIZE_BYTES };
|
|
7
|
+
//# sourceMappingURL=CHUNK_SIZE_BYTES.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CHUNK_SIZE_BYTES.js","names":[],"sources":["../src/CHUNK_SIZE_BYTES.ts"],"sourcesContent":["export let CHUNK_SIZE_BYTES = 8 * 1024 * 1024; // 8MiB\n\nif (\"process\" in globalThis && process.env.CHUNK_SIZE_BYTES) {\n CHUNK_SIZE_BYTES = Number.parseInt(process.env.CHUNK_SIZE_BYTES, 10);\n}\n"],"mappings":";AAAA,IAAW,mBAAmB,IAAI,OAAO;AAEzC,IAAI,aAAa,cAAc,QAAQ,IAAI,iBACzC,oBAAmB,OAAO,SAAS,QAAQ,IAAI,kBAAkB,GAAG"}
|
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import { CompleteEvent, ProgressEvent, StreamEventSource } from
|
|
1
|
+
import { CompleteEvent, ProgressEvent, StreamEventSource } from "./StreamEventSource.js";
|
|
2
|
+
|
|
3
|
+
//#region src/ProgressIterator.d.ts
|
|
2
4
|
declare abstract class BaseEventIterator<T extends CompleteEvent | any> implements AsyncIterable<T> {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
protected eventSource: StreamEventSource;
|
|
6
|
+
protected queue: T[];
|
|
7
|
+
protected index: number;
|
|
8
|
+
protected isComplete: boolean;
|
|
9
|
+
protected resolversNext: PromiseWithResolvers<void>;
|
|
10
|
+
constructor(eventSource: StreamEventSource);
|
|
11
|
+
whenComplete(): Promise<T[]>;
|
|
12
|
+
on: (event: "progress", callback: (event: ProgressEvent) => void) => this;
|
|
13
|
+
protected push(event: T): void;
|
|
14
|
+
protected get queueLength(): number;
|
|
15
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
declare class ProgressIterator extends BaseEventIterator<ProgressEvent | CompleteEvent> {
|
|
18
|
+
constructor(eventSource: StreamEventSource);
|
|
19
|
+
private initializeListeners;
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
declare class CompletionIterator extends BaseEventIterator<CompleteEvent | ProgressEvent> {
|
|
22
|
+
private totalSize;
|
|
23
|
+
private currentProgress;
|
|
24
|
+
constructor(eventSource: StreamEventSource);
|
|
25
|
+
private initializeListeners;
|
|
26
|
+
abort(): void;
|
|
25
27
|
}
|
|
26
|
-
|
|
28
|
+
//#endregion
|
|
29
|
+
export { CompletionIterator, ProgressIterator };
|
|
30
|
+
//# sourceMappingURL=ProgressIterator.d.ts.map
|
package/dist/ProgressIterator.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/ProgressIterator.ts
|
|
2
|
+
const promiseWithResolvers = () => {
|
|
2
3
|
if (typeof Promise.withResolvers === "function") return Promise.withResolvers();
|
|
3
4
|
let resolve;
|
|
4
5
|
let reject;
|
|
@@ -100,4 +101,7 @@ var CompletionIterator = class extends BaseEventIterator {
|
|
|
100
101
|
this.eventSource.abort();
|
|
101
102
|
}
|
|
102
103
|
};
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
103
106
|
export { CompletionIterator, ProgressIterator };
|
|
107
|
+
//# sourceMappingURL=ProgressIterator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressIterator.js","names":["resolve!: (value: T | PromiseLike<T>) => void","reject!: (reason?: any) => void"],"sources":["../src/ProgressIterator.ts"],"sourcesContent":["import type {\n CompleteEvent,\n ProgressEvent,\n StreamEventSource,\n} from \"./StreamEventSource.js\";\n\nconst promiseWithResolvers = <T>() => {\n if (typeof Promise.withResolvers === \"function\") {\n return Promise.withResolvers<T>();\n }\n\n let resolve!: (value: T | PromiseLike<T>) => void;\n let reject!: (reason?: any) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n};\n\nabstract class BaseEventIterator<T extends CompleteEvent | any>\n implements AsyncIterable<T>\n{\n protected eventSource: StreamEventSource;\n protected queue: T[] = [];\n protected index = 0;\n protected isComplete = false;\n protected resolversNext = promiseWithResolvers<void>();\n\n constructor(eventSource: StreamEventSource) {\n this.eventSource = eventSource;\n }\n\n async whenComplete() {\n for await (const _ of this) {\n }\n return this.queue;\n }\n\n declare on: (\n event: \"progress\",\n callback: (event: ProgressEvent) => void,\n ) => this;\n\n protected push(event: T) {\n this.queue.push(event);\n this.resolversNext.resolve();\n this.resolversNext = promiseWithResolvers<void>();\n }\n\n protected get queueLength() {\n return this.queue.length - this.index;\n }\n\n async *[Symbol.asyncIterator](): AsyncIterator<T> {\n try {\n while (!this.isComplete || this.queueLength > 0) {\n if (this.queueLength === 0) {\n await this.resolversNext.promise;\n } else {\n const item = this.queue[this.index];\n if (!item) {\n throw new Error(\"Queue is corrupted\");\n }\n this.index++;\n yield item;\n }\n }\n } finally {\n this.eventSource.close();\n }\n }\n}\n\n// Progress-only iterator\nexport class ProgressIterator extends BaseEventIterator<\n ProgressEvent | CompleteEvent\n> {\n constructor(eventSource: StreamEventSource) {\n super(eventSource);\n this.initializeListeners();\n }\n\n private initializeListeners() {\n this.eventSource.on(\"progress\", (event) => {\n this.push(event);\n });\n\n this.eventSource.on(\"complete\", (event) => {\n this.isComplete = true;\n this.push(event);\n });\n\n this.eventSource.on(\"error\", (error) => {\n this.eventSource.close();\n this.resolversNext.reject(error);\n });\n }\n}\n\n// Size and Completion iterator\nexport class CompletionIterator extends BaseEventIterator<\n CompleteEvent | ProgressEvent\n> {\n private totalSize = 0;\n private currentProgress = 0;\n\n constructor(eventSource: StreamEventSource) {\n super(eventSource);\n this.initializeListeners();\n }\n\n private initializeListeners() {\n this.eventSource.on(\"size\", (event) => {\n this.totalSize = event.data.size;\n this.push({\n type: \"progress\",\n data: {\n progress: 0,\n },\n });\n });\n\n this.eventSource.on(\"completion\", (event) => {\n this.currentProgress += Number(event.data.count);\n\n this.push({\n type: \"progress\",\n data: {\n progress: this.currentProgress / this.totalSize,\n },\n });\n\n if (this.currentProgress >= this.totalSize) {\n this.isComplete = true;\n }\n });\n\n this.eventSource.on(\"complete\", (event) => {\n this.isComplete = true;\n this.push(event);\n });\n\n this.eventSource.on(\"error\", (error) => {\n this.eventSource.close();\n this.resolversNext.reject(error);\n });\n }\n\n abort() {\n this.eventSource.abort();\n }\n}\n"],"mappings":";AAMA,MAAM,6BAAgC;AACpC,KAAI,OAAO,QAAQ,kBAAkB,WACnC,QAAO,QAAQ,eAAkB;CAGnC,IAAIA;CACJ,IAAIC;AAKJ,QAAO;EAAE,SAJO,IAAI,SAAY,KAAK,QAAQ;AAC3C,aAAU;AACV,YAAS;IACT;EACgB;EAAS;EAAQ;;AAGrC,IAAe,oBAAf,MAEA;CAOE,YAAY,aAAgC;eALrB,EAAE;eACP;oBACK;uBACG,sBAA4B;AAGpD,OAAK,cAAc;;CAGrB,MAAM,eAAe;AACnB,aAAW,MAAM,KAAK;AAEtB,SAAO,KAAK;;CAQd,AAAU,KAAK,OAAU;AACvB,OAAK,MAAM,KAAK,MAAM;AACtB,OAAK,cAAc,SAAS;AAC5B,OAAK,gBAAgB,sBAA4B;;CAGnD,IAAc,cAAc;AAC1B,SAAO,KAAK,MAAM,SAAS,KAAK;;CAGlC,QAAQ,OAAO,iBAAmC;AAChD,MAAI;AACF,UAAO,CAAC,KAAK,cAAc,KAAK,cAAc,EAC5C,KAAI,KAAK,gBAAgB,EACvB,OAAM,KAAK,cAAc;QACpB;IACL,MAAM,OAAO,KAAK,MAAM,KAAK;AAC7B,QAAI,CAAC,KACH,OAAM,IAAI,MAAM,qBAAqB;AAEvC,SAAK;AACL,UAAM;;YAGF;AACR,QAAK,YAAY,OAAO;;;;AAM9B,IAAa,mBAAb,cAAsC,kBAEpC;CACA,YAAY,aAAgC;AAC1C,QAAM,YAAY;AAClB,OAAK,qBAAqB;;CAG5B,AAAQ,sBAAsB;AAC5B,OAAK,YAAY,GAAG,aAAa,UAAU;AACzC,QAAK,KAAK,MAAM;IAChB;AAEF,OAAK,YAAY,GAAG,aAAa,UAAU;AACzC,QAAK,aAAa;AAClB,QAAK,KAAK,MAAM;IAChB;AAEF,OAAK,YAAY,GAAG,UAAU,UAAU;AACtC,QAAK,YAAY,OAAO;AACxB,QAAK,cAAc,OAAO,MAAM;IAChC;;;AAKN,IAAa,qBAAb,cAAwC,kBAEtC;CAIA,YAAY,aAAgC;AAC1C,QAAM,YAAY;mBAJA;yBACM;AAIxB,OAAK,qBAAqB;;CAG5B,AAAQ,sBAAsB;AAC5B,OAAK,YAAY,GAAG,SAAS,UAAU;AACrC,QAAK,YAAY,MAAM,KAAK;AAC5B,QAAK,KAAK;IACR,MAAM;IACN,MAAM,EACJ,UAAU,GACX;IACF,CAAC;IACF;AAEF,OAAK,YAAY,GAAG,eAAe,UAAU;AAC3C,QAAK,mBAAmB,OAAO,MAAM,KAAK,MAAM;AAEhD,QAAK,KAAK;IACR,MAAM;IACN,MAAM,EACJ,UAAU,KAAK,kBAAkB,KAAK,WACvC;IACF,CAAC;AAEF,OAAI,KAAK,mBAAmB,KAAK,UAC/B,MAAK,aAAa;IAEpB;AAEF,OAAK,YAAY,GAAG,aAAa,UAAU;AACzC,QAAK,aAAa;AAClB,QAAK,KAAK,MAAM;IAChB;AAEF,OAAK,YAAY,GAAG,UAAU,UAAU;AACtC,QAAK,YAAY,OAAO;AACxB,QAAK,cAAc,OAAO,MAAM;IAChC;;CAGJ,QAAQ;AACN,OAAK,YAAY,OAAO"}
|
|
@@ -1,61 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
//#region src/StreamEventSource.d.ts
|
|
2
|
+
type EventCallback<T> = (event: T) => void;
|
|
3
|
+
type StreamEventSourceEventMap = {
|
|
4
|
+
progress: ProgressEvent;
|
|
5
|
+
complete: CompleteEvent;
|
|
6
|
+
size: SizeEvent;
|
|
7
|
+
completion: CompletionEvent;
|
|
8
|
+
heartbeat: HeartbeatEvent;
|
|
9
|
+
message: {
|
|
10
|
+
id: string | undefined;
|
|
11
|
+
data: string;
|
|
12
|
+
};
|
|
13
|
+
end: Array<unknown>;
|
|
14
|
+
error: Error;
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
type ProgressEvent = {
|
|
17
|
+
type: "progress";
|
|
18
|
+
data: {
|
|
19
|
+
/** Progress events are sent as a percentage of the total render time.
|
|
20
|
+
* This is a number between 0 and 1.
|
|
21
|
+
*/
|
|
22
|
+
progress: number;
|
|
23
|
+
};
|
|
23
24
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
type CompleteEvent = {
|
|
26
|
+
type: "complete";
|
|
27
|
+
data: object;
|
|
27
28
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
type SizeEvent = {
|
|
30
|
+
type: "size";
|
|
31
|
+
data: {
|
|
32
|
+
size: number;
|
|
33
|
+
};
|
|
33
34
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
type CompletionEvent = {
|
|
36
|
+
type: "completion";
|
|
37
|
+
data: {
|
|
38
|
+
count: number;
|
|
39
|
+
};
|
|
39
40
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
type HeartbeatEvent = {
|
|
42
|
+
type: "heartbeat";
|
|
43
|
+
data: {
|
|
44
|
+
timestamp: string;
|
|
45
|
+
};
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
declare class StreamEventSource {
|
|
48
|
+
private stream;
|
|
49
|
+
private activeReader;
|
|
50
|
+
private decoder;
|
|
51
|
+
private parser;
|
|
52
|
+
private listeners;
|
|
53
|
+
private abortController;
|
|
54
|
+
constructor(stream: ReadableStream, abortController: AbortController);
|
|
55
|
+
on<K extends keyof StreamEventSourceEventMap>(event: K, callback: EventCallback<StreamEventSourceEventMap[K]>): this;
|
|
56
|
+
off<K extends keyof StreamEventSourceEventMap>(event: K, callback: EventCallback<StreamEventSourceEventMap[K]>): this;
|
|
57
|
+
protected emit<K extends keyof StreamEventSourceEventMap>(event: K, data: StreamEventSourceEventMap[K]): void;
|
|
58
|
+
whenClosed(): Promise<void>;
|
|
59
|
+
private startReading;
|
|
60
|
+
close(): void;
|
|
61
|
+
abort(): void;
|
|
61
62
|
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { CompleteEvent, CompletionEvent, EventCallback, ProgressEvent, StreamEventSource, StreamEventSourceEventMap };
|
|
65
|
+
//# sourceMappingURL=StreamEventSource.d.ts.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import debug from "debug";
|
|
2
2
|
import { createParser } from "eventsource-parser";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
//#region src/StreamEventSource.ts
|
|
5
|
+
const log = debug("ef:StreamEventSource");
|
|
4
6
|
var StreamEventSource = class {
|
|
5
7
|
constructor(stream, abortController) {
|
|
6
8
|
this.activeReader = null;
|
|
@@ -116,4 +118,7 @@ var StreamEventSource = class {
|
|
|
116
118
|
this.abortController.abort();
|
|
117
119
|
}
|
|
118
120
|
};
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
119
123
|
export { StreamEventSource };
|
|
124
|
+
//# sourceMappingURL=StreamEventSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamEventSource.js","names":[],"sources":["../src/StreamEventSource.ts"],"sourcesContent":["import debug from \"debug\";\nimport { createParser } from \"eventsource-parser\";\n\nconst log = debug(\"ef:StreamEventSource\");\n\nexport type EventCallback<T> = (event: T) => void;\nexport type StreamEventSourceEventMap = {\n progress: ProgressEvent;\n complete: CompleteEvent;\n size: SizeEvent;\n completion: CompletionEvent;\n heartbeat: HeartbeatEvent;\n message: {\n id: string | undefined;\n data: string;\n };\n end: Array<unknown>;\n error: Error;\n};\n\nexport type ProgressEvent = {\n type: \"progress\";\n data: {\n /** Progress events are sent as a percentage of the total render time.\n * This is a number between 0 and 1.\n */\n progress: number;\n };\n};\nexport type CompleteEvent = { type: \"complete\"; data: object };\nexport type SizeEvent = { type: \"size\"; data: { size: number } };\nexport type CompletionEvent = { type: \"completion\"; data: { count: number } };\nexport type HeartbeatEvent = { type: \"heartbeat\"; data: { timestamp: string } };\n\nexport class StreamEventSource {\n private stream: ReadableStream;\n private activeReader: ReadableStreamDefaultReader<Uint8Array> | null = null;\n private decoder = new TextDecoder();\n private parser;\n private listeners: {\n [K in keyof StreamEventSourceEventMap]?: EventCallback<\n StreamEventSourceEventMap[K]\n >[];\n } = {};\n private abortController: AbortController;\n constructor(stream: ReadableStream, abortController: AbortController) {\n if (!stream) {\n console.error(\"StreamEventSource: Stream is null or undefined\");\n throw new Error(\"Stream is required\");\n }\n this.stream = stream;\n this.abortController = abortController;\n\n // Create parser instance\n this.parser = createParser({\n onError: (err) => {\n console.error(\"StreamEventSource: Parser error:\", err);\n this.emit(\"error\", err);\n },\n onEvent: (event) => {\n if (event.event) {\n switch (event.event) {\n case \"heartbeat\":\n this.emit(\"heartbeat\", {\n type: \"heartbeat\",\n data: JSON.parse(event.data),\n });\n break;\n case \"size\":\n this.emit(\"size\", {\n type: \"size\",\n data: JSON.parse(event.data),\n });\n break;\n case \"completion\":\n this.emit(\"completion\", {\n type: \"completion\",\n data: JSON.parse(event.data),\n });\n break;\n case \"progress\":\n this.emit(\"progress\", {\n type: \"progress\",\n data: JSON.parse(event.data),\n });\n break;\n case \"complete\":\n this.emit(\"complete\", {\n type: \"complete\",\n data: JSON.parse(event.data),\n });\n break;\n case \"error\":\n log(\"StreamEventSource: Error event\", event.data);\n this.emit(\"error\", new Error(event.data));\n break;\n default:\n this.emit(\n \"error\",\n new Error(`Unknown event: ${event.event} data: ${event.data}`),\n );\n }\n } else {\n this.emit(\"message\", {\n id: event.id,\n data: event.data,\n });\n }\n },\n });\n\n this.startReading().catch((error) => {\n console.error(\"StreamEventSource: Error in startReading:\", error);\n this.emit(\"error\", error);\n });\n\n this.abortController.signal.addEventListener(\"abort\", () => {\n this.close();\n });\n }\n\n on<K extends keyof StreamEventSourceEventMap>(\n event: K,\n callback: EventCallback<StreamEventSourceEventMap[K]>,\n ) {\n if (!this.listeners[event]) {\n this.listeners[event] = [];\n }\n this.listeners[event]?.push(callback);\n return this;\n }\n\n off<K extends keyof StreamEventSourceEventMap>(\n event: K,\n callback: EventCallback<StreamEventSourceEventMap[K]>,\n ) {\n const listeners = this.listeners[event];\n if (listeners) {\n const index = listeners.indexOf(callback);\n if (index !== -1) {\n listeners.splice(index, 1);\n }\n }\n return this;\n }\n\n protected emit<K extends keyof StreamEventSourceEventMap>(\n event: K,\n data: StreamEventSourceEventMap[K],\n ) {\n for (const callback of this.listeners[event] ?? []) {\n callback(data);\n }\n }\n\n whenClosed() {\n return new Promise<void>((resolve) => {\n this.on(\"end\", () => resolve());\n });\n }\n\n private async startReading() {\n try {\n this.activeReader = this.stream.getReader();\n while (true) {\n const { done, value } = await this.activeReader.read();\n if (done) break;\n\n const chunk = this.decoder.decode(value);\n if (!value) {\n throw new Error(\"Chunk is null\");\n }\n this.parser.feed(chunk);\n }\n this.activeReader = null;\n this.emit(\"end\", []);\n } catch (error) {\n console.error(\"StreamEventSource: Error reading stream:\", error);\n if (error instanceof Error) {\n this.emit(\"error\", error);\n } else {\n this.emit(\"error\", new Error(String(error)));\n }\n }\n }\n\n close() {\n if (this.activeReader) {\n this.activeReader = null;\n }\n this.parser.reset();\n }\n\n abort() {\n this.abortController.abort();\n }\n}\n"],"mappings":"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"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { StreamEventSource } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { StreamEventSource } from "./StreamEventSource.js";
|
|
2
|
+
|
|
3
|
+
//#region src/client.d.ts
|
|
4
|
+
declare class Client {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(token?: string, efHost?: string);
|
|
7
|
+
authenticatedEventSource: (path: string, init?: RequestInit) => Promise<StreamEventSource>;
|
|
8
|
+
authenticatedFetch: (path: string, init?: RequestInit & {
|
|
9
|
+
duplex?: "half";
|
|
10
|
+
}) => Promise<Response>;
|
|
9
11
|
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Client };
|
|
14
|
+
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { StreamEventSource } from "./StreamEventSource.js";
|
|
2
2
|
import debug from "debug";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
//#region src/client.ts
|
|
5
|
+
const log = debug("ef:api:client");
|
|
4
6
|
var Client = class {
|
|
5
7
|
#token;
|
|
6
8
|
#efHost;
|
|
@@ -44,4 +46,7 @@ var Client = class {
|
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
47
51
|
export { Client };
|
|
52
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":["requestInit: RequestInit","#efHost","#token"],"sources":["../src/client.ts"],"sourcesContent":["import debug from \"debug\";\nimport { StreamEventSource } from \"./StreamEventSource.js\";\n\nconst log = debug(\"ef:api:client\");\n\nexport class Client {\n #token?: string;\n #efHost: string;\n\n constructor(token?: string, efHost = \"https://editframe.dev\") {\n log(\"Creating client with efHost\", { efHost, tokenIsSet: !!token });\n this.#token = token;\n this.#efHost = efHost;\n\n // Only validate token if provided\n if (token) {\n const { apiKey, apiSecret } =\n token.match(/^(?<apiSecret>ef_[^_]+)_(?<apiKey>.+)$/)?.groups ?? {};\n\n if (!apiKey || !apiSecret) {\n throw new Error(\"Invalid token format. Must look like: ef_{}_{}\");\n }\n }\n }\n\n authenticatedEventSource = async (path: string, init: RequestInit = {}) => {\n const abortController = new AbortController();\n\n const requestInit: RequestInit = {\n ...init,\n };\n\n // if (process.env.NODE_ENV !== \"test\") {\n requestInit.signal ??= abortController.signal;\n // }\n\n const response = await this.authenticatedFetch(path, requestInit);\n if (response.body === null) {\n throw new Error(\"Could not create event source. Response body is null.\");\n }\n\n return new StreamEventSource(response.body, abortController);\n };\n\n authenticatedFetch = async (\n path: string,\n init: RequestInit & { duplex?: \"half\" } = {},\n ) => {\n init.headers ||= {};\n const url = new URL(path, this.#efHost);\n\n log(\n \"Authenticated fetch\",\n { url: url.toString(), init },\n this.#token\n ? \"(Token will be added as Bearer token)\"\n : \"(Using session cookie)\",\n );\n\n // Only add Authorization header if token is present\n if (this.#token) {\n Object.assign(init.headers, {\n Authorization: `Bearer ${this.#token}`,\n });\n }\n\n // Always include Content-Type\n Object.assign(init.headers, {\n \"Content-Type\": \"application/json\",\n });\n\n // Add credentials: 'include' for cookie support\n init.credentials = \"include\";\n\n try {\n const response = await fetch(url, init);\n\n log(\"Authenticated fetch response\", response.status, response.statusText);\n return response;\n } catch (error) {\n console.error(\"Client authenticatedFetch error\", url, error);\n throw error;\n }\n };\n}\n"],"mappings":";;;;AAGA,MAAM,MAAM,MAAM,gBAAgB;AAElC,IAAa,SAAb,MAAoB;CAClB;CACA;CAEA,YAAY,OAAgB,SAAS,yBAAyB;kCAgBnC,OAAO,MAAc,OAAoB,EAAE,KAAK;GACzE,MAAM,kBAAkB,IAAI,iBAAiB;GAE7C,MAAMA,cAA2B,EAC/B,GAAG,MACJ;AAGD,eAAY,WAAW,gBAAgB;GAGvC,MAAM,WAAW,MAAM,KAAK,mBAAmB,MAAM,YAAY;AACjE,OAAI,SAAS,SAAS,KACpB,OAAM,IAAI,MAAM,wDAAwD;AAG1E,UAAO,IAAI,kBAAkB,SAAS,MAAM,gBAAgB;;4BAGzC,OACnB,MACA,OAA0C,EAAE,KACzC;AACH,QAAK,YAAY,EAAE;GACnB,MAAM,MAAM,IAAI,IAAI,MAAM,MAAKC,OAAQ;AAEvC,OACE,uBACA;IAAE,KAAK,IAAI,UAAU;IAAE;IAAM,EAC7B,MAAKC,QACD,0CACA,yBACL;AAGD,OAAI,MAAKA,MACP,QAAO,OAAO,KAAK,SAAS,EAC1B,eAAe,UAAU,MAAKA,SAC/B,CAAC;AAIJ,UAAO,OAAO,KAAK,SAAS,EAC1B,gBAAgB,oBACjB,CAAC;AAGF,QAAK,cAAc;AAEnB,OAAI;IACF,MAAM,WAAW,MAAM,MAAM,KAAK,KAAK;AAEvC,QAAI,gCAAgC,SAAS,QAAQ,SAAS,WAAW;AACzE,WAAO;YACA,OAAO;AACd,YAAQ,MAAM,mCAAmC,KAAK,MAAM;AAC5D,UAAM;;;AAvER,MAAI,+BAA+B;GAAE;GAAQ,YAAY,CAAC,CAAC;GAAO,CAAC;AACnE,QAAKA,QAAS;AACd,QAAKD,SAAU;AAGf,MAAI,OAAO;GACT,MAAM,EAAE,QAAQ,cACd,MAAM,MAAM,yCAAyC,EAAE,UAAU,EAAE;AAErE,OAAI,CAAC,UAAU,CAAC,UACd,OAAM,IAAI,MAAM,iDAAiD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { CompletionEvent, EventCallback, ProgressEvent, StreamEventSource, StreamEventSourceEventMap } from "./StreamEventSource.js";
|
|
2
|
+
import { Client } from "./client.js";
|
|
3
|
+
import { CompletionIterator, ProgressIterator } from "./ProgressIterator.js";
|
|
4
|
+
import { CreateCaptionFilePayload, CreateCaptionFileResult, LookupCaptionFileByMd5Result, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile } from "./resources/caption-file.js";
|
|
5
|
+
import { IteratorWithPromise, UploadChunkEvent } from "./uploadChunks.js";
|
|
6
|
+
import { CreateImageFilePayload, CreateImageFileResult, GetImageFileMetadataResult, ImageFileMimeTypes, LookupImageFileByMd5Result, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile } from "./resources/image-file.js";
|
|
7
|
+
import { CreateISOBMFFFilePayload, CreateISOBMFFFileResult, GetISOBMFFFileTranscriptionResult, LookupISOBMFFFileByMd5Result, TranscribeISOBMFFFilePayload, TranscribeISOBMFFFileResult, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex } from "./resources/isobmff-file.js";
|
|
8
|
+
import { AudioStreamSchema, AudioTrackPayload, CreateISOBMFFTrackPayload, CreateISOBMFFTrackResult, VideoStreamSchema, VideoTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
|
|
9
|
+
import { IsobmffProcessInfoResult, getIsobmffProcessInfo, getIsobmffProcessProgress } from "./resources/process-isobmff.js";
|
|
10
|
+
import { CreateRenderPayload, CreateRenderResult, LookupRenderByMd5Result, OutputConfiguration, RenderOutputConfiguration, createRender, downloadRender, getRenderInfo, getRenderProgress, lookupRenderByMd5, uploadRender } from "./resources/renders.js";
|
|
11
|
+
import { CreateTranscriptionPayload, CreateTranscriptionResult, TranscriptionInfoResult, createTranscription, getTranscriptionInfo, getTranscriptionProgress } from "./resources/transcriptions.js";
|
|
12
|
+
import { CreateUnprocessedFilePayload, CreateUnprocessedFileResult, LookupUnprocessedFileByMd5Result, ProcessIsobmffFileResult, UnprocessedFile, UnprocessedFileUploadDetails, createUnprocessedFile, lookupUnprocessedFileByMd5, processIsobmffFile, uploadUnprocessedReadableStream } from "./resources/unprocessed-file.js";
|
|
13
|
+
import { URLTokenResult, createURLToken } from "./resources/url-token.js";
|
|
14
|
+
export { type AudioStreamSchema, AudioTrackPayload, Client, type CompletionEvent, type CompletionIterator, CreateCaptionFilePayload, type CreateCaptionFileResult, CreateISOBMFFFilePayload, type CreateISOBMFFFileResult, CreateISOBMFFTrackPayload, type CreateISOBMFFTrackResult, CreateImageFilePayload, type CreateImageFileResult, CreateRenderPayload, type CreateRenderResult, CreateTranscriptionPayload, type CreateTranscriptionResult, CreateUnprocessedFilePayload, type CreateUnprocessedFileResult, type EventCallback, type GetISOBMFFFileTranscriptionResult, type GetImageFileMetadataResult, ImageFileMimeTypes, type IsobmffProcessInfoResult, type IteratorWithPromise, type LookupCaptionFileByMd5Result, type LookupISOBMFFFileByMd5Result, type LookupImageFileByMd5Result, type LookupRenderByMd5Result, type LookupUnprocessedFileByMd5Result, OutputConfiguration, type ProcessIsobmffFileResult, type ProgressEvent, type ProgressIterator, RenderOutputConfiguration, type StreamEventSource, type StreamEventSourceEventMap, TranscribeISOBMFFFilePayload, type TranscribeISOBMFFFileResult, type TranscriptionInfoResult, type URLTokenResult, type UnprocessedFile, type UnprocessedFileUploadDetails, type UploadChunkEvent, type VideoStreamSchema, VideoTrackPayload, createCaptionFile, createISOBMFFFile, createISOBMFFTrack, createImageFile, createRender, createTranscription, createURLToken, createUnprocessedFile, downloadRender, getISOBMFFFileTranscription, getImageFileMetadata, getIsobmffProcessInfo, getIsobmffProcessProgress, getRenderInfo, getRenderProgress, getTranscriptionInfo, getTranscriptionProgress, lookupCaptionFileByMd5, lookupISOBMFFFileByMd5, lookupImageFileByMd5, lookupRenderByMd5, lookupUnprocessedFileByMd5, processIsobmffFile, transcribeISOBMFFFile, uploadCaptionFile, uploadFragmentIndex, uploadISOBMFFTrack, uploadImageFile, uploadRender, uploadUnprocessedReadableStream };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { CreateImageFilePayload, ImageFileMimeTypes, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile } from "./resources/image-file.js";
|
|
2
|
-
import { CreateUnprocessedFilePayload, createUnprocessedFile, lookupUnprocessedFileByMd5, processIsobmffFile, uploadUnprocessedReadableStream } from "./resources/unprocessed-file.js";
|
|
3
1
|
import { Client } from "./client.js";
|
|
4
2
|
import { CreateCaptionFilePayload, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile } from "./resources/caption-file.js";
|
|
3
|
+
import { CreateImageFilePayload, ImageFileMimeTypes, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile } from "./resources/image-file.js";
|
|
5
4
|
import { CreateISOBMFFFilePayload, TranscribeISOBMFFFilePayload, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex } from "./resources/isobmff-file.js";
|
|
6
5
|
import { AudioTrackPayload, CreateISOBMFFTrackPayload, VideoTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
|
|
7
6
|
import { getIsobmffProcessInfo, getIsobmffProcessProgress } from "./resources/process-isobmff.js";
|
|
8
7
|
import { CreateRenderPayload, OutputConfiguration, RenderOutputConfiguration, createRender, downloadRender, getRenderInfo, getRenderProgress, lookupRenderByMd5, uploadRender } from "./resources/renders.js";
|
|
9
8
|
import { CreateTranscriptionPayload, createTranscription, getTranscriptionInfo, getTranscriptionProgress } from "./resources/transcriptions.js";
|
|
9
|
+
import { CreateUnprocessedFilePayload, createUnprocessedFile, lookupUnprocessedFileByMd5, processIsobmffFile, uploadUnprocessedReadableStream } from "./resources/unprocessed-file.js";
|
|
10
10
|
import { createURLToken } from "./resources/url-token.js";
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
export { AudioTrackPayload, Client, CreateCaptionFilePayload, CreateISOBMFFFilePayload, CreateISOBMFFTrackPayload, CreateImageFilePayload, CreateRenderPayload, CreateTranscriptionPayload, CreateUnprocessedFilePayload, ImageFileMimeTypes, OutputConfiguration, RenderOutputConfiguration, TranscribeISOBMFFFilePayload, VideoTrackPayload, createCaptionFile, createISOBMFFFile, createISOBMFFTrack, createImageFile, createRender, createTranscription, createURLToken, createUnprocessedFile, downloadRender, getISOBMFFFileTranscription, getImageFileMetadata, getIsobmffProcessInfo, getIsobmffProcessProgress, getRenderInfo, getRenderProgress, getTranscriptionInfo, getTranscriptionProgress, lookupCaptionFileByMd5, lookupISOBMFFFileByMd5, lookupImageFileByMd5, lookupRenderByMd5, lookupUnprocessedFileByMd5, processIsobmffFile, transcribeISOBMFFFile, uploadCaptionFile, uploadFragmentIndex, uploadISOBMFFTrack, uploadImageFile, uploadRender, uploadUnprocessedReadableStream };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { CompletionEvent, EventCallback, ProgressEvent, StreamEventSource, StreamEventSourceEventMap } from "./StreamEventSource.js";
|
|
2
|
+
import { Client } from "./client.js";
|
|
3
|
+
import { CompletionIterator, ProgressIterator } from "./ProgressIterator.js";
|
|
4
|
+
import { CreateCaptionFilePayload, CreateCaptionFileResult, LookupCaptionFileByMd5Result, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile } from "./resources/caption-file.js";
|
|
5
|
+
import { IteratorWithPromise, UploadChunkEvent } from "./uploadChunks.js";
|
|
6
|
+
import { CreateImageFilePayload, CreateImageFileResult, GetImageFileMetadataResult, ImageFileMimeTypes, LookupImageFileByMd5Result, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile } from "./resources/image-file.js";
|
|
7
|
+
import { CreateISOBMFFFilePayload, CreateISOBMFFFileResult, GetISOBMFFFileTranscriptionResult, LookupISOBMFFFileByMd5Result, TranscribeISOBMFFFilePayload, TranscribeISOBMFFFileResult, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex } from "./resources/isobmff-file.js";
|
|
8
|
+
import { AudioStreamSchema, AudioTrackPayload, CreateISOBMFFTrackPayload, CreateISOBMFFTrackResult, VideoStreamSchema, VideoTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
|
|
9
|
+
import { IsobmffProcessInfoResult, getIsobmffProcessInfo, getIsobmffProcessProgress } from "./resources/process-isobmff.js";
|
|
10
|
+
import { CreateRenderPayload, CreateRenderResult, LookupRenderByMd5Result, OutputConfiguration, RenderOutputConfiguration, createRender, downloadRender, getRenderInfo, getRenderProgress, lookupRenderByMd5, uploadRender } from "./resources/renders.js";
|
|
11
|
+
import { CreateTranscriptionPayload, CreateTranscriptionResult, TranscriptionInfoResult, createTranscription, getTranscriptionInfo, getTranscriptionProgress } from "./resources/transcriptions.js";
|
|
12
|
+
import { CreateUnprocessedFilePayload, CreateUnprocessedFileResult, LookupUnprocessedFileByMd5Result, ProcessIsobmffFileResult, UnprocessedFile, UnprocessedFileUploadDetails, createUnprocessedFile, lookupUnprocessedFileByMd5, processIsobmffFile, uploadUnprocessedReadableStream } from "./resources/unprocessed-file.js";
|
|
13
|
+
import { URLTokenResult, createURLToken } from "./resources/url-token.js";
|
|
14
|
+
import { createReadableStreamFromReadable } from "./utils/createReadableStreamFromReadable.js";
|
|
15
|
+
|
|
16
|
+
//#region src/node.d.ts
|
|
17
|
+
declare const createImageFileFromPath: (client: Client, path: string) => Promise<CreateImageFileResult>;
|
|
18
|
+
declare const createUnprocessedFileFromPath: (client: Client, path: string) => Promise<CreateUnprocessedFileResult>;
|
|
19
|
+
declare const uploadUnprocessedFile: (client: Client, uploadDetails: UnprocessedFileUploadDetails, path: string) => Promise<IteratorWithPromise<UploadChunkEvent>>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { AudioStreamSchema, AudioTrackPayload, Client, CompletionEvent, CompletionIterator, CreateCaptionFilePayload, CreateCaptionFileResult, CreateISOBMFFFilePayload, CreateISOBMFFFileResult, CreateISOBMFFTrackPayload, CreateISOBMFFTrackResult, CreateImageFilePayload, CreateImageFileResult, CreateRenderPayload, CreateRenderResult, CreateTranscriptionPayload, CreateTranscriptionResult, CreateUnprocessedFilePayload, CreateUnprocessedFileResult, EventCallback, GetISOBMFFFileTranscriptionResult, GetImageFileMetadataResult, ImageFileMimeTypes, IsobmffProcessInfoResult, IteratorWithPromise, LookupCaptionFileByMd5Result, LookupISOBMFFFileByMd5Result, LookupImageFileByMd5Result, LookupRenderByMd5Result, LookupUnprocessedFileByMd5Result, OutputConfiguration, ProcessIsobmffFileResult, ProgressEvent, ProgressIterator, RenderOutputConfiguration, StreamEventSource, StreamEventSourceEventMap, TranscribeISOBMFFFilePayload, TranscribeISOBMFFFileResult, TranscriptionInfoResult, URLTokenResult, UnprocessedFile, UnprocessedFileUploadDetails, UploadChunkEvent, VideoStreamSchema, VideoTrackPayload, createCaptionFile, createISOBMFFFile, createISOBMFFTrack, createImageFile, createImageFileFromPath, createReadableStreamFromReadable, createRender, createTranscription, createURLToken, createUnprocessedFile, createUnprocessedFileFromPath, downloadRender, getISOBMFFFileTranscription, getImageFileMetadata, getIsobmffProcessInfo, getIsobmffProcessProgress, getRenderInfo, getRenderProgress, getTranscriptionInfo, getTranscriptionProgress, lookupCaptionFileByMd5, lookupISOBMFFFileByMd5, lookupImageFileByMd5, lookupRenderByMd5, lookupUnprocessedFileByMd5, processIsobmffFile, transcribeISOBMFFFile, uploadCaptionFile, uploadFragmentIndex, uploadISOBMFFTrack, uploadImageFile, uploadRender, uploadUnprocessedFile, uploadUnprocessedReadableStream };
|
|
22
|
+
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { CreateImageFilePayload, ImageFileMimeTypes, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile } from "./resources/image-file.js";
|
|
2
|
-
import { CreateUnprocessedFilePayload, createUnprocessedFile, lookupUnprocessedFileByMd5, processIsobmffFile, uploadUnprocessedReadableStream } from "./resources/unprocessed-file.js";
|
|
3
|
-
import { createReadableStreamFromReadable } from "./utils/createReadableStreamFromReadable.js";
|
|
4
1
|
import { Client } from "./client.js";
|
|
5
2
|
import { CreateCaptionFilePayload, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile } from "./resources/caption-file.js";
|
|
3
|
+
import { CreateImageFilePayload, ImageFileMimeTypes, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile } from "./resources/image-file.js";
|
|
6
4
|
import { CreateISOBMFFFilePayload, TranscribeISOBMFFFilePayload, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex } from "./resources/isobmff-file.js";
|
|
7
5
|
import { AudioTrackPayload, CreateISOBMFFTrackPayload, VideoTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
|
|
8
6
|
import { getIsobmffProcessInfo, getIsobmffProcessProgress } from "./resources/process-isobmff.js";
|
|
9
7
|
import { CreateRenderPayload, OutputConfiguration, RenderOutputConfiguration, createRender, downloadRender, getRenderInfo, getRenderProgress, lookupRenderByMd5, uploadRender } from "./resources/renders.js";
|
|
10
8
|
import { CreateTranscriptionPayload, createTranscription, getTranscriptionInfo, getTranscriptionProgress } from "./resources/transcriptions.js";
|
|
9
|
+
import { CreateUnprocessedFilePayload, createUnprocessedFile, lookupUnprocessedFileByMd5, processIsobmffFile, uploadUnprocessedReadableStream } from "./resources/unprocessed-file.js";
|
|
11
10
|
import { createURLToken } from "./resources/url-token.js";
|
|
12
11
|
import "./index.js";
|
|
12
|
+
import { createReadableStreamFromReadable } from "./utils/createReadableStreamFromReadable.js";
|
|
13
13
|
import { stat } from "node:fs/promises";
|
|
14
14
|
import { basename } from "node:path";
|
|
15
15
|
import { md5FilePath } from "@editframe/assets";
|
|
16
16
|
import mime from "mime";
|
|
17
|
+
|
|
18
|
+
//#region src/node.ts
|
|
17
19
|
const createImageFileFromPath = async (client, path$1) => {
|
|
18
20
|
const byte_size = (await stat(path$1)).size;
|
|
19
21
|
const md5 = await md5FilePath(path$1);
|
|
@@ -41,4 +43,7 @@ const uploadUnprocessedFile = async (client, uploadDetails, path$1) => {
|
|
|
41
43
|
const { createReadableStreamFromReadable: createReadableStreamFromReadable$1 } = await import("./utils/createReadableStreamFromReadable.js");
|
|
42
44
|
return uploadUnprocessedReadableStream(client, uploadDetails, createReadableStreamFromReadable$1(readStream));
|
|
43
45
|
};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
44
48
|
export { AudioTrackPayload, Client, CreateCaptionFilePayload, CreateISOBMFFFilePayload, CreateISOBMFFTrackPayload, CreateImageFilePayload, CreateRenderPayload, CreateTranscriptionPayload, CreateUnprocessedFilePayload, ImageFileMimeTypes, OutputConfiguration, RenderOutputConfiguration, TranscribeISOBMFFFilePayload, VideoTrackPayload, createCaptionFile, createISOBMFFFile, createISOBMFFTrack, createImageFile, createImageFileFromPath, createReadableStreamFromReadable, createRender, createTranscription, createURLToken, createUnprocessedFile, createUnprocessedFileFromPath, downloadRender, getISOBMFFFileTranscription, getImageFileMetadata, getIsobmffProcessInfo, getIsobmffProcessProgress, getRenderInfo, getRenderProgress, getTranscriptionInfo, getTranscriptionProgress, lookupCaptionFileByMd5, lookupISOBMFFFileByMd5, lookupImageFileByMd5, lookupRenderByMd5, lookupUnprocessedFileByMd5, processIsobmffFile, transcribeISOBMFFFile, uploadCaptionFile, uploadFragmentIndex, uploadISOBMFFTrack, uploadImageFile, uploadRender, uploadUnprocessedFile, uploadUnprocessedReadableStream };
|
|
49
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","names":["path","createReadableStreamFromReadable"],"sources":["../src/node.ts"],"sourcesContent":["import { stat } from \"node:fs/promises\";\nimport { basename } from \"node:path\";\nimport { md5FilePath } from \"@editframe/assets\";\nimport mime from \"mime\";\n\nimport type { Client } from \"./client.js\";\nimport {\n CreateImageFilePayload,\n createImageFile,\n} from \"./resources/image-file.js\";\nimport {\n createUnprocessedFile,\n type UnprocessedFileUploadDetails,\n uploadUnprocessedReadableStream,\n} from \"./resources/unprocessed-file.js\";\n\nexport { createReadableStreamFromReadable } from \"./utils/createReadableStreamFromReadable.js\";\n\nexport const createImageFileFromPath = async (client: Client, path: string) => {\n const fileInfo = await stat(path);\n\n const byte_size = fileInfo.size;\n\n const md5 = await md5FilePath(path);\n\n const mime_type = mime.getType(path);\n\n return createImageFile(client, {\n ...CreateImageFilePayload.parse({\n md5,\n height: 0,\n width: 0,\n mime_type,\n filename: basename(path),\n byte_size,\n }),\n });\n};\n\nexport const createUnprocessedFileFromPath = async (\n client: Client,\n path: string,\n) => {\n const fileInfo = await stat(path);\n\n const byte_size = fileInfo.size;\n\n const md5 = await md5FilePath(path);\n\n return createUnprocessedFile(client, {\n md5,\n filename: basename(path),\n byte_size,\n });\n};\n\nexport const uploadUnprocessedFile = async (\n client: Client,\n uploadDetails: UnprocessedFileUploadDetails,\n path: string,\n) => {\n const { createReadStream } = await import(\"node:fs\");\n const readStream = createReadStream(path);\n\n const { createReadableStreamFromReadable } = await import(\n \"./utils/createReadableStreamFromReadable.ts\"\n );\n\n return uploadUnprocessedReadableStream(\n client,\n uploadDetails,\n createReadableStreamFromReadable(readStream),\n );\n};\n\nexport * from \"./index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAa,0BAA0B,OAAO,QAAgB,WAAiB;CAG7E,MAAM,aAFW,MAAM,KAAKA,OAAK,EAEN;CAE3B,MAAM,MAAM,MAAM,YAAYA,OAAK;CAEnC,MAAM,YAAY,KAAK,QAAQA,OAAK;AAEpC,QAAO,gBAAgB,QAAQ,EAC7B,GAAG,uBAAuB,MAAM;EAC9B;EACA,QAAQ;EACR,OAAO;EACP;EACA,UAAU,SAASA,OAAK;EACxB;EACD,CAAC,EACH,CAAC;;AAGJ,MAAa,gCAAgC,OAC3C,QACA,WACG;CAGH,MAAM,aAFW,MAAM,KAAKA,OAAK,EAEN;AAI3B,QAAO,sBAAsB,QAAQ;EACnC,KAHU,MAAM,YAAYA,OAAK;EAIjC,UAAU,SAASA,OAAK;EACxB;EACD,CAAC;;AAGJ,MAAa,wBAAwB,OACnC,QACA,eACA,WACG;CACH,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAC1C,MAAM,aAAa,iBAAiBA,OAAK;CAEzC,MAAM,EAAE,yEAAqC,MAAM,OACjD;AAGF,QAAO,gCACL,QACA,eACAC,mCAAiC,WAAW,CAC7C"}
|
|
@@ -1,55 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { Client } from "../client.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/resources/caption-file.d.ts
|
|
5
|
+
declare const CreateCaptionFilePayload: z.ZodObject<{
|
|
6
|
+
/**
|
|
7
|
+
* The md5 hash of the caption file
|
|
8
|
+
*/
|
|
9
|
+
md5: z.ZodString;
|
|
10
|
+
/**
|
|
11
|
+
* The filename of the caption file
|
|
12
|
+
*/
|
|
13
|
+
filename: z.ZodString;
|
|
14
|
+
/**
|
|
15
|
+
* The size of the caption file in bytes
|
|
16
|
+
*/
|
|
17
|
+
byte_size: z.ZodNumber;
|
|
16
18
|
}, "strip", z.ZodTypeAny, {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
md5: string;
|
|
20
|
+
filename: string;
|
|
21
|
+
byte_size: number;
|
|
20
22
|
}, {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
md5: string;
|
|
24
|
+
filename: string;
|
|
25
|
+
byte_size: number;
|
|
24
26
|
}>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
type CreateCaptionFilePayload = z.infer<typeof CreateCaptionFilePayload>;
|
|
28
|
+
interface CreateCaptionFileResult {
|
|
29
|
+
/**
|
|
30
|
+
* Whether the caption file is complete
|
|
31
|
+
*/
|
|
32
|
+
complete: boolean | null;
|
|
33
|
+
/**
|
|
34
|
+
* The id of the caption file
|
|
35
|
+
*/
|
|
36
|
+
id: string;
|
|
37
|
+
/**
|
|
38
|
+
* The md5 hash of the caption file
|
|
39
|
+
*/
|
|
40
|
+
md5: string;
|
|
39
41
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
interface LookupCaptionFileByMd5Result {
|
|
43
|
+
/**
|
|
44
|
+
* Whether the caption file is complete
|
|
45
|
+
*/
|
|
46
|
+
complete: boolean | null;
|
|
47
|
+
/**
|
|
48
|
+
* The id of the caption file
|
|
49
|
+
*/
|
|
50
|
+
id: string;
|
|
51
|
+
/**
|
|
52
|
+
* The md5 hash of the caption file
|
|
53
|
+
*/
|
|
54
|
+
md5: string;
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* Create a caption file
|
|
@@ -68,6 +70,9 @@ export interface LookupCaptionFileByMd5Result {
|
|
|
68
70
|
* @resource
|
|
69
71
|
* @beta
|
|
70
72
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
declare const createCaptionFile: (client: Client, payload: CreateCaptionFilePayload) => Promise<CreateCaptionFileResult>;
|
|
74
|
+
declare const uploadCaptionFile: (client: Client, fileId: string, fileStream: ReadableStream, fileSize: number) => Promise<any>;
|
|
75
|
+
declare const lookupCaptionFileByMd5: (client: Client, md5: string) => Promise<LookupCaptionFileByMd5Result | null>;
|
|
76
|
+
//#endregion
|
|
77
|
+
export { CreateCaptionFilePayload, CreateCaptionFileResult, LookupCaptionFileByMd5Result, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile };
|
|
78
|
+
//# sourceMappingURL=caption-file.d.ts.map
|
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
import debug from "debug";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
//#region src/resources/caption-file.ts
|
|
5
|
+
const log = debug("ef:api:caption-file");
|
|
6
|
+
const MAX_CAPTION_SIZE = 1024 * 1024 * 2;
|
|
5
7
|
const CreateCaptionFilePayload = z.object({
|
|
6
8
|
md5: z.string(),
|
|
7
9
|
filename: z.string(),
|
|
8
10
|
byte_size: z.number().int().max(MAX_CAPTION_SIZE)
|
|
9
11
|
});
|
|
10
|
-
|
|
12
|
+
const restrictSize = (size) => {
|
|
11
13
|
if (size > MAX_CAPTION_SIZE) throw new Error(`File size ${size} bytes exceeds limit ${MAX_CAPTION_SIZE} bytes\n`);
|
|
12
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Create a caption file
|
|
17
|
+
* @param client - The authenticated client to use for the request
|
|
18
|
+
* @param payload - The payload to send to the server
|
|
19
|
+
* @returns The result of the request
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const result = await createCaptionFile(client, {
|
|
23
|
+
* id: "123",
|
|
24
|
+
* filename: "caption.srt",
|
|
25
|
+
* });
|
|
26
|
+
* console.log(result);
|
|
27
|
+
* ```
|
|
28
|
+
* @category CaptionFile
|
|
29
|
+
* @resource
|
|
30
|
+
* @beta
|
|
31
|
+
*/
|
|
13
32
|
const createCaptionFile = async (client, payload) => {
|
|
14
33
|
log("Creating caption file", payload);
|
|
15
34
|
restrictSize(payload.byte_size);
|
|
@@ -40,4 +59,7 @@ const lookupCaptionFileByMd5 = async (client, md5) => {
|
|
|
40
59
|
if (response.status === 404) return null;
|
|
41
60
|
throw new Error(`Failed to lookup caption by md5 ${md5} ${response.status} ${response.statusText}`);
|
|
42
61
|
};
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
43
64
|
export { CreateCaptionFilePayload, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile };
|
|
65
|
+
//# sourceMappingURL=caption-file.js.map
|