@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.
- package/dist/CHUNK_SIZE_BYTES.cjs +13 -0
- package/dist/CHUNK_SIZE_BYTES.cjs.map +1 -0
- package/dist/ProgressIterator.cjs +109 -0
- package/dist/ProgressIterator.cjs.map +1 -0
- package/dist/ProgressIterator.d.cts +30 -0
- package/dist/StreamEventSource.cjs +127 -0
- package/dist/StreamEventSource.cjs.map +1 -0
- package/dist/StreamEventSource.d.cts +65 -0
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/client.cjs +54 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +14 -0
- package/dist/index.cjs +70 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -2
- package/dist/node.cjs +175 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +27 -0
- package/dist/node.d.ts +8 -3
- package/dist/node.js +64 -5
- package/dist/node.js.map +1 -1
- package/dist/resources/caption-file.cjs +74 -0
- package/dist/resources/caption-file.cjs.map +1 -0
- package/dist/resources/caption-file.d.cts +83 -0
- package/dist/resources/caption-file.d.ts +5 -0
- package/dist/resources/caption-file.js +3 -0
- package/dist/resources/caption-file.js.map +1 -1
- package/dist/resources/file.cjs +145 -0
- package/dist/resources/file.cjs.map +1 -0
- package/dist/resources/file.d.cts +91 -0
- package/dist/resources/file.d.ts +91 -0
- package/dist/resources/file.js +129 -0
- package/dist/resources/file.js.map +1 -0
- package/dist/resources/image-file.cjs +87 -0
- package/dist/resources/image-file.cjs.map +1 -0
- package/dist/resources/image-file.d.cts +123 -0
- package/dist/resources/image-file.d.ts +7 -0
- package/dist/resources/image-file.js +4 -0
- package/dist/resources/image-file.js.map +1 -1
- package/dist/resources/isobmff-file.cjs +72 -0
- package/dist/resources/isobmff-file.cjs.map +1 -0
- package/dist/resources/isobmff-file.d.cts +81 -0
- package/dist/resources/isobmff-file.d.ts +8 -0
- package/dist/resources/isobmff-file.js +5 -0
- package/dist/resources/isobmff-file.js.map +1 -1
- package/dist/resources/isobmff-track.cjs +109 -0
- package/dist/resources/isobmff-track.cjs.map +1 -0
- package/dist/resources/isobmff-track.d.cts +769 -0
- package/dist/resources/isobmff-track.d.ts +2 -0
- package/dist/resources/isobmff-track.js +2 -0
- package/dist/resources/isobmff-track.js.map +1 -1
- package/dist/resources/process-isobmff.cjs +16 -0
- package/dist/resources/process-isobmff.cjs.map +1 -0
- package/dist/resources/process-isobmff.d.cts +17 -0
- package/dist/resources/renders.bundle.cjs +50 -0
- package/dist/resources/renders.bundle.cjs.map +1 -0
- package/dist/resources/renders.bundle.d.cts +9 -0
- package/dist/resources/renders.bundle.d.ts +1 -1
- package/dist/resources/renders.cjs +152 -0
- package/dist/resources/renders.cjs.map +1 -0
- package/dist/resources/renders.d.cts +284 -0
- package/dist/resources/renders.d.ts +19 -19
- package/dist/resources/renders.js +1 -1
- package/dist/resources/transcriptions.cjs +38 -0
- package/dist/resources/transcriptions.cjs.map +1 -0
- package/dist/resources/transcriptions.d.cts +30 -0
- package/dist/resources/unprocessed-file.cjs +61 -0
- package/dist/resources/unprocessed-file.cjs.map +1 -0
- package/dist/resources/unprocessed-file.d.cts +51 -0
- package/dist/resources/unprocessed-file.d.ts +9 -0
- package/dist/resources/unprocessed-file.js +4 -0
- package/dist/resources/unprocessed-file.js.map +1 -1
- package/dist/resources/url-token.cjs +19 -0
- package/dist/resources/url-token.cjs.map +1 -0
- package/dist/resources/url-token.d.cts +10 -0
- package/dist/streamChunker.cjs +29 -0
- package/dist/streamChunker.cjs.map +1 -0
- package/dist/uploadChunks.cjs +87 -0
- package/dist/uploadChunks.cjs.map +1 -0
- package/dist/uploadChunks.d.cts +14 -0
- package/dist/utils/assertTypesMatch.cjs +7 -0
- package/dist/utils/assertTypesMatch.cjs.map +1 -0
- package/dist/utils/createReadableStreamFromReadable.cjs +71 -0
- package/dist/utils/createReadableStreamFromReadable.cjs.map +1 -0
- package/dist/utils/createReadableStreamFromReadable.d.cts +9 -0
- package/dist/utils/createReadableStreamFromReadable.d.ts +1 -1
- package/package.json +37 -9
- package/tsdown.config.ts +1 -0
package/dist/node.cjs
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_client = require('./client.cjs');
|
|
3
|
+
const require_isobmff_track = require('./resources/isobmff-track.cjs');
|
|
4
|
+
const require_file = require('./resources/file.cjs');
|
|
5
|
+
const require_caption_file = require('./resources/caption-file.cjs');
|
|
6
|
+
const require_image_file = require('./resources/image-file.cjs');
|
|
7
|
+
const require_isobmff_file = require('./resources/isobmff-file.cjs');
|
|
8
|
+
const require_process_isobmff = require('./resources/process-isobmff.cjs');
|
|
9
|
+
const require_renders = require('./resources/renders.cjs');
|
|
10
|
+
const require_transcriptions = require('./resources/transcriptions.cjs');
|
|
11
|
+
const require_unprocessed_file = require('./resources/unprocessed-file.cjs');
|
|
12
|
+
const require_url_token = require('./resources/url-token.cjs');
|
|
13
|
+
require('./index.cjs');
|
|
14
|
+
const require_createReadableStreamFromReadable = require('./utils/createReadableStreamFromReadable.cjs');
|
|
15
|
+
let mime_types = require("mime-types");
|
|
16
|
+
mime_types = require_rolldown_runtime.__toESM(mime_types);
|
|
17
|
+
let node_fs_promises = require("node:fs/promises");
|
|
18
|
+
node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises);
|
|
19
|
+
let node_path = require("node:path");
|
|
20
|
+
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
21
|
+
let __editframe_assets = require("@editframe/assets");
|
|
22
|
+
__editframe_assets = require_rolldown_runtime.__toESM(__editframe_assets);
|
|
23
|
+
|
|
24
|
+
//#region src/node.ts
|
|
25
|
+
const createImageFileFromPath = async (client, path) => {
|
|
26
|
+
const byte_size = (await (0, node_fs_promises.stat)(path)).size;
|
|
27
|
+
const md5 = await (0, __editframe_assets.md5FilePath)(path);
|
|
28
|
+
const mime_type = (0, mime_types.lookup)(path) || null;
|
|
29
|
+
return require_image_file.createImageFile(client, { ...require_image_file.CreateImageFilePayload.parse({
|
|
30
|
+
md5,
|
|
31
|
+
height: 0,
|
|
32
|
+
width: 0,
|
|
33
|
+
mime_type,
|
|
34
|
+
filename: (0, node_path.basename)(path),
|
|
35
|
+
byte_size
|
|
36
|
+
}) });
|
|
37
|
+
};
|
|
38
|
+
const createUnprocessedFileFromPath = async (client, path) => {
|
|
39
|
+
const byte_size = (await (0, node_fs_promises.stat)(path)).size;
|
|
40
|
+
return require_unprocessed_file.createUnprocessedFile(client, {
|
|
41
|
+
md5: await (0, __editframe_assets.md5FilePath)(path),
|
|
42
|
+
filename: (0, node_path.basename)(path),
|
|
43
|
+
byte_size
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const uploadUnprocessedFile = async (client, uploadDetails, path) => {
|
|
47
|
+
const { createReadStream } = await import("node:fs");
|
|
48
|
+
const readStream = createReadStream(path);
|
|
49
|
+
const { createReadableStreamFromReadable: createReadableStreamFromReadable$1 } = await Promise.resolve().then(() => require("./utils/createReadableStreamFromReadable.cjs"));
|
|
50
|
+
return require_unprocessed_file.uploadUnprocessedReadableStream(client, uploadDetails, createReadableStreamFromReadable$1(readStream));
|
|
51
|
+
};
|
|
52
|
+
const VIDEO_EXTENSIONS = new Set([
|
|
53
|
+
".mp4",
|
|
54
|
+
".mov",
|
|
55
|
+
".webm",
|
|
56
|
+
".mkv",
|
|
57
|
+
".avi",
|
|
58
|
+
".m4v",
|
|
59
|
+
".mp3",
|
|
60
|
+
".wav",
|
|
61
|
+
".ogg",
|
|
62
|
+
".flac",
|
|
63
|
+
".aac",
|
|
64
|
+
".m4a"
|
|
65
|
+
]);
|
|
66
|
+
const IMAGE_EXTENSIONS = new Set([
|
|
67
|
+
".jpg",
|
|
68
|
+
".jpeg",
|
|
69
|
+
".png",
|
|
70
|
+
".gif",
|
|
71
|
+
".webp",
|
|
72
|
+
".svg"
|
|
73
|
+
]);
|
|
74
|
+
const CAPTION_EXTENSIONS = new Set([
|
|
75
|
+
".vtt",
|
|
76
|
+
".srt",
|
|
77
|
+
".json"
|
|
78
|
+
]);
|
|
79
|
+
function inferFileType(filePath) {
|
|
80
|
+
const ext = (0, node_path.extname)(filePath).toLowerCase();
|
|
81
|
+
if (VIDEO_EXTENSIONS.has(ext)) return "video";
|
|
82
|
+
if (IMAGE_EXTENSIONS.has(ext)) return "image";
|
|
83
|
+
if (CAPTION_EXTENSIONS.has(ext)) return "caption";
|
|
84
|
+
return "video";
|
|
85
|
+
}
|
|
86
|
+
const upload = async (client, filePath) => {
|
|
87
|
+
const byte_size = (await (0, node_fs_promises.stat)(filePath)).size;
|
|
88
|
+
const md5 = await (0, __editframe_assets.md5FilePath)(filePath);
|
|
89
|
+
const filename = (0, node_path.basename)(filePath);
|
|
90
|
+
const type = inferFileType(filePath);
|
|
91
|
+
const file = await require_file.createFile(client, {
|
|
92
|
+
filename,
|
|
93
|
+
type,
|
|
94
|
+
byte_size,
|
|
95
|
+
md5,
|
|
96
|
+
mime_type: (0, mime_types.lookup)(filePath) || void 0
|
|
97
|
+
});
|
|
98
|
+
const { createReadStream } = await import("node:fs");
|
|
99
|
+
const readStream = createReadStream(filePath);
|
|
100
|
+
const { createReadableStreamFromReadable: createReadableStreamFromReadable$1 } = await Promise.resolve().then(() => require("./utils/createReadableStreamFromReadable.cjs"));
|
|
101
|
+
return {
|
|
102
|
+
file,
|
|
103
|
+
uploadIterator: require_file.uploadFile(client, {
|
|
104
|
+
id: file.id,
|
|
105
|
+
byte_size,
|
|
106
|
+
type
|
|
107
|
+
}, createReadableStreamFromReadable$1(readStream))
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
exports.AudioTrackPayload = require_isobmff_track.AudioTrackPayload;
|
|
113
|
+
exports.Client = require_client.Client;
|
|
114
|
+
exports.CreateCaptionFilePayload = require_caption_file.CreateCaptionFilePayload;
|
|
115
|
+
exports.CreateFilePayload = require_file.CreateFilePayload;
|
|
116
|
+
exports.CreateISOBMFFFilePayload = require_isobmff_file.CreateISOBMFFFilePayload;
|
|
117
|
+
exports.CreateISOBMFFTrackPayload = require_isobmff_track.CreateISOBMFFTrackPayload;
|
|
118
|
+
exports.CreateImageFilePayload = require_image_file.CreateImageFilePayload;
|
|
119
|
+
exports.CreateRenderPayload = require_renders.CreateRenderPayload;
|
|
120
|
+
exports.CreateTranscriptionPayload = require_transcriptions.CreateTranscriptionPayload;
|
|
121
|
+
exports.CreateUnprocessedFilePayload = require_unprocessed_file.CreateUnprocessedFilePayload;
|
|
122
|
+
exports.FileStatus = require_file.FileStatus;
|
|
123
|
+
exports.FileType = require_file.FileType;
|
|
124
|
+
exports.ImageFileMimeTypes = require_image_file.ImageFileMimeTypes;
|
|
125
|
+
exports.OutputConfiguration = require_renders.OutputConfiguration;
|
|
126
|
+
exports.RenderOutputConfiguration = require_renders.RenderOutputConfiguration;
|
|
127
|
+
exports.TranscribeISOBMFFFilePayload = require_isobmff_file.TranscribeISOBMFFFilePayload;
|
|
128
|
+
exports.VideoTrackPayload = require_isobmff_track.VideoTrackPayload;
|
|
129
|
+
exports.createCaptionFile = require_caption_file.createCaptionFile;
|
|
130
|
+
exports.createFile = require_file.createFile;
|
|
131
|
+
exports.createFileTrack = require_file.createFileTrack;
|
|
132
|
+
exports.createISOBMFFFile = require_isobmff_file.createISOBMFFFile;
|
|
133
|
+
exports.createISOBMFFTrack = require_isobmff_track.createISOBMFFTrack;
|
|
134
|
+
exports.createImageFile = require_image_file.createImageFile;
|
|
135
|
+
exports.createImageFileFromPath = createImageFileFromPath;
|
|
136
|
+
exports.createReadableStreamFromReadable = require_createReadableStreamFromReadable.createReadableStreamFromReadable;
|
|
137
|
+
exports.createRender = require_renders.createRender;
|
|
138
|
+
exports.createTranscription = require_transcriptions.createTranscription;
|
|
139
|
+
exports.createURLToken = require_url_token.createURLToken;
|
|
140
|
+
exports.createUnprocessedFile = require_unprocessed_file.createUnprocessedFile;
|
|
141
|
+
exports.createUnprocessedFileFromPath = createUnprocessedFileFromPath;
|
|
142
|
+
exports.deleteFile = require_file.deleteFile;
|
|
143
|
+
exports.downloadRender = require_renders.downloadRender;
|
|
144
|
+
exports.getFileDetail = require_file.getFileDetail;
|
|
145
|
+
exports.getFileProcessingProgress = require_file.getFileProcessingProgress;
|
|
146
|
+
exports.getFileTranscription = require_file.getFileTranscription;
|
|
147
|
+
exports.getISOBMFFFileTranscription = require_isobmff_file.getISOBMFFFileTranscription;
|
|
148
|
+
exports.getImageFileMetadata = require_image_file.getImageFileMetadata;
|
|
149
|
+
exports.getIsobmffProcessInfo = require_process_isobmff.getIsobmffProcessInfo;
|
|
150
|
+
exports.getIsobmffProcessProgress = require_process_isobmff.getIsobmffProcessProgress;
|
|
151
|
+
exports.getRenderInfo = require_renders.getRenderInfo;
|
|
152
|
+
exports.getRenderProgress = require_renders.getRenderProgress;
|
|
153
|
+
exports.getTranscriptionInfo = require_transcriptions.getTranscriptionInfo;
|
|
154
|
+
exports.getTranscriptionProgress = require_transcriptions.getTranscriptionProgress;
|
|
155
|
+
exports.lookupCaptionFileByMd5 = require_caption_file.lookupCaptionFileByMd5;
|
|
156
|
+
exports.lookupFileByMd5 = require_file.lookupFileByMd5;
|
|
157
|
+
exports.lookupISOBMFFFileByMd5 = require_isobmff_file.lookupISOBMFFFileByMd5;
|
|
158
|
+
exports.lookupImageFileByMd5 = require_image_file.lookupImageFileByMd5;
|
|
159
|
+
exports.lookupRenderByMd5 = require_renders.lookupRenderByMd5;
|
|
160
|
+
exports.lookupUnprocessedFileByMd5 = require_unprocessed_file.lookupUnprocessedFileByMd5;
|
|
161
|
+
exports.processIsobmffFile = require_unprocessed_file.processIsobmffFile;
|
|
162
|
+
exports.transcribeFile = require_file.transcribeFile;
|
|
163
|
+
exports.transcribeISOBMFFFile = require_isobmff_file.transcribeISOBMFFFile;
|
|
164
|
+
exports.upload = upload;
|
|
165
|
+
exports.uploadCaptionFile = require_caption_file.uploadCaptionFile;
|
|
166
|
+
exports.uploadFile = require_file.uploadFile;
|
|
167
|
+
exports.uploadFileIndex = require_file.uploadFileIndex;
|
|
168
|
+
exports.uploadFileTrack = require_file.uploadFileTrack;
|
|
169
|
+
exports.uploadFragmentIndex = require_isobmff_file.uploadFragmentIndex;
|
|
170
|
+
exports.uploadISOBMFFTrack = require_isobmff_track.uploadISOBMFFTrack;
|
|
171
|
+
exports.uploadImageFile = require_image_file.uploadImageFile;
|
|
172
|
+
exports.uploadRender = require_renders.uploadRender;
|
|
173
|
+
exports.uploadUnprocessedFile = uploadUnprocessedFile;
|
|
174
|
+
exports.uploadUnprocessedReadableStream = require_unprocessed_file.uploadUnprocessedReadableStream;
|
|
175
|
+
//# sourceMappingURL=node.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.cjs","names":["createImageFile","CreateImageFilePayload","createUnprocessedFile","uploadUnprocessedReadableStream","createReadableStreamFromReadable","createFile","uploadFile"],"sources":["../src/node.ts"],"sourcesContent":["import { stat } from \"node:fs/promises\";\nimport { basename, extname } from \"node:path\";\nimport { md5FilePath } from \"@editframe/assets\";\nimport { lookup } from \"mime-types\";\n\nimport type { Client } from \"./client.js\";\nimport {\n CreateImageFilePayload,\n createImageFile,\n} from \"./resources/image-file.js\";\nimport {\n createUnprocessedFile,\n type UnprocessedFileUploadDetails,\n uploadUnprocessedReadableStream,\n} from \"./resources/unprocessed-file.js\";\nimport { createFile, type FileType, uploadFile } from \"./resources/file.js\";\n\nexport { createReadableStreamFromReadable } from \"./utils/createReadableStreamFromReadable.js\";\n\nexport const createImageFileFromPath = async (client: Client, path: string) => {\n const fileInfo = await stat(path);\n\n const byte_size = fileInfo.size;\n\n const md5 = await md5FilePath(path);\n\n const mime_type = lookup(path) || null;\n\n return createImageFile(client, {\n ...CreateImageFilePayload.parse({\n md5,\n height: 0,\n width: 0,\n mime_type,\n filename: basename(path),\n byte_size,\n }),\n });\n};\n\nexport const createUnprocessedFileFromPath = async (\n client: Client,\n path: string,\n) => {\n const fileInfo = await stat(path);\n\n const byte_size = fileInfo.size;\n\n const md5 = await md5FilePath(path);\n\n return createUnprocessedFile(client, {\n md5,\n filename: basename(path),\n byte_size,\n });\n};\n\nexport const uploadUnprocessedFile = async (\n client: Client,\n uploadDetails: UnprocessedFileUploadDetails,\n path: string,\n) => {\n const { createReadStream } = await import(\"node:fs\");\n const readStream = createReadStream(path);\n\n const { createReadableStreamFromReadable } =\n await import(\"./utils/createReadableStreamFromReadable.ts\");\n\n return uploadUnprocessedReadableStream(\n client,\n uploadDetails,\n createReadableStreamFromReadable(readStream),\n );\n};\n\nconst VIDEO_EXTENSIONS = new Set([\n \".mp4\",\n \".mov\",\n \".webm\",\n \".mkv\",\n \".avi\",\n \".m4v\",\n \".mp3\",\n \".wav\",\n \".ogg\",\n \".flac\",\n \".aac\",\n \".m4a\",\n]);\nconst IMAGE_EXTENSIONS = new Set([\n \".jpg\",\n \".jpeg\",\n \".png\",\n \".gif\",\n \".webp\",\n \".svg\",\n]);\nconst CAPTION_EXTENSIONS = new Set([\".vtt\", \".srt\", \".json\"]);\n\nfunction inferFileType(filePath: string): FileType {\n const ext = extname(filePath).toLowerCase();\n if (VIDEO_EXTENSIONS.has(ext)) return \"video\";\n if (IMAGE_EXTENSIONS.has(ext)) return \"image\";\n if (CAPTION_EXTENSIONS.has(ext)) return \"caption\";\n return \"video\";\n}\n\nexport const upload = async (client: Client, filePath: string) => {\n const fileInfo = await stat(filePath);\n const byte_size = fileInfo.size;\n const md5 = await md5FilePath(filePath);\n const filename = basename(filePath);\n const type = inferFileType(filePath);\n const mime_type = lookup(filePath) || undefined;\n\n const file = await createFile(client, {\n filename,\n type,\n byte_size,\n md5,\n mime_type,\n });\n\n const { createReadStream } = await import(\"node:fs\");\n const readStream = createReadStream(filePath);\n const { createReadableStreamFromReadable } =\n await import(\"./utils/createReadableStreamFromReadable.ts\");\n\n const uploadIterator = uploadFile(\n client,\n { id: file.id, byte_size, type },\n createReadableStreamFromReadable(readStream),\n );\n\n return { file, uploadIterator };\n};\n\nexport * from \"./index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAa,0BAA0B,OAAO,QAAgB,SAAiB;CAG7E,MAAM,aAFW,iCAAW,KAAK,EAEN;CAE3B,MAAM,MAAM,0CAAkB,KAAK;CAEnC,MAAM,mCAAmB,KAAK,IAAI;AAElC,QAAOA,mCAAgB,QAAQ,EAC7B,GAAGC,0CAAuB,MAAM;EAC9B;EACA,QAAQ;EACR,OAAO;EACP;EACA,kCAAmB,KAAK;EACxB;EACD,CAAC,EACH,CAAC;;AAGJ,MAAa,gCAAgC,OAC3C,QACA,SACG;CAGH,MAAM,aAFW,iCAAW,KAAK,EAEN;AAI3B,QAAOC,+CAAsB,QAAQ;EACnC,KAHU,0CAAkB,KAAK;EAIjC,kCAAmB,KAAK;EACxB;EACD,CAAC;;AAGJ,MAAa,wBAAwB,OACnC,QACA,eACA,SACG;CACH,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAC1C,MAAM,aAAa,iBAAiB,KAAK;CAEzC,MAAM,EAAE,yEACN,2CAAM;AAER,QAAOC,yDACL,QACA,eACAC,mCAAiC,WAAW,CAC7C;;AAGH,MAAM,mBAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AACF,MAAM,mBAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AACF,MAAM,qBAAqB,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAQ,CAAC;AAE7D,SAAS,cAAc,UAA4B;CACjD,MAAM,6BAAc,SAAS,CAAC,aAAa;AAC3C,KAAI,iBAAiB,IAAI,IAAI,CAAE,QAAO;AACtC,KAAI,iBAAiB,IAAI,IAAI,CAAE,QAAO;AACtC,KAAI,mBAAmB,IAAI,IAAI,CAAE,QAAO;AACxC,QAAO;;AAGT,MAAa,SAAS,OAAO,QAAgB,aAAqB;CAEhE,MAAM,aADW,iCAAW,SAAS,EACV;CAC3B,MAAM,MAAM,0CAAkB,SAAS;CACvC,MAAM,mCAAoB,SAAS;CACnC,MAAM,OAAO,cAAc,SAAS;CAGpC,MAAM,OAAO,MAAMC,wBAAW,QAAQ;EACpC;EACA;EACA;EACA;EACA,kCAPuB,SAAS,IAAI;EAQrC,CAAC;CAEF,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAC1C,MAAM,aAAa,iBAAiB,SAAS;CAC7C,MAAM,EAAE,yEACN,2CAAM;AAQR,QAAO;EAAE;EAAM,gBANQC,wBACrB,QACA;GAAE,IAAI,KAAK;GAAI;GAAW;GAAM,EAChCF,mCAAiC,WAAW,CAC7C;EAE8B"}
|
package/dist/node.d.cts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CompletionEvent, EventCallback, ProgressEvent, StreamEventSource, StreamEventSourceEventMap } from "./StreamEventSource.cjs";
|
|
2
|
+
import { Client } from "./client.cjs";
|
|
3
|
+
import { CompletionIterator, ProgressIterator } from "./ProgressIterator.cjs";
|
|
4
|
+
import { IteratorWithPromise, UploadChunkEvent } from "./uploadChunks.cjs";
|
|
5
|
+
import { AudioStreamSchema, AudioTrackPayload, CreateISOBMFFTrackPayload, CreateISOBMFFTrackResult, VideoStreamSchema, VideoTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.cjs";
|
|
6
|
+
import { CreateFilePayload, CreateFileResult, FileDetail, FileRecord, FileStatus, FileTranscriptionResult, FileType, LookupFileByMd5Result, TranscribeFileResult, createFile, createFileTrack, deleteFile, getFileDetail, getFileProcessingProgress, getFileTranscription, lookupFileByMd5, transcribeFile, uploadFile, uploadFileIndex, uploadFileTrack } from "./resources/file.cjs";
|
|
7
|
+
import { CreateCaptionFilePayload, CreateCaptionFileResult, LookupCaptionFileByMd5Result, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile } from "./resources/caption-file.cjs";
|
|
8
|
+
import { CreateImageFilePayload, CreateImageFileResult, GetImageFileMetadataResult, ImageFileMimeTypes, LookupImageFileByMd5Result, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile } from "./resources/image-file.cjs";
|
|
9
|
+
import { CreateISOBMFFFilePayload, CreateISOBMFFFileResult, GetISOBMFFFileTranscriptionResult, LookupISOBMFFFileByMd5Result, TranscribeISOBMFFFilePayload, TranscribeISOBMFFFileResult, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex } from "./resources/isobmff-file.cjs";
|
|
10
|
+
import { IsobmffProcessInfoResult, getIsobmffProcessInfo, getIsobmffProcessProgress } from "./resources/process-isobmff.cjs";
|
|
11
|
+
import { CreateRenderPayload, CreateRenderResult, LookupRenderByMd5Result, OutputConfiguration, RenderOutputConfiguration, createRender, downloadRender, getRenderInfo, getRenderProgress, lookupRenderByMd5, uploadRender } from "./resources/renders.cjs";
|
|
12
|
+
import { CreateTranscriptionPayload, CreateTranscriptionResult, TranscriptionInfoResult, createTranscription, getTranscriptionInfo, getTranscriptionProgress } from "./resources/transcriptions.cjs";
|
|
13
|
+
import { CreateUnprocessedFilePayload, CreateUnprocessedFileResult, LookupUnprocessedFileByMd5Result, ProcessIsobmffFileResult, UnprocessedFile, UnprocessedFileUploadDetails, createUnprocessedFile, lookupUnprocessedFileByMd5, processIsobmffFile, uploadUnprocessedReadableStream } from "./resources/unprocessed-file.cjs";
|
|
14
|
+
import { URLTokenResult, createURLToken } from "./resources/url-token.cjs";
|
|
15
|
+
import { createReadableStreamFromReadable } from "./utils/createReadableStreamFromReadable.cjs";
|
|
16
|
+
|
|
17
|
+
//#region src/node.d.ts
|
|
18
|
+
declare const createImageFileFromPath: (client: Client, path: string) => Promise<CreateImageFileResult>;
|
|
19
|
+
declare const createUnprocessedFileFromPath: (client: Client, path: string) => Promise<CreateUnprocessedFileResult>;
|
|
20
|
+
declare const uploadUnprocessedFile: (client: Client, uploadDetails: UnprocessedFileUploadDetails, path: string) => Promise<IteratorWithPromise<UploadChunkEvent>>;
|
|
21
|
+
declare const upload: (client: Client, filePath: string) => Promise<{
|
|
22
|
+
file: CreateFileResult;
|
|
23
|
+
uploadIterator: IteratorWithPromise<UploadChunkEvent>;
|
|
24
|
+
}>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AudioStreamSchema, AudioTrackPayload, Client, CompletionEvent, CompletionIterator, CreateCaptionFilePayload, CreateCaptionFileResult, CreateFilePayload, CreateFileResult, CreateISOBMFFTrackPayload as CreateFileTrackPayload, CreateISOBMFFTrackResult as CreateFileTrackResult, CreateISOBMFFFilePayload, CreateISOBMFFFileResult, CreateISOBMFFTrackPayload, CreateISOBMFFTrackResult, CreateImageFilePayload, CreateImageFileResult, CreateRenderPayload, CreateRenderResult, CreateTranscriptionPayload, CreateTranscriptionResult, CreateUnprocessedFilePayload, CreateUnprocessedFileResult, EventCallback, FileDetail, FileRecord, FileStatus, FileTranscriptionResult, FileType, GetISOBMFFFileTranscriptionResult, GetImageFileMetadataResult, ImageFileMimeTypes, IsobmffProcessInfoResult, IteratorWithPromise, LookupCaptionFileByMd5Result, LookupFileByMd5Result, LookupISOBMFFFileByMd5Result, LookupImageFileByMd5Result, LookupRenderByMd5Result, LookupUnprocessedFileByMd5Result, OutputConfiguration, ProcessIsobmffFileResult, ProgressEvent, ProgressIterator, RenderOutputConfiguration, StreamEventSource, StreamEventSourceEventMap, TranscribeFileResult, TranscribeISOBMFFFilePayload, TranscribeISOBMFFFileResult, TranscriptionInfoResult, URLTokenResult, UnprocessedFile, UnprocessedFileUploadDetails, UploadChunkEvent, VideoStreamSchema, VideoTrackPayload, createCaptionFile, createFile, createFileTrack, createISOBMFFFile, createISOBMFFTrack, createImageFile, createImageFileFromPath, createReadableStreamFromReadable, createRender, createTranscription, createURLToken, createUnprocessedFile, createUnprocessedFileFromPath, deleteFile, downloadRender, getFileDetail, getFileProcessingProgress, getFileTranscription, getISOBMFFFileTranscription, getImageFileMetadata, getIsobmffProcessInfo, getIsobmffProcessProgress, getRenderInfo, getRenderProgress, getTranscriptionInfo, getTranscriptionProgress, lookupCaptionFileByMd5, lookupFileByMd5, lookupISOBMFFFileByMd5, lookupImageFileByMd5, lookupRenderByMd5, lookupUnprocessedFileByMd5, processIsobmffFile, transcribeFile, transcribeISOBMFFFile, upload, uploadCaptionFile, uploadFile, uploadFileIndex, uploadFileTrack, uploadFragmentIndex, uploadISOBMFFTrack, uploadImageFile, uploadRender, uploadUnprocessedFile, uploadUnprocessedReadableStream };
|
|
27
|
+
//# sourceMappingURL=node.d.cts.map
|
package/dist/node.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CompletionEvent, EventCallback, ProgressEvent, StreamEventSource, StreamEventSourceEventMap } from "./StreamEventSource.js";
|
|
2
2
|
import { Client } from "./client.js";
|
|
3
3
|
import { CompletionIterator, ProgressIterator } from "./ProgressIterator.js";
|
|
4
|
-
import { CreateCaptionFilePayload, CreateCaptionFileResult, LookupCaptionFileByMd5Result, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile } from "./resources/caption-file.js";
|
|
5
4
|
import { IteratorWithPromise, UploadChunkEvent } from "./uploadChunks.js";
|
|
5
|
+
import { AudioStreamSchema, AudioTrackPayload, CreateISOBMFFTrackPayload, CreateISOBMFFTrackResult, VideoStreamSchema, VideoTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
|
|
6
|
+
import { CreateFilePayload, CreateFileResult, FileDetail, FileRecord, FileStatus, FileTranscriptionResult, FileType, LookupFileByMd5Result, TranscribeFileResult, createFile, createFileTrack, deleteFile, getFileDetail, getFileProcessingProgress, getFileTranscription, lookupFileByMd5, transcribeFile, uploadFile, uploadFileIndex, uploadFileTrack } from "./resources/file.js";
|
|
7
|
+
import { CreateCaptionFilePayload, CreateCaptionFileResult, LookupCaptionFileByMd5Result, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile } from "./resources/caption-file.js";
|
|
6
8
|
import { CreateImageFilePayload, CreateImageFileResult, GetImageFileMetadataResult, ImageFileMimeTypes, LookupImageFileByMd5Result, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile } from "./resources/image-file.js";
|
|
7
9
|
import { CreateISOBMFFFilePayload, CreateISOBMFFFileResult, GetISOBMFFFileTranscriptionResult, LookupISOBMFFFileByMd5Result, TranscribeISOBMFFFilePayload, TranscribeISOBMFFFileResult, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex } from "./resources/isobmff-file.js";
|
|
8
|
-
import { AudioStreamSchema, AudioTrackPayload, CreateISOBMFFTrackPayload, CreateISOBMFFTrackResult, VideoStreamSchema, VideoTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
|
|
9
10
|
import { IsobmffProcessInfoResult, getIsobmffProcessInfo, getIsobmffProcessProgress } from "./resources/process-isobmff.js";
|
|
10
11
|
import { CreateRenderPayload, CreateRenderResult, LookupRenderByMd5Result, OutputConfiguration, RenderOutputConfiguration, createRender, downloadRender, getRenderInfo, getRenderProgress, lookupRenderByMd5, uploadRender } from "./resources/renders.js";
|
|
11
12
|
import { CreateTranscriptionPayload, CreateTranscriptionResult, TranscriptionInfoResult, createTranscription, getTranscriptionInfo, getTranscriptionProgress } from "./resources/transcriptions.js";
|
|
@@ -18,6 +19,10 @@ import { createReadableStreamFromReadable } from "./utils/createReadableStreamFr
|
|
|
18
19
|
declare const createImageFileFromPath: (client: Client, path: string) => Promise<CreateImageFileResult>;
|
|
19
20
|
declare const createUnprocessedFileFromPath: (client: Client, path: string) => Promise<CreateUnprocessedFileResult>;
|
|
20
21
|
declare const uploadUnprocessedFile: (client: Client, uploadDetails: UnprocessedFileUploadDetails, path: string) => Promise<IteratorWithPromise<UploadChunkEvent>>;
|
|
22
|
+
declare const upload: (client: Client, filePath: string) => Promise<{
|
|
23
|
+
file: CreateFileResult;
|
|
24
|
+
uploadIterator: IteratorWithPromise<UploadChunkEvent>;
|
|
25
|
+
}>;
|
|
21
26
|
//#endregion
|
|
22
|
-
export { AudioStreamSchema, AudioTrackPayload, Client, CompletionEvent, CompletionIterator, CreateCaptionFilePayload, CreateCaptionFileResult, CreateISOBMFFFilePayload, CreateISOBMFFFileResult, CreateISOBMFFTrackPayload, CreateISOBMFFTrackResult, CreateImageFilePayload, CreateImageFileResult, CreateRenderPayload, CreateRenderResult, CreateTranscriptionPayload, CreateTranscriptionResult, CreateUnprocessedFilePayload, CreateUnprocessedFileResult, EventCallback, GetISOBMFFFileTranscriptionResult, GetImageFileMetadataResult, ImageFileMimeTypes, IsobmffProcessInfoResult, IteratorWithPromise, LookupCaptionFileByMd5Result, LookupISOBMFFFileByMd5Result, LookupImageFileByMd5Result, LookupRenderByMd5Result, LookupUnprocessedFileByMd5Result, OutputConfiguration, ProcessIsobmffFileResult, ProgressEvent, ProgressIterator, RenderOutputConfiguration, StreamEventSource, StreamEventSourceEventMap, TranscribeISOBMFFFilePayload, TranscribeISOBMFFFileResult, TranscriptionInfoResult, URLTokenResult, UnprocessedFile, UnprocessedFileUploadDetails, UploadChunkEvent, VideoStreamSchema, VideoTrackPayload, createCaptionFile, createISOBMFFFile, createISOBMFFTrack, createImageFile, createImageFileFromPath, createReadableStreamFromReadable, createRender, createTranscription, createURLToken, createUnprocessedFile, createUnprocessedFileFromPath, downloadRender, getISOBMFFFileTranscription, getImageFileMetadata, getIsobmffProcessInfo, getIsobmffProcessProgress, getRenderInfo, getRenderProgress, getTranscriptionInfo, getTranscriptionProgress, lookupCaptionFileByMd5, lookupISOBMFFFileByMd5, lookupImageFileByMd5, lookupRenderByMd5, lookupUnprocessedFileByMd5, processIsobmffFile, transcribeISOBMFFFile, uploadCaptionFile, uploadFragmentIndex, uploadISOBMFFTrack, uploadImageFile, uploadRender, uploadUnprocessedFile, uploadUnprocessedReadableStream };
|
|
27
|
+
export { AudioStreamSchema, AudioTrackPayload, Client, CompletionEvent, CompletionIterator, CreateCaptionFilePayload, CreateCaptionFileResult, CreateFilePayload, CreateFileResult, CreateISOBMFFTrackPayload as CreateFileTrackPayload, CreateISOBMFFTrackResult as CreateFileTrackResult, CreateISOBMFFFilePayload, CreateISOBMFFFileResult, CreateISOBMFFTrackPayload, CreateISOBMFFTrackResult, CreateImageFilePayload, CreateImageFileResult, CreateRenderPayload, CreateRenderResult, CreateTranscriptionPayload, CreateTranscriptionResult, CreateUnprocessedFilePayload, CreateUnprocessedFileResult, EventCallback, FileDetail, FileRecord, FileStatus, FileTranscriptionResult, FileType, GetISOBMFFFileTranscriptionResult, GetImageFileMetadataResult, ImageFileMimeTypes, IsobmffProcessInfoResult, IteratorWithPromise, LookupCaptionFileByMd5Result, LookupFileByMd5Result, LookupISOBMFFFileByMd5Result, LookupImageFileByMd5Result, LookupRenderByMd5Result, LookupUnprocessedFileByMd5Result, OutputConfiguration, ProcessIsobmffFileResult, ProgressEvent, ProgressIterator, RenderOutputConfiguration, StreamEventSource, StreamEventSourceEventMap, TranscribeFileResult, TranscribeISOBMFFFilePayload, TranscribeISOBMFFFileResult, TranscriptionInfoResult, URLTokenResult, UnprocessedFile, UnprocessedFileUploadDetails, UploadChunkEvent, VideoStreamSchema, VideoTrackPayload, createCaptionFile, createFile, createFileTrack, createISOBMFFFile, createISOBMFFTrack, createImageFile, createImageFileFromPath, createReadableStreamFromReadable, createRender, createTranscription, createURLToken, createUnprocessedFile, createUnprocessedFileFromPath, deleteFile, downloadRender, getFileDetail, getFileProcessingProgress, getFileTranscription, getISOBMFFFileTranscription, getImageFileMetadata, getIsobmffProcessInfo, getIsobmffProcessProgress, getRenderInfo, getRenderProgress, getTranscriptionInfo, getTranscriptionProgress, lookupCaptionFileByMd5, lookupFileByMd5, lookupISOBMFFFileByMd5, lookupImageFileByMd5, lookupRenderByMd5, lookupUnprocessedFileByMd5, processIsobmffFile, transcribeFile, transcribeISOBMFFFile, upload, uploadCaptionFile, uploadFile, uploadFileIndex, uploadFileTrack, uploadFragmentIndex, uploadISOBMFFTrack, uploadImageFile, uploadRender, uploadUnprocessedFile, uploadUnprocessedReadableStream };
|
|
23
28
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Client } from "./client.js";
|
|
2
|
+
import { AudioTrackPayload, CreateISOBMFFTrackPayload, VideoTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
|
|
3
|
+
import { CreateFilePayload, FileStatus, FileType, createFile, createFileTrack, deleteFile, getFileDetail, getFileProcessingProgress, getFileTranscription, lookupFileByMd5, transcribeFile, uploadFile, uploadFileIndex, uploadFileTrack } from "./resources/file.js";
|
|
2
4
|
import { CreateCaptionFilePayload, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile } from "./resources/caption-file.js";
|
|
3
5
|
import { CreateImageFilePayload, ImageFileMimeTypes, createImageFile, getImageFileMetadata, lookupImageFileByMd5, uploadImageFile } from "./resources/image-file.js";
|
|
4
6
|
import { CreateISOBMFFFilePayload, TranscribeISOBMFFFilePayload, createISOBMFFFile, getISOBMFFFileTranscription, lookupISOBMFFFileByMd5, transcribeISOBMFFFile, uploadFragmentIndex } from "./resources/isobmff-file.js";
|
|
5
|
-
import { AudioTrackPayload, CreateISOBMFFTrackPayload, VideoTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
|
|
6
7
|
import { getIsobmffProcessInfo, getIsobmffProcessProgress } from "./resources/process-isobmff.js";
|
|
7
8
|
import { CreateRenderPayload, OutputConfiguration, RenderOutputConfiguration, createRender, downloadRender, getRenderInfo, getRenderProgress, lookupRenderByMd5, uploadRender } from "./resources/renders.js";
|
|
8
9
|
import { CreateTranscriptionPayload, createTranscription, getTranscriptionInfo, getTranscriptionProgress } from "./resources/transcriptions.js";
|
|
@@ -10,16 +11,16 @@ import { CreateUnprocessedFilePayload, createUnprocessedFile, lookupUnprocessedF
|
|
|
10
11
|
import { createURLToken } from "./resources/url-token.js";
|
|
11
12
|
import "./index.js";
|
|
12
13
|
import { createReadableStreamFromReadable } from "./utils/createReadableStreamFromReadable.js";
|
|
14
|
+
import { lookup } from "mime-types";
|
|
13
15
|
import { stat } from "node:fs/promises";
|
|
14
|
-
import { basename } from "node:path";
|
|
16
|
+
import { basename, extname } from "node:path";
|
|
15
17
|
import { md5FilePath } from "@editframe/assets";
|
|
16
|
-
import mime from "mime";
|
|
17
18
|
|
|
18
19
|
//#region src/node.ts
|
|
19
20
|
const createImageFileFromPath = async (client, path$1) => {
|
|
20
21
|
const byte_size = (await stat(path$1)).size;
|
|
21
22
|
const md5 = await md5FilePath(path$1);
|
|
22
|
-
const mime_type =
|
|
23
|
+
const mime_type = lookup(path$1) || null;
|
|
23
24
|
return createImageFile(client, { ...CreateImageFilePayload.parse({
|
|
24
25
|
md5,
|
|
25
26
|
height: 0,
|
|
@@ -43,7 +44,65 @@ const uploadUnprocessedFile = async (client, uploadDetails, path$1) => {
|
|
|
43
44
|
const { createReadableStreamFromReadable: createReadableStreamFromReadable$1 } = await import("./utils/createReadableStreamFromReadable.js");
|
|
44
45
|
return uploadUnprocessedReadableStream(client, uploadDetails, createReadableStreamFromReadable$1(readStream));
|
|
45
46
|
};
|
|
47
|
+
const VIDEO_EXTENSIONS = new Set([
|
|
48
|
+
".mp4",
|
|
49
|
+
".mov",
|
|
50
|
+
".webm",
|
|
51
|
+
".mkv",
|
|
52
|
+
".avi",
|
|
53
|
+
".m4v",
|
|
54
|
+
".mp3",
|
|
55
|
+
".wav",
|
|
56
|
+
".ogg",
|
|
57
|
+
".flac",
|
|
58
|
+
".aac",
|
|
59
|
+
".m4a"
|
|
60
|
+
]);
|
|
61
|
+
const IMAGE_EXTENSIONS = new Set([
|
|
62
|
+
".jpg",
|
|
63
|
+
".jpeg",
|
|
64
|
+
".png",
|
|
65
|
+
".gif",
|
|
66
|
+
".webp",
|
|
67
|
+
".svg"
|
|
68
|
+
]);
|
|
69
|
+
const CAPTION_EXTENSIONS = new Set([
|
|
70
|
+
".vtt",
|
|
71
|
+
".srt",
|
|
72
|
+
".json"
|
|
73
|
+
]);
|
|
74
|
+
function inferFileType(filePath) {
|
|
75
|
+
const ext = extname(filePath).toLowerCase();
|
|
76
|
+
if (VIDEO_EXTENSIONS.has(ext)) return "video";
|
|
77
|
+
if (IMAGE_EXTENSIONS.has(ext)) return "image";
|
|
78
|
+
if (CAPTION_EXTENSIONS.has(ext)) return "caption";
|
|
79
|
+
return "video";
|
|
80
|
+
}
|
|
81
|
+
const upload = async (client, filePath) => {
|
|
82
|
+
const byte_size = (await stat(filePath)).size;
|
|
83
|
+
const md5 = await md5FilePath(filePath);
|
|
84
|
+
const filename = basename(filePath);
|
|
85
|
+
const type = inferFileType(filePath);
|
|
86
|
+
const file = await createFile(client, {
|
|
87
|
+
filename,
|
|
88
|
+
type,
|
|
89
|
+
byte_size,
|
|
90
|
+
md5,
|
|
91
|
+
mime_type: lookup(filePath) || void 0
|
|
92
|
+
});
|
|
93
|
+
const { createReadStream } = await import("node:fs");
|
|
94
|
+
const readStream = createReadStream(filePath);
|
|
95
|
+
const { createReadableStreamFromReadable: createReadableStreamFromReadable$1 } = await import("./utils/createReadableStreamFromReadable.js");
|
|
96
|
+
return {
|
|
97
|
+
file,
|
|
98
|
+
uploadIterator: uploadFile(client, {
|
|
99
|
+
id: file.id,
|
|
100
|
+
byte_size,
|
|
101
|
+
type
|
|
102
|
+
}, createReadableStreamFromReadable$1(readStream))
|
|
103
|
+
};
|
|
104
|
+
};
|
|
46
105
|
|
|
47
106
|
//#endregion
|
|
48
|
-
export { AudioTrackPayload, Client, CreateCaptionFilePayload, CreateISOBMFFFilePayload, CreateISOBMFFTrackPayload, CreateImageFilePayload, CreateRenderPayload, CreateTranscriptionPayload, CreateUnprocessedFilePayload, ImageFileMimeTypes, OutputConfiguration, RenderOutputConfiguration, TranscribeISOBMFFFilePayload, VideoTrackPayload, createCaptionFile, createISOBMFFFile, createISOBMFFTrack, createImageFile, createImageFileFromPath, createReadableStreamFromReadable, createRender, createTranscription, createURLToken, createUnprocessedFile, createUnprocessedFileFromPath, downloadRender, getISOBMFFFileTranscription, getImageFileMetadata, getIsobmffProcessInfo, getIsobmffProcessProgress, getRenderInfo, getRenderProgress, getTranscriptionInfo, getTranscriptionProgress, lookupCaptionFileByMd5, lookupISOBMFFFileByMd5, lookupImageFileByMd5, lookupRenderByMd5, lookupUnprocessedFileByMd5, processIsobmffFile, transcribeISOBMFFFile, uploadCaptionFile, uploadFragmentIndex, uploadISOBMFFTrack, uploadImageFile, uploadRender, uploadUnprocessedFile, uploadUnprocessedReadableStream };
|
|
107
|
+
export { AudioTrackPayload, Client, CreateCaptionFilePayload, CreateFilePayload, CreateISOBMFFFilePayload, CreateISOBMFFTrackPayload, CreateImageFilePayload, CreateRenderPayload, CreateTranscriptionPayload, CreateUnprocessedFilePayload, FileStatus, FileType, ImageFileMimeTypes, OutputConfiguration, RenderOutputConfiguration, TranscribeISOBMFFFilePayload, VideoTrackPayload, createCaptionFile, createFile, createFileTrack, createISOBMFFFile, createISOBMFFTrack, createImageFile, createImageFileFromPath, createReadableStreamFromReadable, createRender, createTranscription, createURLToken, createUnprocessedFile, createUnprocessedFileFromPath, deleteFile, downloadRender, getFileDetail, getFileProcessingProgress, getFileTranscription, getISOBMFFFileTranscription, getImageFileMetadata, getIsobmffProcessInfo, getIsobmffProcessProgress, getRenderInfo, getRenderProgress, getTranscriptionInfo, getTranscriptionProgress, lookupCaptionFileByMd5, lookupFileByMd5, lookupISOBMFFFileByMd5, lookupImageFileByMd5, lookupRenderByMd5, lookupUnprocessedFileByMd5, processIsobmffFile, transcribeFile, transcribeISOBMFFFile, upload, uploadCaptionFile, uploadFile, uploadFileIndex, uploadFileTrack, uploadFragmentIndex, uploadISOBMFFTrack, uploadImageFile, uploadRender, uploadUnprocessedFile, uploadUnprocessedReadableStream };
|
|
49
108
|
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","names":["path","createReadableStreamFromReadable"],"sources":["../src/node.ts"],"sourcesContent":["import { stat } from \"node:fs/promises\";\nimport { basename } from \"node:path\";\nimport { md5FilePath } from \"@editframe/assets\";\nimport
|
|
1
|
+
{"version":3,"file":"node.js","names":["path","createReadableStreamFromReadable"],"sources":["../src/node.ts"],"sourcesContent":["import { stat } from \"node:fs/promises\";\nimport { basename, extname } from \"node:path\";\nimport { md5FilePath } from \"@editframe/assets\";\nimport { lookup } from \"mime-types\";\n\nimport type { Client } from \"./client.js\";\nimport {\n CreateImageFilePayload,\n createImageFile,\n} from \"./resources/image-file.js\";\nimport {\n createUnprocessedFile,\n type UnprocessedFileUploadDetails,\n uploadUnprocessedReadableStream,\n} from \"./resources/unprocessed-file.js\";\nimport { createFile, type FileType, uploadFile } from \"./resources/file.js\";\n\nexport { createReadableStreamFromReadable } from \"./utils/createReadableStreamFromReadable.js\";\n\nexport const createImageFileFromPath = async (client: Client, path: string) => {\n const fileInfo = await stat(path);\n\n const byte_size = fileInfo.size;\n\n const md5 = await md5FilePath(path);\n\n const mime_type = lookup(path) || null;\n\n return createImageFile(client, {\n ...CreateImageFilePayload.parse({\n md5,\n height: 0,\n width: 0,\n mime_type,\n filename: basename(path),\n byte_size,\n }),\n });\n};\n\nexport const createUnprocessedFileFromPath = async (\n client: Client,\n path: string,\n) => {\n const fileInfo = await stat(path);\n\n const byte_size = fileInfo.size;\n\n const md5 = await md5FilePath(path);\n\n return createUnprocessedFile(client, {\n md5,\n filename: basename(path),\n byte_size,\n });\n};\n\nexport const uploadUnprocessedFile = async (\n client: Client,\n uploadDetails: UnprocessedFileUploadDetails,\n path: string,\n) => {\n const { createReadStream } = await import(\"node:fs\");\n const readStream = createReadStream(path);\n\n const { createReadableStreamFromReadable } =\n await import(\"./utils/createReadableStreamFromReadable.ts\");\n\n return uploadUnprocessedReadableStream(\n client,\n uploadDetails,\n createReadableStreamFromReadable(readStream),\n );\n};\n\nconst VIDEO_EXTENSIONS = new Set([\n \".mp4\",\n \".mov\",\n \".webm\",\n \".mkv\",\n \".avi\",\n \".m4v\",\n \".mp3\",\n \".wav\",\n \".ogg\",\n \".flac\",\n \".aac\",\n \".m4a\",\n]);\nconst IMAGE_EXTENSIONS = new Set([\n \".jpg\",\n \".jpeg\",\n \".png\",\n \".gif\",\n \".webp\",\n \".svg\",\n]);\nconst CAPTION_EXTENSIONS = new Set([\".vtt\", \".srt\", \".json\"]);\n\nfunction inferFileType(filePath: string): FileType {\n const ext = extname(filePath).toLowerCase();\n if (VIDEO_EXTENSIONS.has(ext)) return \"video\";\n if (IMAGE_EXTENSIONS.has(ext)) return \"image\";\n if (CAPTION_EXTENSIONS.has(ext)) return \"caption\";\n return \"video\";\n}\n\nexport const upload = async (client: Client, filePath: string) => {\n const fileInfo = await stat(filePath);\n const byte_size = fileInfo.size;\n const md5 = await md5FilePath(filePath);\n const filename = basename(filePath);\n const type = inferFileType(filePath);\n const mime_type = lookup(filePath) || undefined;\n\n const file = await createFile(client, {\n filename,\n type,\n byte_size,\n md5,\n mime_type,\n });\n\n const { createReadStream } = await import(\"node:fs\");\n const readStream = createReadStream(filePath);\n const { createReadableStreamFromReadable } =\n await import(\"./utils/createReadableStreamFromReadable.ts\");\n\n const uploadIterator = uploadFile(\n client,\n { id: file.id, byte_size, type },\n createReadableStreamFromReadable(readStream),\n );\n\n return { file, uploadIterator };\n};\n\nexport * from \"./index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAa,0BAA0B,OAAO,QAAgB,WAAiB;CAG7E,MAAM,aAFW,MAAM,KAAKA,OAAK,EAEN;CAE3B,MAAM,MAAM,MAAM,YAAYA,OAAK;CAEnC,MAAM,YAAY,OAAOA,OAAK,IAAI;AAElC,QAAO,gBAAgB,QAAQ,EAC7B,GAAG,uBAAuB,MAAM;EAC9B;EACA,QAAQ;EACR,OAAO;EACP;EACA,UAAU,SAASA,OAAK;EACxB;EACD,CAAC,EACH,CAAC;;AAGJ,MAAa,gCAAgC,OAC3C,QACA,WACG;CAGH,MAAM,aAFW,MAAM,KAAKA,OAAK,EAEN;AAI3B,QAAO,sBAAsB,QAAQ;EACnC,KAHU,MAAM,YAAYA,OAAK;EAIjC,UAAU,SAASA,OAAK;EACxB;EACD,CAAC;;AAGJ,MAAa,wBAAwB,OACnC,QACA,eACA,WACG;CACH,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAC1C,MAAM,aAAa,iBAAiBA,OAAK;CAEzC,MAAM,EAAE,yEACN,MAAM,OAAO;AAEf,QAAO,gCACL,QACA,eACAC,mCAAiC,WAAW,CAC7C;;AAGH,MAAM,mBAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AACF,MAAM,mBAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AACF,MAAM,qBAAqB,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAQ,CAAC;AAE7D,SAAS,cAAc,UAA4B;CACjD,MAAM,MAAM,QAAQ,SAAS,CAAC,aAAa;AAC3C,KAAI,iBAAiB,IAAI,IAAI,CAAE,QAAO;AACtC,KAAI,iBAAiB,IAAI,IAAI,CAAE,QAAO;AACtC,KAAI,mBAAmB,IAAI,IAAI,CAAE,QAAO;AACxC,QAAO;;AAGT,MAAa,SAAS,OAAO,QAAgB,aAAqB;CAEhE,MAAM,aADW,MAAM,KAAK,SAAS,EACV;CAC3B,MAAM,MAAM,MAAM,YAAY,SAAS;CACvC,MAAM,WAAW,SAAS,SAAS;CACnC,MAAM,OAAO,cAAc,SAAS;CAGpC,MAAM,OAAO,MAAM,WAAW,QAAQ;EACpC;EACA;EACA;EACA;EACA,WAPgB,OAAO,SAAS,IAAI;EAQrC,CAAC;CAEF,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAC1C,MAAM,aAAa,iBAAiB,SAAS;CAC7C,MAAM,EAAE,yEACN,MAAM,OAAO;AAQf,QAAO;EAAE;EAAM,gBANQ,WACrB,QACA;GAAE,IAAI,KAAK;GAAI;GAAW;GAAM,EAChCA,mCAAiC,WAAW,CAC7C;EAE8B"}
|
|
@@ -0,0 +1,74 @@
|
|
|
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/caption-file.ts
|
|
8
|
+
const log = (0, debug.default)("ef:api:caption-file");
|
|
9
|
+
const MAX_CAPTION_SIZE = 1024 * 1024 * 2;
|
|
10
|
+
const CreateCaptionFilePayload = zod.z.object({
|
|
11
|
+
md5: zod.z.string(),
|
|
12
|
+
filename: zod.z.string(),
|
|
13
|
+
byte_size: zod.z.number().int().max(MAX_CAPTION_SIZE)
|
|
14
|
+
});
|
|
15
|
+
const restrictSize = (size) => {
|
|
16
|
+
if (size > MAX_CAPTION_SIZE) throw new Error(`File size ${size} bytes exceeds limit ${MAX_CAPTION_SIZE} bytes\n`);
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Create a caption file
|
|
20
|
+
* @param client - The authenticated client to use for the request
|
|
21
|
+
* @param payload - The payload to send to the server
|
|
22
|
+
* @returns The result of the request
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const result = await createCaptionFile(client, {
|
|
26
|
+
* id: "123",
|
|
27
|
+
* filename: "caption.srt",
|
|
28
|
+
* });
|
|
29
|
+
* console.log(result);
|
|
30
|
+
* ```
|
|
31
|
+
* @category CaptionFile
|
|
32
|
+
* @resource
|
|
33
|
+
* @beta
|
|
34
|
+
* @deprecated Use the unified file API from ./file.js instead
|
|
35
|
+
*/
|
|
36
|
+
const createCaptionFile = async (client, payload) => {
|
|
37
|
+
log("Creating caption file", payload);
|
|
38
|
+
restrictSize(payload.byte_size);
|
|
39
|
+
const response = await client.authenticatedFetch("/api/v1/caption_files", {
|
|
40
|
+
method: "POST",
|
|
41
|
+
body: JSON.stringify(payload)
|
|
42
|
+
});
|
|
43
|
+
log("Caption file created", response);
|
|
44
|
+
if (response.ok) return await response.json();
|
|
45
|
+
throw new Error(`Failed to create caption ${response.status} ${response.statusText}`);
|
|
46
|
+
};
|
|
47
|
+
/** @deprecated Use the unified file API from ./file.js instead */
|
|
48
|
+
const uploadCaptionFile = async (client, fileId, fileStream, fileSize) => {
|
|
49
|
+
log("Uploading caption file", fileId);
|
|
50
|
+
restrictSize(fileSize);
|
|
51
|
+
const response = await client.authenticatedFetch(`/api/v1/caption_files/${fileId}/upload`, {
|
|
52
|
+
method: "POST",
|
|
53
|
+
body: fileStream,
|
|
54
|
+
duplex: "half"
|
|
55
|
+
});
|
|
56
|
+
log("Caption file uploaded", response);
|
|
57
|
+
if (response.ok) return response.json();
|
|
58
|
+
throw new Error(`Failed to upload caption ${response.status} ${response.statusText}`);
|
|
59
|
+
};
|
|
60
|
+
/** @deprecated Use the unified file API from ./file.js instead */
|
|
61
|
+
const lookupCaptionFileByMd5 = async (client, md5) => {
|
|
62
|
+
const response = await client.authenticatedFetch(`/api/v1/caption_files/md5/${md5}`, { method: "GET" });
|
|
63
|
+
log("Caption file lookup", response);
|
|
64
|
+
if (response.ok) return await response.json();
|
|
65
|
+
if (response.status === 404) return null;
|
|
66
|
+
throw new Error(`Failed to lookup caption by md5 ${md5} ${response.status} ${response.statusText}`);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
exports.CreateCaptionFilePayload = CreateCaptionFilePayload;
|
|
71
|
+
exports.createCaptionFile = createCaptionFile;
|
|
72
|
+
exports.lookupCaptionFileByMd5 = lookupCaptionFileByMd5;
|
|
73
|
+
exports.uploadCaptionFile = uploadCaptionFile;
|
|
74
|
+
//# sourceMappingURL=caption-file.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caption-file.cjs","names":["z"],"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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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 * @deprecated Use the unified file API from ./file.js instead\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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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,yBAAY,sBAAsB;AAExC,MAAM,mBAAmB,OAAO,OAAO;AAEvC,MAAa,2BAA2BA,MAAE,OAAO;CAI/C,KAAKA,MAAE,QAAQ;CAIf,UAAUA,MAAE,QAAQ;CAIpB,WAAWA,MAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,iBAAiB;CAClD,CAAC;AAoCF,MAAM,gBAAgB,SAAiB;AACrC,KAAI,OAAO,iBACT,OAAM,IAAI,MACR,aAAa,KAAK,uBAAuB,iBAAiB,UAC3D;;;;;;;;;;;;;;;;;;;;AAsBL,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;;;AAIH,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;;;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,mCAAmC,IAAI,GAAG,SAAS,OAAO,GAAG,SAAS,aACvE"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Client } from "../client.cjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/resources/caption-file.d.ts
|
|
5
|
+
declare const CreateCaptionFilePayload: z.ZodObject<{
|
|
6
|
+
/**
|
|
7
|
+
* The md5 hash of the caption file
|
|
8
|
+
*/
|
|
9
|
+
md5: z.ZodString;
|
|
10
|
+
/**
|
|
11
|
+
* The filename of the caption file
|
|
12
|
+
*/
|
|
13
|
+
filename: z.ZodString;
|
|
14
|
+
/**
|
|
15
|
+
* The size of the caption file in bytes
|
|
16
|
+
*/
|
|
17
|
+
byte_size: z.ZodNumber;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
md5: string;
|
|
20
|
+
filename: string;
|
|
21
|
+
byte_size: number;
|
|
22
|
+
}, {
|
|
23
|
+
md5: string;
|
|
24
|
+
filename: string;
|
|
25
|
+
byte_size: number;
|
|
26
|
+
}>;
|
|
27
|
+
type CreateCaptionFilePayload = z.infer<typeof CreateCaptionFilePayload>;
|
|
28
|
+
/** @deprecated Use the unified file API from ./file.js instead */
|
|
29
|
+
interface CreateCaptionFileResult {
|
|
30
|
+
/**
|
|
31
|
+
* Whether the caption file is complete
|
|
32
|
+
*/
|
|
33
|
+
complete: boolean | null;
|
|
34
|
+
/**
|
|
35
|
+
* The id of the caption file
|
|
36
|
+
*/
|
|
37
|
+
id: string;
|
|
38
|
+
/**
|
|
39
|
+
* The md5 hash of the caption file
|
|
40
|
+
*/
|
|
41
|
+
md5: string;
|
|
42
|
+
}
|
|
43
|
+
/** @deprecated Use the unified file API from ./file.js instead */
|
|
44
|
+
interface LookupCaptionFileByMd5Result {
|
|
45
|
+
/**
|
|
46
|
+
* Whether the caption file is complete
|
|
47
|
+
*/
|
|
48
|
+
complete: boolean | null;
|
|
49
|
+
/**
|
|
50
|
+
* The id of the caption file
|
|
51
|
+
*/
|
|
52
|
+
id: string;
|
|
53
|
+
/**
|
|
54
|
+
* The md5 hash of the caption file
|
|
55
|
+
*/
|
|
56
|
+
md5: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a caption file
|
|
60
|
+
* @param client - The authenticated client to use for the request
|
|
61
|
+
* @param payload - The payload to send to the server
|
|
62
|
+
* @returns The result of the request
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const result = await createCaptionFile(client, {
|
|
66
|
+
* id: "123",
|
|
67
|
+
* filename: "caption.srt",
|
|
68
|
+
* });
|
|
69
|
+
* console.log(result);
|
|
70
|
+
* ```
|
|
71
|
+
* @category CaptionFile
|
|
72
|
+
* @resource
|
|
73
|
+
* @beta
|
|
74
|
+
* @deprecated Use the unified file API from ./file.js instead
|
|
75
|
+
*/
|
|
76
|
+
declare const createCaptionFile: (client: Client, payload: CreateCaptionFilePayload) => Promise<CreateCaptionFileResult>;
|
|
77
|
+
/** @deprecated Use the unified file API from ./file.js instead */
|
|
78
|
+
declare const uploadCaptionFile: (client: Client, fileId: string, fileStream: ReadableStream, fileSize: number) => Promise<any>;
|
|
79
|
+
/** @deprecated Use the unified file API from ./file.js instead */
|
|
80
|
+
declare const lookupCaptionFileByMd5: (client: Client, md5: string) => Promise<LookupCaptionFileByMd5Result | null>;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { CreateCaptionFilePayload, CreateCaptionFileResult, LookupCaptionFileByMd5Result, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile };
|
|
83
|
+
//# sourceMappingURL=caption-file.d.cts.map
|
|
@@ -25,6 +25,7 @@ declare const CreateCaptionFilePayload: z.ZodObject<{
|
|
|
25
25
|
byte_size: number;
|
|
26
26
|
}>;
|
|
27
27
|
type CreateCaptionFilePayload = z.infer<typeof CreateCaptionFilePayload>;
|
|
28
|
+
/** @deprecated Use the unified file API from ./file.js instead */
|
|
28
29
|
interface CreateCaptionFileResult {
|
|
29
30
|
/**
|
|
30
31
|
* Whether the caption file is complete
|
|
@@ -39,6 +40,7 @@ interface CreateCaptionFileResult {
|
|
|
39
40
|
*/
|
|
40
41
|
md5: string;
|
|
41
42
|
}
|
|
43
|
+
/** @deprecated Use the unified file API from ./file.js instead */
|
|
42
44
|
interface LookupCaptionFileByMd5Result {
|
|
43
45
|
/**
|
|
44
46
|
* Whether the caption file is complete
|
|
@@ -69,9 +71,12 @@ interface LookupCaptionFileByMd5Result {
|
|
|
69
71
|
* @category CaptionFile
|
|
70
72
|
* @resource
|
|
71
73
|
* @beta
|
|
74
|
+
* @deprecated Use the unified file API from ./file.js instead
|
|
72
75
|
*/
|
|
73
76
|
declare const createCaptionFile: (client: Client, payload: CreateCaptionFilePayload) => Promise<CreateCaptionFileResult>;
|
|
77
|
+
/** @deprecated Use the unified file API from ./file.js instead */
|
|
74
78
|
declare const uploadCaptionFile: (client: Client, fileId: string, fileStream: ReadableStream, fileSize: number) => Promise<any>;
|
|
79
|
+
/** @deprecated Use the unified file API from ./file.js instead */
|
|
75
80
|
declare const lookupCaptionFileByMd5: (client: Client, md5: string) => Promise<LookupCaptionFileByMd5Result | null>;
|
|
76
81
|
//#endregion
|
|
77
82
|
export { CreateCaptionFilePayload, CreateCaptionFileResult, LookupCaptionFileByMd5Result, createCaptionFile, lookupCaptionFileByMd5, uploadCaptionFile };
|
|
@@ -28,6 +28,7 @@ const restrictSize = (size) => {
|
|
|
28
28
|
* @category CaptionFile
|
|
29
29
|
* @resource
|
|
30
30
|
* @beta
|
|
31
|
+
* @deprecated Use the unified file API from ./file.js instead
|
|
31
32
|
*/
|
|
32
33
|
const createCaptionFile = async (client, payload) => {
|
|
33
34
|
log("Creating caption file", payload);
|
|
@@ -40,6 +41,7 @@ const createCaptionFile = async (client, payload) => {
|
|
|
40
41
|
if (response.ok) return await response.json();
|
|
41
42
|
throw new Error(`Failed to create caption ${response.status} ${response.statusText}`);
|
|
42
43
|
};
|
|
44
|
+
/** @deprecated Use the unified file API from ./file.js instead */
|
|
43
45
|
const uploadCaptionFile = async (client, fileId, fileStream, fileSize) => {
|
|
44
46
|
log("Uploading caption file", fileId);
|
|
45
47
|
restrictSize(fileSize);
|
|
@@ -52,6 +54,7 @@ const uploadCaptionFile = async (client, fileId, fileStream, fileSize) => {
|
|
|
52
54
|
if (response.ok) return response.json();
|
|
53
55
|
throw new Error(`Failed to upload caption ${response.status} ${response.statusText}`);
|
|
54
56
|
};
|
|
57
|
+
/** @deprecated Use the unified file API from ./file.js instead */
|
|
55
58
|
const lookupCaptionFileByMd5 = async (client, md5) => {
|
|
56
59
|
const response = await client.authenticatedFetch(`/api/v1/caption_files/md5/${md5}`, { method: "GET" });
|
|
57
60
|
log("Caption file lookup", response);
|
|
@@ -1 +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;
|
|
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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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 * @deprecated Use the unified file API from ./file.js instead\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\n/** @deprecated Use the unified file API from ./file.js instead */\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\n/** @deprecated Use the unified file API from ./file.js instead */\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;AAoCF,MAAM,gBAAgB,SAAiB;AACrC,KAAI,OAAO,iBACT,OAAM,IAAI,MACR,aAAa,KAAK,uBAAuB,iBAAiB,UAC3D;;;;;;;;;;;;;;;;;;;;AAsBL,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;;;AAIH,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;;;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,mCAAmC,IAAI,GAAG,SAAS,OAAO,GAAG,SAAS,aACvE"}
|