@editframe/cli 0.11.0-beta.9 → 0.12.0-beta.10

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.
Files changed (39) hide show
  1. package/dist/VERSION.d.ts +1 -1
  2. package/dist/VERSION.js +1 -1
  3. package/dist/commands/process-file.js +27 -30
  4. package/dist/commands/render.js +8 -2
  5. package/dist/operations/getRenderInfo.d.ts +2 -2
  6. package/dist/operations/syncAssetsDirectory/SubAssetSync.js +3 -0
  7. package/dist/operations/syncAssetsDirectory/SyncCaption.d.ts +2 -2
  8. package/dist/operations/syncAssetsDirectory/SyncCaption.js +19 -8
  9. package/dist/operations/syncAssetsDirectory/SyncFragmentIndex.d.ts +2 -2
  10. package/dist/operations/syncAssetsDirectory/SyncFragmentIndex.js +19 -12
  11. package/dist/operations/syncAssetsDirectory/SyncImage.d.ts +2 -2
  12. package/dist/operations/syncAssetsDirectory/SyncImage.js +20 -13
  13. package/dist/operations/syncAssetsDirectory/SyncStatus.d.ts +7 -11
  14. package/dist/operations/syncAssetsDirectory/SyncStatus.js +1 -1
  15. package/dist/operations/syncAssetsDirectory/SyncTrack.d.ts +4 -4
  16. package/dist/operations/syncAssetsDirectory/SyncTrack.js +14 -12
  17. package/dist/utils/createReadableStreamFromReadable.d.ts +4 -0
  18. package/dist/utils/createReadableStreamFromReadable.js +82 -0
  19. package/dist/utils/launchBrowserAndWaitForSDK.js +2 -2
  20. package/dist/utils/validateVideoResolution.d.ts +1 -1
  21. package/package.json +5 -5
  22. package/src/commands/process-file.ts +33 -37
  23. package/src/commands/render.ts +9 -2
  24. package/src/operations/syncAssetsDirectory/SubAssetSync.ts +4 -0
  25. package/src/operations/syncAssetsDirectory/SyncCaption.test.ts +29 -3
  26. package/src/operations/syncAssetsDirectory/SyncCaption.ts +22 -9
  27. package/src/operations/syncAssetsDirectory/SyncFragmentIndex.test.ts +30 -4
  28. package/src/operations/syncAssetsDirectory/SyncFragmentIndex.ts +22 -13
  29. package/src/operations/syncAssetsDirectory/SyncImage.test.ts +27 -3
  30. package/src/operations/syncAssetsDirectory/SyncImage.ts +27 -17
  31. package/src/operations/syncAssetsDirectory/SyncStatus.ts +3 -3
  32. package/src/operations/syncAssetsDirectory/SyncTrack.test.ts +38 -3
  33. package/src/operations/syncAssetsDirectory/SyncTrack.ts +20 -13
  34. package/src/operations/syncAssetsDirectory.test.ts +22 -1
  35. package/src/utils/createReadableStreamFromReadable.ts +117 -0
  36. package/src/utils/launchBrowserAndWaitForSDK.ts +2 -2
  37. package/src/utils/startDevServer.ts +1 -1
  38. package/test-fixtures/fixture.ts +0 -1
  39. package/test-fixtures/network.ts +72 -29
@@ -1,10 +1,12 @@
1
+ import { useMSW } from "TEST/useMSW.ts";
1
2
  import { describe, expect, test } from "vitest";
2
3
  import { fixture, withFixtures } from "../../../test-fixtures/fixture.ts";
3
4
  import {
4
5
  mockCreateIsobmffFile,
5
6
  mockCreateIsobmffTrack,
6
7
  mockGetIsobmffTrackUpload,
7
- useMSW,
8
+ mockLookupISOBMFFFileByMd5,
9
+ mockLookupISOBMFFFileByMd5NotFound,
8
10
  } from "../../../test-fixtures/network.ts";
9
11
  import { SyncTrack } from "./SyncTrack.ts";
10
12
 
@@ -21,8 +23,28 @@ describe("SyncTrack", async () => {
21
23
  await expect(syncTrack.byteSize()).resolves.toEqual(26434);
22
24
  });
23
25
  describe("prepare()", () => {
26
+ test("Uses existing ISOBMFF file if md5 matches", async () => {
27
+ server.use(
28
+ mockLookupISOBMFFFileByMd5({
29
+ complete: true,
30
+ id: "123",
31
+ md5: video!.md5,
32
+ fixture: video!,
33
+ }),
34
+ );
35
+ const syncTrack = new SyncTrack(
36
+ await generateTrack(video!, 1),
37
+ video!.md5,
38
+ );
39
+ await syncTrack.prepare();
40
+ expect(syncTrack.isoFile).toBeDefined();
41
+ });
42
+
24
43
  test("Creates ISOBMFF file", async () => {
25
44
  server.use(
45
+ mockLookupISOBMFFFileByMd5NotFound({
46
+ md5: video!.md5,
47
+ }),
26
48
  mockCreateIsobmffFile({
27
49
  complete: true,
28
50
  id: "123",
@@ -40,6 +62,9 @@ describe("SyncTrack", async () => {
40
62
 
41
63
  test("Probes track", async () => {
42
64
  server.use(
65
+ mockLookupISOBMFFFileByMd5NotFound({
66
+ md5: video!.md5,
67
+ }),
43
68
  mockCreateIsobmffFile({
44
69
  complete: true,
45
70
  id: "123",
@@ -81,6 +106,9 @@ describe("SyncTrack", async () => {
81
106
 
82
107
  test("isComplete() returns false when not complete", async () => {
83
108
  server.use(
109
+ mockLookupISOBMFFFileByMd5NotFound({
110
+ md5: video!.md5,
111
+ }),
84
112
  mockCreateIsobmffFile({
85
113
  complete: true,
86
114
  id: "123",
@@ -106,6 +134,9 @@ describe("SyncTrack", async () => {
106
134
 
107
135
  test("isComplete() returns true when complete", async () => {
108
136
  server.use(
137
+ mockLookupISOBMFFFileByMd5NotFound({
138
+ md5: video!.md5,
139
+ }),
109
140
  mockCreateIsobmffFile({
110
141
  complete: true,
111
142
  id: "123",
@@ -140,6 +171,9 @@ describe("SyncTrack", async () => {
140
171
  });
141
172
  test("uploads track", async () => {
142
173
  server.use(
174
+ mockLookupISOBMFFFileByMd5NotFound({
175
+ md5: video!.md5,
176
+ }),
143
177
  mockCreateIsobmffFile({
144
178
  complete: true,
145
179
  id: "123",
@@ -178,6 +212,9 @@ describe("SyncTrack", async () => {
178
212
  });
179
213
  test("marks synced", async () => {
180
214
  server.use(
215
+ mockLookupISOBMFFFileByMd5NotFound({
216
+ md5: video!.md5,
217
+ }),
181
218
  mockCreateIsobmffFile({
182
219
  complete: true,
183
220
  id: "123",
@@ -203,7 +240,6 @@ describe("SyncTrack", async () => {
203
240
  complete: true,
204
241
  id: "123:track-1",
205
242
  md5: video!.md5,
206
- asset_id: `${video!.md5}:test.mp4`,
207
243
  byte_size: 26434,
208
244
  });
209
245
 
@@ -212,7 +248,6 @@ describe("SyncTrack", async () => {
212
248
  complete: true,
213
249
  id: "123",
214
250
  md5: video!.md5,
215
- asset_id: `${video!.md5}:test.mp4`,
216
251
  byte_size: 26434,
217
252
  });
218
253
  });
@@ -1,6 +1,6 @@
1
1
  import { createReadStream } from "node:fs";
2
2
  import fs from "node:fs/promises";
3
- import { dirname, join } from "node:path";
3
+ import { basename, dirname, join } from "node:path";
4
4
 
5
5
  import type { z } from "zod";
6
6
 
@@ -8,12 +8,15 @@ import {
8
8
  type CreateISOBMFFFileResult,
9
9
  type CreateISOBMFFTrackPayload,
10
10
  type CreateISOBMFFTrackResult,
11
+ type LookupISOBMFFFileByMd5Result,
11
12
  createISOBMFFFile,
12
13
  createISOBMFFTrack,
14
+ lookupISOBMFFFileByMd5,
13
15
  uploadISOBMFFTrack,
14
16
  } from "@editframe/api";
15
17
  import { Probe } from "@editframe/assets";
16
18
 
19
+ import { createReadableStreamFromReadable } from "../../utils/createReadableStreamFromReadable.ts";
17
20
  import { getClient } from "../../utils/index.ts";
18
21
  import type { SubAssetSync } from "./SubAssetSync.ts";
19
22
  import { SyncStatus } from "./SyncStatus.ts";
@@ -21,10 +24,8 @@ import { SyncStatus } from "./SyncStatus.ts";
21
24
  export class SyncTrack implements SubAssetSync<CreateISOBMFFTrackResult> {
22
25
  icon = "📼";
23
26
  label = "track";
24
- syncStatus: SyncStatus = new SyncStatus(this.path);
25
- fileSyncStatus: SyncStatus = new SyncStatus(
26
- join(dirname(this.path), "isobmff"),
27
- );
27
+ syncStatus = new SyncStatus(this.path);
28
+ fileSyncStatus = new SyncStatus(join(dirname(this.path), "isobmff"));
28
29
  created: CreateISOBMFFTrackResult | null = null;
29
30
 
30
31
  constructor(
@@ -32,7 +33,10 @@ export class SyncTrack implements SubAssetSync<CreateISOBMFFTrackResult> {
32
33
  public md5: string,
33
34
  ) {}
34
35
 
35
- private _isoFile: CreateISOBMFFFileResult | null = null;
36
+ private _isoFile:
37
+ | CreateISOBMFFFileResult
38
+ | LookupISOBMFFFileByMd5Result
39
+ | null = null;
36
40
 
37
41
  get isoFile() {
38
42
  if (this._isoFile) {
@@ -62,10 +66,15 @@ export class SyncTrack implements SubAssetSync<CreateISOBMFFTrackResult> {
62
66
  }
63
67
 
64
68
  async prepare() {
65
- this._isoFile = await createISOBMFFFile(getClient(), {
66
- md5: this.md5,
67
- filename: this.path.replace(/\.track-[\d]+.mp4$/, ""),
68
- });
69
+ const maybeIsoFile = await lookupISOBMFFFileByMd5(getClient(), this.md5);
70
+ if (maybeIsoFile) {
71
+ this._isoFile = maybeIsoFile;
72
+ } else {
73
+ this._isoFile = await createISOBMFFFile(getClient(), {
74
+ md5: this.md5,
75
+ filename: basename(this.path).replace(/\.track-[\d]+.mp4$/, ""),
76
+ });
77
+ }
69
78
  this._probeResult = await Probe.probePath(this.path);
70
79
  }
71
80
 
@@ -131,7 +140,7 @@ export class SyncTrack implements SubAssetSync<CreateISOBMFFTrackResult> {
131
140
  getClient(),
132
141
  this.isoFile.id,
133
142
  Number(this.trackId),
134
- createReadStream(this.path),
143
+ createReadableStreamFromReadable(createReadStream(this.path)),
135
144
  this.created?.byte_size,
136
145
  ).whenUploaded();
137
146
  }
@@ -148,7 +157,6 @@ export class SyncTrack implements SubAssetSync<CreateISOBMFFTrackResult> {
148
157
  complete: true,
149
158
  id: `${this.created.file_id}:${this.created.track_id}`,
150
159
  md5: this.md5,
151
- asset_id: this.created.asset_id,
152
160
  byte_size: byteSize,
153
161
  }),
154
162
  this.fileSyncStatus.markSynced({
@@ -156,7 +164,6 @@ export class SyncTrack implements SubAssetSync<CreateISOBMFFTrackResult> {
156
164
  complete: true,
157
165
  id: this.created.file_id,
158
166
  md5: this.md5,
159
- asset_id: this.created.asset_id,
160
167
  byte_size: byteSize,
161
168
  }),
162
169
  ]);
@@ -1,13 +1,15 @@
1
1
  import { describe, it } from "vitest";
2
2
 
3
+ import { useMSW } from "TEST/useMSW.ts";
3
4
  import { fixture, withFixtures } from "../../test-fixtures/fixture.ts";
4
5
  import {
5
6
  mockCreateImageFile,
6
7
  mockCreateIsobmffFile,
7
8
  mockCreateIsobmffTrack,
8
9
  mockGetUploadImageFile,
10
+ mockLookupISOBMFFFileByMd5NotFound,
11
+ mockLookupImageFileByMd5NotFound,
9
12
  mockUploadIsobmffFileIndex,
10
- useMSW,
11
13
  } from "../../test-fixtures/network.ts";
12
14
 
13
15
  describe("syncAssetsDirectory", () => {
@@ -25,6 +27,9 @@ describe("syncAssetsDirectory", () => {
25
27
  cacheImage,
26
28
  }) => {
27
29
  server.use(
30
+ mockLookupImageFileByMd5NotFound({
31
+ md5: testPng!.md5,
32
+ }),
28
33
  mockCreateImageFile({
29
34
  complete: true,
30
35
  id: "123",
@@ -55,6 +60,9 @@ describe("syncAssetsDirectory", () => {
55
60
  syncAssetsDirectory,
56
61
  }) => {
57
62
  server.use(
63
+ mockLookupImageFileByMd5NotFound({
64
+ md5: testPng!.md5,
65
+ }),
58
66
  mockCreateImageFile({
59
67
  complete: false,
60
68
  id: "123",
@@ -91,6 +99,9 @@ describe("syncAssetsDirectory", () => {
91
99
  expectInfoFileContent,
92
100
  }) => {
93
101
  server.use(
102
+ mockLookupImageFileByMd5NotFound({
103
+ md5: testPng!.md5,
104
+ }),
94
105
  mockCreateImageFile({
95
106
  complete: false,
96
107
  id: "123",
@@ -160,6 +171,10 @@ describe("syncAssetsDirectory", () => {
160
171
  fixture: testMp4!,
161
172
  };
162
173
  server.use(
174
+ mockLookupISOBMFFFileByMd5NotFound({
175
+ md5: testMp4!.md5,
176
+ }),
177
+
163
178
  mockCreateIsobmffFile(creationArgs),
164
179
 
165
180
  mockCreateIsobmffTrack({
@@ -247,6 +262,9 @@ describe("syncAssetsDirectory", () => {
247
262
  fixture: testMp4!,
248
263
  };
249
264
  server.use(
265
+ mockLookupISOBMFFFileByMd5NotFound({
266
+ md5: testMp4!.md5,
267
+ }),
250
268
  mockCreateIsobmffFile(creationArgs),
251
269
  mockUploadIsobmffFileIndex({
252
270
  id: "123",
@@ -326,6 +344,9 @@ describe("syncAssetsDirectory", () => {
326
344
  expectCacheFiles,
327
345
  }) => {
328
346
  server.use(
347
+ mockLookupISOBMFFFileByMd5NotFound({
348
+ md5: testMp4!.md5,
349
+ }),
329
350
  mockCreateIsobmffFile({
330
351
  complete: true,
331
352
  id: "123",
@@ -0,0 +1,117 @@
1
+ import { type Readable, Stream } from "node:stream";
2
+
3
+ export const createReadableStreamFromReadable = (
4
+ source: Readable & { readableHighWaterMark?: number },
5
+ ) => {
6
+ const pump = new StreamPump(source);
7
+ const stream = new ReadableStream(pump, pump);
8
+ return stream;
9
+ };
10
+
11
+ class StreamPump {
12
+ public highWaterMark: number;
13
+ public accumalatedSize: number;
14
+ private stream: Stream & {
15
+ readableHighWaterMark?: number;
16
+ readable?: boolean;
17
+ resume?: () => void;
18
+ pause?: () => void;
19
+ destroy?: (error?: Error) => void;
20
+ };
21
+ private controller?: ReadableStreamController<Uint8Array>;
22
+
23
+ constructor(
24
+ stream: Stream & {
25
+ readableHighWaterMark?: number;
26
+ readable?: boolean;
27
+ resume?: () => void;
28
+ pause?: () => void;
29
+ destroy?: (error?: Error) => void;
30
+ },
31
+ ) {
32
+ this.highWaterMark =
33
+ stream.readableHighWaterMark ||
34
+ new Stream.Readable().readableHighWaterMark;
35
+ this.accumalatedSize = 0;
36
+ this.stream = stream;
37
+ this.enqueue = this.enqueue.bind(this);
38
+ this.error = this.error.bind(this);
39
+ this.close = this.close.bind(this);
40
+ }
41
+
42
+ size(chunk: Uint8Array) {
43
+ return chunk?.byteLength || 0;
44
+ }
45
+
46
+ start(controller: ReadableStreamController<Uint8Array>) {
47
+ this.controller = controller;
48
+ this.stream.on("data", this.enqueue);
49
+ this.stream.once("error", this.error);
50
+ this.stream.once("end", this.close);
51
+ this.stream.once("close", this.close);
52
+ }
53
+
54
+ pull() {
55
+ this.resume();
56
+ }
57
+
58
+ cancel(reason?: Error) {
59
+ if (this.stream.destroy) {
60
+ this.stream.destroy(reason);
61
+ }
62
+
63
+ this.stream.off("data", this.enqueue);
64
+ this.stream.off("error", this.error);
65
+ this.stream.off("end", this.close);
66
+ this.stream.off("close", this.close);
67
+ }
68
+
69
+ enqueue(chunk: Uint8Array | string) {
70
+ if (this.controller) {
71
+ try {
72
+ const bytes = chunk instanceof Uint8Array ? chunk : Buffer.from(chunk);
73
+
74
+ const available = (this.controller.desiredSize || 0) - bytes.byteLength;
75
+ this.controller.enqueue(bytes);
76
+ if (available <= 0) {
77
+ this.pause();
78
+ }
79
+ } catch (error: any) {
80
+ this.controller.error(
81
+ new Error(
82
+ "Could not create Buffer, chunk must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object",
83
+ ),
84
+ );
85
+ this.cancel();
86
+ }
87
+ }
88
+ }
89
+
90
+ pause() {
91
+ if (this.stream.pause) {
92
+ this.stream.pause();
93
+ }
94
+ }
95
+
96
+ resume() {
97
+ if (this.stream.readable && this.stream.resume) {
98
+ this.stream.resume();
99
+ }
100
+ }
101
+
102
+ close() {
103
+ if (this.controller) {
104
+ this.controller.close();
105
+ // biome-ignore lint/performance/noDelete: infrequent use
106
+ delete this.controller;
107
+ }
108
+ }
109
+
110
+ error(error: Error) {
111
+ if (this.controller) {
112
+ this.controller.error(error);
113
+ // biome-ignore lint/performance/noDelete: infrequent use
114
+ delete this.controller;
115
+ }
116
+ }
117
+ }
@@ -1,6 +1,6 @@
1
1
  import chalk from "chalk";
2
- import { type Browser, type Page, chromium } from "playwright";
3
2
  import debug from "debug";
3
+ import { type Browser, type Page, chromium } from "playwright";
4
4
 
5
5
  import { withSpinner } from "./withSpinner.ts";
6
6
 
@@ -26,7 +26,7 @@ export async function launchBrowserAndWaitForSDK(
26
26
  });
27
27
  });
28
28
 
29
- const page = await withSpinner("Loading EditFrame SDK", async () => {
29
+ const page = await withSpinner("Loading Editframe SDK", async () => {
30
30
  const pageOptions: Parameters<Browser["newPage"]>[0] = {};
31
31
  if (options.interactive === true) {
32
32
  // By default, playwright uses its own viewport, so resizing the browser window
@@ -1,7 +1,7 @@
1
1
  import path from "node:path";
2
2
 
3
- import { type ViteDevServer, createServer } from "vite";
4
3
  import tailwindcss from "tailwindcss";
4
+ import { type ViteDevServer, createServer } from "vite";
5
5
 
6
6
  import { vitePluginEditframe as editframe } from "@editframe/vite-plugin";
7
7
 
@@ -80,7 +80,6 @@ export const withFixtures = async (
80
80
  const filePath = join(cacheDir, fixture.md5, fileName);
81
81
  const content = JSON.parse(await readFile(filePath, "utf-8"));
82
82
  expect(content).toMatchObject({
83
- asset_id: `${fixture.md5}:${fixture.name}`,
84
83
  md5: fixture.md5,
85
84
  version: "1",
86
85
  byte_size: fixture.content.length,
@@ -1,44 +1,42 @@
1
1
  import { http, HttpResponse } from "msw";
2
- import { setupServer } from "msw/node";
3
- import { afterAll, afterEach, beforeAll } from "vitest";
4
2
  import type { Fixture } from "./fixture.ts";
5
3
 
6
- const server = setupServer();
7
-
8
- export const useMSW = () => {
9
- beforeAll(() => {
10
- server.listen();
11
- process.env.EF_TOKEN = "ef_SECRET_TOKEN";
12
- process.env.EF_HOST = "http://localhost:3000";
13
- });
14
- afterAll(() => server.close());
15
- afterEach(() => server.resetHandlers());
16
- return server;
17
- };
18
-
19
4
  export const mockCreateImageFile = ({
20
5
  complete = true,
21
6
  id = "123",
22
- filename = "test.png",
23
- fixture,
24
7
  }: { complete?: boolean; id?: string; filename?: string; fixture: Fixture }) =>
25
8
  http.post(
26
9
  "http://localhost:3000/api/v1/image_files",
27
10
  async () => {
28
11
  return HttpResponse.json({
29
12
  id,
30
- asset_id: `${fixture.md5}:${filename}`,
31
13
  complete,
32
14
  });
33
15
  },
34
16
  { once: true },
35
17
  );
36
18
 
19
+ export const mockLookupImageFileByMd5 = ({
20
+ md5 = "test-md5",
21
+ }: { complete?: boolean; id?: string; md5?: string; fixture: Fixture }) =>
22
+ http.get(`http://localhost:3000/api/v1/image_files/md5/${md5}`, async () => {
23
+ return HttpResponse.json({
24
+ id: "123",
25
+ complete: true,
26
+ });
27
+ });
28
+
29
+ export const mockLookupImageFileByMd5NotFound = ({
30
+ md5 = "test-md5",
31
+ }: { md5?: string }) =>
32
+ http.get(`http://localhost:3000/api/v1/image_files/md5/${md5}`, async () => {
33
+ return HttpResponse.json({}, { status: 404 });
34
+ });
35
+
37
36
  export const mockGetUploadImageFile = ({
38
37
  complete = true,
39
38
  id = "123",
40
39
  filename = "test.png",
41
- fixture,
42
40
  }: { complete?: boolean; id?: string; filename?: string; fixture: Fixture }) =>
43
41
  http.get(
44
42
  `http://localhost:3000/api/v1/image_files/${id}/upload`,
@@ -47,7 +45,6 @@ export const mockGetUploadImageFile = ({
47
45
  id,
48
46
  complete,
49
47
  filename,
50
- asset_id: `${fixture.md5}:${filename}`,
51
48
  });
52
49
  },
53
50
  );
@@ -55,8 +52,6 @@ export const mockGetUploadImageFile = ({
55
52
  export const mockCreateIsobmffFile = ({
56
53
  complete = true,
57
54
  id = "123",
58
- filename = "test.mp4",
59
- fixture,
60
55
  }: {
61
56
  complete?: boolean;
62
57
  id?: string;
@@ -68,19 +63,46 @@ export const mockCreateIsobmffFile = ({
68
63
  async () => {
69
64
  return HttpResponse.json({
70
65
  id,
71
- asset_id: `${fixture.md5}:${filename}`,
72
66
  fragment_index_complete: complete,
73
67
  });
74
68
  },
75
69
  { once: true },
76
70
  );
77
71
 
72
+ export const mockLookupISOBMFFFileByMd5 = ({
73
+ complete = true,
74
+ id = "123",
75
+ md5 = "test-md5",
76
+ }: {
77
+ complete?: boolean;
78
+ id?: string;
79
+ md5?: string;
80
+ fixture: Fixture;
81
+ }) =>
82
+ http.get(
83
+ `http://localhost:3000/api/v1/isobmff_files/md5/${md5}`,
84
+ async () => {
85
+ return HttpResponse.json({
86
+ id,
87
+ complete,
88
+ });
89
+ },
90
+ );
91
+
92
+ export const mockLookupISOBMFFFileByMd5NotFound = ({
93
+ md5 = "test-md5",
94
+ }: { md5?: string }) =>
95
+ http.get(
96
+ `http://localhost:3000/api/v1/isobmff_files/md5/${md5}`,
97
+ async () => {
98
+ return HttpResponse.json({}, { status: 404 });
99
+ },
100
+ );
101
+
78
102
  export const mockCreateIsobmffTrack = ({
79
103
  complete = true,
80
104
  id = "123",
81
105
  fileId = "123",
82
- filename = "test.mp4",
83
- fixture,
84
106
  }: {
85
107
  complete?: boolean;
86
108
  id?: string;
@@ -93,7 +115,6 @@ export const mockCreateIsobmffTrack = ({
93
115
  async () => {
94
116
  return HttpResponse.json({
95
117
  id,
96
- asset_id: `${fixture.md5}:${filename}`,
97
118
  complete,
98
119
  file_id: fileId,
99
120
  track_id: id,
@@ -137,11 +158,34 @@ export const mockUploadIsobmffFileIndex = ({
137
158
  { once: true },
138
159
  );
139
160
 
161
+ export const mockLookupCaptionFileByMd5 = ({
162
+ complete = true,
163
+ id = "123",
164
+ md5 = "test-md5",
165
+ }: { complete?: boolean; id?: string; md5?: string; fixture: Fixture }) =>
166
+ http.get(
167
+ `http://localhost:3000/api/v1/caption_files/md5/${md5}`,
168
+ async () => {
169
+ return HttpResponse.json({
170
+ id,
171
+ complete,
172
+ });
173
+ },
174
+ );
175
+
176
+ export const mockLookupCaptionFileByMd5NotFound = ({
177
+ md5 = "test-md5",
178
+ }: { md5?: string }) =>
179
+ http.get(
180
+ `http://localhost:3000/api/v1/caption_files/md5/${md5}`,
181
+ async () => {
182
+ return HttpResponse.json({}, { status: 404 });
183
+ },
184
+ );
185
+
140
186
  export const mockCreateCaptionFile = ({
141
187
  complete = true,
142
188
  id = "123",
143
- filename = "test.captions.json",
144
- fixture,
145
189
  }: {
146
190
  complete?: boolean;
147
191
  id?: string;
@@ -154,7 +198,6 @@ export const mockCreateCaptionFile = ({
154
198
  return HttpResponse.json({
155
199
  id,
156
200
  complete,
157
- asset_id: `${fixture.md5}:${filename}`,
158
201
  });
159
202
  },
160
203
  { once: true },