@editframe/api 0.7.0-beta.12 → 0.7.0-beta.15
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
CHANGED
|
@@ -3,6 +3,6 @@ import { RequestInit } from 'node-fetch';
|
|
|
3
3
|
export declare class Client {
|
|
4
4
|
private token;
|
|
5
5
|
private efHost;
|
|
6
|
-
constructor(token: string, efHost
|
|
6
|
+
constructor(token: string, efHost?: string);
|
|
7
7
|
authenticatedFetch: (path: string, init?: RequestInit) => Promise<import('node-fetch').Response>;
|
|
8
8
|
}
|
package/dist/client.js
CHANGED
|
@@ -2,7 +2,7 @@ import debug from "debug";
|
|
|
2
2
|
import fetch from "node-fetch";
|
|
3
3
|
const log = debug("ef:api:client");
|
|
4
4
|
class Client {
|
|
5
|
-
constructor(token, efHost) {
|
|
5
|
+
constructor(token, efHost = "https://editframe.dev") {
|
|
6
6
|
this.token = token;
|
|
7
7
|
this.efHost = efHost;
|
|
8
8
|
this.authenticatedFetch = async (path, init = {}) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export { createImageFile, CreateImageFilePayload, type CreateImageFileResult, up
|
|
|
3
3
|
export { createISOBMFFFile, CreateISOBMFFFilePayload, type CreateISOBMFFFileResult, uploadFragmentIndex, } from './resources/isobmff-file.ts';
|
|
4
4
|
export { createISOBMFFTrack, CreateISOBMFFTrackPayload, type CreateISOBMFFTrackResult, uploadISOBMFFTrack, } from './resources/isobmff-track.ts';
|
|
5
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';
|
|
6
|
+
export { createUnprocessedFile, CreateUnprocessedFilePayload, type CreateUnprocessedFileResult, updateUnprocessedFile, UpdateUnprocessedFilePayload, type UpdateUnprocessedFileResult, uploadUnprocessedFile, processAVFile, } from './resources/unprocessed-file.ts';
|
|
7
7
|
export { Client } from './client.ts';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +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
|
+
import { CreateUnprocessedFilePayload, UpdateUnprocessedFilePayload, createUnprocessedFile, processAVFile, updateUnprocessedFile, uploadUnprocessedFile } from "./resources/unprocessed-file.js";
|
|
7
7
|
import { Client } from "./client.js";
|
|
8
8
|
export {
|
|
9
9
|
Client,
|
|
@@ -20,6 +20,7 @@ export {
|
|
|
20
20
|
createImageFile,
|
|
21
21
|
createRender,
|
|
22
22
|
createUnprocessedFile,
|
|
23
|
+
processAVFile,
|
|
23
24
|
updateUnprocessedFile,
|
|
24
25
|
uploadCaptionFile,
|
|
25
26
|
uploadFragmentIndex,
|
|
@@ -38,4 +38,5 @@ export interface UpdateUnprocessedFileResult {
|
|
|
38
38
|
export declare const createUnprocessedFile: (client: Client, payload: z.infer<typeof CreateUnprocessedFilePayload>) => Promise<CreateUnprocessedFileResult>;
|
|
39
39
|
export declare const updateUnprocessedFile: (client: Client, fileId: string, payload: Partial<z.infer<typeof UpdateUnprocessedFilePayload>>) => Promise<UpdateUnprocessedFileResult>;
|
|
40
40
|
export declare const uploadUnprocessedFile: (client: Client, fileId: string, fileStream: Readable) => Promise<unknown>;
|
|
41
|
+
export declare const processAVFile: (client: Client, filePath: string) => Promise<UpdateUnprocessedFileResult>;
|
|
41
42
|
export {};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
import { createReadStream } from "node:fs";
|
|
1
3
|
import { z } from "zod";
|
|
2
4
|
import debug from "debug";
|
|
5
|
+
import { md5FilePath } from "@editframe/assets";
|
|
3
6
|
const log = debug("ef:api:unprocessed-file");
|
|
4
7
|
const FileProcessors = z.array(z.union([z.literal("isobmff"), z.literal("captions")])).refine(
|
|
5
8
|
(value) => {
|
|
@@ -88,10 +91,28 @@ const uploadUnprocessedFile = async (client, fileId, fileStream) => {
|
|
|
88
91
|
}
|
|
89
92
|
}
|
|
90
93
|
};
|
|
94
|
+
const processAVFile = async (client, filePath) => {
|
|
95
|
+
log("Processing AV file", filePath);
|
|
96
|
+
const fileId = await md5FilePath(filePath);
|
|
97
|
+
log("File ID", fileId);
|
|
98
|
+
await createUnprocessedFile(client, {
|
|
99
|
+
id: fileId,
|
|
100
|
+
processes: [],
|
|
101
|
+
filename: basename(filePath)
|
|
102
|
+
});
|
|
103
|
+
const readStream = createReadStream(filePath);
|
|
104
|
+
await uploadUnprocessedFile(client, fileId, readStream);
|
|
105
|
+
const fileInformation = await updateUnprocessedFile(client, fileId, {
|
|
106
|
+
processes: ["isobmff"]
|
|
107
|
+
});
|
|
108
|
+
log("File processed", fileInformation);
|
|
109
|
+
return fileInformation;
|
|
110
|
+
};
|
|
91
111
|
export {
|
|
92
112
|
CreateUnprocessedFilePayload,
|
|
93
113
|
UpdateUnprocessedFilePayload,
|
|
94
114
|
createUnprocessedFile,
|
|
115
|
+
processAVFile,
|
|
95
116
|
updateUnprocessedFile,
|
|
96
117
|
uploadUnprocessedFile
|
|
97
118
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editframe/api",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.15",
|
|
4
4
|
"description": "API functions for EditFrame",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"vite-tsconfig-paths": "^4.3.2"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@editframe/assets": "0.7.0-beta.
|
|
29
|
+
"@editframe/assets": "0.7.0-beta.15",
|
|
30
30
|
"debug": "^4.3.5",
|
|
31
31
|
"zod": "^3.23.8"
|
|
32
32
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { Readable } from "node:stream";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { createReadStream } from "node:fs";
|
|
2
4
|
|
|
3
5
|
import { z } from "zod";
|
|
4
6
|
import debug from "debug";
|
|
5
7
|
|
|
8
|
+
import { md5FilePath } from "@editframe/assets";
|
|
9
|
+
|
|
6
10
|
import type { Client } from "../client.ts";
|
|
7
11
|
|
|
8
12
|
const log = debug("ef:api:unprocessed-file");
|
|
@@ -131,3 +135,26 @@ export const uploadUnprocessedFile = async (
|
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
};
|
|
138
|
+
|
|
139
|
+
export const processAVFile = async (client: Client, filePath: string) => {
|
|
140
|
+
log("Processing AV file", filePath);
|
|
141
|
+
const fileId = await md5FilePath(filePath);
|
|
142
|
+
|
|
143
|
+
log("File ID", fileId);
|
|
144
|
+
await createUnprocessedFile(client, {
|
|
145
|
+
id: fileId,
|
|
146
|
+
processes: [],
|
|
147
|
+
filename: basename(filePath),
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const readStream = createReadStream(filePath);
|
|
151
|
+
|
|
152
|
+
await uploadUnprocessedFile(client, fileId, readStream);
|
|
153
|
+
|
|
154
|
+
const fileInformation = await updateUnprocessedFile(client, fileId, {
|
|
155
|
+
processes: ["isobmff"],
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
log("File processed", fileInformation);
|
|
159
|
+
return fileInformation;
|
|
160
|
+
};
|