@visulima/storage 1.0.0-alpha.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +562 -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-CiPEMcuo.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-BK-WPL0h.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-1UvDIQZd.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-BSn6Qfnf.js +1 -0
- package/dist/packem_shared/BoxStorage-DbGqBLux.js +1 -0
- package/dist/packem_shared/BunS3File-BcYmsz1n.js +1 -0
- package/dist/packem_shared/BunS3MetaStorage-BSn6Qfnf.js +1 -0
- package/dist/packem_shared/BunS3Storage-DNvimm9e.js +1 -0
- package/dist/packem_shared/BunnyFile-BgEOlcYI.js +1 -0
- package/dist/packem_shared/BunnyMetaStorage-BSn6Qfnf.js +1 -0
- package/dist/packem_shared/BunnyStorage-C7d0opLL.js +1 -0
- package/dist/packem_shared/CloudinaryFile-Bo5B-vM1.js +1 -0
- package/dist/packem_shared/CloudinaryMetaStorage-DPVnmNe5.js +1 -0
- package/dist/packem_shared/CloudinaryStorage-Dc3XA2lP.js +1 -0
- package/dist/packem_shared/DiskStorage-CI07TVNu.js +1 -0
- package/dist/packem_shared/DiskStorageWithChecksum-vFCubS6K.js +1 -0
- package/dist/packem_shared/DropboxFile-BFb7eOzy.js +1 -0
- package/dist/packem_shared/DropboxMetaStorage-BSn6Qfnf.js +1 -0
- package/dist/packem_shared/DropboxStorage-CY9Ggu3m.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-CpIcMjP0.js +1 -0
- package/dist/packem_shared/FirebaseFile-BLaBxa2A.js +1 -0
- package/dist/packem_shared/FirebaseMetaStorage-DPVnmNe5.js +1 -0
- package/dist/packem_shared/FirebaseStorage-D6O9CJXN.js +2 -0
- package/dist/packem_shared/FtpFile-ClWDYnt2.js +1 -0
- package/dist/packem_shared/FtpMetaStorage-BSn6Qfnf.js +1 -0
- package/dist/packem_shared/FtpStorage-DbEjbq8z.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-BuPA0DDW.js +1 -0
- package/dist/packem_shared/GCStorage-i9t5TQc1.js +1 -0
- package/dist/packem_shared/GoogleDriveFile-DHpLhzg9.js +1 -0
- package/dist/packem_shared/GoogleDriveMetaStorage-Cbwa1CHV.js +1 -0
- package/dist/packem_shared/GoogleDriveStorage-Bklsz7Bh.js +1 -0
- package/dist/packem_shared/LocalMetaStorage-BhicZnNl.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-9gbWd09l.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-CQjYqU--.js +1 -0
- package/dist/packem_shared/Multipart-D0ok6BBy.js +1 -0
- package/dist/packem_shared/NetlifyBlobFile-DoFhkzaH.js +1 -0
- package/dist/packem_shared/NetlifyBlobMetaStorage-DPVnmNe5.js +1 -0
- package/dist/packem_shared/NetlifyBlobStorage-CkpCCoN1.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-Cbwa1CHV.js +1 -0
- package/dist/packem_shared/OneDriveStorage-CP6MvGAa.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-DOTLwVE7.js +1 -0
- package/dist/packem_shared/PocketBaseStorage-2qhbI2PW.js +1 -0
- package/dist/packem_shared/Rest-CI_BiZPv.js +1 -0
- package/dist/packem_shared/Rest-DvfN4-kf.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-YGeNk3Tt.js +1 -0
- package/dist/packem_shared/SftpFile-ClWDYnt2.js +1 -0
- package/dist/packem_shared/SftpMetaStorage-BSn6Qfnf.js +1 -0
- package/dist/packem_shared/SftpStorage-2Hz396Xr.js +1 -0
- package/dist/packem_shared/SharePointFile-Blz9FS4h.js +1 -0
- package/dist/packem_shared/SharePointMetaStorage-BSn6Qfnf.js +1 -0
- package/dist/packem_shared/SharePointStorage-CrX2Pk6C.js +1 -0
- package/dist/packem_shared/SupabaseFile-Bo5B-vM1.js +1 -0
- package/dist/packem_shared/SupabaseMetaStorage-Cbwa1CHV.js +1 -0
- package/dist/packem_shared/SupabaseStorage-Dc_DBX29.js +1 -0
- package/dist/packem_shared/TUS_RESUMABLE-CyTSRvPU.js +1 -0
- package/dist/packem_shared/Tus-BBVt2ky3.js +1 -0
- package/dist/packem_shared/Tus-BlBZykIL.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-DPVnmNe5.js +1 -0
- package/dist/packem_shared/UploadThingStorage-BChykYSe.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-BSn6Qfnf.js +1 -0
- package/dist/packem_shared/VercelBlobStorage-CsRyPfw3.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-D-9Ku1h-.js +1 -0
- package/dist/packem_shared/base-handler-fetch-CfkNakv8.js +1 -0
- package/dist/packem_shared/base-handler-node-BF1v1qDa.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-CsQcYW3s.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-B1RrMqH3.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-iuJnu90B.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-DvWvbDbh.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-e0reNDE_.js +1 -0
- package/dist/packem_shared/restOpenApiSpec-Csv513qf.js +1 -0
- package/dist/packem_shared/s3-base-storage-BoTyhuzO.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-0j5nCAUp.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 +218 -67
- 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,287 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { F as File, M as MetaStorage, c as createRetryWrapper, R as RetryConfig, d as FileInit, B as BaseStorage, O as OperationOptions, e as FilePart, f as FileQuery, g as FileReturn } from "./storage.d-CEM1upWM.js";
|
|
3
|
+
/**
|
|
4
|
+
* Part interface for multipart uploads.
|
|
5
|
+
*/
|
|
6
|
+
interface Part {
|
|
7
|
+
ETag?: string;
|
|
8
|
+
PartNumber: number;
|
|
9
|
+
Size?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Base file type for S3-compatible storage.
|
|
13
|
+
*/
|
|
14
|
+
interface S3CompatibleFile extends File {
|
|
15
|
+
Parts?: Part[];
|
|
16
|
+
partSize?: number;
|
|
17
|
+
partsUrls?: string[];
|
|
18
|
+
UploadId?: string;
|
|
19
|
+
uri?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Per-call options forwarded to the underlying AWS SDK send().
|
|
23
|
+
*/
|
|
24
|
+
interface S3CallOptions {
|
|
25
|
+
/** Forwarded to `client.send(command, { abortSignal })`. */
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* S3 API operations interface that must be implemented by concrete storage classes.
|
|
30
|
+
*/
|
|
31
|
+
interface S3ApiOperations {
|
|
32
|
+
abortMultipartUpload: (params: {
|
|
33
|
+
Bucket: string;
|
|
34
|
+
Key: string;
|
|
35
|
+
UploadId: string;
|
|
36
|
+
}, options?: S3CallOptions) => Promise<void>;
|
|
37
|
+
checkBucketAccess: (params: {
|
|
38
|
+
Bucket: string;
|
|
39
|
+
}) => Promise<void>;
|
|
40
|
+
completeMultipartUpload: (params: {
|
|
41
|
+
Bucket: string;
|
|
42
|
+
Key: string;
|
|
43
|
+
Parts: {
|
|
44
|
+
ETag: string;
|
|
45
|
+
PartNumber: number;
|
|
46
|
+
}[];
|
|
47
|
+
UploadId: string;
|
|
48
|
+
}, options?: S3CallOptions) => Promise<{
|
|
49
|
+
ETag?: string;
|
|
50
|
+
Location: string;
|
|
51
|
+
}>;
|
|
52
|
+
copyObject: (params: {
|
|
53
|
+
Bucket: string;
|
|
54
|
+
CopySource: string;
|
|
55
|
+
Key: string;
|
|
56
|
+
StorageClass?: string;
|
|
57
|
+
}, options?: S3CallOptions) => Promise<void>;
|
|
58
|
+
createMultipartUpload: (params: {
|
|
59
|
+
ACL?: string;
|
|
60
|
+
Bucket: string;
|
|
61
|
+
ContentType?: string;
|
|
62
|
+
Key: string;
|
|
63
|
+
Metadata?: Record<string, string>;
|
|
64
|
+
}, options?: S3CallOptions) => Promise<{
|
|
65
|
+
UploadId: string;
|
|
66
|
+
}>;
|
|
67
|
+
deleteObject: (params: {
|
|
68
|
+
Bucket: string;
|
|
69
|
+
Key: string;
|
|
70
|
+
}, options?: S3CallOptions) => Promise<void>;
|
|
71
|
+
getObject: (params: {
|
|
72
|
+
Bucket: string;
|
|
73
|
+
Key: string;
|
|
74
|
+
Range?: string;
|
|
75
|
+
}, options?: S3CallOptions) => Promise<{
|
|
76
|
+
Body?: ReadableStream | Readable;
|
|
77
|
+
ContentLength?: number;
|
|
78
|
+
ContentType?: string;
|
|
79
|
+
ETag?: string;
|
|
80
|
+
Expires?: Date;
|
|
81
|
+
LastModified?: Date;
|
|
82
|
+
Metadata?: Record<string, string>;
|
|
83
|
+
}>;
|
|
84
|
+
getPresignedUrl: (params: {
|
|
85
|
+
Bucket: string;
|
|
86
|
+
expiresIn: number;
|
|
87
|
+
Key: string;
|
|
88
|
+
PartNumber: number;
|
|
89
|
+
UploadId: string;
|
|
90
|
+
}) => Promise<string>;
|
|
91
|
+
headObject: (params: {
|
|
92
|
+
Bucket: string;
|
|
93
|
+
Key: string;
|
|
94
|
+
}, options?: S3CallOptions) => Promise<{
|
|
95
|
+
ContentLength?: number;
|
|
96
|
+
ContentType?: string;
|
|
97
|
+
ETag?: string;
|
|
98
|
+
Expires?: Date;
|
|
99
|
+
LastModified?: Date;
|
|
100
|
+
Metadata?: Record<string, string>;
|
|
101
|
+
}>;
|
|
102
|
+
listObjectsV2: (params: {
|
|
103
|
+
Bucket: string;
|
|
104
|
+
ContinuationToken?: string;
|
|
105
|
+
Delimiter?: string;
|
|
106
|
+
MaxKeys?: number;
|
|
107
|
+
Prefix?: string;
|
|
108
|
+
}, options?: S3CallOptions) => Promise<{
|
|
109
|
+
CommonPrefixes?: {
|
|
110
|
+
Prefix?: string;
|
|
111
|
+
}[];
|
|
112
|
+
Contents?: {
|
|
113
|
+
Key?: string;
|
|
114
|
+
LastModified?: Date;
|
|
115
|
+
}[];
|
|
116
|
+
IsTruncated?: boolean;
|
|
117
|
+
NextContinuationToken?: string;
|
|
118
|
+
}>;
|
|
119
|
+
listParts: (params: {
|
|
120
|
+
Bucket: string;
|
|
121
|
+
Key: string;
|
|
122
|
+
UploadId: string;
|
|
123
|
+
}, options?: S3CallOptions) => Promise<{
|
|
124
|
+
Parts?: Part[];
|
|
125
|
+
}>;
|
|
126
|
+
uploadPart: (params: {
|
|
127
|
+
Body: Readable | ReadableStream | Uint8Array;
|
|
128
|
+
Bucket: string;
|
|
129
|
+
ContentLength?: number;
|
|
130
|
+
ContentMD5?: string;
|
|
131
|
+
Key: string;
|
|
132
|
+
PartNumber: number;
|
|
133
|
+
UploadId: string;
|
|
134
|
+
}, options?: S3CallOptions) => Promise<{
|
|
135
|
+
ETag: string;
|
|
136
|
+
}>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Base class for S3-compatible storage implementations.
|
|
140
|
+
* Contains all shared business logic for S3 operations.
|
|
141
|
+
* @template TFile The file type used by this storage backend.
|
|
142
|
+
*/
|
|
143
|
+
declare abstract class S3BaseStorage<TFile extends S3CompatibleFile = S3CompatibleFile> extends BaseStorage<TFile> {
|
|
144
|
+
override checksumTypes: string[];
|
|
145
|
+
override readonly supportsRange: boolean;
|
|
146
|
+
override readonly supportsDelimiter: boolean;
|
|
147
|
+
protected bucket: string;
|
|
148
|
+
protected meta: MetaStorage<TFile>;
|
|
149
|
+
/**
|
|
150
|
+
* S3 multipart upload does not allow more than 10000 parts.
|
|
151
|
+
*/
|
|
152
|
+
protected readonly MAX_PARTS = 1e4;
|
|
153
|
+
protected readonly partSize: number;
|
|
154
|
+
protected readonly retry: ReturnType<typeof createRetryWrapper>;
|
|
155
|
+
protected readonly resolvedRetryConfig: RetryConfig;
|
|
156
|
+
/**
|
|
157
|
+
* Abstract method to get S3 API operations implementation.
|
|
158
|
+
*/
|
|
159
|
+
protected abstract getS3Api(): S3ApiOperations;
|
|
160
|
+
/**
|
|
161
|
+
* Abstract method to get the file class constructor.
|
|
162
|
+
*/
|
|
163
|
+
protected abstract getFileClass(): new (config: FileInit) => TFile;
|
|
164
|
+
/**
|
|
165
|
+
* Abstract method to get ACL value.
|
|
166
|
+
*/
|
|
167
|
+
protected abstract getAcl(): string | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* Abstract method for access check.
|
|
170
|
+
*/
|
|
171
|
+
protected abstract accessCheck(maxWaitTime?: number): Promise<void>;
|
|
172
|
+
constructor(config: {
|
|
173
|
+
bucket: string;
|
|
174
|
+
clientDirectUpload?: boolean;
|
|
175
|
+
expiration?: {
|
|
176
|
+
maxAge?: string;
|
|
177
|
+
};
|
|
178
|
+
filename?: (file: TFile) => string;
|
|
179
|
+
logger?: BaseStorage<TFile>["logger"];
|
|
180
|
+
metaStorage?: MetaStorage<TFile>;
|
|
181
|
+
metaStorageConfig?: unknown;
|
|
182
|
+
partSize?: number | string;
|
|
183
|
+
retryConfig?: RetryConfig;
|
|
184
|
+
});
|
|
185
|
+
protected override getRetryConfig(): RetryConfig;
|
|
186
|
+
/**
|
|
187
|
+
* Creates a new S3 multipart upload.
|
|
188
|
+
*/
|
|
189
|
+
create(config: FileInit, options?: OperationOptions): Promise<TFile>;
|
|
190
|
+
/**
|
|
191
|
+
* Writes data to an S3 multipart upload.
|
|
192
|
+
*/
|
|
193
|
+
write(part: FilePart | FileQuery | TFile, options?: OperationOptions): Promise<TFile>;
|
|
194
|
+
/**
|
|
195
|
+
* Deletes an upload and its metadata.
|
|
196
|
+
*/
|
|
197
|
+
delete({
|
|
198
|
+
id
|
|
199
|
+
}: FileQuery, options?: OperationOptions): Promise<TFile>;
|
|
200
|
+
/**
|
|
201
|
+
* Copies an upload file to a new location.
|
|
202
|
+
*/
|
|
203
|
+
copy(name: string, destination: string, options?: OperationOptions & {
|
|
204
|
+
storageClass?: string;
|
|
205
|
+
}): Promise<TFile>;
|
|
206
|
+
/**
|
|
207
|
+
* Moves an upload file to a new location.
|
|
208
|
+
*/
|
|
209
|
+
move(name: string, destination: string, options?: OperationOptions): Promise<TFile>;
|
|
210
|
+
/**
|
|
211
|
+
* Lists files in the bucket.
|
|
212
|
+
*/
|
|
213
|
+
override list(limit?: number, options?: OperationOptions): Promise<TFile[]>;
|
|
214
|
+
/**
|
|
215
|
+
* Directory-style listing via S3's native `Delimiter`/`Prefix` — the provider returns the direct
|
|
216
|
+
* child objects plus the `CommonPrefixes` ("subdirectories") one delimiter level below `prefix`,
|
|
217
|
+
* so the whole subtree never has to be fetched. Pages until exhausted or `limit` direct files
|
|
218
|
+
* have been collected; common prefixes are accumulated (deduped) across pages.
|
|
219
|
+
*/
|
|
220
|
+
override listDirectory(options?: OperationOptions & {
|
|
221
|
+
delimiter: string;
|
|
222
|
+
limit?: number;
|
|
223
|
+
prefix?: string;
|
|
224
|
+
}): Promise<{
|
|
225
|
+
files: TFile[];
|
|
226
|
+
prefixes: string[];
|
|
227
|
+
}>;
|
|
228
|
+
/**
|
|
229
|
+
* Checks if a file exists by verifying both metadata and the actual S3 object.
|
|
230
|
+
* Returns true only if both the metadata and the S3 object exist.
|
|
231
|
+
* @param query File query containing the file ID to check.
|
|
232
|
+
* @returns Promise resolving to true if both metadata and S3 object exist, false otherwise.
|
|
233
|
+
*/
|
|
234
|
+
override exists({
|
|
235
|
+
id
|
|
236
|
+
}: FileQuery, options?: OperationOptions): Promise<boolean>;
|
|
237
|
+
/**
|
|
238
|
+
* Gets an uploaded file by ID.
|
|
239
|
+
*/
|
|
240
|
+
get({
|
|
241
|
+
id
|
|
242
|
+
}: FileQuery, options?: OperationOptions & {
|
|
243
|
+
range?: {
|
|
244
|
+
end?: number;
|
|
245
|
+
start: number;
|
|
246
|
+
};
|
|
247
|
+
}): Promise<FileReturn>;
|
|
248
|
+
/**
|
|
249
|
+
* Gets file stream (abstract - must be implemented by subclasses due to stream differences).
|
|
250
|
+
*/
|
|
251
|
+
abstract override getStream(query: FileQuery, options?: OperationOptions): Promise<{
|
|
252
|
+
headers?: Record<string, string>;
|
|
253
|
+
size?: number;
|
|
254
|
+
stream: Readable;
|
|
255
|
+
}>;
|
|
256
|
+
/**
|
|
257
|
+
* Builds presigned URLs for client uploads.
|
|
258
|
+
*/
|
|
259
|
+
protected buildPresigned(file: TFile): Promise<TFile>;
|
|
260
|
+
/**
|
|
261
|
+
* Gets presigned URLs for all parts.
|
|
262
|
+
*/
|
|
263
|
+
protected getPartsPresignedUrls(file: TFile): Promise<string[]>;
|
|
264
|
+
/**
|
|
265
|
+
* Gets parts for a multipart upload.
|
|
266
|
+
*/
|
|
267
|
+
protected getParts(file: TFile): Promise<Part[]>;
|
|
268
|
+
/**
|
|
269
|
+
* Completes a multipart upload.
|
|
270
|
+
*/
|
|
271
|
+
protected completeMultipartUpload(file: TFile): Promise<{
|
|
272
|
+
ETag?: string;
|
|
273
|
+
Location: string;
|
|
274
|
+
}>;
|
|
275
|
+
/**
|
|
276
|
+
* Aborts a multipart upload.
|
|
277
|
+
*/
|
|
278
|
+
protected abortMultipartUpload(file: TFile, options?: OperationOptions): Promise<void>;
|
|
279
|
+
/**
|
|
280
|
+
* Internal onComplete handler.
|
|
281
|
+
*/
|
|
282
|
+
protected internalOnComplete: (file: TFile) => Promise<[{
|
|
283
|
+
ETag?: string;
|
|
284
|
+
Location: string;
|
|
285
|
+
}, TFile]>;
|
|
286
|
+
}
|
|
287
|
+
export { Part as P, S3CallOptions as S, S3ApiOperations as a, S3BaseStorage as b };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n=new Set(["fr-par","nl-ams","pl-waw"]),E=s=>{const r=s?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.SCALEWAY_ACCESS_KEY_ID??process.env.SCALEWAY_ACCESS_KEY,o=s?.endpoint??process.env.SCALEWAY_ENDPOINT,e=s?.region??process.env.SCALEWAY_REGION,c=s?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.SCALEWAY_SECRET_ACCESS_KEY??process.env.SCALEWAY_SECRET_KEY;if(!e||!r||!c)throw new Error("Missing required parameters for Scaleway Object Storage client.");if(!n.has(e))throw new Error(`Invalid Scaleway region "${e}". Expected one of: ${[...n].join(", ")}.`);return{credentials:{accessKeyId:r,secretAccessKey:c},endpoint:o??`https://s3.${e}.scw.cloud`,forcePathStyle:!1,region:e}};export{E as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const c={value:{createdAt:"2022-12-16T10:35:17.466Z",id:"391c9157ec481ac6-f72b2d884632d7e6-cdeb2056546033e3",modifiedAt:"2022-12-16T10:35:17.470Z"}},o=(e,t)=>e.map(i=>({...i,description:`[${t}] ${i.description}`,"x-group":t})),d=(e,t=["jpeg","png","webp","avif","tiff","gif","mp4","webm","mkv","ogg","mp3","wav","aac","flac"])=>{if(!e)return[];const i=o([{description:"Output format for the transformed media",in:"query",name:"format",schema:{enum:t,type:"string"}},{description:"Quality setting (0-100 for images, affects compression)",in:"query",name:"quality",schema:{maximum:100,minimum:1,type:"integer"}}],"Common"),n=o([{description:"Desired width in pixels",in:"query",name:"width",schema:{minimum:1,type:"integer"}},{description:"Desired height in pixels",in:"query",name:"height",schema:{minimum:1,type:"integer"}},{description:"Resize fit mode",in:"query",name:"fit",schema:{enum:["cover","contain","fill","inside","outside"],type:"string"}},{description:"Position for cover/contain fits",in:"query",name:"position",schema:{oneOf:[{enum:["top","right","bottom","left","center"],type:"string"},{minimum:0,type:"integer"}]}},{description:"Avoid enlarging images smaller than specified dimensions",in:"query",name:"withoutEnlargement",schema:{type:"boolean"}},{description:"Avoid reducing images larger than specified dimensions",in:"query",name:"withoutReduction",schema:{type:"boolean"}},{description:"Resize kernel algorithm",in:"query",name:"kernel",schema:{enum:["nearest","cubic","mitchell","lanczos2","lanczos3"],type:"string"}},{description:"Fast shrink on load for large images",in:"query",name:"fastShrinkOnLoad",schema:{type:"boolean"}},{description:"Crop area left offset",in:"query",name:"left",schema:{minimum:0,type:"integer"}},{description:"Crop area top offset",in:"query",name:"top",schema:{minimum:0,type:"integer"}},{description:"Crop area width",in:"query",name:"cropWidth",schema:{minimum:1,type:"integer"}},{description:"Crop area height",in:"query",name:"cropHeight",schema:{minimum:1,type:"integer"}},{description:"Rotation angle in degrees. Note: angles other than 90°, 180°, and 270° require interpolation and may affect quality",in:"query",name:"angle",schema:{type:"number"}},{description:"Background color for rotation (hex, rgb, or color name)",in:"query",name:"background",schema:{type:"string"}},{description:"Apply blur effect",in:"query",name:"blur",schema:{type:"boolean"}},{description:"Apply sharpening",in:"query",name:"sharpen",schema:{type:"boolean"}},{description:"Apply median filter with specified size",in:"query",name:"median",schema:{minimum:1,type:"integer"}},{description:"Apply CLAHE (Contrast Limited Adaptive Histogram Equalization)",in:"query",name:"clahe",schema:{type:"boolean"}},{description:"Apply thresholding with specified value (0-255)",in:"query",name:"threshold",schema:{maximum:255,minimum:0,type:"integer"}},{description:"Apply gamma correction",in:"query",name:"gamma",schema:{type:"boolean"}},{description:"Negate (invert) the image",in:"query",name:"negate",schema:{type:"boolean"}},{description:"Normalise the image",in:"query",name:"normalise",schema:{type:"boolean"}},{description:"Flatten alpha channel",in:"query",name:"flatten",schema:{type:"boolean"}},{description:"Unflatten alpha channel",in:"query",name:"unflatten",schema:{type:"boolean"}},{description:"Flip image vertically",in:"query",name:"flip",schema:{type:"boolean"}},{description:"Flop image horizontally",in:"query",name:"flop",schema:{type:"boolean"}},{description:"Convert to greyscale",in:"query",name:"greyscale",schema:{type:"boolean"}},{description:"Apply modulation effects",in:"query",name:"modulate",schema:{type:"boolean"}},{description:"Brightness multiplier for modulation",in:"query",name:"brightness",schema:{type:"number"}},{description:"Saturation multiplier for modulation",in:"query",name:"saturation",schema:{type:"number"}},{description:"Hue rotation in degrees for modulation",in:"query",name:"hue",schema:{type:"integer"}},{description:"Lightness adjustment for modulation",in:"query",name:"lightness",schema:{type:"integer"}},{description:"Apply tinting",in:"query",name:"tint",schema:{type:"boolean"}},{description:"Convert colourspace",in:"query",name:"colourspace",schema:{enum:["srgb","rgb","cmyk","lab","b-w"],type:"string"}},{description:"Apply affine transformation",in:"query",name:"affine",schema:{type:"boolean"}},{description:"Apply dilation",in:"query",name:"dilate",schema:{type:"boolean"}},{description:"Apply erosion",in:"query",name:"erode",schema:{type:"boolean"}},{description:"Set pipeline colourspace",in:"query",name:"pipelineColourspace",schema:{type:"boolean"}},{description:"Convert to colourspace",in:"query",name:"toColourspace",schema:{type:"boolean"}},{description:"Remove alpha channel",in:"query",name:"removeAlpha",schema:{type:"boolean"}},{description:"Ensure alpha channel",in:"query",name:"ensureAlpha",schema:{type:"boolean"}}],"Image"),s=o([{description:"Desired width in pixels",in:"query",name:"width",schema:{minimum:1,type:"integer"}},{description:"Desired height in pixels",in:"query",name:"height",schema:{minimum:1,type:"integer"}},{description:"Video frame rate in Hz",in:"query",name:"frameRate",schema:{minimum:1,type:"number"}},{description:"Video key frame interval in seconds",in:"query",name:"keyFrameInterval",schema:{minimum:.1,type:"number"}}],"Video"),r=o([{description:"Target bitrate in bits per second",in:"query",name:"bitrate",schema:{minimum:1,type:"integer"}},{description:"Video or audio codec",in:"query",name:"codec",schema:{enum:["avc","hevc","vp8","vp9","av1","aac","opus","mp3","vorbis","flac"],type:"string"}}],"Video/Audio"),l=o([{description:"Audio channel count",in:"query",name:"numberOfChannels",schema:{enum:[1,2,3,4,5,6,7,8],type:"integer"}},{description:"Audio sample rate in Hz",in:"query",name:"sampleRate",schema:{enum:[8e3,11025,16e3,22050,32e3,44100,48e3,88200,96e3,192e3],type:"integer"}}],"Audio");let a=[];a=[...a,...i],(e===!0||e==="image")&&(a=[...a,...n]),(e===!0||e==="video")&&(a=[...a,...s]),(e===!0||e==="video"||e==="audio")&&(a=[...a,...r]),(e===!0||e==="audio")&&(a=[...a,...l]);const m=new Set;return a.filter(p=>m.has(p.name)?!1:(m.add(p.name),!0))},y=(e,t=["jpeg","png","webp","avif","tiff","gif","mp4","webm","mkv","ogg","mp3","wav","aac","flac"])=>{const i=d(e,t),n={};return i.forEach(s=>{const r=s["x-group"]||"Other";n[r]||(n[r]=[]),n[r].push(s.name)}),{groups:n,parameters:i}},u=e=>e?{"X-Media-Type":{description:"Type of media (image/video/audio)",schema:{enum:["image","video","audio"],type:"string"}},"X-Original-Format":{description:"Original file format",schema:{type:"string"}},"X-Transformed-Format":{description:"Transformed file format",schema:{type:"string"}}}:{},h=e=>e?{400:{content:{"application/json":{examples:{ValidationError:{value:{error:{code:"INVALID_PARAMS_FOR_IMAGE",details:{invalidParams:["codec","bitrate"],mediaType:"image",validParams:["format","quality","width","height","fit","position","withoutEnlargement","withoutReduction","kernel","fastShrinkOnLoad","left","top","cropWidth","cropHeight","angle","background","blur","sharpen","median","clahe","threshold","gamma","negate","normalise","flatten","unflatten","flip","flop","greyscale","modulate","brightness","saturation","hue","lightness","tint","colourspace","affine","dilate","erode","pipelineColourspace","toColourspace","removeAlpha","ensureAlpha"]},message:"Invalid query parameters for image transformation: codec, bitrate. Images support: format, quality, width, height, fit, position, withoutEnlargement, withoutReduction, kernel, fastShrinkOnLoad, left, top, cropWidth, cropHeight, angle, background, blur, sharpen, median, clahe, threshold, gamma, negate, normalise, flatten, unflatten, flip, flop, greyscale, modulate, brightness, saturation, hue, lightness, tint, colourspace, affine, dilate, erode, pipelineColourspace, toColourspace, removeAlpha, ensureAlpha. Video/audio parameters (codec, bitrate) are not supported for images.",name:"ValidationError"}}}},schema:{$ref:"#/components/schemas/ValidationError"}}},description:"Invalid transformation parameters"},413:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"File too large for transformation"},415:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Unsupported media type for transformation"}}:{},g=(e,t,i,n)=>({description:"Get the uploaded file with optional media transformation support",operationId:e,parameters:[{in:"path",name:"id",required:!0,schema:{type:"string"}},...d(i,n)],responses:{200:{content:{"*/*":{schema:{description:i?"Transformed file content":"File content",format:"binary",type:"string"}}},description:i?"File retrieved and transformed successfully":"File retrieved successfully",headers:{"Content-Type":{description:`MIME type of the file${i?" (or transformed file)":""}`,schema:{type:"string"}},ETag:{description:`Upload ETag${i?" (or transformed file ETag)":""}`,schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},"Last-Modified":{description:"Upload last modified date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}},...u(i),"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},...h(i),404:{content:{"application/json":{example:{error:{code:"FileNotFound",message:"Not found"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Not Found"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Get the uploaded file",tags:t}),f=(e,t)=>({description:"Get the uploaded file metadata",operationId:e,parameters:[{in:"path",name:"id",required:!0,schema:{type:"string"}}],responses:{200:{content:{"application/json":{schema:{$ref:"#/components/schemas/FileMeta"}}},description:"OK",headers:{"Last-Modified":{description:"Upload last modified date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},404:{content:{"application/json":{example:{error:{code:"FileNotFound",message:"File metadata not found"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Not Found"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Get the uploaded file metadata",tags:t}),b={Error:{description:"Error",properties:{error:{properties:{code:{minLength:1,type:"string"},message:{minLength:1,type:"string"},name:{minLength:3,type:"string"}},required:["message"],type:"object"}},required:["error"],type:"object"},ValidationError:{description:"Validation error response",properties:{code:{enum:["INVALID_PARAMS_FOR_IMAGE","INVALID_PARAMS_FOR_VIDEO","INVALID_PARAMS_FOR_AUDIO","INVALID_FIT_VALUE","INVALID_ANGLE_VALUE","INVALID_FORMAT","INCOMPLETE_CROP_PARAMS","INVALID_VIDEO_CODEC","INVALID_VIDEO_FORMAT","INVALID_WIDTH","INVALID_HEIGHT","INVALID_BITRATE","INVALID_FRAME_RATE","INVALID_KEY_FRAME_INTERVAL","INVALID_AUDIO_CODEC","INVALID_AUDIO_FORMAT","INVALID_CHANNEL_COUNT","INVALID_SAMPLE_RATE"],type:"string"},details:{properties:{invalidParams:{items:{type:"string"},type:"array"},mediaType:{enum:["image","video","audio"],type:"string"},suggestions:{items:{type:"string"},type:"array"},validParams:{items:{type:"string"},type:"array"}},required:["invalidParams","validParams","mediaType"],type:"object"},message:{type:"string"},name:{enum:["ValidationError"],type:"string"}},required:["code","details","message","name"],type:"object"}},A={FileMeta:{description:"File meta",properties:{bytesWritten:{type:"integer"},contentType:{type:"string"},createdAt:{format:"date-time",type:"string"},id:{minLength:1,type:"string"},metadata:{type:"object"},name:{minLength:1,type:"string"},originalName:{minLength:1,type:"string"},status:{enum:["completed","part","deleted","created"],type:"string"}},type:"object"}},q={FileMeta:{value:[c]},FileMetaPagination:{value:{data:[c.value],meta:{firstPage:1,firstPageUrl:"/?page=1",lastPage:1,lastPageUrl:"/?page=10",nextPageUrl:"/?page=2",page:1,perPage:1,previousPageUrl:void 0,total:1}}}},I=(e,t)=>({description:"List upload",operationId:e,parameters:[{description:"Maximum number of elements to retrieve.",in:"query",name:"limit",schema:{nullable:!0,type:"integer"}},{description:"Page number. Use only for pagination.",in:"query",name:"page",schema:{nullable:!0,type:"integer"}}],responses:{200:{content:{"application/json":{examples:{Default:{$ref:"#/components/examples/FileMeta"},Pagination:{$ref:"#/components/examples/FileMetaPagination"}},schema:{$ref:"#/components/schemas/FileMeta"}}},description:"OK"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"List upload",tags:t});export{y as getOrganizedTransformationParameters,b as sharedErrorSchemaObject,q as sharedFileMetaExampleObject,A as sharedFileMetaSchemaObject,g as sharedGet,I as sharedGetList,f as sharedGetMeta};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Readable as K}from"node:stream";import{setInterval as W}from"node:timers";import{inspect as Z}from"node:util";import{W as H,A as O}from"./path-0oTTdkvl-DvWvbDbh.js";import X from"type-is";import q from"./NoOpMetrics-BLo6u4NY.js";import{N as J}from"./cache-Cw3QjoVN.js";import{ErrorMap as $,throwErrorCode as b,ERRORS as E}from"./ERRORS-BIBxE2oR.js";import{randomUUID as Q}from"node:crypto";import{LRUCache as ee}from"lru-cache";import{retry as te}from"./createRetryWrapper-CxgiV_hH.js";import{t as re}from"./is-expired-CBEk6XBi.js";const se=/^(?<value>-?\d+(?:[.,]\d+)*) *(?<type>[a-z]+)?$/i,oe=/^KIBI/,ie=/^MIBI/,ae=/^GIBI/,ne=/^TEBI/,ce=/^PEBI/,le=/^EXBI/,ue=/^ZEBI/,ge=/^YIBI/,he=/^(.)IB$/,me={iec:[{long:"Bytes",short:"B"},{long:"Kibibytes",short:"KiB"},{long:"Mebibytes",short:"MiB"},{long:"Gibibytes",short:"GiB"},{long:"Tebibytes",short:"TiB"},{long:"Pebibytes",short:"PiB"},{long:"Exbibytes",short:"EiB"},{long:"Zebibytes",short:"ZiB"},{long:"Yobibytes",short:"YiB"}],iec_octet:[{long:"Octets",short:"o"},{long:"Kibioctets",short:"Kio"},{long:"Mebioctets",short:"Mio"},{long:"Gibioctets",short:"Gio"},{long:"Tebioctets",short:"Tio"},{long:"Pebioctets",short:"Pio"},{long:"Exbioctets",short:"Eio"},{long:"Zebioctets",short:"Zio"},{long:"Yobioctets",short:"Yio"}],metric:[{long:"Bytes",short:"Bytes"},{long:"Kilobytes",short:"KB"},{long:"Megabytes",short:"MB"},{long:"Gigabytes",short:"GB"},{long:"Terabytes",short:"TB"},{long:"Petabytes",short:"PB"},{long:"Exabytes",short:"EB"},{long:"Zettabytes",short:"ZB"},{long:"Yottabytes",short:"YB"}],metric_octet:[{long:"Octets",short:"o"},{long:"Kilo-octets",short:"ko"},{long:"Mega-octets",short:"Mo"},{long:"Giga-octets",short:"Go"},{long:"Tera-octets",short:"To"},{long:"Peta-octets",short:"Po"},{long:"Exa-octets",short:"Eo"},{long:"Zetta-octets",short:"Zo"},{long:"Yotta-octets",short:"Yo"}]},k=new Map,de=t=>{let e=k.get(t);if(e===void 0){const r=new Intl.NumberFormat(t);e={decimalSeparator:r.format(1.1).replaceAll(new RegExp("\\p{Number}","gu"),""),thousandSeparator:r.format(11111).replaceAll(new RegExp("\\p{Number}","gu"),"")},k.set(t,e)}return e},pe=(t,e)=>{const{decimalSeparator:r,thousandSeparator:s}=de(e);return Number.parseFloat(t.replaceAll(new RegExp(`\\${s}`,"g"),"").replace(new RegExp(`\\${r}`),"."))},fe=t=>{switch(t){case 2:return 1024;case 10:return 1e3;default:throw new Error("Unsupported base.")}},_=(t,e)=>{const r={base:2,locale:"en-US",units:"metric",...e};if(typeof t!="string"||t.length===0)throw new TypeError("Value is not a string or is empty.");if(t.length>100)throw new TypeError("Value exceeds the maximum length of 100 characters.");const s=se.exec(t)?.groups;if(!s)return Number.NaN;const o=pe(s.value,r.locale),i=(s.type??"Bytes").toUpperCase().replace(oe,"KILO").replace(ie,"MEGA").replace(ae,"GIGA").replace(ne,"TERA").replace(ce,"PETA").replace(le,"EXA").replace(ue,"ZETTA").replace(ge,"YOTTA").replace(he,"$1B"),a=me[r.units].findIndex(l=>l.short.toUpperCase()===i||l.long.toUpperCase()===i);if(a===-1)return Number.NaN;const c=fe(r.base);return o*c**a},ye=(t,e,r,s,o,i,a,c,l,n,u,h,g,d)=>{const m={d:s,h:o,m:i,mo:e,ms:c,s:a,w:r,y:t};return m.future=l,m.past=n,m.decimal=u,h!==void 0&&(m.unitMap=h),m.groupSeparator=g,m.placeholderSeparator=d,m},F={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},we=ye(t=>`year${t===1?"":"s"}`,t=>`month${t===1?"":"s"}`,t=>`week${t===1?"":"s"}`,t=>`day${t===1?"":"s"}`,t=>`hour${t===1?"":"s"}`,t=>`minute${t===1?"":"s"}`,t=>`second${t===1?"":"s"}`,t=>`millisecond${t===1?"":"s"}`,"in %s","%s ago",".",F,",","_"),z=new WeakSet,be=t=>{if(z.has(t))return;const e=["y","mo","w","d","h","m","s","ms","future","past"];for(const s of e)if(!Object.hasOwn(t,s))throw new TypeError(`Missing required property: ${s}`);if(typeof t.future!="string"||typeof t.past!="string")throw new TypeError("Properties future and past must be of type string");const r=["y","mo","w","d","h","m","s","ms"];for(const s of r)if(typeof t[s]!="string"&&typeof t[s]!="function")throw new TypeError(`Property ${s} must be of type string or function`);if(t.decimal&&typeof t.decimal!="string")throw new TypeError("Property decimal must be of type string");if(t.delimiter&&typeof t.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(t._digitReplacements&&!Array.isArray(t._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(t._numberFirst&&typeof t._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(t.unitMap&&typeof t.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(t.unitMap&&Object.values(t.unitMap).some(s=>typeof s!="string"))throw new TypeError("All values in unitMap must be of type string");z.add(t)},w={d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},T=/[-/\\^$*+?.()|[\]{}]/g,R=new WeakMap,v=t=>String.raw`(?:(\d+(?:[.,]\d+)?)${t})?`,Ee=new RegExp(`^P${v("Y")}${v("M")}${v("W")}${v("D")}(?:T${v("H")}${v("M")}${v("S")})?$`,"i"),ve=/^(?:(\d+):)?(?:(\d+):)?(\d+)$/,$e=/^[+-]?\d+(?:\.\d+)?$/,xe=/^[-+]/,Ae=(t,e)=>{if(typeof t!="string"||t.length===0)return;const{defaultUnit:r="ms",language:s=we}={};be(s);const o=s.decimal??".",i=s.groupSeparator??",",a=s.placeholderSeparator??"_",c=o.replaceAll(T,String.raw`\$&`),l=i.replaceAll(T,String.raw`\$&`),n=a.replaceAll(T,String.raw`\$&`),u=s.unitMap??F;let h=t.replaceAll(new RegExp(String.raw`(\d)[${n}${l}](\d)`,"g"),"$1$2");if(o!=="."&&(h=h.replaceAll(new RegExp(String.raw`(\d)${c}(\d)`,"g"),"$1.$2")),$e.test(t)){const f=Number.parseFloat(h.trim());if(!Number.isNaN(f)){const p=u[r];if(p!==void 0)return f*w[p]}return}const g=Ee.exec(t);if(g){const f=[[1,w.y],[2,w.mo],[3,w.w],[4,w.d],[5,w.h],[6,w.m],[7,w.s]];let p=0,y=!1;for(const[N,I]of f){const A=g[N];A!==void 0&&(y=!0,p+=Number.parseFloat(A.replace(",","."))*I)}if(y)return p}const d=ve.exec(t);if(d){let f=0,p=0;d[2]!==void 0?(f=Number.parseInt(d[1]??"0",10),p=Number.parseInt(d[2],10)):d[1]!==void 0&&(p=Number.parseInt(d[1],10));const y=Number.parseInt(d[3]??"0",10);return f*36e5+p*6e4+y*1e3}let m=R.get(u);if(m===void 0){const f=Object.keys(u).toSorted((p,y)=>y.length-p.length).map(p=>p.replaceAll(T,String.raw`\$&`)).join("|");m=new RegExp(String.raw`(-?\d*\.?\d+)\s*(${f})`,"gi"),R.set(u,m)}let D=0,x,S=!1,B=-1,M=0;for(m.lastIndex=0;(x=m.exec(h))!==null;){const f=x[1],p=x[2];if(!f||!p)continue;const y=f.trim(),N=y.startsWith("-")?-1:1,I=y.replace(xe,""),A=Number.parseFloat(I),U=u[p.toLowerCase()];if(U===void 0)continue;if(!S)B=x.index;else if(h.slice(M,x.index).trim().length>0)return;S=!0,M=m.lastIndex;const Y=w[U];if(Number.isNaN(A))return;D+=N*A*Y}const j=h.slice(0,B).trim(),G=h.slice(M).trim();if(!(S&&(j.length>0||G.length>0))&&S)return D};class Se extends ee{constructor(e){super({ttl:3e4,ttlAutopurge:!0,...e})}lock(e){if(this.get(e)!==void 0)throw new Error(`${e} is locked`);const r=Q();return this.set(e,r),r}unlock(e,r){return this.get(e)!==r?!1:this.delete(e)}}const C=t=>{if(t===Number(t))return t;if(!t)return;const e=Ae(t);if(e!==void 0)return e};class Te extends Error{code;statusCode;body;headers;name="ValidationError";constructor(e,r,s,o){const i=typeof s=="string"?s:s?.message||"Validation error";super(i),this.code=e,this.statusCode=r,this.body=s,this.headers=o}}const Ce=t=>t&&t[0].toUpperCase()+t.slice(1),Me=t=>{if(!Array.isArray(t))return t;const[e,r,s]=t;return{body:r,headers:s,statusCode:e}};class Ne{constructor(e="ValidationError"){this.prefix=e}prefix;validators={};add(e){Object.entries(e).forEach(([r,s])=>{const o=`${this.prefix}${Ce(r)}`;if(this.validators[o]={...this.validators[o],...s},typeof this.validators[o].isValid!="function")throw new TypeError('Validation config "isValid" is missing, or it is not a function!')})}async verify(e){for(const[r,s]of Object.entries(this.validators))if(!await s.isValid(e)){const o=s.response||(r in $?$[r]:$.UnknownError),i=Me(o),{body:a,headers:c,message:l,statusCode:n}=i;throw new Te(r,n,a||l,c)}}}const We=t=>t.name==="ValidationError",Ie=t=>{if(typeof t.name=="string")return t.name;if(typeof t.title=="string")return t.title;if(typeof t.originalName=="string")return t.originalName;if(typeof t.filename=="string")return t.filename},P=(t,e)=>{const r={...t};return Object.keys(e).forEach(s=>{const o=e[s];if(o!==null&&typeof o=="object"&&!Array.isArray(o)){const i=r[s],a=i&&typeof i=="object"&&!Array.isArray(i)?i:{};r[s]=P(a,o)}else r[s]=o}),r},Oe=(t,e)=>{const r=P(t,e);Object.assign(t,r),t.originalName=Ie(t.metadata)||t.originalName},De=/(secret|password|passwd|pwd|token|api[_-]?key|credential|authorization|sas|signature|sessiontoken|connectionstring)/i,L=t=>{const e={};for(const[r,s]of Object.entries(t))typeof s=="string"&&De.test(r)?e[r]="[REDACTED]":s&&typeof s=="object"&&!Array.isArray(s)&&s.constructor===Object?e[r]=L(s):e[r]=s;return e},Be={allowMIME:["*/*"],filename:({id:t})=>t,maxMetadataSize:"8MB",maxUploadSize:"5TB",onComplete:()=>{},onCreate:()=>{},onDelete:()=>{},onError:()=>{},onUpdate:()=>{},useRelativeLocation:!1,validation:{}},Ue=t=>!t||t.length<3||t.length>255||O(t)?!1:!(t.toUpperCase().includes("../")||t.includes("\0")),Ze=t=>{if(!t||t.length<3||t.length>255||O(t))return!1;const e=t.toUpperCase();return!['"',"*",":","<",">","?","\\","|","../","\0"].some(r=>e.includes(r))};class V{onCreate;onUpdate;onComplete;onDelete;onError;isReady=!0;errorResponses={};cache;logger;metrics;genericConfig;maxMetadataSize;checksumTypes=[];supportsRange=!1;supportsMetadata=!0;supportsCacheControl=!1;supportsDelimiter=!1;reportsUploadProgress=!1;maxUploadSize;expiration;locker;namingFunction;validation=new Ne;assetFolder=void 0;concurrency;constructor(e){const r={...Be,...e};this.onCreate=r.onCreate,this.onUpdate=r.onUpdate,this.onComplete=r.onComplete,this.onDelete=r.onDelete,this.onError=r.onError,this.namingFunction=r.filename,this.maxUploadSize=typeof r.maxUploadSize=="string"?_(r.maxUploadSize):r.maxUploadSize,this.maxMetadataSize=typeof r.maxMetadataSize=="string"?_(r.maxMetadataSize):r.maxMetadataSize,this.expiration=r.expiration,this.genericConfig=r,r.assetFolder!==void 0&&(this.assetFolder=H(r.assetFolder)),this.locker=new Se({max:1e3,ttl:3e4,ttlAutopurge:!0}),this.cache=r.cache??new J,this.logger=r.logger,this.metrics=r.metrics??new q,this.logger?.debug(`${this.constructor.name} config: ${Z(L({...e,logger:this.logger.constructor}))}`);const s=C(r.expiration?.purgeInterval);s&&this.startAutoPurge(s);const o={isValid(l){if(l.size===void 0)return!0;const n=l.size;if(n==null)return!1;const u=typeof n=="number"?n:Number(n);if(Number.isNaN(u)||u<0)return!1;const h=typeof this.value=="number"?this.value:Number(this.value);return!Number.isNaN(h)&&u<=h},response:$.RequestEntityTooLarge,value:this.maxUploadSize},i={isValid(l){return!!X.is(l.contentType,this.value)},response:$.UnsupportedMediaType,value:r.allowMIME},a=r.fileNameValidation??Ue,c={isValid(l){return a(l.name)},response:$.InvalidFileName};this.validation.add({filename:c,mime:i,size:o}),this.validation.add({...r.validation})}get raw(){}async getReadUrl(e,r){return b(E.METHOD_NOT_ALLOWED,`${this.constructor.name} does not implement getReadUrl()`)}async getUploadUrl(e,r){return b(E.METHOD_NOT_ALLOWED,`${this.constructor.name} does not implement getUploadUrl()`)}get tusExtension(){const e=["creation","creation-with-upload","termination","checksum","creation-defer-length","concatenation"];return this.expiration&&e.push("expiration"),e}async validate(e){await this.validation.verify(e)}async exists(e,r){return this.instrumentOperation("exists",async()=>{try{return await this.getMeta(e.id,r),!0}catch{return!1}})}normalizeError(e){const r={code:e.name,message:e.message,name:e.name,statusCode:500};return{...r,message:`[${this.constructor.name}] ${r.message}`}}get config(){return this.genericConfig}async saveMeta(e){return V.assertSafeId(e.id),this.updateTimestamps(e),this.cache.set(e.id,e),this.meta.save(e.id,e)}static assertSafeId(e){(!e||typeof e!="string"||e.includes("\0")||e.includes("../")||e.includes("..\\")||e===".."||e.startsWith("../")||e.startsWith("..\\")||O(e)||/^[A-Z]:[/\\]/i.test(e))&&b(E.INVALID_FILE_NAME,`Invalid file id: "${e}"`)}async deleteMeta(e){return this.cache.delete(e),this.meta.delete(e)}async getMeta(e,r){try{const s=await this.meta.get(e);return this.cache.set(s.id,s),{...s}}catch(s){const o=this.normalizeError(s instanceof Error?s:new Error(String(s)));return await this.onError(o),b(E.FILE_NOT_FOUND)}}async checkIfExpired(e){return re(e)?(this.delete(e).catch(()=>{}),this.deleteMeta(e.id).catch(()=>{}),b(E.GONE)):e}async purge(e){return this.instrumentOperation("purge",async()=>{const r=C(e||this.expiration?.maxAge),s={items:[],maxAgeMs:r};if(r){const o=Date.now()-r,i=(await this.list()).filter(a=>Number(new Date(this.expiration?.rolling&&a.modifiedAt||a.createdAt))<o);for await(const{id:a,...c}of i)try{const l=await this.delete({id:a});s.items.push({...l,...c})}catch(l){this.logger?.warn(`Failed to delete file ${a} during purge: ${l instanceof Error?l.message:String(l)}`)}s.items.length>0&&(this.logger?.info(`Purge: removed ${s.items.length} uploads`),this.metrics.gauge("storage.operations.purge.items_count",s.items.length,{storage:this.constructor.name.toLowerCase().replace("storage","")}))}return s})}async getStream({id:e},r){return this.instrumentOperation("getStream",async()=>{const s=await this.get({id:e},r),o=K.from(s.content);return{headers:{"Content-Length":String(s.size),"Content-Type":s.contentType,...s.ETag&&{ETag:s.ETag},...s.modifiedAt&&{"Last-Modified":s.modifiedAt.toString()}},size:typeof s.size=="number"?s.size:void 0,stream:o}})}async list(e=1e3,r){return this.instrumentOperation("list",async()=>{throw new Error("Not implemented")})}async listDirectory(e){return b(E.METHOD_NOT_ALLOWED,`${this.constructor.name} does not implement listDirectory()`)}async update({id:e},r){return this.instrumentOperation("update",async()=>{const s=await this.getMeta(e),o={...r};if("ttl"in o&&o.ttl!==void 0){const a=o.ttl,c=typeof a=="string"?C(a):a;c!==void 0&&(o.expiredAt=Date.now()+c),delete o.ttl}Oe(s,o),await this.saveMeta(s);const i={...s,status:"updated"};return await this.onUpdate(i),i})}async deleteBatch(e,r){const s=Date.now(),o=this.constructor.name.toLowerCase().replace("storage","");this.metrics.increment("storage.operations.batch.delete.count",1,{batch_size:e.length,storage:o});const i=[],a=[],c=e.map(async u=>{try{return{file:await this.delete({id:u},r),id:u,success:!0}}catch(h){const g=h instanceof Error?h.message:"Delete failed";return this.metrics.increment("storage.operations.delete.error.count",1,{error:g,storage:o}),{error:g,id:u,success:!1}}}),l=await Promise.allSettled(c);for(const u of l)u.status==="fulfilled"?u.value.success?i.push(u.value.file):a.push({error:u.value.error,id:u.value.id}):a.push({error:u.reason?.message||"Delete failed",id:""});const n=Date.now()-s;return this.metrics.timing("storage.operations.batch.delete.duration",n,{batch_size:e.length,storage:o}),this.metrics.gauge("storage.operations.batch.delete.success_count",i.length,{storage:o}),this.metrics.gauge("storage.operations.batch.delete.failed_count",a.length,{storage:o}),{failed:a,failedCount:a.length,successful:i,successfulCount:i.length}}async copyBatch(e){const r=Date.now(),s=this.constructor.name.toLowerCase().replace("storage","");this.metrics.increment("storage.operations.batch.copy.count",1,{batch_size:e.length,storage:s});const o=[],i=[],a=e.map(async({destination:n,options:u,source:h})=>{try{return{file:await this.copy(h,n,u),id:n,success:!0}}catch(g){const d=g instanceof Error?g.message:"Copy failed";return this.metrics.increment("storage.operations.copy.error.count",1,{error:d,storage:s}),{error:d,id:n,success:!1}}}),c=await Promise.allSettled(a);for(const n of c)n.status==="fulfilled"?n.value.success&&n.value.file?o.push(n.value.file):i.push({error:n.value.error||"Copy failed",id:n.value.id}):i.push({error:n.reason?.message||"Copy failed",id:""});const l=Date.now()-r;return this.metrics.timing("storage.operations.batch.copy.duration",l,{batch_size:e.length,storage:s}),this.metrics.gauge("storage.operations.batch.copy.success_count",o.length,{storage:s}),this.metrics.gauge("storage.operations.batch.copy.failed_count",i.length,{storage:s}),{failed:i,failedCount:i.length,successful:o,successfulCount:o.length}}async moveBatch(e){const r=Date.now(),s=this.constructor.name.toLowerCase().replace("storage","");this.metrics.increment("storage.operations.batch.move.count",1,{batch_size:e.length,storage:s});const o=[],i=[],a=e.map(async({destination:n,source:u})=>{try{return{file:await this.move(u,n),id:n,success:!0}}catch(h){const g=h instanceof Error?h.message:"Move failed";return this.metrics.increment("storage.operations.move.error.count",1,{error:g,storage:s}),{error:g,id:n,success:!1}}}),c=await Promise.allSettled(a);for(const n of c)n.status==="fulfilled"?n.value.success&&n.value.file?o.push(n.value.file):i.push({error:n.value.error||"Move failed",id:n.value.id}):i.push({error:n.reason?.message||"Move failed",id:n.reason?.id||""});const l=Date.now()-r;return this.metrics.timing("storage.operations.batch.move.duration",l,{batch_size:e.length,storage:s}),this.metrics.gauge("storage.operations.batch.move.success_count",o.length,{storage:s}),this.metrics.gauge("storage.operations.batch.move.failed_count",i.length,{storage:s}),{failed:i,failedCount:i.length,successful:o,successfulCount:o.length}}async lock(e){return this.locker.has(e)?b(E.FILE_LOCKED):this.config.concurrency&&typeof this.config.concurrency=="number"&&this.config.concurrency<=this.locker.size?b(E.STORAGE_BUSY):this.locker.lock(e)}async unlock(e,r){if(r===void 0){this.locker.delete(e);return}this.locker.unlock(e,r)}async withLock(e,r){const s=await this.lock(e);try{return await r()}finally{await this.unlock(e,s)}}isUnsupportedChecksum(e=""){return!!e&&!this.checksumTypes.includes(e)}startAutoPurge(e){if(e>=2147483647)throw new Error("“purgeInterval” must be less than 2147483647 ms");W(()=>{this.purge().catch(r=>this.logger?.error(r))},e)}updateTimestamps(e){e.createdAt??=new Date().toISOString();const r=C(this.expiration?.maxAge);return r&&!e.expiredAt&&(e.expiredAt=this.expiration?.rolling?Date.now()+r:+new Date(e.createdAt)+r),e}getRetryConfig(){}runOperation(e,r,s){let o;typeof e?.retries=="number"?o={maxRetries:e.retries}:e?.retries&&(o=e.retries);const i={...this.getRetryConfig(),...o};s?.replayable===!1&&(i.maxRetries=0);const a=[];this.genericConfig.defaultSignal&&a.push(this.genericConfig.defaultSignal),e?.signal&&a.push(e.signal);let c;a.length===1?[c]=a:a.length>1&&(c=AbortSignal.any(a));const l=typeof e?.timeout=="number"?e.timeout:this.genericConfig.defaultTimeout,n=typeof l=="number"&&l>0?l:void 0,u=i.shouldRetry;i.shouldRetry=g=>c?.aborted||g instanceof Error&&g.name==="AbortError"?!1:u?u(g):!1;const h=g=>{if(g instanceof Error&&g.name==="AbortError")return g;const d=g instanceof Error&&g.message?g.message:"The operation was aborted",m=new Error(d,{cause:g});return m.name="AbortError",m};return te(async()=>{if(c?.aborted)throw h(c.reason);let g,d;if(n===void 0)d=c;else{const m=new AbortController;g=setTimeout(()=>{m.abort(new DOMException(`The operation timed out after ${n}ms`,"TimeoutError"))},n),d=c?AbortSignal.any([c,m.signal]):m.signal}try{return await r(d)}catch(m){throw d?.aborted?h(m):m}finally{g&&clearTimeout(g)}},i)}async instrumentOperation(e,r,s){const o=Date.now(),i={storage:this.constructor.name.toLowerCase().replace("storage",""),...s};try{this.metrics.increment(`storage.operations.${e}.count`,1,i);const a=await r(),c=Date.now()-o;return this.metrics.timing(`storage.operations.${e}.duration`,c,i),a&&typeof a=="object"&&"size"in a&&typeof a.size=="number"&&this.metrics.gauge("storage.files.size",a.size,{...i,operation:e}),a}catch(a){const c=Date.now()-o,l=a instanceof Error?a.message:"Unknown error";throw this.metrics.timing(`storage.operations.${e}.duration`,c,{...i,error:"true"}),this.metrics.increment(`storage.operations.${e}.error.count`,1,{...i,error:l}),a}}}export{V as B,Ae as C,_ as X,Ze as a,Te as b,C as c,Ue as d,Oe as e,We as i};
|