@editframe/api 0.20.4-beta.0 → 0.23.6-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/ProgressIterator.js +5 -6
- package/dist/StreamEventSource.js +1 -1
- package/dist/client.js +1 -1
- package/dist/node.js +3 -6
- package/dist/resources/caption-file.js +3 -20
- package/dist/resources/image-file.js +2 -2
- package/dist/resources/isobmff-file.js +2 -2
- package/dist/resources/isobmff-track.js +2 -2
- package/dist/resources/process-isobmff.js +1 -2
- package/dist/resources/renders.bundle.js +1 -2
- package/dist/resources/renders.d.ts +3 -72
- package/dist/resources/renders.js +12 -15
- package/dist/resources/transcriptions.js +2 -3
- package/dist/resources/unprocessed-file.js +3 -3
- package/dist/resources/url-token.js +1 -1
- package/dist/uploadChunks.js +2 -2
- package/dist/utils/createReadableStreamFromReadable.js +1 -2
- package/package.json +3 -3
- package/types.json +1 -1
package/dist/ProgressIterator.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
var promiseWithResolvers = () => {
|
|
2
2
|
if (typeof Promise.withResolvers === "function") return Promise.withResolvers();
|
|
3
3
|
let resolve;
|
|
4
4
|
let reject;
|
|
5
|
-
const promise = new Promise((res, rej) => {
|
|
6
|
-
resolve = res;
|
|
7
|
-
reject = rej;
|
|
8
|
-
});
|
|
9
5
|
return {
|
|
10
|
-
promise,
|
|
6
|
+
promise: new Promise((res, rej) => {
|
|
7
|
+
resolve = res;
|
|
8
|
+
reject = rej;
|
|
9
|
+
}),
|
|
11
10
|
resolve,
|
|
12
11
|
reject
|
|
13
12
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import debug from "debug";
|
|
2
2
|
import { createParser } from "eventsource-parser";
|
|
3
|
-
|
|
3
|
+
var log = debug("ef:StreamEventSource");
|
|
4
4
|
var StreamEventSource = class {
|
|
5
5
|
constructor(stream, abortController) {
|
|
6
6
|
this.activeReader = null;
|
package/dist/client.js
CHANGED
package/dist/node.js
CHANGED
|
@@ -15,8 +15,7 @@ import { basename } from "node:path";
|
|
|
15
15
|
import { md5FilePath } from "@editframe/assets";
|
|
16
16
|
import mime from "mime";
|
|
17
17
|
const createImageFileFromPath = async (client, path$1) => {
|
|
18
|
-
const
|
|
19
|
-
const byte_size = fileInfo.size;
|
|
18
|
+
const byte_size = (await stat(path$1)).size;
|
|
20
19
|
const md5 = await md5FilePath(path$1);
|
|
21
20
|
const mime_type = mime.getType(path$1);
|
|
22
21
|
return createImageFile(client, { ...CreateImageFilePayload.parse({
|
|
@@ -29,11 +28,9 @@ const createImageFileFromPath = async (client, path$1) => {
|
|
|
29
28
|
}) });
|
|
30
29
|
};
|
|
31
30
|
const createUnprocessedFileFromPath = async (client, path$1) => {
|
|
32
|
-
const
|
|
33
|
-
const byte_size = fileInfo.size;
|
|
34
|
-
const md5 = await md5FilePath(path$1);
|
|
31
|
+
const byte_size = (await stat(path$1)).size;
|
|
35
32
|
return createUnprocessedFile(client, {
|
|
36
|
-
md5,
|
|
33
|
+
md5: await md5FilePath(path$1),
|
|
37
34
|
filename: basename(path$1),
|
|
38
35
|
byte_size
|
|
39
36
|
});
|
|
@@ -1,32 +1,15 @@
|
|
|
1
1
|
import debug from "debug";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var log = debug("ef:api:caption-file");
|
|
4
|
+
var MAX_CAPTION_SIZE = 1024 * 1024 * 2;
|
|
5
5
|
const CreateCaptionFilePayload = z.object({
|
|
6
6
|
md5: z.string(),
|
|
7
7
|
filename: z.string(),
|
|
8
8
|
byte_size: z.number().int().max(MAX_CAPTION_SIZE)
|
|
9
9
|
});
|
|
10
|
-
|
|
10
|
+
var restrictSize = (size) => {
|
|
11
11
|
if (size > MAX_CAPTION_SIZE) throw new Error(`File size ${size} bytes exceeds limit ${MAX_CAPTION_SIZE} bytes\n`);
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
14
|
-
* Create a caption file
|
|
15
|
-
* @param client - The authenticated client to use for the request
|
|
16
|
-
* @param payload - The payload to send to the server
|
|
17
|
-
* @returns The result of the request
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* const result = await createCaptionFile(client, {
|
|
21
|
-
* id: "123",
|
|
22
|
-
* filename: "caption.srt",
|
|
23
|
-
* });
|
|
24
|
-
* console.log(result);
|
|
25
|
-
* ```
|
|
26
|
-
* @category CaptionFile
|
|
27
|
-
* @resource
|
|
28
|
-
* @beta
|
|
29
|
-
*/
|
|
30
13
|
const createCaptionFile = async (client, payload) => {
|
|
31
14
|
log("Creating caption file", payload);
|
|
32
15
|
restrictSize(payload.byte_size);
|
|
@@ -2,8 +2,8 @@ import { uploadChunks } from "../uploadChunks.js";
|
|
|
2
2
|
import debug from "debug";
|
|
3
3
|
import { types } from "mime-types";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var log = debug("ef:api:image-file");
|
|
6
|
+
var MAX_IMAGE_SIZE = 1024 * 1024 * 16;
|
|
7
7
|
const ImageFileMimeTypes = z.enum([
|
|
8
8
|
"image/jpeg",
|
|
9
9
|
"image/png",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import debug from "debug";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var log = debug("ef:api:isobmff-file");
|
|
4
|
+
var FILE_SIZE_LIMIT = 1024 * 1024 * 2;
|
|
5
5
|
const CreateISOBMFFFilePayload = z.object({
|
|
6
6
|
md5: z.string(),
|
|
7
7
|
filename: z.string()
|
|
@@ -48,8 +48,8 @@ const VideoStreamSchema = z.object({
|
|
|
48
48
|
disposition: z.record(z.unknown())
|
|
49
49
|
});
|
|
50
50
|
assertTypesMatch(true);
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
var log = debug("ef:api:isobmff-track");
|
|
52
|
+
var MAX_TRACK_SIZE = 1024 * 1024 * 1024;
|
|
53
53
|
const AudioTrackPayload = z.object({
|
|
54
54
|
file_id: z.string(),
|
|
55
55
|
track_id: z.number().int(),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ProgressIterator } from "../ProgressIterator.js";
|
|
2
2
|
const getIsobmffProcessProgress = async (client, id) => {
|
|
3
|
-
|
|
4
|
-
return new ProgressIterator(eventSource);
|
|
3
|
+
return new ProgressIterator(await client.authenticatedEventSource(`/api/v1/process_isobmff/${id}/progress`));
|
|
5
4
|
};
|
|
6
5
|
const getIsobmffProcessInfo = async (client, id) => {
|
|
7
6
|
const response = await client.authenticatedFetch(`/api/v1/process_isobmff/${id}`);
|
|
@@ -31,7 +31,6 @@ const bundleRender = async (options) => {
|
|
|
31
31
|
}, ["."]);
|
|
32
32
|
const passthrough = new PassThrough();
|
|
33
33
|
tarStream.pipe(passthrough);
|
|
34
|
-
|
|
35
|
-
return tarReadStream;
|
|
34
|
+
return createReadableStreamFromReadable(passthrough);
|
|
36
35
|
};
|
|
37
36
|
export { bundleRender };
|
|
@@ -213,7 +213,7 @@ export declare const CreateRenderPayload: z.ZodObject<{
|
|
|
213
213
|
transparency?: boolean | undefined;
|
|
214
214
|
} | undefined;
|
|
215
215
|
}>;
|
|
216
|
-
export declare const CreateRenderPayloadWithOutput: z.ZodObject<
|
|
216
|
+
export declare const CreateRenderPayloadWithOutput: z.ZodObject<{
|
|
217
217
|
md5: z.ZodOptional<z.ZodString>;
|
|
218
218
|
fps: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
219
219
|
width: z.ZodOptional<z.ZodNumber>;
|
|
@@ -223,76 +223,7 @@ export declare const CreateRenderPayloadWithOutput: z.ZodObject<z.objectUtil.ext
|
|
|
223
223
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
224
224
|
duration_ms: z.ZodOptional<z.ZodNumber>;
|
|
225
225
|
strategy: z.ZodOptional<z.ZodDefault<z.ZodEnum<["v1"]>>>;
|
|
226
|
-
|
|
227
|
-
container: z.ZodLiteral<"mp4">;
|
|
228
|
-
video: z.ZodObject<{
|
|
229
|
-
codec: z.ZodLiteral<"h264">;
|
|
230
|
-
}, "strip", z.ZodTypeAny, {
|
|
231
|
-
codec: "h264";
|
|
232
|
-
}, {
|
|
233
|
-
codec: "h264";
|
|
234
|
-
}>;
|
|
235
|
-
audio: z.ZodObject<{
|
|
236
|
-
codec: z.ZodLiteral<"aac">;
|
|
237
|
-
}, "strip", z.ZodTypeAny, {
|
|
238
|
-
codec: "aac";
|
|
239
|
-
}, {
|
|
240
|
-
codec: "aac";
|
|
241
|
-
}>;
|
|
242
|
-
}, "strip", z.ZodTypeAny, {
|
|
243
|
-
audio: {
|
|
244
|
-
codec: "aac";
|
|
245
|
-
};
|
|
246
|
-
video: {
|
|
247
|
-
codec: "h264";
|
|
248
|
-
};
|
|
249
|
-
container: "mp4";
|
|
250
|
-
}, {
|
|
251
|
-
audio: {
|
|
252
|
-
codec: "aac";
|
|
253
|
-
};
|
|
254
|
-
video: {
|
|
255
|
-
codec: "h264";
|
|
256
|
-
};
|
|
257
|
-
container: "mp4";
|
|
258
|
-
}>, z.ZodObject<{
|
|
259
|
-
container: z.ZodLiteral<"jpeg">;
|
|
260
|
-
quality: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
261
|
-
}, "strip", z.ZodTypeAny, {
|
|
262
|
-
container: "jpeg";
|
|
263
|
-
quality?: number | undefined;
|
|
264
|
-
}, {
|
|
265
|
-
container: "jpeg";
|
|
266
|
-
quality?: number | undefined;
|
|
267
|
-
}>, z.ZodObject<{
|
|
268
|
-
container: z.ZodLiteral<"png">;
|
|
269
|
-
compression: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
270
|
-
transparency: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
271
|
-
}, "strip", z.ZodTypeAny, {
|
|
272
|
-
container: "png";
|
|
273
|
-
compression?: number | undefined;
|
|
274
|
-
transparency?: boolean | undefined;
|
|
275
|
-
}, {
|
|
276
|
-
container: "png";
|
|
277
|
-
compression?: number | undefined;
|
|
278
|
-
transparency?: boolean | undefined;
|
|
279
|
-
}>, z.ZodObject<{
|
|
280
|
-
container: z.ZodLiteral<"webp">;
|
|
281
|
-
quality: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
282
|
-
compression: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
283
|
-
transparency: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
284
|
-
}, "strip", z.ZodTypeAny, {
|
|
285
|
-
container: "webp";
|
|
286
|
-
quality?: number | undefined;
|
|
287
|
-
compression?: number | undefined;
|
|
288
|
-
transparency?: boolean | undefined;
|
|
289
|
-
}, {
|
|
290
|
-
container: "webp";
|
|
291
|
-
quality?: number | undefined;
|
|
292
|
-
compression?: number | undefined;
|
|
293
|
-
transparency?: boolean | undefined;
|
|
294
|
-
}>]>>>;
|
|
295
|
-
}, {
|
|
226
|
+
} & {
|
|
296
227
|
output: z.ZodDiscriminatedUnion<"container", [z.ZodObject<{
|
|
297
228
|
container: z.ZodLiteral<"mp4">;
|
|
298
229
|
video: z.ZodObject<{
|
|
@@ -362,7 +293,7 @@ export declare const CreateRenderPayloadWithOutput: z.ZodObject<z.objectUtil.ext
|
|
|
362
293
|
compression?: number | undefined;
|
|
363
294
|
transparency?: boolean | undefined;
|
|
364
295
|
}>]>;
|
|
365
|
-
}
|
|
296
|
+
}, "strip", z.ZodTypeAny, {
|
|
366
297
|
output: {
|
|
367
298
|
audio: {
|
|
368
299
|
codec: "aac";
|
|
@@ -2,24 +2,24 @@ import { assertTypesMatch } from "../utils/assertTypesMatch.js";
|
|
|
2
2
|
import { CompletionIterator } from "../ProgressIterator.js";
|
|
3
3
|
import debug from "debug";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
var log = debug("ef:api:renders");
|
|
6
|
+
var H264Configuration = z.object({ codec: z.literal("h264") });
|
|
7
|
+
var AACConfiguration = z.object({ codec: z.literal("aac") });
|
|
8
|
+
var MP4Configuration = z.object({
|
|
9
9
|
container: z.literal("mp4"),
|
|
10
10
|
video: H264Configuration,
|
|
11
11
|
audio: AACConfiguration
|
|
12
12
|
});
|
|
13
|
-
|
|
13
|
+
var JpegConfiguration = z.object({
|
|
14
14
|
container: z.literal("jpeg"),
|
|
15
15
|
quality: z.number().int().min(1).max(100).default(80).optional()
|
|
16
16
|
});
|
|
17
|
-
|
|
17
|
+
var PngConfiguration = z.object({
|
|
18
18
|
container: z.literal("png"),
|
|
19
19
|
compression: z.number().int().min(1).max(100).default(80).optional(),
|
|
20
20
|
transparency: z.boolean().default(false).optional()
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
var WebpConfiguration = z.object({
|
|
23
23
|
container: z.literal("webp"),
|
|
24
24
|
quality: z.number().int().min(1).max(100).default(80).optional(),
|
|
25
25
|
compression: z.number().int().min(0).max(6).default(4).optional(),
|
|
@@ -47,15 +47,14 @@ const CreateRenderPayload = z.object({
|
|
|
47
47
|
audio: { codec: "aac" }
|
|
48
48
|
}).optional()
|
|
49
49
|
});
|
|
50
|
-
|
|
50
|
+
CreateRenderPayload.extend({ output: RenderOutputConfiguration });
|
|
51
51
|
var OutputConfiguration = class OutputConfiguration {
|
|
52
52
|
static parse(input) {
|
|
53
|
-
|
|
53
|
+
return new OutputConfiguration(RenderOutputConfiguration.parse(input ?? {
|
|
54
54
|
container: "mp4",
|
|
55
55
|
video: { codec: "h264" },
|
|
56
56
|
audio: { codec: "aac" }
|
|
57
|
-
});
|
|
58
|
-
return new OutputConfiguration(output);
|
|
57
|
+
}));
|
|
59
58
|
}
|
|
60
59
|
constructor(output) {
|
|
61
60
|
this.output = output;
|
|
@@ -118,8 +117,7 @@ const uploadRender = async (client, renderId, fileStream) => {
|
|
|
118
117
|
throw new Error(`Failed to upload render ${response.status} ${response.statusText}`);
|
|
119
118
|
};
|
|
120
119
|
const getRenderInfo = async (client, id) => {
|
|
121
|
-
|
|
122
|
-
return response.json();
|
|
120
|
+
return (await client.authenticatedFetch(`/api/v1/renders/${id}`)).json();
|
|
123
121
|
};
|
|
124
122
|
const lookupRenderByMd5 = async (client, md5) => {
|
|
125
123
|
const response = await client.authenticatedFetch(`/api/v1/renders/md5/${md5}`, { method: "GET" });
|
|
@@ -128,8 +126,7 @@ const lookupRenderByMd5 = async (client, md5) => {
|
|
|
128
126
|
throw new Error(`Failed to lookup render by md5 ${md5} ${response.status} ${response.statusText}`);
|
|
129
127
|
};
|
|
130
128
|
const getRenderProgress = async (client, id) => {
|
|
131
|
-
|
|
132
|
-
return new CompletionIterator(eventSource);
|
|
129
|
+
return new CompletionIterator(await client.authenticatedEventSource(`/api/v1/renders/${id}/progress`));
|
|
133
130
|
};
|
|
134
131
|
const downloadRender = async (client, id) => {
|
|
135
132
|
const response = await client.authenticatedFetch(`/api/v1/renders/${id}.mp4`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CompletionIterator } from "../ProgressIterator.js";
|
|
2
2
|
import debug from "debug";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
|
|
4
|
+
var log = debug("ef:api:transcriptions");
|
|
5
5
|
const CreateTranscriptionPayload = z.object({
|
|
6
6
|
file_id: z.string(),
|
|
7
7
|
track_id: z.number().int()
|
|
@@ -17,8 +17,7 @@ const createTranscription = async (client, payload) => {
|
|
|
17
17
|
throw new Error(`Failed to create transcription ${response.status} ${response.statusText}`);
|
|
18
18
|
};
|
|
19
19
|
const getTranscriptionProgress = async (client, id) => {
|
|
20
|
-
|
|
21
|
-
return new CompletionIterator(eventSource);
|
|
20
|
+
return new CompletionIterator(await client.authenticatedEventSource(`/api/v1/transcriptions/${id}/progress`));
|
|
22
21
|
};
|
|
23
22
|
const getTranscriptionInfo = async (client, id) => {
|
|
24
23
|
const response = await client.authenticatedFetch(`/api/v1/transcriptions/${id}`);
|
|
@@ -2,14 +2,14 @@ import { uploadChunks } from "../uploadChunks.js";
|
|
|
2
2
|
import { assertTypesMatch } from "../utils/assertTypesMatch.js";
|
|
3
3
|
import debug from "debug";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var log = debug("ef:api:unprocessed-file");
|
|
6
|
+
var MAX_FILE_SIZE = 1024 * 1024 * 1024;
|
|
7
7
|
const CreateUnprocessedFilePayload = z.object({
|
|
8
8
|
md5: z.string(),
|
|
9
9
|
filename: z.string(),
|
|
10
10
|
byte_size: z.number().int().max(MAX_FILE_SIZE)
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
z.object({});
|
|
13
13
|
assertTypesMatch(true);
|
|
14
14
|
const createUnprocessedFile = async (client, payload) => {
|
|
15
15
|
log("Creating an unprocessed file", payload);
|
package/dist/uploadChunks.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CHUNK_SIZE_BYTES } from "./CHUNK_SIZE_BYTES.js";
|
|
2
2
|
import { streamChunker } from "./streamChunker.js";
|
|
3
3
|
import debug from "debug";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
var log = debug("ef:api:uploadChunk");
|
|
5
|
+
var uploadChunk = async (client, { url, chunkBuffer, chunkNumber, fileSize, chunkSizeBytes = CHUNK_SIZE_BYTES }) => {
|
|
6
6
|
const startByte = chunkNumber * chunkSizeBytes;
|
|
7
7
|
const endByte = startByte + chunkBuffer.length - 1;
|
|
8
8
|
log(`Uploading chunk ${chunkNumber} for ${url}`);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Stream } from "node:stream";
|
|
2
2
|
const createReadableStreamFromReadable = (source) => {
|
|
3
3
|
const pump = new StreamPump(source);
|
|
4
|
-
|
|
5
|
-
return stream;
|
|
4
|
+
return new ReadableStream(pump, pump);
|
|
6
5
|
};
|
|
7
6
|
var StreamPump = class {
|
|
8
7
|
constructor(stream) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editframe/api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.6-beta.0",
|
|
4
4
|
"description": "API functions for EditFrame",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"vite-plugin-dts": "^4.5.4"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@editframe/assets": "0.
|
|
48
|
+
"@editframe/assets": "0.23.6-beta.0",
|
|
49
49
|
"@vitejs/plugin-react": "^4.3.4",
|
|
50
50
|
"debug": "^4.3.5",
|
|
51
51
|
"eventsource-parser": "^3.0.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"mime": "^4.0.4",
|
|
54
54
|
"mime-types": "^2.1.35",
|
|
55
55
|
"node-fetch": "^3.3.2",
|
|
56
|
-
"rolldown-vite": "^
|
|
56
|
+
"rolldown-vite": "^7.1.15",
|
|
57
57
|
"tar": "^7.4.3",
|
|
58
58
|
"vite-plugin-singlefile": "^2.1.0",
|
|
59
59
|
"vite-tsconfig-paths": "^4.3.2",
|