@editframe/cli 0.7.0-beta.1 → 0.7.0-beta.11
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/VERSION.cjs +1 -1
- package/dist/VERSION.js +1 -1
- package/dist/commands/auth.cjs +14 -11
- package/dist/commands/auth.js +15 -12
- package/dist/commands/check.cjs +2 -2
- package/dist/commands/check.js +2 -2
- package/dist/commands/process.cjs +36 -0
- package/dist/commands/process.js +35 -0
- package/dist/commands/render.cjs +34 -25
- package/dist/commands/render.js +34 -25
- package/dist/index.cjs +1 -11
- package/dist/index.js +1 -12
- package/dist/operations/getRenderInfo.cjs +59 -0
- package/dist/operations/getRenderInfo.js +59 -0
- package/dist/operations/processRenderInfo.cjs +30 -0
- package/dist/operations/processRenderInfo.js +30 -0
- package/dist/operations/syncAssetsDirectory.cjs +83 -40
- package/dist/operations/syncAssetsDirectory.js +82 -39
- package/dist/utils/index.cjs +8 -15
- package/dist/utils/index.js +8 -15
- package/dist/utils/launchBrowserAndWaitForSDK.cjs +7 -3
- package/dist/utils/launchBrowserAndWaitForSDK.js +7 -3
- package/dist/utils/validateVideoResolution.cjs +27 -0
- package/dist/utils/validateVideoResolution.js +27 -0
- package/package.json +6 -12
- package/src/commands/auth.ts +14 -12
- package/src/commands/check.ts +2 -2
- package/src/commands/process.ts +43 -37
- package/src/commands/render.ts +32 -30
- package/src/operations/getRenderInfo.ts +80 -0
- package/src/operations/processRenderInfo.ts +37 -0
- package/src/operations/syncAssetsDirectory.ts +77 -40
- package/src/utils/index.ts +7 -16
- package/src/utils/launchBrowserAndWaitForSDK.ts +9 -3
- package/src/utils/validateVideoResolution.ts +33 -0
- package/dist/api/caption-file.cjs +0 -48
- package/dist/api/caption-file.js +0 -48
- package/dist/api/image-file.cjs +0 -49
- package/dist/api/image-file.js +0 -49
- package/dist/api/index.cjs +0 -12
- package/dist/api/index.js +0 -12
- package/dist/api/isobmff-file.cjs +0 -48
- package/dist/api/isobmff-file.js +0 -48
- package/dist/api/isobmff-track.cjs +0 -63
- package/dist/api/isobmff-track.js +0 -63
- package/dist/api/renders.cjs +0 -51
- package/dist/api/renders.js +0 -51
- package/src/api/caption-file.ts +0 -60
- package/src/api/image-file.ts +0 -58
- package/src/api/index.ts +0 -17
- package/src/api/isobmff-file.ts +0 -59
- package/src/api/isobmff-track.ts +0 -77
- package/src/api/renders.ts +0 -59
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { Probe } from "@editframe/assets";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import {
|
|
5
|
+
createCaptionFile,
|
|
6
|
+
createImageFile,
|
|
7
|
+
createISOBMFFFile,
|
|
8
|
+
createISOBMFFTrack,
|
|
9
|
+
uploadCaptionFile,
|
|
10
|
+
uploadFragmentIndex,
|
|
11
|
+
uploadImageFile,
|
|
12
|
+
uploadISOBMFFTrack,
|
|
13
|
+
type CreateISOBMFFTrackPayload,
|
|
14
|
+
} from "@editframe/api";
|
|
15
|
+
|
|
9
16
|
import { createReadStream } from "node:fs";
|
|
10
17
|
import type { z } from "zod";
|
|
18
|
+
import { getClient } from "../utils";
|
|
11
19
|
|
|
12
20
|
const imageMatch = /\.(png|jpe?g|gif|webp)$/i;
|
|
13
21
|
const trackMatch = /\.track-[\d]+.mp4$/i;
|
|
@@ -30,7 +38,7 @@ class SyncStatus {
|
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
async markSynced() {
|
|
33
|
-
|
|
41
|
+
process.stderr.write(`✏️ Marking asset as synced: ${this.assetPath}\n`);
|
|
34
42
|
await fs.writeFile(this.infoPath, "{}", "utf-8");
|
|
35
43
|
}
|
|
36
44
|
}
|
|
@@ -48,21 +56,26 @@ export const syncAssetDirectory = async (
|
|
|
48
56
|
"assets",
|
|
49
57
|
".cache",
|
|
50
58
|
);
|
|
51
|
-
const stat = await fs.stat(fullPath)
|
|
52
|
-
|
|
59
|
+
const stat = await fs.stat(fullPath).catch((error) => {
|
|
60
|
+
if (error.code === "ENOENT") {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
64
|
+
});
|
|
65
|
+
if (!stat?.isDirectory()) {
|
|
53
66
|
console.error(`No assets cache directory found at ${fullPath}`);
|
|
54
67
|
return;
|
|
55
68
|
}
|
|
56
69
|
const assets = await fs.readdir(fullPath);
|
|
57
70
|
|
|
58
|
-
|
|
71
|
+
process.stderr.write(`Syncing asset dir: ${fullPath}\n`);
|
|
59
72
|
|
|
60
73
|
for (const asset of assets) {
|
|
61
|
-
|
|
74
|
+
process.stderr.write(`Syncing asset: ${asset}\n`);
|
|
62
75
|
const assetDir = path.join(fullPath, asset);
|
|
63
76
|
const stat = await fs.stat(assetDir);
|
|
64
77
|
if (!stat.isDirectory()) {
|
|
65
|
-
|
|
78
|
+
process.stderr.write("Invalid asset. Did not find asset directory.\n");
|
|
66
79
|
return;
|
|
67
80
|
}
|
|
68
81
|
const subAssets = await fs.readdir(assetDir);
|
|
@@ -75,7 +88,9 @@ export const syncAssetDirectory = async (
|
|
|
75
88
|
const subAssetPath = path.join(assetDir, subAsset);
|
|
76
89
|
const syncStatus = new SyncStatus(subAssetPath);
|
|
77
90
|
if (await syncStatus.isSynced()) {
|
|
78
|
-
|
|
91
|
+
process.stderr.write(
|
|
92
|
+
` ✔ Sub-asset has already been synced: ${subAsset}\n`,
|
|
93
|
+
);
|
|
79
94
|
continue;
|
|
80
95
|
}
|
|
81
96
|
switch (true) {
|
|
@@ -83,7 +98,9 @@ export const syncAssetDirectory = async (
|
|
|
83
98
|
const probeResult = await Probe.probePath(subAssetPath);
|
|
84
99
|
const [videoProbe] = probeResult.videoStreams;
|
|
85
100
|
if (!videoProbe) {
|
|
86
|
-
|
|
101
|
+
process.stderr.write(
|
|
102
|
+
`🚫 No video stream found in image: ${subAsset}\n`,
|
|
103
|
+
);
|
|
87
104
|
break;
|
|
88
105
|
}
|
|
89
106
|
const ext = path.extname(subAsset).slice(1);
|
|
@@ -95,11 +112,11 @@ export const syncAssetDirectory = async (
|
|
|
95
112
|
ext === "webp"
|
|
96
113
|
)
|
|
97
114
|
) {
|
|
98
|
-
|
|
115
|
+
process.stderr.write(`🚫 Invalid image format: ${subAsset}\n`);
|
|
99
116
|
break;
|
|
100
117
|
}
|
|
101
|
-
|
|
102
|
-
const created = await createImageFile({
|
|
118
|
+
process.stderr.write(`🖼️ Syncing image: ${subAsset}\n`);
|
|
119
|
+
const created = await createImageFile(getClient(), {
|
|
103
120
|
id: asset,
|
|
104
121
|
filename: subAsset,
|
|
105
122
|
width: videoProbe.width,
|
|
@@ -108,18 +125,22 @@ export const syncAssetDirectory = async (
|
|
|
108
125
|
});
|
|
109
126
|
if (created) {
|
|
110
127
|
if (created.complete) {
|
|
111
|
-
|
|
128
|
+
process.stderr.write(" ✔ Image has already been synced.\n");
|
|
112
129
|
} else {
|
|
113
|
-
await uploadImageFile(
|
|
114
|
-
|
|
130
|
+
await uploadImageFile(
|
|
131
|
+
getClient(),
|
|
132
|
+
created.id,
|
|
133
|
+
createReadStream(subAssetPath),
|
|
134
|
+
);
|
|
135
|
+
process.stderr.write(" ✅ Image has been synced.\n");
|
|
115
136
|
}
|
|
116
137
|
await syncStatus.markSynced();
|
|
117
138
|
}
|
|
118
139
|
break;
|
|
119
140
|
}
|
|
120
141
|
case trackMatch.test(subAsset): {
|
|
121
|
-
|
|
122
|
-
const createdFile = await createISOBMFFFile({
|
|
142
|
+
process.stderr.write(`📼 Syncing a/v track: ${subAsset}\n`);
|
|
143
|
+
const createdFile = await createISOBMFFFile(getClient(), {
|
|
123
144
|
id: asset,
|
|
124
145
|
filename: subAsset.replace(/\.track-[\d]+.mp4$/, ""),
|
|
125
146
|
});
|
|
@@ -127,16 +148,22 @@ export const syncAssetDirectory = async (
|
|
|
127
148
|
const probe = await Probe.probePath(subAssetPath);
|
|
128
149
|
const trackId = subAsset.match(/track-([\d]+).mp4/)?.[1];
|
|
129
150
|
if (!trackId) {
|
|
130
|
-
|
|
151
|
+
process.stderr.write(
|
|
152
|
+
`🚫 No track ID found for track: ${subAsset}\n`,
|
|
153
|
+
);
|
|
131
154
|
break;
|
|
132
155
|
}
|
|
133
156
|
const [track] = probe.streams;
|
|
134
157
|
if (!track) {
|
|
135
|
-
|
|
158
|
+
process.stderr.write(
|
|
159
|
+
`🚫 No track stream found in track: ${subAsset}\n`,
|
|
160
|
+
);
|
|
136
161
|
break;
|
|
137
162
|
}
|
|
138
163
|
if (track.duration === undefined) {
|
|
139
|
-
|
|
164
|
+
process.stderr.write(
|
|
165
|
+
`🚫 No duration found in track: ${subAsset}\n`,
|
|
166
|
+
);
|
|
140
167
|
break;
|
|
141
168
|
}
|
|
142
169
|
|
|
@@ -168,21 +195,25 @@ export const syncAssetDirectory = async (
|
|
|
168
195
|
codec_name: track.codec_name,
|
|
169
196
|
byte_size: stat.size,
|
|
170
197
|
};
|
|
171
|
-
const createdTrack = await createISOBMFFTrack(
|
|
198
|
+
const createdTrack = await createISOBMFFTrack(
|
|
199
|
+
getClient(),
|
|
200
|
+
createPayload,
|
|
201
|
+
);
|
|
172
202
|
|
|
173
203
|
if (createdTrack) {
|
|
174
204
|
if (
|
|
175
205
|
createdTrack.last_received_byte ===
|
|
176
206
|
createdTrack.byte_size - 1
|
|
177
207
|
) {
|
|
178
|
-
|
|
208
|
+
process.stderr.write(" ✔ Track has already been synced.\n");
|
|
179
209
|
} else {
|
|
180
210
|
await uploadISOBMFFTrack(
|
|
211
|
+
getClient(),
|
|
181
212
|
createdFile.id,
|
|
182
213
|
Number(trackId),
|
|
183
214
|
createReadStream(subAssetPath),
|
|
184
215
|
);
|
|
185
|
-
|
|
216
|
+
process.stderr.write(" ✅ Track has been synced.\n");
|
|
186
217
|
}
|
|
187
218
|
await syncStatus.markSynced();
|
|
188
219
|
}
|
|
@@ -191,49 +222,55 @@ export const syncAssetDirectory = async (
|
|
|
191
222
|
break;
|
|
192
223
|
}
|
|
193
224
|
case fragmentIndexMatch.test(subAsset): {
|
|
194
|
-
|
|
195
|
-
const createdFile = await createISOBMFFFile({
|
|
225
|
+
process.stderr.write(`📋 Syncing fragment index: ${subAsset}\n`);
|
|
226
|
+
const createdFile = await createISOBMFFFile(getClient(), {
|
|
196
227
|
id: asset,
|
|
197
228
|
filename: subAsset.replace(/\.tracks.json$/, ""),
|
|
198
229
|
});
|
|
199
230
|
if (createdFile) {
|
|
200
231
|
if (createdFile.fragment_index_complete) {
|
|
201
|
-
|
|
232
|
+
process.stderr.write(
|
|
233
|
+
" ✔ Fragment index has already been synced.\n",
|
|
234
|
+
);
|
|
202
235
|
} else {
|
|
203
236
|
const readStream = createReadStream(subAssetPath);
|
|
204
|
-
await uploadFragmentIndex(asset, readStream);
|
|
205
|
-
|
|
237
|
+
await uploadFragmentIndex(getClient(), asset, readStream);
|
|
238
|
+
process.stderr.write(" ✅ Fragment index has been synced.\n");
|
|
206
239
|
}
|
|
207
240
|
await syncStatus.markSynced();
|
|
208
241
|
} else {
|
|
209
|
-
|
|
242
|
+
process.stderr.write(
|
|
243
|
+
`🚫 No file found for fragment index: ${subAsset}\n`,
|
|
244
|
+
);
|
|
210
245
|
break;
|
|
211
246
|
}
|
|
212
247
|
break;
|
|
213
248
|
}
|
|
214
249
|
case captionsMatch.test(subAsset): {
|
|
215
|
-
|
|
216
|
-
const createdFile = await createCaptionFile({
|
|
250
|
+
process.stderr.write(`📝 Syncing captions: ${subAsset}\n`);
|
|
251
|
+
const createdFile = await createCaptionFile(getClient(), {
|
|
217
252
|
id: asset,
|
|
218
253
|
filename: subAsset.replace(/\.captions.json$/, ""),
|
|
219
254
|
});
|
|
220
255
|
if (createdFile) {
|
|
221
256
|
if (createdFile.complete) {
|
|
222
|
-
|
|
257
|
+
process.stderr.write(" ✔ Captions have already been synced.\n");
|
|
223
258
|
} else {
|
|
224
259
|
const readStream = createReadStream(subAssetPath);
|
|
225
|
-
await uploadCaptionFile(asset, readStream);
|
|
226
|
-
|
|
260
|
+
await uploadCaptionFile(getClient(), asset, readStream);
|
|
261
|
+
process.stderr.write(" ✅ Captions have been synced.\n");
|
|
227
262
|
}
|
|
228
263
|
await syncStatus.markSynced();
|
|
229
264
|
} else {
|
|
230
|
-
|
|
265
|
+
process.stderr.write(
|
|
266
|
+
`🚫 No file found for captions: ${subAsset}\n`,
|
|
267
|
+
);
|
|
231
268
|
break;
|
|
232
269
|
}
|
|
233
270
|
break;
|
|
234
271
|
}
|
|
235
272
|
default: {
|
|
236
|
-
|
|
273
|
+
process.stderr.write(`🚫 Unknown sub-asset: ${subAsset}\n`);
|
|
237
274
|
break;
|
|
238
275
|
}
|
|
239
276
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { program } from "commander";
|
|
2
2
|
import "dotenv/config";
|
|
3
|
-
import
|
|
3
|
+
import { Client } from "@editframe/api";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
const programOpts = program.opts();
|
|
5
|
+
let client: Client;
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
);
|
|
7
|
+
export const getClient = () => {
|
|
8
|
+
if (!client) {
|
|
9
|
+
const programOpts = program.opts();
|
|
10
|
+
client = new Client(programOpts.token, programOpts.efHost);
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
Object.assign(init.headers, {
|
|
15
|
-
Authorization: `Bearer ${programOpts.token}`,
|
|
16
|
-
"Content-Type": "application/json",
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const url = new URL(path, programOpts.efHost);
|
|
20
|
-
// console.log("Fetching", url.toString());
|
|
21
|
-
return fetch(url, init);
|
|
12
|
+
return client;
|
|
22
13
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { type Browser, type Page, chromium } from "playwright";
|
|
3
|
+
import debug from "debug";
|
|
4
|
+
|
|
3
5
|
import { withSpinner } from "./withSpinner";
|
|
4
6
|
|
|
7
|
+
const browserLog = debug("ef:cli::browser");
|
|
8
|
+
|
|
5
9
|
interface LaunchOptions {
|
|
6
10
|
url: string;
|
|
7
11
|
headless?: boolean;
|
|
@@ -32,11 +36,13 @@ export async function launchBrowserAndWaitForSDK(
|
|
|
32
36
|
}
|
|
33
37
|
const page = await browser.newPage(pageOptions);
|
|
34
38
|
page.on("console", (msg) => {
|
|
35
|
-
|
|
39
|
+
browserLog(chalk.blue(`browser (${msg.type()}) |`), msg.text());
|
|
36
40
|
});
|
|
37
41
|
const url =
|
|
38
42
|
options.url + (options.efInteractive ? "" : "?EF_NONINTERACTIVE=1");
|
|
39
|
-
|
|
43
|
+
process.stderr.write("\nLoading url: ");
|
|
44
|
+
process.stderr.write(url);
|
|
45
|
+
process.stderr.write("\n");
|
|
40
46
|
await page.goto(url);
|
|
41
47
|
await page.waitForFunction(
|
|
42
48
|
() => {
|
|
@@ -46,7 +52,7 @@ export async function launchBrowserAndWaitForSDK(
|
|
|
46
52
|
);
|
|
47
53
|
},
|
|
48
54
|
[],
|
|
49
|
-
{ timeout:
|
|
55
|
+
{ timeout: 10_000 },
|
|
50
56
|
);
|
|
51
57
|
return page;
|
|
52
58
|
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import ora from "ora";
|
|
3
|
+
import debug from "debug";
|
|
4
|
+
|
|
5
|
+
const log = debug("ef:cli:auth");
|
|
6
|
+
|
|
7
|
+
type VideoPayload = {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const schema = z
|
|
13
|
+
.object({
|
|
14
|
+
width: z.number().int(),
|
|
15
|
+
height: z.number().int(),
|
|
16
|
+
})
|
|
17
|
+
.refine((data) => data.width % 2 === 0 && data.height % 2 === 0, {
|
|
18
|
+
message: "Both width and height must be divisible by 2.",
|
|
19
|
+
path: ["width", "height"],
|
|
20
|
+
});
|
|
21
|
+
export const validateVideoResolution = async (rawPayload: VideoPayload) => {
|
|
22
|
+
const spinner = ora("Validating video resolution").start();
|
|
23
|
+
const result = schema.safeParse(rawPayload);
|
|
24
|
+
if (result.success) {
|
|
25
|
+
spinner.succeed("Video resolution is valid");
|
|
26
|
+
return result.data;
|
|
27
|
+
}
|
|
28
|
+
spinner.fail("Invalid video resolution");
|
|
29
|
+
process.stderr.write(result.error?.errors.map((e) => e.message).join("\n"));
|
|
30
|
+
process.stderr.write("\n");
|
|
31
|
+
log("Error:", result.error?.errors.map((e) => e.message).join("\n"));
|
|
32
|
+
process.exit(1);
|
|
33
|
+
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const zod = require("zod");
|
|
4
|
-
const index = require("../utils/index.cjs");
|
|
5
|
-
const CreateCaptionFilePayload = zod.z.object({
|
|
6
|
-
id: zod.z.string(),
|
|
7
|
-
filename: zod.z.string()
|
|
8
|
-
});
|
|
9
|
-
const createCaptionFile = async (payload) => {
|
|
10
|
-
const fileCreation = await index.authenticatedFetch("/api/video2/caption_files", {
|
|
11
|
-
method: "POST",
|
|
12
|
-
body: JSON.stringify(payload)
|
|
13
|
-
});
|
|
14
|
-
switch (fileCreation.status) {
|
|
15
|
-
case 200: {
|
|
16
|
-
return await fileCreation.json();
|
|
17
|
-
}
|
|
18
|
-
default: {
|
|
19
|
-
console.log(
|
|
20
|
-
`Failed to create file ${fileCreation.status} ${fileCreation.statusText}`
|
|
21
|
-
);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const uploadCaptionFile = async (fileId, fileStream) => {
|
|
27
|
-
const fileIndex = await index.authenticatedFetch(
|
|
28
|
-
`/api/video2/caption_files/${fileId}/upload`,
|
|
29
|
-
{
|
|
30
|
-
method: "POST",
|
|
31
|
-
body: fileStream
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
switch (fileIndex.status) {
|
|
35
|
-
case 200: {
|
|
36
|
-
return fileIndex.json();
|
|
37
|
-
}
|
|
38
|
-
default: {
|
|
39
|
-
console.log(
|
|
40
|
-
`Failed to upload caption ${fileIndex.status} ${fileIndex.statusText}`
|
|
41
|
-
);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
exports.CreateCaptionFilePayload = CreateCaptionFilePayload;
|
|
47
|
-
exports.createCaptionFile = createCaptionFile;
|
|
48
|
-
exports.uploadCaptionFile = uploadCaptionFile;
|
package/dist/api/caption-file.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { authenticatedFetch } from "../utils/index.js";
|
|
3
|
-
const CreateCaptionFilePayload = z.object({
|
|
4
|
-
id: z.string(),
|
|
5
|
-
filename: z.string()
|
|
6
|
-
});
|
|
7
|
-
const createCaptionFile = async (payload) => {
|
|
8
|
-
const fileCreation = await authenticatedFetch("/api/video2/caption_files", {
|
|
9
|
-
method: "POST",
|
|
10
|
-
body: JSON.stringify(payload)
|
|
11
|
-
});
|
|
12
|
-
switch (fileCreation.status) {
|
|
13
|
-
case 200: {
|
|
14
|
-
return await fileCreation.json();
|
|
15
|
-
}
|
|
16
|
-
default: {
|
|
17
|
-
console.log(
|
|
18
|
-
`Failed to create file ${fileCreation.status} ${fileCreation.statusText}`
|
|
19
|
-
);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const uploadCaptionFile = async (fileId, fileStream) => {
|
|
25
|
-
const fileIndex = await authenticatedFetch(
|
|
26
|
-
`/api/video2/caption_files/${fileId}/upload`,
|
|
27
|
-
{
|
|
28
|
-
method: "POST",
|
|
29
|
-
body: fileStream
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
switch (fileIndex.status) {
|
|
33
|
-
case 200: {
|
|
34
|
-
return fileIndex.json();
|
|
35
|
-
}
|
|
36
|
-
default: {
|
|
37
|
-
console.log(
|
|
38
|
-
`Failed to upload caption ${fileIndex.status} ${fileIndex.statusText}`
|
|
39
|
-
);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
export {
|
|
45
|
-
CreateCaptionFilePayload,
|
|
46
|
-
createCaptionFile,
|
|
47
|
-
uploadCaptionFile
|
|
48
|
-
};
|
package/dist/api/image-file.cjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const zod = require("zod");
|
|
4
|
-
const index = require("../utils/index.cjs");
|
|
5
|
-
const CreateImageFilePayload = zod.z.object({
|
|
6
|
-
id: zod.z.string(),
|
|
7
|
-
height: zod.z.number().int(),
|
|
8
|
-
width: zod.z.number().int(),
|
|
9
|
-
mime_type: zod.z.enum(["image/jpeg", "image/png", "image/jpg", "image/webp"]),
|
|
10
|
-
filename: zod.z.string()
|
|
11
|
-
});
|
|
12
|
-
const createImageFile = async (payload) => {
|
|
13
|
-
const response = await index.authenticatedFetch("/api/video2/image_files", {
|
|
14
|
-
method: "POST",
|
|
15
|
-
body: JSON.stringify(payload)
|
|
16
|
-
});
|
|
17
|
-
switch (response.status) {
|
|
18
|
-
case 200: {
|
|
19
|
-
return await response.json();
|
|
20
|
-
}
|
|
21
|
-
default: {
|
|
22
|
-
console.error(
|
|
23
|
-
`Failed to create file ${response.status} ${response.statusText}`
|
|
24
|
-
);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const uploadImageFile = async (fileId, fileStream) => {
|
|
30
|
-
const fileIndex = await index.authenticatedFetch(
|
|
31
|
-
`/api/video2/image_files/${fileId}/upload`,
|
|
32
|
-
{
|
|
33
|
-
method: "POST",
|
|
34
|
-
body: fileStream
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
switch (fileIndex.status) {
|
|
38
|
-
case 200: {
|
|
39
|
-
return fileIndex.json();
|
|
40
|
-
}
|
|
41
|
-
default: {
|
|
42
|
-
console.log("Failed to upload image");
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
exports.CreateImageFilePayload = CreateImageFilePayload;
|
|
48
|
-
exports.createImageFile = createImageFile;
|
|
49
|
-
exports.uploadImageFile = uploadImageFile;
|
package/dist/api/image-file.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { authenticatedFetch } from "../utils/index.js";
|
|
3
|
-
const CreateImageFilePayload = z.object({
|
|
4
|
-
id: z.string(),
|
|
5
|
-
height: z.number().int(),
|
|
6
|
-
width: z.number().int(),
|
|
7
|
-
mime_type: z.enum(["image/jpeg", "image/png", "image/jpg", "image/webp"]),
|
|
8
|
-
filename: z.string()
|
|
9
|
-
});
|
|
10
|
-
const createImageFile = async (payload) => {
|
|
11
|
-
const response = await authenticatedFetch("/api/video2/image_files", {
|
|
12
|
-
method: "POST",
|
|
13
|
-
body: JSON.stringify(payload)
|
|
14
|
-
});
|
|
15
|
-
switch (response.status) {
|
|
16
|
-
case 200: {
|
|
17
|
-
return await response.json();
|
|
18
|
-
}
|
|
19
|
-
default: {
|
|
20
|
-
console.error(
|
|
21
|
-
`Failed to create file ${response.status} ${response.statusText}`
|
|
22
|
-
);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const uploadImageFile = async (fileId, fileStream) => {
|
|
28
|
-
const fileIndex = await authenticatedFetch(
|
|
29
|
-
`/api/video2/image_files/${fileId}/upload`,
|
|
30
|
-
{
|
|
31
|
-
method: "POST",
|
|
32
|
-
body: fileStream
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
switch (fileIndex.status) {
|
|
36
|
-
case 200: {
|
|
37
|
-
return fileIndex.json();
|
|
38
|
-
}
|
|
39
|
-
default: {
|
|
40
|
-
console.log("Failed to upload image");
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
export {
|
|
46
|
-
CreateImageFilePayload,
|
|
47
|
-
createImageFile,
|
|
48
|
-
uploadImageFile
|
|
49
|
-
};
|
package/dist/api/index.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const captionFile = require("./caption-file.cjs");
|
|
4
|
-
const imageFile = require("./image-file.cjs");
|
|
5
|
-
const isobmffFile = require("./isobmff-file.cjs");
|
|
6
|
-
const isobmffTrack = require("./isobmff-track.cjs");
|
|
7
|
-
const renders = require("./renders.cjs");
|
|
8
|
-
exports.CreateCaptionFilePayload = captionFile.CreateCaptionFilePayload;
|
|
9
|
-
exports.CreateImageFilePayload = imageFile.CreateImageFilePayload;
|
|
10
|
-
exports.CreateISOBMFFFilePayload = isobmffFile.CreateISOBMFFFilePayload;
|
|
11
|
-
exports.CreateISOBMFFTrackPayload = isobmffTrack.CreateISOBMFFTrackPayload;
|
|
12
|
-
exports.CreateRenderPayload = renders.CreateRenderPayload;
|
package/dist/api/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CreateCaptionFilePayload } from "./caption-file.js";
|
|
2
|
-
import { CreateImageFilePayload } from "./image-file.js";
|
|
3
|
-
import { CreateISOBMFFFilePayload } from "./isobmff-file.js";
|
|
4
|
-
import { CreateISOBMFFTrackPayload } from "./isobmff-track.js";
|
|
5
|
-
import { CreateRenderPayload } from "./renders.js";
|
|
6
|
-
export {
|
|
7
|
-
CreateCaptionFilePayload,
|
|
8
|
-
CreateISOBMFFFilePayload,
|
|
9
|
-
CreateISOBMFFTrackPayload,
|
|
10
|
-
CreateImageFilePayload,
|
|
11
|
-
CreateRenderPayload
|
|
12
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const zod = require("zod");
|
|
4
|
-
const index = require("../utils/index.cjs");
|
|
5
|
-
const CreateISOBMFFFilePayload = zod.z.object({
|
|
6
|
-
id: zod.z.string(),
|
|
7
|
-
filename: zod.z.string()
|
|
8
|
-
});
|
|
9
|
-
const createISOBMFFFile = async (payload) => {
|
|
10
|
-
const response = await index.authenticatedFetch("/api/video2/isobmff_files", {
|
|
11
|
-
method: "POST",
|
|
12
|
-
body: JSON.stringify(payload)
|
|
13
|
-
});
|
|
14
|
-
switch (response.status) {
|
|
15
|
-
case 200: {
|
|
16
|
-
return await response.json();
|
|
17
|
-
}
|
|
18
|
-
default: {
|
|
19
|
-
console.log(
|
|
20
|
-
`Failed to create file ${response.status} ${response.statusText}`
|
|
21
|
-
);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const uploadFragmentIndex = async (fileId, fileStream) => {
|
|
27
|
-
const fileIndex = await index.authenticatedFetch(
|
|
28
|
-
`/api/video2/isobmff_files/${fileId}/index/upload`,
|
|
29
|
-
{
|
|
30
|
-
method: "POST",
|
|
31
|
-
body: fileStream
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
switch (fileIndex.status) {
|
|
35
|
-
case 200: {
|
|
36
|
-
return fileIndex.json();
|
|
37
|
-
}
|
|
38
|
-
default: {
|
|
39
|
-
console.log(
|
|
40
|
-
`Failed to create fragment index ${fileIndex.status} ${fileIndex.statusText}`
|
|
41
|
-
);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
exports.CreateISOBMFFFilePayload = CreateISOBMFFFilePayload;
|
|
47
|
-
exports.createISOBMFFFile = createISOBMFFFile;
|
|
48
|
-
exports.uploadFragmentIndex = uploadFragmentIndex;
|
package/dist/api/isobmff-file.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { authenticatedFetch } from "../utils/index.js";
|
|
3
|
-
const CreateISOBMFFFilePayload = z.object({
|
|
4
|
-
id: z.string(),
|
|
5
|
-
filename: z.string()
|
|
6
|
-
});
|
|
7
|
-
const createISOBMFFFile = async (payload) => {
|
|
8
|
-
const response = await authenticatedFetch("/api/video2/isobmff_files", {
|
|
9
|
-
method: "POST",
|
|
10
|
-
body: JSON.stringify(payload)
|
|
11
|
-
});
|
|
12
|
-
switch (response.status) {
|
|
13
|
-
case 200: {
|
|
14
|
-
return await response.json();
|
|
15
|
-
}
|
|
16
|
-
default: {
|
|
17
|
-
console.log(
|
|
18
|
-
`Failed to create file ${response.status} ${response.statusText}`
|
|
19
|
-
);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const uploadFragmentIndex = async (fileId, fileStream) => {
|
|
25
|
-
const fileIndex = await authenticatedFetch(
|
|
26
|
-
`/api/video2/isobmff_files/${fileId}/index/upload`,
|
|
27
|
-
{
|
|
28
|
-
method: "POST",
|
|
29
|
-
body: fileStream
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
switch (fileIndex.status) {
|
|
33
|
-
case 200: {
|
|
34
|
-
return fileIndex.json();
|
|
35
|
-
}
|
|
36
|
-
default: {
|
|
37
|
-
console.log(
|
|
38
|
-
`Failed to create fragment index ${fileIndex.status} ${fileIndex.statusText}`
|
|
39
|
-
);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
export {
|
|
45
|
-
CreateISOBMFFFilePayload,
|
|
46
|
-
createISOBMFFFile,
|
|
47
|
-
uploadFragmentIndex
|
|
48
|
-
};
|