@editframe/api 0.37.3-beta → 0.38.1

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 (89) hide show
  1. package/dist/CHUNK_SIZE_BYTES.cjs +13 -0
  2. package/dist/CHUNK_SIZE_BYTES.cjs.map +1 -0
  3. package/dist/ProgressIterator.cjs +109 -0
  4. package/dist/ProgressIterator.cjs.map +1 -0
  5. package/dist/ProgressIterator.d.cts +30 -0
  6. package/dist/StreamEventSource.cjs +127 -0
  7. package/dist/StreamEventSource.cjs.map +1 -0
  8. package/dist/StreamEventSource.d.cts +65 -0
  9. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  10. package/dist/client.cjs +54 -0
  11. package/dist/client.cjs.map +1 -0
  12. package/dist/client.d.cts +14 -0
  13. package/dist/index.cjs +70 -0
  14. package/dist/index.d.cts +15 -0
  15. package/dist/index.d.ts +4 -3
  16. package/dist/index.js +3 -2
  17. package/dist/node.cjs +175 -0
  18. package/dist/node.cjs.map +1 -0
  19. package/dist/node.d.cts +27 -0
  20. package/dist/node.d.ts +8 -3
  21. package/dist/node.js +64 -5
  22. package/dist/node.js.map +1 -1
  23. package/dist/resources/caption-file.cjs +74 -0
  24. package/dist/resources/caption-file.cjs.map +1 -0
  25. package/dist/resources/caption-file.d.cts +83 -0
  26. package/dist/resources/caption-file.d.ts +5 -0
  27. package/dist/resources/caption-file.js +3 -0
  28. package/dist/resources/caption-file.js.map +1 -1
  29. package/dist/resources/file.cjs +145 -0
  30. package/dist/resources/file.cjs.map +1 -0
  31. package/dist/resources/file.d.cts +91 -0
  32. package/dist/resources/file.d.ts +91 -0
  33. package/dist/resources/file.js +129 -0
  34. package/dist/resources/file.js.map +1 -0
  35. package/dist/resources/image-file.cjs +87 -0
  36. package/dist/resources/image-file.cjs.map +1 -0
  37. package/dist/resources/image-file.d.cts +123 -0
  38. package/dist/resources/image-file.d.ts +7 -0
  39. package/dist/resources/image-file.js +4 -0
  40. package/dist/resources/image-file.js.map +1 -1
  41. package/dist/resources/isobmff-file.cjs +72 -0
  42. package/dist/resources/isobmff-file.cjs.map +1 -0
  43. package/dist/resources/isobmff-file.d.cts +81 -0
  44. package/dist/resources/isobmff-file.d.ts +8 -0
  45. package/dist/resources/isobmff-file.js +5 -0
  46. package/dist/resources/isobmff-file.js.map +1 -1
  47. package/dist/resources/isobmff-track.cjs +109 -0
  48. package/dist/resources/isobmff-track.cjs.map +1 -0
  49. package/dist/resources/isobmff-track.d.cts +769 -0
  50. package/dist/resources/isobmff-track.d.ts +2 -0
  51. package/dist/resources/isobmff-track.js +2 -0
  52. package/dist/resources/isobmff-track.js.map +1 -1
  53. package/dist/resources/process-isobmff.cjs +16 -0
  54. package/dist/resources/process-isobmff.cjs.map +1 -0
  55. package/dist/resources/process-isobmff.d.cts +17 -0
  56. package/dist/resources/renders.bundle.cjs +50 -0
  57. package/dist/resources/renders.bundle.cjs.map +1 -0
  58. package/dist/resources/renders.bundle.d.cts +9 -0
  59. package/dist/resources/renders.bundle.d.ts +1 -1
  60. package/dist/resources/renders.cjs +152 -0
  61. package/dist/resources/renders.cjs.map +1 -0
  62. package/dist/resources/renders.d.cts +284 -0
  63. package/dist/resources/renders.d.ts +19 -19
  64. package/dist/resources/renders.js +1 -1
  65. package/dist/resources/transcriptions.cjs +38 -0
  66. package/dist/resources/transcriptions.cjs.map +1 -0
  67. package/dist/resources/transcriptions.d.cts +30 -0
  68. package/dist/resources/unprocessed-file.cjs +61 -0
  69. package/dist/resources/unprocessed-file.cjs.map +1 -0
  70. package/dist/resources/unprocessed-file.d.cts +51 -0
  71. package/dist/resources/unprocessed-file.d.ts +9 -0
  72. package/dist/resources/unprocessed-file.js +4 -0
  73. package/dist/resources/unprocessed-file.js.map +1 -1
  74. package/dist/resources/url-token.cjs +19 -0
  75. package/dist/resources/url-token.cjs.map +1 -0
  76. package/dist/resources/url-token.d.cts +10 -0
  77. package/dist/streamChunker.cjs +29 -0
  78. package/dist/streamChunker.cjs.map +1 -0
  79. package/dist/uploadChunks.cjs +87 -0
  80. package/dist/uploadChunks.cjs.map +1 -0
  81. package/dist/uploadChunks.d.cts +14 -0
  82. package/dist/utils/assertTypesMatch.cjs +7 -0
  83. package/dist/utils/assertTypesMatch.cjs.map +1 -0
  84. package/dist/utils/createReadableStreamFromReadable.cjs +71 -0
  85. package/dist/utils/createReadableStreamFromReadable.cjs.map +1 -0
  86. package/dist/utils/createReadableStreamFromReadable.d.cts +9 -0
  87. package/dist/utils/createReadableStreamFromReadable.d.ts +1 -1
  88. package/package.json +37 -9
  89. package/tsdown.config.ts +1 -0
@@ -0,0 +1,123 @@
1
+ import { Client } from "../client.cjs";
2
+ import { IteratorWithPromise, UploadChunkEvent } from "../uploadChunks.cjs";
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;
32
+ }, "strip", z.ZodTypeAny, {
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;
39
+ }, {
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;
46
+ }>, {
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;
53
+ }, {
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;
60
+ }>;
61
+ type CreateImageFilePayload = z.infer<typeof CreateImageFilePayload>;
62
+ /** @deprecated Use the unified file API from ./file.js instead */
63
+ interface CreateImageFileResult {
64
+ /**
65
+ * Whether the image file has been fully uploaded.
66
+ */
67
+ complete: boolean | null;
68
+ /**
69
+ * The byte size of the image file.
70
+ */
71
+ byte_size: number;
72
+ /**
73
+ * The id of the image file.
74
+ */
75
+ id: string;
76
+ /**
77
+ * The md5 hash of the image file.
78
+ */
79
+ md5: string | null;
80
+ }
81
+ /** @deprecated Use the unified file API from ./file.js instead */
82
+ interface LookupImageFileByMd5Result {
83
+ /**
84
+ * Whether the image file has been fully uploaded.
85
+ */
86
+ complete: boolean | null;
87
+ /**
88
+ * The byte size of the image file.
89
+ */
90
+ byte_size: number;
91
+ /**
92
+ * The id of the image file.
93
+ */
94
+ id: string;
95
+ /**
96
+ * md5 hash of the image file.
97
+ */
98
+ md5: string | null;
99
+ /**
100
+ * The height of the image file in pixels.
101
+ */
102
+ height: number | null;
103
+ /**
104
+ * The width of the image file in pixels.
105
+ */
106
+ width: number | null;
107
+ }
108
+ /** @deprecated Use the unified file API from ./file.js instead */
109
+ interface GetImageFileMetadataResult extends LookupImageFileByMd5Result {}
110
+ /** @deprecated Use the unified file API from ./file.js instead */
111
+ declare const createImageFile: (client: Client, payload: CreateImageFilePayload) => Promise<CreateImageFileResult>;
112
+ /** @deprecated Use the unified file API from ./file.js instead */
113
+ declare const uploadImageFile: (client: Client, uploadDetails: {
114
+ id: string;
115
+ byte_size: number;
116
+ }, fileStream: ReadableStream, chunkSizeBytes?: number) => IteratorWithPromise<UploadChunkEvent>;
117
+ /** @deprecated Use the unified file API from ./file.js instead */
118
+ declare const getImageFileMetadata: (client: Client, id: string) => Promise<GetImageFileMetadataResult | null>;
119
+ /** @deprecated Use the unified file API from ./file.js instead */
120
+ declare const lookupImageFileByMd5: (client: Client, md5: string) => Promise<LookupImageFileByMd5Result | null>;
121
+ //#endregion
122
+ export { CreateImageFilePayload, CreateImageFileResult, GetImageFileMetadataResult, ImageFileMimeTypes, LookupImageFileByMd5Result, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile };
123
+ //# sourceMappingURL=image-file.d.cts.map
@@ -59,6 +59,7 @@ declare const CreateImageFilePayload: z.ZodEffects<z.ZodObject<{
59
59
  mime_type?: "image/jpeg" | "image/png" | "image/jpg" | "image/webp" | "image/svg+xml" | undefined;
60
60
  }>;
61
61
  type CreateImageFilePayload = z.infer<typeof CreateImageFilePayload>;
62
+ /** @deprecated Use the unified file API from ./file.js instead */
62
63
  interface CreateImageFileResult {
63
64
  /**
64
65
  * Whether the image file has been fully uploaded.
@@ -77,6 +78,7 @@ interface CreateImageFileResult {
77
78
  */
78
79
  md5: string | null;
79
80
  }
81
+ /** @deprecated Use the unified file API from ./file.js instead */
80
82
  interface LookupImageFileByMd5Result {
81
83
  /**
82
84
  * Whether the image file has been fully uploaded.
@@ -103,13 +105,18 @@ interface LookupImageFileByMd5Result {
103
105
  */
104
106
  width: number | null;
105
107
  }
108
+ /** @deprecated Use the unified file API from ./file.js instead */
106
109
  interface GetImageFileMetadataResult extends LookupImageFileByMd5Result {}
110
+ /** @deprecated Use the unified file API from ./file.js instead */
107
111
  declare const createImageFile: (client: Client, payload: CreateImageFilePayload) => Promise<CreateImageFileResult>;
112
+ /** @deprecated Use the unified file API from ./file.js instead */
108
113
  declare const uploadImageFile: (client: Client, uploadDetails: {
109
114
  id: string;
110
115
  byte_size: number;
111
116
  }, fileStream: ReadableStream, chunkSizeBytes?: number) => IteratorWithPromise<UploadChunkEvent>;
117
+ /** @deprecated Use the unified file API from ./file.js instead */
112
118
  declare const getImageFileMetadata: (client: Client, id: string) => Promise<GetImageFileMetadataResult | null>;
119
+ /** @deprecated Use the unified file API from ./file.js instead */
113
120
  declare const lookupImageFileByMd5: (client: Client, md5: string) => Promise<LookupImageFileByMd5Result | null>;
114
121
  //#endregion
115
122
  export { CreateImageFilePayload, CreateImageFileResult, GetImageFileMetadataResult, ImageFileMimeTypes, LookupImageFileByMd5Result, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile };
@@ -35,6 +35,7 @@ const CreateImageFilePayload = z.object({
35
35
  path: ["mime_type"]
36
36
  });
37
37
  });
38
+ /** @deprecated Use the unified file API from ./file.js instead */
38
39
  const createImageFile = async (client, payload) => {
39
40
  log("Creating image file", payload);
40
41
  CreateImageFilePayload.parse(payload);
@@ -46,6 +47,7 @@ const createImageFile = async (client, payload) => {
46
47
  if (response.ok) return await response.json();
47
48
  throw new Error(`Failed to create file ${response.status} ${response.statusText}`);
48
49
  };
50
+ /** @deprecated Use the unified file API from ./file.js instead */
49
51
  const uploadImageFile = (client, uploadDetails, fileStream, chunkSizeBytes) => {
50
52
  log("Uploading image file", uploadDetails.id);
51
53
  return uploadChunks(client, {
@@ -56,11 +58,13 @@ const uploadImageFile = (client, uploadDetails, fileStream, chunkSizeBytes) => {
56
58
  chunkSizeBytes
57
59
  });
58
60
  };
61
+ /** @deprecated Use the unified file API from ./file.js instead */
59
62
  const getImageFileMetadata = async (client, id) => {
60
63
  const response = await client.authenticatedFetch(`/api/v1/image_files/${id}.json`, { method: "GET" });
61
64
  if (response.ok) return await response.json();
62
65
  return null;
63
66
  };
67
+ /** @deprecated Use the unified file API from ./file.js instead */
64
68
  const lookupImageFileByMd5 = async (client, md5) => {
65
69
  const response = await client.authenticatedFetch(`/api/v1/image_files/md5/${md5}`, { method: "GET" });
66
70
  log("Image file lookup", response);
@@ -1 +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 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;AAoDJ,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
+ {"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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\nexport interface GetImageFileMetadataResult extends LookupImageFileByMd5Result {}\n\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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,iB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,KAAK,uBAAuB,cAAc,GAAG;EAC7C,UAAU,cAAc;EACxB;EACA,SAAS;EACT;EACD,CAAC;;;AAIJ,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;;;AAIT,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"}
@@ -0,0 +1,72 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let debug = require("debug");
3
+ debug = require_rolldown_runtime.__toESM(debug);
4
+ let zod = require("zod");
5
+ zod = require_rolldown_runtime.__toESM(zod);
6
+
7
+ //#region src/resources/isobmff-file.ts
8
+ const log = (0, debug.default)("ef:api:isobmff-file");
9
+ const FILE_SIZE_LIMIT = 1024 * 1024 * 2;
10
+ const CreateISOBMFFFilePayload = zod.z.object({
11
+ md5: zod.z.string(),
12
+ filename: zod.z.string()
13
+ });
14
+ /** @deprecated Use the unified file API from ./file.js instead */
15
+ const createISOBMFFFile = async (client, payload) => {
16
+ log("Creating isobmff file", payload);
17
+ const response = await client.authenticatedFetch("/api/v1/isobmff_files", {
18
+ method: "POST",
19
+ body: JSON.stringify(payload)
20
+ });
21
+ log("ISOBMFF file created", response);
22
+ if (response.ok) return await response.json();
23
+ throw new Error(`Failed to create isobmff file ${response.status} ${response.statusText}`);
24
+ };
25
+ /** @deprecated Use the unified file API from ./file.js instead */
26
+ const uploadFragmentIndex = async (client, fileId, fileStream, fileSize) => {
27
+ log("Uploading fragment index", fileId);
28
+ if (fileSize > FILE_SIZE_LIMIT) throw new Error(`File size exceeds limit of ${FILE_SIZE_LIMIT} bytes`);
29
+ const response = await client.authenticatedFetch(`/api/v1/isobmff_files/${fileId}/index/upload`, {
30
+ method: "POST",
31
+ body: fileStream,
32
+ duplex: "half"
33
+ });
34
+ log("Fragment index uploaded", response);
35
+ if (response.ok) return response.json();
36
+ throw new Error(`Failed to create fragment index ${response.status} ${response.statusText}`);
37
+ };
38
+ /** @deprecated Use the unified file API from ./file.js instead */
39
+ const lookupISOBMFFFileByMd5 = async (client, md5) => {
40
+ const response = await client.authenticatedFetch(`/api/v1/isobmff_files/md5/${md5}`, { method: "GET" });
41
+ log("ISOBMFF file lookup", response);
42
+ if (response.ok) return await response.json();
43
+ if (response.status === 404) return null;
44
+ throw new Error(`Failed to lookup isobmff file by md5 ${md5} ${response.status} ${response.statusText}`);
45
+ };
46
+ /** @deprecated Use the unified file API from ./file.js instead */
47
+ const getISOBMFFFileTranscription = async (client, id) => {
48
+ const response = await client.authenticatedFetch(`/api/v1/isobmff_files/${id}/transcription`);
49
+ if (response.ok) return await response.json();
50
+ if (response.status === 404) return null;
51
+ throw new Error(`Failed to get isobmff file transcription ${id} ${response.status} ${response.statusText}`);
52
+ };
53
+ const TranscribeISOBMFFFilePayload = zod.z.object({ trackId: zod.z.string().optional() });
54
+ /** @deprecated Use the unified file API from ./file.js instead */
55
+ const transcribeISOBMFFFile = async (client, id, payload = {}) => {
56
+ const response = await client.authenticatedFetch(`/api/v1/isobmff_files/${id}/transcribe`, {
57
+ method: "POST",
58
+ body: JSON.stringify(payload)
59
+ });
60
+ if (response.ok) return await response.json();
61
+ throw new Error(`Failed to transcribe isobmff file ${id} ${response.status} ${response.statusText}`);
62
+ };
63
+
64
+ //#endregion
65
+ exports.CreateISOBMFFFilePayload = CreateISOBMFFFilePayload;
66
+ exports.TranscribeISOBMFFFilePayload = TranscribeISOBMFFFilePayload;
67
+ exports.createISOBMFFFile = createISOBMFFFile;
68
+ exports.getISOBMFFFileTranscription = getISOBMFFFileTranscription;
69
+ exports.lookupISOBMFFFileByMd5 = lookupISOBMFFFileByMd5;
70
+ exports.transcribeISOBMFFFile = transcribeISOBMFFFile;
71
+ exports.uploadFragmentIndex = uploadFragmentIndex;
72
+ //# sourceMappingURL=isobmff-file.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isobmff-file.cjs","names":["z"],"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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\nexport interface GetISOBMFFFileTranscriptionResult {\n id: string;\n work_slice_ms: number;\n isobmff_track: {\n duration_ms: number;\n };\n}\n\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\nexport interface TranscribeISOBMFFFileResult {\n id: string;\n file_id: string;\n track_id: number;\n}\n\n/** @deprecated Use the unified file API from ./file.js instead */\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,yBAAY,sBAAsB;AACxC,MAAM,kBAAkB,OAAO,OAAO;AAEtC,MAAa,2BAA2BA,MAAE,OAAO;CAC/C,KAAKA,MAAE,QAAQ;CACf,UAAUA,MAAE,QAAQ;CACrB,CAAC;;AA+CF,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;;;AAIH,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;;;AAIH,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;;;AAIH,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+BA,MAAE,OAAO,EACnD,SAASA,MAAE,QAAQ,CAAC,UAAU,EAC/B,CAAC;;AAcF,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"}
@@ -0,0 +1,81 @@
1
+ import { Client } from "../client.cjs";
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;
8
+ }, "strip", z.ZodTypeAny, {
9
+ md5: string;
10
+ filename: string;
11
+ }, {
12
+ md5: string;
13
+ filename: string;
14
+ }>;
15
+ type CreateISOBMFFFilePayload = z.infer<typeof CreateISOBMFFFilePayload>;
16
+ /** @deprecated Use the unified file API from ./file.js instead */
17
+ interface CreateISOBMFFFileResult {
18
+ /**
19
+ * Whether the fragment index is complete. The fragment index is used internally by editframe to efficiently seek within files.
20
+ */
21
+ fragment_index_complete: boolean;
22
+ /**
23
+ * The filename of the isobmff file
24
+ */
25
+ filename: string;
26
+ /**
27
+ * The id of the isobmff file
28
+ */
29
+ id: string;
30
+ /**
31
+ * The md5 hash of the isobmff file
32
+ */
33
+ md5: string;
34
+ }
35
+ interface LookupISOBMFFFileByMd5Result {
36
+ /**
37
+ * Whether the fragment index is complete
38
+ */
39
+ fragment_index_complete: boolean;
40
+ /**
41
+ * The filename of the isobmff file
42
+ */
43
+ filename: string;
44
+ id: string;
45
+ md5: string;
46
+ }
47
+ /** @deprecated Use the unified file API from ./file.js instead */
48
+ interface GetISOBMFFFileTranscriptionResult {
49
+ id: string;
50
+ work_slice_ms: number;
51
+ isobmff_track: {
52
+ duration_ms: number;
53
+ };
54
+ }
55
+ /** @deprecated Use the unified file API from ./file.js instead */
56
+ declare const createISOBMFFFile: (client: Client, payload: CreateISOBMFFFilePayload) => Promise<CreateISOBMFFFileResult>;
57
+ /** @deprecated Use the unified file API from ./file.js instead */
58
+ declare const uploadFragmentIndex: (client: Client, fileId: string, fileStream: ReadableStream, fileSize: number) => Promise<any>;
59
+ /** @deprecated Use the unified file API from ./file.js instead */
60
+ declare const lookupISOBMFFFileByMd5: (client: Client, md5: string) => Promise<LookupISOBMFFFileByMd5Result | null>;
61
+ /** @deprecated Use the unified file API from ./file.js instead */
62
+ declare const getISOBMFFFileTranscription: (client: Client, id: string) => Promise<GetISOBMFFFileTranscriptionResult | null>;
63
+ declare const TranscribeISOBMFFFilePayload: z.ZodObject<{
64
+ trackId: z.ZodOptional<z.ZodString>;
65
+ }, "strip", z.ZodTypeAny, {
66
+ trackId?: string | undefined;
67
+ }, {
68
+ trackId?: string | undefined;
69
+ }>;
70
+ type TranscribeISOBMFFFilePayload = z.infer<typeof TranscribeISOBMFFFilePayload>;
71
+ /** @deprecated Use the unified file API from ./file.js instead */
72
+ interface TranscribeISOBMFFFileResult {
73
+ id: string;
74
+ file_id: string;
75
+ track_id: number;
76
+ }
77
+ /** @deprecated Use the unified file API from ./file.js instead */
78
+ declare const transcribeISOBMFFFile: (client: Client, id: string, payload?: TranscribeISOBMFFFilePayload) => Promise<TranscribeISOBMFFFileResult>;
79
+ //#endregion
80
+ export { CreateISOBMFFFilePayload, CreateISOBMFFFileResult, GetISOBMFFFileTranscriptionResult, LookupISOBMFFFileByMd5Result, TranscribeISOBMFFFilePayload, TranscribeISOBMFFFileResult, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex };
81
+ //# sourceMappingURL=isobmff-file.d.cts.map
@@ -13,6 +13,7 @@ declare const CreateISOBMFFFilePayload: z.ZodObject<{
13
13
  filename: string;
14
14
  }>;
15
15
  type CreateISOBMFFFilePayload = z.infer<typeof CreateISOBMFFFilePayload>;
16
+ /** @deprecated Use the unified file API from ./file.js instead */
16
17
  interface CreateISOBMFFFileResult {
17
18
  /**
18
19
  * Whether the fragment index is complete. The fragment index is used internally by editframe to efficiently seek within files.
@@ -43,6 +44,7 @@ interface LookupISOBMFFFileByMd5Result {
43
44
  id: string;
44
45
  md5: string;
45
46
  }
47
+ /** @deprecated Use the unified file API from ./file.js instead */
46
48
  interface GetISOBMFFFileTranscriptionResult {
47
49
  id: string;
48
50
  work_slice_ms: number;
@@ -50,9 +52,13 @@ interface GetISOBMFFFileTranscriptionResult {
50
52
  duration_ms: number;
51
53
  };
52
54
  }
55
+ /** @deprecated Use the unified file API from ./file.js instead */
53
56
  declare const createISOBMFFFile: (client: Client, payload: CreateISOBMFFFilePayload) => Promise<CreateISOBMFFFileResult>;
57
+ /** @deprecated Use the unified file API from ./file.js instead */
54
58
  declare const uploadFragmentIndex: (client: Client, fileId: string, fileStream: ReadableStream, fileSize: number) => Promise<any>;
59
+ /** @deprecated Use the unified file API from ./file.js instead */
55
60
  declare const lookupISOBMFFFileByMd5: (client: Client, md5: string) => Promise<LookupISOBMFFFileByMd5Result | null>;
61
+ /** @deprecated Use the unified file API from ./file.js instead */
56
62
  declare const getISOBMFFFileTranscription: (client: Client, id: string) => Promise<GetISOBMFFFileTranscriptionResult | null>;
57
63
  declare const TranscribeISOBMFFFilePayload: z.ZodObject<{
58
64
  trackId: z.ZodOptional<z.ZodString>;
@@ -62,11 +68,13 @@ declare const TranscribeISOBMFFFilePayload: z.ZodObject<{
62
68
  trackId?: string | undefined;
63
69
  }>;
64
70
  type TranscribeISOBMFFFilePayload = z.infer<typeof TranscribeISOBMFFFilePayload>;
71
+ /** @deprecated Use the unified file API from ./file.js instead */
65
72
  interface TranscribeISOBMFFFileResult {
66
73
  id: string;
67
74
  file_id: string;
68
75
  track_id: number;
69
76
  }
77
+ /** @deprecated Use the unified file API from ./file.js instead */
70
78
  declare const transcribeISOBMFFFile: (client: Client, id: string, payload?: TranscribeISOBMFFFilePayload) => Promise<TranscribeISOBMFFFileResult>;
71
79
  //#endregion
72
80
  export { CreateISOBMFFFilePayload, CreateISOBMFFFileResult, GetISOBMFFFileTranscriptionResult, LookupISOBMFFFileByMd5Result, TranscribeISOBMFFFilePayload, TranscribeISOBMFFFileResult, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex };
@@ -8,6 +8,7 @@ const CreateISOBMFFFilePayload = z.object({
8
8
  md5: z.string(),
9
9
  filename: z.string()
10
10
  });
11
+ /** @deprecated Use the unified file API from ./file.js instead */
11
12
  const createISOBMFFFile = async (client, payload) => {
12
13
  log("Creating isobmff file", payload);
13
14
  const response = await client.authenticatedFetch("/api/v1/isobmff_files", {
@@ -18,6 +19,7 @@ const createISOBMFFFile = async (client, payload) => {
18
19
  if (response.ok) return await response.json();
19
20
  throw new Error(`Failed to create isobmff file ${response.status} ${response.statusText}`);
20
21
  };
22
+ /** @deprecated Use the unified file API from ./file.js instead */
21
23
  const uploadFragmentIndex = async (client, fileId, fileStream, fileSize) => {
22
24
  log("Uploading fragment index", fileId);
23
25
  if (fileSize > FILE_SIZE_LIMIT) throw new Error(`File size exceeds limit of ${FILE_SIZE_LIMIT} bytes`);
@@ -30,6 +32,7 @@ const uploadFragmentIndex = async (client, fileId, fileStream, fileSize) => {
30
32
  if (response.ok) return response.json();
31
33
  throw new Error(`Failed to create fragment index ${response.status} ${response.statusText}`);
32
34
  };
35
+ /** @deprecated Use the unified file API from ./file.js instead */
33
36
  const lookupISOBMFFFileByMd5 = async (client, md5) => {
34
37
  const response = await client.authenticatedFetch(`/api/v1/isobmff_files/md5/${md5}`, { method: "GET" });
35
38
  log("ISOBMFF file lookup", response);
@@ -37,6 +40,7 @@ const lookupISOBMFFFileByMd5 = async (client, md5) => {
37
40
  if (response.status === 404) return null;
38
41
  throw new Error(`Failed to lookup isobmff file by md5 ${md5} ${response.status} ${response.statusText}`);
39
42
  };
43
+ /** @deprecated Use the unified file API from ./file.js instead */
40
44
  const getISOBMFFFileTranscription = async (client, id) => {
41
45
  const response = await client.authenticatedFetch(`/api/v1/isobmff_files/${id}/transcription`);
42
46
  if (response.ok) return await response.json();
@@ -44,6 +48,7 @@ const getISOBMFFFileTranscription = async (client, id) => {
44
48
  throw new Error(`Failed to get isobmff file transcription ${id} ${response.status} ${response.statusText}`);
45
49
  };
46
50
  const TranscribeISOBMFFFilePayload = z.object({ trackId: z.string().optional() });
51
+ /** @deprecated Use the unified file API from ./file.js instead */
47
52
  const transcribeISOBMFFFile = async (client, id, payload = {}) => {
48
53
  const response = await client.authenticatedFetch(`/api/v1/isobmff_files/${id}/transcribe`, {
49
54
  method: "POST",
@@ -1 +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"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AAyB,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"}
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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\nexport interface GetISOBMFFFileTranscriptionResult {\n id: string;\n work_slice_ms: number;\n isobmff_track: {\n duration_ms: number;\n };\n}\n\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\nexport interface TranscribeISOBMFFFileResult {\n id: string;\n file_id: string;\n track_id: number;\n}\n\n/** @deprecated Use the unified file API from ./file.js instead */\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;;AA+CF,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,I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,CACF;AAED,KAAI,SAAS,GACX,QAAQ,MAAM,SAAS,MAAM;AAG/B,OAAM,IAAI,MACR,qCAAqC,GAAG,GAAG,SAAS,OAAO,GAAG,SAAS,aACxE"}
@@ -0,0 +1,109 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_uploadChunks = require('../uploadChunks.cjs');
3
+ const require_assertTypesMatch = require('../utils/assertTypesMatch.cjs');
4
+ let debug = require("debug");
5
+ debug = require_rolldown_runtime.__toESM(debug);
6
+ let zod = require("zod");
7
+ zod = require_rolldown_runtime.__toESM(zod);
8
+
9
+ //#region src/resources/isobmff-track.ts
10
+ const AudioStreamSchema = zod.z.object({
11
+ index: zod.z.number(),
12
+ codec_name: zod.z.string(),
13
+ codec_long_name: zod.z.string(),
14
+ codec_type: zod.z.literal("audio"),
15
+ codec_tag_string: zod.z.string(),
16
+ codec_tag: zod.z.string(),
17
+ sample_fmt: zod.z.string(),
18
+ sample_rate: zod.z.string(),
19
+ channels: zod.z.number(),
20
+ channel_layout: zod.z.string().optional(),
21
+ bits_per_sample: zod.z.number(),
22
+ initial_padding: zod.z.number().optional(),
23
+ r_frame_rate: zod.z.string(),
24
+ avg_frame_rate: zod.z.string(),
25
+ time_base: zod.z.string(),
26
+ start_pts: zod.z.number().optional(),
27
+ start_time: zod.z.coerce.number().optional(),
28
+ duration_ts: zod.z.number(),
29
+ duration: zod.z.coerce.number(),
30
+ bit_rate: zod.z.string(),
31
+ disposition: zod.z.record(zod.z.unknown())
32
+ });
33
+ require_assertTypesMatch.assertTypesMatch(true);
34
+ const VideoStreamSchema = zod.z.object({
35
+ index: zod.z.number(),
36
+ codec_name: zod.z.string(),
37
+ codec_long_name: zod.z.string(),
38
+ codec_type: zod.z.literal("video"),
39
+ codec_tag_string: zod.z.string(),
40
+ codec_tag: zod.z.string(),
41
+ width: zod.z.number(),
42
+ height: zod.z.number(),
43
+ coded_width: zod.z.number(),
44
+ coded_height: zod.z.number(),
45
+ r_frame_rate: zod.z.string(),
46
+ avg_frame_rate: zod.z.string(),
47
+ time_base: zod.z.string(),
48
+ start_pts: zod.z.number().optional(),
49
+ start_time: zod.z.coerce.number().optional(),
50
+ duration_ts: zod.z.number().optional(),
51
+ duration: zod.z.coerce.number().optional(),
52
+ bit_rate: zod.z.string().optional(),
53
+ disposition: zod.z.record(zod.z.unknown())
54
+ });
55
+ require_assertTypesMatch.assertTypesMatch(true);
56
+ const log = (0, debug.default)("ef:api:isobmff-track");
57
+ const MAX_TRACK_SIZE = 1024 * 1024 * 1024;
58
+ const AudioTrackPayload = zod.z.object({
59
+ file_id: zod.z.string(),
60
+ track_id: zod.z.number().int(),
61
+ type: zod.z.literal("audio"),
62
+ probe_info: AudioStreamSchema,
63
+ duration_ms: zod.z.number().int(),
64
+ codec_name: zod.z.string(),
65
+ byte_size: zod.z.number().int().max(MAX_TRACK_SIZE)
66
+ });
67
+ require_assertTypesMatch.assertTypesMatch(true);
68
+ const VideoTrackPayload = zod.z.object({
69
+ file_id: zod.z.string(),
70
+ track_id: zod.z.number().int(),
71
+ type: zod.z.literal("video"),
72
+ probe_info: VideoStreamSchema,
73
+ duration_ms: zod.z.number().int(),
74
+ codec_name: zod.z.string(),
75
+ byte_size: zod.z.number().int().max(MAX_TRACK_SIZE)
76
+ });
77
+ require_assertTypesMatch.assertTypesMatch(true);
78
+ const CreateISOBMFFTrackPayload = zod.z.discriminatedUnion("type", [AudioTrackPayload, VideoTrackPayload]);
79
+ require_assertTypesMatch.assertTypesMatch(true);
80
+ /** @deprecated Use the unified file API from ./file.js instead */
81
+ const createISOBMFFTrack = async (client, payload) => {
82
+ log("Creating isobmff track", payload);
83
+ CreateISOBMFFTrackPayload.parse(payload);
84
+ const response = await client.authenticatedFetch("/api/v1/isobmff_tracks", {
85
+ method: "POST",
86
+ body: JSON.stringify(payload)
87
+ });
88
+ log("ISOBMFF track created", response);
89
+ if (response.ok) return await response.json();
90
+ throw new Error(`Failed to create isobmff track ${response.status} ${response.statusText}`);
91
+ };
92
+ /** @deprecated Use the unified file API from ./file.js instead */
93
+ const uploadISOBMFFTrack = (client, fileId, trackId, fileStream, trackSize) => {
94
+ log("Uploading fragment track", fileId);
95
+ return require_uploadChunks.uploadChunks(client, {
96
+ url: `/api/v1/isobmff_tracks/${fileId}/${trackId}/upload`,
97
+ fileStream,
98
+ fileSize: trackSize,
99
+ maxSize: MAX_TRACK_SIZE
100
+ });
101
+ };
102
+
103
+ //#endregion
104
+ exports.AudioTrackPayload = AudioTrackPayload;
105
+ exports.CreateISOBMFFTrackPayload = CreateISOBMFFTrackPayload;
106
+ exports.VideoTrackPayload = VideoTrackPayload;
107
+ exports.createISOBMFFTrack = createISOBMFFTrack;
108
+ exports.uploadISOBMFFTrack = uploadISOBMFFTrack;
109
+ //# sourceMappingURL=isobmff-track.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isobmff-track.cjs","names":["z","assertTypesMatch","uploadChunks"],"sources":["../../src/resources/isobmff-track.ts"],"sourcesContent":["import debug from \"debug\";\nimport { z } from \"zod\";\nimport type { Client } from \"../client.js\";\nimport { uploadChunks } from \"../uploadChunks.js\";\nimport { assertTypesMatch } from \"../utils/assertTypesMatch.ts\";\n\nexport const AudioStreamSchema = z.object({\n index: z.number(),\n codec_name: z.string(),\n codec_long_name: z.string(),\n codec_type: z.literal(\"audio\"),\n codec_tag_string: z.string(),\n codec_tag: z.string(),\n sample_fmt: z.string(),\n sample_rate: z.string(),\n channels: z.number(),\n channel_layout: z.string().optional(),\n bits_per_sample: z.number(),\n initial_padding: z.number().optional(),\n r_frame_rate: z.string(),\n avg_frame_rate: z.string(),\n time_base: z.string(),\n start_pts: z.number().optional(),\n start_time: z.coerce.number().optional(),\n duration_ts: z.number(),\n duration: z.coerce.number(),\n bit_rate: z.string(),\n disposition: z.record(z.unknown()),\n});\n\nexport interface AudioStreamSchema {\n /** The index of the stream in the file */\n index: number;\n /** The name of the codec */\n codec_name: string;\n /** The long name of the codec */\n codec_long_name: string;\n /** The type of the codec */\n codec_type: \"audio\";\n /** The tag string of the codec */\n codec_tag_string: string;\n /** The tag of the codec */\n codec_tag: string;\n /** The sample format */\n sample_fmt: string;\n /** The sample rate */\n sample_rate: string;\n /** The number of channels */\n channels: number;\n /** The channel layout */\n channel_layout?: string;\n /** The number of bits per sample */\n bits_per_sample: number;\n /** The initial padding */\n initial_padding?: number;\n /** The frame rate */\n r_frame_rate: string;\n /** The average frame rate */\n avg_frame_rate: string;\n /** The time base */\n time_base: string;\n /** The start presentation timestamp */\n start_pts?: number;\n /** The start time */\n start_time?: number;\n /** The duration timestamp */\n duration_ts: number;\n /** The duration */\n duration: number;\n /** The bit rate */\n bit_rate: string;\n /** The disposition record. Subject to change, not documented. */\n disposition: Record<string, unknown>;\n}\n\nassertTypesMatch<z.infer<typeof AudioStreamSchema>, AudioStreamSchema>(true);\n\nexport const VideoStreamSchema = z.object({\n index: z.number(),\n codec_name: z.string(),\n codec_long_name: z.string(),\n codec_type: z.literal(\"video\"),\n codec_tag_string: z.string(),\n codec_tag: z.string(),\n width: z.number(),\n height: z.number(),\n coded_width: z.number(),\n coded_height: z.number(),\n r_frame_rate: z.string(),\n avg_frame_rate: z.string(),\n time_base: z.string(),\n start_pts: z.number().optional(),\n start_time: z.coerce.number().optional(),\n duration_ts: z.number().optional(),\n duration: z.coerce.number().optional(),\n bit_rate: z.string().optional(),\n disposition: z.record(z.unknown()),\n});\n\nexport interface VideoStreamSchema {\n /** The index of the stream in the file */\n index: number;\n /** The name of the codec */\n codec_name: string;\n /** The long name of the codec */\n codec_long_name: string;\n /** The type of the codec */\n codec_type: \"video\";\n /** The tag string of the codec */\n codec_tag_string: string;\n /** The tag of the codec */\n codec_tag: string;\n /** The width */\n width: number;\n /** The height */\n height: number;\n /** The coded width */\n coded_width: number;\n /** The coded height */\n coded_height: number;\n /** The frame rate */\n r_frame_rate: string;\n /** The average frame rate */\n avg_frame_rate: string;\n /** The time base */\n time_base: string;\n /** The start presentation timestamp */\n start_pts?: number;\n /** The start time */\n start_time?: number;\n /** The duration timestamp */\n duration_ts?: number;\n /** The duration */\n duration?: number;\n /** The bit rate */\n bit_rate?: string;\n /** The disposition record. Subject to change, not documented. */\n disposition: Record<string, unknown>;\n}\n\nassertTypesMatch<z.infer<typeof VideoStreamSchema>, VideoStreamSchema>(true);\n\nconst log = debug(\"ef:api:isobmff-track\");\n\nconst MAX_TRACK_SIZE = 1024 * 1024 * 1024; // 1GB\n\nexport const AudioTrackPayload = z.object({\n file_id: z.string(),\n track_id: z.number().int(),\n type: z.literal(\"audio\"),\n probe_info: AudioStreamSchema,\n duration_ms: z.number().int(),\n codec_name: z.string(),\n byte_size: z.number().int().max(MAX_TRACK_SIZE),\n});\n\nexport interface AudioTrackPayload {\n file_id: string;\n track_id: number;\n type: \"audio\";\n probe_info: AudioStreamSchema;\n duration_ms: number;\n codec_name: string;\n byte_size: number;\n}\n\n// These will actually error if types don't match\nassertTypesMatch<z.infer<typeof AudioTrackPayload>, AudioTrackPayload>(true);\n\nexport const VideoTrackPayload = z.object({\n file_id: z.string(),\n track_id: z.number().int(),\n type: z.literal(\"video\"),\n probe_info: VideoStreamSchema,\n duration_ms: z.number().int(),\n codec_name: z.string(),\n byte_size: z.number().int().max(MAX_TRACK_SIZE),\n});\n\nexport interface VideoTrackPayload {\n file_id: string;\n track_id: number;\n type: \"video\";\n probe_info: VideoStreamSchema;\n duration_ms: number;\n codec_name: string;\n byte_size: number;\n}\n\nassertTypesMatch<z.infer<typeof VideoTrackPayload>, VideoTrackPayload>(true);\n\nexport const CreateISOBMFFTrackPayload = z.discriminatedUnion(\"type\", [\n AudioTrackPayload,\n VideoTrackPayload,\n]);\n\nexport type CreateISOBMFFTrackPayload = VideoTrackPayload | AudioTrackPayload;\n\nassertTypesMatch<\n z.infer<typeof CreateISOBMFFTrackPayload>,\n CreateISOBMFFTrackPayload\n>(true);\n\nexport interface CreateISOBMFFTrackResult {\n next_byte: number;\n byte_size: number;\n track_id: number;\n file_id: string;\n complete: boolean;\n}\n\n/** @deprecated Use the unified file API from ./file.js instead */\nexport const createISOBMFFTrack = async (\n client: Client,\n payload: CreateISOBMFFTrackPayload,\n) => {\n log(\"Creating isobmff track\", payload);\n CreateISOBMFFTrackPayload.parse(payload);\n const response = await client.authenticatedFetch(\"/api/v1/isobmff_tracks\", {\n method: \"POST\",\n body: JSON.stringify(payload),\n });\n\n log(\"ISOBMFF track created\", response);\n if (response.ok) {\n return (await response.json()) as CreateISOBMFFTrackResult;\n }\n\n throw new Error(\n `Failed to create isobmff track ${response.status} ${response.statusText}`,\n );\n};\n\n/** @deprecated Use the unified file API from ./file.js instead */\nexport const uploadISOBMFFTrack = (\n client: Client,\n fileId: string,\n trackId: number,\n fileStream: ReadableStream,\n trackSize: number,\n) => {\n log(\"Uploading fragment track\", fileId);\n\n return uploadChunks(client, {\n url: `/api/v1/isobmff_tracks/${fileId}/${trackId}/upload`,\n fileStream,\n fileSize: trackSize,\n maxSize: MAX_TRACK_SIZE,\n });\n};\n"],"mappings":";;;;;;;;;AAMA,MAAa,oBAAoBA,MAAE,OAAO;CACxC,OAAOA,MAAE,QAAQ;CACjB,YAAYA,MAAE,QAAQ;CACtB,iBAAiBA,MAAE,QAAQ;CAC3B,YAAYA,MAAE,QAAQ,QAAQ;CAC9B,kBAAkBA,MAAE,QAAQ;CAC5B,WAAWA,MAAE,QAAQ;CACrB,YAAYA,MAAE,QAAQ;CACtB,aAAaA,MAAE,QAAQ;CACvB,UAAUA,MAAE,QAAQ;CACpB,gBAAgBA,MAAE,QAAQ,CAAC,UAAU;CACrC,iBAAiBA,MAAE,QAAQ;CAC3B,iBAAiBA,MAAE,QAAQ,CAAC,UAAU;CACtC,cAAcA,MAAE,QAAQ;CACxB,gBAAgBA,MAAE,QAAQ;CAC1B,WAAWA,MAAE,QAAQ;CACrB,WAAWA,MAAE,QAAQ,CAAC,UAAU;CAChC,YAAYA,MAAE,OAAO,QAAQ,CAAC,UAAU;CACxC,aAAaA,MAAE,QAAQ;CAC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