@editframe/api 0.7.0-beta.12 → 0.7.0-beta.16

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: string);
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, processAVFileBuffer, } 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, processAVFileBuffer, updateUnprocessedFile, uploadUnprocessedFile } from "./resources/unprocessed-file.js";
7
7
  import { Client } from "./client.js";
8
8
  export {
9
9
  Client,
@@ -20,6 +20,8 @@ export {
20
20
  createImageFile,
21
21
  createRender,
22
22
  createUnprocessedFile,
23
+ processAVFile,
24
+ processAVFileBuffer,
23
25
  updateUnprocessedFile,
24
26
  uploadCaptionFile,
25
27
  uploadFragmentIndex,
@@ -38,4 +38,6 @@ 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 processAVFileBuffer: (client: Client, buffer: Buffer) => Promise<UpdateUnprocessedFileResult>;
42
+ export declare const processAVFile: (client: Client, filePath: string) => Promise<UpdateUnprocessedFileResult>;
41
43
  export {};
@@ -1,5 +1,9 @@
1
+ import { Readable } from "node:stream";
2
+ import { basename } from "node:path";
3
+ import { createReadStream } from "node:fs";
1
4
  import { z } from "zod";
2
5
  import debug from "debug";
6
+ import { md5Buffer, md5FilePath } from "@editframe/assets";
3
7
  const log = debug("ef:api:unprocessed-file");
4
8
  const FileProcessors = z.array(z.union([z.literal("isobmff"), z.literal("captions")])).refine(
5
9
  (value) => {
@@ -88,10 +92,48 @@ const uploadUnprocessedFile = async (client, fileId, fileStream) => {
88
92
  }
89
93
  }
90
94
  };
95
+ const processAVFileBuffer = async (client, buffer) => {
96
+ log("Processing AV file buffer");
97
+ const fileId = await md5Buffer(buffer);
98
+ log("File ID", fileId);
99
+ await createUnprocessedFile(client, {
100
+ id: fileId,
101
+ processes: [],
102
+ filename: "buffer"
103
+ });
104
+ const readStream = new Readable();
105
+ readStream.push(buffer);
106
+ readStream.push(null);
107
+ await uploadUnprocessedFile(client, fileId, readStream);
108
+ const fileInformation = await updateUnprocessedFile(client, fileId, {
109
+ processes: ["isobmff"]
110
+ });
111
+ log("File processed", fileInformation);
112
+ return fileInformation;
113
+ };
114
+ const processAVFile = async (client, filePath) => {
115
+ log("Processing AV file", filePath);
116
+ const fileId = await md5FilePath(filePath);
117
+ log("File ID", fileId);
118
+ await createUnprocessedFile(client, {
119
+ id: fileId,
120
+ processes: [],
121
+ filename: basename(filePath)
122
+ });
123
+ const readStream = createReadStream(filePath);
124
+ await uploadUnprocessedFile(client, fileId, readStream);
125
+ const fileInformation = await updateUnprocessedFile(client, fileId, {
126
+ processes: ["isobmff"]
127
+ });
128
+ log("File processed", fileInformation);
129
+ return fileInformation;
130
+ };
91
131
  export {
92
132
  CreateUnprocessedFilePayload,
93
133
  UpdateUnprocessedFilePayload,
94
134
  createUnprocessedFile,
135
+ processAVFile,
136
+ processAVFileBuffer,
95
137
  updateUnprocessedFile,
96
138
  uploadUnprocessedFile
97
139
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editframe/api",
3
- "version": "0.7.0-beta.12",
3
+ "version": "0.7.0-beta.16",
4
4
  "description": "API functions for EditFrame",
5
5
  "exports": {
6
6
  ".": {
@@ -26,8 +26,9 @@
26
26
  "vite-tsconfig-paths": "^4.3.2"
27
27
  },
28
28
  "dependencies": {
29
- "@editframe/assets": "0.7.0-beta.12",
29
+ "@editframe/assets": "0.7.0-beta.16",
30
30
  "debug": "^4.3.5",
31
+ "node-fetch": "^3.3.2",
31
32
  "zod": "^3.23.8"
32
33
  }
33
34
  }
@@ -1,8 +1,12 @@
1
- import type { Readable } from "node:stream";
1
+ import { 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, md5Buffer } 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,51 @@ export const uploadUnprocessedFile = async (
131
135
  }
132
136
  }
133
137
  };
138
+
139
+ export const processAVFileBuffer = async (client: Client, buffer: Buffer) => {
140
+ log("Processing AV file buffer");
141
+ const fileId = await md5Buffer(buffer);
142
+
143
+ log("File ID", fileId);
144
+ await createUnprocessedFile(client, {
145
+ id: fileId,
146
+ processes: [],
147
+ filename: "buffer",
148
+ });
149
+
150
+ const readStream = new Readable();
151
+ readStream.push(buffer);
152
+ readStream.push(null);
153
+
154
+ await uploadUnprocessedFile(client, fileId, readStream);
155
+
156
+ const fileInformation = await updateUnprocessedFile(client, fileId, {
157
+ processes: ["isobmff"],
158
+ });
159
+
160
+ log("File processed", fileInformation);
161
+ return fileInformation;
162
+ };
163
+
164
+ export const processAVFile = async (client: Client, filePath: string) => {
165
+ log("Processing AV file", filePath);
166
+ const fileId = await md5FilePath(filePath);
167
+
168
+ log("File ID", fileId);
169
+ await createUnprocessedFile(client, {
170
+ id: fileId,
171
+ processes: [],
172
+ filename: basename(filePath),
173
+ });
174
+
175
+ const readStream = createReadStream(filePath);
176
+
177
+ await uploadUnprocessedFile(client, fileId, readStream);
178
+
179
+ const fileInformation = await updateUnprocessedFile(client, fileId, {
180
+ processes: ["isobmff"],
181
+ });
182
+
183
+ log("File processed", fileInformation);
184
+ return fileInformation;
185
+ };