@editframe/api 0.12.0-beta.12 → 0.12.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/index.d.ts CHANGED
@@ -5,6 +5,6 @@ export { createISOBMFFTrack, CreateISOBMFFTrackPayload, type CreateISOBMFFTrackR
5
5
  export { createRender, CreateRenderPayload, type CreateRenderResult, uploadRender, type LookupRenderByMd5Result, lookupRenderByMd5, } from './resources/renders.ts';
6
6
  export { createTranscription, CreateTranscriptionPayload, type CreateTranscriptionResult, getTranscriptionInfo, getTranscriptionProgress, type TranscriptionInfoResult, } from './resources/transcriptions.ts';
7
7
  export { createURLToken, type URLTokenResult, } from './resources/url-token.ts';
8
- export { createUnprocessedFile, CreateUnprocessedFilePayload, type CreateUnprocessedFileResult, uploadUnprocessedReadableStream, type LookupUnprocessedFileByMd5Result, lookupUnprocessedFileByMd5, processIsobmffFile, type ProcessIsobmffFileResult, createUnprocessedFileFromPath, uploadUnprocessedFile, } from './resources/unprocessed-file.ts';
8
+ export { createUnprocessedFile, CreateUnprocessedFilePayload, type CreateUnprocessedFileResult, uploadUnprocessedReadableStream, type LookupUnprocessedFileByMd5Result, lookupUnprocessedFileByMd5, processIsobmffFile, type ProcessIsobmffFileResult, } from './resources/unprocessed-file.ts';
9
9
  export { getIsobmffProcessInfo, getIsobmffProcessProgress, type IsobmffProcessInfoResult, } from './resources/process-isobmff.ts';
10
10
  export { Client } from './client.ts';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { CreateISOBMFFTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } fro
5
5
  import { CreateRenderPayload, createRender, lookupRenderByMd5, uploadRender } from "./resources/renders.js";
6
6
  import { CreateTranscriptionPayload, createTranscription, getTranscriptionInfo, getTranscriptionProgress } from "./resources/transcriptions.js";
7
7
  import { createURLToken } from "./resources/url-token.js";
8
- import { CreateUnprocessedFilePayload, createUnprocessedFile, createUnprocessedFileFromPath, lookupUnprocessedFileByMd5, processIsobmffFile, uploadUnprocessedFile, uploadUnprocessedReadableStream } from "./resources/unprocessed-file.js";
8
+ import { CreateUnprocessedFilePayload, createUnprocessedFile, lookupUnprocessedFileByMd5, processIsobmffFile, uploadUnprocessedReadableStream } from "./resources/unprocessed-file.js";
9
9
  import { getIsobmffProcessInfo, getIsobmffProcessProgress } from "./resources/process-isobmff.js";
10
10
  import { Client } from "./client.js";
11
11
  export {
@@ -26,7 +26,6 @@ export {
26
26
  createTranscription,
27
27
  createURLToken,
28
28
  createUnprocessedFile,
29
- createUnprocessedFileFromPath,
30
29
  getISOBMFFFileTranscription,
31
30
  getIsobmffProcessInfo,
32
31
  getIsobmffProcessProgress,
@@ -44,6 +43,5 @@ export {
44
43
  uploadISOBMFFTrack,
45
44
  uploadImageFile,
46
45
  uploadRender,
47
- uploadUnprocessedFile,
48
46
  uploadUnprocessedReadableStream
49
47
  };
package/dist/node.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Client } from './client.ts';
2
+ import { UnprocessedFileUploadDetails } from './resources/unprocessed-file.ts';
3
+ export declare const createImageFileFromPath: (client: Client, path: string) => Promise<import('./index.ts').CreateImageFileResult>;
4
+ export declare const createUnprocessedFileFromPath: (client: Client, path: string) => Promise<import('./index.ts').CreateUnprocessedFileResult>;
5
+ export declare const uploadUnprocessedFile: (client: Client, uploadDetails: UnprocessedFileUploadDetails, path: string) => Promise<import('./uploadChunks.ts').IteratorWithPromise<import('./uploadChunks.ts').UploadChunkEvent>>;
6
+ export * from './index.ts';
package/dist/node.js ADDED
@@ -0,0 +1,92 @@
1
+ import { stat } from "node:fs/promises";
2
+ import { basename } from "node:path";
3
+ import mime from "mime";
4
+ import { md5FilePath } from "@editframe/assets";
5
+ import { createImageFile, CreateImageFilePayload } from "./resources/image-file.js";
6
+ import { lookupImageFileByMd5, uploadImageFile } from "./resources/image-file.js";
7
+ import { createUnprocessedFile, uploadUnprocessedReadableStream } from "./resources/unprocessed-file.js";
8
+ import { CreateUnprocessedFilePayload, lookupUnprocessedFileByMd5, processIsobmffFile } from "./resources/unprocessed-file.js";
9
+ import { CreateCaptionFilePayload, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile } from "./resources/caption-file.js";
10
+ import { CreateISOBMFFFilePayload, TranscribeISOBMFFFilePayload, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex } from "./resources/isobmff-file.js";
11
+ import { CreateISOBMFFTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
12
+ import { CreateRenderPayload, createRender, lookupRenderByMd5, uploadRender } from "./resources/renders.js";
13
+ import { CreateTranscriptionPayload, createTranscription, getTranscriptionInfo, getTranscriptionProgress } from "./resources/transcriptions.js";
14
+ import { createURLToken } from "./resources/url-token.js";
15
+ import { getIsobmffProcessInfo, getIsobmffProcessProgress } from "./resources/process-isobmff.js";
16
+ import { Client } from "./client.js";
17
+ const createImageFileFromPath = async (client, path) => {
18
+ const fileInfo = await stat(path);
19
+ const byte_size = fileInfo.size;
20
+ const md5 = await md5FilePath(path);
21
+ const mime_type = mime.getType(path);
22
+ return createImageFile(client, {
23
+ ...CreateImageFilePayload.parse({
24
+ md5,
25
+ height: 0,
26
+ width: 0,
27
+ mime_type,
28
+ filename: basename(path),
29
+ byte_size
30
+ })
31
+ });
32
+ };
33
+ const createUnprocessedFileFromPath = async (client, path) => {
34
+ const fileInfo = await stat(path);
35
+ const byte_size = fileInfo.size;
36
+ const md5 = await md5FilePath(path);
37
+ return createUnprocessedFile(client, {
38
+ md5,
39
+ filename: basename(path),
40
+ byte_size
41
+ });
42
+ };
43
+ const uploadUnprocessedFile = async (client, uploadDetails, path) => {
44
+ const { createReadStream } = await import("node:fs");
45
+ const readStream = createReadStream(path);
46
+ const { createReadableStreamFromReadable } = await import("./utils/createReadableStreamFromReadable.js");
47
+ return uploadUnprocessedReadableStream(
48
+ client,
49
+ uploadDetails,
50
+ createReadableStreamFromReadable(readStream)
51
+ );
52
+ };
53
+ export {
54
+ Client,
55
+ CreateCaptionFilePayload,
56
+ CreateISOBMFFFilePayload,
57
+ CreateISOBMFFTrackPayload,
58
+ CreateImageFilePayload,
59
+ CreateRenderPayload,
60
+ CreateTranscriptionPayload,
61
+ CreateUnprocessedFilePayload,
62
+ TranscribeISOBMFFFilePayload,
63
+ createCaptionFile,
64
+ createISOBMFFFile,
65
+ createISOBMFFTrack,
66
+ createImageFile,
67
+ createImageFileFromPath,
68
+ createRender,
69
+ createTranscription,
70
+ createURLToken,
71
+ createUnprocessedFile,
72
+ createUnprocessedFileFromPath,
73
+ getISOBMFFFileTranscription,
74
+ getIsobmffProcessInfo,
75
+ getIsobmffProcessProgress,
76
+ getTranscriptionInfo,
77
+ getTranscriptionProgress,
78
+ lookupCaptionFileByMd5,
79
+ lookupISOBMFFFileByMd5,
80
+ lookupImageFileByMd5,
81
+ lookupRenderByMd5,
82
+ lookupUnprocessedFileByMd5,
83
+ processIsobmffFile,
84
+ transcribeISOBMFFFile,
85
+ uploadCaptionFile,
86
+ uploadFragmentIndex,
87
+ uploadISOBMFFTrack,
88
+ uploadImageFile,
89
+ uploadRender,
90
+ uploadUnprocessedFile,
91
+ uploadUnprocessedReadableStream
92
+ };
@@ -5,12 +5,12 @@ export declare const CreateCaptionFilePayload: z.ZodObject<{
5
5
  filename: z.ZodString;
6
6
  byte_size: z.ZodNumber;
7
7
  }, "strip", z.ZodTypeAny, {
8
- md5: string;
9
8
  filename: string;
9
+ md5: string;
10
10
  byte_size: number;
11
11
  }, {
12
- md5: string;
13
12
  filename: string;
13
+ md5: string;
14
14
  byte_size: number;
15
15
  }>;
16
16
  export interface CreateCaptionFileResult {
@@ -8,19 +8,19 @@ export declare const CreateImageFilePayload: z.ZodObject<{
8
8
  filename: z.ZodString;
9
9
  byte_size: z.ZodNumber;
10
10
  }, "strip", z.ZodTypeAny, {
11
- md5: string;
12
- filename: string;
13
- byte_size: number;
14
11
  width: number;
15
12
  height: number;
16
- mime_type: "image/jpeg" | "image/png" | "image/jpg" | "image/webp";
17
- }, {
18
- md5: string;
19
13
  filename: string;
14
+ md5: string;
15
+ mime_type: "image/jpeg" | "image/png" | "image/jpg" | "image/webp";
20
16
  byte_size: number;
17
+ }, {
21
18
  width: number;
22
19
  height: number;
20
+ filename: string;
21
+ md5: string;
23
22
  mime_type: "image/jpeg" | "image/png" | "image/jpg" | "image/webp";
23
+ byte_size: number;
24
24
  }>;
25
25
  export interface CreateImageFileResult {
26
26
  complete: boolean | null;
@@ -34,7 +34,6 @@ export interface LookupImageFileByMd5Result {
34
34
  id: string;
35
35
  md5: string;
36
36
  }
37
- export declare const createImageFileFromPath: (client: Client, path: string) => Promise<CreateImageFileResult>;
38
37
  export declare const createImageFile: (client: Client, payload: z.infer<typeof CreateImageFilePayload>) => Promise<CreateImageFileResult>;
39
38
  export declare const uploadImageFile: (client: Client, uploadDetails: {
40
39
  id: string;
@@ -1,5 +1,4 @@
1
1
  import debug from "debug";
2
- import "mime";
3
2
  import { z } from "zod";
4
3
  import { uploadChunks } from "../uploadChunks.js";
5
4
  const log = debug("ef:api:image-file");
@@ -4,11 +4,11 @@ export declare const CreateISOBMFFFilePayload: z.ZodObject<{
4
4
  md5: z.ZodString;
5
5
  filename: z.ZodString;
6
6
  }, "strip", z.ZodTypeAny, {
7
- md5: string;
8
7
  filename: string;
9
- }, {
10
8
  md5: string;
9
+ }, {
11
10
  filename: string;
11
+ md5: string;
12
12
  }>;
13
13
  export interface CreateISOBMFFFileResult {
14
14
  fragment_index_complete: boolean;
@@ -75,9 +75,9 @@ export declare const CreateISOBMFFTrackPayload: z.ZodDiscriminatedUnion<"type",
75
75
  codec_name: z.ZodString;
76
76
  byte_size: z.ZodNumber;
77
77
  }, "strip", z.ZodTypeAny, {
78
+ codec_name: string;
78
79
  type: "audio";
79
80
  byte_size: number;
80
- codec_name: string;
81
81
  file_id: string;
82
82
  track_id: number;
83
83
  probe_info: {
@@ -105,9 +105,9 @@ export declare const CreateISOBMFFTrackPayload: z.ZodDiscriminatedUnion<"type",
105
105
  };
106
106
  duration_ms: number;
107
107
  }, {
108
+ codec_name: string;
108
109
  type: "audio";
109
110
  byte_size: number;
110
- codec_name: string;
111
111
  file_id: string;
112
112
  track_id: number;
113
113
  probe_info: {
@@ -203,9 +203,9 @@ export declare const CreateISOBMFFTrackPayload: z.ZodDiscriminatedUnion<"type",
203
203
  codec_name: z.ZodString;
204
204
  byte_size: z.ZodNumber;
205
205
  }, "strip", z.ZodTypeAny, {
206
+ codec_name: string;
206
207
  type: "video";
207
208
  byte_size: number;
208
- codec_name: string;
209
209
  file_id: string;
210
210
  track_id: number;
211
211
  probe_info: {
@@ -231,9 +231,9 @@ export declare const CreateISOBMFFTrackPayload: z.ZodDiscriminatedUnion<"type",
231
231
  };
232
232
  duration_ms: number;
233
233
  }, {
234
+ codec_name: string;
234
235
  type: "video";
235
236
  byte_size: number;
236
- codec_name: string;
237
237
  file_id: string;
238
238
  track_id: number;
239
239
  probe_info: {
@@ -9,17 +9,17 @@ export declare const CreateRenderPayload: z.ZodObject<{
9
9
  duration_ms: z.ZodNumber;
10
10
  strategy: z.ZodEnum<["v1", "v2"]>;
11
11
  }, "strip", z.ZodTypeAny, {
12
- md5: string;
13
12
  width: number;
14
13
  height: number;
14
+ md5: string;
15
15
  strategy: "v1" | "v2";
16
16
  duration_ms: number;
17
17
  fps: number;
18
18
  work_slice_ms: number;
19
19
  }, {
20
- md5: string;
21
20
  width: number;
22
21
  height: number;
22
+ md5: string;
23
23
  strategy: "v1" | "v2";
24
24
  duration_ms: number;
25
25
  fps: number;
@@ -5,12 +5,12 @@ export declare const CreateUnprocessedFilePayload: z.ZodObject<{
5
5
  filename: z.ZodString;
6
6
  byte_size: z.ZodNumber;
7
7
  }, "strip", z.ZodTypeAny, {
8
- md5: string;
9
8
  filename: string;
9
+ md5: string;
10
10
  byte_size: number;
11
11
  }, {
12
- md5: string;
13
12
  filename: string;
13
+ md5: string;
14
14
  byte_size: number;
15
15
  }>;
16
16
  export declare const UpdateUnprocessedFilePayload: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
@@ -21,7 +21,7 @@ interface UnprocessedFile {
21
21
  id: string;
22
22
  md5: string;
23
23
  }
24
- type UnprocessedFileUploadDetails = Pick<UnprocessedFile, "id" | "byte_size">;
24
+ export type UnprocessedFileUploadDetails = Pick<UnprocessedFile, "id" | "byte_size">;
25
25
  export interface CreateUnprocessedFileResult extends UnprocessedFile {
26
26
  }
27
27
  export interface LookupUnprocessedFileByMd5Result extends UnprocessedFile {
@@ -31,9 +31,7 @@ export interface UpdateUnprocessedFileResult extends UnprocessedFile {
31
31
  export interface ProcessIsobmffFileResult {
32
32
  id: string;
33
33
  }
34
- export declare const createUnprocessedFileFromPath: (client: Client, path: string) => Promise<CreateUnprocessedFileResult>;
35
34
  export declare const createUnprocessedFile: (client: Client, payload: z.infer<typeof CreateUnprocessedFilePayload>) => Promise<CreateUnprocessedFileResult>;
36
- export declare const uploadUnprocessedFile: (client: Client, uploadDetails: UnprocessedFileUploadDetails, path: string) => Promise<import('../uploadChunks.ts').IteratorWithPromise<import('../uploadChunks.ts').UploadChunkEvent>>;
37
35
  export declare const uploadUnprocessedReadableStream: (client: Client, uploadDetails: UnprocessedFileUploadDetails, fileStream: ReadableStream) => import('../uploadChunks.ts').IteratorWithPromise<import('../uploadChunks.ts').UploadChunkEvent>;
38
36
  export declare const lookupUnprocessedFileByMd5: (client: Client, md5: string) => Promise<LookupUnprocessedFileByMd5Result | null>;
39
37
  export declare const processIsobmffFile: (client: Client, id: string) => Promise<ProcessIsobmffFileResult>;
@@ -9,27 +9,6 @@ const CreateUnprocessedFilePayload = z.object({
9
9
  byte_size: z.number().int().max(MAX_FILE_SIZE)
10
10
  });
11
11
  z.object({});
12
- const createUnprocessedFileFromPath = async (client, path) => {
13
- const [{ stat }, { basename }, { md5FilePath }] = await Promise.all([
14
- import("node:fs/promises"),
15
- import("node:path"),
16
- import("@editframe/assets")
17
- ]).catch((error) => {
18
- console.error("Error importing modules", error);
19
- console.error(
20
- "This is likely because you are bundling for the browser. createUnprocessedFileFromPath can only be run in environments that support importing `node:path`"
21
- );
22
- throw error;
23
- });
24
- const fileInfo = await stat(path);
25
- const byte_size = fileInfo.size;
26
- const md5 = await md5FilePath(path);
27
- return createUnprocessedFile(client, {
28
- md5,
29
- filename: basename(path),
30
- byte_size
31
- });
32
- };
33
12
  const createUnprocessedFile = async (client, payload) => {
34
13
  log("Creating an unprocessed file", payload);
35
14
  CreateUnprocessedFilePayload.parse(payload);
@@ -53,16 +32,6 @@ const createUnprocessedFile = async (client, payload) => {
53
32
  `Failed to create unprocessed file ${response.status} ${response.statusText}`
54
33
  );
55
34
  };
56
- const uploadUnprocessedFile = async (client, uploadDetails, path) => {
57
- const { createReadStream } = await import("node:fs");
58
- const readStream = createReadStream(path);
59
- const { createReadableStreamFromReadable } = await import("../utils/createReadableStreamFromReadable.js");
60
- return uploadUnprocessedReadableStream(
61
- client,
62
- uploadDetails,
63
- createReadableStreamFromReadable(readStream)
64
- );
65
- };
66
35
  const uploadUnprocessedReadableStream = (client, uploadDetails, fileStream) => {
67
36
  log("Uploading unprocessed file", uploadDetails.id);
68
37
  return uploadChunks(client, {
@@ -106,9 +75,7 @@ const processIsobmffFile = async (client, id) => {
106
75
  export {
107
76
  CreateUnprocessedFilePayload,
108
77
  createUnprocessedFile,
109
- createUnprocessedFileFromPath,
110
78
  lookupUnprocessedFileByMd5,
111
79
  processIsobmffFile,
112
- uploadUnprocessedFile,
113
80
  uploadUnprocessedReadableStream
114
81
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editframe/api",
3
- "version": "0.12.0-beta.12",
3
+ "version": "0.12.0-beta.16",
4
4
  "description": "API functions for EditFrame",
5
5
  "exports": {
6
6
  ".": {
@@ -8,6 +8,12 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "default": "./dist/index.js"
10
10
  }
11
+ },
12
+ "./node": {
13
+ "import": {
14
+ "types": "./dist/node.d.ts",
15
+ "default": "./dist/node.js"
16
+ }
11
17
  }
12
18
  },
13
19
  "type": "module",
@@ -29,7 +35,7 @@
29
35
  "vite-tsconfig-paths": "^4.3.2"
30
36
  },
31
37
  "dependencies": {
32
- "@editframe/assets": "0.12.0-beta.12",
38
+ "@editframe/assets": "0.12.0-beta.16",
33
39
  "debug": "^4.3.5",
34
40
  "jsonwebtoken": "^9.0.2",
35
41
  "node-fetch": "^3.3.2",
@@ -1,5 +1,4 @@
1
1
  import debug from "debug";
2
- import mime from "mime";
3
2
  import { z } from "zod";
4
3
 
5
4
  import type { Client } from "../client.ts";
@@ -32,39 +31,6 @@ export interface LookupImageFileByMd5Result {
32
31
  md5: string;
33
32
  }
34
33
 
35
- export const createImageFileFromPath = async (client: Client, path: string) => {
36
- const [{ stat }, { basename }, { md5FilePath }] = await Promise.all([
37
- import("node:fs/promises"),
38
- import("node:path"),
39
- import("@editframe/assets"),
40
- ]).catch((error) => {
41
- console.error("Error importing modules", error);
42
- console.error(
43
- "This is likely because you are bundling for the browser. createImageFileFromPath can only be run in environments that support importing `node:path`",
44
- );
45
- throw error;
46
- });
47
-
48
- const fileInfo = await stat(path);
49
-
50
- const byte_size = fileInfo.size;
51
-
52
- const md5 = await md5FilePath(path);
53
-
54
- const mime_type = mime.getType(path);
55
-
56
- return createImageFile(client, {
57
- ...CreateImageFilePayload.parse({
58
- md5,
59
- height: 0,
60
- width: 0,
61
- mime_type,
62
- filename: basename(path),
63
- byte_size,
64
- }),
65
- });
66
- };
67
-
68
34
  export const createImageFile = async (
69
35
  client: Client,
70
36
  payload: z.infer<typeof CreateImageFilePayload>,
@@ -24,7 +24,10 @@ interface UnprocessedFile {
24
24
  md5: string;
25
25
  }
26
26
 
27
- type UnprocessedFileUploadDetails = Pick<UnprocessedFile, "id" | "byte_size">;
27
+ export type UnprocessedFileUploadDetails = Pick<
28
+ UnprocessedFile,
29
+ "id" | "byte_size"
30
+ >;
28
31
 
29
32
  export interface CreateUnprocessedFileResult extends UnprocessedFile {}
30
33
 
@@ -36,35 +39,6 @@ export interface ProcessIsobmffFileResult {
36
39
  id: string;
37
40
  }
38
41
 
39
- export const createUnprocessedFileFromPath = async (
40
- client: Client,
41
- path: string,
42
- ) => {
43
- const [{ stat }, { basename }, { md5FilePath }] = await Promise.all([
44
- import("node:fs/promises"),
45
- import("node:path"),
46
- import("@editframe/assets"),
47
- ]).catch((error) => {
48
- console.error("Error importing modules", error);
49
- console.error(
50
- "This is likely because you are bundling for the browser. createUnprocessedFileFromPath can only be run in environments that support importing `node:path`",
51
- );
52
- throw error;
53
- });
54
-
55
- const fileInfo = await stat(path);
56
-
57
- const byte_size = fileInfo.size;
58
-
59
- const md5 = await md5FilePath(path);
60
-
61
- return createUnprocessedFile(client, {
62
- md5,
63
- filename: basename(path),
64
- byte_size,
65
- });
66
- };
67
-
68
42
  export const createUnprocessedFile = async (
69
43
  client: Client,
70
44
  payload: z.infer<typeof CreateUnprocessedFilePayload>,
@@ -95,25 +69,6 @@ export const createUnprocessedFile = async (
95
69
  );
96
70
  };
97
71
 
98
- export const uploadUnprocessedFile = async (
99
- client: Client,
100
- uploadDetails: UnprocessedFileUploadDetails,
101
- path: string,
102
- ) => {
103
- const { createReadStream } = await import("node:fs");
104
- const readStream = createReadStream(path);
105
-
106
- const { createReadableStreamFromReadable } = await import(
107
- "../utils/createReadableStreamFromReadable.ts"
108
- );
109
-
110
- return uploadUnprocessedReadableStream(
111
- client,
112
- uploadDetails,
113
- createReadableStreamFromReadable(readStream),
114
- );
115
- };
116
-
117
72
  export const uploadUnprocessedReadableStream = (
118
73
  client: Client,
119
74
  uploadDetails: UnprocessedFileUploadDetails,