transloadit 3.0.2 → 4.0.0-4
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/CHANGELOG.md +9 -12
- package/README.md +175 -129
- package/dist/ApiError.d.ts +20 -0
- package/dist/ApiError.d.ts.map +1 -0
- package/dist/ApiError.js +35 -0
- package/dist/ApiError.js.map +1 -0
- package/dist/InconsistentResponseError.d.ts +4 -0
- package/dist/InconsistentResponseError.d.ts.map +1 -0
- package/dist/InconsistentResponseError.js +7 -0
- package/dist/InconsistentResponseError.js.map +1 -0
- package/dist/PaginationStream.d.ts +14 -0
- package/dist/PaginationStream.d.ts.map +1 -0
- package/dist/PaginationStream.js +39 -0
- package/dist/PaginationStream.js.map +1 -0
- package/dist/PollingTimeoutError.d.ts +5 -0
- package/dist/PollingTimeoutError.d.ts.map +1 -0
- package/dist/PollingTimeoutError.js +8 -0
- package/dist/PollingTimeoutError.js.map +1 -0
- package/dist/Transloadit.d.ts +227 -0
- package/dist/Transloadit.d.ts.map +1 -0
- package/dist/Transloadit.js +628 -0
- package/dist/Transloadit.js.map +1 -0
- package/dist/alphalib/types/assemblyStatus.d.ts +6208 -0
- package/dist/alphalib/types/assemblyStatus.d.ts.map +1 -0
- package/dist/alphalib/types/assemblyStatus.js +285 -0
- package/dist/alphalib/types/assemblyStatus.js.map +1 -0
- package/dist/alphalib/types/robots/_index.d.ts +56966 -0
- package/dist/alphalib/types/robots/_index.d.ts.map +1 -0
- package/dist/alphalib/types/robots/_index.js +347 -0
- package/dist/alphalib/types/robots/_index.js.map +1 -0
- package/dist/alphalib/types/robots/_instructions-primitives.d.ts +2157 -0
- package/dist/alphalib/types/robots/_instructions-primitives.d.ts.map +1 -0
- package/dist/alphalib/types/robots/_instructions-primitives.js +655 -0
- package/dist/alphalib/types/robots/_instructions-primitives.js.map +1 -0
- package/dist/alphalib/types/robots/audio-artwork.d.ts +628 -0
- package/dist/alphalib/types/robots/audio-artwork.d.ts.map +1 -0
- package/dist/alphalib/types/robots/audio-artwork.js +55 -0
- package/dist/alphalib/types/robots/audio-artwork.js.map +1 -0
- package/dist/alphalib/types/robots/audio-concat.d.ts +632 -0
- package/dist/alphalib/types/robots/audio-concat.d.ts.map +1 -0
- package/dist/alphalib/types/robots/audio-concat.js +66 -0
- package/dist/alphalib/types/robots/audio-concat.js.map +1 -0
- package/dist/alphalib/types/robots/audio-encode.d.ts +629 -0
- package/dist/alphalib/types/robots/audio-encode.d.ts.map +1 -0
- package/dist/alphalib/types/robots/audio-encode.js +55 -0
- package/dist/alphalib/types/robots/audio-encode.js.map +1 -0
- package/dist/alphalib/types/robots/audio-loop.d.ts +631 -0
- package/dist/alphalib/types/robots/audio-loop.d.ts.map +1 -0
- package/dist/alphalib/types/robots/audio-loop.js +54 -0
- package/dist/alphalib/types/robots/audio-loop.js.map +1 -0
- package/dist/alphalib/types/robots/audio-merge.d.ts +637 -0
- package/dist/alphalib/types/robots/audio-merge.d.ts.map +1 -0
- package/dist/alphalib/types/robots/audio-merge.js +65 -0
- package/dist/alphalib/types/robots/audio-merge.js.map +1 -0
- package/dist/alphalib/types/robots/audio-waveform.d.ts +642 -0
- package/dist/alphalib/types/robots/audio-waveform.d.ts.map +1 -0
- package/dist/alphalib/types/robots/audio-waveform.js +80 -0
- package/dist/alphalib/types/robots/audio-waveform.js.map +1 -0
- package/dist/alphalib/types/robots/azure-import.d.ts +46 -0
- package/dist/alphalib/types/robots/azure-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/azure-import.js +58 -0
- package/dist/alphalib/types/robots/azure-import.js.map +1 -0
- package/dist/alphalib/types/robots/azure-store.d.ts +129 -0
- package/dist/alphalib/types/robots/azure-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/azure-store.js +73 -0
- package/dist/alphalib/types/robots/azure-store.js.map +1 -0
- package/dist/alphalib/types/robots/backblaze-import.d.ts +49 -0
- package/dist/alphalib/types/robots/backblaze-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/backblaze-import.js +66 -0
- package/dist/alphalib/types/robots/backblaze-import.js.map +1 -0
- package/dist/alphalib/types/robots/backblaze-store.d.ts +111 -0
- package/dist/alphalib/types/robots/backblaze-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/backblaze-store.js +58 -0
- package/dist/alphalib/types/robots/backblaze-store.js.map +1 -0
- package/dist/alphalib/types/robots/cloudfiles-import.d.ts +55 -0
- package/dist/alphalib/types/robots/cloudfiles-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/cloudfiles-import.js +65 -0
- package/dist/alphalib/types/robots/cloudfiles-import.js.map +1 -0
- package/dist/alphalib/types/robots/cloudfiles-store.d.ts +114 -0
- package/dist/alphalib/types/robots/cloudfiles-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/cloudfiles-store.js +56 -0
- package/dist/alphalib/types/robots/cloudfiles-store.js.map +1 -0
- package/dist/alphalib/types/robots/cloudflare-import.d.ts +52 -0
- package/dist/alphalib/types/robots/cloudflare-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/cloudflare-import.js +68 -0
- package/dist/alphalib/types/robots/cloudflare-import.js.map +1 -0
- package/dist/alphalib/types/robots/cloudflare-store.d.ts +117 -0
- package/dist/alphalib/types/robots/cloudflare-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/cloudflare-store.js +57 -0
- package/dist/alphalib/types/robots/cloudflare-store.js.map +1 -0
- package/dist/alphalib/types/robots/digitalocean-import.d.ts +52 -0
- package/dist/alphalib/types/robots/digitalocean-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/digitalocean-import.js +65 -0
- package/dist/alphalib/types/robots/digitalocean-import.js.map +1 -0
- package/dist/alphalib/types/robots/digitalocean-store.d.ts +123 -0
- package/dist/alphalib/types/robots/digitalocean-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/digitalocean-store.js +62 -0
- package/dist/alphalib/types/robots/digitalocean-store.js.map +1 -0
- package/dist/alphalib/types/robots/document-autorotate.d.ts +91 -0
- package/dist/alphalib/types/robots/document-autorotate.d.ts.map +1 -0
- package/dist/alphalib/types/robots/document-autorotate.js +31 -0
- package/dist/alphalib/types/robots/document-autorotate.js.map +1 -0
- package/dist/alphalib/types/robots/document-convert.d.ts +118 -0
- package/dist/alphalib/types/robots/document-convert.d.ts.map +1 -0
- package/dist/alphalib/types/robots/document-convert.js +182 -0
- package/dist/alphalib/types/robots/document-convert.js.map +1 -0
- package/dist/alphalib/types/robots/document-merge.d.ts +97 -0
- package/dist/alphalib/types/robots/document-merge.d.ts.map +1 -0
- package/dist/alphalib/types/robots/document-merge.js +66 -0
- package/dist/alphalib/types/robots/document-merge.js.map +1 -0
- package/dist/alphalib/types/robots/document-ocr.d.ts +100 -0
- package/dist/alphalib/types/robots/document-ocr.d.ts.map +1 -0
- package/dist/alphalib/types/robots/document-ocr.js +65 -0
- package/dist/alphalib/types/robots/document-ocr.js.map +1 -0
- package/dist/alphalib/types/robots/document-split.d.ts +94 -0
- package/dist/alphalib/types/robots/document-split.d.ts.map +1 -0
- package/dist/alphalib/types/robots/document-split.js +34 -0
- package/dist/alphalib/types/robots/document-split.js.map +1 -0
- package/dist/alphalib/types/robots/document-thumbs.d.ts +134 -0
- package/dist/alphalib/types/robots/document-thumbs.d.ts.map +1 -0
- package/dist/alphalib/types/robots/document-thumbs.js +111 -0
- package/dist/alphalib/types/robots/document-thumbs.js.map +1 -0
- package/dist/alphalib/types/robots/dropbox-import.d.ts +43 -0
- package/dist/alphalib/types/robots/dropbox-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/dropbox-import.js +52 -0
- package/dist/alphalib/types/robots/dropbox-import.js.map +1 -0
- package/dist/alphalib/types/robots/dropbox-store.d.ts +114 -0
- package/dist/alphalib/types/robots/dropbox-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/dropbox-store.js +49 -0
- package/dist/alphalib/types/robots/dropbox-store.js.map +1 -0
- package/dist/alphalib/types/robots/edgly-deliver.d.ts +19 -0
- package/dist/alphalib/types/robots/edgly-deliver.d.ts.map +1 -0
- package/dist/alphalib/types/robots/edgly-deliver.js +31 -0
- package/dist/alphalib/types/robots/edgly-deliver.js.map +1 -0
- package/dist/alphalib/types/robots/file-compress.d.ts +106 -0
- package/dist/alphalib/types/robots/file-compress.d.ts.map +1 -0
- package/dist/alphalib/types/robots/file-compress.js +102 -0
- package/dist/alphalib/types/robots/file-compress.js.map +1 -0
- package/dist/alphalib/types/robots/file-decompress.d.ts +94 -0
- package/dist/alphalib/types/robots/file-decompress.d.ts.map +1 -0
- package/dist/alphalib/types/robots/file-decompress.js +81 -0
- package/dist/alphalib/types/robots/file-decompress.js.map +1 -0
- package/dist/alphalib/types/robots/file-filter.d.ts +107 -0
- package/dist/alphalib/types/robots/file-filter.d.ts.map +1 -0
- package/dist/alphalib/types/robots/file-filter.js +108 -0
- package/dist/alphalib/types/robots/file-filter.js.map +1 -0
- package/dist/alphalib/types/robots/file-hash.d.ts +94 -0
- package/dist/alphalib/types/robots/file-hash.d.ts.map +1 -0
- package/dist/alphalib/types/robots/file-hash.js +49 -0
- package/dist/alphalib/types/robots/file-hash.js.map +1 -0
- package/dist/alphalib/types/robots/file-preview.d.ts +393 -0
- package/dist/alphalib/types/robots/file-preview.d.ts.map +1 -0
- package/dist/alphalib/types/robots/file-preview.js +155 -0
- package/dist/alphalib/types/robots/file-preview.js.map +1 -0
- package/dist/alphalib/types/robots/file-read.d.ts +91 -0
- package/dist/alphalib/types/robots/file-read.d.ts.map +1 -0
- package/dist/alphalib/types/robots/file-read.js +34 -0
- package/dist/alphalib/types/robots/file-read.js.map +1 -0
- package/dist/alphalib/types/robots/file-serve.d.ts +95 -0
- package/dist/alphalib/types/robots/file-serve.d.ts.map +1 -0
- package/dist/alphalib/types/robots/file-serve.js +56 -0
- package/dist/alphalib/types/robots/file-serve.js.map +1 -0
- package/dist/alphalib/types/robots/file-verify.d.ts +100 -0
- package/dist/alphalib/types/robots/file-verify.d.ts.map +1 -0
- package/dist/alphalib/types/robots/file-verify.js +52 -0
- package/dist/alphalib/types/robots/file-verify.js.map +1 -0
- package/dist/alphalib/types/robots/file-virusscan.d.ts +97 -0
- package/dist/alphalib/types/robots/file-virusscan.d.ts.map +1 -0
- package/dist/alphalib/types/robots/file-virusscan.js +55 -0
- package/dist/alphalib/types/robots/file-virusscan.js.map +1 -0
- package/dist/alphalib/types/robots/file-watermark.d.ts +92 -0
- package/dist/alphalib/types/robots/file-watermark.d.ts.map +1 -0
- package/dist/alphalib/types/robots/file-watermark.js +13 -0
- package/dist/alphalib/types/robots/file-watermark.js.map +1 -0
- package/dist/alphalib/types/robots/ftp-import.d.ts +46 -0
- package/dist/alphalib/types/robots/ftp-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/ftp-import.js +47 -0
- package/dist/alphalib/types/robots/ftp-import.js.map +1 -0
- package/dist/alphalib/types/robots/ftp-store.d.ts +120 -0
- package/dist/alphalib/types/robots/ftp-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/ftp-store.js +57 -0
- package/dist/alphalib/types/robots/ftp-store.js.map +1 -0
- package/dist/alphalib/types/robots/google-import.d.ts +40 -0
- package/dist/alphalib/types/robots/google-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/google-import.js +65 -0
- package/dist/alphalib/types/robots/google-import.js.map +1 -0
- package/dist/alphalib/types/robots/google-store.d.ts +113 -0
- package/dist/alphalib/types/robots/google-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/google-store.js +86 -0
- package/dist/alphalib/types/robots/google-store.js.map +1 -0
- package/dist/alphalib/types/robots/html-convert.d.ts +115 -0
- package/dist/alphalib/types/robots/html-convert.d.ts.map +1 -0
- package/dist/alphalib/types/robots/html-convert.js +81 -0
- package/dist/alphalib/types/robots/html-convert.js.map +1 -0
- package/dist/alphalib/types/robots/http-import.d.ts +42 -0
- package/dist/alphalib/types/robots/http-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/http-import.js +76 -0
- package/dist/alphalib/types/robots/http-import.js.map +1 -0
- package/dist/alphalib/types/robots/image-describe.d.ts +103 -0
- package/dist/alphalib/types/robots/image-describe.d.ts.map +1 -0
- package/dist/alphalib/types/robots/image-describe.js +66 -0
- package/dist/alphalib/types/robots/image-describe.js.map +1 -0
- package/dist/alphalib/types/robots/image-facedetect.d.ts +109 -0
- package/dist/alphalib/types/robots/image-facedetect.d.ts.map +1 -0
- package/dist/alphalib/types/robots/image-facedetect.js +125 -0
- package/dist/alphalib/types/robots/image-facedetect.js.map +1 -0
- package/dist/alphalib/types/robots/image-generate.d.ts +229 -0
- package/dist/alphalib/types/robots/image-generate.d.ts.map +1 -0
- package/dist/alphalib/types/robots/image-generate.js +27 -0
- package/dist/alphalib/types/robots/image-generate.js.map +1 -0
- package/dist/alphalib/types/robots/image-merge.d.ts +109 -0
- package/dist/alphalib/types/robots/image-merge.d.ts.map +1 -0
- package/dist/alphalib/types/robots/image-merge.js +74 -0
- package/dist/alphalib/types/robots/image-merge.js.map +1 -0
- package/dist/alphalib/types/robots/image-ocr.d.ts +100 -0
- package/dist/alphalib/types/robots/image-ocr.d.ts.map +1 -0
- package/dist/alphalib/types/robots/image-ocr.js +64 -0
- package/dist/alphalib/types/robots/image-ocr.js.map +1 -0
- package/dist/alphalib/types/robots/image-optimize.d.ts +103 -0
- package/dist/alphalib/types/robots/image-optimize.d.ts.map +1 -0
- package/dist/alphalib/types/robots/image-optimize.js +60 -0
- package/dist/alphalib/types/robots/image-optimize.js.map +1 -0
- package/dist/alphalib/types/robots/image-remove-background.d.ts +98 -0
- package/dist/alphalib/types/robots/image-remove-background.d.ts.map +1 -0
- package/dist/alphalib/types/robots/image-remove-background.js +21 -0
- package/dist/alphalib/types/robots/image-remove-background.js.map +1 -0
- package/dist/alphalib/types/robots/image-resize.d.ts +696 -0
- package/dist/alphalib/types/robots/image-resize.d.ts.map +1 -0
- package/dist/alphalib/types/robots/image-resize.js +364 -0
- package/dist/alphalib/types/robots/image-resize.js.map +1 -0
- package/dist/alphalib/types/robots/media-playlist.d.ts +115 -0
- package/dist/alphalib/types/robots/media-playlist.d.ts.map +1 -0
- package/dist/alphalib/types/robots/media-playlist.js +56 -0
- package/dist/alphalib/types/robots/media-playlist.js.map +1 -0
- package/dist/alphalib/types/robots/meta-write.d.ts +623 -0
- package/dist/alphalib/types/robots/meta-write.d.ts.map +1 -0
- package/dist/alphalib/types/robots/meta-write.js +53 -0
- package/dist/alphalib/types/robots/meta-write.js.map +1 -0
- package/dist/alphalib/types/robots/minio-import.d.ts +52 -0
- package/dist/alphalib/types/robots/minio-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/minio-import.js +68 -0
- package/dist/alphalib/types/robots/minio-import.js.map +1 -0
- package/dist/alphalib/types/robots/minio-store.d.ts +120 -0
- package/dist/alphalib/types/robots/minio-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/minio-store.js +61 -0
- package/dist/alphalib/types/robots/minio-store.js.map +1 -0
- package/dist/alphalib/types/robots/progress-simulate.d.ts +29 -0
- package/dist/alphalib/types/robots/progress-simulate.d.ts.map +1 -0
- package/dist/alphalib/types/robots/progress-simulate.js +15 -0
- package/dist/alphalib/types/robots/progress-simulate.js.map +1 -0
- package/dist/alphalib/types/robots/s3-import.d.ts +52 -0
- package/dist/alphalib/types/robots/s3-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/s3-import.js +104 -0
- package/dist/alphalib/types/robots/s3-import.js.map +1 -0
- package/dist/alphalib/types/robots/s3-store.d.ts +135 -0
- package/dist/alphalib/types/robots/s3-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/s3-store.js +118 -0
- package/dist/alphalib/types/robots/s3-store.js.map +1 -0
- package/dist/alphalib/types/robots/script-run.d.ts +94 -0
- package/dist/alphalib/types/robots/script-run.d.ts.map +1 -0
- package/dist/alphalib/types/robots/script-run.js +79 -0
- package/dist/alphalib/types/robots/script-run.js.map +1 -0
- package/dist/alphalib/types/robots/sftp-import.d.ts +43 -0
- package/dist/alphalib/types/robots/sftp-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/sftp-import.js +45 -0
- package/dist/alphalib/types/robots/sftp-import.js.map +1 -0
- package/dist/alphalib/types/robots/sftp-store.d.ts +120 -0
- package/dist/alphalib/types/robots/sftp-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/sftp-store.js +58 -0
- package/dist/alphalib/types/robots/sftp-store.js.map +1 -0
- package/dist/alphalib/types/robots/speech-transcribe.d.ts +210 -0
- package/dist/alphalib/types/robots/speech-transcribe.d.ts.map +1 -0
- package/dist/alphalib/types/robots/speech-transcribe.js +80 -0
- package/dist/alphalib/types/robots/speech-transcribe.js.map +1 -0
- package/dist/alphalib/types/robots/supabase-import.d.ts +52 -0
- package/dist/alphalib/types/robots/supabase-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/supabase-import.js +70 -0
- package/dist/alphalib/types/robots/supabase-import.js.map +1 -0
- package/dist/alphalib/types/robots/supabase-store.d.ts +117 -0
- package/dist/alphalib/types/robots/supabase-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/supabase-store.js +54 -0
- package/dist/alphalib/types/robots/supabase-store.js.map +1 -0
- package/dist/alphalib/types/robots/swift-import.d.ts +52 -0
- package/dist/alphalib/types/robots/swift-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/swift-import.js +68 -0
- package/dist/alphalib/types/robots/swift-import.js.map +1 -0
- package/dist/alphalib/types/robots/swift-store.d.ts +120 -0
- package/dist/alphalib/types/robots/swift-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/swift-store.js +58 -0
- package/dist/alphalib/types/robots/swift-store.js.map +1 -0
- package/dist/alphalib/types/robots/text-speak.d.ts +106 -0
- package/dist/alphalib/types/robots/text-speak.d.ts.map +1 -0
- package/dist/alphalib/types/robots/text-speak.js +97 -0
- package/dist/alphalib/types/robots/text-speak.js.map +1 -0
- package/dist/alphalib/types/robots/text-translate.d.ts +100 -0
- package/dist/alphalib/types/robots/text-translate.d.ts.map +1 -0
- package/dist/alphalib/types/robots/text-translate.js +196 -0
- package/dist/alphalib/types/robots/text-translate.js.map +1 -0
- package/dist/alphalib/types/robots/tigris-import.d.ts +52 -0
- package/dist/alphalib/types/robots/tigris-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/tigris-import.js +68 -0
- package/dist/alphalib/types/robots/tigris-import.js.map +1 -0
- package/dist/alphalib/types/robots/tigris-store.d.ts +120 -0
- package/dist/alphalib/types/robots/tigris-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/tigris-store.js +61 -0
- package/dist/alphalib/types/robots/tigris-store.js.map +1 -0
- package/dist/alphalib/types/robots/tlcdn-deliver.d.ts +19 -0
- package/dist/alphalib/types/robots/tlcdn-deliver.d.ts.map +1 -0
- package/dist/alphalib/types/robots/tlcdn-deliver.js +31 -0
- package/dist/alphalib/types/robots/tlcdn-deliver.js.map +1 -0
- package/dist/alphalib/types/robots/tus-store.d.ts +110 -0
- package/dist/alphalib/types/robots/tus-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/tus-store.js +74 -0
- package/dist/alphalib/types/robots/tus-store.js.map +1 -0
- package/dist/alphalib/types/robots/upload-handle.d.ts +92 -0
- package/dist/alphalib/types/robots/upload-handle.d.ts.map +1 -0
- package/dist/alphalib/types/robots/upload-handle.js +54 -0
- package/dist/alphalib/types/robots/upload-handle.js.map +1 -0
- package/dist/alphalib/types/robots/video-adaptive.d.ts +640 -0
- package/dist/alphalib/types/robots/video-adaptive.d.ts.map +1 -0
- package/dist/alphalib/types/robots/video-adaptive.js +119 -0
- package/dist/alphalib/types/robots/video-adaptive.js.map +1 -0
- package/dist/alphalib/types/robots/video-concat.d.ts +634 -0
- package/dist/alphalib/types/robots/video-concat.d.ts.map +1 -0
- package/dist/alphalib/types/robots/video-concat.js +65 -0
- package/dist/alphalib/types/robots/video-concat.js.map +1 -0
- package/dist/alphalib/types/robots/video-encode.d.ts +1439 -0
- package/dist/alphalib/types/robots/video-encode.d.ts.map +1 -0
- package/dist/alphalib/types/robots/video-encode.js +157 -0
- package/dist/alphalib/types/robots/video-encode.js.map +1 -0
- package/dist/alphalib/types/robots/video-merge.d.ts +655 -0
- package/dist/alphalib/types/robots/video-merge.d.ts.map +1 -0
- package/dist/alphalib/types/robots/video-merge.js +64 -0
- package/dist/alphalib/types/robots/video-merge.js.map +1 -0
- package/dist/alphalib/types/robots/video-subtitle.d.ts +649 -0
- package/dist/alphalib/types/robots/video-subtitle.d.ts.map +1 -0
- package/dist/alphalib/types/robots/video-subtitle.js +77 -0
- package/dist/alphalib/types/robots/video-subtitle.js.map +1 -0
- package/dist/alphalib/types/robots/video-thumbs.d.ts +642 -0
- package/dist/alphalib/types/robots/video-thumbs.d.ts.map +1 -0
- package/dist/alphalib/types/robots/video-thumbs.js +79 -0
- package/dist/alphalib/types/robots/video-thumbs.js.map +1 -0
- package/dist/alphalib/types/robots/vimeo-store.d.ts +116 -0
- package/dist/alphalib/types/robots/vimeo-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/vimeo-store.js +81 -0
- package/dist/alphalib/types/robots/vimeo-store.js.map +1 -0
- package/dist/alphalib/types/robots/wasabi-import.d.ts +53 -0
- package/dist/alphalib/types/robots/wasabi-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/wasabi-import.js +72 -0
- package/dist/alphalib/types/robots/wasabi-import.js.map +1 -0
- package/dist/alphalib/types/robots/wasabi-store.d.ts +120 -0
- package/dist/alphalib/types/robots/wasabi-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/wasabi-store.js +59 -0
- package/dist/alphalib/types/robots/wasabi-store.js.map +1 -0
- package/dist/alphalib/types/robots/youtube-store.d.ts +110 -0
- package/dist/alphalib/types/robots/youtube-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/youtube-store.js +105 -0
- package/dist/alphalib/types/robots/youtube-store.js.map +1 -0
- package/dist/alphalib/types/stackVersions.d.ts +13 -0
- package/dist/alphalib/types/stackVersions.d.ts.map +1 -0
- package/dist/alphalib/types/stackVersions.js +16 -0
- package/dist/alphalib/types/stackVersions.js.map +1 -0
- package/dist/alphalib/types/template.d.ts +77150 -0
- package/dist/alphalib/types/template.d.ts.map +1 -0
- package/dist/alphalib/types/template.js +49 -0
- package/dist/alphalib/types/template.js.map +1 -0
- package/dist/alphalib/zodParseWithContext.d.ts +18 -0
- package/dist/alphalib/zodParseWithContext.d.ts.map +1 -0
- package/dist/alphalib/zodParseWithContext.js +123 -0
- package/dist/alphalib/zodParseWithContext.js.map +1 -0
- package/dist/apiTypes.d.ts +127 -0
- package/dist/apiTypes.d.ts.map +1 -0
- package/dist/apiTypes.js +3 -0
- package/dist/apiTypes.js.map +1 -0
- package/dist/tus.d.ts +17 -0
- package/dist/tus.d.ts.map +1 -0
- package/dist/tus.js +88 -0
- package/dist/tus.js.map +1 -0
- package/package.json +58 -39
- package/src/ApiError.ts +44 -0
- package/src/InconsistentResponseError.ts +3 -0
- package/src/PaginationStream.ts +55 -0
- package/src/PollingTimeoutError.ts +5 -0
- package/src/Transloadit.ts +826 -0
- package/src/alphalib/types/assemblyStatus.ts +300 -0
- package/src/alphalib/types/robots/_index.ts +437 -0
- package/src/alphalib/types/robots/_instructions-primitives.ts +835 -0
- package/src/alphalib/types/robots/audio-artwork.ts +57 -0
- package/src/alphalib/types/robots/audio-concat.ts +74 -0
- package/src/alphalib/types/robots/audio-encode.ts +63 -0
- package/src/alphalib/types/robots/audio-loop.ts +62 -0
- package/src/alphalib/types/robots/audio-merge.ts +73 -0
- package/src/alphalib/types/robots/audio-waveform.ts +83 -0
- package/src/alphalib/types/robots/azure-import.ts +69 -0
- package/src/alphalib/types/robots/azure-store.ts +76 -0
- package/src/alphalib/types/robots/backblaze-import.ts +81 -0
- package/src/alphalib/types/robots/backblaze-store.ts +63 -0
- package/src/alphalib/types/robots/cloudfiles-import.ts +80 -0
- package/src/alphalib/types/robots/cloudfiles-store.ts +63 -0
- package/src/alphalib/types/robots/cloudflare-import.ts +84 -0
- package/src/alphalib/types/robots/cloudflare-store.ts +64 -0
- package/src/alphalib/types/robots/digitalocean-import.ts +81 -0
- package/src/alphalib/types/robots/digitalocean-store.ts +69 -0
- package/src/alphalib/types/robots/document-autorotate.ts +36 -0
- package/src/alphalib/types/robots/document-convert.ts +186 -0
- package/src/alphalib/types/robots/document-merge.ts +68 -0
- package/src/alphalib/types/robots/document-ocr.ts +72 -0
- package/src/alphalib/types/robots/document-split.ts +38 -0
- package/src/alphalib/types/robots/document-thumbs.ts +119 -0
- package/src/alphalib/types/robots/dropbox-import.ts +58 -0
- package/src/alphalib/types/robots/dropbox-store.ts +52 -0
- package/src/alphalib/types/robots/edgly-deliver.ts +32 -0
- package/src/alphalib/types/robots/file-compress.ts +104 -0
- package/src/alphalib/types/robots/file-decompress.ts +86 -0
- package/src/alphalib/types/robots/file-filter.ts +115 -0
- package/src/alphalib/types/robots/file-hash.ts +51 -0
- package/src/alphalib/types/robots/file-preview.ts +174 -0
- package/src/alphalib/types/robots/file-read.ts +36 -0
- package/src/alphalib/types/robots/file-serve.ts +60 -0
- package/src/alphalib/types/robots/file-verify.ts +55 -0
- package/src/alphalib/types/robots/file-virusscan.ts +60 -0
- package/src/alphalib/types/robots/file-watermark.ts +13 -0
- package/src/alphalib/types/robots/ftp-import.ts +52 -0
- package/src/alphalib/types/robots/ftp-store.ts +61 -0
- package/src/alphalib/types/robots/google-import.ts +77 -0
- package/src/alphalib/types/robots/google-store.ts +89 -0
- package/src/alphalib/types/robots/html-convert.ts +83 -0
- package/src/alphalib/types/robots/http-import.ts +79 -0
- package/src/alphalib/types/robots/image-describe.ts +74 -0
- package/src/alphalib/types/robots/image-facedetect.ts +131 -0
- package/src/alphalib/types/robots/image-generate.ts +32 -0
- package/src/alphalib/types/robots/image-merge.ts +81 -0
- package/src/alphalib/types/robots/image-ocr.ts +71 -0
- package/src/alphalib/types/robots/image-optimize.ts +61 -0
- package/src/alphalib/types/robots/image-remove-background.ts +23 -0
- package/src/alphalib/types/robots/image-resize.ts +401 -0
- package/src/alphalib/types/robots/media-playlist.ts +58 -0
- package/src/alphalib/types/robots/meta-write.ts +55 -0
- package/src/alphalib/types/robots/minio-import.ts +80 -0
- package/src/alphalib/types/robots/minio-store.ts +64 -0
- package/src/alphalib/types/robots/progress-simulate.ts +16 -0
- package/src/alphalib/types/robots/s3-import.ts +116 -0
- package/src/alphalib/types/robots/s3-store.ts +121 -0
- package/src/alphalib/types/robots/script-run.ts +81 -0
- package/src/alphalib/types/robots/sftp-import.ts +50 -0
- package/src/alphalib/types/robots/sftp-store.ts +61 -0
- package/src/alphalib/types/robots/speech-transcribe.ts +96 -0
- package/src/alphalib/types/robots/supabase-import.ts +84 -0
- package/src/alphalib/types/robots/supabase-store.ts +59 -0
- package/src/alphalib/types/robots/swift-import.ts +80 -0
- package/src/alphalib/types/robots/swift-store.ts +61 -0
- package/src/alphalib/types/robots/text-speak.ts +100 -0
- package/src/alphalib/types/robots/text-translate.ts +199 -0
- package/src/alphalib/types/robots/tigris-import.ts +80 -0
- package/src/alphalib/types/robots/tigris-store.ts +64 -0
- package/src/alphalib/types/robots/tlcdn-deliver.ts +32 -0
- package/src/alphalib/types/robots/tus-store.ts +77 -0
- package/src/alphalib/types/robots/upload-handle.ts +58 -0
- package/src/alphalib/types/robots/video-adaptive.ts +123 -0
- package/src/alphalib/types/robots/video-concat.ts +68 -0
- package/src/alphalib/types/robots/video-encode.ts +182 -0
- package/src/alphalib/types/robots/video-merge.ts +72 -0
- package/src/alphalib/types/robots/video-subtitle.ts +86 -0
- package/src/alphalib/types/robots/video-thumbs.ts +88 -0
- package/src/alphalib/types/robots/vimeo-store.ts +84 -0
- package/src/alphalib/types/robots/wasabi-import.ts +84 -0
- package/src/alphalib/types/robots/wasabi-store.ts +62 -0
- package/src/alphalib/types/robots/youtube-store.ts +108 -0
- package/src/alphalib/types/stackVersions.ts +12 -0
- package/src/alphalib/types/template.ts +71 -0
- package/src/alphalib/zodParseWithContext.ts +151 -0
- package/src/apiTypes.ts +165 -0
- package/src/tus.ts +123 -0
- package/index.js +0 -1
- package/src/PaginationStream.js +0 -39
- package/src/Transloadit.js +0 -701
- package/types/index.d.ts +0 -217
package/src/Transloadit.js
DELETED
|
@@ -1,701 +0,0 @@
|
|
|
1
|
-
const got = require('got')
|
|
2
|
-
const FormData = require('form-data')
|
|
3
|
-
const crypto = require('crypto')
|
|
4
|
-
const fromPairs = require('lodash/fromPairs')
|
|
5
|
-
const sumBy = require('lodash/sumBy')
|
|
6
|
-
const fs = require('fs')
|
|
7
|
-
const { basename } = require('path')
|
|
8
|
-
const tus = require('tus-js-client')
|
|
9
|
-
const { access, stat: fsStat } = require('fs').promises
|
|
10
|
-
const log = require('debug')('transloadit')
|
|
11
|
-
const logWarn = require('debug')('transloadit:warn')
|
|
12
|
-
const intoStream = require('into-stream')
|
|
13
|
-
const isStream = require('is-stream')
|
|
14
|
-
const assert = require('assert')
|
|
15
|
-
const pMap = require('p-map')
|
|
16
|
-
const uuid = require('uuid')
|
|
17
|
-
|
|
18
|
-
const PaginationStream = require('./PaginationStream')
|
|
19
|
-
const { version } = require('../package.json')
|
|
20
|
-
|
|
21
|
-
function decorateError (err, body) {
|
|
22
|
-
if (!body) return err
|
|
23
|
-
let { message } = err
|
|
24
|
-
|
|
25
|
-
// Provide a more useful message if there is one
|
|
26
|
-
if (body.message && body.error) message = `${body.error}: ${body.message}`
|
|
27
|
-
else if (body.error) message = body.error
|
|
28
|
-
|
|
29
|
-
if (body.assembly_ssl_url) message += ` - ${body.assembly_ssl_url}`
|
|
30
|
-
|
|
31
|
-
/* eslint-disable no-param-reassign */
|
|
32
|
-
err.message = message
|
|
33
|
-
if (body.assembly_id) err.assemblyId = body.assembly_id
|
|
34
|
-
if (body.error) err.transloaditErrorCode = body.error
|
|
35
|
-
/* eslint-enable no-param-reassign */
|
|
36
|
-
|
|
37
|
-
return err
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
class InconsistentResponseError extends Error {
|
|
41
|
-
constructor (message) {
|
|
42
|
-
super(message)
|
|
43
|
-
this.name = 'InconsistentResponseError'
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Not sure if this is still a problem with the API, but throw a special error type so the user can retry if needed
|
|
48
|
-
function checkAssemblyUrls (result) {
|
|
49
|
-
if (result.assembly_url == null || result.assembly_ssl_url == null) {
|
|
50
|
-
throw new InconsistentResponseError('Server returned an incomplete assembly response (no URL)')
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const isFileBasedStream = (stream) => !!stream.path
|
|
55
|
-
|
|
56
|
-
function getHrTimeMs () {
|
|
57
|
-
return Number(process.hrtime.bigint() / 1000000n)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function checkResult (result) {
|
|
61
|
-
// In case server returned a successful HTTP status code, but an `error` in the JSON object
|
|
62
|
-
// This happens sometimes when createAssembly with an invalid file (IMPORT_FILE_ERROR)
|
|
63
|
-
if (typeof result === 'object' && result !== null && typeof result.error === 'string') {
|
|
64
|
-
const err = new Error('Error in response')
|
|
65
|
-
// Mimic got HTTPError structure
|
|
66
|
-
err.response = {
|
|
67
|
-
body: result,
|
|
68
|
-
}
|
|
69
|
-
throw decorateError(err, result)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async function sendTusRequest ({ streamsMap, assembly, onProgress }) {
|
|
74
|
-
const streamLabels = Object.keys(streamsMap)
|
|
75
|
-
|
|
76
|
-
let totalBytes = 0
|
|
77
|
-
let lastEmittedProgress = 0
|
|
78
|
-
|
|
79
|
-
const sizes = {}
|
|
80
|
-
|
|
81
|
-
// Initialize data
|
|
82
|
-
await pMap(streamLabels, async (label) => {
|
|
83
|
-
const { path } = streamsMap[label]
|
|
84
|
-
|
|
85
|
-
if (path) {
|
|
86
|
-
const { size } = await fsStat(path)
|
|
87
|
-
sizes[label] = size
|
|
88
|
-
totalBytes += size
|
|
89
|
-
}
|
|
90
|
-
}, { concurrency: 5 })
|
|
91
|
-
|
|
92
|
-
const uploadProgresses = {}
|
|
93
|
-
|
|
94
|
-
async function uploadSingleStream (label) {
|
|
95
|
-
uploadProgresses[label] = 0
|
|
96
|
-
|
|
97
|
-
const { stream, path } = streamsMap[label]
|
|
98
|
-
const size = sizes[label]
|
|
99
|
-
|
|
100
|
-
const onTusProgress = (bytesUploaded) => {
|
|
101
|
-
uploadProgresses[label] = bytesUploaded
|
|
102
|
-
|
|
103
|
-
// get all uploaded bytes for all files
|
|
104
|
-
const uploadedBytes = sumBy(streamLabels, (l) => uploadProgresses[l])
|
|
105
|
-
|
|
106
|
-
// don't send redundant progress
|
|
107
|
-
if (lastEmittedProgress < uploadedBytes) {
|
|
108
|
-
lastEmittedProgress = uploadedBytes
|
|
109
|
-
onProgress({ uploadedBytes, totalBytes })
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const filename = path ? basename(path) : label
|
|
114
|
-
|
|
115
|
-
await new Promise((resolve, reject) => {
|
|
116
|
-
const tusUpload = new tus.Upload(stream, {
|
|
117
|
-
endpoint: assembly.tus_url,
|
|
118
|
-
metadata: {
|
|
119
|
-
assembly_url: assembly.assembly_ssl_url,
|
|
120
|
-
fieldname : label,
|
|
121
|
-
filename,
|
|
122
|
-
},
|
|
123
|
-
uploadSize: size,
|
|
124
|
-
onError : reject,
|
|
125
|
-
onProgress: onTusProgress,
|
|
126
|
-
onSuccess : resolve,
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
tusUpload.start()
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
log(label, 'upload done')
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// TODO throttle concurrency? Can use p-map
|
|
136
|
-
const promises = streamLabels.map((label) => uploadSingleStream(label))
|
|
137
|
-
await Promise.all(promises)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
class TransloaditClient {
|
|
141
|
-
constructor (opts = {}) {
|
|
142
|
-
if (opts.authKey == null) {
|
|
143
|
-
throw new Error('Please provide an authKey')
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (opts.authSecret == null) {
|
|
147
|
-
throw new Error('Please provide an authSecret')
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (opts.endpoint && opts.endpoint.endsWith('/')) {
|
|
151
|
-
throw new Error('Trailing slash in endpoint is not allowed')
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
this._authKey = opts.authKey
|
|
155
|
-
this._authSecret = opts.authSecret
|
|
156
|
-
this._endpoint = opts.endpoint || 'https://api2.transloadit.com'
|
|
157
|
-
this._maxRetries = opts.maxRetries != null ? opts.maxRetries : 5
|
|
158
|
-
this._defaultTimeout = opts.timeout != null ? opts.timeout : 60000
|
|
159
|
-
|
|
160
|
-
this._lastUsedAssemblyUrl = ''
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
getLastUsedAssemblyUrl () {
|
|
164
|
-
return this._lastUsedAssemblyUrl
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
setDefaultTimeout (timeout) {
|
|
168
|
-
this._defaultTimeout = timeout
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Create an Assembly
|
|
173
|
-
*
|
|
174
|
-
* @param {object} opts assembly options
|
|
175
|
-
* @returns {Promise}
|
|
176
|
-
*/
|
|
177
|
-
createAssembly (opts = {}, arg2) {
|
|
178
|
-
// Warn users of old callback API
|
|
179
|
-
if (typeof arg2 === 'function') {
|
|
180
|
-
throw new TypeError('You are trying to send a function as the second argument. This is no longer valid in this version. Please see github README for usage.')
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const {
|
|
184
|
-
params = {},
|
|
185
|
-
waitForCompletion = false,
|
|
186
|
-
isResumable = true,
|
|
187
|
-
timeout = 24 * 60 * 60 * 1000, // 1 day
|
|
188
|
-
onUploadProgress = () => {},
|
|
189
|
-
onAssemblyProgress = () => {},
|
|
190
|
-
files = {},
|
|
191
|
-
uploads = {},
|
|
192
|
-
assemblyId,
|
|
193
|
-
} = opts
|
|
194
|
-
|
|
195
|
-
// Keep track of how long the request took
|
|
196
|
-
const startTimeMs = getHrTimeMs()
|
|
197
|
-
|
|
198
|
-
// Undocumented feature to allow specifying a custom assembly id from the client
|
|
199
|
-
// Not recommended for general use due to security. E.g if the user doesn't provide a cryptographically
|
|
200
|
-
// secure ID, then anyone could access the assembly.
|
|
201
|
-
let effectiveAssemblyId
|
|
202
|
-
if (assemblyId != null) {
|
|
203
|
-
effectiveAssemblyId = assemblyId
|
|
204
|
-
} else {
|
|
205
|
-
effectiveAssemblyId = uuid.v4().replace(/-/g, '')
|
|
206
|
-
}
|
|
207
|
-
const urlSuffix = `/assemblies/${effectiveAssemblyId}`
|
|
208
|
-
|
|
209
|
-
// We want to be able to return the promise immediately with custom data
|
|
210
|
-
const promise = (async () => {
|
|
211
|
-
this._lastUsedAssemblyUrl = `${this._endpoint}${urlSuffix}`
|
|
212
|
-
|
|
213
|
-
// eslint-disable-next-line no-bitwise
|
|
214
|
-
await pMap(Object.entries(files), async ([, path]) => access(path, fs.F_OK | fs.R_OK), { concurrency: 5 })
|
|
215
|
-
|
|
216
|
-
// Convert uploads to streams
|
|
217
|
-
const streamsMap = fromPairs(Object.entries(uploads).map(([label, value]) => {
|
|
218
|
-
const isReadable = isStream.readable(value)
|
|
219
|
-
if (!isReadable && isStream(value)) {
|
|
220
|
-
// https://github.com/transloadit/node-sdk/issues/92
|
|
221
|
-
throw new Error(`Upload named "${label}" is not a Readable stream`)
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return [
|
|
225
|
-
label,
|
|
226
|
-
isStream.readable(value) ? value : intoStream(value),
|
|
227
|
-
]
|
|
228
|
-
}))
|
|
229
|
-
|
|
230
|
-
// Wrap in object structure (so we can know if it's a pathless stream or not)
|
|
231
|
-
const allStreamsMap = fromPairs(Object.entries(streamsMap).map(([label, stream]) => [label, { stream }]))
|
|
232
|
-
|
|
233
|
-
// Create streams from files too
|
|
234
|
-
for (const [label, path] of Object.entries(files)) {
|
|
235
|
-
const stream = fs.createReadStream(path)
|
|
236
|
-
allStreamsMap[label] = { stream, path } // File streams have path
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const allStreams = Object.values(allStreamsMap)
|
|
240
|
-
|
|
241
|
-
// Pause all streams
|
|
242
|
-
allStreams.forEach(({ stream }) => stream.pause())
|
|
243
|
-
|
|
244
|
-
// If any stream emits error, we want to handle this and exit with error
|
|
245
|
-
const streamErrorPromise = new Promise((resolve, reject) => {
|
|
246
|
-
allStreams.forEach(({ stream }) => stream.on('error', reject))
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
const createAssemblyAndUpload = async () => {
|
|
250
|
-
const useTus = isResumable && allStreams.every(isFileBasedStream)
|
|
251
|
-
|
|
252
|
-
const requestOpts = {
|
|
253
|
-
urlSuffix,
|
|
254
|
-
method: 'post',
|
|
255
|
-
timeout,
|
|
256
|
-
params,
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (useTus) {
|
|
260
|
-
requestOpts.fields = {
|
|
261
|
-
tus_num_expected_upload_files: allStreams.length,
|
|
262
|
-
}
|
|
263
|
-
} else if (isResumable) {
|
|
264
|
-
logWarn('Disabling resumability because the size of one or more streams cannot be determined')
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// upload as form multipart or tus?
|
|
268
|
-
const formUploadStreamsMap = useTus ? {} : allStreamsMap
|
|
269
|
-
const tusStreamsMap = useTus ? allStreamsMap : {}
|
|
270
|
-
|
|
271
|
-
const result = await this._remoteJson(requestOpts, formUploadStreamsMap, onUploadProgress)
|
|
272
|
-
checkResult(result)
|
|
273
|
-
|
|
274
|
-
if (useTus && Object.keys(tusStreamsMap).length > 0) {
|
|
275
|
-
await sendTusRequest({
|
|
276
|
-
streamsMap: tusStreamsMap,
|
|
277
|
-
assembly : result,
|
|
278
|
-
onProgress: onUploadProgress,
|
|
279
|
-
})
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (!waitForCompletion) return result
|
|
283
|
-
const awaitResult = await this.awaitAssemblyCompletion(result.assembly_id, {
|
|
284
|
-
timeout, onAssemblyProgress, startTimeMs,
|
|
285
|
-
})
|
|
286
|
-
checkResult(awaitResult)
|
|
287
|
-
return awaitResult
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return Promise.race([createAssemblyAndUpload(), streamErrorPromise])
|
|
291
|
-
})()
|
|
292
|
-
|
|
293
|
-
// This allows the user to use or log the assemblyId even before it has been created for easier debugging
|
|
294
|
-
promise.assemblyId = effectiveAssemblyId
|
|
295
|
-
return promise
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
async awaitAssemblyCompletion (assemblyId, {
|
|
299
|
-
onAssemblyProgress = () => {},
|
|
300
|
-
timeout,
|
|
301
|
-
startTimeMs = getHrTimeMs(),
|
|
302
|
-
interval = 1000,
|
|
303
|
-
} = {}) {
|
|
304
|
-
assert(assemblyId)
|
|
305
|
-
|
|
306
|
-
// eslint-disable-next-line no-constant-condition
|
|
307
|
-
while (true) {
|
|
308
|
-
// eslint-disable-next-line no-await-in-loop
|
|
309
|
-
const result = await this.getAssembly(assemblyId)
|
|
310
|
-
|
|
311
|
-
if (!['ASSEMBLY_UPLOADING', 'ASSEMBLY_EXECUTING', 'ASSEMBLY_REPLAYING'].includes(result.ok)) {
|
|
312
|
-
return result // Done!
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
try {
|
|
316
|
-
onAssemblyProgress(result)
|
|
317
|
-
} catch (err) {
|
|
318
|
-
log('Caught onAssemblyProgress error', err)
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
const nowMs = getHrTimeMs()
|
|
322
|
-
if (timeout != null && nowMs - startTimeMs >= timeout) {
|
|
323
|
-
const err = new Error('Polling timed out')
|
|
324
|
-
err.code = 'POLLING_TIMED_OUT'
|
|
325
|
-
throw err
|
|
326
|
-
}
|
|
327
|
-
// eslint-disable-next-line no-await-in-loop
|
|
328
|
-
await new Promise((resolve) => setTimeout(resolve, interval))
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Cancel the assembly
|
|
334
|
-
*
|
|
335
|
-
* @param {string} assemblyId assembly ID
|
|
336
|
-
* @returns {Promise} after the assembly is deleted
|
|
337
|
-
*/
|
|
338
|
-
async cancelAssembly (assemblyId) {
|
|
339
|
-
// You may wonder why do we need to call getAssembly first:
|
|
340
|
-
// If we use the default base URL (instead of the one returned in assembly_url_ssl),
|
|
341
|
-
// the delete call will hang in certain cases
|
|
342
|
-
// See test "should stop the assembly from reaching completion"
|
|
343
|
-
const { assembly_ssl_url: url } = await this.getAssembly(assemblyId)
|
|
344
|
-
const opts = {
|
|
345
|
-
url,
|
|
346
|
-
// urlSuffix: `/assemblies/${assemblyId}`, // Cannot simply do this, see above
|
|
347
|
-
method: 'delete',
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
return this._remoteJson(opts)
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Replay an Assembly
|
|
355
|
-
*
|
|
356
|
-
* @param {string} assemblyId of the assembly to replay
|
|
357
|
-
* @param {object} optional params
|
|
358
|
-
* @returns {Promise} after the replay is started
|
|
359
|
-
*/
|
|
360
|
-
async replayAssembly (assemblyId, params = {}) {
|
|
361
|
-
const requestOpts = {
|
|
362
|
-
urlSuffix: `/assemblies/${assemblyId}/replay`,
|
|
363
|
-
method : 'post',
|
|
364
|
-
}
|
|
365
|
-
if (Object.keys(params).length > 0) requestOpts.params = params
|
|
366
|
-
const result = await this._remoteJson(requestOpts)
|
|
367
|
-
checkResult(result)
|
|
368
|
-
return result
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Replay an Assembly notification
|
|
373
|
-
*
|
|
374
|
-
* @param {string} assemblyId of the assembly whose notification to replay
|
|
375
|
-
* @param {object} optional params
|
|
376
|
-
* @returns {Promise} after the replay is started
|
|
377
|
-
*/
|
|
378
|
-
async replayAssemblyNotification (assemblyId, params = {}) {
|
|
379
|
-
const requestOpts = {
|
|
380
|
-
urlSuffix: `/assembly_notifications/${assemblyId}/replay`,
|
|
381
|
-
method : 'post',
|
|
382
|
-
}
|
|
383
|
-
if (Object.keys(params).length > 0) requestOpts.params = params
|
|
384
|
-
return this._remoteJson(requestOpts)
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* List all assembly notifications
|
|
389
|
-
*
|
|
390
|
-
* @param {object} params optional request options
|
|
391
|
-
* @returns {Promise} the list of Assembly notifications
|
|
392
|
-
*/
|
|
393
|
-
async listAssemblyNotifications (params) {
|
|
394
|
-
const requestOpts = {
|
|
395
|
-
urlSuffix: '/assembly_notifications',
|
|
396
|
-
method : 'get',
|
|
397
|
-
params : params || {},
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
return this._remoteJson(requestOpts)
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
streamAssemblyNotifications (params) {
|
|
404
|
-
return new PaginationStream(async (page) => this.listAssemblyNotifications({ ...params, page }))
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* List all assemblies
|
|
409
|
-
*
|
|
410
|
-
* @param {object} params optional request options
|
|
411
|
-
* @returns {Promise} list of Assemblies
|
|
412
|
-
*/
|
|
413
|
-
async listAssemblies (params) {
|
|
414
|
-
const requestOpts = {
|
|
415
|
-
urlSuffix: '/assemblies',
|
|
416
|
-
method : 'get',
|
|
417
|
-
params : params || {},
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
return this._remoteJson(requestOpts)
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
streamAssemblies (params) {
|
|
424
|
-
return new PaginationStream(async (page) => this.listAssemblies({ ...params, page }))
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Get an Assembly
|
|
429
|
-
*
|
|
430
|
-
* @param {string} assemblyId the Assembly Id
|
|
431
|
-
* @returns {Promise} the retrieved Assembly
|
|
432
|
-
*/
|
|
433
|
-
async getAssembly (assemblyId) {
|
|
434
|
-
const result = await this._remoteJson({ urlSuffix: `/assemblies/${assemblyId}` })
|
|
435
|
-
checkAssemblyUrls(result)
|
|
436
|
-
return result
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* Create an Assembly Template
|
|
441
|
-
*
|
|
442
|
-
* @param {object} params optional request options
|
|
443
|
-
* @returns {Promise} when the template is created
|
|
444
|
-
*/
|
|
445
|
-
async createTemplate (params) {
|
|
446
|
-
const requestOpts = {
|
|
447
|
-
urlSuffix: '/templates',
|
|
448
|
-
method : 'post',
|
|
449
|
-
params : params || {},
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
return this._remoteJson(requestOpts)
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
* Edit an Assembly Template
|
|
457
|
-
*
|
|
458
|
-
* @param {string} templateId the template ID
|
|
459
|
-
* @param {object} params optional request options
|
|
460
|
-
* @returns {Promise} when the template is edited
|
|
461
|
-
*/
|
|
462
|
-
async editTemplate (templateId, params) {
|
|
463
|
-
const requestOpts = {
|
|
464
|
-
urlSuffix: `/templates/${templateId}`,
|
|
465
|
-
method : 'put',
|
|
466
|
-
params : params || {},
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
return this._remoteJson(requestOpts)
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* Delete an Assembly Template
|
|
474
|
-
*
|
|
475
|
-
* @param {string} templateId the template ID
|
|
476
|
-
* @returns {Promise} when the template is deleted
|
|
477
|
-
*/
|
|
478
|
-
async deleteTemplate (templateId) {
|
|
479
|
-
const requestOpts = {
|
|
480
|
-
urlSuffix: `/templates/${templateId}`,
|
|
481
|
-
method : 'delete',
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
return this._remoteJson(requestOpts)
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* Get an Assembly Template
|
|
489
|
-
*
|
|
490
|
-
* @param {string} templateId the template ID
|
|
491
|
-
* @returns {Promise} when the template is retrieved
|
|
492
|
-
*/
|
|
493
|
-
async getTemplate (templateId) {
|
|
494
|
-
const requestOpts = {
|
|
495
|
-
urlSuffix: `/templates/${templateId}`,
|
|
496
|
-
method : 'get',
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
return this._remoteJson(requestOpts)
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* List all Assembly Templates
|
|
504
|
-
*
|
|
505
|
-
* @param {object} params optional request options
|
|
506
|
-
* @returns {Promise} the list of templates
|
|
507
|
-
*/
|
|
508
|
-
async listTemplates (params) {
|
|
509
|
-
const requestOpts = {
|
|
510
|
-
urlSuffix: '/templates',
|
|
511
|
-
method : 'get',
|
|
512
|
-
params : params || {},
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
return this._remoteJson(requestOpts)
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
streamTemplates (params) {
|
|
519
|
-
return new PaginationStream(async (page) => this.listTemplates({ ...params, page }))
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* Get account Billing details for a specific month
|
|
524
|
-
*
|
|
525
|
-
* @param {string} month the date for the required billing in the format yyyy-mm
|
|
526
|
-
* @returns {Promise} with billing data
|
|
527
|
-
*/
|
|
528
|
-
async getBill (month) {
|
|
529
|
-
assert(month, 'month is required')
|
|
530
|
-
const requestOpts = {
|
|
531
|
-
urlSuffix: `/bill/${month}`,
|
|
532
|
-
method : 'get',
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
return this._remoteJson(requestOpts)
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
calcSignature (params) {
|
|
539
|
-
const jsonParams = this._prepareParams(params)
|
|
540
|
-
const signature = this._calcSignature(jsonParams)
|
|
541
|
-
|
|
542
|
-
return { signature, params: jsonParams }
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
_calcSignature (toSign) {
|
|
546
|
-
return crypto
|
|
547
|
-
.createHmac('sha1', this._authSecret)
|
|
548
|
-
.update(Buffer.from(toSign, 'utf-8'))
|
|
549
|
-
.digest('hex')
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
// Sets the multipart/form-data for POST, PUT and DELETE requests, including
|
|
553
|
-
// the streams, the signed params, and any additional fields.
|
|
554
|
-
_appendForm (form, params, streamsMap, fields) {
|
|
555
|
-
const sigData = this.calcSignature(params)
|
|
556
|
-
const jsonParams = sigData.params
|
|
557
|
-
const { signature } = sigData
|
|
558
|
-
|
|
559
|
-
form.append('params', jsonParams)
|
|
560
|
-
|
|
561
|
-
if (fields != null) {
|
|
562
|
-
for (const [key, val] of Object.entries(fields)) {
|
|
563
|
-
form.append(key, val)
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
form.append('signature', signature)
|
|
568
|
-
|
|
569
|
-
if (streamsMap) {
|
|
570
|
-
Object.entries(streamsMap).forEach(([label, { stream, path }]) => {
|
|
571
|
-
const options = path ? undefined : { filename: label } // https://github.com/transloadit/node-sdk/issues/86
|
|
572
|
-
form.append(label, stream, options)
|
|
573
|
-
})
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
// Implements HTTP GET query params, handling the case where the url already
|
|
578
|
-
// has params.
|
|
579
|
-
_appendParamsToUrl (url, params) {
|
|
580
|
-
const { signature, params: jsonParams } = this.calcSignature(params)
|
|
581
|
-
|
|
582
|
-
const prefix = url.indexOf('?') === -1 ? '?' : '&'
|
|
583
|
-
|
|
584
|
-
return `${url}${prefix}signature=${signature}¶ms=${encodeURIComponent(jsonParams)}`
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
// Responsible for including auth parameters in all requests
|
|
588
|
-
_prepareParams (paramsIn) {
|
|
589
|
-
let params = paramsIn
|
|
590
|
-
if (params == null) {
|
|
591
|
-
params = {}
|
|
592
|
-
}
|
|
593
|
-
if (params.auth == null) {
|
|
594
|
-
params.auth = {}
|
|
595
|
-
}
|
|
596
|
-
if (params.auth.key == null) {
|
|
597
|
-
params.auth.key = this._authKey
|
|
598
|
-
}
|
|
599
|
-
if (params.auth.expires == null) {
|
|
600
|
-
params.auth.expires = this._getExpiresDate()
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
return JSON.stringify(params)
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
// We want to mock this method
|
|
607
|
-
// eslint-disable-next-line class-methods-use-this
|
|
608
|
-
_getExpiresDate () {
|
|
609
|
-
const expiresDate = new Date()
|
|
610
|
-
expiresDate.setDate(expiresDate.getDate() + 1)
|
|
611
|
-
return expiresDate.toISOString()
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
// Responsible for making API calls. Automatically sends streams with any POST,
|
|
615
|
-
// PUT or DELETE requests. Automatically adds signature parameters to all
|
|
616
|
-
// requests. Also automatically parses the JSON response.
|
|
617
|
-
async _remoteJson (opts, streamsMap, onProgress = () => {}) {
|
|
618
|
-
const { urlSuffix, url: urlInput, timeout = this._defaultTimeout, method = 'get', params = {}, fields, headers } = opts
|
|
619
|
-
|
|
620
|
-
// Allow providing either a `urlSuffix` or a full `url`
|
|
621
|
-
if (!urlSuffix && !urlInput) throw new Error('No URL provided')
|
|
622
|
-
let url = urlInput || `${this._endpoint}${urlSuffix}`
|
|
623
|
-
|
|
624
|
-
if (method === 'get') {
|
|
625
|
-
url = this._appendParamsToUrl(url, params)
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
log('Sending request', method, url)
|
|
629
|
-
|
|
630
|
-
// Cannot use got.retry because we are using FormData which is a stream and can only be used once
|
|
631
|
-
// https://github.com/sindresorhus/got/issues/1282
|
|
632
|
-
for (let retryCount = 0; ; retryCount++) {
|
|
633
|
-
let form
|
|
634
|
-
|
|
635
|
-
if (method === 'post' || method === 'put' || method === 'delete') {
|
|
636
|
-
form = new FormData()
|
|
637
|
-
this._appendForm(form, params, streamsMap, fields)
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
const isUploadingStreams = streamsMap && Object.keys(streamsMap).length > 0
|
|
641
|
-
|
|
642
|
-
const requestOpts = {
|
|
643
|
-
retry : 0,
|
|
644
|
-
body : form,
|
|
645
|
-
timeout,
|
|
646
|
-
headers: {
|
|
647
|
-
'Transloadit-Client': `node-sdk:${version}`,
|
|
648
|
-
'User-Agent' : undefined, // Remove got's user-agent
|
|
649
|
-
...headers,
|
|
650
|
-
},
|
|
651
|
-
responseType: 'json',
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
// For non-file streams transfer encoding does not get set, and the uploaded files will not get accepted
|
|
655
|
-
// https://github.com/transloadit/node-sdk/issues/86
|
|
656
|
-
// https://github.com/form-data/form-data/issues/394#issuecomment-573595015
|
|
657
|
-
if (isUploadingStreams) requestOpts.headers['transfer-encoding'] = 'chunked'
|
|
658
|
-
|
|
659
|
-
try {
|
|
660
|
-
const request = got[method](url, requestOpts)
|
|
661
|
-
if (isUploadingStreams) {
|
|
662
|
-
request.on('uploadProgress', ({ transferred, total }) => onProgress({ uploadedBytes: transferred, totalBytes: total }))
|
|
663
|
-
}
|
|
664
|
-
// eslint-disable-next-line no-await-in-loop
|
|
665
|
-
const { body } = await request
|
|
666
|
-
return body
|
|
667
|
-
} catch (err) {
|
|
668
|
-
if (!(err instanceof got.HTTPError)) throw err
|
|
669
|
-
|
|
670
|
-
const { statusCode, body } = err.response
|
|
671
|
-
logWarn('HTTP error', statusCode, body)
|
|
672
|
-
|
|
673
|
-
const shouldRetry = statusCode === 413 && body.error === 'RATE_LIMIT_REACHED' && body.info && body.info.retryIn && retryCount < this._maxRetries
|
|
674
|
-
|
|
675
|
-
// https://transloadit.com/blog/2012/04/introducing-rate-limiting/
|
|
676
|
-
if (!shouldRetry) throw decorateError(err, body)
|
|
677
|
-
|
|
678
|
-
const { retryIn: retryInSec } = body.info
|
|
679
|
-
logWarn(`Rate limit reached, retrying request in approximately ${retryInSec} seconds.`)
|
|
680
|
-
const retryInMs = 1000 * (retryInSec * (1 + 0.1 * Math.random()))
|
|
681
|
-
// eslint-disable-next-line no-await-in-loop
|
|
682
|
-
await new Promise((resolve) => setTimeout(resolve, retryInMs))
|
|
683
|
-
// Retry
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
// See https://github.com/sindresorhus/got#errors
|
|
690
|
-
// Expose relevant errors
|
|
691
|
-
TransloaditClient.RequestError = got.RequestError
|
|
692
|
-
TransloaditClient.ReadError = got.ReadError
|
|
693
|
-
TransloaditClient.ParseError = got.ParseError
|
|
694
|
-
TransloaditClient.UploadError = got.UploadError
|
|
695
|
-
TransloaditClient.HTTPError = got.HTTPError
|
|
696
|
-
TransloaditClient.MaxRedirectsError = got.MaxRedirectsError
|
|
697
|
-
TransloaditClient.TimeoutError = got.TimeoutError
|
|
698
|
-
|
|
699
|
-
TransloaditClient.InconsistentResponseError = InconsistentResponseError
|
|
700
|
-
|
|
701
|
-
module.exports = TransloaditClient
|