@editframe/api 0.24.1-beta.0 → 0.25.1-beta.0

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.
Files changed (77) hide show
  1. package/dist/CHUNK_SIZE_BYTES.js +4 -0
  2. package/dist/CHUNK_SIZE_BYTES.js.map +1 -0
  3. package/dist/ProgressIterator.d.ts +26 -22
  4. package/dist/ProgressIterator.js +5 -1
  5. package/dist/ProgressIterator.js.map +1 -0
  6. package/dist/StreamEventSource.d.ts +58 -54
  7. package/dist/StreamEventSource.js +6 -1
  8. package/dist/StreamEventSource.js.map +1 -0
  9. package/dist/client.d.ts +13 -8
  10. package/dist/client.js +6 -1
  11. package/dist/client.js.map +1 -0
  12. package/dist/index.d.ts +14 -13
  13. package/dist/index.js +4 -3
  14. package/dist/node.d.ts +22 -7
  15. package/dist/node.js +8 -3
  16. package/dist/node.js.map +1 -0
  17. package/dist/resources/caption-file.d.ts +56 -51
  18. package/dist/resources/caption-file.js +25 -3
  19. package/dist/resources/caption-file.js.map +1 -0
  20. package/dist/resources/image-file.d.ts +109 -104
  21. package/dist/resources/image-file.js +8 -3
  22. package/dist/resources/image-file.js.map +1 -0
  23. package/dist/resources/isobmff-file.d.ts +63 -58
  24. package/dist/resources/isobmff-file.js +7 -2
  25. package/dist/resources/isobmff-file.js.map +1 -0
  26. package/dist/resources/isobmff-track.d.ts +604 -598
  27. package/dist/resources/isobmff-track.js +7 -2
  28. package/dist/resources/isobmff-track.js.map +1 -0
  29. package/dist/resources/process-isobmff.d.ts +16 -11
  30. package/dist/resources/process-isobmff.js +5 -0
  31. package/dist/resources/process-isobmff.js.map +1 -0
  32. package/dist/resources/renders.bundle.d.ts +7 -4
  33. package/dist/resources/renders.bundle.js +6 -1
  34. package/dist/resources/renders.bundle.js.map +1 -0
  35. package/dist/resources/renders.d.ts +229 -367
  36. package/dist/resources/renders.js +13 -8
  37. package/dist/resources/renders.js.map +1 -0
  38. package/dist/resources/transcriptions.d.ts +25 -20
  39. package/dist/resources/transcriptions.js +6 -1
  40. package/dist/resources/transcriptions.js.map +1 -0
  41. package/dist/resources/unprocessed-file.d.ts +36 -35
  42. package/dist/resources/unprocessed-file.js +8 -3
  43. package/dist/resources/unprocessed-file.js.map +1 -0
  44. package/dist/resources/url-token.d.ts +9 -4
  45. package/dist/resources/url-token.js +6 -1
  46. package/dist/resources/url-token.js.map +1 -0
  47. package/dist/streamChunker.js +5 -0
  48. package/dist/streamChunker.js.map +1 -0
  49. package/dist/uploadChunks.d.ts +9 -16
  50. package/dist/uploadChunks.js +7 -2
  51. package/dist/uploadChunks.js.map +1 -0
  52. package/dist/utils/assertTypesMatch.js +4 -0
  53. package/dist/utils/assertTypesMatch.js.map +1 -0
  54. package/dist/utils/createReadableStreamFromReadable.d.ts +8 -3
  55. package/dist/utils/createReadableStreamFromReadable.js +5 -0
  56. package/dist/utils/createReadableStreamFromReadable.js.map +1 -0
  57. package/package.json +53 -34
  58. package/src/resources/renders.bundle.ts +1 -1
  59. package/tsdown.config.ts +10 -0
  60. package/dist/CHUNK_SIZE_BYTES.d.ts +0 -1
  61. package/dist/ProgressIterator.test.d.ts +0 -1
  62. package/dist/StreamEventSource.test.d.ts +0 -1
  63. package/dist/client.test.d.ts +0 -1
  64. package/dist/readableFromBuffers.d.ts +0 -1
  65. package/dist/resources/caption-file.test.d.ts +0 -1
  66. package/dist/resources/image-file.test.d.ts +0 -1
  67. package/dist/resources/isobmff-file.test.d.ts +0 -1
  68. package/dist/resources/isobmff-track.test.d.ts +0 -1
  69. package/dist/resources/process-isobmff.test.d.ts +0 -1
  70. package/dist/resources/renders.test.d.ts +0 -1
  71. package/dist/resources/transcriptions.test.d.ts +0 -1
  72. package/dist/resources/unprocessed-file.test.d.ts +0 -1
  73. package/dist/resources/url-token.test.d.ts +0 -1
  74. package/dist/streamChunker.d.ts +0 -1
  75. package/dist/streamChunker.test.d.ts +0 -1
  76. package/dist/uploadChunks.test.d.ts +0 -1
  77. package/dist/utils/assertTypesMatch.d.ts +0 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"caption-file.js","names":[],"sources":["../../src/resources/caption-file.ts"],"sourcesContent":["import debug from \"debug\";\nimport { z } from \"zod\";\n\nimport type { Client } from \"../client.js\";\n\nconst log = debug(\"ef:api:caption-file\");\n\nconst MAX_CAPTION_SIZE = 1024 * 1024 * 2; // 2MB\n\nexport const CreateCaptionFilePayload = z.object({\n /**\n * The md5 hash of the caption file\n */\n md5: z.string(),\n /**\n * The filename of the caption file\n */\n filename: z.string(),\n /**\n * The size of the caption file in bytes\n */\n byte_size: z.number().int().max(MAX_CAPTION_SIZE),\n});\n\nexport type CreateCaptionFilePayload = z.infer<typeof CreateCaptionFilePayload>;\n\nexport interface CreateCaptionFileResult {\n /**\n * Whether the caption file is complete\n */\n complete: boolean | null;\n /**\n * The id of the caption file\n */\n id: string;\n /**\n * The md5 hash of the caption file\n */\n md5: string;\n}\n\nexport interface LookupCaptionFileByMd5Result {\n /**\n * Whether the caption file is complete\n */\n complete: boolean | null;\n /**\n * The id of the caption file\n */\n id: string;\n /**\n * The md5 hash of the caption file\n */\n md5: string;\n}\n\nconst restrictSize = (size: number) => {\n if (size > MAX_CAPTION_SIZE) {\n throw new Error(\n `File size ${size} bytes exceeds limit ${MAX_CAPTION_SIZE} bytes\\n`,\n );\n }\n};\n\n/**\n * Create a caption file\n * @param client - The authenticated client to use for the request\n * @param payload - The payload to send to the server\n * @returns The result of the request\n * @example\n * ```ts\n * const result = await createCaptionFile(client, {\n * id: \"123\",\n * filename: \"caption.srt\",\n * });\n * console.log(result);\n * ```\n * @category CaptionFile\n * @resource\n * @beta\n */\nexport const createCaptionFile = async (\n client: Client,\n payload: CreateCaptionFilePayload,\n) => {\n log(\"Creating caption file\", payload);\n restrictSize(payload.byte_size);\n const response = await client.authenticatedFetch(\"/api/v1/caption_files\", {\n method: \"POST\",\n body: JSON.stringify(payload),\n });\n log(\"Caption file created\", response);\n\n if (response.ok) {\n return (await response.json()) as CreateCaptionFileResult;\n }\n\n throw new Error(\n `Failed to create caption ${response.status} ${response.statusText}`,\n );\n};\n\nexport const uploadCaptionFile = async (\n client: Client,\n fileId: string,\n fileStream: ReadableStream,\n fileSize: number,\n) => {\n log(\"Uploading caption file\", fileId);\n restrictSize(fileSize);\n\n const response = await client.authenticatedFetch(\n `/api/v1/caption_files/${fileId}/upload`,\n {\n method: \"POST\",\n body: fileStream,\n duplex: \"half\",\n },\n );\n log(\"Caption file uploaded\", response);\n\n if (response.ok) {\n return response.json();\n }\n\n throw new Error(\n `Failed to upload caption ${response.status} ${response.statusText}`,\n );\n};\n\nexport const lookupCaptionFileByMd5 = async (\n client: Client,\n md5: string,\n): Promise<LookupCaptionFileByMd5Result | null> => {\n const response = await client.authenticatedFetch(\n `/api/v1/caption_files/md5/${md5}`,\n {\n method: \"GET\",\n },\n );\n log(\"Caption file lookup\", response);\n\n if (response.ok) {\n return (await response.json()) as LookupCaptionFileByMd5Result;\n }\n\n if (response.status === 404) {\n return null;\n }\n\n throw new Error(\n `Failed to lookup caption by md5 ${md5} ${response.status} ${response.statusText}`,\n );\n};\n"],"mappings":";;;;AAKA,MAAM,MAAM,MAAM,sBAAsB;AAExC,MAAM,mBAAmB,OAAO,OAAO;AAEvC,MAAa,2BAA2B,EAAE,OAAO;CAI/C,KAAK,EAAE,QAAQ;CAIf,UAAU,EAAE,QAAQ;CAIpB,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,iBAAiB;CAClD,CAAC;AAkCF,MAAM,gBAAgB,SAAiB;AACrC,KAAI,OAAO,iBACT,OAAM,IAAI,MACR,aAAa,KAAK,uBAAuB,iBAAiB,UAC3D;;;;;;;;;;;;;;;;;;;AAqBL,MAAa,oBAAoB,OAC/B,QACA,YACG;AACH,KAAI,yBAAyB,QAAQ;AACrC,cAAa,QAAQ,UAAU;CAC/B,MAAM,WAAW,MAAM,OAAO,mBAAmB,yBAAyB;EACxE,QAAQ;EACR,MAAM,KAAK,UAAU,QAAQ;EAC9B,CAAC;AACF,KAAI,wBAAwB,SAAS;AAErC,KAAI,SAAS,GACX,QAAQ,MAAM,SAAS,MAAM;AAG/B,OAAM,IAAI,MACR,4BAA4B,SAAS,OAAO,GAAG,SAAS,aACzD;;AAGH,MAAa,oBAAoB,OAC/B,QACA,QACA,YACA,aACG;AACH,KAAI,0BAA0B,OAAO;AACrC,cAAa,SAAS;CAEtB,MAAM,WAAW,MAAM,OAAO,mBAC5B,yBAAyB,OAAO,UAChC;EACE,QAAQ;EACR,MAAM;EACN,QAAQ;EACT,CACF;AACD,KAAI,yBAAyB,SAAS;AAEtC,KAAI,SAAS,GACX,QAAO,SAAS,MAAM;AAGxB,OAAM,IAAI,MACR,4BAA4B,SAAS,OAAO,GAAG,SAAS,aACzD;;AAGH,MAAa,yBAAyB,OACpC,QACA,QACiD;CACjD,MAAM,WAAW,MAAM,OAAO,mBAC5B,6BAA6B,OAC7B,EACE,QAAQ,OACT,CACF;AACD,KAAI,uBAAuB,SAAS;AAEpC,KAAI,SAAS,GACX,QAAQ,MAAM,SAAS,MAAM;AAG/B,KAAI,SAAS,WAAW,IACtB,QAAO;AAGT,OAAM,IAAI,MACR,mCAAmC,IAAI,GAAG,SAAS,OAAO,GAAG,SAAS,aACvE"}
@@ -1,111 +1,116 @@
1
- import { z } from 'zod';
2
- import { Client } from '../client.js';
3
- export declare const ImageFileMimeTypes: z.ZodEnum<["image/jpeg", "image/png", "image/jpg", "image/webp", "image/svg+xml"]>;
4
- export declare const CreateImageFilePayload: z.ZodEffects<z.ZodObject<{
5
- /**
6
- * The md5 hash of the image file.
7
- */
8
- md5: z.ZodOptional<z.ZodString>;
9
- /**
10
- * The height of the image file in pixels.
11
- */
12
- height: z.ZodOptional<z.ZodNumber>;
13
- /**
14
- * The width of the image file in pixels.
15
- */
16
- width: z.ZodOptional<z.ZodNumber>;
17
- /**
18
- * The mime type of the image file. Optional if the filename has a known file extension.
19
- */
20
- mime_type: z.ZodOptional<z.ZodEnum<["image/jpeg", "image/png", "image/jpg", "image/webp", "image/svg+xml"]>>;
21
- /**
22
- * The filename of the image file.
23
- */
24
- filename: z.ZodString;
25
- /**
26
- * The byte size of the image file.
27
- */
28
- byte_size: z.ZodNumber;
1
+ import { Client } from "../client.js";
2
+ import { IteratorWithPromise, UploadChunkEvent } from "../uploadChunks.js";
3
+ import { z } from "zod";
4
+
5
+ //#region src/resources/image-file.d.ts
6
+ declare const ImageFileMimeTypes: z.ZodEnum<["image/jpeg", "image/png", "image/jpg", "image/webp", "image/svg+xml"]>;
7
+ declare const CreateImageFilePayload: z.ZodEffects<z.ZodObject<{
8
+ /**
9
+ * The md5 hash of the image file.
10
+ */
11
+ md5: z.ZodOptional<z.ZodString>;
12
+ /**
13
+ * The height of the image file in pixels.
14
+ */
15
+ height: z.ZodOptional<z.ZodNumber>;
16
+ /**
17
+ * The width of the image file in pixels.
18
+ */
19
+ width: z.ZodOptional<z.ZodNumber>;
20
+ /**
21
+ * The mime type of the image file. Optional if the filename has a known file extension.
22
+ */
23
+ mime_type: z.ZodOptional<z.ZodEnum<["image/jpeg", "image/png", "image/jpg", "image/webp", "image/svg+xml"]>>;
24
+ /**
25
+ * The filename of the image file.
26
+ */
27
+ filename: z.ZodString;
28
+ /**
29
+ * The byte size of the image file.
30
+ */
31
+ byte_size: z.ZodNumber;
29
32
  }, "strip", z.ZodTypeAny, {
30
- filename: string;
31
- byte_size: number;
32
- width?: number | undefined;
33
- height?: number | undefined;
34
- md5?: string | undefined;
35
- mime_type?: "image/jpeg" | "image/png" | "image/jpg" | "image/webp" | "image/svg+xml" | undefined;
33
+ filename: string;
34
+ byte_size: number;
35
+ md5?: string | undefined;
36
+ height?: number | undefined;
37
+ width?: number | undefined;
38
+ mime_type?: "image/jpeg" | "image/png" | "image/jpg" | "image/webp" | "image/svg+xml" | undefined;
36
39
  }, {
37
- filename: string;
38
- byte_size: number;
39
- width?: number | undefined;
40
- height?: number | undefined;
41
- md5?: string | undefined;
42
- mime_type?: "image/jpeg" | "image/png" | "image/jpg" | "image/webp" | "image/svg+xml" | undefined;
40
+ filename: string;
41
+ byte_size: number;
42
+ md5?: string | undefined;
43
+ height?: number | undefined;
44
+ width?: number | undefined;
45
+ mime_type?: "image/jpeg" | "image/png" | "image/jpg" | "image/webp" | "image/svg+xml" | undefined;
43
46
  }>, {
44
- filename: string;
45
- byte_size: number;
46
- width?: number | undefined;
47
- height?: number | undefined;
48
- md5?: string | undefined;
49
- mime_type?: "image/jpeg" | "image/png" | "image/jpg" | "image/webp" | "image/svg+xml" | undefined;
47
+ filename: string;
48
+ byte_size: number;
49
+ md5?: string | undefined;
50
+ height?: number | undefined;
51
+ width?: number | undefined;
52
+ mime_type?: "image/jpeg" | "image/png" | "image/jpg" | "image/webp" | "image/svg+xml" | undefined;
50
53
  }, {
51
- filename: string;
52
- byte_size: number;
53
- width?: number | undefined;
54
- height?: number | undefined;
55
- md5?: string | undefined;
56
- mime_type?: "image/jpeg" | "image/png" | "image/jpg" | "image/webp" | "image/svg+xml" | undefined;
54
+ filename: string;
55
+ byte_size: number;
56
+ md5?: string | undefined;
57
+ height?: number | undefined;
58
+ width?: number | undefined;
59
+ mime_type?: "image/jpeg" | "image/png" | "image/jpg" | "image/webp" | "image/svg+xml" | undefined;
57
60
  }>;
58
- export type CreateImageFilePayload = z.infer<typeof CreateImageFilePayload>;
59
- export interface CreateImageFileResult {
60
- /**
61
- * Whether the image file has been fully uploaded.
62
- */
63
- complete: boolean | null;
64
- /**
65
- * The byte size of the image file.
66
- */
67
- byte_size: number;
68
- /**
69
- * The id of the image file.
70
- */
71
- id: string;
72
- /**
73
- * The md5 hash of the image file.
74
- */
75
- md5: string | null;
61
+ type CreateImageFilePayload = z.infer<typeof CreateImageFilePayload>;
62
+ interface CreateImageFileResult {
63
+ /**
64
+ * Whether the image file has been fully uploaded.
65
+ */
66
+ complete: boolean | null;
67
+ /**
68
+ * The byte size of the image file.
69
+ */
70
+ byte_size: number;
71
+ /**
72
+ * The id of the image file.
73
+ */
74
+ id: string;
75
+ /**
76
+ * The md5 hash of the image file.
77
+ */
78
+ md5: string | null;
76
79
  }
77
- export interface LookupImageFileByMd5Result {
78
- /**
79
- * Whether the image file has been fully uploaded.
80
- */
81
- complete: boolean | null;
82
- /**
83
- * The byte size of the image file.
84
- */
85
- byte_size: number;
86
- /**
87
- * The id of the image file.
88
- */
89
- id: string;
90
- /**
91
- * md5 hash of the image file.
92
- */
93
- md5: string | null;
94
- /**
95
- * The height of the image file in pixels.
96
- */
97
- height: number | null;
98
- /**
99
- * The width of the image file in pixels.
100
- */
101
- width: number | null;
80
+ interface LookupImageFileByMd5Result {
81
+ /**
82
+ * Whether the image file has been fully uploaded.
83
+ */
84
+ complete: boolean | null;
85
+ /**
86
+ * The byte size of the image file.
87
+ */
88
+ byte_size: number;
89
+ /**
90
+ * The id of the image file.
91
+ */
92
+ id: string;
93
+ /**
94
+ * md5 hash of the image file.
95
+ */
96
+ md5: string | null;
97
+ /**
98
+ * The height of the image file in pixels.
99
+ */
100
+ height: number | null;
101
+ /**
102
+ * The width of the image file in pixels.
103
+ */
104
+ width: number | null;
102
105
  }
103
- export interface GetImageFileMetadataResult extends LookupImageFileByMd5Result {
104
- }
105
- export declare const createImageFile: (client: Client, payload: CreateImageFilePayload) => Promise<CreateImageFileResult>;
106
- export declare const uploadImageFile: (client: Client, uploadDetails: {
107
- id: string;
108
- byte_size: number;
109
- }, fileStream: ReadableStream, chunkSizeBytes?: number) => import('../uploadChunks.js').IteratorWithPromise<import('../uploadChunks.js').UploadChunkEvent>;
110
- export declare const getImageFileMetadata: (client: Client, id: string) => Promise<GetImageFileMetadataResult | null>;
111
- export declare const lookupImageFileByMd5: (client: Client, md5: string) => Promise<LookupImageFileByMd5Result | null>;
106
+ interface GetImageFileMetadataResult extends LookupImageFileByMd5Result {}
107
+ declare const createImageFile: (client: Client, payload: CreateImageFilePayload) => Promise<CreateImageFileResult>;
108
+ declare const uploadImageFile: (client: Client, uploadDetails: {
109
+ id: string;
110
+ byte_size: number;
111
+ }, fileStream: ReadableStream, chunkSizeBytes?: number) => IteratorWithPromise<UploadChunkEvent>;
112
+ declare const getImageFileMetadata: (client: Client, id: string) => Promise<GetImageFileMetadataResult | null>;
113
+ declare const lookupImageFileByMd5: (client: Client, md5: string) => Promise<LookupImageFileByMd5Result | null>;
114
+ //#endregion
115
+ export { CreateImageFilePayload, CreateImageFileResult, GetImageFileMetadataResult, ImageFileMimeTypes, LookupImageFileByMd5Result, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile };
116
+ //# sourceMappingURL=image-file.d.ts.map
@@ -1,9 +1,11 @@
1
1
  import { uploadChunks } from "../uploadChunks.js";
2
2
  import debug from "debug";
3
- import { types } from "mime-types";
4
3
  import { z } from "zod";
5
- var log = debug("ef:api:image-file");
6
- var MAX_IMAGE_SIZE = 1024 * 1024 * 16;
4
+ import { types } from "mime-types";
5
+
6
+ //#region src/resources/image-file.ts
7
+ const log = debug("ef:api:image-file");
8
+ const MAX_IMAGE_SIZE = 1024 * 1024 * 16;
7
9
  const ImageFileMimeTypes = z.enum([
8
10
  "image/jpeg",
9
11
  "image/png",
@@ -66,4 +68,7 @@ const lookupImageFileByMd5 = async (client, md5) => {
66
68
  if (response.status === 404) return null;
67
69
  throw new Error(`Failed to lookup image by md5 ${md5} ${response.status} ${response.statusText}`);
68
70
  };
71
+
72
+ //#endregion
69
73
  export { CreateImageFilePayload, ImageFileMimeTypes, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile };
74
+ //# sourceMappingURL=image-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-file.js","names":[],"sources":["../../src/resources/image-file.ts"],"sourcesContent":["import debug from \"debug\";\nimport { types } from \"mime-types\";\nimport { z } from \"zod\";\n\nimport type { Client } from \"../client.js\";\nimport { uploadChunks } from \"../uploadChunks.js\";\n\nconst log = debug(\"ef:api:image-file\");\n\nconst MAX_IMAGE_SIZE = 1024 * 1024 * 16; // 16MB\n\nexport const ImageFileMimeTypes = z.enum([\n \"image/jpeg\",\n \"image/png\",\n \"image/jpg\",\n \"image/webp\",\n \"image/svg+xml\",\n]);\n\nfunction getFileExtension(path: string) {\n const match = path.match(/\\.([^.]+)$/);\n return match ? match[1] : null;\n}\n\nexport const CreateImageFilePayload = z\n .object({\n /**\n * The md5 hash of the image file.\n */\n md5: z.string().optional(),\n /**\n * The height of the image file in pixels.\n */\n height: z.number().int().optional(),\n /**\n * The width of the image file in pixels.\n */\n width: z.number().int().optional(),\n /**\n * The mime type of the image file. Optional if the filename has a known file extension.\n */\n mime_type: ImageFileMimeTypes.optional(),\n /**\n * The filename of the image file.\n */\n filename: z.string(),\n /**\n * The byte size of the image file.\n */\n byte_size: z.number().int().max(MAX_IMAGE_SIZE),\n })\n .superRefine((data, ctx) => {\n const extension = getFileExtension(data.filename);\n const mimeType = extension ? types[extension] : null;\n const parsedMimeType = ImageFileMimeTypes.safeParse(mimeType).data;\n\n if (parsedMimeType) {\n data.mime_type = parsedMimeType;\n }\n\n if (!parsedMimeType && !data.mime_type) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message:\n \"mime_type is required when filename extension doesn't match a known image type\",\n path: [\"mime_type\"],\n });\n }\n });\n\nexport type CreateImageFilePayload = z.infer<typeof CreateImageFilePayload>;\n\nexport interface CreateImageFileResult {\n /**\n * Whether the image file has been fully uploaded.\n */\n complete: boolean | null;\n /**\n * The byte size of the image file.\n */\n byte_size: number;\n /**\n * The id of the image file.\n */\n id: string;\n /**\n * The md5 hash of the image file.\n */\n md5: string | null;\n}\n\nexport interface LookupImageFileByMd5Result {\n /**\n * Whether the image file has been fully uploaded.\n */\n complete: boolean | null;\n /**\n * The byte size of the image file.\n */\n byte_size: number;\n /**\n * The id of the image file.\n */\n id: string;\n /**\n * md5 hash of the image file.\n */\n md5: string | null;\n /**\n * The height of the image file in pixels.\n */\n height: number | null;\n /**\n * The width of the image file in pixels.\n */\n width: number | null;\n}\n\nexport interface GetImageFileMetadataResult\n extends LookupImageFileByMd5Result {}\n\nexport const createImageFile = async (\n client: Client,\n payload: CreateImageFilePayload,\n) => {\n log(\"Creating image file\", payload);\n CreateImageFilePayload.parse(payload);\n const response = await client.authenticatedFetch(\"/api/v1/image_files\", {\n method: \"POST\",\n body: JSON.stringify(payload),\n });\n\n log(\"Image file created\", response);\n\n if (response.ok) {\n return (await response.json()) as CreateImageFileResult;\n }\n\n throw new Error(\n `Failed to create file ${response.status} ${response.statusText}`,\n );\n};\n\nexport const uploadImageFile = (\n client: Client,\n uploadDetails: {\n id: string;\n byte_size: number;\n },\n fileStream: ReadableStream,\n chunkSizeBytes?: number,\n) => {\n log(\"Uploading image file\", uploadDetails.id);\n\n return uploadChunks(client, {\n url: `/api/v1/image_files/${uploadDetails.id}/upload`,\n fileSize: uploadDetails.byte_size,\n fileStream,\n maxSize: MAX_IMAGE_SIZE,\n chunkSizeBytes,\n });\n};\n\nexport const getImageFileMetadata = async (\n client: Client,\n id: string,\n): Promise<GetImageFileMetadataResult | null> => {\n const response = await client.authenticatedFetch(\n `/api/v1/image_files/${id}.json`,\n {\n method: \"GET\",\n },\n );\n\n if (response.ok) {\n return (await response.json()) as LookupImageFileByMd5Result;\n }\n\n return null;\n};\n\nexport const lookupImageFileByMd5 = async (\n client: Client,\n md5: string,\n): Promise<LookupImageFileByMd5Result | null> => {\n const response = await client.authenticatedFetch(\n `/api/v1/image_files/md5/${md5}`,\n {\n method: \"GET\",\n },\n );\n log(\"Image file lookup\", response);\n\n if (response.ok) {\n return (await response.json()) as LookupImageFileByMd5Result;\n }\n\n if (response.status === 404) {\n return null;\n }\n\n throw new Error(\n `Failed to lookup image by md5 ${md5} ${response.status} ${response.statusText}`,\n );\n};\n"],"mappings":";;;;;;AAOA,MAAM,MAAM,MAAM,oBAAoB;AAEtC,MAAM,iBAAiB,OAAO,OAAO;AAErC,MAAa,qBAAqB,EAAE,KAAK;CACvC;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAS,iBAAiB,MAAc;CACtC,MAAM,QAAQ,KAAK,MAAM,aAAa;AACtC,QAAO,QAAQ,MAAM,KAAK;;AAG5B,MAAa,yBAAyB,EACnC,OAAO;CAIN,KAAK,EAAE,QAAQ,CAAC,UAAU;CAI1B,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;CAInC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;CAIlC,WAAW,mBAAmB,UAAU;CAIxC,UAAU,EAAE,QAAQ;CAIpB,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,eAAe;CAChD,CAAC,CACD,aAAa,MAAM,QAAQ;CAC1B,MAAM,YAAY,iBAAiB,KAAK,SAAS;CACjD,MAAM,WAAW,YAAY,MAAM,aAAa;CAChD,MAAM,iBAAiB,mBAAmB,UAAU,SAAS,CAAC;AAE9D,KAAI,eACF,MAAK,YAAY;AAGnB,KAAI,CAAC,kBAAkB,CAAC,KAAK,UAC3B,KAAI,SAAS;EACX,MAAM,EAAE,aAAa;EACrB,SACE;EACF,MAAM,CAAC,YAAY;EACpB,CAAC;EAEJ;AAqDJ,MAAa,kBAAkB,OAC7B,QACA,YACG;AACH,KAAI,uBAAuB,QAAQ;AACnC,wBAAuB,MAAM,QAAQ;CACrC,MAAM,WAAW,MAAM,OAAO,mBAAmB,uBAAuB;EACtE,QAAQ;EACR,MAAM,KAAK,UAAU,QAAQ;EAC9B,CAAC;AAEF,KAAI,sBAAsB,SAAS;AAEnC,KAAI,SAAS,GACX,QAAQ,MAAM,SAAS,MAAM;AAG/B,OAAM,IAAI,MACR,yBAAyB,SAAS,OAAO,GAAG,SAAS,aACtD;;AAGH,MAAa,mBACX,QACA,eAIA,YACA,mBACG;AACH,KAAI,wBAAwB,cAAc,GAAG;AAE7C,QAAO,aAAa,QAAQ;EAC1B,KAAK,uBAAuB,cAAc,GAAG;EAC7C,UAAU,cAAc;EACxB;EACA,SAAS;EACT;EACD,CAAC;;AAGJ,MAAa,uBAAuB,OAClC,QACA,OAC+C;CAC/C,MAAM,WAAW,MAAM,OAAO,mBAC5B,uBAAuB,GAAG,QAC1B,EACE,QAAQ,OACT,CACF;AAED,KAAI,SAAS,GACX,QAAQ,MAAM,SAAS,MAAM;AAG/B,QAAO;;AAGT,MAAa,uBAAuB,OAClC,QACA,QAC+C;CAC/C,MAAM,WAAW,MAAM,OAAO,mBAC5B,2BAA2B,OAC3B,EACE,QAAQ,OACT,CACF;AACD,KAAI,qBAAqB,SAAS;AAElC,KAAI,SAAS,GACX,QAAQ,MAAM,SAAS,MAAM;AAG/B,KAAI,SAAS,WAAW,IACtB,QAAO;AAGT,OAAM,IAAI,MACR,iCAAiC,IAAI,GAAG,SAAS,OAAO,GAAG,SAAS,aACrE"}
@@ -1,68 +1,73 @@
1
- import { z } from 'zod';
2
- import { Client } from '../client.js';
3
- export declare const CreateISOBMFFFilePayload: z.ZodObject<{
4
- md5: z.ZodString;
5
- filename: z.ZodString;
1
+ import { Client } from "../client.js";
2
+ import { z } from "zod";
3
+
4
+ //#region src/resources/isobmff-file.d.ts
5
+ declare const CreateISOBMFFFilePayload: z.ZodObject<{
6
+ md5: z.ZodString;
7
+ filename: z.ZodString;
6
8
  }, "strip", z.ZodTypeAny, {
7
- filename: string;
8
- md5: string;
9
+ md5: string;
10
+ filename: string;
9
11
  }, {
10
- filename: string;
11
- md5: string;
12
+ md5: string;
13
+ filename: string;
12
14
  }>;
13
- export type CreateISOBMFFFilePayload = z.infer<typeof CreateISOBMFFFilePayload>;
14
- export interface CreateISOBMFFFileResult {
15
- /**
16
- * Whether the fragment index is complete. The fragment index is used internally by editframe to efficiently seek within files.
17
- */
18
- fragment_index_complete: boolean;
19
- /**
20
- * The filename of the isobmff file
21
- */
22
- filename: string;
23
- /**
24
- * The id of the isobmff file
25
- */
26
- id: string;
27
- /**
28
- * The md5 hash of the isobmff file
29
- */
30
- md5: string;
15
+ type CreateISOBMFFFilePayload = z.infer<typeof CreateISOBMFFFilePayload>;
16
+ interface CreateISOBMFFFileResult {
17
+ /**
18
+ * Whether the fragment index is complete. The fragment index is used internally by editframe to efficiently seek within files.
19
+ */
20
+ fragment_index_complete: boolean;
21
+ /**
22
+ * The filename of the isobmff file
23
+ */
24
+ filename: string;
25
+ /**
26
+ * The id of the isobmff file
27
+ */
28
+ id: string;
29
+ /**
30
+ * The md5 hash of the isobmff file
31
+ */
32
+ md5: string;
31
33
  }
32
- export interface LookupISOBMFFFileByMd5Result {
33
- /**
34
- * Whether the fragment index is complete
35
- */
36
- fragment_index_complete: boolean;
37
- /**
38
- * The filename of the isobmff file
39
- */
40
- filename: string;
41
- id: string;
42
- md5: string;
34
+ interface LookupISOBMFFFileByMd5Result {
35
+ /**
36
+ * Whether the fragment index is complete
37
+ */
38
+ fragment_index_complete: boolean;
39
+ /**
40
+ * The filename of the isobmff file
41
+ */
42
+ filename: string;
43
+ id: string;
44
+ md5: string;
43
45
  }
44
- export interface GetISOBMFFFileTranscriptionResult {
45
- id: string;
46
- work_slice_ms: number;
47
- isobmff_track: {
48
- duration_ms: number;
49
- };
46
+ interface GetISOBMFFFileTranscriptionResult {
47
+ id: string;
48
+ work_slice_ms: number;
49
+ isobmff_track: {
50
+ duration_ms: number;
51
+ };
50
52
  }
51
- export declare const createISOBMFFFile: (client: Client, payload: CreateISOBMFFFilePayload) => Promise<CreateISOBMFFFileResult>;
52
- export declare const uploadFragmentIndex: (client: Client, fileId: string, fileStream: ReadableStream, fileSize: number) => Promise<any>;
53
- export declare const lookupISOBMFFFileByMd5: (client: Client, md5: string) => Promise<LookupISOBMFFFileByMd5Result | null>;
54
- export declare const getISOBMFFFileTranscription: (client: Client, id: string) => Promise<GetISOBMFFFileTranscriptionResult | null>;
55
- export declare const TranscribeISOBMFFFilePayload: z.ZodObject<{
56
- trackId: z.ZodOptional<z.ZodString>;
53
+ declare const createISOBMFFFile: (client: Client, payload: CreateISOBMFFFilePayload) => Promise<CreateISOBMFFFileResult>;
54
+ declare const uploadFragmentIndex: (client: Client, fileId: string, fileStream: ReadableStream, fileSize: number) => Promise<any>;
55
+ declare const lookupISOBMFFFileByMd5: (client: Client, md5: string) => Promise<LookupISOBMFFFileByMd5Result | null>;
56
+ declare const getISOBMFFFileTranscription: (client: Client, id: string) => Promise<GetISOBMFFFileTranscriptionResult | null>;
57
+ declare const TranscribeISOBMFFFilePayload: z.ZodObject<{
58
+ trackId: z.ZodOptional<z.ZodString>;
57
59
  }, "strip", z.ZodTypeAny, {
58
- trackId?: string | undefined;
60
+ trackId?: string | undefined;
59
61
  }, {
60
- trackId?: string | undefined;
62
+ trackId?: string | undefined;
61
63
  }>;
62
- export type TranscribeISOBMFFFilePayload = z.infer<typeof TranscribeISOBMFFFilePayload>;
63
- export interface TranscribeISOBMFFFileResult {
64
- id: string;
65
- file_id: string;
66
- track_id: number;
64
+ type TranscribeISOBMFFFilePayload = z.infer<typeof TranscribeISOBMFFFilePayload>;
65
+ interface TranscribeISOBMFFFileResult {
66
+ id: string;
67
+ file_id: string;
68
+ track_id: number;
67
69
  }
68
- export declare const transcribeISOBMFFFile: (client: Client, id: string, payload?: TranscribeISOBMFFFilePayload) => Promise<TranscribeISOBMFFFileResult>;
70
+ declare const transcribeISOBMFFFile: (client: Client, id: string, payload?: TranscribeISOBMFFFilePayload) => Promise<TranscribeISOBMFFFileResult>;
71
+ //#endregion
72
+ export { CreateISOBMFFFilePayload, CreateISOBMFFFileResult, GetISOBMFFFileTranscriptionResult, LookupISOBMFFFileByMd5Result, TranscribeISOBMFFFilePayload, TranscribeISOBMFFFileResult, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex };
73
+ //# sourceMappingURL=isobmff-file.d.ts.map
@@ -1,7 +1,9 @@
1
1
  import debug from "debug";
2
2
  import { z } from "zod";
3
- var log = debug("ef:api:isobmff-file");
4
- var FILE_SIZE_LIMIT = 1024 * 1024 * 2;
3
+
4
+ //#region src/resources/isobmff-file.ts
5
+ const log = debug("ef:api:isobmff-file");
6
+ const FILE_SIZE_LIMIT = 1024 * 1024 * 2;
5
7
  const CreateISOBMFFFilePayload = z.object({
6
8
  md5: z.string(),
7
9
  filename: z.string()
@@ -50,4 +52,7 @@ const transcribeISOBMFFFile = async (client, id, payload = {}) => {
50
52
  if (response.ok) return await response.json();
51
53
  throw new Error(`Failed to transcribe isobmff file ${id} ${response.status} ${response.statusText}`);
52
54
  };
55
+
56
+ //#endregion
53
57
  export { CreateISOBMFFFilePayload, TranscribeISOBMFFFilePayload, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex };
58
+ //# sourceMappingURL=isobmff-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isobmff-file.js","names":[],"sources":["../../src/resources/isobmff-file.ts"],"sourcesContent":["import debug from \"debug\";\nimport { z } from \"zod\";\n\nimport type { Client } from \"../client.js\";\n\nconst log = debug(\"ef:api:isobmff-file\");\nconst FILE_SIZE_LIMIT = 1024 * 1024 * 2; // 32MB\n\nexport const CreateISOBMFFFilePayload = z.object({\n md5: z.string(),\n filename: z.string(),\n});\n\nexport type CreateISOBMFFFilePayload = z.infer<typeof CreateISOBMFFFilePayload>;\n\nexport interface CreateISOBMFFFileResult {\n /**\n * Whether the fragment index is complete. The fragment index is used internally by editframe to efficiently seek within files.\n */\n fragment_index_complete: boolean;\n /**\n * The filename of the isobmff file\n */\n filename: string;\n /**\n * The id of the isobmff file\n */\n id: string;\n /**\n * The md5 hash of the isobmff file\n */\n md5: string;\n}\n\nexport interface LookupISOBMFFFileByMd5Result {\n /**\n * Whether the fragment index is complete\n */\n fragment_index_complete: boolean;\n /**\n * The filename of the isobmff file\n */\n filename: string;\n id: string;\n md5: string;\n}\n\nexport interface GetISOBMFFFileTranscriptionResult {\n id: string;\n work_slice_ms: number;\n isobmff_track: {\n duration_ms: number;\n };\n}\n\nexport const createISOBMFFFile = async (\n client: Client,\n payload: CreateISOBMFFFilePayload,\n) => {\n log(\"Creating isobmff file\", payload);\n const response = await client.authenticatedFetch(\"/api/v1/isobmff_files\", {\n method: \"POST\",\n body: JSON.stringify(payload),\n });\n\n log(\"ISOBMFF file created\", response);\n\n if (response.ok) {\n return (await response.json()) as CreateISOBMFFFileResult;\n }\n\n throw new Error(\n `Failed to create isobmff file ${response.status} ${response.statusText}`,\n );\n};\n\nexport const uploadFragmentIndex = async (\n client: Client,\n fileId: string,\n fileStream: ReadableStream,\n fileSize: number,\n) => {\n log(\"Uploading fragment index\", fileId);\n if (fileSize > FILE_SIZE_LIMIT) {\n throw new Error(`File size exceeds limit of ${FILE_SIZE_LIMIT} bytes`);\n }\n const response = await client.authenticatedFetch(\n `/api/v1/isobmff_files/${fileId}/index/upload`,\n {\n method: \"POST\",\n body: fileStream,\n duplex: \"half\",\n },\n );\n\n log(\"Fragment index uploaded\", response);\n if (response.ok) {\n return response.json();\n }\n\n throw new Error(\n `Failed to create fragment index ${response.status} ${response.statusText}`,\n );\n};\n\nexport const lookupISOBMFFFileByMd5 = async (\n client: Client,\n md5: string,\n): Promise<LookupISOBMFFFileByMd5Result | null> => {\n const response = await client.authenticatedFetch(\n `/api/v1/isobmff_files/md5/${md5}`,\n {\n method: \"GET\",\n },\n );\n log(\"ISOBMFF file lookup\", response);\n\n if (response.ok) {\n return (await response.json()) as LookupISOBMFFFileByMd5Result;\n }\n\n if (response.status === 404) {\n return null;\n }\n\n throw new Error(\n `Failed to lookup isobmff file by md5 ${md5} ${response.status} ${response.statusText}`,\n );\n};\n\nexport const getISOBMFFFileTranscription = async (\n client: Client,\n id: string,\n): Promise<GetISOBMFFFileTranscriptionResult | null> => {\n const response = await client.authenticatedFetch(\n `/api/v1/isobmff_files/${id}/transcription`,\n );\n\n if (response.ok) {\n return (await response.json()) as GetISOBMFFFileTranscriptionResult;\n }\n\n if (response.status === 404) {\n return null;\n }\n\n throw new Error(\n `Failed to get isobmff file transcription ${id} ${response.status} ${response.statusText}`,\n );\n};\n\nexport const TranscribeISOBMFFFilePayload = z.object({\n trackId: z.string().optional(),\n});\n\nexport type TranscribeISOBMFFFilePayload = z.infer<\n typeof TranscribeISOBMFFFilePayload\n>;\n\nexport interface TranscribeISOBMFFFileResult {\n id: string;\n file_id: string;\n track_id: number;\n}\n\nexport const transcribeISOBMFFFile = async (\n client: Client,\n id: string,\n payload: TranscribeISOBMFFFilePayload = {},\n) => {\n const response = await client.authenticatedFetch(\n `/api/v1/isobmff_files/${id}/transcribe`,\n {\n method: \"POST\",\n body: JSON.stringify(payload),\n },\n );\n\n if (response.ok) {\n return (await response.json()) as TranscribeISOBMFFFileResult;\n }\n\n throw new Error(\n `Failed to transcribe isobmff file ${id} ${response.status} ${response.statusText}`,\n );\n};\n"],"mappings":";;;;AAKA,MAAM,MAAM,MAAM,sBAAsB;AACxC,MAAM,kBAAkB,OAAO,OAAO;AAEtC,MAAa,2BAA2B,EAAE,OAAO;CAC/C,KAAK,EAAE,QAAQ;CACf,UAAU,EAAE,QAAQ;CACrB,CAAC;AA4CF,MAAa,oBAAoB,OAC/B,QACA,YACG;AACH,KAAI,yBAAyB,QAAQ;CACrC,MAAM,WAAW,MAAM,OAAO,mBAAmB,yBAAyB;EACxE,QAAQ;EACR,MAAM,KAAK,UAAU,QAAQ;EAC9B,CAAC;AAEF,KAAI,wBAAwB,SAAS;AAErC,KAAI,SAAS,GACX,QAAQ,MAAM,SAAS,MAAM;AAG/B,OAAM,IAAI,MACR,iCAAiC,SAAS,OAAO,GAAG,SAAS,aAC9D;;AAGH,MAAa,sBAAsB,OACjC,QACA,QACA,YACA,aACG;AACH,KAAI,4BAA4B,OAAO;AACvC,KAAI,WAAW,gBACb,OAAM,IAAI,MAAM,8BAA8B,gBAAgB,QAAQ;CAExE,MAAM,WAAW,MAAM,OAAO,mBAC5B,yBAAyB,OAAO,gBAChC;EACE,QAAQ;EACR,MAAM;EACN,QAAQ;EACT,CACF;AAED,KAAI,2BAA2B,SAAS;AACxC,KAAI,SAAS,GACX,QAAO,SAAS,MAAM;AAGxB,OAAM,IAAI,MACR,mCAAmC,SAAS,OAAO,GAAG,SAAS,aAChE;;AAGH,MAAa,yBAAyB,OACpC,QACA,QACiD;CACjD,MAAM,WAAW,MAAM,OAAO,mBAC5B,6BAA6B,OAC7B,EACE,QAAQ,OACT,CACF;AACD,KAAI,uBAAuB,SAAS;AAEpC,KAAI,SAAS,GACX,QAAQ,MAAM,SAAS,MAAM;AAG/B,KAAI,SAAS,WAAW,IACtB,QAAO;AAGT,OAAM,IAAI,MACR,wCAAwC,IAAI,GAAG,SAAS,OAAO,GAAG,SAAS,aAC5E;;AAGH,MAAa,8BAA8B,OACzC,QACA,OACsD;CACtD,MAAM,WAAW,MAAM,OAAO,mBAC5B,yBAAyB,GAAG,gBAC7B;AAED,KAAI,SAAS,GACX,QAAQ,MAAM,SAAS,MAAM;AAG/B,KAAI,SAAS,WAAW,IACtB,QAAO;AAGT,OAAM,IAAI,MACR,4CAA4C,GAAG,GAAG,SAAS,OAAO,GAAG,SAAS,aAC/E;;AAGH,MAAa,+BAA+B,EAAE,OAAO,EACnD,SAAS,EAAE,QAAQ,CAAC,UAAU,EAC/B,CAAC;AAYF,MAAa,wBAAwB,OACnC,QACA,IACA,UAAwC,EAAE,KACvC;CACH,MAAM,WAAW,MAAM,OAAO,mBAC5B,yBAAyB,GAAG,cAC5B;EACE,QAAQ;EACR,MAAM,KAAK,UAAU,QAAQ;EAC9B,CACF;AAED,KAAI,SAAS,GACX,QAAQ,MAAM,SAAS,MAAM;AAG/B,OAAM,IAAI,MACR,qCAAqC,GAAG,GAAG,SAAS,OAAO,GAAG,SAAS,aACxE"}