@editframe/api 0.7.0-beta.10 → 0.7.0-beta.12
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/client.d.ts +8 -0
- package/dist/client.js +3 -3
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -1
- package/dist/resources/caption-file.d.ts +20 -0
- package/dist/resources/image-file.d.ts +29 -0
- package/dist/resources/isobmff-file.d.ts +20 -0
- package/dist/resources/isobmff-track.d.ts +271 -0
- package/dist/resources/renders.d.ts +35 -0
- package/dist/resources/unprocessed-file.d.ts +41 -0
- package/dist/resources/unprocessed-file.js +97 -0
- package/package.json +6 -10
- package/src/resources/caption-file.ts +1 -1
- package/src/resources/image-file.ts +1 -1
- package/src/resources/isobmff-file.ts +1 -1
- package/src/resources/isobmff-track.ts +1 -1
- package/src/resources/renders.ts +1 -1
- package/src/resources/unprocessed-file.ts +133 -0
- package/dist/client.cjs +0 -29
- package/dist/index.cjs +0 -24
- package/dist/resources/caption-file.cjs +0 -56
- package/dist/resources/image-file.cjs +0 -52
- package/dist/resources/isobmff-file.cjs +0 -56
- package/dist/resources/isobmff-track.cjs +0 -71
- package/dist/resources/renders.cjs +0 -56
- package/src/util/nodeStreamToWebStream.ts +0 -20
package/dist/client.d.ts
ADDED
package/dist/client.js
CHANGED
|
@@ -7,21 +7,21 @@ class Client {
|
|
|
7
7
|
this.efHost = efHost;
|
|
8
8
|
this.authenticatedFetch = async (path, init = {}) => {
|
|
9
9
|
init.headers ||= {};
|
|
10
|
+
const url = new URL(path, this.efHost);
|
|
10
11
|
log(
|
|
11
12
|
"Authenticated fetch",
|
|
12
|
-
{
|
|
13
|
+
{ url, init },
|
|
13
14
|
"(Token will be added as Bearer token)"
|
|
14
15
|
);
|
|
15
16
|
Object.assign(init.headers, {
|
|
16
17
|
Authorization: `Bearer ${this.token}`,
|
|
17
18
|
"Content-Type": "application/json"
|
|
18
19
|
});
|
|
19
|
-
const url = new URL(path, this.efHost);
|
|
20
20
|
const response = await fetch(url, init);
|
|
21
21
|
log("Authenticated fetch response", response.status, response.statusText);
|
|
22
22
|
return response;
|
|
23
23
|
};
|
|
24
|
-
log("Creating client with efHost", efHost,
|
|
24
|
+
log("Creating client with efHost", { efHost, tokenIsSet: !!token });
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
export {
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createCaptionFile, CreateCaptionFilePayload, type CreateCaptionFileResult, uploadCaptionFile, } from './resources/caption-file.ts';
|
|
2
|
+
export { createImageFile, CreateImageFilePayload, type CreateImageFileResult, uploadImageFile, } from './resources/image-file.ts';
|
|
3
|
+
export { createISOBMFFFile, CreateISOBMFFFilePayload, type CreateISOBMFFFileResult, uploadFragmentIndex, } from './resources/isobmff-file.ts';
|
|
4
|
+
export { createISOBMFFTrack, CreateISOBMFFTrackPayload, type CreateISOBMFFTrackResult, uploadISOBMFFTrack, } from './resources/isobmff-track.ts';
|
|
5
|
+
export { createRender, CreateRenderPayload, type CreateRenderResult, uploadRender, } from './resources/renders.ts';
|
|
6
|
+
export { createUnprocessedFile, CreateUnprocessedFilePayload, type CreateUnprocessedFileResult, updateUnprocessedFile, UpdateUnprocessedFilePayload, type UpdateUnprocessedFileResult, uploadUnprocessedFile, } from './resources/unprocessed-file.ts';
|
|
7
|
+
export { Client } from './client.ts';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { CreateImageFilePayload, createImageFile, uploadImageFile } from "./reso
|
|
|
3
3
|
import { CreateISOBMFFFilePayload, createISOBMFFFile, uploadFragmentIndex } from "./resources/isobmff-file.js";
|
|
4
4
|
import { CreateISOBMFFTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
|
|
5
5
|
import { CreateRenderPayload, createRender, uploadRender } from "./resources/renders.js";
|
|
6
|
+
import { CreateUnprocessedFilePayload, UpdateUnprocessedFilePayload, createUnprocessedFile, updateUnprocessedFile, uploadUnprocessedFile } from "./resources/unprocessed-file.js";
|
|
6
7
|
import { Client } from "./client.js";
|
|
7
8
|
export {
|
|
8
9
|
Client,
|
|
@@ -11,14 +12,19 @@ export {
|
|
|
11
12
|
CreateISOBMFFTrackPayload,
|
|
12
13
|
CreateImageFilePayload,
|
|
13
14
|
CreateRenderPayload,
|
|
15
|
+
CreateUnprocessedFilePayload,
|
|
16
|
+
UpdateUnprocessedFilePayload,
|
|
14
17
|
createCaptionFile,
|
|
15
18
|
createISOBMFFFile,
|
|
16
19
|
createISOBMFFTrack,
|
|
17
20
|
createImageFile,
|
|
18
21
|
createRender,
|
|
22
|
+
createUnprocessedFile,
|
|
23
|
+
updateUnprocessedFile,
|
|
19
24
|
uploadCaptionFile,
|
|
20
25
|
uploadFragmentIndex,
|
|
21
26
|
uploadISOBMFFTrack,
|
|
22
27
|
uploadImageFile,
|
|
23
|
-
uploadRender
|
|
28
|
+
uploadRender,
|
|
29
|
+
uploadUnprocessedFile
|
|
24
30
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Client } from '../client.ts';
|
|
4
|
+
|
|
5
|
+
export declare const CreateCaptionFilePayload: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
filename: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
id: string;
|
|
10
|
+
filename: string;
|
|
11
|
+
}, {
|
|
12
|
+
id: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
}>;
|
|
15
|
+
export interface CreateCaptionFileResult {
|
|
16
|
+
complete: boolean | null;
|
|
17
|
+
id: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const createCaptionFile: (client: Client, payload: z.infer<typeof CreateCaptionFilePayload>) => Promise<CreateCaptionFileResult | undefined>;
|
|
20
|
+
export declare const uploadCaptionFile: (client: Client, fileId: string, fileStream: Readable) => Promise<unknown>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Client } from '../client.ts';
|
|
4
|
+
|
|
5
|
+
export declare const CreateImageFilePayload: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
height: z.ZodNumber;
|
|
8
|
+
width: z.ZodNumber;
|
|
9
|
+
mime_type: z.ZodEnum<["image/jpeg", "image/png", "image/jpg", "image/webp"]>;
|
|
10
|
+
filename: z.ZodString;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
id: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
height: number;
|
|
15
|
+
width: number;
|
|
16
|
+
mime_type: "image/jpeg" | "image/png" | "image/jpg" | "image/webp";
|
|
17
|
+
}, {
|
|
18
|
+
id: string;
|
|
19
|
+
filename: string;
|
|
20
|
+
height: number;
|
|
21
|
+
width: number;
|
|
22
|
+
mime_type: "image/jpeg" | "image/png" | "image/jpg" | "image/webp";
|
|
23
|
+
}>;
|
|
24
|
+
export interface CreateImageFileResult {
|
|
25
|
+
complete: boolean | null;
|
|
26
|
+
id: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const createImageFile: (client: Client, payload: z.infer<typeof CreateImageFilePayload>) => Promise<CreateImageFileResult | undefined>;
|
|
29
|
+
export declare const uploadImageFile: (client: Client, fileId: string, fileStream: Readable) => Promise<unknown>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Client } from '../client.ts';
|
|
4
|
+
|
|
5
|
+
export declare const CreateISOBMFFFilePayload: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
filename: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
id: string;
|
|
10
|
+
filename: string;
|
|
11
|
+
}, {
|
|
12
|
+
id: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
}>;
|
|
15
|
+
export interface CreateISOBMFFFileResult {
|
|
16
|
+
fragment_index_complete: boolean;
|
|
17
|
+
id: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const createISOBMFFFile: (client: Client, payload: z.infer<typeof CreateISOBMFFFilePayload>) => Promise<CreateISOBMFFFileResult | undefined>;
|
|
20
|
+
export declare const uploadFragmentIndex: (client: Client, fileId: string, fileStream: Readable) => Promise<unknown>;
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Client } from '../client.ts';
|
|
4
|
+
|
|
5
|
+
export declare const CreateISOBMFFTrackPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
6
|
+
file_id: z.ZodString;
|
|
7
|
+
track_id: z.ZodNumber;
|
|
8
|
+
type: z.ZodLiteral<"audio">;
|
|
9
|
+
probe_info: z.ZodObject<{
|
|
10
|
+
index: z.ZodNumber;
|
|
11
|
+
codec_name: z.ZodString;
|
|
12
|
+
codec_long_name: z.ZodString;
|
|
13
|
+
codec_type: z.ZodLiteral<"audio">;
|
|
14
|
+
codec_tag_string: z.ZodString;
|
|
15
|
+
codec_tag: z.ZodString;
|
|
16
|
+
sample_fmt: z.ZodString;
|
|
17
|
+
sample_rate: z.ZodString;
|
|
18
|
+
channels: z.ZodNumber;
|
|
19
|
+
channel_layout: z.ZodString;
|
|
20
|
+
bits_per_sample: z.ZodNumber;
|
|
21
|
+
initial_padding: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
r_frame_rate: z.ZodString;
|
|
23
|
+
avg_frame_rate: z.ZodString;
|
|
24
|
+
time_base: z.ZodString;
|
|
25
|
+
start_pts: z.ZodNumber;
|
|
26
|
+
start_time: z.ZodNumber;
|
|
27
|
+
duration_ts: z.ZodNumber;
|
|
28
|
+
duration: z.ZodNumber;
|
|
29
|
+
bit_rate: z.ZodString;
|
|
30
|
+
disposition: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
duration: number;
|
|
33
|
+
index: number;
|
|
34
|
+
codec_name: string;
|
|
35
|
+
codec_long_name: string;
|
|
36
|
+
codec_type: "audio";
|
|
37
|
+
codec_tag_string: string;
|
|
38
|
+
codec_tag: string;
|
|
39
|
+
sample_fmt: string;
|
|
40
|
+
sample_rate: string;
|
|
41
|
+
channels: number;
|
|
42
|
+
channel_layout: string;
|
|
43
|
+
bits_per_sample: number;
|
|
44
|
+
r_frame_rate: string;
|
|
45
|
+
avg_frame_rate: string;
|
|
46
|
+
time_base: string;
|
|
47
|
+
start_pts: number;
|
|
48
|
+
start_time: number;
|
|
49
|
+
duration_ts: number;
|
|
50
|
+
bit_rate: string;
|
|
51
|
+
disposition: Record<string, unknown>;
|
|
52
|
+
initial_padding?: number | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
duration: number;
|
|
55
|
+
index: number;
|
|
56
|
+
codec_name: string;
|
|
57
|
+
codec_long_name: string;
|
|
58
|
+
codec_type: "audio";
|
|
59
|
+
codec_tag_string: string;
|
|
60
|
+
codec_tag: string;
|
|
61
|
+
sample_fmt: string;
|
|
62
|
+
sample_rate: string;
|
|
63
|
+
channels: number;
|
|
64
|
+
channel_layout: string;
|
|
65
|
+
bits_per_sample: number;
|
|
66
|
+
r_frame_rate: string;
|
|
67
|
+
avg_frame_rate: string;
|
|
68
|
+
time_base: string;
|
|
69
|
+
start_pts: number;
|
|
70
|
+
start_time: number;
|
|
71
|
+
duration_ts: number;
|
|
72
|
+
bit_rate: string;
|
|
73
|
+
disposition: Record<string, unknown>;
|
|
74
|
+
initial_padding?: number | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
duration_ms: z.ZodNumber;
|
|
77
|
+
codec_name: z.ZodString;
|
|
78
|
+
byte_size: z.ZodNumber;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
type: "audio";
|
|
81
|
+
file_id: string;
|
|
82
|
+
track_id: number;
|
|
83
|
+
probe_info: {
|
|
84
|
+
duration: number;
|
|
85
|
+
index: number;
|
|
86
|
+
codec_name: string;
|
|
87
|
+
codec_long_name: string;
|
|
88
|
+
codec_type: "audio";
|
|
89
|
+
codec_tag_string: string;
|
|
90
|
+
codec_tag: string;
|
|
91
|
+
sample_fmt: string;
|
|
92
|
+
sample_rate: string;
|
|
93
|
+
channels: number;
|
|
94
|
+
channel_layout: string;
|
|
95
|
+
bits_per_sample: number;
|
|
96
|
+
r_frame_rate: string;
|
|
97
|
+
avg_frame_rate: string;
|
|
98
|
+
time_base: string;
|
|
99
|
+
start_pts: number;
|
|
100
|
+
start_time: number;
|
|
101
|
+
duration_ts: number;
|
|
102
|
+
bit_rate: string;
|
|
103
|
+
disposition: Record<string, unknown>;
|
|
104
|
+
initial_padding?: number | undefined;
|
|
105
|
+
};
|
|
106
|
+
duration_ms: number;
|
|
107
|
+
codec_name: string;
|
|
108
|
+
byte_size: number;
|
|
109
|
+
}, {
|
|
110
|
+
type: "audio";
|
|
111
|
+
file_id: string;
|
|
112
|
+
track_id: number;
|
|
113
|
+
probe_info: {
|
|
114
|
+
duration: number;
|
|
115
|
+
index: number;
|
|
116
|
+
codec_name: string;
|
|
117
|
+
codec_long_name: string;
|
|
118
|
+
codec_type: "audio";
|
|
119
|
+
codec_tag_string: string;
|
|
120
|
+
codec_tag: string;
|
|
121
|
+
sample_fmt: string;
|
|
122
|
+
sample_rate: string;
|
|
123
|
+
channels: number;
|
|
124
|
+
channel_layout: string;
|
|
125
|
+
bits_per_sample: number;
|
|
126
|
+
r_frame_rate: string;
|
|
127
|
+
avg_frame_rate: string;
|
|
128
|
+
time_base: string;
|
|
129
|
+
start_pts: number;
|
|
130
|
+
start_time: number;
|
|
131
|
+
duration_ts: number;
|
|
132
|
+
bit_rate: string;
|
|
133
|
+
disposition: Record<string, unknown>;
|
|
134
|
+
initial_padding?: number | undefined;
|
|
135
|
+
};
|
|
136
|
+
duration_ms: number;
|
|
137
|
+
codec_name: string;
|
|
138
|
+
byte_size: number;
|
|
139
|
+
}>, z.ZodObject<{
|
|
140
|
+
file_id: z.ZodString;
|
|
141
|
+
track_id: z.ZodNumber;
|
|
142
|
+
type: z.ZodLiteral<"video">;
|
|
143
|
+
probe_info: z.ZodObject<{
|
|
144
|
+
index: z.ZodNumber;
|
|
145
|
+
codec_name: z.ZodString;
|
|
146
|
+
codec_long_name: z.ZodString;
|
|
147
|
+
codec_type: z.ZodLiteral<"video">;
|
|
148
|
+
codec_tag_string: z.ZodString;
|
|
149
|
+
codec_tag: z.ZodString;
|
|
150
|
+
width: z.ZodNumber;
|
|
151
|
+
height: z.ZodNumber;
|
|
152
|
+
coded_width: z.ZodNumber;
|
|
153
|
+
coded_height: z.ZodNumber;
|
|
154
|
+
r_frame_rate: z.ZodString;
|
|
155
|
+
avg_frame_rate: z.ZodString;
|
|
156
|
+
time_base: z.ZodString;
|
|
157
|
+
start_pts: z.ZodOptional<z.ZodNumber>;
|
|
158
|
+
start_time: z.ZodOptional<z.ZodNumber>;
|
|
159
|
+
duration_ts: z.ZodOptional<z.ZodNumber>;
|
|
160
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
bit_rate: z.ZodOptional<z.ZodString>;
|
|
162
|
+
disposition: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
163
|
+
}, "strip", z.ZodTypeAny, {
|
|
164
|
+
index: number;
|
|
165
|
+
codec_name: string;
|
|
166
|
+
codec_long_name: string;
|
|
167
|
+
codec_type: "video";
|
|
168
|
+
codec_tag_string: string;
|
|
169
|
+
codec_tag: string;
|
|
170
|
+
r_frame_rate: string;
|
|
171
|
+
avg_frame_rate: string;
|
|
172
|
+
time_base: string;
|
|
173
|
+
disposition: Record<string, unknown>;
|
|
174
|
+
width: number;
|
|
175
|
+
height: number;
|
|
176
|
+
coded_width: number;
|
|
177
|
+
coded_height: number;
|
|
178
|
+
duration?: number | undefined;
|
|
179
|
+
start_pts?: number | undefined;
|
|
180
|
+
start_time?: number | undefined;
|
|
181
|
+
duration_ts?: number | undefined;
|
|
182
|
+
bit_rate?: string | undefined;
|
|
183
|
+
}, {
|
|
184
|
+
index: number;
|
|
185
|
+
codec_name: string;
|
|
186
|
+
codec_long_name: string;
|
|
187
|
+
codec_type: "video";
|
|
188
|
+
codec_tag_string: string;
|
|
189
|
+
codec_tag: string;
|
|
190
|
+
r_frame_rate: string;
|
|
191
|
+
avg_frame_rate: string;
|
|
192
|
+
time_base: string;
|
|
193
|
+
disposition: Record<string, unknown>;
|
|
194
|
+
width: number;
|
|
195
|
+
height: number;
|
|
196
|
+
coded_width: number;
|
|
197
|
+
coded_height: number;
|
|
198
|
+
duration?: number | undefined;
|
|
199
|
+
start_pts?: number | undefined;
|
|
200
|
+
start_time?: number | undefined;
|
|
201
|
+
duration_ts?: number | undefined;
|
|
202
|
+
bit_rate?: string | undefined;
|
|
203
|
+
}>;
|
|
204
|
+
duration_ms: z.ZodNumber;
|
|
205
|
+
codec_name: z.ZodString;
|
|
206
|
+
byte_size: z.ZodNumber;
|
|
207
|
+
}, "strip", z.ZodTypeAny, {
|
|
208
|
+
type: "video";
|
|
209
|
+
file_id: string;
|
|
210
|
+
track_id: number;
|
|
211
|
+
probe_info: {
|
|
212
|
+
index: number;
|
|
213
|
+
codec_name: string;
|
|
214
|
+
codec_long_name: string;
|
|
215
|
+
codec_type: "video";
|
|
216
|
+
codec_tag_string: string;
|
|
217
|
+
codec_tag: string;
|
|
218
|
+
r_frame_rate: string;
|
|
219
|
+
avg_frame_rate: string;
|
|
220
|
+
time_base: string;
|
|
221
|
+
disposition: Record<string, unknown>;
|
|
222
|
+
width: number;
|
|
223
|
+
height: number;
|
|
224
|
+
coded_width: number;
|
|
225
|
+
coded_height: number;
|
|
226
|
+
duration?: number | undefined;
|
|
227
|
+
start_pts?: number | undefined;
|
|
228
|
+
start_time?: number | undefined;
|
|
229
|
+
duration_ts?: number | undefined;
|
|
230
|
+
bit_rate?: string | undefined;
|
|
231
|
+
};
|
|
232
|
+
duration_ms: number;
|
|
233
|
+
codec_name: string;
|
|
234
|
+
byte_size: number;
|
|
235
|
+
}, {
|
|
236
|
+
type: "video";
|
|
237
|
+
file_id: string;
|
|
238
|
+
track_id: number;
|
|
239
|
+
probe_info: {
|
|
240
|
+
index: number;
|
|
241
|
+
codec_name: string;
|
|
242
|
+
codec_long_name: string;
|
|
243
|
+
codec_type: "video";
|
|
244
|
+
codec_tag_string: string;
|
|
245
|
+
codec_tag: string;
|
|
246
|
+
r_frame_rate: string;
|
|
247
|
+
avg_frame_rate: string;
|
|
248
|
+
time_base: string;
|
|
249
|
+
disposition: Record<string, unknown>;
|
|
250
|
+
width: number;
|
|
251
|
+
height: number;
|
|
252
|
+
coded_width: number;
|
|
253
|
+
coded_height: number;
|
|
254
|
+
duration?: number | undefined;
|
|
255
|
+
start_pts?: number | undefined;
|
|
256
|
+
start_time?: number | undefined;
|
|
257
|
+
duration_ts?: number | undefined;
|
|
258
|
+
bit_rate?: string | undefined;
|
|
259
|
+
};
|
|
260
|
+
duration_ms: number;
|
|
261
|
+
codec_name: string;
|
|
262
|
+
byte_size: number;
|
|
263
|
+
}>]>;
|
|
264
|
+
export interface CreateISOBMFFTrackResult {
|
|
265
|
+
last_received_byte: number;
|
|
266
|
+
byte_size: number;
|
|
267
|
+
track_id: number;
|
|
268
|
+
file_id: string;
|
|
269
|
+
}
|
|
270
|
+
export declare const createISOBMFFTrack: (client: Client, payload: z.infer<typeof CreateISOBMFFTrackPayload>) => Promise<CreateISOBMFFTrackResult | undefined>;
|
|
271
|
+
export declare const uploadISOBMFFTrack: (client: Client, fileId: string, trackId: number, fileStream: Readable) => Promise<unknown>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Client } from '../client.ts';
|
|
4
|
+
|
|
5
|
+
export declare const CreateRenderPayload: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
fps: z.ZodNumber;
|
|
8
|
+
width: z.ZodNumber;
|
|
9
|
+
height: z.ZodNumber;
|
|
10
|
+
work_slice_ms: z.ZodNumber;
|
|
11
|
+
duration_ms: z.ZodNumber;
|
|
12
|
+
strategy: z.ZodEnum<["v1", "v2"]>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
id: string;
|
|
15
|
+
height: number;
|
|
16
|
+
width: number;
|
|
17
|
+
duration_ms: number;
|
|
18
|
+
fps: number;
|
|
19
|
+
work_slice_ms: number;
|
|
20
|
+
strategy: "v1" | "v2";
|
|
21
|
+
}, {
|
|
22
|
+
id: string;
|
|
23
|
+
height: number;
|
|
24
|
+
width: number;
|
|
25
|
+
duration_ms: number;
|
|
26
|
+
fps: number;
|
|
27
|
+
work_slice_ms: number;
|
|
28
|
+
strategy: "v1" | "v2";
|
|
29
|
+
}>;
|
|
30
|
+
export interface CreateRenderResult {
|
|
31
|
+
status: "complete" | "created" | "failed" | "pending" | "rendering";
|
|
32
|
+
id: string;
|
|
33
|
+
}
|
|
34
|
+
export declare const createRender: (client: Client, payload: z.infer<typeof CreateRenderPayload>) => Promise<CreateRenderResult | undefined>;
|
|
35
|
+
export declare const uploadRender: (client: Client, fileId: string, fileStream: Readable) => Promise<unknown>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Client } from '../client.ts';
|
|
4
|
+
|
|
5
|
+
declare const FileProcessors: z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"isobmff">, z.ZodLiteral<"captions">]>, "many">, ("isobmff" | "captions")[], ("isobmff" | "captions")[]>;
|
|
6
|
+
export declare const CreateUnprocessedFilePayload: z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
filename: z.ZodString;
|
|
9
|
+
processes: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"isobmff">, z.ZodLiteral<"captions">]>, "many">, ("isobmff" | "captions")[], ("isobmff" | "captions")[]>>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
id: string;
|
|
12
|
+
filename: string;
|
|
13
|
+
processes?: ("isobmff" | "captions")[] | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
id: string;
|
|
16
|
+
filename: string;
|
|
17
|
+
processes?: ("isobmff" | "captions")[] | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const UpdateUnprocessedFilePayload: z.ZodObject<{
|
|
20
|
+
processes: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"isobmff">, z.ZodLiteral<"captions">]>, "many">, ("isobmff" | "captions")[], ("isobmff" | "captions")[]>>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
processes?: ("isobmff" | "captions")[] | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
processes?: ("isobmff" | "captions")[] | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export interface CreateUnprocessedFileResult {
|
|
27
|
+
byte_size: number;
|
|
28
|
+
last_received_byte: number;
|
|
29
|
+
id: string;
|
|
30
|
+
processes: z.infer<typeof FileProcessors>;
|
|
31
|
+
}
|
|
32
|
+
export interface UpdateUnprocessedFileResult {
|
|
33
|
+
byte_size: number;
|
|
34
|
+
last_received_byte: number;
|
|
35
|
+
id: string;
|
|
36
|
+
processes: z.infer<typeof FileProcessors>;
|
|
37
|
+
}
|
|
38
|
+
export declare const createUnprocessedFile: (client: Client, payload: z.infer<typeof CreateUnprocessedFilePayload>) => Promise<CreateUnprocessedFileResult>;
|
|
39
|
+
export declare const updateUnprocessedFile: (client: Client, fileId: string, payload: Partial<z.infer<typeof UpdateUnprocessedFilePayload>>) => Promise<UpdateUnprocessedFileResult>;
|
|
40
|
+
export declare const uploadUnprocessedFile: (client: Client, fileId: string, fileStream: Readable) => Promise<unknown>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import debug from "debug";
|
|
3
|
+
const log = debug("ef:api:unprocessed-file");
|
|
4
|
+
const FileProcessors = z.array(z.union([z.literal("isobmff"), z.literal("captions")])).refine(
|
|
5
|
+
(value) => {
|
|
6
|
+
return new Set(value).size === value.length;
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
message: "Processors list must not include duplicates"
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
const CreateUnprocessedFilePayload = z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
filename: z.string(),
|
|
15
|
+
processes: FileProcessors.optional()
|
|
16
|
+
});
|
|
17
|
+
const UpdateUnprocessedFilePayload = z.object({
|
|
18
|
+
processes: FileProcessors.optional()
|
|
19
|
+
});
|
|
20
|
+
const createUnprocessedFile = async (client, payload) => {
|
|
21
|
+
log("Creating an unprocessed file", payload);
|
|
22
|
+
const response = await client.authenticatedFetch(
|
|
23
|
+
"/api/v1/unprocessed_files",
|
|
24
|
+
{
|
|
25
|
+
method: "POST",
|
|
26
|
+
body: JSON.stringify(payload)
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
log(
|
|
30
|
+
"Unprocessed file created",
|
|
31
|
+
response.status,
|
|
32
|
+
response.statusText,
|
|
33
|
+
response.headers
|
|
34
|
+
);
|
|
35
|
+
switch (response.status) {
|
|
36
|
+
case 200: {
|
|
37
|
+
return await response.json();
|
|
38
|
+
}
|
|
39
|
+
default: {
|
|
40
|
+
console.error(
|
|
41
|
+
`Failed to create file ${response.status} ${response.statusText}`
|
|
42
|
+
);
|
|
43
|
+
console.error(await response.text());
|
|
44
|
+
throw new Error("Failed to create unprocessed file");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const updateUnprocessedFile = async (client, fileId, payload) => {
|
|
49
|
+
log("Updating unprocessed file", fileId, payload);
|
|
50
|
+
const response = await client.authenticatedFetch(
|
|
51
|
+
`/api/v1/unprocessed_files/${fileId}`,
|
|
52
|
+
{
|
|
53
|
+
method: "POST",
|
|
54
|
+
body: JSON.stringify(payload)
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
log("Unprocessed file updated", response);
|
|
58
|
+
switch (response.status) {
|
|
59
|
+
case 200: {
|
|
60
|
+
return await response.json();
|
|
61
|
+
}
|
|
62
|
+
default: {
|
|
63
|
+
console.error(
|
|
64
|
+
`Failed to update file ${response.status} ${response.statusText}`
|
|
65
|
+
);
|
|
66
|
+
throw new Error("Failed to update unprocessed file");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const uploadUnprocessedFile = async (client, fileId, fileStream) => {
|
|
71
|
+
log("Uploading unprocessed file", fileId);
|
|
72
|
+
const unprocessedFile = await client.authenticatedFetch(
|
|
73
|
+
`/api/v1/unprocessed_files/${fileId}/upload`,
|
|
74
|
+
{
|
|
75
|
+
method: "POST",
|
|
76
|
+
body: fileStream
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
log("Unprocessed file track uploaded", unprocessedFile);
|
|
80
|
+
switch (unprocessedFile.status) {
|
|
81
|
+
case 200: {
|
|
82
|
+
return unprocessedFile.json();
|
|
83
|
+
}
|
|
84
|
+
default: {
|
|
85
|
+
console.error("Failed to upload unprocessed file");
|
|
86
|
+
console.error(unprocessedFile.status, unprocessedFile.statusText);
|
|
87
|
+
throw new Error("Failed to upload unprocessed file");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
export {
|
|
92
|
+
CreateUnprocessedFilePayload,
|
|
93
|
+
UpdateUnprocessedFilePayload,
|
|
94
|
+
createUnprocessedFile,
|
|
95
|
+
updateUnprocessedFile,
|
|
96
|
+
uploadUnprocessedFile
|
|
97
|
+
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editframe/api",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.12",
|
|
4
4
|
"description": "API functions for EditFrame",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"import": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
},
|
|
11
|
-
"require": {
|
|
12
|
-
"default": "./dist/index.cjs",
|
|
13
|
-
"types": "./dist/index.d.ts"
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
14
10
|
}
|
|
15
11
|
}
|
|
16
12
|
},
|
|
@@ -23,14 +19,14 @@
|
|
|
23
19
|
"author": "",
|
|
24
20
|
"license": "UNLICENSED",
|
|
25
21
|
"devDependencies": {
|
|
26
|
-
"@types/node": "^20.14.
|
|
27
|
-
"typescript": "^5.
|
|
22
|
+
"@types/node": "^20.14.13",
|
|
23
|
+
"typescript": "^5.5.4",
|
|
28
24
|
"vite": "^5.2.11",
|
|
29
25
|
"vite-plugin-dts": "^3.9.1",
|
|
30
26
|
"vite-tsconfig-paths": "^4.3.2"
|
|
31
27
|
},
|
|
32
28
|
"dependencies": {
|
|
33
|
-
"@editframe/assets": "0.7.0-beta.
|
|
29
|
+
"@editframe/assets": "0.7.0-beta.12",
|
|
34
30
|
"debug": "^4.3.5",
|
|
35
31
|
"zod": "^3.23.8"
|
|
36
32
|
}
|
package/src/resources/renders.ts
CHANGED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { Readable } from "node:stream";
|
|
2
|
+
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import debug from "debug";
|
|
5
|
+
|
|
6
|
+
import type { Client } from "../client.ts";
|
|
7
|
+
|
|
8
|
+
const log = debug("ef:api:unprocessed-file");
|
|
9
|
+
|
|
10
|
+
const FileProcessors = z
|
|
11
|
+
.array(z.union([z.literal("isobmff"), z.literal("captions")]))
|
|
12
|
+
.refine(
|
|
13
|
+
(value) => {
|
|
14
|
+
return new Set(value).size === value.length;
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
message: "Processors list must not include duplicates",
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export const CreateUnprocessedFilePayload = z.object({
|
|
22
|
+
id: z.string(),
|
|
23
|
+
filename: z.string(),
|
|
24
|
+
processes: FileProcessors.optional(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const UpdateUnprocessedFilePayload = z.object({
|
|
28
|
+
processes: FileProcessors.optional(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export interface CreateUnprocessedFileResult {
|
|
32
|
+
byte_size: number;
|
|
33
|
+
last_received_byte: number;
|
|
34
|
+
id: string;
|
|
35
|
+
processes: z.infer<typeof FileProcessors>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface UpdateUnprocessedFileResult {
|
|
39
|
+
byte_size: number;
|
|
40
|
+
last_received_byte: number;
|
|
41
|
+
id: string;
|
|
42
|
+
processes: z.infer<typeof FileProcessors>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const createUnprocessedFile = async (
|
|
46
|
+
client: Client,
|
|
47
|
+
payload: z.infer<typeof CreateUnprocessedFilePayload>,
|
|
48
|
+
) => {
|
|
49
|
+
log("Creating an unprocessed file", payload);
|
|
50
|
+
const response = await client.authenticatedFetch(
|
|
51
|
+
"/api/v1/unprocessed_files",
|
|
52
|
+
{
|
|
53
|
+
method: "POST",
|
|
54
|
+
body: JSON.stringify(payload),
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
log(
|
|
59
|
+
"Unprocessed file created",
|
|
60
|
+
response.status,
|
|
61
|
+
response.statusText,
|
|
62
|
+
response.headers,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
switch (response.status) {
|
|
66
|
+
case 200: {
|
|
67
|
+
return (await response.json()) as CreateUnprocessedFileResult;
|
|
68
|
+
}
|
|
69
|
+
default: {
|
|
70
|
+
console.error(
|
|
71
|
+
`Failed to create file ${response.status} ${response.statusText}`,
|
|
72
|
+
);
|
|
73
|
+
console.error(await response.text());
|
|
74
|
+
throw new Error("Failed to create unprocessed file");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const updateUnprocessedFile = async (
|
|
80
|
+
client: Client,
|
|
81
|
+
fileId: string,
|
|
82
|
+
payload: Partial<z.infer<typeof UpdateUnprocessedFilePayload>>,
|
|
83
|
+
) => {
|
|
84
|
+
log("Updating unprocessed file", fileId, payload);
|
|
85
|
+
const response = await client.authenticatedFetch(
|
|
86
|
+
`/api/v1/unprocessed_files/${fileId}`,
|
|
87
|
+
{
|
|
88
|
+
method: "POST",
|
|
89
|
+
body: JSON.stringify(payload),
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
log("Unprocessed file updated", response);
|
|
94
|
+
|
|
95
|
+
switch (response.status) {
|
|
96
|
+
case 200: {
|
|
97
|
+
return (await response.json()) as UpdateUnprocessedFileResult;
|
|
98
|
+
}
|
|
99
|
+
default: {
|
|
100
|
+
console.error(
|
|
101
|
+
`Failed to update file ${response.status} ${response.statusText}`,
|
|
102
|
+
);
|
|
103
|
+
throw new Error("Failed to update unprocessed file");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const uploadUnprocessedFile = async (
|
|
109
|
+
client: Client,
|
|
110
|
+
fileId: string,
|
|
111
|
+
fileStream: Readable,
|
|
112
|
+
) => {
|
|
113
|
+
log("Uploading unprocessed file", fileId);
|
|
114
|
+
const unprocessedFile = await client.authenticatedFetch(
|
|
115
|
+
`/api/v1/unprocessed_files/${fileId}/upload`,
|
|
116
|
+
{
|
|
117
|
+
method: "POST",
|
|
118
|
+
body: fileStream,
|
|
119
|
+
},
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
log("Unprocessed file track uploaded", unprocessedFile);
|
|
123
|
+
switch (unprocessedFile.status) {
|
|
124
|
+
case 200: {
|
|
125
|
+
return unprocessedFile.json();
|
|
126
|
+
}
|
|
127
|
+
default: {
|
|
128
|
+
console.error("Failed to upload unprocessed file");
|
|
129
|
+
console.error(unprocessedFile.status, unprocessedFile.statusText);
|
|
130
|
+
throw new Error("Failed to upload unprocessed file");
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
package/dist/client.cjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const debug = require("debug");
|
|
4
|
-
const fetch = require("node-fetch");
|
|
5
|
-
const log = debug("ef:api:client");
|
|
6
|
-
class Client {
|
|
7
|
-
constructor(token, efHost) {
|
|
8
|
-
this.token = token;
|
|
9
|
-
this.efHost = efHost;
|
|
10
|
-
this.authenticatedFetch = async (path, init = {}) => {
|
|
11
|
-
init.headers ||= {};
|
|
12
|
-
log(
|
|
13
|
-
"Authenticated fetch",
|
|
14
|
-
{ path, init },
|
|
15
|
-
"(Token will be added as Bearer token)"
|
|
16
|
-
);
|
|
17
|
-
Object.assign(init.headers, {
|
|
18
|
-
Authorization: `Bearer ${this.token}`,
|
|
19
|
-
"Content-Type": "application/json"
|
|
20
|
-
});
|
|
21
|
-
const url = new URL(path, this.efHost);
|
|
22
|
-
const response = await fetch(url, init);
|
|
23
|
-
log("Authenticated fetch response", response.status, response.statusText);
|
|
24
|
-
return response;
|
|
25
|
-
};
|
|
26
|
-
log("Creating client with efHost", efHost, "and !!token", !!token);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.Client = Client;
|
package/dist/index.cjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const captionFile = require("./resources/caption-file.cjs");
|
|
4
|
-
const imageFile = require("./resources/image-file.cjs");
|
|
5
|
-
const isobmffFile = require("./resources/isobmff-file.cjs");
|
|
6
|
-
const isobmffTrack = require("./resources/isobmff-track.cjs");
|
|
7
|
-
const renders = require("./resources/renders.cjs");
|
|
8
|
-
const client = require("./client.cjs");
|
|
9
|
-
exports.CreateCaptionFilePayload = captionFile.CreateCaptionFilePayload;
|
|
10
|
-
exports.createCaptionFile = captionFile.createCaptionFile;
|
|
11
|
-
exports.uploadCaptionFile = captionFile.uploadCaptionFile;
|
|
12
|
-
exports.CreateImageFilePayload = imageFile.CreateImageFilePayload;
|
|
13
|
-
exports.createImageFile = imageFile.createImageFile;
|
|
14
|
-
exports.uploadImageFile = imageFile.uploadImageFile;
|
|
15
|
-
exports.CreateISOBMFFFilePayload = isobmffFile.CreateISOBMFFFilePayload;
|
|
16
|
-
exports.createISOBMFFFile = isobmffFile.createISOBMFFFile;
|
|
17
|
-
exports.uploadFragmentIndex = isobmffFile.uploadFragmentIndex;
|
|
18
|
-
exports.CreateISOBMFFTrackPayload = isobmffTrack.CreateISOBMFFTrackPayload;
|
|
19
|
-
exports.createISOBMFFTrack = isobmffTrack.createISOBMFFTrack;
|
|
20
|
-
exports.uploadISOBMFFTrack = isobmffTrack.uploadISOBMFFTrack;
|
|
21
|
-
exports.CreateRenderPayload = renders.CreateRenderPayload;
|
|
22
|
-
exports.createRender = renders.createRender;
|
|
23
|
-
exports.uploadRender = renders.uploadRender;
|
|
24
|
-
exports.Client = client.Client;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const zod = require("zod");
|
|
4
|
-
const debug = require("debug");
|
|
5
|
-
const log = debug("ef:api:caption-file");
|
|
6
|
-
const CreateCaptionFilePayload = zod.z.object({
|
|
7
|
-
id: zod.z.string(),
|
|
8
|
-
filename: zod.z.string()
|
|
9
|
-
});
|
|
10
|
-
const createCaptionFile = async (client, payload) => {
|
|
11
|
-
log("Creating caption file", payload);
|
|
12
|
-
const fileCreation = await client.authenticatedFetch(
|
|
13
|
-
"/api/video2/caption_files",
|
|
14
|
-
{
|
|
15
|
-
method: "POST",
|
|
16
|
-
body: JSON.stringify(payload)
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
log("Caption file created", fileCreation);
|
|
20
|
-
switch (fileCreation.status) {
|
|
21
|
-
case 200: {
|
|
22
|
-
return await fileCreation.json();
|
|
23
|
-
}
|
|
24
|
-
default: {
|
|
25
|
-
console.error(
|
|
26
|
-
`Failed to create file ${fileCreation.status} ${fileCreation.statusText}`
|
|
27
|
-
);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const uploadCaptionFile = async (client, fileId, fileStream) => {
|
|
33
|
-
log("Uploading caption file", fileId);
|
|
34
|
-
const fileIndex = await client.authenticatedFetch(
|
|
35
|
-
`/api/video2/caption_files/${fileId}/upload`,
|
|
36
|
-
{
|
|
37
|
-
method: "POST",
|
|
38
|
-
body: fileStream
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
log("Caption file uploaded", fileIndex);
|
|
42
|
-
switch (fileIndex.status) {
|
|
43
|
-
case 200: {
|
|
44
|
-
return fileIndex.json();
|
|
45
|
-
}
|
|
46
|
-
default: {
|
|
47
|
-
console.error(
|
|
48
|
-
`Failed to upload caption ${fileIndex.status} ${fileIndex.statusText}`
|
|
49
|
-
);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
exports.CreateCaptionFilePayload = CreateCaptionFilePayload;
|
|
55
|
-
exports.createCaptionFile = createCaptionFile;
|
|
56
|
-
exports.uploadCaptionFile = uploadCaptionFile;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const zod = require("zod");
|
|
4
|
-
const debug = require("debug");
|
|
5
|
-
const log = debug("ef:api:image-file");
|
|
6
|
-
const CreateImageFilePayload = zod.z.object({
|
|
7
|
-
id: zod.z.string(),
|
|
8
|
-
height: zod.z.number().int(),
|
|
9
|
-
width: zod.z.number().int(),
|
|
10
|
-
mime_type: zod.z.enum(["image/jpeg", "image/png", "image/jpg", "image/webp"]),
|
|
11
|
-
filename: zod.z.string()
|
|
12
|
-
});
|
|
13
|
-
const createImageFile = async (client, payload) => {
|
|
14
|
-
log("Creating image file", payload);
|
|
15
|
-
const response = await client.authenticatedFetch("/api/video2/image_files", {
|
|
16
|
-
method: "POST",
|
|
17
|
-
body: JSON.stringify(payload)
|
|
18
|
-
});
|
|
19
|
-
log("Image file created", response);
|
|
20
|
-
switch (response.status) {
|
|
21
|
-
case 200: {
|
|
22
|
-
return await response.json();
|
|
23
|
-
}
|
|
24
|
-
default: {
|
|
25
|
-
console.error(
|
|
26
|
-
`Failed to create file ${response.status} ${response.statusText}`
|
|
27
|
-
);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const uploadImageFile = async (client, fileId, fileStream) => {
|
|
33
|
-
const fileIndex = await client.authenticatedFetch(
|
|
34
|
-
`/api/video2/image_files/${fileId}/upload`,
|
|
35
|
-
{
|
|
36
|
-
method: "POST",
|
|
37
|
-
body: fileStream
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
switch (fileIndex.status) {
|
|
41
|
-
case 200: {
|
|
42
|
-
return fileIndex.json();
|
|
43
|
-
}
|
|
44
|
-
default: {
|
|
45
|
-
console.error("Failed to upload image");
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
exports.CreateImageFilePayload = CreateImageFilePayload;
|
|
51
|
-
exports.createImageFile = createImageFile;
|
|
52
|
-
exports.uploadImageFile = uploadImageFile;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const zod = require("zod");
|
|
4
|
-
const debug = require("debug");
|
|
5
|
-
const log = debug("ef:api:isobmff-file");
|
|
6
|
-
const CreateISOBMFFFilePayload = zod.z.object({
|
|
7
|
-
id: zod.z.string(),
|
|
8
|
-
filename: zod.z.string()
|
|
9
|
-
});
|
|
10
|
-
const createISOBMFFFile = async (client, payload) => {
|
|
11
|
-
log("Creating isobmff file", payload);
|
|
12
|
-
const response = await client.authenticatedFetch(
|
|
13
|
-
"/api/video2/isobmff_files",
|
|
14
|
-
{
|
|
15
|
-
method: "POST",
|
|
16
|
-
body: JSON.stringify(payload)
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
log("ISOBMFF file created", response);
|
|
20
|
-
switch (response.status) {
|
|
21
|
-
case 200: {
|
|
22
|
-
return await response.json();
|
|
23
|
-
}
|
|
24
|
-
default: {
|
|
25
|
-
console.error(
|
|
26
|
-
`Failed to create file ${response.status} ${response.statusText}`
|
|
27
|
-
);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const uploadFragmentIndex = async (client, fileId, fileStream) => {
|
|
33
|
-
log("Uploading fragment index", fileId);
|
|
34
|
-
const fileIndex = await client.authenticatedFetch(
|
|
35
|
-
`/api/video2/isobmff_files/${fileId}/index/upload`,
|
|
36
|
-
{
|
|
37
|
-
method: "POST",
|
|
38
|
-
body: fileStream
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
log("Fragment index uploaded", fileIndex);
|
|
42
|
-
switch (fileIndex.status) {
|
|
43
|
-
case 200: {
|
|
44
|
-
return fileIndex.json();
|
|
45
|
-
}
|
|
46
|
-
default: {
|
|
47
|
-
console.error(
|
|
48
|
-
`Failed to create fragment index ${fileIndex.status} ${fileIndex.statusText}`
|
|
49
|
-
);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
exports.CreateISOBMFFFilePayload = CreateISOBMFFFilePayload;
|
|
55
|
-
exports.createISOBMFFFile = createISOBMFFFile;
|
|
56
|
-
exports.uploadFragmentIndex = uploadFragmentIndex;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const zod = require("zod");
|
|
4
|
-
const debug = require("debug");
|
|
5
|
-
const assets = require("@editframe/assets");
|
|
6
|
-
const log = debug("ef:api:isobmff-track");
|
|
7
|
-
const CreateISOBMFFTrackPayload = zod.z.discriminatedUnion("type", [
|
|
8
|
-
zod.z.object({
|
|
9
|
-
file_id: zod.z.string(),
|
|
10
|
-
track_id: zod.z.number().int(),
|
|
11
|
-
type: zod.z.literal("audio"),
|
|
12
|
-
probe_info: assets.AudioStreamSchema,
|
|
13
|
-
duration_ms: zod.z.number().int(),
|
|
14
|
-
codec_name: zod.z.string(),
|
|
15
|
-
byte_size: zod.z.number().int()
|
|
16
|
-
}),
|
|
17
|
-
zod.z.object({
|
|
18
|
-
file_id: zod.z.string(),
|
|
19
|
-
track_id: zod.z.number().int(),
|
|
20
|
-
type: zod.z.literal("video"),
|
|
21
|
-
probe_info: assets.VideoStreamSchema,
|
|
22
|
-
duration_ms: zod.z.number().int(),
|
|
23
|
-
codec_name: zod.z.string(),
|
|
24
|
-
byte_size: zod.z.number().int()
|
|
25
|
-
})
|
|
26
|
-
]);
|
|
27
|
-
const createISOBMFFTrack = async (client, payload) => {
|
|
28
|
-
log("Creating isobmff track", payload);
|
|
29
|
-
const response = await client.authenticatedFetch(
|
|
30
|
-
"/api/video2/isobmff_tracks",
|
|
31
|
-
{
|
|
32
|
-
method: "POST",
|
|
33
|
-
body: JSON.stringify(payload)
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
log("ISOBMFF track created", response);
|
|
37
|
-
switch (response.status) {
|
|
38
|
-
case 200: {
|
|
39
|
-
return await response.json();
|
|
40
|
-
}
|
|
41
|
-
default: {
|
|
42
|
-
console.error("Failed to create track");
|
|
43
|
-
console.error(await response.json());
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const uploadISOBMFFTrack = async (client, fileId, trackId, fileStream) => {
|
|
49
|
-
log("Uploading isobmff track", fileId, trackId);
|
|
50
|
-
const trackIndex = await client.authenticatedFetch(
|
|
51
|
-
`/api/video2/isobmff_tracks/${fileId}/${trackId}/upload`,
|
|
52
|
-
{
|
|
53
|
-
method: "POST",
|
|
54
|
-
body: fileStream
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
log("ISOBMFF track uploaded", trackIndex);
|
|
58
|
-
switch (trackIndex.status) {
|
|
59
|
-
case 200: {
|
|
60
|
-
return trackIndex.json();
|
|
61
|
-
}
|
|
62
|
-
default: {
|
|
63
|
-
console.error("Failed to upload track");
|
|
64
|
-
console.error(trackIndex.status, trackIndex.statusText);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
exports.CreateISOBMFFTrackPayload = CreateISOBMFFTrackPayload;
|
|
70
|
-
exports.createISOBMFFTrack = createISOBMFFTrack;
|
|
71
|
-
exports.uploadISOBMFFTrack = uploadISOBMFFTrack;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const zod = require("zod");
|
|
4
|
-
const debug = require("debug");
|
|
5
|
-
const log = debug("ef:api:renders");
|
|
6
|
-
const CreateRenderPayload = zod.z.object({
|
|
7
|
-
id: zod.z.string().uuid(),
|
|
8
|
-
fps: zod.z.number(),
|
|
9
|
-
width: zod.z.number().int(),
|
|
10
|
-
height: zod.z.number().int(),
|
|
11
|
-
work_slice_ms: zod.z.number().int(),
|
|
12
|
-
duration_ms: zod.z.number().int(),
|
|
13
|
-
strategy: zod.z.enum(["v1", "v2"])
|
|
14
|
-
});
|
|
15
|
-
const createRender = async (client, payload) => {
|
|
16
|
-
log("Creating render", payload);
|
|
17
|
-
const response = await client.authenticatedFetch("/api/video2/renders", {
|
|
18
|
-
method: "POST",
|
|
19
|
-
body: JSON.stringify(payload)
|
|
20
|
-
});
|
|
21
|
-
log("Render created", response);
|
|
22
|
-
switch (response.status) {
|
|
23
|
-
case 200: {
|
|
24
|
-
return await response.json();
|
|
25
|
-
}
|
|
26
|
-
default: {
|
|
27
|
-
console.error("Failed to create render");
|
|
28
|
-
console.error(await response.json());
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const uploadRender = async (client, fileId, fileStream) => {
|
|
34
|
-
log("Uploading render", fileId);
|
|
35
|
-
const fileIndex = await client.authenticatedFetch(
|
|
36
|
-
`/api/video2/renders/${fileId}/upload`,
|
|
37
|
-
{
|
|
38
|
-
method: "POST",
|
|
39
|
-
body: fileStream
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
log("Render uploaded", fileIndex);
|
|
43
|
-
switch (fileIndex.status) {
|
|
44
|
-
case 200: {
|
|
45
|
-
return fileIndex.json();
|
|
46
|
-
}
|
|
47
|
-
default: {
|
|
48
|
-
console.error("Failed to upload render");
|
|
49
|
-
console.error(fileIndex.status, fileIndex.statusText);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
exports.CreateRenderPayload = CreateRenderPayload;
|
|
55
|
-
exports.createRender = createRender;
|
|
56
|
-
exports.uploadRender = uploadRender;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Readable } from "node:stream";
|
|
2
|
-
|
|
3
|
-
export const nodeStreamToWebStream = (nodeStream: Readable): BodyInit => {
|
|
4
|
-
return new ReadableStream({
|
|
5
|
-
start(controller) {
|
|
6
|
-
nodeStream.on("data", (chunk) => {
|
|
7
|
-
controller.enqueue(chunk);
|
|
8
|
-
});
|
|
9
|
-
nodeStream.on("end", () => {
|
|
10
|
-
controller.close();
|
|
11
|
-
});
|
|
12
|
-
nodeStream.on("error", (err) => {
|
|
13
|
-
controller.error(err);
|
|
14
|
-
});
|
|
15
|
-
},
|
|
16
|
-
cancel() {
|
|
17
|
-
nodeStream.destroy();
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
};
|