@visulima/storage 1.0.0-alpha.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +555 -0
- package/LICENSE.md +237 -568
- package/README.md +82 -466
- package/dist/adapter/nuxt/module.d.ts +41 -34
- package/dist/adapter/nuxt/module.js +1 -93
- package/dist/adapter/nuxt/package.json +0 -6
- package/dist/ai/ai-sdk/index.d.ts +113 -0
- package/dist/ai/ai-sdk/index.js +1 -0
- package/dist/ai/claude/index.d.ts +177 -0
- package/dist/ai/claude/index.js +1 -0
- package/dist/ai/openai/index.d.ts +205 -0
- package/dist/ai/openai/index.js +1 -0
- package/dist/ai/tanstack/index.d.ts +115 -0
- package/dist/ai/tanstack/index.js +1 -0
- package/dist/handler/http/fetch/index.d.ts +303 -4
- package/dist/handler/http/fetch/index.js +1 -4
- package/dist/handler/http/hono/index.d.ts +73 -64
- package/dist/handler/http/hono/index.js +1 -65
- package/dist/handler/http/nextjs/index.d.ts +66 -58
- package/dist/handler/http/nextjs/index.js +1 -37
- package/dist/handler/http/node/index.d.ts +368 -4
- package/dist/handler/http/node/index.js +1 -8
- package/dist/handler/http/solid-start/index.d.ts +66 -57
- package/dist/handler/http/solid-start/index.js +1 -44
- package/dist/index.d.ts +106 -17
- package/dist/index.js +1 -13
- package/dist/openapi/index.d.ts +24 -5
- package/dist/openapi/index.js +1 -5
- package/dist/packem_shared/AbstractBaseStorage-Ba7cLu-t.js +1 -0
- package/dist/packem_shared/AwsLightFile-CpZrubaV.js +1 -0
- package/dist/packem_shared/AwsLightMetaStorage-DPqJ9LTr.js +1 -0
- package/dist/packem_shared/AwsLightStorage-DTBVxHXO.js +1 -0
- package/dist/packem_shared/AzureFile-DFSaVe25.js +1 -0
- package/dist/packem_shared/AzureSMetaStorage-ByzM6Aix.js +1 -0
- package/dist/packem_shared/AzureStorage-BFsD4qbF.js +1 -0
- package/dist/packem_shared/BaseTransformer-Buw5lX_3.js +1 -0
- package/dist/packem_shared/BoxFile-CseIoPW1.js +1 -0
- package/dist/packem_shared/BoxMetaStorage-DFwhEI9C.js +1 -0
- package/dist/packem_shared/BoxStorage-B_t-OVzf.js +1 -0
- package/dist/packem_shared/BunS3File-BcYmsz1n.js +1 -0
- package/dist/packem_shared/BunS3MetaStorage-DFwhEI9C.js +1 -0
- package/dist/packem_shared/BunS3Storage-CB_pZWlV.js +1 -0
- package/dist/packem_shared/BunnyFile-BgEOlcYI.js +1 -0
- package/dist/packem_shared/BunnyMetaStorage-DFwhEI9C.js +1 -0
- package/dist/packem_shared/BunnyStorage-CILSK4_Z.js +1 -0
- package/dist/packem_shared/CloudinaryFile-Bo5B-vM1.js +1 -0
- package/dist/packem_shared/CloudinaryMetaStorage-D_vNzewL.js +1 -0
- package/dist/packem_shared/CloudinaryStorage-DiCbdAi_.js +1 -0
- package/dist/packem_shared/DiskStorage-Kp5t3vnF.js +1 -0
- package/dist/packem_shared/DiskStorageWithChecksum-Bh6w-Iu8.js +1 -0
- package/dist/packem_shared/DropboxFile-BFb7eOzy.js +1 -0
- package/dist/packem_shared/DropboxMetaStorage-DFwhEI9C.js +1 -0
- package/dist/packem_shared/DropboxStorage-H8bd8hEz.js +1 -0
- package/dist/packem_shared/ERRORS-BIBxE2oR.js +1 -0
- package/dist/packem_shared/File-W8aOo15X.js +1 -0
- package/dist/packem_shared/Files-BA3mpDwz.js +1 -0
- package/dist/packem_shared/FirebaseFile-BLaBxa2A.js +1 -0
- package/dist/packem_shared/FirebaseMetaStorage-D_vNzewL.js +1 -0
- package/dist/packem_shared/FirebaseStorage-Dgk4XyMr.js +2 -0
- package/dist/packem_shared/FtpFile-ClWDYnt2.js +1 -0
- package/dist/packem_shared/FtpMetaStorage-DFwhEI9C.js +1 -0
- package/dist/packem_shared/FtpStorage-g_DjiR-C.js +1 -0
- package/dist/packem_shared/GCSConfig-BQ0OpVhe.js +1 -0
- package/dist/packem_shared/GCSFile-Cero7qZN.js +1 -0
- package/dist/packem_shared/GCSMetaStorage-3fLTlRd4.js +1 -0
- package/dist/packem_shared/GCStorage-DUfwVFd3.js +1 -0
- package/dist/packem_shared/GoogleDriveFile-DHpLhzg9.js +1 -0
- package/dist/packem_shared/GoogleDriveMetaStorage-DqkgoE46.js +1 -0
- package/dist/packem_shared/GoogleDriveStorage-D0-5egHE.js +1 -0
- package/dist/packem_shared/LocalMetaStorage-Bp5mVc76.js +1 -0
- package/dist/packem_shared/MediaTransformer-D2kUsklW.js +1 -0
- package/dist/packem_shared/MemoryMetaStorage-Ksgh9pe7.js +1 -0
- package/dist/packem_shared/MemoryStorage-DzSTdlAq.js +1 -0
- package/dist/packem_shared/MetaStorage-DPEUyWgN.js +1 -0
- package/dist/packem_shared/Metadata-B7CcBueg.js +1 -0
- package/dist/packem_shared/Multipart-Btj2mo9r.js +1 -0
- package/dist/packem_shared/Multipart-C4GpuHMU.js +1 -0
- package/dist/packem_shared/NetlifyBlobFile-DoFhkzaH.js +1 -0
- package/dist/packem_shared/NetlifyBlobMetaStorage-D_vNzewL.js +1 -0
- package/dist/packem_shared/NetlifyBlobStorage-DZdCmOVW.js +1 -0
- package/dist/packem_shared/NoOpMetrics-BLo6u4NY.js +1 -0
- package/dist/packem_shared/OneDriveFile-CNNJYI43.js +1 -0
- package/dist/packem_shared/OneDriveMetaStorage-DqkgoE46.js +1 -0
- package/dist/packem_shared/OneDriveStorage-CvJetV7_.js +1 -0
- package/dist/packem_shared/OpenTelemetryMetrics-DJDQsNKp.js +1 -0
- package/dist/packem_shared/PocketBaseFile-DpJpxl3e.js +1 -0
- package/dist/packem_shared/PocketBaseMetaStorage-CpvDRnSu.js +1 -0
- package/dist/packem_shared/PocketBaseStorage-BPil-koe.js +1 -0
- package/dist/packem_shared/Rest-BehVaxbl.js +1 -0
- package/dist/packem_shared/Rest-ymPCZkKR.js +1 -0
- package/dist/packem_shared/S3File-CpZrubaV.js +1 -0
- package/dist/packem_shared/S3MetaStorage-CMonflzp.js +1 -0
- package/dist/packem_shared/S3Storage-wslqssvr.js +1 -0
- package/dist/packem_shared/SftpFile-ClWDYnt2.js +1 -0
- package/dist/packem_shared/SftpMetaStorage-DFwhEI9C.js +1 -0
- package/dist/packem_shared/SftpStorage-BVbMtS2b.js +1 -0
- package/dist/packem_shared/SharePointFile-Blz9FS4h.js +1 -0
- package/dist/packem_shared/SharePointMetaStorage-DFwhEI9C.js +1 -0
- package/dist/packem_shared/SharePointStorage-DWjvR5oZ.js +1 -0
- package/dist/packem_shared/SupabaseFile-Bo5B-vM1.js +1 -0
- package/dist/packem_shared/SupabaseMetaStorage-DqkgoE46.js +1 -0
- package/dist/packem_shared/SupabaseStorage-BiKmYKb6.js +1 -0
- package/dist/packem_shared/TUS_RESUMABLE-CyTSRvPU.js +1 -0
- package/dist/packem_shared/Tus-BgbON_wQ.js +1 -0
- package/dist/packem_shared/Tus-v6jzkaIO.js +1 -0
- package/dist/packem_shared/UploadControl-DZJhI9Wh.js +1 -0
- package/dist/packem_shared/UploadThingFile-BTFMpcIA.js +1 -0
- package/dist/packem_shared/UploadThingMetaStorage-D_vNzewL.js +1 -0
- package/dist/packem_shared/UploadThingStorage-jrEnANC5.js +1 -0
- package/dist/packem_shared/ValidationError-3B06DFyE.js +1 -0
- package/dist/packem_shared/VercelBlobFile-CVQwKlZk.js +1 -0
- package/dist/packem_shared/VercelBlobMetaStorage-DFwhEI9C.js +1 -0
- package/dist/packem_shared/VercelBlobStorage-Y-cDgH30.js +1 -0
- package/dist/packem_shared/_commonjsHelpers-CWAkuNXM.js +1 -0
- package/dist/packem_shared/agentsCopyFile-Dl5iffdH.js +1 -0
- package/dist/packem_shared/akamai-DthkaFul.js +1 -0
- package/dist/packem_shared/alibaba-BEi25O1g.js +1 -0
- package/dist/packem_shared/approval-fVHwBp7u.js +1 -0
- package/dist/packem_shared/approval.d-CMAYH9GF.d.ts +75 -0
- package/dist/packem_shared/aws-light-meta-storage-DGrn72VJ.js +4 -0
- package/dist/packem_shared/azure-meta-storage-ClbEsfI4.js +1 -0
- package/dist/packem_shared/backblaze-m1N5NZ9q.js +1 -0
- package/dist/packem_shared/base-handler-core-EeV8gZck.js +1 -0
- package/dist/packem_shared/base-handler-fetch-CHzsgb7C.js +1 -0
- package/dist/packem_shared/base-handler-node-BjpW8pGi.js +1 -0
- package/dist/packem_shared/cache-Cw3QjoVN.js +1 -0
- package/dist/packem_shared/claudeCopyFile-BX9O4ORk.js +1 -0
- package/dist/packem_shared/cloudflare-CdUTErlo.js +1 -0
- package/dist/packem_shared/copyFile-49FtxXcm.js +1 -0
- package/dist/packem_shared/copyFile-BUPezT_c.js +1 -0
- package/dist/packem_shared/createResponsesFileTools-6Tvt2PNr.js +1 -0
- package/dist/packem_shared/createRetryWrapper-CxgiV_hH.js +1 -0
- package/dist/packem_shared/detect-file-type-BA7UBLKA.js +1 -0
- package/dist/packem_shared/digitalOcean-B2uB6pgz.js +1 -0
- package/dist/packem_shared/disk-storage-DIn-VnCh.js +1 -0
- package/dist/packem_shared/disk-storage-with-checksum.d-B-VGEsfl.d.ts +156 -0
- package/dist/packem_shared/executors-BDzMjc4y.js +1 -0
- package/dist/packem_shared/executors.d-BZP2rWo3.d.ts +69 -0
- package/dist/packem_shared/exoscale-BDa1Gjth.js +1 -0
- package/dist/packem_shared/filebase-CsFYJIwB.js +1 -0
- package/dist/packem_shared/files.d-CH0iLBNC.d.ts +655 -0
- package/dist/packem_shared/gcs-meta-storage-Dy37wCjI.js +1 -0
- package/dist/packem_shared/get-file-status-y3wTtDQs.js +1 -0
- package/dist/packem_shared/getFormatFromContentType-DCTTPQHm.js +1 -0
- package/dist/packem_shared/has-content-50BsqrWw.js +1 -0
- package/dist/packem_shared/headers-BAiAKekR.js +26 -0
- package/dist/packem_shared/hetzner-BGGFiRGD.js +1 -0
- package/dist/packem_shared/ibmCos-j-3TfJ5p.js +1 -0
- package/dist/packem_shared/idriveE2-C6pQ5pQ0.js +1 -0
- package/dist/packem_shared/index-nZWCQrSe.js +5 -0
- package/dist/packem_shared/internal-D_cZIFwI.js +1 -0
- package/dist/packem_shared/is-expired-CBEk6XBi.js +1 -0
- package/dist/packem_shared/local-meta-storage-C2T92TYb.js +11 -0
- package/dist/packem_shared/local-meta-storage.d-D9PBfkn6.d.ts +21 -0
- package/dist/packem_shared/media-transformer.d-Quf4ai47.d.ts +331 -0
- package/dist/packem_shared/memory-storage.d-4EU1cMt1.d.ts +101 -0
- package/dist/packem_shared/minio-NKquuBfS.js +1 -0
- package/dist/packem_shared/multipart-base-BOzY19lb.js +1 -0
- package/dist/packem_shared/oauth-refresh-EdGzlcOZ.js +1 -0
- package/dist/packem_shared/oracleCloud-DslqNpn6.js +1 -0
- package/dist/packem_shared/ovhCloud-CMHE6uLV.js +1 -0
- package/dist/packem_shared/part-match-D-9dGX42.js +1 -0
- package/dist/packem_shared/path-0oTTdkvl-BVg7lYf5.js +1 -0
- package/dist/packem_shared/posix-dirname-CfpH5wZi.js +1 -0
- package/dist/packem_shared/response-builder-CbSA8qPa.js +1 -0
- package/dist/packem_shared/rest-base-CynUg0mH.js +1 -0
- package/dist/packem_shared/restOpenApiSpec-Csv513qf.js +1 -0
- package/dist/packem_shared/s3-base-storage-DXZYN24h.js +1 -0
- package/dist/packem_shared/s3-base-storage.d-BQgP5B-t.d.ts +287 -0
- package/dist/packem_shared/scaleway-U1In3v70.js +1 -0
- package/dist/packem_shared/sharedErrorSchemaObject-YN65aAKj.js +1 -0
- package/dist/packem_shared/storage-Cyy73Y6r.js +1 -0
- package/dist/packem_shared/storage.d-CEM1upWM.d.ts +1176 -0
- package/dist/packem_shared/storj-Cb59q9kF.js +1 -0
- package/dist/packem_shared/sync-DhR3536K.js +1 -0
- package/dist/packem_shared/tencent-Q1y2GENc.js +1 -0
- package/dist/packem_shared/tigris-BELKoyyp.js +1 -0
- package/dist/packem_shared/transformOpenApiSpec-CIEAgpBD.js +1 -0
- package/dist/packem_shared/tus-base.d-DLzKE54M.d.ts +106 -0
- package/dist/packem_shared/tusOpenApiSpec-D96B03t5.js +1 -0
- package/dist/packem_shared/types.d-Bon9GVVe.d.ts +104 -0
- package/dist/packem_shared/types.d-CggTCgXr.d.ts +49 -0
- package/dist/packem_shared/types.d-CrUWY4On.d.ts +720 -0
- package/dist/packem_shared/update-size-DuNuLyxj.js +1 -0
- package/dist/packem_shared/vultr-B491cQ4e.js +1 -0
- package/dist/packem_shared/waitForStorage-ByQmG4xF.js +1 -0
- package/dist/packem_shared/wasabi-DFrwIoab.js +1 -0
- package/dist/packem_shared/xhrOpenApiSpec-DQR4h6M8.js +1 -0
- package/dist/packem_shared/yandex-CwzHuEKP.js +1 -0
- package/dist/storage/aws/clients/index.d.ts +612 -6
- package/dist/storage/aws/clients/index.js +1 -6
- package/dist/storage/aws/index.d.ts +332 -4
- package/dist/storage/aws/index.js +1 -3
- package/dist/storage/aws-light/index.d.ts +259 -4
- package/dist/storage/aws-light/index.js +1 -3
- package/dist/storage/azure/index.d.ts +236 -4
- package/dist/storage/azure/index.js +1 -3
- package/dist/storage/box/index.d.ts +189 -0
- package/dist/storage/box/index.js +1 -0
- package/dist/storage/bun-s3/index.d.ts +200 -0
- package/dist/storage/bun-s3/index.js +1 -0
- package/dist/storage/bunny/index.d.ts +119 -0
- package/dist/storage/bunny/index.js +1 -0
- package/dist/storage/cloudinary/index.d.ts +121 -0
- package/dist/storage/cloudinary/index.js +1 -0
- package/dist/storage/dropbox/index.d.ts +132 -0
- package/dist/storage/dropbox/index.js +1 -0
- package/dist/storage/firebase/index.d.ts +192 -0
- package/dist/storage/firebase/index.js +1 -0
- package/dist/storage/ftp/index.d.ts +91 -0
- package/dist/storage/ftp/index.js +1 -0
- package/dist/storage/gcs/index.d.ts +195 -5
- package/dist/storage/gcs/index.js +1 -4
- package/dist/storage/google-drive/index.d.ts +148 -0
- package/dist/storage/google-drive/index.js +1 -0
- package/dist/storage/local/index.d.ts +7 -4
- package/dist/storage/local/index.js +1 -3
- package/dist/storage/memory/index.d.ts +6 -0
- package/dist/storage/memory/index.js +1 -0
- package/dist/storage/netlify-blob/index.d.ts +147 -4
- package/dist/storage/netlify-blob/index.js +1 -3
- package/dist/storage/onedrive/index.d.ts +103 -0
- package/dist/storage/onedrive/index.js +1 -0
- package/dist/storage/pocketbase/index.d.ts +172 -0
- package/dist/storage/pocketbase/index.js +1 -0
- package/dist/storage/sftp/index.d.ts +92 -0
- package/dist/storage/sftp/index.js +1 -0
- package/dist/storage/sharepoint/index.d.ts +180 -0
- package/dist/storage/sharepoint/index.js +1 -0
- package/dist/storage/supabase/index.d.ts +115 -0
- package/dist/storage/supabase/index.js +1 -0
- package/dist/storage/uploadthing/index.d.ts +95 -0
- package/dist/storage/uploadthing/index.js +1 -0
- package/dist/storage/vercel-blob/index.d.ts +189 -4
- package/dist/storage/vercel-blob/index.js +1 -3
- package/dist/transformer/audio-transformer.d.ts +127 -125
- package/dist/transformer/audio-transformer.js +1 -278
- package/dist/transformer/image-transformer.d.ts +573 -568
- package/dist/transformer/image-transformer.js +1 -1100
- package/dist/transformer/index.d.ts +62 -5
- package/dist/transformer/index.js +1 -4
- package/dist/transformer/video-transformer.d.ts +144 -142
- package/dist/transformer/video-transformer.js +1 -310
- package/package.json +202 -51
- package/dist/handler/base/base-handler-core.d.ts +0 -91
- package/dist/handler/base/base-handler-fetch.d.ts +0 -76
- package/dist/handler/base/base-handler-node.d.ts +0 -137
- package/dist/handler/multipart/multipart-base.d.ts +0 -84
- package/dist/handler/multipart/multipart-fetch.d.ts +0 -64
- package/dist/handler/multipart/multipart.d.ts +0 -49
- package/dist/handler/rest/rest-base.d.ts +0 -106
- package/dist/handler/rest/rest-fetch.d.ts +0 -88
- package/dist/handler/rest/rest.d.ts +0 -93
- package/dist/handler/tus/tus-base.d.ts +0 -152
- package/dist/handler/tus/tus-fetch.d.ts +0 -72
- package/dist/handler/tus/tus.d.ts +0 -78
- package/dist/handler/types.d.ts +0 -53
- package/dist/handler/utils/request-parser.d.ts +0 -72
- package/dist/handler/utils/response-builder.d.ts +0 -83
- package/dist/handler/utils/storage-utils.d.ts +0 -10
- package/dist/handler/utils/stream-utils.d.ts +0 -29
- package/dist/handler/utils/upload-handlers.d.ts +0 -76
- package/dist/metrics/index.d.ts +0 -2
- package/dist/metrics/no-op-metrics.d.ts +0 -15
- package/dist/metrics/opentelemetry-metrics.d.ts +0 -55
- package/dist/openapi/rest.d.ts +0 -7
- package/dist/openapi/shared.d.ts +0 -13
- package/dist/openapi/transform.d.ts +0 -3
- package/dist/openapi/tus.d.ts +0 -7
- package/dist/openapi/xhr.d.ts +0 -7
- package/dist/packem_shared/AwsLightFile-tTneXZgG.js +0 -11
- package/dist/packem_shared/AwsLightMetaStorage-BWSOtVaN.js +0 -4
- package/dist/packem_shared/AwsLightStorage-Blv-GP4v.js +0 -133
- package/dist/packem_shared/AzureFile-CesgFzps.js +0 -8
- package/dist/packem_shared/AzureSMetaStorage-CFs-OYJT.js +0 -88
- package/dist/packem_shared/AzureStorage-B0v048hG.js +0 -357
- package/dist/packem_shared/BaseTransformer-C2gLib6v.js +0 -82
- package/dist/packem_shared/DiskStorage-Ck5yGQsq.js +0 -12
- package/dist/packem_shared/DiskStorageWithChecksum-BRl-V5x2.js +0 -238
- package/dist/packem_shared/ERRORS-D0apMqnc.js +0 -97
- package/dist/packem_shared/File-Bb3P23dr.js +0 -69
- package/dist/packem_shared/GCSConfig-vPP22kN6.js +0 -11
- package/dist/packem_shared/GCSFile-BIEunhAN.js +0 -8
- package/dist/packem_shared/GCSMetaStorage-CHZKMe7N.js +0 -7
- package/dist/packem_shared/GCStorage-C-gAuP0j.js +0 -406
- package/dist/packem_shared/LocalMetaStorage-CZHhKkMd.js +0 -7
- package/dist/packem_shared/MediaTransformer-D6658DL1.js +0 -1197
- package/dist/packem_shared/MetaStorage-pECeFOad.js +0 -46
- package/dist/packem_shared/Metadata-DRLXeJ0F.js +0 -89
- package/dist/packem_shared/Multipart-CRV21AUU.js +0 -128
- package/dist/packem_shared/Multipart-D2ryPMjD.js +0 -163
- package/dist/packem_shared/NetlifyBlobFile-CXzyjqrD.js +0 -14
- package/dist/packem_shared/NetlifyBlobMetaStorage-DxZ5aDvD.js +0 -9
- package/dist/packem_shared/NetlifyBlobStorage-CLPtjHqd.js +0 -376
- package/dist/packem_shared/NoOpMetrics-DhAk5rXc.js +0 -10
- package/dist/packem_shared/OpenTelemetryMetrics-BnxhqIaH.js +0 -67
- package/dist/packem_shared/Rest-DcxBMBjU.js +0 -228
- package/dist/packem_shared/Rest-DjwU3puo.js +0 -267
- package/dist/packem_shared/S3File-DZiyk9Qt.js +0 -11
- package/dist/packem_shared/S3MetaStorage-Dz9aDabA.js +0 -76
- package/dist/packem_shared/S3Storage-DHmTk-hU.js +0 -316
- package/dist/packem_shared/TUS_RESUMABLE-Dtfsffnj.js +0 -434
- package/dist/packem_shared/Tus-DFVlZHaX.js +0 -200
- package/dist/packem_shared/Tus-DaN0FmOy.js +0 -195
- package/dist/packem_shared/ValidationError-BfF1aE4h.js +0 -26
- package/dist/packem_shared/VercelBlobFile-BCg4aTEq.js +0 -18
- package/dist/packem_shared/VercelBlobMetaStorage-Bd9F-VFm.js +0 -9
- package/dist/packem_shared/VercelBlobStorage-DD9LMOS6.js +0 -261
- package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +0 -5
- package/dist/packem_shared/aws-light-meta-storage-DKJBgbR6.js +0 -446
- package/dist/packem_shared/backblaze-BlMnIcBC.js +0 -20
- package/dist/packem_shared/base-handler-core-BoAqTyz7.js +0 -303
- package/dist/packem_shared/base-handler-fetch-D4u2xits.js +0 -291
- package/dist/packem_shared/base-handler-node-DGzcHHAy.js +0 -730
- package/dist/packem_shared/cache-B88MXQ_2.js +0 -18
- package/dist/packem_shared/cloudflare-Bi1q8wXE.js +0 -21
- package/dist/packem_shared/defaultCloudStorageFileNameValidation-DUuacjWv.js +0 -11
- package/dist/packem_shared/digitalOcean-CWQRJM3L.js +0 -21
- package/dist/packem_shared/disk-storage-CD47QI30.js +0 -810
- package/dist/packem_shared/gcs-meta-storage-CJ8Uts_d.js +0 -158
- package/dist/packem_shared/has-content-CY66ehMK.js +0 -3
- package/dist/packem_shared/headers-YLRp1dLo.js +0 -1318
- package/dist/packem_shared/is-expired-CTThU1q5.js +0 -8
- package/dist/packem_shared/isRetryableError-Dycp7127.js +0 -82
- package/dist/packem_shared/isValidMediaType-BeDgiObq.js +0 -35
- package/dist/packem_shared/local-meta-storage-By-3SNBI.js +0 -649
- package/dist/packem_shared/minio-C2YBZQOw.js +0 -22
- package/dist/packem_shared/multipart-base-C994naBi.js +0 -102
- package/dist/packem_shared/part-match-BMNqHDYD.js +0 -96
- package/dist/packem_shared/path-CR6YkPXX-7R1-9CMk.js +0 -161
- package/dist/packem_shared/response-builder-BtnRiBUI.js +0 -45
- package/dist/packem_shared/rest-base-D9URIFkc.js +0 -457
- package/dist/packem_shared/restOpenApiSpec-D1JC_Jto.js +0 -800
- package/dist/packem_shared/s3-base-storage-C1DIHTYY.js +0 -510
- package/dist/packem_shared/sharedGet-Cpo7QUyu.js +0 -1019
- package/dist/packem_shared/storage-C6NSXb8h.js +0 -1175
- package/dist/packem_shared/tigris-Hac8TKnX.js +0 -21
- package/dist/packem_shared/transformOpenApiSpec-DWM5WtnN.js +0 -975
- package/dist/packem_shared/tusOpenApiSpec-mBZkl7he.js +0 -740
- package/dist/packem_shared/update-size-CCGm6i1J.js +0 -8
- package/dist/packem_shared/validator-BeX_lJet.js +0 -78
- package/dist/packem_shared/waitForStorage-Cscw85sx.js +0 -18
- package/dist/packem_shared/wasabi-DIyflHSd.js +0 -21
- package/dist/packem_shared/xhrOpenApiSpec-B1V5Dxrj.js +0 -264
- package/dist/storage/aws/clients/backblaze.d.ts +0 -12
- package/dist/storage/aws/clients/cloudflare.d.ts +0 -13
- package/dist/storage/aws/clients/digital-ocean.d.ts +0 -12
- package/dist/storage/aws/clients/minio.d.ts +0 -13
- package/dist/storage/aws/clients/tigris.d.ts +0 -12
- package/dist/storage/aws/clients/types.d.ts +0 -95
- package/dist/storage/aws/clients/wasabi.d.ts +0 -12
- package/dist/storage/aws/s3-base-storage.d.ts +0 -248
- package/dist/storage/aws/s3-client-adapter.d.ts +0 -110
- package/dist/storage/aws/s3-file.d.ts +0 -10
- package/dist/storage/aws/s3-meta-storage.d.ts +0 -15
- package/dist/storage/aws/s3-storage.d.ts +0 -70
- package/dist/storage/aws/types.d.ts +0 -119
- package/dist/storage/aws-light/aws-light-api-adapter.d.ts +0 -130
- package/dist/storage/aws-light/aws-light-file.d.ts +0 -10
- package/dist/storage/aws-light/aws-light-meta-storage.d.ts +0 -19
- package/dist/storage/aws-light/aws-light-storage.d.ts +0 -65
- package/dist/storage/aws-light/types.d.ts +0 -37
- package/dist/storage/azure/azure-file.d.ts +0 -6
- package/dist/storage/azure/azure-meta-storage.d.ts +0 -15
- package/dist/storage/azure/azure-storage.d.ts +0 -69
- package/dist/storage/azure/types.d.ts +0 -62
- package/dist/storage/gcs/fetch-error.d.ts +0 -11
- package/dist/storage/gcs/gcs-config.d.ts +0 -2
- package/dist/storage/gcs/gcs-file.d.ts +0 -6
- package/dist/storage/gcs/gcs-meta-storage.d.ts +0 -27
- package/dist/storage/gcs/gcs-storage.d.ts +0 -91
- package/dist/storage/gcs/types.d.ts +0 -55
- package/dist/storage/gcs/utils.d.ts +0 -7
- package/dist/storage/local/disk-storage-with-checksum.d.ts +0 -15
- package/dist/storage/local/disk-storage.d.ts +0 -135
- package/dist/storage/local/local-meta-storage.d.ts +0 -32
- package/dist/storage/meta-storage.d.ts +0 -30
- package/dist/storage/netlify-blob/netlify-blob-file.d.ts +0 -12
- package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +0 -7
- package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +0 -93
- package/dist/storage/netlify-blob/types.d.ts +0 -30
- package/dist/storage/storage.d.ts +0 -353
- package/dist/storage/types.d.ts +0 -221
- package/dist/storage/utils/file/file.d.ts +0 -25
- package/dist/storage/utils/file/get-file-status.d.ts +0 -9
- package/dist/storage/utils/file/has-content.d.ts +0 -9
- package/dist/storage/utils/file/index.d.ts +0 -10
- package/dist/storage/utils/file/is-expired.d.ts +0 -8
- package/dist/storage/utils/file/metadata.d.ts +0 -18
- package/dist/storage/utils/file/part-match.d.ts +0 -11
- package/dist/storage/utils/file/types.d.ts +0 -37
- package/dist/storage/utils/file/update-metadata.d.ts +0 -10
- package/dist/storage/utils/file/update-size.d.ts +0 -10
- package/dist/storage/vercel-blob/types.d.ts +0 -32
- package/dist/storage/vercel-blob/vercel-blob-file.d.ts +0 -16
- package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +0 -7
- package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +0 -76
- package/dist/transformer/base-transformer.d.ts +0 -63
- package/dist/transformer/media-transformer.d.ts +0 -332
- package/dist/transformer/types.d.ts +0 -652
- package/dist/transformer/utils.d.ts +0 -33
- package/dist/transformer/validation-error.d.ts +0 -23
- package/dist/utils/cache.d.ts +0 -32
- package/dist/utils/chunked-upload.d.ts +0 -65
- package/dist/utils/detect-file-type.d.ts +0 -28
- package/dist/utils/errors.d.ts +0 -74
- package/dist/utils/file-path-url-matcher.d.ts +0 -18
- package/dist/utils/headers.d.ts +0 -111
- package/dist/utils/http.d.ts +0 -92
- package/dist/utils/locker.d.ts +0 -26
- package/dist/utils/pipes/stream-checksum.d.ts +0 -47
- package/dist/utils/pipes/stream-length.d.ts +0 -22
- package/dist/utils/primitives/get-last-one.d.ts +0 -3
- package/dist/utils/primitives/is-record.d.ts +0 -2
- package/dist/utils/primitives/map-values.d.ts +0 -9
- package/dist/utils/primitives/pick.d.ts +0 -2
- package/dist/utils/primitives/to-milliseconds.d.ts +0 -12
- package/dist/utils/primitives/to-seconds.d.ts +0 -12
- package/dist/utils/range-checksum.d.ts +0 -33
- package/dist/utils/range-hasher.d.ts +0 -46
- package/dist/utils/retry.d.ts +0 -64
- package/dist/utils/types.d.ts +0 -108
- package/dist/utils/validation-error.d.ts +0 -22
- package/dist/utils/validator.d.ts +0 -36
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { F as File, g as FileReturn, B as BaseStorage } from "./storage.d-CEM1upWM.js";
|
|
2
|
+
import { M as MediaTransformerConfig, a as MediaTransformResult } from "./types.d-CrUWY4On.js";
|
|
3
|
+
/**
|
|
4
|
+
* Unified media transformer that automatically detects media type and routes to appropriate transformer.
|
|
5
|
+
* @template TFile The file type used by this transformer.
|
|
6
|
+
* @template TFileReturn The return type for file retrieval operations.
|
|
7
|
+
*
|
|
8
|
+
* Supports transformations via query parameters for on-demand media processing across all supported formats.
|
|
9
|
+
* @example
|
|
10
|
+
* // eslint-disable-next-line jsdoc/match-description
|
|
11
|
+
* ```ts
|
|
12
|
+
* const transformer = new MediaTransformer(storage, {
|
|
13
|
+
* maxImageSize: 10 * 1024 * 1024, // 10MB
|
|
14
|
+
* maxVideoSize: 100 * 1024 * 1024, // 100MB
|
|
15
|
+
* maxAudioSize: 50 * 1024 * 1024, // 50MB
|
|
16
|
+
* cache: new MapCache(), // In-memory caching
|
|
17
|
+
* saveTransformedFiles: true // Persist transformed files to storage
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Handle transformation via query parameters
|
|
21
|
+
* const result = await transformer.handle('file-id', {
|
|
22
|
+
* width: 800,
|
|
23
|
+
* height: 600,
|
|
24
|
+
* fit: 'cover',
|
|
25
|
+
* format: 'webp',
|
|
26
|
+
* quality: 80
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // Fetch with URL query string
|
|
30
|
+
* const result = await transformer.fetch('file-id', 'width=1280&height=720&codec=avc&bitrate=2000000');
|
|
31
|
+
*
|
|
32
|
+
* // Clear all cached transformed files
|
|
33
|
+
* transformer.clearSavedTransformedFiles();
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ## Configuration Options
|
|
37
|
+
*
|
|
38
|
+
* - `saveTransformedFiles`: Persist transformed files to storage for reuse (default: false)
|
|
39
|
+
* - `cache`: Cache instance for in-memory caching (optional)
|
|
40
|
+
* - `maxImageSize/maxVideoSize/maxAudioSize`: Size limits for processing
|
|
41
|
+
* - `cacheTtl`: Cache time-to-live in seconds
|
|
42
|
+
*
|
|
43
|
+
* ## Supported Query Parameters
|
|
44
|
+
*
|
|
45
|
+
* ### Common Parameters
|
|
46
|
+
* - `format`: Output format (jpeg/png/webp/avif/mp4/webm/mkv/mp3/wav/ogg/aac/flac)
|
|
47
|
+
* - `quality`: Quality for images (0-100), bitrate for video/audio
|
|
48
|
+
*
|
|
49
|
+
* ### Image Parameters
|
|
50
|
+
* - `width`: Width in pixels
|
|
51
|
+
* - `height`: Height in pixels
|
|
52
|
+
* - `fit`: Resize fit mode - cover/contain/fill/inside/outside
|
|
53
|
+
* - `position`: Position for cover/contain fits
|
|
54
|
+
* - `withoutEnlargement`: Avoid enlarging smaller images (boolean)
|
|
55
|
+
* - `withoutReduction`: Avoid reducing larger images (boolean)
|
|
56
|
+
* - `kernel`: Resize kernel - nearest/cubic/mitchell/lanczos2/lanczos3
|
|
57
|
+
* - `fastShrinkOnLoad`: Fast shrink on load (boolean)
|
|
58
|
+
* - `left/top/cropWidth/cropHeight`: Crop parameters
|
|
59
|
+
* - `angle`: Rotation angle in degrees (any number, but angles other than 90°/180°/270° use interpolation and may affect quality)
|
|
60
|
+
* - `background`: Background color for rotation
|
|
61
|
+
* - `blur`: Apply blur effect (boolean)
|
|
62
|
+
* - `sharpen`: Apply sharpening (boolean)
|
|
63
|
+
* - `median`: Apply median filter with size (number)
|
|
64
|
+
* // eslint-disable-next-line jsdoc/match-description
|
|
65
|
+
* - `clahe`: Apply CLAHE (Contrast Limited Adaptive Histogram Equalization) (boolean)
|
|
66
|
+
* - `threshold`: Apply thresholding with value (0-255)
|
|
67
|
+
* - `gamma`: Apply gamma correction (boolean)
|
|
68
|
+
* - `negate`: Negate (invert) the image (boolean)
|
|
69
|
+
* - `normalise/normalize`: Normalise the image (boolean)
|
|
70
|
+
* - `flatten`: Flatten alpha channel (boolean)
|
|
71
|
+
* - `unflatten`: Unflatten alpha channel (boolean)
|
|
72
|
+
* - `flip`: Flip image vertically (boolean)
|
|
73
|
+
* - `flop`: Flop image horizontally (boolean)
|
|
74
|
+
* - `greyscale/grayscale`: Convert to greyscale (boolean)
|
|
75
|
+
* - `modulate`: Apply modulation effects (boolean)
|
|
76
|
+
* - `brightness`: Brightness multiplier for modulation (number)
|
|
77
|
+
* - `saturation`: Saturation multiplier for modulation (number)
|
|
78
|
+
* - `hue`: Hue rotation in degrees for modulation (number)
|
|
79
|
+
* // eslint-disable-next-line jsdoc/match-description
|
|
80
|
+
* - `lightness`: Lightness adjustment for modulation (number)
|
|
81
|
+
* - `tint`: Apply tinting (boolean)
|
|
82
|
+
* - `colourspace`: Convert colourspace - srgb/rgb/cmyk/lab/b-w
|
|
83
|
+
*
|
|
84
|
+
* ### Video Parameters
|
|
85
|
+
* - `width/height/fit`: Same as images
|
|
86
|
+
* - `codec`: Video codec - avc/hevc/vp8/vp9/av1
|
|
87
|
+
* - `bitrate`: Video bitrate in bits per second
|
|
88
|
+
* - `frameRate`: Frame rate in Hz
|
|
89
|
+
* - `keyFrameInterval`: Key frame interval in seconds
|
|
90
|
+
* - `angle`: Rotation angle in degrees (any number, but angles other than 90°/180°/270° use interpolation and may affect quality)
|
|
91
|
+
* - `background`: Background color for rotation
|
|
92
|
+
*
|
|
93
|
+
* ### Audio Parameters
|
|
94
|
+
* - `sampleRate`: Sample rate in Hz
|
|
95
|
+
* - `numberOfChannels`: Number of channels
|
|
96
|
+
* - `codec`: Audio codec - aac/opus/mp3/vorbis/flac
|
|
97
|
+
* - `bitrate`: Audio bitrate in bits per second
|
|
98
|
+
*
|
|
99
|
+
* ## File Persistence
|
|
100
|
+
*
|
|
101
|
+
* When `saveTransformedFiles` is enabled, transformed files are automatically saved to storage
|
|
102
|
+
* with deterministic IDs based on the original file and transformation parameters. Subsequent
|
|
103
|
+
* requests for the same transformation will serve the cached file directly, improving performance
|
|
104
|
+
* and reducing processing costs.
|
|
105
|
+
*/
|
|
106
|
+
declare class MediaTransformer<TFile extends File = File, TFileReturn extends FileReturn = FileReturn> {
|
|
107
|
+
private readonly storage;
|
|
108
|
+
private readonly imageTransformer?;
|
|
109
|
+
private readonly videoTransformer?;
|
|
110
|
+
private readonly audioTransformer?;
|
|
111
|
+
private readonly config;
|
|
112
|
+
private readonly logger;
|
|
113
|
+
/**
|
|
114
|
+
* Creates a new MediaTransformer instance.
|
|
115
|
+
* @param storage The storage backend for retrieving and storing media files.
|
|
116
|
+
* @param config Configuration options for the media transformer including transformer classes and settings.
|
|
117
|
+
* @throws Error if no transformer classes are provided in the configuration.
|
|
118
|
+
*/
|
|
119
|
+
constructor(storage: BaseStorage<TFile, TFileReturn>, config?: MediaTransformerConfig<TFile, TFileReturn>);
|
|
120
|
+
supportedFormats(): string[];
|
|
121
|
+
/**
|
|
122
|
+
* Handles media transformation based on query parameters.
|
|
123
|
+
* @param fileId File identifier.
|
|
124
|
+
* @param query Query parameters for transformation.
|
|
125
|
+
* @returns Unified transformation result.
|
|
126
|
+
*/
|
|
127
|
+
handle(fileId: string, query: Record<string, string | undefined> | URLSearchParams | string): Promise<MediaTransformResult>;
|
|
128
|
+
/**
|
|
129
|
+
* Fetches media transformation with URL query string support.
|
|
130
|
+
* @param fileId File identifier.
|
|
131
|
+
* @param queryString URL query string (e.g., "width=800&height=600&format=webp").
|
|
132
|
+
* @returns Unified transformation result.
|
|
133
|
+
*/
|
|
134
|
+
fetch(fileId: string, queryString: string): Promise<MediaTransformResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Clears cache for a specific file across all transformers.
|
|
137
|
+
* @param fileId Optional file identifier to clear cache for. If omitted, clears all cache.
|
|
138
|
+
*/
|
|
139
|
+
clearCache(fileId?: string): void;
|
|
140
|
+
/**
|
|
141
|
+
* Clears all saved transformed files from storage.
|
|
142
|
+
* @remarks This is a maintenance operation and may take time for large numbers of files.
|
|
143
|
+
*/
|
|
144
|
+
clearSavedTransformedFiles(): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Clears saved transformed files for a specific original file.
|
|
147
|
+
* @param originalFileId Original file identifier to clear transformed files for.
|
|
148
|
+
*/
|
|
149
|
+
clearSavedTransformedFilesForFile(originalFileId: string): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Gets cache statistics (combined from all transformers).
|
|
152
|
+
* @returns Cache statistics for audio, image, and video transformers.
|
|
153
|
+
*/
|
|
154
|
+
getCacheStats(): {
|
|
155
|
+
audio?: {
|
|
156
|
+
maxSize: number;
|
|
157
|
+
size: number;
|
|
158
|
+
};
|
|
159
|
+
image?: {
|
|
160
|
+
maxSize: number;
|
|
161
|
+
size: number;
|
|
162
|
+
};
|
|
163
|
+
video?: {
|
|
164
|
+
maxSize: number;
|
|
165
|
+
size: number;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Validates query parameters for the given media type.
|
|
170
|
+
* @param query The query parameters to validate.
|
|
171
|
+
* @param mediaType The media type being validated ('image', 'video', or 'audio').
|
|
172
|
+
* @throws {ValidationError} When invalid parameters are provided.
|
|
173
|
+
*/
|
|
174
|
+
private validateQueryParameters;
|
|
175
|
+
/**
|
|
176
|
+
* Validates query parameters for image transformations. Checks for invalid video/audio-only parameters, invalid fit values, invalid rotation angles, invalid formats, and incomplete crop parameter sets.
|
|
177
|
+
* @param query Query parameters to validate.
|
|
178
|
+
* @throws {ValidationError} When validation fails.
|
|
179
|
+
*/
|
|
180
|
+
private validateImageQueryParameters;
|
|
181
|
+
/**
|
|
182
|
+
* Validates query parameters for video transformations. Checks for invalid audio-only parameters, invalid fit values, invalid rotation angles, invalid codecs, invalid formats, incomplete crop parameter sets, and invalid numeric values.
|
|
183
|
+
* @param query Query parameters to validate.
|
|
184
|
+
* @throws {ValidationError} When validation fails.
|
|
185
|
+
*/
|
|
186
|
+
private validateVideoQueryParameters;
|
|
187
|
+
/**
|
|
188
|
+
* Generates a unique ID for transformed files based on original file and transformations.
|
|
189
|
+
* @param originalFileId The original file identifier.
|
|
190
|
+
* @param query The transformation query parameters.
|
|
191
|
+
* @param mediaType The media type (image, video, audio).
|
|
192
|
+
* @returns Unique deterministic identifier for the transformed file.
|
|
193
|
+
* @private
|
|
194
|
+
*/
|
|
195
|
+
private generateTransformedFileId;
|
|
196
|
+
/**
|
|
197
|
+
* Checks if the query contains any transformations.
|
|
198
|
+
* @param query The transformation query parameters.
|
|
199
|
+
* @returns True if any transformations are requested.
|
|
200
|
+
* @private
|
|
201
|
+
*/
|
|
202
|
+
private hasTransformations;
|
|
203
|
+
/**
|
|
204
|
+
* Creates a MediaTransformResult from a stored transformed file.
|
|
205
|
+
* @param storedFile The stored transformed file.
|
|
206
|
+
* @param mediaType The media type (image, video, audio).
|
|
207
|
+
* @param originalFile The original file information.
|
|
208
|
+
* @returns Media transformation result with metadata.
|
|
209
|
+
* @private
|
|
210
|
+
*/
|
|
211
|
+
private createMediaTransformResult;
|
|
212
|
+
/**
|
|
213
|
+
* Extracts format from content type.
|
|
214
|
+
* @param contentType MIME content type string.
|
|
215
|
+
* @returns Format string extracted from content type.
|
|
216
|
+
* @private
|
|
217
|
+
*/
|
|
218
|
+
private getFormatFromContentType;
|
|
219
|
+
/**
|
|
220
|
+
* Saves transformed file to storage.
|
|
221
|
+
* @param result The transformation result to save.
|
|
222
|
+
* @param originalFileId The original file identifier.
|
|
223
|
+
* @param query The transformation query parameters.
|
|
224
|
+
* @param mediaType The media type (image, video, audio).
|
|
225
|
+
* @returns Promise that resolves when file is saved.
|
|
226
|
+
* @private
|
|
227
|
+
*/
|
|
228
|
+
private saveTransformedFile;
|
|
229
|
+
/**
|
|
230
|
+
* Validates query parameters for audio transformations. Checks for invalid video-only parameters, invalid codecs, invalid formats, and invalid numeric values.
|
|
231
|
+
* @param query Query parameters to validate.
|
|
232
|
+
* @throws {ValidationError} When validation fails.
|
|
233
|
+
*/
|
|
234
|
+
private validateAudioQueryParameters;
|
|
235
|
+
/**
|
|
236
|
+
* Handles image transformation.
|
|
237
|
+
* @param fileId The file identifier.
|
|
238
|
+
* @param query The transformation query parameters.
|
|
239
|
+
* @returns Promise resolving to media transformation result.
|
|
240
|
+
* @private
|
|
241
|
+
*/
|
|
242
|
+
private handleImageTransformation;
|
|
243
|
+
/**
|
|
244
|
+
* Handles video transformation.
|
|
245
|
+
* @param fileId The file identifier.
|
|
246
|
+
* @param query The transformation query parameters.
|
|
247
|
+
* @returns Promise resolving to media transformation result.
|
|
248
|
+
* @private
|
|
249
|
+
*/
|
|
250
|
+
private handleVideoTransformation;
|
|
251
|
+
/**
|
|
252
|
+
* Handles audio transformation.
|
|
253
|
+
* @param fileId The file identifier.
|
|
254
|
+
* @param query The transformation query parameters.
|
|
255
|
+
* @returns Promise resolving to media transformation result.
|
|
256
|
+
* @private
|
|
257
|
+
*/
|
|
258
|
+
private handleAudioTransformation;
|
|
259
|
+
/**
|
|
260
|
+
* Parses query parameters from various input formats.
|
|
261
|
+
* @param query Query parameters in various formats.
|
|
262
|
+
* @returns Normalized MediaTransformQuery object.
|
|
263
|
+
* @private
|
|
264
|
+
*/
|
|
265
|
+
private parseQuery;
|
|
266
|
+
/**
|
|
267
|
+
* Parses boolean parameter from string.
|
|
268
|
+
* @param value String value to parse.
|
|
269
|
+
* @returns Boolean value or undefined.
|
|
270
|
+
* @private
|
|
271
|
+
*/
|
|
272
|
+
private parseBooleanParameter;
|
|
273
|
+
/**
|
|
274
|
+
* Parses URLSearchParams into MediaTransformQuery.
|
|
275
|
+
* @param parameters URL search parameters object.
|
|
276
|
+
* @returns MediaTransformQuery object with parsed parameters.
|
|
277
|
+
* @private
|
|
278
|
+
*/
|
|
279
|
+
private parseURLSearchParams;
|
|
280
|
+
/**
|
|
281
|
+
* Detects media type from MIME type.
|
|
282
|
+
* @param contentType MIME content type string.
|
|
283
|
+
* @returns Detected media type.
|
|
284
|
+
* @throws Error if content type is missing or unsupported.
|
|
285
|
+
* @private
|
|
286
|
+
*/
|
|
287
|
+
private detectMediaType;
|
|
288
|
+
/**
|
|
289
|
+
* Checks if query has image transformations.
|
|
290
|
+
* @param query The transformation query parameters.
|
|
291
|
+
* @returns True if image transformations are requested.
|
|
292
|
+
* @private
|
|
293
|
+
*/
|
|
294
|
+
private hasImageTransformations;
|
|
295
|
+
/**
|
|
296
|
+
* Checks if query has video transformations.
|
|
297
|
+
* @param query The transformation query parameters.
|
|
298
|
+
* @returns True if video transformations are requested.
|
|
299
|
+
* @private
|
|
300
|
+
*/
|
|
301
|
+
private hasVideoTransformations;
|
|
302
|
+
/**
|
|
303
|
+
* Checks if query has audio transformations.
|
|
304
|
+
* @param query The transformation query parameters.
|
|
305
|
+
* @returns True if audio transformations are requested.
|
|
306
|
+
* @private
|
|
307
|
+
*/
|
|
308
|
+
private hasAudioTransformations;
|
|
309
|
+
/**
|
|
310
|
+
* Converts ImageTransformer result to unified format.
|
|
311
|
+
* @param result The image transformation result.
|
|
312
|
+
* @returns Unified media transformation result.
|
|
313
|
+
* @private
|
|
314
|
+
*/
|
|
315
|
+
private convertImageResult;
|
|
316
|
+
/**
|
|
317
|
+
* Converts VideoTransformer result to unified format.
|
|
318
|
+
* @param result The video transformation result.
|
|
319
|
+
* @returns Unified media transformation result.
|
|
320
|
+
* @private
|
|
321
|
+
*/
|
|
322
|
+
private convertVideoResult;
|
|
323
|
+
/**
|
|
324
|
+
* Converts AudioTransformer result to unified format.
|
|
325
|
+
* @param result The audio transformation result.
|
|
326
|
+
* @returns Unified media transformation result.
|
|
327
|
+
* @private
|
|
328
|
+
*/
|
|
329
|
+
private convertAudioResult;
|
|
330
|
+
}
|
|
331
|
+
export { MediaTransformer as M };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { F as File, k as MetaStorageOptions, M as MetaStorage, l as BaseStorageOptions, d as FileInit, O as OperationOptions, e as FilePart, f as FileQuery, g as FileReturn, B as BaseStorage } from "./storage.d-CEM1upWM.js";
|
|
3
|
+
/**
|
|
4
|
+
* Map-backed metadata storage used by {@link MemoryStorage}. Holds a deep-copied
|
|
5
|
+
* snapshot of each `File` so callers can mutate the returned object without leaking
|
|
6
|
+
* back into the backing store.
|
|
7
|
+
*/
|
|
8
|
+
declare class MemoryMetaStorage<T extends File = File> extends MetaStorage<T> {
|
|
9
|
+
private readonly store;
|
|
10
|
+
constructor(config?: MetaStorageOptions & {
|
|
11
|
+
store?: Map<string, T>;
|
|
12
|
+
});
|
|
13
|
+
override save(id: string, file: T): Promise<T>;
|
|
14
|
+
override get(id: string): Promise<T>;
|
|
15
|
+
override delete(id: string): Promise<void>;
|
|
16
|
+
override touch(id: string, file: T): Promise<T>;
|
|
17
|
+
/** Reset the in-memory metadata. Test/reset helper. */
|
|
18
|
+
clear(): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Public options for {@link MemoryStorage}. The `initial` record lets tests seed the
|
|
22
|
+
* store with a few key→bytes pairs; pass `metaStorage` to share metadata with another
|
|
23
|
+
* `Files` instance (rarely needed — the memory adapter is meant to be ephemeral).
|
|
24
|
+
*/
|
|
25
|
+
interface MemoryStorageOptions<T extends File = File> extends BaseStorageOptions<T> {
|
|
26
|
+
/** Pre-populate the store with these key → bytes entries. */
|
|
27
|
+
initial?: Record<string, Buffer | Uint8Array | string>;
|
|
28
|
+
metaStorageConfig?: MetaStorageOptions;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Stored entry in the backing {@link Map}. `bytes` is the raw payload; `meta` is a
|
|
32
|
+
* lightweight per-key metadata snapshot so {@link MemoryStorage.list} and
|
|
33
|
+
* `head` can answer without dragging the file class around.
|
|
34
|
+
*/
|
|
35
|
+
interface MemoryEntry {
|
|
36
|
+
bytes: Buffer;
|
|
37
|
+
contentType: string;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
eTag: string;
|
|
40
|
+
metadata: Record<string, unknown>;
|
|
41
|
+
modifiedAt: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* In-memory storage adapter backed by a {@link Map}.
|
|
45
|
+
*
|
|
46
|
+
* Implements the full {@link BaseStorage} surface without touching disk or any
|
|
47
|
+
* external service — useful for tests, ephemeral environments, and as a
|
|
48
|
+
* reference implementation. `raw` returns the backing map so tests can inspect
|
|
49
|
+
* or reset state directly:
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* const storage = new MemoryStorage({ initial: { "users/1.json": '{"id":1}' } });
|
|
53
|
+
* storage.raw.clear();
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* Metadata is shallow-cloned on both write and read so callers never share a
|
|
57
|
+
* mutable object with the store.
|
|
58
|
+
*/
|
|
59
|
+
declare class MemoryStorage<TFile extends File = File> extends BaseStorage<TFile> {
|
|
60
|
+
static override readonly name: string;
|
|
61
|
+
override checksumTypes: string[];
|
|
62
|
+
override readonly supportsRange: boolean;
|
|
63
|
+
meta: MemoryMetaStorage<TFile>;
|
|
64
|
+
private readonly store;
|
|
65
|
+
constructor(config?: MemoryStorageOptions<TFile>);
|
|
66
|
+
override get raw(): Map<string, MemoryEntry>;
|
|
67
|
+
create(fileInit: FileInit, _options?: OperationOptions): Promise<TFile>;
|
|
68
|
+
write(part: FilePart | FileQuery, _options?: OperationOptions): Promise<TFile>;
|
|
69
|
+
get({
|
|
70
|
+
id
|
|
71
|
+
}: FileQuery, _options?: OperationOptions & {
|
|
72
|
+
range?: {
|
|
73
|
+
end?: number;
|
|
74
|
+
start: number;
|
|
75
|
+
};
|
|
76
|
+
}): Promise<FileReturn>;
|
|
77
|
+
override getStream({
|
|
78
|
+
id
|
|
79
|
+
}: FileQuery, _options?: OperationOptions & {
|
|
80
|
+
range?: {
|
|
81
|
+
end?: number;
|
|
82
|
+
start: number;
|
|
83
|
+
};
|
|
84
|
+
}): Promise<{
|
|
85
|
+
headers?: Record<string, string>;
|
|
86
|
+
size?: number;
|
|
87
|
+
stream: Readable;
|
|
88
|
+
}>;
|
|
89
|
+
override exists({
|
|
90
|
+
id
|
|
91
|
+
}: FileQuery): Promise<boolean>;
|
|
92
|
+
delete({
|
|
93
|
+
id
|
|
94
|
+
}: FileQuery): Promise<TFile>;
|
|
95
|
+
copy(source: string, destination: string): Promise<TFile>;
|
|
96
|
+
move(source: string, destination: string): Promise<TFile>;
|
|
97
|
+
override list(): Promise<TFile[]>;
|
|
98
|
+
override getReadUrl(key: string): Promise<string>;
|
|
99
|
+
override getUploadUrl(key: string): Promise<string>;
|
|
100
|
+
}
|
|
101
|
+
export { MemoryMetaStorage as M, MemoryStorage as a, MemoryStorageOptions as b };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=e=>{const s=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.MINIO_ACCESS_KEY_ID??process.env.MINIO_ACCESS_KEY,r=e?.endpoint??process.env.AWS_ENDPOINT??process.env.MINIO_ENDPOINT,c=e?.region??process.env.AWS_REGION??process.env.MINIO_REGION,n=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.MINIO_SECRET_ACCESS_KEY??process.env.MINIO_SECRET_KEY;if(!c||!s||!n||!r)throw new Error("Missing required parameters for Minio client.");return{credentials:{accessKeyId:s,secretAccessKey:n},endpoint:r,forcePathStyle:!0,region:c}};export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as c}from"./headers-BAiAKekR.js";class p{async handlePost(e,s,n){const i={contentType:e.mediaType||"application/octet-stream",metadata:{},originalName:e.filename,size:e.size};for(const t of s)if(!t.isFile&&t.name){let o={};if(t.name==="metadata"&&t.text)try{o=JSON.parse(t.text)}catch{}else t.name&&(o={[t.name]:t.text});Object.assign(i.metadata,o)}const d=await this.storage.create(i),l=this.createStreamFromBytes(e.bytes),r=await this.storage.write({body:l,contentLength:e.size,id:d.id,start:0});let a=r;if(Object.keys(i.metadata).length>0){const t={...r.metadata,...i.metadata};a={...await this.storage.update({id:r.id},{metadata:t}),status:r.status}}const m=this.buildFileUrl(n,a);return{...a,headers:{Location:m,...a.expiredAt===void 0?{}:{"X-Upload-Expires":a.expiredAt.toString()},...a.ETag===void 0?{}:{ETag:a.ETag}},statusCode:200}}async handleDelete(e){const s=await this.storage.delete({id:e});if(s.status===void 0)throw c(404,"File not found");return{...s,headers:{},statusCode:204}}get storage(){throw new Error("storage must be implemented")}buildFileUrl(e,s){throw new Error("buildFileUrl must be implemented")}}export{p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const k=e=>{let o,s;const r=e.leewayMs??6e4,a=async()=>{const c=Date.now(),n=await fetch(e.tokenUrl,{body:e.buildBody(),headers:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST"});if(!n.ok){const i=await n.text().catch(()=>"");throw new Error(`${e.provider}: token exchange failed (${n.status}): ${i||n.statusText}`)}const t=await n.json();if(!t.access_token)throw new Error(`${e.provider}: token response missing access_token`);return o={expiresOnMs:c+(t.expires_in??3600)*1e3,token:t.access_token},e.onRefresh?.(t.access_token),t.refresh_token&&e.onRefreshToken?.(t.refresh_token),t.access_token};return{getAccessToken:async()=>o&&o.expiresOnMs-r>Date.now()?o.token:s||(s=a().finally(()=>{s=void 0}),s)}};export{k as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=e=>{const c=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.ORACLE_CLOUD_ACCESS_KEY_ID??process.env.ORACLE_CLOUD_ACCESS_KEY,r=e?.namespace??process.env.ORACLE_CLOUD_NAMESPACE,s=e?.region??process.env.ORACLE_CLOUD_REGION,C=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.ORACLE_CLOUD_SECRET_ACCESS_KEY??process.env.ORACLE_CLOUD_SECRET_KEY;if(!r||!s||!c||!C)throw new Error("Missing required parameters for Oracle Cloud Object Storage client.");return{credentials:{accessKeyId:c,secretAccessKey:C},endpoint:`https://${r}.compat.objectstorage.${s}.oraclecloud.com`,forcePathStyle:!0,region:s}};export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=e=>{const s=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.OVHCLOUD_ACCESS_KEY_ID??process.env.OVHCLOUD_ACCESS_KEY,n=e?.endpoint??process.env.OVHCLOUD_ENDPOINT,r=e?.region??process.env.OVHCLOUD_REGION,c=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.OVHCLOUD_SECRET_ACCESS_KEY??process.env.OVHCLOUD_SECRET_KEY;if(!r||!s||!c)throw new Error("Missing required parameters for OVHcloud Object Storage client.");const o=r.toLowerCase();return{credentials:{accessKeyId:s,secretAccessKey:c},endpoint:n??`https://s3.${o}.io.cloud.ovh.net`,forcePathStyle:!1,region:o}};export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(i,s)=>i.size!==void 0&&s.size!==void 0&&i.size>0&&s.size>0&&i.size>s.size?!1:s.size===void 0?!0:(i.start||0)+(i.contentLength||0)<=s.size;export{e as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const g=/^[A-Z]:\//i,a=(e="")=>e&&e.replaceAll("\\","/").replace(g,l=>l.toUpperCase()),$=/^[/\\]{2}/,u=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,p=/^[A-Z]:$/i,A=(e,l)=>{let t="",n=0,f=-1,c=0,r;for(let s=0;s<=e.length;++s){if(s<e.length)r=e[s];else{if(r==="/")break;r="/"}if(r==="/"){if(!(f===s-1||c===1))if(c===2){if(t.length<2||n!==2||!t.endsWith(".")||t.at(-2)!=="."){if(t.length>2){const h=t.lastIndexOf("/");h===-1?(t="",n=0):(t=t.slice(0,h),n=t.length-1-t.lastIndexOf("/")),f=s,c=0;continue}else if(t.length>0){t="",n=0,f=s,c=0;continue}}l&&(t+=t.length>0?"/..":"..",n=2)}else t.length>0?t+=`/${e.slice(f+1,s)}`:t=e.slice(f+1,s),n=s-f-1;f=s,c=0}else r==="."&&c!==-1?++c:c=-1}return t},o=e=>u.test(e),d=function(e){if(e.length===0)return".";e=a(e);const l=$.exec(e),t=o(e),n=e.at(-1)==="/";return e=A(e,!t),e.length===0?t?"/":n?"./":".":(n&&(e+="/"),p.test(e)&&(e+="/"),l?t?`//${e}`:`//./${e}`:t&&!o(e)?`/${e}`:e)},x=(...e)=>{let l="";for(const t of e)if(t)if(l.length>0){const n=l.at(-1)==="/",f=t[0]==="/";n&&f?l+=t.slice(1):l+=n||f?t:`/${t}`}else l+=t;return d(l)};export{o as A,d as W,x as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=async e=>{const t=[];for await(const r of e)t.push(Buffer.from(r));return Buffer.concat(t)},n=e=>{let t=0,r=e.length;for(;t<r&&e[t]==="/";)t+=1;for(;r>t&&e[r-1]==="/";)r-=1;return t===0&&r===e.length?e:e.slice(t,r)},o=e=>{const t=n(e),r=t.lastIndexOf("/");return r<=0?e.startsWith("/")&&r===0?"/":"":e.startsWith("/")?`/${t.slice(0,r)}`:t.slice(0,r)};export{o as e,n as r,s as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"mime";const d=(t,i={},e=200)=>({...t,headers:i,statusCode:e}),o=(t,i,e={})=>({Location:i,...t.expiredAt===void 0?{}:{"X-Upload-Expires":t.expiredAt.toString()},...t.ETag===void 0?{}:{ETag:t.ETag},...e}),n=(t,i)=>{const e=t.metadata||{},r={"x-chunked-upload":"true","x-upload-complete":i?"true":"false","x-upload-offset":String(t.bytesWritten||0)};return Array.isArray(e._chunks)&&e._chunks.length>0&&(r["x-received-chunks"]=JSON.stringify(e._chunks)),r},s=t=>({"Content-Length":String(t.size||0),"Content-Type":t.contentType,...t.expiredAt===void 0?{}:{"X-Upload-Expires":t.expiredAt.toString()},...t.modifiedAt===void 0?{}:{"Last-Modified":t.modifiedAt.toString()},...t.ETag===void 0?{}:{ETag:t.ETag}}),p=t=>{const i={};for(const[e,r]of Object.entries(t))i[e]=Array.isArray(r)?r.join(", "):String(r);return i};export{o as a,d as b,n as c,s as d,p as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as d}from"./headers-BAiAKekR.js";import{hasBody as _}from"type-is";import{b as h}from"./base-handler-core-EeV8gZck.js";import{ERRORS as E}from"./ERRORS-BIBxE2oR.js";import{b as g,a as C,c as S,d as X}from"./response-builder-CbSA8qPa.js";const M=(a,t={})=>{const e=h(a,"x-file-metadata",!0);if(!e)return t;try{return{...t,...JSON.parse(e)}}catch{return t}},v=a=>{if(!a)return;const t=2e3,e=a.length>t?a.slice(0,Math.max(0,t)):a,r=e.toLowerCase().indexOf("filename");if(r===-1)return;let s=r+8;for(;s<e.length&&(e[s]==="*"||e[s]===" "||e[s]===" ");)s++;if(s>=e.length||e[s]!=="=")return;for(s++;s<e.length&&(e[s]===" "||e[s]===" ");)s++;if(s>=e.length)return;let n=s,i;const o=e[s];return o==='"'||o==="'"?(n=s+1,i=e.indexOf(o,n),i===-1&&(i=e.indexOf(";",n),i===-1&&(i=e.length))):(i=e.indexOf(";",n),i===-1&&(i=e.length)),n>=i?void 0:e.substring(n,i).trim()||void 0},A=a=>{const t=h(a,"content-disposition",!0);return v(t)},L=a=>{const t=h(a,"x-chunked-upload",!0)==="true",e=h(a,"x-chunk-offset",!0),r=h(a,"x-total-size",!0),s={isChunkedUpload:t};if(e){const n=Number.parseInt(e,10);!Number.isNaN(n)&&n>=0&&(s.chunkOffset=n)}if(r){const n=Number.parseInt(r,10);!Number.isNaN(n)&&n>0&&(s.totalSize=n)}return s},P=(a,t=!1)=>{const e=h(a,"x-chunked-upload",!0)==="true";if(!(t&&e)){if(!_(a))throw d(400,"Request body is required");if(Number.parseInt(h(a,"content-length")||"0",10)===0&&!e)throw d(400,"Content-Length is required and must be greater than 0")}},B=(a,t=!1,e)=>{const r=h(a,"x-chunked-upload",!0)==="true",s=Number.parseInt(h(a,"content-length")||"0",10);if(!t&&!r&&s===0)throw d(400,"Content-Length is required and must be greater than 0");if(e!==void 0&&s>e)throw d(413,`File size exceeds maximum allowed size of ${e} bytes`);return s},W=(a,t,e="application/octet-stream")=>{const r=A(a),s=M(a),{isChunkedUpload:n,totalSize:i}=L(a),o=n&&i?i:t;return n&&i&&(s._chunkedUpload=!0,s._chunks=[],s._totalSize=i),{contentType:e,metadata:s,originalName:r,size:o}},x=(a,t)=>{if(a.length===0)return!1;const e=[...a].toSorted((n,i)=>n.offset-i.offset),r=e[0];if(r?.offset!==0)return!1;let s=r.length;for(let n=1;n<e.length;n+=1){const i=e[n];if(i){if(i.offset>s)return!1;s=Math.max(s,i.offset+i.length)}}return s>=t},T=(a,t,e,r)=>{if(Number.isNaN(a)||a<0)throw new Error("Chunk offset must be a valid non-negative number");if(t<=0)throw new Error("Chunk length must be greater than 0");if(t>r)throw new Error(`Chunk size exceeds maximum allowed size of ${r} bytes`);if(a+t>e)throw new Error(`Chunk exceeds file size. Offset: ${a}, Size: ${t}, Total: ${e}`)},D=(a,t)=>{const e=a.find(r=>r.offset===t.offset&&r.length===t.length);return e?t.checksum&&e.checksum!==t.checksum?a.map(r=>r.offset===t.offset?{...r,checksum:t.checksum}:r):a:[...a,t]},U=a=>(a.metadata||{})._chunkedUpload===!0,y=a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&typeof t._totalSize=="number")return t._totalSize};class j{async deleteSingle(t){const e=await this.storage.delete({id:t});if(e.status===void 0)throw d(404,"File not found");return{...e,headers:{},statusCode:204}}async handlePost(t,e,r,s,n){if(e&&t.size!==void 0){const l=typeof t.size=="number"?t.size:Number.parseInt(String(t.size),10);if(l>0&&l>this.storage.maxUploadSize)throw d(413,`File size exceeds maximum allowed size of ${this.storage.maxUploadSize} bytes`)}const i=await this.storage.create(t);if(e){const l=this.buildFileUrl(r,i);return g(i,{...C(i,l),"X-Chunked-Upload":"true","X-Upload-ID":i.id},201)}const o=await this.storage.write({body:s,contentLength:n,id:i.id,start:0}),c=this.buildFileUrl(r,o);return g(o,C(o,c),201)}async handlePut(t,e,r,s,n,i){let o,c=!1;try{await this.storage.getMeta(t),c=!0,i&&await this.storage.update({id:t},{metadata:i}),o=await this.storage.write({body:s,contentLength:n,id:t,start:0})}catch(f){const k=f;if(k.UploadErrorCode===E.FILE_NOT_FOUND||k.code==="ENOENT")try{const p=await this.storage.create(e);o=await this.storage.write({body:s,contentLength:n,id:p.id,start:0})}catch(p){throw p}else throw f}const l=this.buildFileUrl(r,o);return g(o,C(o,l),c?200:201)}async handlePatch(t,e,r,s,n,i){let o=await this.storage.getMeta(t);const c=o.metadata||{},l=U(o);if(l){const u=y(o);u&&o.size!==u&&(o={...o,size:u})}const f=typeof c._totalSize=="number"?c._totalSize:o.size||0;if(!l)throw d(400,"File is not a chunked upload. Use POST or PUT for full file uploads.");const k=100*1024*1024;try{T(e,r,f,k)}catch(u){throw u instanceof Error&&u.message.includes("exceeds maximum")?d(413,u.message):d(400,u instanceof Error?u.message:String(u))}if(o.status==="completed"){const u=this.buildFileUrl(n,o);return g(o,{...C(o,u),"X-Upload-Complete":"true"},200)}const p=await this.storage.withLock(`chunks:${t}`,async()=>{const u=(await this.storage.getMeta(t)).metadata??{},O=Array.isArray(u._chunks)?u._chunks:[],z=D(O,{checksum:s,length:r,offset:e});return await this.storage.update({id:t},{metadata:{...u,_chunks:z}}),z});let m=await this.storage.write({body:i,contentLength:r,id:t,start:e}),w=m.bytesWritten>=f;l&&(w=x(p,f),m.status==="completed"&&!w&&(await this.storage.update({id:t},{status:"part"}),m={...m,status:"part"}));const b=w&&m.bytesWritten!==f?{...m,bytesWritten:f}:m,N=this.buildFileUrl(n,b),F={...C(b,N),...S(b,w),"x-upload-offset":String(b.bytesWritten||0)};return g(b,F,w?200:202)}async handleHead(t){let e=await this.storage.getMeta(t);const r=U(e);if(r){const n=y(e);n&&e.size!==n&&(e={...e,size:n})}const s={...X(e)};if(r){const n=e.metadata||{},i=y(e)||e.size||0,o=Array.isArray(n._chunks)?n._chunks:[],c=x(o,i);Object.assign(s,S(e,c))}return g(e,s,200)}handleOptions(t,e){return{headers:{"Access-Control-Allow-Headers":"Authorization, Content-Type, Content-Length, Content-Disposition, X-File-Metadata, X-Chunked-Upload, X-Total-Size, X-Chunk-Offset, X-Chunk-Checksum","Access-Control-Allow-Methods":t.map(r=>r.toUpperCase()).join(", "),"Access-Control-Max-Age":86400,"X-Max-Upload-Size":String(e)},statusCode:204}}async deleteBatch(t){const e=await this.storage.deleteBatch(t);if(e.successfulCount===0&&e.failedCount>0){const r=e.failed.map(s=>s.id).join(", ");throw d(404,`Failed to delete files: ${r}`)}return{data:e.successful,headers:e.failedCount>0?{"X-Delete-Errors":JSON.stringify(e.failed),"X-Delete-Failed":String(e.failedCount),"X-Delete-Successful":String(e.successfulCount)}:{"X-Delete-Successful":String(e.successfulCount)},statusCode:e.successfulCount===t.length?204:207}}get storage(){throw new Error("storage must be implemented")}buildFileUrl(t,e){throw new Error("buildFileUrl must be implemented")}}export{j as X,B as a,A as b,L as c,W as e,v as p,P as v};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as n}from"node:crypto";import{createPaginationMetaSchemaObject as d,createPaginationSchemaObject as p}from"@visulima/pagination";import{sharedFileMetaSchemaObject as c,sharedErrorSchemaObject as l,sharedFileMetaExampleObject as m,sharedGetList as u,sharedGet as h,sharedGetMeta as f}from"./sharedErrorSchemaObject-YN65aAKj.js";const U=(a,e,i)=>{const{supportedTransformerFormat:o,tags:t,transformer:r}={tags:["REST"],transformer:!1,...i},s=n("sha256").update(e).digest("base64");return{components:{examples:m,parameters:{UploadIDinPath:{description:"Upload ID",in:"path",name:"id",schema:{type:"string"}}},responses:{404:{content:{"application/json":{example:{error:{code:"FileNotFound",message:"Not found"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Not Found"}},schemas:{"X-Chunk-Checksum":{description:"SHA256 checksum of the chunk data for validation. Format: 'sha256 <base64-encoded-checksum>'.",type:"string"},"X-Chunk-Offset":{description:"Byte offset for the chunk being uploaded. Required for PATCH requests in chunked uploads.",type:"integer"},"X-Chunked-Upload":{description:"Header to indicate chunked upload initialization. Set to 'true' to initialize a chunked upload session.",enum:["true"],type:"string"},"X-Chunked-Upload-Response":{description:"Indicates this is a chunked upload session. Returned in HEAD responses.",enum:["true"],type:"string"},"X-Received-Chunks":{description:"JSON array of received chunk offsets. Used for resumable uploads.",type:"string"},"X-Total-Size":{description:"Total size of the file in bytes for chunked uploads. Required when X-Chunked-Upload is 'true'.",type:"integer"},"X-Upload-Complete":{description:"Indicates if the upload is complete. Set to 'true' when all chunks have been uploaded.",enum:["true","false"],type:"string"},"X-Upload-Offset":{description:"Current upload offset in bytes. Returned in responses for chunked uploads.",type:"integer"},...p("FileMetaPagination",{$ref:"#/components/schemas/PaginationMeta"},"#/components/schemas/PaginationMeta"),...d("PaginationMeta"),...l,...c}},paths:{[`${e.replace(/\/$/,"")}/{id}/metadata`]:{get:f(`${s}RestGetFileMeta`,t)},[`${e.replace(/\/$/,"")}/{id}`]:{delete:{description:"Delete a single file",operationId:`${s}RestDeleteFile`,parameters:[{$ref:"#/components/parameters/UploadIDinPath"}],responses:{204:{description:"No Content - File deleted successfully"},404:{$ref:"#/components/responses/404"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Delete file",tags:t},get:h(`${s}RestGetFile`,t,r,o),head:{description:"Get file metadata and upload progress. For chunked uploads, returns progress information including current offset and completion status.",operationId:`${s}RestHeadFile`,parameters:[{$ref:"#/components/parameters/UploadIDinPath"}],responses:{200:{description:"OK",headers:{"Content-Length":{description:"File size in bytes",schema:{type:"integer"}},"Content-Type":{description:"MIME type of the file",schema:{type:"string"}},ETag:{description:"Entity tag for caching",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},"Last-Modified":{description:"Last modified date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}},"X-Chunked-Upload":{description:"Indicates this is a chunked upload session",schema:{$ref:"#/components/schemas/X-Chunked-Upload-Response"}},"X-Received-Chunks":{description:"JSON array of received chunk offsets (chunked uploads only)",schema:{$ref:"#/components/schemas/X-Received-Chunks"}},"X-Upload-Complete":{description:"Indicates if upload is complete (chunked uploads only)",schema:{$ref:"#/components/schemas/X-Upload-Complete"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}},"X-Upload-Offset":{description:"Current upload offset in bytes (chunked uploads only)",schema:{$ref:"#/components/schemas/X-Upload-Offset"}}}},404:{$ref:"#/components/responses/404"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Get file metadata",tags:t},patch:{description:"Upload a chunk for chunked uploads. Requires X-Chunk-Offset header and chunk data in the request body.",operationId:`${s}RestPatchChunk`,parameters:[{$ref:"#/components/parameters/UploadIDinPath"},{description:"Byte offset for this chunk",in:"header",name:"X-Chunk-Offset",required:!0,schema:{$ref:"#/components/schemas/X-Chunk-Offset"}},{description:"SHA256 checksum of the chunk (optional)",in:"header",name:"X-Chunk-Checksum",required:!1,schema:{$ref:"#/components/schemas/X-Chunk-Checksum"}}],requestBody:{content:{"application/octet-stream":{description:"Chunk data as raw binary",schema:{format:"binary",type:"string"}}},description:"Chunk data",required:!0},responses:{200:{description:"Chunk uploaded successfully",headers:{ETag:{description:"Upload ETag",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},Location:{description:"File URL",schema:{example:`${a}${e}/file-id`,format:"uri",type:"string"}},"X-Upload-Complete":{description:"Indicates if upload is complete",schema:{$ref:"#/components/schemas/X-Upload-Complete"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}},"X-Upload-Offset":{description:"Current upload offset after this chunk",schema:{$ref:"#/components/schemas/X-Upload-Offset"}}}},201:{description:"Upload completed (all chunks received)",headers:{ETag:{description:"Upload ETag",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},Location:{description:"File URL",schema:{example:`${a}${e}/file-id`,format:"uri",type:"string"}},"X-Upload-Complete":{description:"Upload is complete",schema:{enum:["true"],type:"string"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},400:{content:{"application/json":{example:{error:{code:"BadRequest",message:"X-Chunk-Offset header is required"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Bad Request"},404:{content:{"application/json":{example:{error:{code:"FileNotFound",message:"Upload session not found"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Not Found"},413:{content:{"application/json":{example:{error:{code:"RequestEntityTooLarge",message:"Chunk size exceeds maximum allowed size of 104857600 bytes"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Request Entity Too Large"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Upload chunk",tags:t},put:{description:"Create or update a file. Requires file ID in the URL path. If file exists, it will be overwritten.",operationId:`${s}RestPutFile`,parameters:[{$ref:"#/components/parameters/UploadIDinPath"}],requestBody:{content:{"application/octet-stream":{description:"File data as raw binary",schema:{format:"binary",type:"string"}}},description:"File data",required:!0},responses:{200:{description:"File updated successfully",headers:{ETag:{description:"Upload ETag",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},Location:{description:"File URL",schema:{example:`${a}${e}/file-id`,format:"uri",type:"string"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},201:{description:"File created successfully",headers:{ETag:{description:"Upload ETag",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},Location:{description:"File URL",schema:{example:`${a}${e}/file-id`,format:"uri",type:"string"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},400:{content:{"application/json":{example:{error:{code:"BadRequest",message:"Request body is required"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Bad Request"},413:{content:{"application/json":{example:{error:{code:"RequestEntityTooLarge",message:"File size exceeds maximum allowed size"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Request Entity Too Large"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Create or update file",tags:t}},[e.trimEnd()]:{delete:{description:'Delete multiple files. Supports batch delete via query parameter (?ids=id1,id2,id3) or JSON body ({ids: ["id1", "id2"]} or ["id1", "id2"]).',operationId:`${s}RestBatchDelete`,parameters:[{description:"Comma-separated list of file IDs to delete",in:"query",name:"ids",required:!1,schema:{example:"id1,id2,id3",type:"string"}}],requestBody:{content:{"application/json":{schema:{oneOf:[{properties:{ids:{description:"Array of file IDs to delete",items:{type:"string"},type:"array"}},required:["ids"],type:"object"},{description:"Array of file IDs to delete",items:{type:"string"},type:"array"}]}}},description:"File IDs to delete (optional if using query parameter)",required:!1},responses:{204:{description:"All files deleted successfully"},207:{description:"Multi-Status - Some files deleted successfully",headers:{"X-Delete-Errors":{description:"JSON array of deletion errors",schema:{type:"string"}},"X-Delete-Failed":{description:"Number of files that failed to delete",schema:{type:"integer"}},"X-Delete-Successful":{description:"Number of files successfully deleted",schema:{type:"integer"}}}},400:{content:{"application/json":{example:{error:{code:"BadRequest",message:"No file IDs provided"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Bad Request"},404:{content:{"application/json":{example:{error:{code:"FileNotFound",message:"Failed to delete files: id1, id2"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Not Found"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Batch delete files",tags:t},get:u(`${s}RestGetList`,t),post:{description:"Upload a file with raw binary data or initialize a chunked upload session. For chunked uploads, set X-Chunked-Upload: true and X-Total-Size headers.",operationId:`${s}RestPostFile`,parameters:[{description:"Set to 'true' to initialize a chunked upload session",in:"header",name:"X-Chunked-Upload",required:!1,schema:{$ref:"#/components/schemas/X-Chunked-Upload"}},{description:"Total size of the file in bytes (required for chunked uploads)",in:"header",name:"X-Total-Size",required:!1,schema:{$ref:"#/components/schemas/X-Total-Size"}},{description:"Optional filename",in:"header",name:"Content-Disposition",required:!1,schema:{example:'attachment; filename="photo.jpg"',type:"string"}},{description:"Optional JSON metadata",in:"header",name:"X-File-Metadata",required:!1,schema:{example:'{"description":"My photo"}',type:"string"}}],requestBody:{content:{"application/octet-stream":{description:"File data as raw binary. For chunked upload initialization, body can be empty.",schema:{format:"binary",type:"string"}}},description:"File data (optional for chunked upload initialization)",required:!1},responses:{200:{description:"The file already exists, send a resume request",headers:{ETag:{description:"Upload ETag",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},Location:{description:"File URL",schema:{example:`${a}${e}/file-id`,format:"uri",type:"string"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},201:{description:"File uploaded successfully or chunked upload session initialized",headers:{ETag:{description:"Upload ETag",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},Location:{description:"File URL or chunked upload session URL",schema:{example:`${a}${e}/file-id`,format:"uri",type:"string"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},400:{content:{"application/json":{example:{error:{code:"BadRequest",message:"Request body is required for non-chunked uploads"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Bad Request"},413:{content:{"application/json":{example:{error:{code:"RequestEntityTooLarge",message:"File size exceeds maximum allowed size"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Request Entity Too Large"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Upload file or initialize chunked upload",tags:t}}}}};export{U as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Readable as w}from"node:stream";import{C,B as M,X as U,c as O}from"./storage-Cyy73Y6r.js";import{d as T}from"./detect-file-type-BA7UBLKA.js";import{throwErrorCode as m,ERRORS as y}from"./ERRORS-BIBxE2oR.js";import{createRetryWrapper as A}from"./createRetryWrapper-CxgiV_hH.js";import{y as k}from"./local-meta-storage-C2T92TYb.js";import{t as x}from"./update-size-DuNuLyxj.js";import{i as I}from"./part-match-D-9dGX42.js";import{e as R}from"./has-content-50BsqrWw.js";import{t as S}from"./get-file-status-y3wTtDQs.js";const z=(u,t)=>{const i={};return Object.keys(u).forEach(e=>{i[e]=t(u[e])}),i},v=u=>u===Number(u)?u:(C(u)??0)/1e3,B=5*1024*1024,L=16*1024*1024,N=u=>{if(u)return`bytes=${Math.max(0,u.start)}-${u.end===void 0?"":u.end}`};class b extends M{checksumTypes=["md5","crc32","crc32c","sha1","sha256"];supportsRange=!0;supportsDelimiter=!0;bucket;meta;MAX_PARTS=1e4;partSize;retry;resolvedRetryConfig;constructor(t){if(super(t),this.bucket=t.bucket,this.partSize=typeof t.partSize=="string"?U(t.partSize):t.partSize||L,this.partSize<B)throw new Error("Minimum allowed partSize value is 5MB");const i={backoffMultiplier:2,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:a=>{const s=a;return s.statusCode&&[408,429,500,502,503,504].includes(s.statusCode)?!0:s.retryable??!1},...t.retryConfig};this.retry=A(i),this.resolvedRetryConfig=i;const{metaStorage:e,metaStorageConfig:r}=t;if(e)this.meta=e;else{const a={...t,...r,logger:this.logger};"directory"in a?(this.logger?.debug("Using local meta storage"),this.meta=new k(a)):this.meta=new k(a)}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(a=>{this.logger?.error("Storage access check failed: %O",a)})}getRetryConfig(){return this.resolvedRetryConfig}async create(t,i){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const n=typeof t.ttl=="string"?O(t.ttl):t.ttl;n!==void 0&&(e.expiredAt=Date.now()+n)}const r=new(this.getFileClass())(e);r.name=this.namingFunction(r),await this.validate(r);try{const n=await this.getMeta(r.id);if(n.bytesWritten>=0)return n}catch{}const a=this.getS3Api();let s;try{s=await this.runOperation(i,n=>a.createMultipartUpload({ACL:this.getAcl(),Bucket:this.bucket,ContentType:r.contentType,Key:r.name,Metadata:z({originalName:r.originalName,...r.metadata},o=>encodeURI(String(o)))},{signal:n}))}catch{return m(y.FILE_ERROR,"s3 create upload error")}const{UploadId:c}=s||{};return c?(r.UploadId=c,r.bytesWritten=0,this.config.clientDirectUpload&&(r.partSize??=this.partSize),await this.saveMeta(r),r.status="created",await this.onCreate(r),this.config.clientDirectUpload?this.buildPresigned(r):r):m(y.FILE_ERROR,"s3 create upload error")})}async write(t,i){return this.instrumentOperation("write",async()=>{let e;if("contentType"in t&&"metadata"in t&&!("body"in t)&&!("start"in t)?e=t:(e=await this.getMeta(t.id),await this.checkIfExpired(e)),e.status==="completed")return e;if(typeof t.size=="number"&&t.size>0&&x(e,t.size),!I(t,e))return m(y.FILE_CONFLICT);if(this.config.clientDirectUpload)return this.buildPresigned(e);e.Parts??=await this.getParts(e),e.bytesWritten=e.Parts.map(a=>a.Size||0).reduce((a,s)=>a+s,0);const r=await this.lock(t.id);try{if(R(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))return m(y.UNSUPPORTED_CHECKSUM_ALGORITHM);if(e.Parts.length===0&&(!e.contentType||e.contentType==="application/octet-stream"))try{const d=t.body instanceof w?t.body:w.fromWeb(t.body),{fileType:g,stream:f}=await T(d);g?.mime&&(e.contentType=g.mime),t.body=f}catch{}if(e.Parts.length>this.MAX_PARTS)throw new Error(`Exceeded ${this.MAX_PARTS} as part of the upload to ${this.bucket}.`);const a=e.Parts.length+1,s=this.getS3Api(),c=e.UploadId;if(!c)throw new Error("UploadId is required");const n=t.body,o=n instanceof Uint8Array,{ETag:l}=await this.runOperation(i,d=>s.uploadPart({Body:n,Bucket:this.bucket,ContentLength:t.contentLength||0,Key:e.name,PartNumber:a,UploadId:c,...t.checksumAlgorithm==="md5"?{ContentMD5:t.checksum}:{}},{signal:d}),{replayable:o}),p={ETag:l,PartNumber:a,Size:t.contentLength};e.Parts=[...e.Parts,p],e.bytesWritten+=t.contentLength||0}if(this.cache.set(e.id,e),e.status=S(e),e.status==="completed"){const[a]=await this.internalOnComplete(e);delete e.Parts,e.uri=a.Location,e.ETag=a.ETag}}finally{await this.unlock(t.id,r)}return e})}async delete({id:t},i){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);e.status="deleted",await this.abortMultipartUpload(e,i),await this.deleteMeta(e.id);const r={...e};return await this.onDelete(r),r})}async copy(t,i,e){return this.instrumentOperation("copy",async()=>{b.assertSafeId(t),b.assertSafeId(i);const r=await this.getMeta(t),a=`${this.bucket}/${t}`,s=this.bucket,c=i,n=this.getS3Api();return await this.runOperation(e,o=>n.copyObject({Bucket:s,CopySource:a,Key:c,...e?.storageClass&&{StorageClass:e.storageClass}},{signal:o})),{...r,id:c,name:c}})}async move(t,i,e){return this.instrumentOperation("move",async()=>{await this.copy(t,i,e);const r=this.getS3Api();return await this.runOperation(e,a=>r.deleteObject({Bucket:this.bucket,Key:t},{signal:a})),await this.getMeta(i)})}async list(t=1e3,i){return this.instrumentOperation("list",async()=>{const e=this.getS3Api(),r=Math.min(t,1e3);let a={Bucket:this.bucket,MaxKeys:r};const s=[];let c=!0;for(;c&&s.length<t;)try{const n=await this.runOperation(i,o=>e.listObjectsV2(a,{signal:o}));for(const{Key:o,LastModified:l}of n?.Contents||[]){if(s.length>=t)break;o!==void 0&&s.push({id:o,...l&&{createdAt:l}})}c=n.IsTruncated||!1,c&&n.NextContinuationToken&&s.length<t&&(a={...a,ContinuationToken:n.NextContinuationToken,MaxKeys:Math.min(r,t-s.length)})}catch(n){const o=this.normalizeError(n instanceof Error?n:new Error(String(n)));throw await this.onError(o),n}return s},{limit:t})}async listDirectory(t){return this.instrumentOperation("listDirectory",async()=>{const i=this.getS3Api(),e=t?.limit??1e3,r=Math.min(e,1e3);let a={Bucket:this.bucket,Delimiter:t?.delimiter,MaxKeys:r,...t?.prefix!==void 0&&{Prefix:t.prefix}};const s=[],c=new Set;let n=!0;for(;n&&s.length<e;)try{const o=await this.runOperation(t,l=>i.listObjectsV2(a,{signal:l}));for(const{Prefix:l}of o?.CommonPrefixes||[])l!==void 0&&c.add(l);for(const{Key:l,LastModified:p}of o?.Contents||[]){if(s.length>=e)break;l!==void 0&&s.push({id:l,...p&&{createdAt:p}})}n=o.IsTruncated||!1,n&&o.NextContinuationToken&&s.length<e&&(a={...a,ContinuationToken:o.NextContinuationToken,MaxKeys:Math.min(r,e-s.length)})}catch(o){const l=this.normalizeError(o instanceof Error?o:new Error(String(o)));throw await this.onError(l),o}return{files:s,prefixes:[...c]}},{limit:t?.limit??1e3})}async exists({id:t},i){return this.instrumentOperation("exists",async()=>{try{await this.getMeta(t);const e=this.getS3Api();return await this.runOperation(i,r=>e.headObject({Bucket:this.bucket,Key:t},{signal:r})),!0}catch{return!1}})}async get({id:t},i){return this.instrumentOperation("get",async()=>{const e=this.getS3Api(),r=N(i?.range),{Body:a,ContentLength:s,ContentType:c,ETag:n,Expires:o,LastModified:l,Metadata:p}=await this.runOperation(i,h=>e.getObject({Bucket:this.bucket,Key:t,...r!==void 0&&{Range:r}},{signal:h}));await this.checkIfExpired({expiredAt:o});const d=[];if(a)if(a instanceof w)for await(const h of a)d.push(h instanceof Uint8Array?h:new Uint8Array(h));else{const h=a.getReader();try{for(;;){const{done:P,value:E}=await h.read();if(P)break;d.push(E)}}finally{h.releaseLock()}}const{originalName:g,...f}=p||{};return{content:Buffer.concat(d),contentType:c,ETag:n,expiredAt:o,id:t,metadata:f,modifiedAt:l,name:t,originalName:g||t,size:Number(s)}})}async buildPresigned(t){const i=t;if(i.Parts?.length||(i.Parts=await this.getParts(t)),i.bytesWritten=i.Parts.map(e=>e.Size||0).reduce((e,r)=>e+r,0),t.status=S(i),i.partsUrls?.length||(i.partsUrls=await this.getPartsPresignedUrls(t)),t.status==="completed"){const[e]=await this.internalOnComplete(t);return delete i.Parts,i.uri=e.Location,t}return t}async getPartsPresignedUrls(t){t.partSize??=this.partSize;const i=t.UploadId;if(!i)throw new Error("UploadId is required for getting presigned URLs");const e=Math.trunc(t.size/this.partSize)+1,r=[],a=Math.trunc(v(this.config.expiration?.maxAge||"6hrs")),s=this.getS3Api();for(let c=0;c<e;c++)r.push(s.getPresignedUrl({Bucket:this.bucket,expiresIn:a,Key:t.name,PartNumber:c+1,UploadId:i}));return Promise.all(r)}async getParts(t){const i=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const{Parts:r=[]}=await this.runOperation(void 0,a=>i.listParts({Bucket:this.bucket,Key:t.name,UploadId:e},{signal:a}));return r}completeMultipartUpload(t){const i=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const r=t.Parts?.map(({ETag:a,PartNumber:s})=>{if(!a||!s)throw new Error("ETag and PartNumber are required");return{ETag:a,PartNumber:s}})||[];return this.runOperation(void 0,a=>i.completeMultipartUpload({Bucket:this.bucket,Key:t.name,Parts:r,UploadId:e},{signal:a}))}async abortMultipartUpload(t,i){if(t.status!=="completed")try{const e=this.getS3Api(),r=t.UploadId;if(!r)return;await this.runOperation(i,a=>e.abortMultipartUpload({Bucket:this.bucket,Key:t.name,UploadId:r},{signal:a}))}catch(e){this.logger?.error("abortMultipartUploadError: ",e);const r=this.normalizeError(e instanceof Error?e:new Error(String(e)));await this.onError(r)}}internalOnComplete=async t=>{const[i]=await Promise.all([this.completeMultipartUpload(t),this.deleteMeta(t.id)]);return[i,t]}}export{b as S,N as b};
|