@editframe/api 0.10.0-beta.2 → 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.
@@ -40,6 +40,12 @@ async function uploadChunks(client, {
40
40
  fileStream,
41
41
  chunkSizeBytes = CHUNK_SIZE_BYTES
42
42
  }) {
43
+ log("Checking upload status", url);
44
+ const uploadStatus = await client.authenticatedFetch(url);
45
+ if (uploadStatus.status === 200) {
46
+ log("Fragment track already uploaded");
47
+ return;
48
+ }
43
49
  let chunkNumber = 0;
44
50
  let complete = false;
45
51
  for await (const chunkBuffer of streamChunker(fileStream, chunkSizeBytes)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editframe/api",
3
- "version": "0.10.0-beta.2",
3
+ "version": "0.10.0-beta.3",
4
4
  "description": "API functions for EditFrame",
5
5
  "exports": {
6
6
  ".": {
@@ -28,7 +28,7 @@
28
28
  "vite-tsconfig-paths": "^4.3.2"
29
29
  },
30
30
  "dependencies": {
31
- "@editframe/assets": "0.10.0-beta.2",
31
+ "@editframe/assets": "0.10.0-beta.3",
32
32
  "debug": "^4.3.5",
33
33
  "jsonwebtoken": "^9.0.2",
34
34
  "node-fetch": "^3.3.2",
@@ -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());
@@ -99,6 +104,7 @@ 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
109
  "http://localhost/api/v1/image_files/test-file-id/upload",
104
110
  () => HttpResponse.text("Internal Server Error", { status: 500 }),
@@ -119,6 +125,7 @@ describe("ImageFile", () => {
119
125
 
120
126
  test("Uploads file", async () => {
121
127
  server.use(
128
+ UploadMustContinue("test-file-id"),
122
129
  http.post(
123
130
  "http://localhost/api/v1/image_files/test-file-id/upload",
124
131
  () => HttpResponse.json(null, { status: 201 }),
@@ -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());
@@ -73,6 +79,7 @@ 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
84
  "http://localhost/api/v1/isobmff_tracks/test-file/1/upload",
78
85
  () => HttpResponse.text("Internal Server Error", { status: 500 }),
@@ -94,6 +101,7 @@ describe("ISOBMFF Track", () => {
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
106
  "http://localhost/api/v1/isobmff_tracks/test-file/1/upload",
99
107
  () => HttpResponse.json({}, { status: 201 }),
@@ -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());
@@ -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
  ),
@@ -193,6 +201,7 @@ describe("Unprocessed File", () => {
193
201
  { status: 200 },
194
202
  ),
195
203
  ),
204
+ UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
196
205
  http.post(
197
206
  "http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
198
207
  () => HttpResponse.text("Internal Server Error", { status: 500 }),
@@ -218,6 +227,7 @@ describe("Unprocessed File", () => {
218
227
  { status: 200 },
219
228
  ),
220
229
  ),
230
+ UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
221
231
  http.post(
222
232
  "http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
223
233
  () => HttpResponse.json({ test }, { status: 201 }),
@@ -247,6 +257,7 @@ describe("Unprocessed File", () => {
247
257
  { status: 200 },
248
258
  ),
249
259
  ),
260
+ UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
250
261
  http.post(
251
262
  "http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
252
263
  () => HttpResponse.json({}, { status: 201 }),
@@ -288,6 +299,7 @@ describe("Unprocessed File", () => {
288
299
  { status: 200 },
289
300
  ),
290
301
  ),
302
+ UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
291
303
  http.post(
292
304
  "http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
293
305
  () => HttpResponse.text("Internal Server Error", { status: 500 }),
@@ -311,6 +323,7 @@ describe("Unprocessed File", () => {
311
323
  { status: 200 },
312
324
  ),
313
325
  ),
326
+ UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
314
327
  http.post(
315
328
  "http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
316
329
  () => HttpResponse.json({ test }, { status: 201 }),
@@ -338,6 +351,7 @@ describe("Unprocessed File", () => {
338
351
  { status: 200 },
339
352
  ),
340
353
  ),
354
+ UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
341
355
  http.post(
342
356
  "http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
343
357
  () => HttpResponse.json({}, { status: 201 }),
@@ -381,6 +395,7 @@ describe("Unprocessed File", () => {
381
395
  { status: 200 },
382
396
  ),
383
397
  ),
398
+ UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
384
399
  http.post(
385
400
  "http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
386
401
  () => HttpResponse.text("Internal Server Error", { status: 500 }),
@@ -406,6 +421,7 @@ describe("Unprocessed File", () => {
406
421
  { status: 200 },
407
422
  ),
408
423
  ),
424
+ UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
409
425
  http.post(
410
426
  "http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
411
427
  () => HttpResponse.json({ test }, { status: 201 }),
@@ -435,6 +451,7 @@ describe("Unprocessed File", () => {
435
451
  { status: 200 },
436
452
  ),
437
453
  ),
454
+ UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
438
455
  http.post(
439
456
  "http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
440
457
  () => HttpResponse.json({}, { status: 201 }),
@@ -476,6 +493,7 @@ describe("Unprocessed File", () => {
476
493
  { status: 200 },
477
494
  ),
478
495
  ),
496
+ UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
479
497
  http.post(
480
498
  "http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
481
499
  () => HttpResponse.text("Internal Server Error", { status: 500 }),
@@ -499,6 +517,7 @@ describe("Unprocessed File", () => {
499
517
  { status: 200 },
500
518
  ),
501
519
  ),
520
+ UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
502
521
  http.post(
503
522
  "http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
504
523
  () => HttpResponse.json({ test }, { status: 201 }),
@@ -526,6 +545,7 @@ describe("Unprocessed File", () => {
526
545
  { status: 200 },
527
546
  ),
528
547
  ),
548
+ UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
529
549
  http.post(
530
550
  "http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
531
551
  () => HttpResponse.json({}, { status: 201 }),