@visulima/storage 1.0.0-alpha.3 → 1.0.0-alpha.30
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 +361 -0
- package/LICENSE.md +213 -573
- package/README.md +83 -470
- package/dist/adapter/nuxt/module.d.ts +41 -34
- package/dist/adapter/nuxt/module.js +1 -93
- package/dist/adapter/nuxt/node_modules/.bin/nuxi +22 -0
- package/dist/adapter/nuxt/node_modules/.bin/nuxt +22 -0
- 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 +361 -4
- package/dist/handler/http/node/index.js +1 -4
- 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 +58 -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/AwsLightFile-BSqjc_rD.js +1 -0
- package/dist/packem_shared/AwsLightMetaStorage-B-iQbToR.js +1 -0
- package/dist/packem_shared/AwsLightStorage-w21RxjUm.js +1 -0
- package/dist/packem_shared/AzureFile-Dgj2Tef4.js +1 -0
- package/dist/packem_shared/AzureSMetaStorage-CR-lfQNQ.js +1 -0
- package/dist/packem_shared/AzureStorage-2kl7JDXs.js +1 -0
- package/dist/packem_shared/BaseTransformer-Fpcuz4kj.js +1 -0
- package/dist/packem_shared/BoxFile-Be0S4N1L.js +1 -0
- package/dist/packem_shared/BoxMetaStorage-DLdXbZaV.js +1 -0
- package/dist/packem_shared/BoxStorage-BUeEJoGL.js +1 -0
- package/dist/packem_shared/BunS3File-D-SRiyrm.js +1 -0
- package/dist/packem_shared/BunS3MetaStorage-Bv_CTTMz.js +1 -0
- package/dist/packem_shared/BunS3Storage-WM3rF6Fw.js +1 -0
- package/dist/packem_shared/BunnyFile-Dotl-lO9.js +1 -0
- package/dist/packem_shared/BunnyMetaStorage-DNMTSeoN.js +1 -0
- package/dist/packem_shared/BunnyStorage-D3s2fRB3.js +1 -0
- package/dist/packem_shared/CloudinaryFile-B5-m33eS.js +1 -0
- package/dist/packem_shared/CloudinaryMetaStorage-DEBk5eQy.js +1 -0
- package/dist/packem_shared/CloudinaryStorage-BBE2-aVz.js +1 -0
- package/dist/packem_shared/DiskStorage-DL0GiG6k.js +1 -0
- package/dist/packem_shared/DiskStorageWithChecksum-BvUTn7O-.js +1 -0
- package/dist/packem_shared/DropboxFile-BGVG2kXM.js +1 -0
- package/dist/packem_shared/DropboxMetaStorage-C6vj1QDA.js +1 -0
- package/dist/packem_shared/DropboxStorage-BL3OIdE_.js +1 -0
- package/dist/packem_shared/ERRORS-CyOuSMLY.js +1 -0
- package/dist/packem_shared/File-BhfUgJjs.js +1 -0
- package/dist/packem_shared/Files-CJh9_N-9.js +1 -0
- package/dist/packem_shared/FirebaseFile-JEu3plMP.js +1 -0
- package/dist/packem_shared/FirebaseMetaStorage-CzyOim-J.js +1 -0
- package/dist/packem_shared/FirebaseStorage-lXMXy3Pm.js +2 -0
- package/dist/packem_shared/FtpFile-B8jaICTB.js +1 -0
- package/dist/packem_shared/FtpMetaStorage-1Njy0DpU.js +1 -0
- package/dist/packem_shared/FtpStorage-Dw94efNW.js +1 -0
- package/dist/packem_shared/GCSConfig-BQ0OpVhe.js +1 -0
- package/dist/packem_shared/GCSFile-CDQ6IWAz.js +1 -0
- package/dist/packem_shared/GCSMetaStorage-udgXA5ia.js +1 -0
- package/dist/packem_shared/GCStorage-ChY6uJuO.js +1 -0
- package/dist/packem_shared/GoogleDriveFile-D0aGfGbL.js +1 -0
- package/dist/packem_shared/GoogleDriveMetaStorage-WGuUZPyx.js +1 -0
- package/dist/packem_shared/GoogleDriveStorage-C0NhBBWH.js +1 -0
- package/dist/packem_shared/LocalMetaStorage-QMKL7McF.js +1 -0
- package/dist/packem_shared/MediaTransformer-D-1c9Q_k.js +1 -0
- package/dist/packem_shared/MetaStorage-Y4m1dWgd.js +1 -0
- package/dist/packem_shared/Metadata-B6Ir0KO7.js +1 -0
- package/dist/packem_shared/Multipart-CIFfQksD.js +1 -0
- package/dist/packem_shared/Multipart-D9WIud9R.js +1 -0
- package/dist/packem_shared/NetlifyBlobFile-PMZLJ8AC.js +1 -0
- package/dist/packem_shared/NetlifyBlobMetaStorage-ClIFdTkT.js +1 -0
- package/dist/packem_shared/NetlifyBlobStorage-CO89TGvF.js +1 -0
- package/dist/packem_shared/NoOpMetrics-Dky06sf1.js +1 -0
- package/dist/packem_shared/OneDriveFile-XbVVKIJh.js +1 -0
- package/dist/packem_shared/OneDriveMetaStorage-DS4f83X2.js +1 -0
- package/dist/packem_shared/OneDriveStorage-jAN46vRm.js +1 -0
- package/dist/packem_shared/OpenTelemetryMetrics-9uxQMSlg.js +1 -0
- package/dist/packem_shared/PocketBaseFile-CkAiSBb0.js +1 -0
- package/dist/packem_shared/PocketBaseMetaStorage-B6utPncj.js +1 -0
- package/dist/packem_shared/PocketBaseStorage-DpOjOKAt.js +1 -0
- package/dist/packem_shared/Rest-BuD3ySAg.js +1 -0
- package/dist/packem_shared/Rest-URrQ5FYM.js +1 -0
- package/dist/packem_shared/S3File-BfmCOET4.js +1 -0
- package/dist/packem_shared/S3MetaStorage-vcriiosn.js +1 -0
- package/dist/packem_shared/S3Storage-n1ohEZj4.js +1 -0
- package/dist/packem_shared/SftpFile-CQCxZNVq.js +1 -0
- package/dist/packem_shared/SftpMetaStorage-DYqXwCdM.js +1 -0
- package/dist/packem_shared/SftpStorage-Ban-WN8v.js +1 -0
- package/dist/packem_shared/SharePointFile-BA6X9Sxr.js +1 -0
- package/dist/packem_shared/SharePointMetaStorage-DVM5-X6g.js +1 -0
- package/dist/packem_shared/SharePointStorage-BY90zh1c.js +1 -0
- package/dist/packem_shared/SupabaseFile-DZ1iv9gM.js +1 -0
- package/dist/packem_shared/SupabaseMetaStorage-ivXoYVUu.js +1 -0
- package/dist/packem_shared/SupabaseStorage-pNbHAE1Y.js +1 -0
- package/dist/packem_shared/TUS_RESUMABLE-B7KtPVeC.js +1 -0
- package/dist/packem_shared/Tus-Fp_hx5ug.js +1 -0
- package/dist/packem_shared/Tus-TNG9HAY8.js +1 -0
- package/dist/packem_shared/UploadThingFile-BpG9mE8K.js +1 -0
- package/dist/packem_shared/UploadThingMetaStorage-BvKNzgm7.js +1 -0
- package/dist/packem_shared/UploadThingStorage-BcmIE2dI.js +1 -0
- package/dist/packem_shared/ValidationError-D8KKJiKA.js +1 -0
- package/dist/packem_shared/VercelBlobFile-Cni_1qwD.js +1 -0
- package/dist/packem_shared/VercelBlobMetaStorage-CwaqWucZ.js +1 -0
- package/dist/packem_shared/VercelBlobStorage-s260zfFo.js +1 -0
- package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +1 -0
- package/dist/packem_shared/agentsListFiles-R-CnGKc4.js +1 -0
- package/dist/packem_shared/akamai-BYS9pP8S.js +1 -0
- package/dist/packem_shared/alibaba-BJQ6ijoK.js +1 -0
- package/dist/packem_shared/approval-BBeX3o4E.js +1 -0
- package/dist/packem_shared/approval.d-CMAYH9GF.d.ts +75 -0
- package/dist/packem_shared/aws-light-meta-storage-CstQBYXG.js +4 -0
- package/dist/packem_shared/azure-meta-storage-C4SrMtT2.js +1 -0
- package/dist/packem_shared/backblaze-CvdtCvJL.js +1 -0
- package/dist/packem_shared/base-handler-core-BYDQditz.js +1 -0
- package/dist/packem_shared/base-handler-fetch-DWzsPkmV.js +1 -0
- package/dist/packem_shared/base-handler-node-Dety2rQB.js +1 -0
- package/dist/packem_shared/cache-qV_5Umeq.js +1 -0
- package/dist/packem_shared/claudeListFiles-DAezbKEi.js +1 -0
- package/dist/packem_shared/cloudflare-Bm_Pg6yx.js +1 -0
- package/dist/packem_shared/createResponsesFileTools-BCep-qdO.js +1 -0
- package/dist/packem_shared/defaultCloudStorageFileNameValidation-shIZX_7L.js +1 -0
- package/dist/packem_shared/detect-file-type-5JhzC9RU.js +1 -0
- package/dist/packem_shared/digitalOcean-Lj1NfDzc.js +1 -0
- package/dist/packem_shared/disk-storage-CKAJvhcj.js +1 -0
- package/dist/packem_shared/disk-storage-with-checksum.d-mHcg2uLw.d.ts +150 -0
- package/dist/packem_shared/executors-DG6hGtvm.js +1 -0
- package/dist/packem_shared/executors.d-X4hz3zfu.d.ts +65 -0
- package/dist/packem_shared/exoscale-O0HzxoDz.js +1 -0
- package/dist/packem_shared/filebase-D-urO4Ob.js +1 -0
- package/dist/packem_shared/gcs-meta-storage-mZiqlX-9.js +1 -0
- package/dist/packem_shared/has-content-Bx2p8Okx.js +1 -0
- package/dist/packem_shared/headers-DC2MEOrK.js +27 -0
- package/dist/packem_shared/hetzner-DDxE7Gy7.js +1 -0
- package/dist/packem_shared/ibmCos-Rx_yku4H.js +1 -0
- package/dist/packem_shared/idriveE2-BFhw0Vwy.js +1 -0
- package/dist/packem_shared/index-B4ETk0Lu.js +5 -0
- package/dist/packem_shared/index.d-C4Fivh4I.d.ts +94 -0
- package/dist/packem_shared/is-expired-1JuZjDtb.js +1 -0
- package/dist/packem_shared/isRetryableError-BhizNeAz.js +1 -0
- package/dist/packem_shared/isValidMediaType-B-2UKjZx.js +1 -0
- package/dist/packem_shared/listFiles-B6VF05d-.js +1 -0
- package/dist/packem_shared/listFiles-BtP6VnUp.js +1 -0
- package/dist/packem_shared/local-meta-storage-Bi0mK6gD.js +1 -0
- package/dist/packem_shared/local-meta-storage.d-B11vHYNm.d.ts +21 -0
- package/dist/packem_shared/media-transformer.d-C3QvECD7.d.ts +331 -0
- package/dist/packem_shared/minio-T_Z3iEy7.js +1 -0
- package/dist/packem_shared/multipart-base-BxckfvQf.js +1 -0
- package/dist/packem_shared/oauth-refresh-Dg2ybc6_.js +1 -0
- package/dist/packem_shared/oracleCloud-D5T9s4JV.js +1 -0
- package/dist/packem_shared/ovhCloud-DCwef2fe.js +1 -0
- package/dist/packem_shared/part-match-B5fLLmFw.js +1 -0
- package/dist/packem_shared/path-D7rMc9nq-B718mbm6.js +1 -0
- package/dist/packem_shared/posix-dirname-CiHXPPnw.js +1 -0
- package/dist/packem_shared/response-builder-Wdo_fvcF.js +1 -0
- package/dist/packem_shared/rest-base-DI7xFXr5.js +1 -0
- package/dist/packem_shared/restOpenApiSpec-PaIVbESh.js +1 -0
- package/dist/packem_shared/s3-base-storage-Dbexfg7p.js +1 -0
- package/dist/packem_shared/s3-base-storage.d-V3N2nKCt.d.ts +260 -0
- package/dist/packem_shared/scaleway-ygRXOss9.js +1 -0
- package/dist/packem_shared/sharedGet-Ce7WGAsc.js +1 -0
- package/dist/packem_shared/storage-Dh0tJh7j.js +1 -0
- package/dist/packem_shared/storage.d-RteRC-cG.d.ts +1106 -0
- package/dist/packem_shared/storj-CVA9mM-7.js +1 -0
- package/dist/packem_shared/tencent-CAcAGaIW.js +1 -0
- package/dist/packem_shared/tigris-wmhjfsH2.js +1 -0
- package/dist/packem_shared/transformOpenApiSpec-C0vEbDTO.js +1 -0
- package/dist/packem_shared/tus-base.d-CygntIPM.d.ts +99 -0
- package/dist/packem_shared/tusOpenApiSpec-DF0-hlWV.js +1 -0
- package/dist/packem_shared/types.d-ChNXbbHG.d.ts +104 -0
- package/dist/packem_shared/types.d-DxonY4XS.d.ts +720 -0
- package/dist/packem_shared/types.d-cI_cMxcZ.d.ts +49 -0
- package/dist/packem_shared/update-size-DANV7aa2.js +1 -0
- package/dist/packem_shared/vultr-lK9L-sFk.js +1 -0
- package/dist/packem_shared/waitForStorage-ChSBLhLc.js +1 -0
- package/dist/packem_shared/wasabi-JQzxdrFy.js +1 -0
- package/dist/packem_shared/xhrOpenApiSpec-nyoboz83.js +1 -0
- package/dist/packem_shared/yandex-ZwvE77v4.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 +321 -4
- package/dist/storage/aws/index.js +1 -3
- package/dist/storage/aws-light/index.d.ts +254 -4
- package/dist/storage/aws-light/index.js +1 -3
- package/dist/storage/azure/index.d.ts +217 -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 +85 -0
- package/dist/storage/ftp/index.js +1 -0
- package/dist/storage/gcs/index.d.ts +181 -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/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 +86 -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 +195 -47
- 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-BlltBst6.js +0 -12
- package/dist/packem_shared/DiskStorageWithChecksum-BJTmMklc.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-BMFEdzJ7.js +0 -7
- package/dist/packem_shared/GCStorage-DnhiwaS9.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-CNFK_Okz.js +0 -163
- package/dist/packem_shared/Multipart-CtUL7BQw.js +0 -128
- 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-CAOAEkOj.js +0 -267
- package/dist/packem_shared/Rest-DNuLwBrK.js +0 -228
- 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-GJzZ9R-f.js +0 -434
- package/dist/packem_shared/Tus-B8PmlMgR.js +0 -200
- package/dist/packem_shared/Tus-C4F1aYOl.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-B85MJLTf.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-BKuf4YLT.js +0 -303
- package/dist/packem_shared/base-handler-fetch-Cr0hLiqg.js +0 -291
- package/dist/packem_shared/base-handler-node-gk5aN9Cx.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-Bh2wy3YW.js +0 -810
- package/dist/packem_shared/gcs-meta-storage-0tgMNnPO.js +0 -158
- package/dist/packem_shared/has-content-CY66ehMK.js +0 -3
- package/dist/packem_shared/headers-DoS5nwM-.js +0 -3220
- 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-B3i67SSX.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-GRCcnan7.js +0 -457
- package/dist/packem_shared/restOpenApiSpec-CwcHHY2C.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-6ohiToBy.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-DS17brnx.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 @@
|
|
|
1
|
+
var re=Object.defineProperty;var o=(e,t)=>re(e,"name",{value:t,configurable:!0});import{utimes as ae}from"node:fs/promises";import{tmpdir as oe}from"node:os";import{createRequire as m}from"node:module";import{A as T,M as _,J as ie,K as ne,L as R}from"./path-D7rMc9nq-B718mbm6.js";import{throwErrorCode as j,ERRORS as P}from"./ERRORS-CyOuSMLY.js";import se from"./MetaStorage-Y4m1dWgd.js";import{stringifyMetadata as ce,parseMetadata as ue}from"./Metadata-B6Ir0KO7.js";const E=0,le=4;var fe=Object.defineProperty,pe=o((e,t)=>fe(e,"name",{value:t,configurable:!0}),"t$6"),me=Object.defineProperty,de=pe((e,t)=>me(e,"name",{value:t,configurable:!0}),"t"),ge=Object.defineProperty,be=de((e,t)=>ge(e,"name",{value:t,configurable:!0}),"n");const $=be(e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},"assertValidFileOrDirectoryPath");var ve=Object.defineProperty,ye=o((e,t)=>ve(e,"name",{value:t,configurable:!0}),"i$8"),he=Object.defineProperty,$e=ye((e,t)=>he(e,"name",{value:t,configurable:!0}),"r"),we=Object.defineProperty,Oe=$e((e,t)=>we(e,"name",{value:t,configurable:!0}),"i");const S=Oe(e=>{if(e.isFile())return"file";if(e.isDirectory())return"dir";if(e.isSymbolicLink())return"symlink"},"getFileInfoType");var je=Object.defineProperty,Pe=o((e,t)=>je(e,"name",{value:t,configurable:!0}),"i$7"),xe=Object.defineProperty,q=Pe((e,t)=>xe(e,"name",{value:t,configurable:!0}),"s");const Ee=m(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Te=q(e=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[t,r]=d.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return d.getBuiltinModule(e)}return Ee(e)},"__cjs_getBuiltinModule"),{lstat:I,mkdir:_e}=Te("node:fs/promises");var Me=Object.defineProperty,ke=q((e,t)=>Me(e,"name",{value:t,configurable:!0}),"o");const Ne=ke(async e=>{$(e);try{const t=await I(e);if(!t.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(S(t))}'`);return}catch(t){if(t.code!=="ENOENT")throw t}try{await _e(e,{recursive:!0})}catch(t){if(t.code!=="EEXIST")throw t;const r=await I(e);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(S(r))}'`,{cause:t})}},"ensureDir");var ze=Object.defineProperty,l=o((e,t)=>ze(e,"name",{value:t,configurable:!0}),"n$7"),Be=Object.defineProperty,s=l((e,t)=>Be(e,"name",{value:t,configurable:!0}),"a");const Fe=m(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ae=s(e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[t,r]=g.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return g.getBuiltinModule(e)}return Fe(e)},"__cjs_getBuiltinModule"),{fileURLToPath:De}=Ae("node:url");var Re=Object.defineProperty,p=s((e,t)=>Re(e,"name",{value:t,configurable:!0}),"t$1");function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o(O,"m$4");l(O,"d");s(O,"getDefaultExportFromCjs");p(O,"getDefaultExportFromCjs");function M(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o(M,"h$1");l(M,"O");s(M,"getDefaultExportFromNamespaceIfPresent");p(M,"getDefaultExportFromNamespaceIfPresent");function k(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.keys(e).length===1?e.default:e}o(k,"x");l(k,"P");s(k,"getDefaultExportFromNamespaceIfNotNamed");p(k,"getDefaultExportFromNamespaceIfNotNamed");function N(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var r=p(s(l(o(function a(){var i=!1;try{i=this instanceof a}catch{}return i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)},"a"),"s"),"a"),"a");r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(a){var i=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(r,a,i.get?i:{enumerable:!0,get:p(function(){return e[a]},"get")})}),r}o(N,"y$2");l(N,"_");s(N,"getAugmentedNamespace");p(N,"getAugmentedNamespace");var L,U;function z(){return U||(U=1,L=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),L}o(z,"w$2");l(z,"k");s(z,"requireBinaryExtensions");var Se=z();const Ie=O(Se);var Le=Object.defineProperty,n=s((e,t)=>Le(e,"name",{value:t,configurable:!0}),"r");const Ue=new Set(Ie),Ce=new Set(["/","\\",void 0]),C=Symbol.for("pathe:normalizedAlias"),We=/(^|[/\\])([^/\\]+?)(?=(?:\.[^.]+)?$)/,qe=n((e,t)=>t.split("/").length-e.split("/").length,"compareAliases"),w=n((e="/")=>{const t=e.at(-1);return t==="/"||t==="\\"},"hasTrailingSlash"),V=n(e=>{if(e[C])return e;const t=Object.fromEntries(Object.entries(e).toSorted(([r],[a])=>qe(r,a)));for(const r in t)for(const a in t)a===r||r.startsWith(a)||t[r].startsWith(a)&&Ce.has(t[r][a.length])&&(t[r]=t[a]+t[r].slice(a.length));return Object.defineProperty(t,C,{enumerable:!1,value:!0}),t},"normalizeAliases");n((e,t)=>{e=T(e),t=V(t);for(const[r,a]of Object.entries(t)){if(!e.startsWith(r))continue;const i=w(r)?r.slice(0,-1):r;if(w(e[i.length]))return _(a,e.slice(r.length))}return e},"resolveAlias");n(e=>We.exec(e)?.[2],"filename");n((e,t)=>{e=T(e),t=V(t);for(const[r,a]of Object.entries(t).toReversed()){if(!e.startsWith(a))continue;const i=w(a)?a.slice(0,-1):a;if(w(e[i.length]))return _(r,e.slice(a.length))}return e},"reverseResolveAlias");const Ve=/^(?:\.?\.[/\\]|\.\.\B)/,Je=/^(?:msys|cygwin)$/;n(e=>Ve.test(e)||e==="..","isRelative");n(e=>Ue.has(ie(e).slice(1).toLowerCase()),"isBinaryPath");const B=n(e=>T(e instanceof URL?De(e):e),"toPath");n(()=>{if(!globalThis.process)return!1;if(globalThis.process.platform==="win32"||globalThis.process.platform==="cygwin")return!0;const e=globalThis.process.env.OSTYPE;return typeof e!="string"?!1:Je.test(e)},"isWindows");var Ke=Object.defineProperty,J=o((e,t)=>Ke(e,"name",{value:t,configurable:!0}),"t$4"),Xe=Object.defineProperty,F=J((e,t)=>Xe(e,"name",{value:t,configurable:!0}),"s");const Ye=m(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ge=F(e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,r]=b.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return b.getBuiltinModule(e)}return Ye(e)},"__cjs_getBuiltinModule"),{access:He}=Ge("node:fs/promises");var Qe=Object.defineProperty,Ze=F((e,t)=>Qe(e,"name",{value:t,configurable:!0}),"o");async function u(e,t=E){$(e),e=B(e);try{return await He(e,t),!0}catch{return!1}}o(u,"i$5");J(u,"d");F(u,"m");Ze(u,"isAccessible");var et=Object.defineProperty,K=o((e,t)=>et(e,"name",{value:t,configurable:!0}),"t$3"),tt=Object.defineProperty,X=K((e,t)=>tt(e,"name",{value:t,configurable:!0}),"t"),rt=Object.defineProperty,at=X((e,t)=>rt(e,"name",{value:t,configurable:!0}),"o");let ot=class extends Error{static{o(this,"c")}static{K(this,"i")}static{X(this,"n")}static{at(this,"PermissionError")}constructor(t){super(`EPERM: Operation not permitted, ${t}`)}get code(){return"EPERM"}set code(t){throw new Error("Cannot overwrite code EPERM")}get name(){return"PermissionError"}set name(t){throw new Error("Cannot overwrite name of PermissionError")}};var it=Object.defineProperty,nt=o((e,t)=>it(e,"name",{value:t,configurable:!0}),"f$4"),st=Object.defineProperty,Y=nt((e,t)=>st(e,"name",{value:t,configurable:!0}),"i");const ct=m(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=Y(e=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[t,r]=v.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return v.getBuiltinModule(e)}return ct(e)},"__cjs_getBuiltinModule"),{readFile:ut}=G("node:fs/promises"),{unzip:lt,brotliDecompress:ft}=G("node:zlib");var pt=Object.defineProperty,H=Y((e,t)=>pt(e,"name",{value:t,configurable:!0}),"n");const mt={brotli:ft,gzip:lt,none:H((e,t)=>{t(null,e)},"none")},dt=H(async(e,t)=>{if($(e),e=B(e),!await u(e))throw new ot(`unable to read the non-accessible file: ${e}`);if(!await u(e,le))throw new Error(`Unable to read the non-readable file: ${e}`);const{buffer:r,compression:a,encoding:i,flag:c}=t??{};return await ut(e,c?{encoding:i,flag:c}:{encoding:i}).then(async f=>await new Promise((ee,te)=>{mt[a??"none"](f,(A,D)=>{A?te(A):ee(r?D:D.toString())})})).catch(f=>{throw f})},"readFile");var gt=Object.defineProperty,bt=o((e,t)=>gt(e,"name",{value:t,configurable:!0}),"a$4"),vt=Object.defineProperty,yt=bt((e,t)=>vt(e,"name",{value:t,configurable:!0}),"t"),ht=Object.defineProperty,$t=yt((e,t)=>ht(e,"name",{value:t,configurable:!0}),"t");const wt=$t(e=>{const t={force:!0,recursive:!0};return e?.maxRetries!==void 0&&(t.maxRetries=e.maxRetries),e?.retryDelay!==void 0&&(t.retryDelay=e.retryDelay),t},"buildRmOptions");var Ot=Object.defineProperty,jt=o((e,t)=>Ot(e,"name",{value:t,configurable:!0}),"i$2"),Pt=Object.defineProperty,Q=jt((e,t)=>Pt(e,"name",{value:t,configurable:!0}),"s");const xt=m(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Et=Q(e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[t,r]=y.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return y.getBuiltinModule(e)}return xt(e)},"__cjs_getBuiltinModule"),{unlink:Tt,rm:_t}=Et("node:fs/promises");var Mt=Object.defineProperty,kt=Q((e,t)=>Mt(e,"name",{value:t,configurable:!0}),"i");const Nt=kt(async(e,t={})=>{$(e);try{await Tt(e)}catch{}try{await _t(e,wt(t))}catch{}},"remove");var zt=Object.defineProperty,Bt=o((e,t)=>zt(e,"name",{value:t,configurable:!0}),"a$2"),Ft=Object.defineProperty,At=Bt((e,t)=>Ft(e,"name",{value:t,configurable:!0}),"t"),Dt=Object.defineProperty,Rt=At((e,t)=>Dt(e,"name",{value:t,configurable:!0}),"e");const St=Rt(e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},"assertValidFileContents");var It=Object.defineProperty,Lt=o((e,t)=>It(e,"name",{value:t,configurable:!0}),"t"),Ut=Object.defineProperty,Ct=Lt((e,t)=>Ut(e,"name",{value:t,configurable:!0}),"r"),Wt=Object.defineProperty,qt=Ct((e,t)=>Wt(e,"name",{value:t,configurable:!0}),"f");const Vt=new TextEncoder,Jt=qt(e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return Vt.encode(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e)){const t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},"toUint8Array");var Kt=Object.defineProperty,Xt=o((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"m"),Yt=Object.defineProperty,Z=Xt((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"s");const Gt=m(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ht=Z(e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[t,r]=h.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return h.getBuiltinModule(e)}return Gt(e)},"__cjs_getBuiltinModule"),{mkdir:Qt,writeFile:Zt,stat:er,rename:W,chown:tr,chmod:rr,unlink:ar}=Ht("node:fs/promises");var or=Object.defineProperty,ir=Z((e,t)=>or(e,"name",{value:t,configurable:!0}),"d");const nr=ir(async(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},$(e),St(t),e=B(e);const a=`${e}.tmp`;try{const i=await u(e,E);if(!i&&r.recursive){const f=ne(e);await u(f,E)||await Qt(f,{recursive:!0})}let c;if(await Zt(a,Jt(t),{encoding:r.encoding,flag:r.flag}),i&&!r.overwrite&&(c=await er(e),r.chown??={gid:c.gid,uid:c.uid},await W(e,`${e}.bak`)),r.chown)try{await tr(a,r.chown.uid,r.chown.gid)}catch{}await rr(a,c&&!r.mode?c.mode:r.mode??438),await W(a,e)}catch(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{await u(a)&&await ar(`${e}.tmp`)}},"writeFile");var sr=Object.defineProperty,x=o((e,t)=>sr(e,"name",{value:t,configurable:!0}),"a");let vr=class extends se{static{o(this,"v")}static{x(this,"LocalMetaStorage")}directory;constructor(t){super(t),this.directory=R(t?.directory||_(oe(),"Upload_meta")),this.accessCheck().catch(r=>{this.logger?.error("Metadata storage access check failed: %O",r)})}getMetaPath=x(t=>{const r=R(`${this.directory}/${this.prefix}${t}${this.suffix}`),a=this.directory.endsWith("/")?this.directory:`${this.directory}/`;return r.startsWith(a)?r:j(P.INVALID_FILE_NAME,`Invalid id: "${t}" resolves outside the meta directory`)},"getMetaPath");getIdFromPath=x(t=>t.slice(`${this.directory}/${this.prefix}`.length,-this.suffix.length),"getIdFromPath");async save(t,r){await this.accessCheck();const a={...r};return a.metadata&&(a.metadata=ce(r.metadata)),await nr(this.getMetaPath(t),JSON.stringify(a),{recursive:!0}),r}async touch(t,r){const a=new Date;return await ae(this.getMetaPath(t),a,a),r}async get(t){try{const r=await dt(this.getMetaPath(t));if(r===void 0)throw j(P.FILE_NOT_FOUND);const a=JSON.parse(r);return a.metadata&&typeof a.metadata=="string"&&(a.metadata=ue(a.metadata)),a}catch(r){const a=r,i=r instanceof SyntaxError;throw a.code==="ENOENT"||i?j(P.FILE_NOT_FOUND):r}}async delete(t){await Nt(this.getMetaPath(t))}async accessCheck(){await Ne(this.directory)}};export{dt as B,B as U,E as _,$ as f,u as i,S as l,vr as v,Ne as w,Nt as y};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { F as File, L as LocalMetaStorageOptions, M as MetaStorage } from "./storage.d-RteRC-cG.js";
|
|
2
|
+
import 'node:stream';
|
|
3
|
+
/**
|
|
4
|
+
* Stores upload metafiles on local disk
|
|
5
|
+
*/
|
|
6
|
+
declare class LocalMetaStorage<T extends File = File> extends MetaStorage<T> {
|
|
7
|
+
readonly directory: string;
|
|
8
|
+
constructor(config?: LocalMetaStorageOptions);
|
|
9
|
+
/**
|
|
10
|
+
* Returns metafile path.
|
|
11
|
+
* @param id upload id
|
|
12
|
+
* @throws {UploadError} If the id resolves to a path outside the meta directory (e.g. via `..` traversal or absolute paths).
|
|
13
|
+
*/
|
|
14
|
+
getMetaPath: (id: string) => string;
|
|
15
|
+
override save(id: string, file: T): Promise<T>;
|
|
16
|
+
override touch(id: string, file: T): Promise<T>;
|
|
17
|
+
override get(id: string): Promise<T>;
|
|
18
|
+
override delete(id: string): Promise<void>;
|
|
19
|
+
private accessCheck;
|
|
20
|
+
}
|
|
21
|
+
export { LocalMetaStorage as L };
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { F as File, a as FileReturn, B as BaseStorage } from "./storage.d-RteRC-cG.js";
|
|
2
|
+
import { M as MediaTransformerConfig, f as MediaTransformResult } from "./types.d-DxonY4XS.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 @@
|
|
|
1
|
+
var E=Object.defineProperty;var o=(e,s)=>E(e,"name",{value:s,configurable:!0});var t=Object.defineProperty,I=o((e,s)=>t(e,"name",{value:s,configurable:!0}),"t");const S=I(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,n=e?.region??process.env.AWS_REGION??process.env.MINIO_REGION,c=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.MINIO_SECRET_ACCESS_KEY??process.env.MINIO_SECRET_KEY;if(!n||!s||!c||!r)throw new Error("Missing required parameters for Minio client.");return{credentials:{accessKeyId:s,secretAccessKey:c},endpoint:r,forcePathStyle:!0,region:n}},"minio");export{S as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=Object.defineProperty;var d=(s,t)=>h(s,"name",{value:t,configurable:!0});import{n as p}from"./headers-DC2MEOrK.js";var g=Object.defineProperty,b=d((s,t)=>g(s,"name",{value:t,configurable:!0}),"d");class y{static{d(this,"F")}static{b(this,"MultipartBase")}async handlePost(t,i,l){const r={contentType:t.mediaType||"application/octet-stream",metadata:{},originalName:t.filename,size:t.size};for(const e of i)if(!e.isFile&&e.name){let n={};if(e.name==="metadata"&&e.text)try{n=JSON.parse(e.text)}catch{}else e.name&&(n={[e.name]:e.text});Object.assign(r.metadata,n)}const m=await this.storage.create(r),c=this.createStreamFromBytes(t.bytes),o=await this.storage.write({body:c,contentLength:t.size,id:m.id,start:0});let a=o;if(Object.keys(r.metadata).length>0){const e={...o.metadata,...r.metadata};a={...await this.storage.update({id:o.id},{metadata:e}),status:o.status}}const u=this.buildFileUrl(l,a);return{...a,headers:{Location:u,...a.expiredAt===void 0?{}:{"X-Upload-Expires":a.expiredAt.toString()},...a.ETag===void 0?{}:{ETag:a.ETag}},statusCode:200}}async handleDelete(t){const i=await this.storage.delete({id:t});if(i.status===void 0)throw p(404,"File not found");return{...i,headers:{},statusCode:204}}get storage(){throw new Error("storage must be implemented")}buildFileUrl(t,i){throw new Error("buildFileUrl must be implemented")}}export{y as F};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var o=(e,t)=>d(e,"name",{value:t,configurable:!0});var h=Object.defineProperty,a=o((e,t)=>h(e,"name",{value:t,configurable:!0}),"r");const k=a(e=>{let t;const c=e.leewayMs??6e4;return{getAccessToken:a(async()=>{const s=Date.now();if(t&&t.expiresOnMs-c>s)return t.token;const 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 r=await n.json();if(!r.access_token)throw new Error(`${e.provider}: token response missing access_token`);return t={expiresOnMs:s+(r.expires_in??3600)*1e3,token:r.access_token},e.onRefresh?.(r.access_token),r.access_token},"refresh")}},"createOAuthRefreshHandle");export{k as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var E=Object.defineProperty;var C=(e,r)=>E(e,"name",{value:r,configurable:!0});var t=Object.defineProperty,n=C((e,r)=>t(e,"name",{value:r,configurable:!0}),"C");const a=n(e=>{const r=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.ORACLE_CLOUD_ACCESS_KEY_ID??process.env.ORACLE_CLOUD_ACCESS_KEY,c=e?.namespace??process.env.ORACLE_CLOUD_NAMESPACE,s=e?.region??process.env.ORACLE_CLOUD_REGION,o=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.ORACLE_CLOUD_SECRET_ACCESS_KEY??process.env.ORACLE_CLOUD_SECRET_KEY;if(!c||!s||!r||!o)throw new Error("Missing required parameters for Oracle Cloud Object Storage client.");return{credentials:{accessKeyId:r,secretAccessKey:o},endpoint:`https://${c}.compat.objectstorage.${s}.oraclecloud.com`,forcePathStyle:!0,region:s}},"oracleCloud");export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var C=Object.defineProperty;var n=(e,s)=>C(e,"name",{value:s,configurable:!0});var E=Object.defineProperty,_=n((e,s)=>E(e,"name",{value:s,configurable:!0}),"r");const S=_(e=>{const s=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.OVHCLOUD_ACCESS_KEY_ID??process.env.OVHCLOUD_ACCESS_KEY,t=e?.endpoint??process.env.OVHCLOUD_ENDPOINT,r=e?.region??process.env.OVHCLOUD_REGION,o=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.OVHCLOUD_SECRET_ACCESS_KEY??process.env.OVHCLOUD_SECRET_KEY;if(!r||!s||!o)throw new Error("Missing required parameters for OVHcloud Object Storage client.");const c=r.toLowerCase();return{credentials:{accessKeyId:s,secretAccessKey:o},endpoint:t??`https://s3.${c}.io.cloud.ovh.net`,forcePathStyle:!1,region:c}},"ovhCloud");export{S as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var r=(e,t)=>i(e,"name",{value:t,configurable:!0});var a=Object.defineProperty,s=r((e,t)=>a(e,"name",{value:t,configurable:!0}),"t");const v=s(e=>e.bytesWritten===e.size?"completed":e.createdAt?"part":"created","getFileStatus");var n=Object.defineProperty,o=r((e,t)=>n(e,"name",{value:t,configurable:!0}),"i");const z=o((e,t)=>e.size!==void 0&&t.size!==void 0&&e.size>0&&t.size>0&&e.size>t.size?!1:t.size===void 0?!0:(e.start||0)+(e.contentLength||0)<=t.size,"partMatch");export{v as o,z as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Vt=Object.defineProperty;var he=(s,u)=>Vt(s,"name",{value:u,configurable:!0});var Ht=Object.defineProperty,Jt=he((s,u)=>Ht(s,"name",{value:u,configurable:!0}),"$e"),Kt=Object.defineProperty,V=Jt((s,u)=>Kt(s,"name",{value:u,configurable:!0}),"W"),Qt=Object.defineProperty,a=V((s,u)=>Qt(s,"name",{value:u,configurable:!0}),"u$1");let ge=a(()=>{var s=(()=>{var u=Object.defineProperty,c=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,b=a((e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},"ne"),A=a((e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of p(t))!g.call(e,r)&&r!==n&&u(e,r,{get:a(()=>t[r],"get"),enumerable:!(o=c(t,r))||o.enumerable});return e},"ae"),m=a(e=>A(u({},"__esModule",{value:!0}),e),"oe"),P={};b(P,{zeptomatch:a(()=>pe,"zeptomatch")});var H=a(e=>{const t=new Set,n=[e];for(let o=0;o<n.length;o++){const r=n[o];if(t.has(r))continue;t.add(r);const{children:l}=r;if(l?.length)for(let i=0,h=l.length;i<h;i++)n.push(l[i])}return Array.from(t)},"M"),be=a(e=>{let t="";const n=H(e);for(let o=0,r=n.length;o<r;o++){const l=n[o];if(!l.regex)continue;const i=l.regex.flags;if(t||(t=i),t!==i)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${i}"`)}return t},"se"),J=a((e,t,n)=>{const o=n.get(e);if(o!==void 0)return o;const r=e.partial??t;let l="";if(e.regex&&(l+=r?"(?:$|":"",l+=e.regex.source),e.children?.length){const i=ve(e.children.map(h=>J(h,t,n)).filter(Boolean));if(i?.length){const h=e.children.some(W=>!W.regex||!(W.partial??t)),x=i.length>1||r&&(!l.length||h);l+=x?r?"(?:$|":"(?:":"",l+=i.join("|"),l+=x?")":""}}return e.regex&&(l+=r?")":""),n.set(e,l),l},"O"),we=a((e,t)=>{const n=new Map,o=H(e);for(let r=o.length-1;r>=0;r--){const l=J(o[r],t,n);if(!(r>0))return l}return""},"ie"),ve=a(e=>Array.from(new Set(e)),"ue"),S=a((e,t,n)=>S.compile(e,n).test(t),"R");S.compile=(e,t)=>{const n=t?.partial??!1,o=we(e,n),r=be(e);return new RegExp(`^(?:${o})$`,r)};var ye=S,je=a((e,t)=>{const n=ye.compile(e,t),o=`${n.source.slice(0,-1)}[\\\\/]?$`,r=n.flags;return new RegExp(o,r)},"le"),Me=je,Ae=a(e=>{const t=e.map(o=>o.source).join("|")||"$^",n=e[0]?.flags;return new RegExp(t,n)},"ve"),ze=Ae,K=a(e=>Array.isArray(e),"j"),R=a(e=>typeof e=="function","_"),ke=a(e=>e.length===0,"he"),Oe=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return n=>(n.length===0||n.length===1)&&t.test(e.call(n))})(),Ee=a(e=>typeof e=="number","de"),Ie=a(e=>typeof e=="object"&&e!==null,"xe"),Pe=a(e=>e instanceof RegExp,"me"),Re=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),Be=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),Q=a(e=>typeof e=="string","A"),y=a(e=>e===void 0,"f"),We=a(e=>{const t=new Map;return n=>{const o=t.get(n);if(o!==void 0)return o;const r=e(n);return t.set(n,r),r}},"ye"),T=a((e,t,n={})=>{const o={cache:{},input:e,index:0,indexBacktrackMax:0,options:n,output:[]},r=j(t)(o),l=Math.max(o.index,o.indexBacktrackMax);if(r&&o.index===e.length)return o.output;throw new Error(`Failed to parse at index ${l}`)},"I"),f=a((e,t)=>K(e)?Ze(e,t):Q(e)?X(e,t):_e(e,t),"i"),Ze=a((e,t)=>{const n={};for(const o of e){if(o.length!==1)throw new Error(`Invalid character: "${o}"`);const r=o.charCodeAt(0);n[r]=!0}return o=>{const r=o.input;let l=o.index,i=l;for(;i<r.length&&r.charCodeAt(i)in n;)i+=1;if(i>l){if(!y(t)&&!o.options.silent){const h=r.slice(l,i),x=R(t)?t(h,r,`${l}`):t;y(x)||o.output.push(x)}o.index=i}return!0}},"we"),_e=a((e,t)=>{if(Be(e))return X(e.source,t);{const n=e.source,o=e.flags.replace(/y|$/,"y"),r=new RegExp(n,o);return Re(e)&&R(t)&&!Oe(t)?Ce(r,t):Se(r,t)}},"$e"),Ce=a((e,t)=>n=>{const o=n.index,r=n.input;e.lastIndex=o;const l=e.exec(r);if(l){const i=e.lastIndex;if(!n.options.silent){const h=t(...l,r,`${o}`);y(h)||n.output.push(h)}return n.index=i,!0}else return!1},"Ee"),Se=a((e,t)=>n=>{const o=n.index,r=n.input;if(e.lastIndex=o,e.test(r)){const l=e.lastIndex;if(!y(t)&&!n.options.silent){const i=R(t)?t(r.slice(o,l),r,`${o}`):t;y(i)||n.output.push(i)}return n.index=l,!0}else return!1},"Ce"),X=a((e,t)=>n=>{const o=n.index,r=n.input;if(r.startsWith(e,o)){if(!y(t)&&!n.options.silent){const l=R(t)?t(e,r,`${o}`):t;y(l)||n.output.push(l)}return n.index+=e.length,!0}else return!1},"F"),q=a((e,t,n,o)=>{const r=j(e),l=t>1;return F(L(ee(i=>{let h=0;for(;h<n;){const x=i.index;if(!r(i)||(h+=1,i.index===x))break}return h>=t},l),o))},"k"),Y=a((e,t)=>q(e,0,1,t),"L"),C=a((e,t)=>q(e,0,1/0,t),"$"),qe=a((e,t)=>q(e,1,1/0,t),"Re"),O=a((e,t)=>{const n=e.map(j);return F(L(ee(o=>{for(let r=0,l=n.length;r<l;r++)if(!n[r](o))return!1;return!0}),t))},"x"),w=a((e,t)=>{const n=e.map(j);return F(L(o=>{for(let r=0,l=n.length;r<l;r++)if(n[r](o))return!0;return!1},t))},"p"),ee=a((e,t=!0,n=!1)=>{const o=j(e);return t?r=>{const l=r.index,i=r.output.length,h=o(r);return!h&&!n&&(r.indexBacktrackMax=Math.max(r.indexBacktrackMax,r.index)),(!h||n)&&(r.index=l,r.output.length!==i&&(r.output.length=i)),h}:o},"q"),L=a((e,t)=>{const n=j(e);return t?o=>{if(o.options.silent)return n(o);const r=o.output.length;if(n(o)){const l=o.output.splice(r,1/0),i=t(l);return y(i)||o.output.push(i),!0}else return!1}:n},"B"),F=(()=>{let e=0;return t=>{const n=j(t),o=e+=1;return r=>{var l;if(r.options.memoization===!1)return n(r);const i=r.index,h=(l=r.cache)[o]||(l[o]={indexMax:-1,queue:[]}),x=h.queue;if(i<=h.indexMax){const Z=h.store||(h.store=new Map);if(x.length){for(let I=0,Gt=x.length;I<Gt;I+=2){const Ut=x[I*2],Dt=x[I*2+1];Z.set(Ut,Dt)}x.length=0}const v=Z.get(i);if(v===!1)return!1;if(Ee(v))return r.index=v,!0;if(v)return r.index=v.index,v.output?.length&&r.output.push(...v.output),!0}const W=r.output.length,Nt=n(r);if(h.indexMax=Math.max(h.indexMax,i),Nt){const Z=r.index,v=r.output.length;if(v>W){const I=r.output.slice(W,v);x.push(i,{index:Z,output:I})}else x.push(i,Z);return!0}else return x.push(i,!1),!1}}})(),te=a(e=>{let t;return n=>(t||(t=j(e())),t(n))},"G"),j=We(e=>{if(R(e))return ke(e)?te(e):e;if(Q(e)||Pe(e))return f(e);if(K(e))return O(e);if(Ie(e))return w(Object.values(e));throw new Error("Invalid rule")}),z=a(e=>e,"d"),Le=a(e=>typeof e=="string","ke"),Fe=a(e=>{const t=new WeakMap,n=new WeakMap;return(o,r)=>{const l=r?.partial?n:t,i=l.get(o);if(i!==void 0)return i;const h=e(o,r);return l.set(o,h),h}},"Be"),Ne=a(e=>{const t={},n={};return(o,r)=>{const l=r?.partial?n:t;return l[o]??(l[o]=e(o,r))}},"Pe"),Ge=f(/\\./,z),Ue=f(/./,z),De=f(/\*\*\*+/,"*"),Ve=f(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),He=f(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),Je=C(w([Ge,De,Ve,He,Ue])),Ke=Je,Qe=a(e=>T(e,Ke,{memoization:!1}).join(""),"Ie"),Te=Qe,ne="abcdefghijklmnopqrstuvwxyz",Xe=a(e=>{let t="";for(;e>0;){const n=(e-1)%26;t=ne[n]+t,e=Math.floor((e-1)/26)}return t},"Le"),re=a(e=>{let t=0;for(let n=0,o=e.length;n<o;n++)t=t*26+ne.indexOf(e[n])+1;return t},"V"),N=a((e,t)=>{if(t<e)return N(t,e);const n=[];for(;e<=t;)n.push(e++);return n},"b"),Ye=a((e,t,n)=>N(e,t).map(o=>String(o).padStart(n,"0")),"qe"),oe=a((e,t)=>N(re(e),re(t)).map(Xe),"W"),d=a(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),B=a(e=>({children:e}),"y"),E=(()=>{const e=a((t,n,o)=>{if(o.has(t))return;o.add(t);const{children:r}=t;if(!r.length)r.push(n);else for(let l=0,i=r.length;l<i;l++)e(r[l],n,o)},"e");return t=>{if(!t.length)return B([]);for(let n=t.length-1;n>=1;n--){const o=new Set,r=t[n-1],l=t[n];e(r,l,o)}return t[0]}})(),M=a(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),et=f(/\\./,d),tt=f(/[$.*+?^(){}[\]\|]/,e=>d(`\\${e}`)),nt=f(/[\\\/]/,M),rt=f(/[^$.*+?^(){}[\]\|\\\/]+/,d),ot=f(/^(?:!!)*!(.*)$/,(e,t)=>d(`(?!^${pe.compile(t).source}$).*?`)),st=f(/^(!!)+/),lt=w([ot,st]),ut=f(/\/(\*\*\/)+/,()=>B([E([M(),d(".+?"),M()]),M()])),at=f(/^(\*\*\/)+/,()=>B([d("^"),E([d(".*?"),M()])])),ct=f(/\/(\*\*)$/,()=>B([E([M(),d(".*?")]),d("$")])),it=f(/\*\*/,()=>d(".*?")),se=w([ut,at,ct,it]),ft=f(/\*\/(?!\*\*\/|\*$)/,()=>E([d("[^\\\\/]*?"),M()])),pt=f(/\*/,()=>d("[^\\\\/]*")),le=w([ft,pt]),ue=f("?",()=>d("[^\\\\/]")),ht=f("[",z),gt=f("]",z),dt=f(/[!^]/,"^\\\\/"),xt=f(/[a-z]-[a-z]|[0-9]-[0-9]/i,z),$t=f(/\\./,z),mt=f(/[$.*+?^(){}[\|]/,e=>`\\${e}`),bt=f(/[\\\/]/,"\\\\/"),wt=f(/[^$.*+?^(){}[\]\|\\\/]+/,z),vt=w([$t,mt,bt,xt,wt]),ae=O([ht,Y(dt),C(vt),gt],e=>d(e.join(""))),yt=f("{","(?:"),jt=f("}",")"),Mt=f(/(\d+)\.\.(\d+)/,(e,t,n)=>Ye(+t,+n,Math.min(t.length,n.length)).join("|")),At=f(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>oe(t,n).join("|")),zt=f(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>oe(t.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),kt=w([Mt,At,zt]),ce=O([yt,kt,jt],e=>d(e.join(""))),Ot=f("{"),Et=f("}"),It=f(","),Pt=f(/\\./,d),Rt=f(/[$.*+?^(){[\]\|]/,e=>d(`\\${e}`)),Bt=f(/[\\\/]/,M),Wt=f(/[^$.*+?^(){}[\]\|\\\/,]+/,d),Zt=te(()=>fe),_t=f("",()=>d("(?:)")),Ct=qe(w([se,le,ue,ae,ce,Zt,Pt,Rt,Bt,Wt]),E),ie=w([Ct,_t]),fe=O([Ot,Y(O([ie,C(O([It,ie]))])),Et],B),St=C(w([lt,se,le,ue,ae,ce,fe,et,tt,nt,rt]),E),qt=St,Lt=a(e=>T(e,qt,{memoization:!1})[0],"kr"),Ft=Lt,G=a((e,t,n)=>G.compile(e,n).test(t),"N");G.compile=(()=>{const e=Ne((n,o)=>Me(Ft(Te(n)),o)),t=Fe((n,o)=>ze(n.map(r=>e(r,o))));return(n,o)=>Le(n)?e(n,o):t(n,o)})();var pe=G;return m(P)})();return s.default||s},"_lazyMatch"),U;const Tt=a((s,u)=>(U||(U=ge(),ge=null),U(s,u)),"default");var Xt=Object.defineProperty,Yt=V((s,u)=>Xt(s,"name",{value:u,configurable:!0}),"t$1");const en=/^[A-Z]:\//i,k=Yt((s="")=>s&&s.replaceAll("\\","/").replace(en,u=>u.toUpperCase()),"normalizeWindowsPath");var tn=Object.defineProperty,$=V((s,u)=>tn(s,"name",{value:u,configurable:!0}),"r");const nn=/^[/\\]{2}/,rn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,xe=/^[A-Z]:$/i,de=/^\/([A-Z]:)?$/i,on=/.(\.[^./]+)$/,sn=/^[/\\]|^[a-z]:[/\\]/i,ln=/\/$/,un=$(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),$e=$((s,u)=>{let c="",p=0,g=-1,b=0,A;for(let m=0;m<=s.length;++m){if(m<s.length)A=s[m];else{if(A==="/")break;A="/"}if(A==="/"){if(!(g===m-1||b===1))if(b===2){if(c.length<2||p!==2||!c.endsWith(".")||c.at(-2)!=="."){if(c.length>2){const P=c.lastIndexOf("/");P===-1?(c="",p=0):(c=c.slice(0,P),p=c.length-1-c.lastIndexOf("/")),g=m,b=0;continue}else if(c.length>0){c="",p=0,g=m,b=0;continue}}u&&(c+=c.length>0?"/..":"..",p=2)}else c.length>0?c+=`/${s.slice(g+1,m)}`:c=s.slice(g+1,m),p=m-g-1;g=m,b=0}else A==="."&&b!==-1?++b:b=-1}return c},"normalizeString"),_=$(s=>rn.test(s),"isAbsolute"),me=$(function(s){if(s.length===0)return".";s=k(s);const u=nn.exec(s),c=_(s),p=s.at(-1)==="/";return s=$e(s,!c),s.length===0?c?"/":p?"./":".":(p&&(s+="/"),xe.test(s)&&(s+="/"),u?c?`//${s}`:`//./${s}`:c&&!_(s)?`/${s}`:s)},"normalize"),hn=$((...s)=>{let u="";for(const c of s)if(c)if(u.length>0){const p=u.at(-1)==="/",g=c[0]==="/";p&&g?u+=c.slice(1):u+=p||g?c:`/${c}`}else u+=c;return me(u)},"join"),D=$(function(...s){s=s.map(p=>k(p));let u="",c=!1;for(let p=s.length-1;p>=-1&&!c;p--){const g=p>=0?s[p]:un();!g||g.length===0||(u=`${g}/${u}`,c=_(g))}return u=$e(u,!c),c&&!_(u)?`/${u}`:u.length>0?u:"."},"resolve");$(function(s){return k(s)},"toNamespacedPath");const an=$(function(s){return on.exec(k(s))?.[1]??""},"extname");$(function(s,u){const c=D(s).replace(de,"$1").split("/"),p=D(u).replace(de,"$1").split("/");if(p[0][1]===":"&&c[0][1]===":"&&c[0]!==p[0])return p.join("/");const g=[...c];for(const b of g){if(p[0]!==b)break;c.shift(),p.shift()}return[...c.map(()=>".."),...p].join("/")},"relative");const cn=$(s=>{const u=k(s).replace(ln,"").split("/").slice(0,-1);return u.length===1&&xe.test(u[0])&&(u[0]=`${u[0]}/`),u.join("/")||(_(s)?"/":".")},"dirname");$(function(s){const u=[s.root,s.dir,s.base??s.name+s.ext].filter(Boolean);return k(s.root?D(...u):u.join("/"))},"format");const fn=$((s,u)=>{const c=k(s).split("/").pop();return u&&c.endsWith(u)?c.slice(0,-u.length):c},"basename");$(function(s){const u=sn.exec(s)?.[0]?.replaceAll("\\","/")??"",c=fn(s),p=an(c);return{base:c,dir:cn(s),ext:p,name:c.slice(0,c.length-p.length),root:u}},"parse");$((s,u)=>Tt(u,me(s)),"matchesGlob");export{k as A,D as C,an as J,cn as K,me as L,hn as M,_ as O,fn as Q};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.defineProperty;var a=(r,e)=>n(r,"name",{value:e,configurable:!0});var o=Object.defineProperty,s=a((r,e)=>o(r,"name",{value:e,configurable:!0}),"e$1");const m=s(async r=>{const e=[];for await(const t of r)e.push(Buffer.from(t));return Buffer.concat(e)},"collectStream");var c=Object.defineProperty,i=a((r,e)=>c(r,"name",{value:e,configurable:!0}),"r");const f=i(r=>{let e=0,t=r.length;for(;e<t&&r[e]==="/";)e+=1;for(;t>e&&r[t-1]==="/";)t-=1;return e===0&&t===r.length?r:r.slice(e,t)},"trimSlashes");var l=Object.defineProperty,u=a((r,e)=>l(r,"name",{value:e,configurable:!0}),"i");const b=u(r=>{const e=f(r),t=e.lastIndexOf("/");return t<=0?r.startsWith("/")&&t===0?"/":"":r.startsWith("/")?`/${e.slice(0,t)}`:e.slice(0,t)},"posixDirname");export{f as i,m as n,b as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=Object.defineProperty;var l=(e,r)=>u(e,"name",{value:r,configurable:!0});import g from"mime";import{H as s}from"./headers-DC2MEOrK.js";var f=Object.defineProperty,o=l((e,r)=>f(e,"name",{value:r,configurable:!0}),"i");const a="Content-Type",b=o((e,r={},t=200)=>({...e,headers:r,statusCode:t}),"buildResponseFile"),T=o((e,r,t={})=>({Location:r,...e.expiredAt===void 0?{}:{"X-Upload-Expires":e.expiredAt.toString()},...e.ETag===void 0?{}:{ETag:e.ETag},...t}),"buildFileHeaders"),v=o((e,r)=>{const t=e.metadata||{},n={"x-chunked-upload":"true","x-upload-complete":r?"true":"false","x-upload-offset":String(e.bytesWritten||0)};return Array.isArray(t._chunks)&&t._chunks.length>0&&(n["x-received-chunks"]=JSON.stringify(t._chunks)),n},"buildChunkedUploadHeaders");o((e,r,t,n,i)=>{const c=new URL(e||"/","http://localhost"),{pathname:p}=c,d=`${p}/${r}.${g.getExtension(t)}`;return n?d:`${i||""}${d}`},"buildLocationHeader");const x=o(e=>({"Content-Length":String(e.size||0),"Content-Type":e.contentType,...e.expiredAt===void 0?{}:{"X-Upload-Expires":e.expiredAt.toString()},...e.modifiedAt===void 0?{}:{"Last-Modified":e.modifiedAt.toString()},...e.ETag===void 0?{}:{ETag:e.ETag}}),"buildFileMetadataHeaders"),E=o(e=>{const r={};for(const[t,n]of Object.entries(e))r[t]=Array.isArray(n)?n.join(", "):String(n);return r},"convertHeadersToString");o(e=>({error:{code:e.code||e.name||"Error",message:e.message||"Unknown error",name:e.name||"Error"}}),"buildErrorResponseBody");o((e,r={})=>{const t={...r};let n;if(typeof e=="string"){if(n=e,t[a]===void 0)t[a]=s.createContentType({mediaType:"text/plain"});else{const i=Array.isArray(t[a])?t[a].join(", "):String(t[a]);t[a]=s.ensureCharset(i)}t["Content-Length"]===void 0&&(t["Content-Length"]=Buffer.byteLength(e))}else e instanceof Buffer?n=e:(n=JSON.stringify(e||{}),t[a]||(t[a]=s.createContentType({charset:"utf8",mediaType:"application/json"})));return{data:n,headers:t}},"prepareResponseBody");o(e=>{const r={...e};return"content"in r&&delete r.content,"stream"in r&&delete r.stream,r},"cleanFileData");export{T as a,b,v as c,x as d,E as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var E=Object.defineProperty;var y=(a,t)=>E(a,"name",{value:t,configurable:!0});import{n as u}from"./headers-DC2MEOrK.js";import{hasBody as X}from"type-is";import{a as c}from"./base-handler-core-BYDQditz.js";import{ERRORS as A}from"./ERRORS-CyOuSMLY.js";import{b,a as z,c as v,d as L}from"./response-builder-Wdo_fvcF.js";var T=Object.defineProperty,f=y((a,t)=>T(a,"name",{value:t,configurable:!0}),"a$1");const D=f((a,t={})=>{const e=c(a,"x-file-metadata",!0);if(!e)return t;try{return{...t,...JSON.parse(e)}}catch{return t}},"parseMetadata"),P=f(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,o;const i=e[s];return i==='"'||i==="'"?(n=s+1,o=e.indexOf(i,n),o===-1&&(o=e.indexOf(";",n),o===-1&&(o=e.length))):(o=e.indexOf(";",n),o===-1&&(o=e.length)),n>=o?void 0:e.substring(n,o).trim()||void 0},"parseContentDispositionValue"),I=f(a=>{const t=c(a,"content-disposition",!0);return P(t)},"parseContentDisposition"),R=f(a=>{const t=c(a,"x-chunked-upload",!0)==="true",e=c(a,"x-chunk-offset",!0),r=c(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},"parseChunkHeaders"),Z=f((a,t=!1)=>{const e=c(a,"x-chunked-upload",!0)==="true";if(!(t&&e)){if(!X(a))throw u(400,"Request body is required");if(Number.parseInt(c(a,"content-length")||"0",10)===0&&!e)throw u(400,"Content-Length is required and must be greater than 0")}},"validateRequestBody"),ee=f((a,t=!1,e)=>{const r=c(a,"x-chunked-upload",!0)==="true",s=Number.parseInt(c(a,"content-length")||"0",10);if(!t&&!r&&s===0)throw u(400,"Content-Length is required and must be greater than 0");if(e!==void 0&&s>e)throw u(413,`File size exceeds maximum allowed size of ${e} bytes`);return s},"validateContentLength"),te=f((a,t,e="application/octet-stream")=>{const r=I(a),s=D(a),{isChunkedUpload:n,totalSize:o}=R(a),i=n&&o?o:t;return n&&o&&(s._chunkedUpload=!0,s._chunks=[],s._totalSize=o),{contentType:e,metadata:s,originalName:r,size:i}},"extractFileInit");f((a,t,e)=>{if(Number.isNaN(a)||a<0)throw u(400,"X-Chunk-Offset must be a valid non-negative number");if(a+t>e)throw u(400,`Chunk exceeds file size. Offset: ${a}, Size: ${t}, Total: ${e}`)},"validateChunk");f((a,t="application/octet-stream")=>c(a,"content-type")||t,"getContentType");var W=Object.defineProperty,g=y((a,t)=>W(a,"name",{value:t,configurable:!0}),"a");const N=g((a,t)=>{if(a.length===0)return!1;const e=[...a].toSorted((n,o)=>n.offset-o.offset),r=e[0];if(r?.offset!==0)return!1;let s=r.length;for(let n=1;n<e.length;n+=1){const o=e[n];if(o){if(o.offset>s)return!1;s=Math.max(s,o.offset+o.length)}}return s>=t},"isUploadComplete"),H=g((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(r!==void 0&&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}`)},"validateChunk"),B=g((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]},"trackChunk"),j=g((a,t)=>{if(a.length===0||t===0)return{bytesWritten:0,percentage:0};const e=[...a].toSorted((o,i)=>o.offset-i.offset);let r=0,s=0;for(const o of e){const i=o.offset+o.length;o.offset<=s?r=Math.max(r,i):r+=o.length,s=Math.max(s,i)}r=Math.min(r,t);const n=t>0?r/t*100:0;return{bytesWritten:r,percentage:n}},"calculateUploadProgress");g(a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&Array.isArray(t._chunks)){const e=typeof t._totalSize=="number"?t._totalSize:a.size||0;return j(t._chunks,e).bytesWritten}return a.bytesWritten||0},"getBytesWritten");const _=g(a=>(a.metadata||{})._chunkedUpload===!0,"isChunkedUpload"),U=g(a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&typeof t._totalSize=="number")return t._totalSize},"getTotalSize");var q=Object.defineProperty,$=y((a,t)=>q(a,"name",{value:t,configurable:!0}),"y");class ae{static{y(this,"M")}static{$(this,"RestBase")}async deleteSingle(t){const e=await this.storage.delete({id:t});if(e.status===void 0)throw u(404,"File not found");return{...e,headers:{},statusCode:204}}async handlePost(t,e,r,s,n){if(e&&t.size!==void 0){const d=typeof t.size=="number"?t.size:Number.parseInt(String(t.size),10);if(d>0&&d>this.storage.maxUploadSize)throw u(413,`File size exceeds maximum allowed size of ${this.storage.maxUploadSize} bytes`)}const o=await this.storage.create(t);if(e){const d=this.buildFileUrl(r,o);return b(o,{...z(o,d),"X-Chunked-Upload":"true","X-Upload-ID":o.id},201)}const i=await this.storage.write({body:s,contentLength:n,id:o.id,start:0}),h=this.buildFileUrl(r,i);return b(i,z(i,h),201)}async handlePut(t,e,r,s,n,o){let i,h=!1;try{await this.storage.getMeta(t),h=!0,o&&await this.storage.update({id:t},{metadata:o}),i=await this.storage.write({body:s,contentLength:n,id:t,start:0})}catch(m){const S=m;if(S.UploadErrorCode===A.FILE_NOT_FOUND||S.code==="ENOENT")try{const w=await this.storage.create(e);i=await this.storage.write({body:s,contentLength:n,id:w.id,start:0})}catch(w){throw w}else throw m}const d=this.buildFileUrl(r,i);return b(i,z(i,d),h?200:201)}async handlePatch(t,e,r,s,n,o){let i=await this.storage.getMeta(t);const h=i.metadata||{},d=_(i);if(d){const l=U(i);l&&i.size!==l&&(i={...i,size:l})}const m=typeof h._totalSize=="number"?h._totalSize:i.size||0;if(!d)throw u(400,"File is not a chunked upload. Use POST or PUT for full file uploads.");const S=100*1024*1024;try{H(e,r,m,S)}catch(l){throw l instanceof Error&&l.message.includes("exceeds maximum")?u(413,l.message):u(400,l instanceof Error?l.message:String(l))}if(i.status==="completed"){const l=this.buildFileUrl(n,i);return b(i,{...z(i,l),"X-Upload-Complete":"true"},200)}const w=await this.storage.withLock(`chunks:${t}`,async()=>{const l=(await this.storage.getMeta(t)).metadata??{},M=Array.isArray(l._chunks)?l._chunks:[],x=B(M,{checksum:s,length:r,offset:e});return await this.storage.update({id:t},{metadata:{...l,_chunks:x}}),x});let p=await this.storage.write({body:o,contentLength:r,id:t,start:e}),C=p.bytesWritten>=m;d&&(C=N(w,m),p.status==="completed"&&!C&&(await this.storage.update({id:t},{status:"part"}),p={...p,status:"part"}));const k=C&&p.bytesWritten!==m?{...p,bytesWritten:m}:p,F=this.buildFileUrl(n,k),O={...z(k,F),...v(k,C),"x-upload-offset":String(k.bytesWritten||0)};return b(k,O,C?200:202)}async handleHead(t){let e=await this.storage.getMeta(t);const r=_(e);if(r){const n=U(e);n&&e.size!==n&&(e={...e,size:n})}const s={...L(e)};if(r){const n=e.metadata||{},o=U(e)||e.size||0,i=Array.isArray(n._chunks)?n._chunks:[],h=N(i,o);Object.assign(s,v(e,h))}return b(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 u(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{ae as M,ee as a,R as b,P as c,te as e,I as p,Z as v};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var i=(t,e)=>d(t,"name",{value:e,configurable:!0});import{createHash as p}from"node:crypto";import{createPaginationMetaSchemaObject as c,createPaginationSchemaObject as l}from"@visulima/pagination";import{sharedFileMetaSchemaObject as m,sharedErrorSchemaObject as u,sharedFileMetaExampleObject as h,sharedGetList as f,sharedGet as y,sharedGetMeta as g}from"./sharedGet-Ce7WGAsc.js";var k=Object.defineProperty,U=i((t,e)=>k(t,"name",{value:e,configurable:!0}),"o");const R=U((t,e,o)=>{const{supportedTransformerFormat:r,tags:s,transformer:n}={tags:["REST"],transformer:!1,...o},a=p("sha256").update(e).digest("base64");return{components:{examples:h,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"},...l("FileMetaPagination",{$ref:"#/components/schemas/PaginationMeta"},"#/components/schemas/PaginationMeta"),...c("PaginationMeta"),...u,...m}},paths:{[`${e.replace(/\/$/,"")}/{id}/metadata`]:{get:g(`${a}RestGetFileMeta`,s)},[`${e.replace(/\/$/,"")}/{id}`]:{delete:{description:"Delete a single file",operationId:`${a}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:s},get:y(`${a}RestGetFile`,s,n,r),head:{description:"Get file metadata and upload progress. For chunked uploads, returns progress information including current offset and completion status.",operationId:`${a}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:s},patch:{description:"Upload a chunk for chunked uploads. Requires X-Chunk-Offset header and chunk data in the request body.",operationId:`${a}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:`${t}${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:`${t}${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:s},put:{description:"Create or update a file. Requires file ID in the URL path. If file exists, it will be overwritten.",operationId:`${a}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:`${t}${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:`${t}${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:s}},[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:`${a}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:s},get:f(`${a}RestGetList`,s),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:`${a}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:`${t}${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:`${t}${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:s}}}}},"swaggerSpec");export{R as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var O=Object.defineProperty;var g=(c,t)=>O(c,"name",{value:t,configurable:!0});import{Readable as b}from"node:stream";import{z as C,B as M,$ as A,t as T}from"./storage-Dh0tJh7j.js";import{d as I}from"./detect-file-type-5JhzC9RU.js";import{throwErrorCode as y,ERRORS as f}from"./ERRORS-CyOuSMLY.js";import{createRetryWrapper as R}from"./isRetryableError-BhizNeAz.js";import{v as k}from"./local-meta-storage-Bi0mK6gD.js";import{u as z}from"./update-size-DANV7aa2.js";import{r as v,o as P}from"./part-match-B5fLLmFw.js";import{o as x}from"./has-content-Bx2p8Okx.js";var B=Object.defineProperty,L=g((c,t)=>B(c,"name",{value:t,configurable:!0}),"o$1");const N=L((c,t)=>{const a={};return Object.keys(c).forEach(e=>{a[e]=t(c[e])}),a},"mapValues");var $=Object.defineProperty,K=g((c,t)=>$(c,"name",{value:t,configurable:!0}),"t");const j=K(c=>c===Number(c)?c:(C(c)??0)/1e3,"toSeconds");var D=Object.defineProperty,w=g((c,t)=>D(c,"name",{value:t,configurable:!0}),"m");const F=5*1024*1024,W=16*1024*1024;class S extends M{static{g(this,"S3BaseStorage")}static{w(this,"S3BaseStorage")}checksumTypes=["md5","crc32","crc32c","sha1","sha256"];bucket;meta;MAX_PARTS=1e4;partSize;retry;resolvedRetryConfig;constructor(t){if(super(t),this.bucket=t.bucket,this.partSize=typeof t.partSize=="string"?A(t.partSize):t.partSize||W,this.partSize<F)throw new Error("Minimum allowed partSize value is 5MB");const a={backoffMultiplier:2,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:w(i=>{const s=i;return s.statusCode&&[408,429,500,502,503,504].includes(s.statusCode)?!0:s.retryable??!1},"shouldRetry"),...t.retryConfig};this.retry=R(a),this.resolvedRetryConfig=a;const{metaStorage:e,metaStorageConfig:r}=t;if(e)this.meta=e;else{const i={...t,...r,logger:this.logger};"directory"in i?(this.logger?.debug("Using local meta storage"),this.meta=new k(i)):this.meta=new k(i)}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(i=>{this.logger?.error("Storage access check failed: %O",i)})}getRetryConfig(){return this.resolvedRetryConfig}async create(t,a){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const n=typeof t.ttl=="string"?T(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 i=this.getS3Api();let s;try{s=await this.runOperation(a,n=>i.createMultipartUpload({ACL:this.getAcl(),Bucket:this.bucket,ContentType:r.contentType,Key:r.name,Metadata:N({originalName:r.originalName,...r.metadata},l=>encodeURI(String(l)))},{signal:n}))}catch{return y(f.FILE_ERROR,"s3 create upload error")}const{UploadId:o}=s||{};return o?(r.UploadId=o,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):y(f.FILE_ERROR,"s3 create upload error")})}async write(t,a){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&&z(e,t.size),!v(t,e))return y(f.FILE_CONFLICT);if(this.config.clientDirectUpload)return this.buildPresigned(e);e.Parts??=await this.getParts(e),e.bytesWritten=e.Parts.map(i=>i.Size||0).reduce((i,s)=>i+s,0);const r=await this.lock(t.id);try{if(x(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))return y(f.UNSUPPORTED_CHECKSUM_ALGORITHM);if(e.Parts.length===0&&(!e.contentType||e.contentType==="application/octet-stream"))try{const p=t.body instanceof b?t.body:b.fromWeb(t.body),{fileType:m,stream:u}=await I(p);m?.mime&&(e.contentType=m.mime),t.body=u}catch{}if(e.Parts.length>this.MAX_PARTS)throw new Error(`Exceeded ${this.MAX_PARTS} as part of the upload to ${this.bucket}.`);const i=e.Parts.length+1,s=this.getS3Api(),o=e.UploadId;if(!o)throw new Error("UploadId is required");const n=t.body,l=n instanceof Uint8Array,{ETag:h}=await this.runOperation(a,p=>s.uploadPart({Body:n,Bucket:this.bucket,ContentLength:t.contentLength||0,Key:e.name,PartNumber:i,UploadId:o,...t.checksumAlgorithm==="md5"?{ContentMD5:t.checksum}:{}},{signal:p}),{replayable:l}),d={ETag:h,PartNumber:i,Size:t.contentLength};e.Parts=[...e.Parts,d],e.bytesWritten+=t.contentLength||0}if(this.cache.set(e.id,e),e.status=P(e),e.status==="completed"){const[i]=await this.internalOnComplete(e);delete e.Parts,e.uri=i.Location,e.ETag=i.ETag}}finally{await this.unlock(t.id,r)}return e})}async delete({id:t},a){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);e.status="deleted",await this.abortMultipartUpload(e,a),await this.deleteMeta(e.id);const r={...e};return await this.onDelete(r),r})}async copy(t,a,e){return this.instrumentOperation("copy",async()=>{S.assertSafeId(t),S.assertSafeId(a);const r=await this.getMeta(t),i=`${this.bucket}/${t}`,s=this.bucket,o=a,n=this.getS3Api();return await this.runOperation(e,l=>n.copyObject({Bucket:s,CopySource:i,Key:o,...e?.storageClass&&{StorageClass:e.storageClass}},{signal:l})),{...r,id:o,name:o}})}async move(t,a,e){return this.instrumentOperation("move",async()=>{await this.copy(t,a,e);const r=this.getS3Api();return await this.runOperation(e,i=>r.deleteObject({Bucket:this.bucket,Key:t},{signal:i})),await this.getMeta(a)})}async list(t=1e3,a){return this.instrumentOperation("list",async()=>{const e=this.getS3Api(),r=Math.min(t,1e3);let i={Bucket:this.bucket,MaxKeys:r};const s=[];let o=!0;for(;o&&s.length<t;)try{const n=await this.runOperation(a,l=>e.listObjectsV2(i,{signal:l}));for(const{Key:l,LastModified:h}of n?.Contents||[]){if(s.length>=t)break;l!==void 0&&s.push({id:l,...h&&{createdAt:h}})}o=n.IsTruncated||!1,o&&n.NextContinuationToken&&s.length<t&&(i={...i,ContinuationToken:n.NextContinuationToken,MaxKeys:Math.min(r,t-s.length)})}catch(n){const l=this.normalizeError(n instanceof Error?n:new Error(String(n)));throw await this.onError(l),n}return s},{limit:t})}async exists({id:t},a){return this.instrumentOperation("exists",async()=>{try{await this.getMeta(t);const e=this.getS3Api();return await this.runOperation(a,r=>e.headObject({Bucket:this.bucket,Key:t},{signal:r})),!0}catch{return!1}})}async get({id:t},a){return this.instrumentOperation("get",async()=>{const e=this.getS3Api(),{Body:r,ContentLength:i,ContentType:s,ETag:o,Expires:n,LastModified:l,Metadata:h}=await this.runOperation(a,u=>e.getObject({Bucket:this.bucket,Key:t},{signal:u}));await this.checkIfExpired({expiredAt:n});const d=[];if(r)if(r instanceof b)for await(const u of r)d.push(u instanceof Uint8Array?u:new Uint8Array(u));else{const u=r.getReader();for(;;){const{done:U,value:E}=await u.read();if(U)break;d.push(E)}}const{originalName:p,...m}=h||{};return{content:Buffer.concat(d),contentType:s,ETag:o,expiredAt:n,id:t,metadata:m,modifiedAt:l,name:t,originalName:p||t,size:Number(i)}})}async buildPresigned(t){const a=t;if(a.Parts?.length||(a.Parts=await this.getParts(t)),a.bytesWritten=a.Parts.map(e=>e.Size||0).reduce((e,r)=>e+r,0),t.status=P(a),a.partsUrls?.length||(a.partsUrls=await this.getPartsPresignedUrls(t)),t.status==="completed"){const[e]=await this.internalOnComplete(t);return delete a.Parts,a.uri=e.Location,t}return t}async getPartsPresignedUrls(t){t.partSize??=this.partSize;const a=t.UploadId;if(!a)throw new Error("UploadId is required for getting presigned URLs");const e=Math.trunc(t.size/this.partSize)+1,r=[],i=Math.trunc(j(this.config.expiration?.maxAge||"6hrs")),s=this.getS3Api();for(let o=0;o<e;o++)r.push(s.getPresignedUrl({Bucket:this.bucket,expiresIn:i,Key:t.name,PartNumber:o+1,UploadId:a}));return Promise.all(r)}async getParts(t){const a=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const{Parts:r=[]}=await this.runOperation(void 0,i=>a.listParts({Bucket:this.bucket,Key:t.name,UploadId:e},{signal:i}));return r}completeMultipartUpload(t){const a=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const r=t.Parts?.map(({ETag:i,PartNumber:s})=>{if(!i||!s)throw new Error("ETag and PartNumber are required");return{ETag:i,PartNumber:s}})||[];return this.runOperation(void 0,i=>a.completeMultipartUpload({Bucket:this.bucket,Key:t.name,Parts:r,UploadId:e},{signal:i}))}async abortMultipartUpload(t,a){if(t.status!=="completed")try{const e=this.getS3Api(),r=t.UploadId;if(!r)return;await this.runOperation(a,i=>e.abortMultipartUpload({Bucket:this.bucket,Key:t.name,UploadId:r},{signal:i}))}catch(e){this.logger?.error("abortMultipartUploadError: ",e);const r=this.normalizeError(e instanceof Error?e:new Error(String(e)));await this.onError(r)}}internalOnComplete=w(async t=>{const[a]=await Promise.all([this.completeMultipartUpload(t),this.deleteMeta(t.id)]);return[a,t]},"internalOnComplete")}export{S};
|