@editframe/api 0.9.0-beta.3 → 0.10.0-beta.3
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/resources/caption-file.d.ts +4 -3
- package/dist/resources/caption-file.js +6 -9
- package/dist/resources/image-file.d.ts +4 -3
- package/dist/resources/image-file.js +3 -3
- package/dist/resources/isobmff-file.d.ts +5 -3
- package/dist/resources/isobmff-file.js +6 -9
- package/dist/resources/isobmff-track.js +5 -8
- package/dist/resources/renders.d.ts +5 -4
- package/dist/resources/renders.js +3 -3
- package/dist/resources/unprocessed-file.d.ts +7 -3
- package/dist/resources/unprocessed-file.js +52 -38
- package/dist/uploadChunks.js +6 -0
- package/package.json +2 -2
- package/src/resources/caption-file.test.ts +12 -15
- package/src/resources/caption-file.ts +7 -9
- package/src/resources/image-file.test.ts +17 -10
- package/src/resources/image-file.ts +4 -3
- package/src/resources/isobmff-file.test.ts +6 -6
- package/src/resources/isobmff-file.ts +8 -9
- package/src/resources/isobmff-track.test.ts +13 -5
- package/src/resources/isobmff-track.ts +5 -8
- package/src/resources/renders.test.ts +5 -5
- package/src/resources/renders.ts +5 -4
- package/src/resources/unprocessed-file.test.ts +119 -15
- package/src/resources/unprocessed-file.ts +69 -47
|
@@ -10,6 +10,11 @@ import { readableFromBuffers } from "../readableFromBuffers.ts";
|
|
|
10
10
|
const server = setupServer();
|
|
11
11
|
const client = new Client("ef_TEST_TOKEN", "http://localhost");
|
|
12
12
|
|
|
13
|
+
const UploadMustContinue = (id = "test-file") =>
|
|
14
|
+
http.get(`http://localhost/api/v1/image_files/${id}/upload`, () =>
|
|
15
|
+
HttpResponse.json({}, { status: 202 }),
|
|
16
|
+
);
|
|
17
|
+
|
|
13
18
|
describe("ImageFile", () => {
|
|
14
19
|
beforeAll(() => server.listen());
|
|
15
20
|
afterEach(() => server.resetHandlers());
|
|
@@ -19,7 +24,7 @@ describe("ImageFile", () => {
|
|
|
19
24
|
test("Throws when file is too large", async () => {
|
|
20
25
|
await expect(
|
|
21
26
|
createImageFile(client, {
|
|
22
|
-
|
|
27
|
+
md5: "test-md5",
|
|
23
28
|
filename: "test",
|
|
24
29
|
byte_size: 1024 * 1024 * 17,
|
|
25
30
|
height: 100,
|
|
@@ -43,14 +48,14 @@ describe("ImageFile", () => {
|
|
|
43
48
|
|
|
44
49
|
test("Throws when server returns an error", async () => {
|
|
45
50
|
server.use(
|
|
46
|
-
http.post("http://localhost/api/
|
|
51
|
+
http.post("http://localhost/api/v1/image_files", () =>
|
|
47
52
|
HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
48
53
|
),
|
|
49
54
|
);
|
|
50
55
|
|
|
51
56
|
await expect(
|
|
52
57
|
createImageFile(client, {
|
|
53
|
-
|
|
58
|
+
md5: "test-md5",
|
|
54
59
|
filename: "test",
|
|
55
60
|
byte_size: 4,
|
|
56
61
|
height: 100,
|
|
@@ -62,16 +67,16 @@ describe("ImageFile", () => {
|
|
|
62
67
|
|
|
63
68
|
test("Returns json data from the http response", async () => {
|
|
64
69
|
server.use(
|
|
65
|
-
http.post("http://localhost/api/
|
|
70
|
+
http.post("http://localhost/api/v1/image_files", () =>
|
|
66
71
|
HttpResponse.json(
|
|
67
|
-
{
|
|
72
|
+
{ md5: "test-md5" },
|
|
68
73
|
{ status: 200, statusText: "OK" },
|
|
69
74
|
),
|
|
70
75
|
),
|
|
71
76
|
);
|
|
72
77
|
|
|
73
78
|
const response = await createImageFile(client, {
|
|
74
|
-
|
|
79
|
+
md5: "test-md5",
|
|
75
80
|
filename: "test",
|
|
76
81
|
byte_size: 4,
|
|
77
82
|
height: 100,
|
|
@@ -79,7 +84,7 @@ describe("ImageFile", () => {
|
|
|
79
84
|
mime_type: "image/jpeg",
|
|
80
85
|
});
|
|
81
86
|
|
|
82
|
-
expect(response).toEqual({
|
|
87
|
+
expect(response).toEqual({ md5: "test-md5" });
|
|
83
88
|
});
|
|
84
89
|
});
|
|
85
90
|
|
|
@@ -99,8 +104,9 @@ describe("ImageFile", () => {
|
|
|
99
104
|
|
|
100
105
|
test("Throws if upload fails", async () => {
|
|
101
106
|
server.use(
|
|
107
|
+
UploadMustContinue("test-file-id"),
|
|
102
108
|
http.post(
|
|
103
|
-
"http://localhost/api/
|
|
109
|
+
"http://localhost/api/v1/image_files/test-file-id/upload",
|
|
104
110
|
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
105
111
|
),
|
|
106
112
|
);
|
|
@@ -113,14 +119,15 @@ describe("ImageFile", () => {
|
|
|
113
119
|
4,
|
|
114
120
|
),
|
|
115
121
|
).rejects.toThrowError(
|
|
116
|
-
"Failed to upload chunk 0 for /api/
|
|
122
|
+
"Failed to upload chunk 0 for /api/v1/image_files/test-file-id/upload 500 Internal Server Error",
|
|
117
123
|
);
|
|
118
124
|
});
|
|
119
125
|
|
|
120
126
|
test("Uploads file", async () => {
|
|
121
127
|
server.use(
|
|
128
|
+
UploadMustContinue("test-file-id"),
|
|
122
129
|
http.post(
|
|
123
|
-
"http://localhost/api/
|
|
130
|
+
"http://localhost/api/v1/image_files/test-file-id/upload",
|
|
124
131
|
() => HttpResponse.json(null, { status: 201 }),
|
|
125
132
|
),
|
|
126
133
|
);
|
|
@@ -11,7 +11,7 @@ const log = debug("ef:api:image-file");
|
|
|
11
11
|
const MAX_IMAGE_SIZE = 1024 * 1024 * 16; // 16MB
|
|
12
12
|
|
|
13
13
|
export const CreateImageFilePayload = z.object({
|
|
14
|
-
|
|
14
|
+
md5: z.string(),
|
|
15
15
|
height: z.number().int(),
|
|
16
16
|
width: z.number().int(),
|
|
17
17
|
mime_type: z.enum(["image/jpeg", "image/png", "image/jpg", "image/webp"]),
|
|
@@ -22,6 +22,7 @@ export const CreateImageFilePayload = z.object({
|
|
|
22
22
|
export interface CreateImageFileResult {
|
|
23
23
|
complete: boolean | null;
|
|
24
24
|
id: string;
|
|
25
|
+
md5: string;
|
|
25
26
|
asset_id: string;
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -31,7 +32,7 @@ export const createImageFile = async (
|
|
|
31
32
|
) => {
|
|
32
33
|
log("Creating image file", payload);
|
|
33
34
|
CreateImageFilePayload.parse(payload);
|
|
34
|
-
const response = await client.authenticatedFetch("/api/
|
|
35
|
+
const response = await client.authenticatedFetch("/api/v1/image_files", {
|
|
35
36
|
method: "POST",
|
|
36
37
|
body: JSON.stringify(payload),
|
|
37
38
|
});
|
|
@@ -61,7 +62,7 @@ export const uploadImageFile = async (
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
const result = await uploadChunks(client, {
|
|
64
|
-
url: `/api/
|
|
65
|
+
url: `/api/v1/image_files/${fileId}/upload`,
|
|
65
66
|
fileSize,
|
|
66
67
|
fileStream,
|
|
67
68
|
});
|
|
@@ -17,14 +17,14 @@ describe("ISOBMFFFile", () => {
|
|
|
17
17
|
describe("createISOBMFFFile", () => {
|
|
18
18
|
test("Throws when server returns an error", async () => {
|
|
19
19
|
server.use(
|
|
20
|
-
http.post("http://localhost/api/
|
|
20
|
+
http.post("http://localhost/api/v1/isobmff_files", () =>
|
|
21
21
|
HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
22
22
|
),
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
await expect(
|
|
26
26
|
createISOBMFFFile(client, {
|
|
27
|
-
|
|
27
|
+
md5: "test-md5",
|
|
28
28
|
filename: "test",
|
|
29
29
|
}),
|
|
30
30
|
).rejects.toThrowError(
|
|
@@ -34,7 +34,7 @@ describe("ISOBMFFFile", () => {
|
|
|
34
34
|
|
|
35
35
|
test("Returns json data from the http response", async () => {
|
|
36
36
|
server.use(
|
|
37
|
-
http.post("http://localhost/api/
|
|
37
|
+
http.post("http://localhost/api/v1/isobmff_files", () =>
|
|
38
38
|
HttpResponse.json(
|
|
39
39
|
{ id: "test-id" },
|
|
40
40
|
{ status: 200, statusText: "OK" },
|
|
@@ -43,7 +43,7 @@ describe("ISOBMFFFile", () => {
|
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
const response = await createISOBMFFFile(client, {
|
|
46
|
-
|
|
46
|
+
md5: "test-md5",
|
|
47
47
|
filename: "test",
|
|
48
48
|
});
|
|
49
49
|
|
|
@@ -66,7 +66,7 @@ describe("ISOBMFFFile", () => {
|
|
|
66
66
|
test("Throws when server returns an error", async () => {
|
|
67
67
|
server.use(
|
|
68
68
|
http.post(
|
|
69
|
-
"http://localhost/api/
|
|
69
|
+
"http://localhost/api/v1/isobmff_files/test-id/index/upload",
|
|
70
70
|
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
71
71
|
),
|
|
72
72
|
);
|
|
@@ -86,7 +86,7 @@ describe("ISOBMFFFile", () => {
|
|
|
86
86
|
test("Returns json data from the http response", async () => {
|
|
87
87
|
server.use(
|
|
88
88
|
http.post(
|
|
89
|
-
"http://localhost/api/
|
|
89
|
+
"http://localhost/api/v1/isobmff_files/test-id/index/upload",
|
|
90
90
|
() =>
|
|
91
91
|
HttpResponse.json(
|
|
92
92
|
{ fragment_index_complete: true },
|
|
@@ -9,13 +9,15 @@ const log = debug("ef:api:isobmff-file");
|
|
|
9
9
|
const FILE_SIZE_LIMIT = 1024 * 1024 * 2; // 32MB
|
|
10
10
|
|
|
11
11
|
export const CreateISOBMFFFilePayload = z.object({
|
|
12
|
-
|
|
12
|
+
md5: z.string(),
|
|
13
13
|
filename: z.string(),
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
export interface CreateISOBMFFFileResult {
|
|
17
17
|
fragment_index_complete: boolean;
|
|
18
|
+
filename: string;
|
|
18
19
|
id: string;
|
|
20
|
+
md5: string;
|
|
19
21
|
asset_id: string;
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -24,13 +26,10 @@ export const createISOBMFFFile = async (
|
|
|
24
26
|
payload: z.infer<typeof CreateISOBMFFFilePayload>,
|
|
25
27
|
) => {
|
|
26
28
|
log("Creating isobmff file", payload);
|
|
27
|
-
const response = await client.authenticatedFetch(
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
body: JSON.stringify(payload),
|
|
32
|
-
},
|
|
33
|
-
);
|
|
29
|
+
const response = await client.authenticatedFetch("/api/v1/isobmff_files", {
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: JSON.stringify(payload),
|
|
32
|
+
});
|
|
34
33
|
|
|
35
34
|
log("ISOBMFF file created", response);
|
|
36
35
|
|
|
@@ -54,7 +53,7 @@ export const uploadFragmentIndex = async (
|
|
|
54
53
|
throw new Error(`File size exceeds limit of ${FILE_SIZE_LIMIT} bytes`);
|
|
55
54
|
}
|
|
56
55
|
const response = await client.authenticatedFetch(
|
|
57
|
-
`/api/
|
|
56
|
+
`/api/v1/isobmff_files/${fileId}/index/upload`,
|
|
58
57
|
{
|
|
59
58
|
method: "POST",
|
|
60
59
|
body: fileStream,
|
|
@@ -10,6 +10,12 @@ import { readableFromBuffers } from "../readableFromBuffers.ts";
|
|
|
10
10
|
const server = setupServer();
|
|
11
11
|
const client = new Client("ef_TEST_TOKEN", "http://localhost");
|
|
12
12
|
|
|
13
|
+
const UploadMustContinue = (fileId = "test-file", trackId = 1) =>
|
|
14
|
+
http.get(
|
|
15
|
+
`http://localhost/api/v1/isobmff_tracks/${fileId}/${trackId}/upload`,
|
|
16
|
+
() => HttpResponse.json({}, { status: 202 }),
|
|
17
|
+
);
|
|
18
|
+
|
|
13
19
|
describe("ISOBMFF Track", () => {
|
|
14
20
|
beforeAll(() => server.listen());
|
|
15
21
|
afterEach(() => server.resetHandlers());
|
|
@@ -39,7 +45,7 @@ describe("ISOBMFF Track", () => {
|
|
|
39
45
|
|
|
40
46
|
test("Throws when server returns an error", async () => {
|
|
41
47
|
server.use(
|
|
42
|
-
http.post("http://localhost/api/
|
|
48
|
+
http.post("http://localhost/api/v1/isobmff_tracks", () =>
|
|
43
49
|
HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
44
50
|
),
|
|
45
51
|
);
|
|
@@ -53,7 +59,7 @@ describe("ISOBMFF Track", () => {
|
|
|
53
59
|
|
|
54
60
|
test("Returns json data from the http response", async () => {
|
|
55
61
|
server.use(
|
|
56
|
-
http.post("http://localhost/api/
|
|
62
|
+
http.post("http://localhost/api/v1/isobmff_tracks", () =>
|
|
57
63
|
HttpResponse.json(
|
|
58
64
|
{ testResponse: "test" },
|
|
59
65
|
{ status: 200, statusText: "OK" },
|
|
@@ -73,8 +79,9 @@ describe("ISOBMFF Track", () => {
|
|
|
73
79
|
describe("uploadISOBMFFTrack", () => {
|
|
74
80
|
test("Throws when server returns an error", async () => {
|
|
75
81
|
server.use(
|
|
82
|
+
UploadMustContinue("test-file", 1),
|
|
76
83
|
http.post(
|
|
77
|
-
"http://localhost/api/
|
|
84
|
+
"http://localhost/api/v1/isobmff_tracks/test-file/1/upload",
|
|
78
85
|
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
79
86
|
),
|
|
80
87
|
);
|
|
@@ -88,14 +95,15 @@ describe("ISOBMFF Track", () => {
|
|
|
88
95
|
4,
|
|
89
96
|
),
|
|
90
97
|
).rejects.toThrowError(
|
|
91
|
-
"Failed to upload chunk 0 for /api/
|
|
98
|
+
"Failed to upload chunk 0 for /api/v1/isobmff_tracks/test-file/1/upload 500 Internal Server Error",
|
|
92
99
|
);
|
|
93
100
|
});
|
|
94
101
|
|
|
95
102
|
test("Succeeds when server returns a success", async () => {
|
|
96
103
|
server.use(
|
|
104
|
+
UploadMustContinue("test-file", 1),
|
|
97
105
|
http.post(
|
|
98
|
-
"http://localhost/api/
|
|
106
|
+
"http://localhost/api/v1/isobmff_tracks/test-file/1/upload",
|
|
99
107
|
() => HttpResponse.json({}, { status: 201 }),
|
|
100
108
|
),
|
|
101
109
|
);
|
|
@@ -46,13 +46,10 @@ export const createISOBMFFTrack = async (
|
|
|
46
46
|
) => {
|
|
47
47
|
log("Creating isobmff track", payload);
|
|
48
48
|
CreateISOBMFFTrackPayload.parse(payload);
|
|
49
|
-
const response = await client.authenticatedFetch(
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
body: JSON.stringify(payload),
|
|
54
|
-
},
|
|
55
|
-
);
|
|
49
|
+
const response = await client.authenticatedFetch("/api/v1/isobmff_tracks", {
|
|
50
|
+
method: "POST",
|
|
51
|
+
body: JSON.stringify(payload),
|
|
52
|
+
});
|
|
56
53
|
|
|
57
54
|
log("ISOBMFF track created", response);
|
|
58
55
|
if (response.ok) {
|
|
@@ -74,7 +71,7 @@ export const uploadISOBMFFTrack = async (
|
|
|
74
71
|
log("Uploading fragment track", fileId);
|
|
75
72
|
|
|
76
73
|
await uploadChunks(client, {
|
|
77
|
-
url: `/api/
|
|
74
|
+
url: `/api/v1/isobmff_tracks/${fileId}/${trackId}/upload`,
|
|
78
75
|
fileStream,
|
|
79
76
|
fileSize: trackSize,
|
|
80
77
|
});
|
|
@@ -17,7 +17,7 @@ describe("Renders", () => {
|
|
|
17
17
|
describe("createRender", () => {
|
|
18
18
|
test("throws if server returns an error", async () => {
|
|
19
19
|
server.use(
|
|
20
|
-
http.post("http://localhost/api/
|
|
20
|
+
http.post("http://localhost/api/v1/renders", () =>
|
|
21
21
|
HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
22
22
|
),
|
|
23
23
|
);
|
|
@@ -31,7 +31,7 @@ describe("Renders", () => {
|
|
|
31
31
|
|
|
32
32
|
test("returns json data from the http response", async () => {
|
|
33
33
|
server.use(
|
|
34
|
-
http.post("http://localhost/api/
|
|
34
|
+
http.post("http://localhost/api/v1/renders", () =>
|
|
35
35
|
HttpResponse.json(
|
|
36
36
|
{ testResponse: "test" },
|
|
37
37
|
{ status: 200, statusText: "OK" },
|
|
@@ -61,7 +61,7 @@ describe("Renders", () => {
|
|
|
61
61
|
|
|
62
62
|
test("throws if server returns an error", async () => {
|
|
63
63
|
server.use(
|
|
64
|
-
http.post("http://localhost/api/
|
|
64
|
+
http.post("http://localhost/api/v1/renders/test-id/upload", () =>
|
|
65
65
|
HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
66
66
|
),
|
|
67
67
|
);
|
|
@@ -80,7 +80,7 @@ describe("Renders", () => {
|
|
|
80
80
|
|
|
81
81
|
test("returns json data from the http response", async () => {
|
|
82
82
|
server.use(
|
|
83
|
-
http.post("http://localhost/api/
|
|
83
|
+
http.post("http://localhost/api/v1/renders/test-id/upload", () =>
|
|
84
84
|
HttpResponse.json(
|
|
85
85
|
{ testResponse: "test" },
|
|
86
86
|
{ status: 200, statusText: "OK" },
|
|
@@ -102,7 +102,7 @@ describe("Renders", () => {
|
|
|
102
102
|
|
|
103
103
|
const createTestRender = () =>
|
|
104
104
|
({
|
|
105
|
-
|
|
105
|
+
md5: "test-md5",
|
|
106
106
|
fps: 30,
|
|
107
107
|
width: 1920,
|
|
108
108
|
height: 1080,
|
package/src/resources/renders.ts
CHANGED
|
@@ -9,7 +9,7 @@ const log = debug("ef:api:renders");
|
|
|
9
9
|
const FILE_SIZE_LIMIT = 1024 * 1024 * 16; // 16MiB
|
|
10
10
|
|
|
11
11
|
export const CreateRenderPayload = z.object({
|
|
12
|
-
|
|
12
|
+
md5: z.string(),
|
|
13
13
|
fps: z.number(),
|
|
14
14
|
width: z.number().int(),
|
|
15
15
|
height: z.number().int(),
|
|
@@ -19,8 +19,9 @@ export const CreateRenderPayload = z.object({
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
export interface CreateRenderResult {
|
|
22
|
-
status: "complete" | "created" | "failed" | "pending" | "rendering";
|
|
23
22
|
id: string;
|
|
23
|
+
md5: string;
|
|
24
|
+
status: "complete" | "created" | "failed" | "pending" | "rendering";
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export const createRender = async (
|
|
@@ -28,7 +29,7 @@ export const createRender = async (
|
|
|
28
29
|
payload: z.infer<typeof CreateRenderPayload>,
|
|
29
30
|
) => {
|
|
30
31
|
log("Creating render", payload);
|
|
31
|
-
const response = await client.authenticatedFetch("/api/
|
|
32
|
+
const response = await client.authenticatedFetch("/api/v1/renders", {
|
|
32
33
|
method: "POST",
|
|
33
34
|
body: JSON.stringify(payload),
|
|
34
35
|
});
|
|
@@ -55,7 +56,7 @@ export const uploadRender = async (
|
|
|
55
56
|
throw new Error(`File size exceeds limit of ${FILE_SIZE_LIMIT} bytes`);
|
|
56
57
|
}
|
|
57
58
|
const response = await client.authenticatedFetch(
|
|
58
|
-
`/api/
|
|
59
|
+
`/api/v1/renders/${fileId}/upload`,
|
|
59
60
|
{
|
|
60
61
|
method: "POST",
|
|
61
62
|
body: fileStream,
|
|
@@ -22,6 +22,11 @@ const client = new Client("ef_TEST_TOKEN", "http://localhost");
|
|
|
22
22
|
|
|
23
23
|
const TEST_AV_FILE = join(__dirname, "test-av-file.txt");
|
|
24
24
|
|
|
25
|
+
const UploadMustContinue = (id = "test-file") =>
|
|
26
|
+
http.get(`http://localhost/api/v1/unprocessed_files/${id}/upload`, () =>
|
|
27
|
+
HttpResponse.json({}, { status: 202 }),
|
|
28
|
+
);
|
|
29
|
+
|
|
25
30
|
describe("Unprocessed File", () => {
|
|
26
31
|
beforeAll(() => server.listen());
|
|
27
32
|
afterEach(() => server.resetHandlers());
|
|
@@ -31,7 +36,7 @@ describe("Unprocessed File", () => {
|
|
|
31
36
|
test("Throws when file is too large", async () => {
|
|
32
37
|
await expect(
|
|
33
38
|
createUnprocessedFile(client, {
|
|
34
|
-
|
|
39
|
+
md5: "test-file",
|
|
35
40
|
filename: "test-file",
|
|
36
41
|
processes: [],
|
|
37
42
|
byte_size: 1024 * 1024 * 1025,
|
|
@@ -60,7 +65,7 @@ describe("Unprocessed File", () => {
|
|
|
60
65
|
|
|
61
66
|
await expect(
|
|
62
67
|
createUnprocessedFile(client, {
|
|
63
|
-
|
|
68
|
+
md5: "test-file",
|
|
64
69
|
filename: "test-file",
|
|
65
70
|
processes: [],
|
|
66
71
|
byte_size: 1024 * 1024,
|
|
@@ -81,7 +86,7 @@ describe("Unprocessed File", () => {
|
|
|
81
86
|
);
|
|
82
87
|
|
|
83
88
|
const result = await createUnprocessedFile(client, {
|
|
84
|
-
|
|
89
|
+
md5: "test-file",
|
|
85
90
|
filename: "test-file",
|
|
86
91
|
processes: [],
|
|
87
92
|
byte_size: 1024 * 1024,
|
|
@@ -129,6 +134,7 @@ describe("Unprocessed File", () => {
|
|
|
129
134
|
describe("uploadUnprocessedFile", () => {
|
|
130
135
|
test("Throws when server responds with an error", async () => {
|
|
131
136
|
server.use(
|
|
137
|
+
UploadMustContinue(),
|
|
132
138
|
http.post(
|
|
133
139
|
"http://localhost/api/v1/unprocessed_files/test-file/upload",
|
|
134
140
|
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
@@ -149,6 +155,7 @@ describe("Unprocessed File", () => {
|
|
|
149
155
|
|
|
150
156
|
test("Succeeds when server returns a success", async () => {
|
|
151
157
|
server.use(
|
|
158
|
+
UploadMustContinue(),
|
|
152
159
|
http.post(
|
|
153
160
|
"http://localhost/api/v1/unprocessed_files/test-file/upload",
|
|
154
161
|
() => HttpResponse.json({}, { status: 201 }),
|
|
@@ -169,6 +176,7 @@ describe("Unprocessed File", () => {
|
|
|
169
176
|
describe("processAVFileBuffer", () => {
|
|
170
177
|
test("Throws when server responds with an error when creating file", async () => {
|
|
171
178
|
server.use(
|
|
179
|
+
UploadMustContinue(),
|
|
172
180
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
173
181
|
HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
174
182
|
),
|
|
@@ -184,8 +192,16 @@ describe("Unprocessed File", () => {
|
|
|
184
192
|
test("Throws when server responds with an error when uploading file", async () => {
|
|
185
193
|
server.use(
|
|
186
194
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
187
|
-
HttpResponse.json(
|
|
195
|
+
HttpResponse.json(
|
|
196
|
+
{
|
|
197
|
+
complete: false,
|
|
198
|
+
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
199
|
+
processes: [],
|
|
200
|
+
},
|
|
201
|
+
{ status: 200 },
|
|
202
|
+
),
|
|
188
203
|
),
|
|
204
|
+
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
189
205
|
http.post(
|
|
190
206
|
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
191
207
|
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
@@ -202,8 +218,16 @@ describe("Unprocessed File", () => {
|
|
|
202
218
|
test("Throws when server responds with an error when updating file", async () => {
|
|
203
219
|
server.use(
|
|
204
220
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
205
|
-
HttpResponse.json(
|
|
221
|
+
HttpResponse.json(
|
|
222
|
+
{
|
|
223
|
+
complete: false,
|
|
224
|
+
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
225
|
+
processes: [],
|
|
226
|
+
},
|
|
227
|
+
{ status: 200 },
|
|
228
|
+
),
|
|
206
229
|
),
|
|
230
|
+
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
207
231
|
http.post(
|
|
208
232
|
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
209
233
|
() => HttpResponse.json({ test }, { status: 201 }),
|
|
@@ -224,8 +248,16 @@ describe("Unprocessed File", () => {
|
|
|
224
248
|
test("Returns json data when upload is successful", async () => {
|
|
225
249
|
server.use(
|
|
226
250
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
227
|
-
HttpResponse.json(
|
|
251
|
+
HttpResponse.json(
|
|
252
|
+
{
|
|
253
|
+
complete: false,
|
|
254
|
+
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
255
|
+
processes: [],
|
|
256
|
+
},
|
|
257
|
+
{ status: 200 },
|
|
258
|
+
),
|
|
228
259
|
),
|
|
260
|
+
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
229
261
|
http.post(
|
|
230
262
|
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
231
263
|
() => HttpResponse.json({}, { status: 201 }),
|
|
@@ -258,8 +290,16 @@ describe("Unprocessed File", () => {
|
|
|
258
290
|
test("Throws when server responds with an error when uploading file", async () => {
|
|
259
291
|
server.use(
|
|
260
292
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
261
|
-
HttpResponse.json(
|
|
293
|
+
HttpResponse.json(
|
|
294
|
+
{
|
|
295
|
+
complete: false,
|
|
296
|
+
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
297
|
+
processes: [],
|
|
298
|
+
},
|
|
299
|
+
{ status: 200 },
|
|
300
|
+
),
|
|
262
301
|
),
|
|
302
|
+
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
263
303
|
http.post(
|
|
264
304
|
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
265
305
|
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
@@ -274,8 +314,16 @@ describe("Unprocessed File", () => {
|
|
|
274
314
|
test("Throws when server responds with an error when updating file", async () => {
|
|
275
315
|
server.use(
|
|
276
316
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
277
|
-
HttpResponse.json(
|
|
317
|
+
HttpResponse.json(
|
|
318
|
+
{
|
|
319
|
+
complete: false,
|
|
320
|
+
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
321
|
+
processes: [],
|
|
322
|
+
},
|
|
323
|
+
{ status: 200 },
|
|
324
|
+
),
|
|
278
325
|
),
|
|
326
|
+
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
279
327
|
http.post(
|
|
280
328
|
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
281
329
|
() => HttpResponse.json({ test }, { status: 201 }),
|
|
@@ -294,8 +342,16 @@ describe("Unprocessed File", () => {
|
|
|
294
342
|
test("Returns json data when upload is successful", async () => {
|
|
295
343
|
server.use(
|
|
296
344
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
297
|
-
HttpResponse.json(
|
|
345
|
+
HttpResponse.json(
|
|
346
|
+
{
|
|
347
|
+
complete: false,
|
|
348
|
+
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
349
|
+
processes: [],
|
|
350
|
+
},
|
|
351
|
+
{ status: 200 },
|
|
352
|
+
),
|
|
298
353
|
),
|
|
354
|
+
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
299
355
|
http.post(
|
|
300
356
|
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
301
357
|
() => HttpResponse.json({}, { status: 201 }),
|
|
@@ -330,8 +386,16 @@ describe("Unprocessed File", () => {
|
|
|
330
386
|
test("Throws when server responds with an error when uploading file", async () => {
|
|
331
387
|
server.use(
|
|
332
388
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
333
|
-
HttpResponse.json(
|
|
389
|
+
HttpResponse.json(
|
|
390
|
+
{
|
|
391
|
+
complete: false,
|
|
392
|
+
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
393
|
+
processes: [],
|
|
394
|
+
},
|
|
395
|
+
{ status: 200 },
|
|
396
|
+
),
|
|
334
397
|
),
|
|
398
|
+
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
335
399
|
http.post(
|
|
336
400
|
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
337
401
|
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
@@ -348,8 +412,16 @@ describe("Unprocessed File", () => {
|
|
|
348
412
|
test("Throws when server responds with an error when updating file", async () => {
|
|
349
413
|
server.use(
|
|
350
414
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
351
|
-
HttpResponse.json(
|
|
415
|
+
HttpResponse.json(
|
|
416
|
+
{
|
|
417
|
+
complete: false,
|
|
418
|
+
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
419
|
+
processes: [],
|
|
420
|
+
},
|
|
421
|
+
{ status: 200 },
|
|
422
|
+
),
|
|
352
423
|
),
|
|
424
|
+
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
353
425
|
http.post(
|
|
354
426
|
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
355
427
|
() => HttpResponse.json({ test }, { status: 201 }),
|
|
@@ -370,8 +442,16 @@ describe("Unprocessed File", () => {
|
|
|
370
442
|
test("Returns json data when upload is successful", async () => {
|
|
371
443
|
server.use(
|
|
372
444
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
373
|
-
HttpResponse.json(
|
|
445
|
+
HttpResponse.json(
|
|
446
|
+
{
|
|
447
|
+
complete: false,
|
|
448
|
+
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
449
|
+
processes: [],
|
|
450
|
+
},
|
|
451
|
+
{ status: 200 },
|
|
452
|
+
),
|
|
374
453
|
),
|
|
454
|
+
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
375
455
|
http.post(
|
|
376
456
|
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
377
457
|
() => HttpResponse.json({}, { status: 201 }),
|
|
@@ -404,8 +484,16 @@ describe("Unprocessed File", () => {
|
|
|
404
484
|
test("Throws when server responds with an error when uploading file", async () => {
|
|
405
485
|
server.use(
|
|
406
486
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
407
|
-
HttpResponse.json(
|
|
487
|
+
HttpResponse.json(
|
|
488
|
+
{
|
|
489
|
+
complete: false,
|
|
490
|
+
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
491
|
+
processes: [],
|
|
492
|
+
},
|
|
493
|
+
{ status: 200 },
|
|
494
|
+
),
|
|
408
495
|
),
|
|
496
|
+
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
409
497
|
http.post(
|
|
410
498
|
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
411
499
|
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
@@ -420,8 +508,16 @@ describe("Unprocessed File", () => {
|
|
|
420
508
|
test("Throws when server responds with an error when updating file", async () => {
|
|
421
509
|
server.use(
|
|
422
510
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
423
|
-
HttpResponse.json(
|
|
511
|
+
HttpResponse.json(
|
|
512
|
+
{
|
|
513
|
+
complete: false,
|
|
514
|
+
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
515
|
+
processes: [],
|
|
516
|
+
},
|
|
517
|
+
{ status: 200 },
|
|
518
|
+
),
|
|
424
519
|
),
|
|
520
|
+
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
425
521
|
http.post(
|
|
426
522
|
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
427
523
|
() => HttpResponse.json({ test }, { status: 201 }),
|
|
@@ -440,8 +536,16 @@ describe("Unprocessed File", () => {
|
|
|
440
536
|
test("Returns json data when upload is successful", async () => {
|
|
441
537
|
server.use(
|
|
442
538
|
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
443
|
-
HttpResponse.json(
|
|
539
|
+
HttpResponse.json(
|
|
540
|
+
{
|
|
541
|
+
complete: false,
|
|
542
|
+
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
543
|
+
processes: [],
|
|
544
|
+
},
|
|
545
|
+
{ status: 200 },
|
|
546
|
+
),
|
|
444
547
|
),
|
|
548
|
+
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
445
549
|
http.post(
|
|
446
550
|
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
447
551
|
() => HttpResponse.json({}, { status: 201 }),
|