@visulima/storage 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/LICENSE.md +130 -1
- package/dist/adapter/nuxt/module.d.ts +5 -5
- package/dist/adapter/nuxt/module.js +1 -1
- package/dist/ai/ai-sdk/index.d.ts +7 -7
- package/dist/ai/ai-sdk/index.js +1 -1
- package/dist/ai/claude/index.d.ts +5 -5
- package/dist/ai/claude/index.js +1 -1
- package/dist/ai/openai/index.d.ts +13 -5
- package/dist/ai/openai/index.js +1 -1
- package/dist/ai/tanstack/index.d.ts +6 -6
- package/dist/ai/tanstack/index.js +1 -1
- package/dist/handler/http/fetch/index.d.ts +8 -8
- package/dist/handler/http/fetch/index.js +1 -1
- package/dist/handler/http/hono/index.d.ts +7 -7
- package/dist/handler/http/hono/index.js +1 -1
- package/dist/handler/http/nextjs/index.d.ts +7 -7
- package/dist/handler/http/nextjs/index.js +1 -1
- package/dist/handler/http/node/index.d.ts +7 -7
- package/dist/handler/http/node/index.js +1 -1
- package/dist/handler/http/solid-start/index.d.ts +7 -7
- package/dist/handler/http/solid-start/index.js +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +1 -1
- package/dist/openapi/index.js +1 -1
- package/dist/packem_shared/AbstractBaseStorage-CcIPoAES.js +1 -0
- package/dist/packem_shared/AwsLightFile-CqeZ6M7o.js +1 -0
- package/dist/packem_shared/AwsLightMetaStorage-Cb4xIpax.js +1 -0
- package/dist/packem_shared/AwsLightStorage-Bhg6C3fo.js +1 -0
- package/dist/packem_shared/AzureFile-DoUVXQMI.js +1 -0
- package/dist/packem_shared/AzureSMetaStorage-ByKDwgWo.js +1 -0
- package/dist/packem_shared/AzureStorage-BzYWVRnX.js +1 -0
- package/dist/packem_shared/BaseTransformer-ByIAKnn8.js +1 -0
- package/dist/packem_shared/BoxFile-CKKRYACc.js +1 -0
- package/dist/packem_shared/BoxMetaStorage-BI-G6aeO.js +1 -0
- package/dist/packem_shared/BoxStorage-Bmzt-OTx.js +1 -0
- package/dist/packem_shared/BunS3File-B2rczbY_.js +1 -0
- package/dist/packem_shared/BunS3MetaStorage-BI-G6aeO.js +1 -0
- package/dist/packem_shared/{BunS3Storage-B_roVJ29.js → BunS3Storage-uJ-u5wpg.js} +1 -1
- package/dist/packem_shared/BunnyFile-CBJdpNcB.js +1 -0
- package/dist/packem_shared/BunnyMetaStorage-BI-G6aeO.js +1 -0
- package/dist/packem_shared/BunnyStorage-9fw8VeuO.js +1 -0
- package/dist/packem_shared/CloudinaryFile-Dl8cnbJo.js +1 -0
- package/dist/packem_shared/CloudinaryMetaStorage-CYWznm7F.js +1 -0
- package/dist/packem_shared/CloudinaryStorage-CRVFUrEK.js +1 -0
- package/dist/packem_shared/DiskStorage-Wm6PC8Rc.js +1 -0
- package/dist/packem_shared/DiskStorageWithChecksum-CyhRDK5M.js +1 -0
- package/dist/packem_shared/DropboxFile-BUSubTWW.js +1 -0
- package/dist/packem_shared/DropboxMetaStorage-BYbJBJXr.js +1 -0
- package/dist/packem_shared/DropboxStorage-ZfgP7IMo.js +1 -0
- package/dist/packem_shared/{ERRORS-BIBxE2oR.js → ERRORS-olUcTqo2.js} +1 -1
- package/dist/packem_shared/File-DLAa0hBv.js +1 -0
- package/dist/packem_shared/Files-NF7wRh5C.js +1 -0
- package/dist/packem_shared/FirebaseFile-Dl8cnbJo.js +1 -0
- package/dist/packem_shared/FirebaseMetaStorage-DX1-58UY.js +1 -0
- package/dist/packem_shared/FirebaseStorage-D8NgHiZh.js +2 -0
- package/dist/packem_shared/FtpFile-H8EmE3S_.js +1 -0
- package/dist/packem_shared/FtpMetaStorage-BI-G6aeO.js +1 -0
- package/dist/packem_shared/FtpStorage-BjBdLfTV.js +1 -0
- package/dist/packem_shared/GCSFile-mFuZfcTW.js +1 -0
- package/dist/packem_shared/GCSMetaStorage-Dm8m-iJT.js +1 -0
- package/dist/packem_shared/GCStorage-BWV6QQqd.js +1 -0
- package/dist/packem_shared/GoogleDriveFile-fDYE1aaN.js +1 -0
- package/dist/packem_shared/GoogleDriveMetaStorage-CEleJNZZ.js +1 -0
- package/dist/packem_shared/{GoogleDriveStorage-Du7uBhSm.js → GoogleDriveStorage-CS9nWKP5.js} +1 -1
- package/dist/packem_shared/LocalMetaStorage-EnWCLyKq.js +1 -0
- package/dist/packem_shared/MediaTransformer-GqBUkOvz.js +1 -0
- package/dist/packem_shared/MemoryMetaStorage-DdAIGIVO.js +1 -0
- package/dist/packem_shared/{MemoryStorage-ChKyI6OY.js → MemoryStorage-CJw7SAlG.js} +1 -1
- package/dist/packem_shared/Metadata-BeQVDFer.js +1 -0
- package/dist/packem_shared/{Multipart-V64Bg5dt.js → Multipart-C3ve9Z0D.js} +1 -1
- package/dist/packem_shared/Multipart-PlMON60C.js +1 -0
- package/dist/packem_shared/NetlifyBlobFile-Br5HPqlC.js +1 -0
- package/dist/packem_shared/NetlifyBlobMetaStorage-DD5mbms5.js +1 -0
- package/dist/packem_shared/NetlifyBlobStorage-DVpJgN3v.js +1 -0
- package/dist/packem_shared/NoOpMetrics-CWqe9gwp.js +1 -0
- package/dist/packem_shared/OneDriveFile-Ccv5bkno.js +1 -0
- package/dist/packem_shared/OneDriveMetaStorage-D0GzJ0FC.js +1 -0
- package/dist/packem_shared/OneDriveStorage-CTYdWnnf.js +1 -0
- package/dist/packem_shared/OpenTelemetryMetrics-opDTaCRp.js +1 -0
- package/dist/packem_shared/PocketBaseFile-Dl8cnbJo.js +1 -0
- package/dist/packem_shared/PocketBaseMetaStorage-DgKNhi2j.js +1 -0
- package/dist/packem_shared/PocketBaseStorage-CHQVk7lR.js +1 -0
- package/dist/packem_shared/Rest-DQRxx8yQ.js +1 -0
- package/dist/packem_shared/Rest-DYXzbF-Q.js +1 -0
- package/dist/packem_shared/S3File-CyL0Q6Nx.js +1 -0
- package/dist/packem_shared/S3MetaStorage-DszTVQMa.js +1 -0
- package/dist/packem_shared/S3Storage-Bdns7a3N.js +1 -0
- package/dist/packem_shared/SftpFile-H8EmE3S_.js +1 -0
- package/dist/packem_shared/SftpMetaStorage-BI-G6aeO.js +1 -0
- package/dist/packem_shared/SftpStorage-D08to8f6.js +1 -0
- package/dist/packem_shared/SharePointFile-BWfd3Rel.js +1 -0
- package/dist/packem_shared/SharePointMetaStorage-BI-G6aeO.js +1 -0
- package/dist/packem_shared/{SharePointStorage-Dtnt5-wk.js → SharePointStorage-PtgEmyCY.js} +1 -1
- package/dist/packem_shared/SupabaseFile-CI0eFAyo.js +1 -0
- package/dist/packem_shared/SupabaseMetaStorage-CRw0xTXk.js +1 -0
- package/dist/packem_shared/SupabaseStorage-DJe4YZJD.js +1 -0
- package/dist/packem_shared/TUS_RESUMABLE-Dsxqcx-u.js +1 -0
- package/dist/packem_shared/{Tus-CJBgnJrn.js → Tus-C800fRBi.js} +1 -1
- package/dist/packem_shared/Tus-Vttn79I2.js +1 -0
- package/dist/packem_shared/UploadThingFile-DP4kNmpS.js +1 -0
- package/dist/packem_shared/UploadThingMetaStorage-CYWznm7F.js +1 -0
- package/dist/packem_shared/UploadThingStorage-S3iYzJ8Z.js +1 -0
- package/dist/packem_shared/ValidationError-SzFFFHiN.js +1 -0
- package/dist/packem_shared/VercelBlobFile-Censq2sD.js +1 -0
- package/dist/packem_shared/VercelBlobMetaStorage-DgKNhi2j.js +1 -0
- package/dist/packem_shared/VercelBlobStorage-D1eytZwU.js +1 -0
- package/dist/packem_shared/_commonjsHelpers-CqkleIqs.js +1 -0
- package/dist/packem_shared/agentsCopyFile-BMTcfVHg.js +1 -0
- package/dist/packem_shared/akamai-BPAk4688.js +1 -0
- package/dist/packem_shared/alibaba-CPhhkaQs.js +1 -0
- package/dist/packem_shared/approval-DcuhtQKs.js +1 -0
- package/dist/packem_shared/aws-light-meta-storage-CgGLgB8g.js +4 -0
- package/dist/packem_shared/azure-meta-storage-DmBO5MmP.js +1 -0
- package/dist/packem_shared/backblaze-CjeWkpeg.js +1 -0
- package/dist/packem_shared/base-handler-core-BvNgdV-9.js +1 -0
- package/dist/packem_shared/base-handler-fetch-DDSPIzWT.js +1 -0
- package/dist/packem_shared/base-handler-node-C83nCFpv.js +1 -0
- package/dist/packem_shared/claudeCopyFile-CMKFZHFh.js +1 -0
- package/dist/packem_shared/cloudflare-CijqmNaq.js +1 -0
- package/dist/packem_shared/copyFile-B7PNh9O7.js +1 -0
- package/dist/packem_shared/copyFile-Q5eYZIU5.js +1 -0
- package/dist/packem_shared/createResponsesFileTools-SU-K9JG4.js +1 -0
- package/dist/packem_shared/createRetryWrapper-BM8PL0cI.js +1 -0
- package/dist/packem_shared/detect-file-type-go3r-MOD.js +1 -0
- package/dist/packem_shared/digitalOcean-BE_d_CcF.js +1 -0
- package/dist/packem_shared/disk-storage-DEOi12bM.js +1 -0
- package/dist/packem_shared/{executors-BDzMjc4y.js → executors-DgKT6b1T.js} +1 -1
- package/dist/packem_shared/{executors.d-B9dIy3NT.d.ts → executors.d-HWHR3Ids.d.ts} +1 -6
- package/dist/packem_shared/exoscale-BzXbsZ3A.js +1 -0
- package/dist/packem_shared/{filebase-CsFYJIwB.js → filebase-pfolz904.js} +1 -1
- package/dist/packem_shared/{files.d-CmSZi3M0.d.ts → files.d-DuIceNg2.d.ts} +1 -1
- package/dist/packem_shared/gcs-meta-storage-A5uvIda3.js +1 -0
- package/dist/packem_shared/{get-file-status-y3wTtDQs.js → get-file-status-B8WmWzcM.js} +1 -1
- package/dist/packem_shared/getFormatFromContentType-BAVdaQ0o.js +1 -0
- package/dist/packem_shared/has-content-96mmyLn2.js +1 -0
- package/dist/packem_shared/headers-erjZrwbT.js +26 -0
- package/dist/packem_shared/hetzner-CaLW6ANw.js +1 -0
- package/dist/packem_shared/{ibmCos-j-3TfJ5p.js → ibmCos-Dbcs7XEJ.js} +1 -1
- package/dist/packem_shared/idriveE2-BiiGl7tr.js +1 -0
- package/dist/packem_shared/index-DKzU1HON.js +5 -0
- package/dist/packem_shared/internal-Zb__DDsV.js +1 -0
- package/dist/packem_shared/is-expired-CZlgTFFz.js +1 -0
- package/dist/packem_shared/local-meta-storage-Ca6WrUmN.js +1 -0
- package/dist/packem_shared/{local-meta-storage.d-cRTXr1kb.d.ts → local-meta-storage.d-CYWYyCUo.d.ts} +1 -2
- package/dist/packem_shared/{media-transformer.d-C8tn4J2Z.d.ts → media-transformer.d-Co37isNg.d.ts} +2 -2
- package/dist/packem_shared/minio-CC_RGR-q.js +1 -0
- package/dist/packem_shared/multipart-base-0AXqLN-B.js +1 -0
- package/dist/packem_shared/oauth-refresh-Cf1z47zf.js +1 -0
- package/dist/packem_shared/{oracleCloud-DslqNpn6.js → oracleCloud-eAWm6voZ.js} +1 -1
- package/dist/packem_shared/{ovhCloud-CMHE6uLV.js → ovhCloud-D00DprwO.js} +1 -1
- package/dist/packem_shared/part-match-Cb6xL9eN.js +1 -0
- package/dist/packem_shared/path-CxEa27Rz-DSh0_A5o.js +1 -0
- package/dist/packem_shared/posix-dirname-CSjB98Q5.js +1 -0
- package/dist/packem_shared/response-builder-tJ84C7n4.js +1 -0
- package/dist/packem_shared/rest-base-CzhSrUnH.js +1 -0
- package/dist/packem_shared/{restOpenApiSpec-Csv513qf.js → restOpenApiSpec-BNBrZFuE.js} +1 -1
- package/dist/packem_shared/s3-base-storage-DuHVKzSw.js +1 -0
- package/dist/packem_shared/{s3-base-storage.d-ks99NSs-.d.ts → s3-base-storage.d-BmuspwCF.d.ts} +1 -1
- package/dist/packem_shared/scaleway-Dms2IqTd.js +1 -0
- package/dist/packem_shared/{sharedErrorSchemaObject-YN65aAKj.js → sharedErrorSchemaObject-GTCM7U0s.js} +1 -1
- package/dist/packem_shared/{storage-DR7qdwBN.js → storage-uypoNkqu.js} +1 -1
- package/dist/packem_shared/{storage.d-DwdJrArF.d.ts → storage.d-C9EdfTf1.d.ts} +1 -1
- package/dist/packem_shared/storj-DzEePQoh.js +1 -0
- package/dist/packem_shared/sync-ClnPrYjk.js +1 -0
- package/dist/packem_shared/tencent-7P8z8AwE.js +1 -0
- package/dist/packem_shared/tigris-DlNWhmsM.js +1 -0
- package/dist/packem_shared/{transformOpenApiSpec-CIEAgpBD.js → transformOpenApiSpec-Bcnw9LVy.js} +1 -1
- package/dist/packem_shared/{tus-base.d-BKBoJVy0.d.ts → tus-base.d-Dgnbivbj.d.ts} +3 -8
- package/dist/packem_shared/{tusOpenApiSpec-D96B03t5.js → tusOpenApiSpec-BU8nhLH2.js} +1 -1
- package/dist/packem_shared/{types.d-BEUv414z.d.ts → types.d-D1TIRqKW.d.ts} +1 -1
- package/dist/packem_shared/{types.d-D7Zlz5RE.d.ts → types.d-D6Jkz0Sp.d.ts} +2 -2
- package/dist/packem_shared/{types.d-B1_xZIhu.d.ts → types.d-ZrDWKyVi.d.ts} +1 -2
- package/dist/packem_shared/update-size-Dxc1hvbI.js +1 -0
- package/dist/packem_shared/vultr-Crvmg314.js +1 -0
- package/dist/packem_shared/waitForStorage-afkqWeuz.js +1 -0
- package/dist/packem_shared/wasabi-CyCMxoUT.js +1 -0
- package/dist/packem_shared/{xhrOpenApiSpec-DQR4h6M8.js → xhrOpenApiSpec-xDSkxm2d.js} +1 -1
- package/dist/packem_shared/yandex-D1HwCz7g.js +1 -0
- package/dist/storage/aws/clients/index.js +1 -1
- package/dist/storage/aws/index.d.ts +3 -3
- package/dist/storage/aws/index.js +1 -1
- package/dist/storage/aws-light/index.d.ts +2 -2
- package/dist/storage/aws-light/index.js +1 -1
- package/dist/storage/azure/index.d.ts +2 -2
- package/dist/storage/azure/index.js +1 -1
- package/dist/storage/box/index.d.ts +3 -3
- package/dist/storage/box/index.js +1 -1
- package/dist/storage/bun-s3/index.d.ts +2 -2
- package/dist/storage/bun-s3/index.js +1 -1
- package/dist/storage/bunny/index.d.ts +3 -3
- package/dist/storage/bunny/index.js +1 -1
- package/dist/storage/cloudinary/index.d.ts +3 -3
- package/dist/storage/cloudinary/index.js +1 -1
- package/dist/storage/dropbox/index.d.ts +3 -3
- package/dist/storage/dropbox/index.js +1 -1
- package/dist/storage/firebase/index.d.ts +2 -2
- package/dist/storage/firebase/index.js +1 -1
- package/dist/storage/ftp/index.d.ts +3 -3
- package/dist/storage/ftp/index.js +1 -1
- package/dist/storage/gcs/index.d.ts +2 -2
- package/dist/storage/gcs/index.js +1 -1
- package/dist/storage/google-drive/index.d.ts +3 -3
- package/dist/storage/google-drive/index.js +1 -1
- package/dist/storage/local/index.d.ts +148 -4
- package/dist/storage/local/index.js +1 -1
- package/dist/storage/memory/index.d.ts +93 -3
- package/dist/storage/memory/index.js +1 -1
- package/dist/storage/netlify-blob/index.d.ts +3 -3
- package/dist/storage/netlify-blob/index.js +1 -1
- package/dist/storage/onedrive/index.d.ts +4 -4
- package/dist/storage/onedrive/index.js +1 -1
- package/dist/storage/pocketbase/index.d.ts +2 -2
- package/dist/storage/pocketbase/index.js +1 -1
- package/dist/storage/sftp/index.d.ts +3 -3
- package/dist/storage/sftp/index.js +1 -1
- package/dist/storage/sharepoint/index.d.ts +3 -3
- package/dist/storage/sharepoint/index.js +1 -1
- package/dist/storage/supabase/index.d.ts +3 -3
- package/dist/storage/supabase/index.js +1 -1
- package/dist/storage/uploadthing/index.d.ts +2 -2
- package/dist/storage/uploadthing/index.js +1 -1
- package/dist/storage/vercel-blob/index.d.ts +3 -3
- package/dist/storage/vercel-blob/index.js +1 -1
- package/dist/transformer/audio-transformer.d.ts +2 -2
- package/dist/transformer/audio-transformer.js +1 -1
- package/dist/transformer/image-transformer.d.ts +2 -2
- package/dist/transformer/image-transformer.js +1 -1
- package/dist/transformer/index.d.ts +3 -3
- package/dist/transformer/index.js +1 -1
- package/dist/transformer/video-transformer.d.ts +2 -2
- package/dist/transformer/video-transformer.js +1 -1
- package/package.json +19 -18
- package/dist/packem_shared/AbstractBaseStorage-CLsYmMZg.js +0 -1
- package/dist/packem_shared/AwsLightFile-CpZrubaV.js +0 -1
- package/dist/packem_shared/AwsLightMetaStorage-DPqJ9LTr.js +0 -1
- package/dist/packem_shared/AwsLightStorage-DGSPFUqr.js +0 -1
- package/dist/packem_shared/AzureFile-DFSaVe25.js +0 -1
- package/dist/packem_shared/AzureSMetaStorage-ByzM6Aix.js +0 -1
- package/dist/packem_shared/AzureStorage-DvKk_hhz.js +0 -1
- package/dist/packem_shared/BaseTransformer-Buw5lX_3.js +0 -1
- package/dist/packem_shared/BoxFile-CseIoPW1.js +0 -1
- package/dist/packem_shared/BoxMetaStorage-CJsyeQ63.js +0 -1
- package/dist/packem_shared/BoxStorage-CmM95wi2.js +0 -1
- package/dist/packem_shared/BunS3File-BcYmsz1n.js +0 -1
- package/dist/packem_shared/BunS3MetaStorage-CJsyeQ63.js +0 -1
- package/dist/packem_shared/BunnyFile-BgEOlcYI.js +0 -1
- package/dist/packem_shared/BunnyMetaStorage-CJsyeQ63.js +0 -1
- package/dist/packem_shared/BunnyStorage-eZ1QDVaY.js +0 -1
- package/dist/packem_shared/CloudinaryFile-Bo5B-vM1.js +0 -1
- package/dist/packem_shared/CloudinaryMetaStorage-Bv_YCZ0Q.js +0 -1
- package/dist/packem_shared/CloudinaryStorage-CpH2f0Fv.js +0 -1
- package/dist/packem_shared/DiskStorage-DzjjqCzo.js +0 -1
- package/dist/packem_shared/DiskStorageWithChecksum-MZkDEyts.js +0 -1
- package/dist/packem_shared/DropboxFile-BFb7eOzy.js +0 -1
- package/dist/packem_shared/DropboxMetaStorage-CJsyeQ63.js +0 -1
- package/dist/packem_shared/DropboxStorage-BB9NoWK2.js +0 -1
- package/dist/packem_shared/File-W8aOo15X.js +0 -1
- package/dist/packem_shared/Files-DyMJ9FPN.js +0 -1
- package/dist/packem_shared/FirebaseFile-BLaBxa2A.js +0 -1
- package/dist/packem_shared/FirebaseMetaStorage-Bv_YCZ0Q.js +0 -1
- package/dist/packem_shared/FirebaseStorage-BgbxzYNC.js +0 -2
- package/dist/packem_shared/FtpFile-ClWDYnt2.js +0 -1
- package/dist/packem_shared/FtpMetaStorage-CJsyeQ63.js +0 -1
- package/dist/packem_shared/FtpStorage-CNqXDz7P.js +0 -1
- package/dist/packem_shared/GCSFile-Cero7qZN.js +0 -1
- package/dist/packem_shared/GCSMetaStorage-Cm_XzR0C.js +0 -1
- package/dist/packem_shared/GCStorage-DcvsI7eu.js +0 -1
- package/dist/packem_shared/GoogleDriveFile-DHpLhzg9.js +0 -1
- package/dist/packem_shared/GoogleDriveMetaStorage-B0gLF7Io.js +0 -1
- package/dist/packem_shared/LocalMetaStorage-CcGfFG39.js +0 -1
- package/dist/packem_shared/MediaTransformer-D2kUsklW.js +0 -1
- package/dist/packem_shared/MemoryMetaStorage-Ksgh9pe7.js +0 -1
- package/dist/packem_shared/Metadata-B7CcBueg.js +0 -1
- package/dist/packem_shared/Multipart-C35TR2qL.js +0 -1
- package/dist/packem_shared/NetlifyBlobFile-DoFhkzaH.js +0 -1
- package/dist/packem_shared/NetlifyBlobMetaStorage-Bv_YCZ0Q.js +0 -1
- package/dist/packem_shared/NetlifyBlobStorage-CZsr_0DF.js +0 -1
- package/dist/packem_shared/NoOpMetrics-BLo6u4NY.js +0 -1
- package/dist/packem_shared/OneDriveFile-CNNJYI43.js +0 -1
- package/dist/packem_shared/OneDriveMetaStorage-B0gLF7Io.js +0 -1
- package/dist/packem_shared/OneDriveStorage-B8qFgMq1.js +0 -1
- package/dist/packem_shared/OpenTelemetryMetrics-DJDQsNKp.js +0 -1
- package/dist/packem_shared/PocketBaseFile-DpJpxl3e.js +0 -1
- package/dist/packem_shared/PocketBaseMetaStorage-Cm3v8g1-.js +0 -1
- package/dist/packem_shared/PocketBaseStorage-D2vMN-oY.js +0 -1
- package/dist/packem_shared/Rest-BrEMYgxZ.js +0 -1
- package/dist/packem_shared/Rest-aPVP2ww1.js +0 -1
- package/dist/packem_shared/S3File-CpZrubaV.js +0 -1
- package/dist/packem_shared/S3MetaStorage-CMonflzp.js +0 -1
- package/dist/packem_shared/S3Storage-CTe_BMDl.js +0 -1
- package/dist/packem_shared/SftpFile-ClWDYnt2.js +0 -1
- package/dist/packem_shared/SftpMetaStorage-CJsyeQ63.js +0 -1
- package/dist/packem_shared/SftpStorage-BKeAzuej.js +0 -1
- package/dist/packem_shared/SharePointFile-Blz9FS4h.js +0 -1
- package/dist/packem_shared/SharePointMetaStorage-CJsyeQ63.js +0 -1
- package/dist/packem_shared/SupabaseFile-Bo5B-vM1.js +0 -1
- package/dist/packem_shared/SupabaseMetaStorage-B0gLF7Io.js +0 -1
- package/dist/packem_shared/SupabaseStorage-CmGQjqXf.js +0 -1
- package/dist/packem_shared/TUS_RESUMABLE-CyTSRvPU.js +0 -1
- package/dist/packem_shared/Tus-D9c7KDnl.js +0 -1
- package/dist/packem_shared/UploadThingFile-BTFMpcIA.js +0 -1
- package/dist/packem_shared/UploadThingMetaStorage-Bv_YCZ0Q.js +0 -1
- package/dist/packem_shared/UploadThingStorage-DZ4zNvDH.js +0 -1
- package/dist/packem_shared/ValidationError-3B06DFyE.js +0 -1
- package/dist/packem_shared/VercelBlobFile-CVQwKlZk.js +0 -1
- package/dist/packem_shared/VercelBlobMetaStorage-CJsyeQ63.js +0 -1
- package/dist/packem_shared/VercelBlobStorage-DDNEofR3.js +0 -1
- package/dist/packem_shared/_commonjsHelpers-CWAkuNXM.js +0 -1
- package/dist/packem_shared/agentsCopyFile-Dl5iffdH.js +0 -1
- package/dist/packem_shared/akamai-DthkaFul.js +0 -1
- package/dist/packem_shared/alibaba-BEi25O1g.js +0 -1
- package/dist/packem_shared/approval-fVHwBp7u.js +0 -1
- package/dist/packem_shared/aws-light-meta-storage-DGrn72VJ.js +0 -4
- package/dist/packem_shared/azure-meta-storage-ClbEsfI4.js +0 -1
- package/dist/packem_shared/backblaze-m1N5NZ9q.js +0 -1
- package/dist/packem_shared/base-handler-core-BJP9jHCE.js +0 -1
- package/dist/packem_shared/base-handler-fetch-yrYrukwL.js +0 -1
- package/dist/packem_shared/base-handler-node-C8P9rkaH.js +0 -1
- package/dist/packem_shared/claudeCopyFile-BX9O4ORk.js +0 -1
- package/dist/packem_shared/cloudflare-CdUTErlo.js +0 -1
- package/dist/packem_shared/copyFile-49FtxXcm.js +0 -1
- package/dist/packem_shared/copyFile-BUPezT_c.js +0 -1
- package/dist/packem_shared/createResponsesFileTools-6Tvt2PNr.js +0 -1
- package/dist/packem_shared/createRetryWrapper-DgmeHPNF.js +0 -1
- package/dist/packem_shared/detect-file-type-BA7UBLKA.js +0 -1
- package/dist/packem_shared/digitalOcean-B2uB6pgz.js +0 -1
- package/dist/packem_shared/disk-storage-DqnnFQAQ.js +0 -1
- package/dist/packem_shared/disk-storage-with-checksum.d-Dgwyza8a.d.ts +0 -146
- package/dist/packem_shared/exoscale-BDa1Gjth.js +0 -1
- package/dist/packem_shared/gcs-meta-storage-Bu2upyHK.js +0 -1
- package/dist/packem_shared/getFormatFromContentType-DCTTPQHm.js +0 -1
- package/dist/packem_shared/has-content-50BsqrWw.js +0 -1
- package/dist/packem_shared/headers-BAiAKekR.js +0 -26
- package/dist/packem_shared/hetzner-BGGFiRGD.js +0 -1
- package/dist/packem_shared/idriveE2-C6pQ5pQ0.js +0 -1
- package/dist/packem_shared/index-nZWCQrSe.js +0 -5
- package/dist/packem_shared/internal-D_cZIFwI.js +0 -1
- package/dist/packem_shared/is-expired-CBEk6XBi.js +0 -1
- package/dist/packem_shared/local-meta-storage-BELb1YwO.js +0 -11
- package/dist/packem_shared/memory-storage.d-BNZvDG1b.d.ts +0 -93
- package/dist/packem_shared/minio-NKquuBfS.js +0 -1
- package/dist/packem_shared/multipart-base-BOzY19lb.js +0 -1
- package/dist/packem_shared/oauth-refresh-EdGzlcOZ.js +0 -1
- package/dist/packem_shared/part-match-D-9dGX42.js +0 -1
- package/dist/packem_shared/path-C-OWflAo-_mqb5p5d.js +0 -1
- package/dist/packem_shared/posix-dirname-CfpH5wZi.js +0 -1
- package/dist/packem_shared/response-builder-CbSA8qPa.js +0 -1
- package/dist/packem_shared/rest-base-BQ_dhWyV.js +0 -1
- package/dist/packem_shared/s3-base-storage-CX94H-Za.js +0 -1
- package/dist/packem_shared/scaleway-U1In3v70.js +0 -1
- package/dist/packem_shared/storj-Cb59q9kF.js +0 -1
- package/dist/packem_shared/sync-DhR3536K.js +0 -1
- package/dist/packem_shared/tencent-Q1y2GENc.js +0 -1
- package/dist/packem_shared/tigris-BELKoyyp.js +0 -1
- package/dist/packem_shared/update-size-DuNuLyxj.js +0 -1
- package/dist/packem_shared/vultr-B491cQ4e.js +0 -1
- package/dist/packem_shared/waitForStorage-ByQmG4xF.js +0 -1
- package/dist/packem_shared/wasabi-DFrwIoab.js +0 -1
- package/dist/packem_shared/yandex-CwzHuEKP.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Readable as a}from"node:stream";import{parseMultipartRequest as n,MaxFileSizeExceededError as d,MultipartParseError as l}from"@remix-run/multipart-parser/node";import{c as i}from"./headers-erjZrwbT.js";import{g as m}from"./base-handler-core-BvNgdV-9.js";import{V as f}from"./storage-uypoNkqu.js";import{B as h}from"./base-handler-node-C83nCFpv.js";import{M as u}from"./multipart-base-0AXqLN-B.js";const c=/^multipart\/.+|application\/x-www-form-urlencoded$/i;class H extends h{static methods=["delete","download","get","options","post"];multipartBase;maxFileSize;maxHeaderSize;constructor(r){super(r),this.maxFileSize=r.maxFileSize??Math.min(this.storage.maxUploadSize,1024*1024*1024),this.maxHeaderSize=r.maxHeaderSize??64*1024;const e=this;this.multipartBase=new class extends u{get storage(){return e.storage}get maxFileSize(){return e.maxFileSize}get maxHeaderSize(){return e.maxHeaderSize}buildFileUrl(t,s){return e.buildFileUrl({url:t},s)}createStreamFromBytes(t){return t instanceof Uint8Array||Buffer.isBuffer(t)?a.from(Buffer.from(t)):typeof t=="number"?a.from(Buffer.alloc(0)):a.from(Buffer.from(String(t)))}createEmptyStream(){return a.from(new Uint8Array(0))}}}async post(r){if(!c.test(r.headers["content-type"]?.split(";")[0]??""))throw i(400,"Invalid content-type");try{const e=[];for await(const o of n(r,{maxFileSize:this.maxFileSize,maxHeaderSize:this.maxHeaderSize}))e.push(o);const t=e.find(o=>o.isFile);if(!t)throw i(400,"No file found in multipart request");const s=r.originalUrl||r.url||"";return this.multipartBase.handlePost(t,e,s)}catch(e){throw e instanceof d?i(413,"File size limit exceeded"):e instanceof l?i(400,"Invalid multipart request"):e instanceof f&&e.statusCode?i(e.statusCode,e.message||e.body||"Validation failed"):e}}async delete(r){try{const e=m(r);return this.multipartBase.handleDelete(e)}catch(e){throw this.checkForUndefinedIdOrPath(e),e.code==="ENOENT"?i(404,"File not found"):e}}compose(){this.registeredHandlers.set("POST",this.post.bind(this)),this.registeredHandlers.set("DELETE",this.delete.bind(this)),this.registeredHandlers.set("GET",this.get.bind(this)),this.registeredHandlers.set("OPTIONS",this.options.bind(this)),this.logger?.debug("Registered handler: %s",[...this.registeredHandlers.keys()].join(", "))}}export{H as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./File-DLAa0hBv.js";class a extends e{url;pathname}export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as e}from"./local-meta-storage-Ca6WrUmN.js";class r extends e{constructor(t){super(t)}}export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getStore as m}from"@netlify/blobs";import{d}from"./detect-file-type-go3r-MOD.js";import{B as p,t as h,u as y}from"./storage-uypoNkqu.js";import{L as b}from"./local-meta-storage-Ca6WrUmN.js";import c from"./NetlifyBlobFile-Br5HPqlC.js";import{g as u}from"./get-file-status-B8WmWzcM.js";import{u as w}from"./update-size-Dxc1hvbI.js";import{p as g}from"./part-match-Cb6xL9eN.js";import{h as E}from"./has-content-96mmyLn2.js";class I extends p{static name="netlify-blob";checksumTypes=["md5"];get raw(){return this.store}meta;storeName;siteID;token;store;resolvedRetryConfig;constructor(e){super(e),this.storeName=e.storeName||"default",this.siteID=e.siteID||process.env.NETLIFY_SITE_ID,this.token=e.token||process.env.NETLIFY_TOKEN,this.store=m({name:this.storeName,...this.siteID&&{siteID:this.siteID},...this.token&&{token:this.token}});const n={backoffMultiplier:2,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:r=>{if(r instanceof Error){const s=r.code;if(s==="ECONNRESET"||s==="ETIMEDOUT"||s==="ENOTFOUND"||s==="ECONNREFUSED")return!0}const o=r;if(o.status&&[408,429,500,502,503,504].includes(o.status))return!0},...e.retryConfig};this.resolvedRetryConfig=n;const{metaStorage:t,metaStorageConfig:a}=e;this.meta=t||new b(a),this.isReady=!0}getRetryConfig(){return this.resolvedRetryConfig}async create(e,n){return this.instrumentOperation("create",async()=>{const t={...e};if(e.ttl){const r=typeof e.ttl=="string"?h(e.ttl):e.ttl;t.expiredAt=r===void 0?void 0:Date.now()+r}const a=new c(t);a.name=this.namingFunction(a),await this.validate(a);try{const r=await this.getMeta(a.id);if(r.bytesWritten>=0)return r}catch{}return a.bytesWritten=0,a.status=u(a),await this.saveMeta(a),await this.onCreate(a),a})}async write(e,n){return this.instrumentOperation("write",async()=>{let t;if("contentType"in e&&"metadata"in e&&!("body"in e)&&!("start"in e)?t=e:(t=await this.getMeta(e.id),await this.checkIfExpired(t)),t.status==="completed")return t;if(e.size!==void 0&&w(t,e.size),!g(e,t))throw new Error("File part does not match");const a=await this.lock(e.id);try{if(E(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const r=[],o=e.body;for await(const s of o)r.push(Buffer.from(s));const i=Buffer.concat(r);if((t.bytesWritten===0||Number.isNaN(t.bytesWritten))&&(!t.contentType||t.contentType==="application/octet-stream"))try{const s=await d(i);s?.mime&&(t.contentType=s.mime)}catch{}await this.runOperation(n,()=>this.store.set(t.name,i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),{metadata:{...t.metadata,contentType:t.contentType}})),t.pathname=t.name,t.url=this.getBlobUrl(t.name),t.bytesWritten=i.length}return t.status=u(t),t.status==="completed"&&await this.internalOnComplete(t),await this.saveMeta(t),t}finally{await this.unlock(e.id,a)}})}async delete({id:e},n){return this.instrumentOperation("delete",async()=>{const t=await this.getMeta(e);if(!t.pathname)throw new Error(`File ${e} does not have a valid pathname`);t.status="deleted";try{await this.runOperation(n,()=>this.store.delete(t.pathname))}catch(r){this.logger?.error("Failed to delete blob from Netlify Blob:",r);const o=this.normalizeError(r instanceof Error?r:new Error(String(r)));await this.onError(o)}await this.deleteMeta(t.id);const a={...t};return await this.onDelete(a),a})}async exists({id:e},n){return this.instrumentOperation("exists",async()=>{try{const t=await this.getMeta(e);if(!t.pathname||t.pathname.length<=0)return!1;const a=await this.runOperation(n,()=>this.store.get(t.pathname,{type:"blob"}));return a!=null}catch{return!1}})}async get({id:e},n){return this.instrumentOperation("get",async()=>{const t=await this.checkIfExpired(await this.getMeta(e));if(!t.pathname||t.pathname.length<=0)throw new Error("File pathname not found");const a=await this.runOperation(n,()=>this.store.get(t.pathname,{type:"blob"}));if(!a)throw new Error("File not found in Netlify Blob");let r;if(typeof a=="string")r=Buffer.from(a,"utf8").buffer;else if(a&&typeof a=="object"&&"arrayBuffer"in a&&typeof a.arrayBuffer=="function")r=await this.runOperation(n,()=>a.arrayBuffer());else throw new Error("Invalid blob type returned from Netlify Blob");const o=Buffer.from(r);let i=null;try{i=await this.store.getMetadata?.(t.pathname)??null}catch{}return{content:o,contentType:i?.contentType||t.contentType,ETag:t.ETag,expiredAt:t.expiredAt,id:e,metadata:{...t.metadata,...i?.metadata},modifiedAt:t.modifiedAt,name:t.name,originalName:t.originalName,size:t.size||o.length}})}async copy(e,n,t){return this.instrumentOperation("copy",async()=>{const a=await this.getMeta(e);if(!a.pathname)throw new Error("Source file pathname not found");const r=await this.runOperation(t,()=>this.store.get(a.pathname,{type:"blob"}));if(!r)throw new Error("Source file not found in Netlify Blob");let o=null;try{const l=this.store;l.getMetadata&&a.pathname&&(o=await l.getMetadata(a.pathname))}catch{}let i;if(typeof r=="string")i=Buffer.from(r,"utf8").buffer;else if(r&&typeof r=="object"&&"arrayBuffer"in r){const l=r;i=await this.runOperation(t,()=>l.arrayBuffer())}else throw new Error("Invalid blob type returned from Netlify Blob");const s=Buffer.from(i);await this.runOperation(t,()=>this.store.set(n,s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),{metadata:o||{contentType:a.contentType,...a.metadata}}));const f={...a,id:n,name:n,pathname:n,url:this.getBlobUrl(n)};return await this.saveMeta(f),f})}async move(e,n,t){return this.instrumentOperation("move",async()=>{const a=await this.copy(e,n,t);return await this.delete({id:e},t),a})}async update({id:e},n,t){return this.instrumentOperation("update",async()=>{const a=await this.getMeta(e),r={...n};if("ttl"in r&&r.ttl!==void 0){const i=r.ttl,s=typeof i=="string"?h(i):i;s!==void 0&&(r.expiredAt=Date.now()+s),delete r.ttl}y(a,r),await this.saveMeta(a);const o={...a,status:"updated"};return await this.onUpdate(o),o})}async list(e=1e3,n){return this.instrumentOperation("list",async()=>{const t=await this.runOperation(n,()=>this.store.list()),a=[];for await(const r of t.blobs){let o=null;try{o=await this.store.getMetadata?.(r.key)??null}catch{}const i=new c({contentType:o?.contentType||"application/octet-stream",metadata:o?.metadata||{},originalName:r.key}),s=r;if(i.createdAt=s.createdAt?.toISOString(),i.id=r.key,i.modifiedAt=s.updatedAt?.toISOString(),i.name=r.key,i.pathname=r.key,i.size=s.size,i.url=this.getBlobUrl(r.key),a.push(i),a.length>=e)break}return a},{limit:e})}internalOnComplete=e=>this.deleteMeta(e.id);getBlobUrl(e){return`/api/blobs/${this.storeName}/${e}`}}export{I as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class i{increment(t,e,a){}timing(t,e,a){}gauge(t,e,a){}}export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./File-DLAa0hBv.js";class l extends e{driveItemId;eTag;webUrl}export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as t}from"./local-meta-storage-Ca6WrUmN.js";class o extends t{constructor(e){super(e)}}export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import f from"./OneDriveFile-Ccv5bkno.js";import A from"./OneDriveMetaStorage-D0GzJ0FC.js";import{ResponseType as T,Client as S,GraphError as _}from"@microsoft/microsoft-graph-client";import{wrapStorageError as p,ERRORS as m,throwErrorCode as E}from"./ERRORS-olUcTqo2.js";import{c as P}from"./oauth-refresh-Cf1z47zf.js";import{B as U}from"./storage-uypoNkqu.js";import{g}from"./get-file-status-B8WmWzcM.js";import{u as b}from"./update-size-Dxc1hvbI.js";import{p as N}from"./part-match-Cb6xL9eN.js";import{h as L}from"./has-content-96mmyLn2.js";const k="https://graph.microsoft.com/.default",M=250*1024*1024,$=16*320*1024,x=1e3,u=r=>{let e=0,n=r.length;for(;e<n&&r[e]==="/";)e+=1;for(;n>e&&r[n-1]==="/";)n-=1;return e===0&&n===r.length?r:r.slice(e,n)},w=(r,e)=>{if(u(r).split("/").filter(Boolean).some(n=>n==="."||n===".."))throw new Error(`OneDrive storage: ${e} must not contain "." or ".." path segments.`)},y=r=>r.split("/").map(e=>encodeURIComponent(e)).join("/"),F=async r=>{const e=[];for await(const n of r)e.push(Buffer.from(n));return Buffer.concat(e)},I=r=>({getAccessToken:()=>Promise.resolve(r)}),B=r=>({getAccessToken:async()=>r()}),O=r=>P({buildBody:()=>new URLSearchParams({client_id:r.clientId,client_secret:r.clientSecret,grant_type:"client_credentials",scope:k}),provider:"OneDrive",tokenUrl:`https://login.microsoftonline.com/${encodeURIComponent(r.tenantId)}/oauth2/v2.0/token`}),v=r=>P({buildBody:()=>new URLSearchParams({client_id:r.clientId,grant_type:"refresh_token",refresh_token:r.refreshToken,scope:k,...r.clientSecret&&{client_secret:r.clientSecret}}),provider:"OneDrive",tokenUrl:`https://login.microsoftonline.com/${encodeURIComponent(r.tenantId??"common")}/oauth2/v2.0/token`}),V=r=>({getAccessToken:()=>r.getAccessToken()}),C=r=>{if(r.client)return r.client;const e=r.accessToken!==void 0,n=r.clientCredentials!==void 0,t=r.oauth!==void 0;if([e,n,t].filter(Boolean).length>1)throw new Error("OneDrive storage: pass exactly one of `accessToken`, `clientCredentials`, or `oauth`.");let i;if(r.accessToken!==void 0?i=typeof r.accessToken=="function"?B(r.accessToken):I(r.accessToken):r.clientCredentials?i=O(r.clientCredentials):r.oauth&&(i=v({clientId:r.oauth.clientId,refreshToken:r.oauth.refreshToken,...r.oauth.clientSecret&&{clientSecret:r.oauth.clientSecret},...r.oauth.tenantId&&{tenantId:r.oauth.tenantId}})),!i){const s=process.env.ONEDRIVE_ACCESS_TOKEN;if(s)i=I(s);else{const o=process.env.ONEDRIVE_CLIENT_ID,c=process.env.ONEDRIVE_CLIENT_SECRET,l=process.env.ONEDRIVE_TENANT_ID,h=process.env.ONEDRIVE_REFRESH_TOKEN;h&&o?i=v({clientId:o,refreshToken:h,...c&&{clientSecret:c},...l&&{tenantId:l}}):o&&c&&l&&(i=O({clientId:o,clientSecret:c,tenantId:l}))}}if(!i)throw new Error("OneDrive storage: missing auth. Pass `client`, `accessToken`, `clientCredentials`, or `oauth`. Env fallbacks: ONEDRIVE_ACCESS_TOKEN; or ONEDRIVE_REFRESH_TOKEN + ONEDRIVE_CLIENT_ID (+ optional ONEDRIVE_CLIENT_SECRET, ONEDRIVE_TENANT_ID); or ONEDRIVE_CLIENT_ID + ONEDRIVE_CLIENT_SECRET + ONEDRIVE_TENANT_ID.");return S.initWithMiddleware({authProvider:V(i)})},z=r=>{if(r instanceof _)return r.statusCode===404||r.code==="itemNotFound";if(r&&typeof r=="object"){const e=r;return e.statusCode===404||e.status===404||e.code==="itemNotFound"}return!1};class Z extends U{static name="onedrive";checksumTypes=[];meta;basePath;client;copyTimeoutMs;publicByDefault;rootFolderPath;constructor(e){if(super(e),[e.driveId,e.siteId,e.userId].filter(t=>t!==void 0).length>1)throw new Error("OneDrive storage: pass at most one of `driveId`, `siteId`, or `userId`.");if(e.driveId)this.basePath=`/drives/${encodeURIComponent(e.driveId)}`;else if(e.siteId)this.basePath=`/sites/${encodeURIComponent(e.siteId)}/drive`;else if(e.userId)this.basePath=`/users/${encodeURIComponent(e.userId)}/drive`;else{if(e.clientCredentials)throw new Error("OneDrive storage: `clientCredentials` (app-only) auth requires `driveId`, `siteId`, or `userId`.");this.basePath="/me/drive"}w(e.rootFolderPath??"","rootFolderPath"),this.rootFolderPath=u(e.rootFolderPath??""),this.publicByDefault=e.publicByDefault??!1,this.copyTimeoutMs=e.copyTimeoutMs??6e4,this.client=C(e),this.meta=e.metaStorage??new A(e.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(e,n){return this.instrumentOperation("create",async()=>{const t=new f(e);t.name=this.namingFunction(t),await this.validate(t);try{const a=await this.getMeta(t.id);if(a.bytesWritten>=0)return a}catch{}return t.bytesWritten=0,t.status=g(t),await this.saveMeta(t),await this.onCreate(t),t})}async write(e,n){return this.instrumentOperation("write",async()=>{let t;if("contentType"in e&&"metadata"in e&&!("body"in e)&&!("start"in e)?t=e:(t=await this.getMeta(e.id),await this.checkIfExpired(t)),t.status==="completed")return t;if(e.size!==void 0&&b(t,e.size),!N(e,t))throw new Error("File part does not match");const a=await this.lock(e.id);try{if(L(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const i=await F(e.body),s=t.name||t.id,o=i.byteLength<=M?await this.uploadSimple(s,i,t.contentType,n):await this.uploadSession(s,i,t.contentType,n);t.bytesWritten=i.length,t.size=i.length,t.driveItemId=o.id,t.webUrl=o.webUrl,t.eTag=o.eTag,t.ETag=o.eTag}return t.status=g(t),t.status==="completed"&&await this.internalOnComplete(t),await this.saveMeta(t),t}finally{await this.unlock(e.id,a)}})}async delete({id:e},n){return this.instrumentOperation("delete",async()=>{let t;try{t=await this.getMeta(e)}catch{}const a=t?.name??e;try{await this.runOperation(n,()=>this.client.api(this.itemApiPath(a)).delete())}catch(i){if(!z(i))throw i}return t?(t.status="deleted",await this.deleteMeta(t.id),await this.onDelete(t),t):Object.assign(new f({contentType:"application/octet-stream",metadata:{},originalName:e}),{id:e,name:e,status:"deleted"})})}async get({id:e},n){return this.instrumentOperation("get",async()=>{let t,a=e;try{t=await this.checkIfExpired(await this.getMeta(e)),a=t.name??e}catch{}const i=await this.runOperation(n,()=>this.client.api(this.itemApiPath(a)).get()),s=await this.runOperation(n,()=>this.client.api(this.itemActionPath(a,"content")).responseType(T.ARRAYBUFFER).get()),o=Buffer.from(s);return{content:o,contentType:t?.contentType??i.file?.mimeType??"application/octet-stream",ETag:t?.ETag??i.eTag,expiredAt:t?.expiredAt,id:e,metadata:t?.metadata??{},modifiedAt:t?.modifiedAt??i.lastModifiedDateTime,name:t?.name??i.name,originalName:t?.originalName??i.name,size:t?.size??i.size??o.length}})}async copy(e,n,t){return this.instrumentOperation("copy",async()=>{const a=this.parentReferencePath(n),s={name:R(n),parentReference:{path:a}},o=await this.runOperation(t,()=>this.client.api(this.itemActionPath(e,"copy")).responseType(T.RAW).post(s));if(o.status!==202){const d=await o.text().catch(()=>"");throw p(new Error(d||o.statusText),{adapter:"OneDrive",operation:"copy",status:o.status})}const c=o.headers.get("Location");if(!c)throw p(new Error("response missing Location monitor URL"),{adapter:"OneDrive",code:m.STORAGE_ERROR,operation:"copy"});const l=await this.pollCopyMonitor(c,t),h=new f({contentType:"application/octet-stream",metadata:{},originalName:n});return h.id=n,h.name=n,h.driveItemId=l,h})}async move(e,n,t){return this.instrumentOperation("move",async()=>{const a=this.parentReferencePath(n),i=R(n),s=await this.runOperation(t,()=>this.client.api(this.itemApiPath(e)).patch({name:i,parentReference:{path:a}})),o=new f({contentType:"application/octet-stream",metadata:{},originalName:n});o.id=n,o.name=n,o.driveItemId=s.id,o.webUrl=s.webUrl,o.eTag=s.eTag,o.ETag=s.eTag;try{await this.deleteMeta(e)}catch{}return o})}async list(e=1e3,n){return this.instrumentOperation("list",async()=>{const t=[];let a=`${this.folderListChildrenPath()}?$top=${Math.min(e,1e3)}`;for(;a&&t.length<e;){const i=await this.runOperation(n,()=>this.client.api(a).get());for(const s of i.value){if(!s.file)continue;const o=this.itemPathToKey(s);if(!o)continue;const c=new f({contentType:s.file.mimeType??"application/octet-stream",metadata:{},originalName:s.name});if(c.id=o,c.name=o,c.driveItemId=s.id,c.webUrl=s.webUrl,c.eTag=s.eTag,c.ETag=s.eTag,c.size=s.size??0,c.modifiedAt=s.lastModifiedDateTime,t.push(c),t.length>=e)break}a=i["@odata.nextLink"]??null}return t},{limit:e})}async getReadUrl(e,n){if(n?.responseContentDisposition||n?.responseContentType)return E(m.METHOD_NOT_ALLOWED,"OneDrive: `responseContentDisposition` / `responseContentType` are not supported — Graph download URLs have no overrides.");if(this.publicByDefault){const s=(await this.client.api(this.itemActionPath(e,"createLink")).post({scope:"anonymous",type:"view"})).link?.webUrl;if(!s)throw new Error("OneDrive: createLink response missing webUrl");return s}const a=(await this.client.api(this.itemApiPath(e)).select("@microsoft.graph.downloadUrl").get())["@microsoft.graph.downloadUrl"];if(!a)throw new Error("OneDrive: item has no `@microsoft.graph.downloadUrl` — it may be a folder or have no content.");return a}async getUploadUrl(e,n){if(n?.contentLength!==void 0)return E(m.BAD_REQUEST,"OneDrive: `contentLength` is not supported for upload URLs. A Graph upload session does not enforce a server-side content-length policy, so the cap would not bind; enforce size limits at your application gateway/proxy before issuing the session URL.");const t=await this.client.api(this.itemActionPath(e,"createUploadSession")).post({item:{"@microsoft.graph.conflictBehavior":"replace",...n?.contentType&&{file:{mimeType:n.contentType}}}});if(!t.uploadUrl)throw p(new Error("createUploadSession response missing uploadUrl"),{adapter:"OneDrive",code:m.STORAGE_ERROR,operation:"getUploadUrl"});return t.uploadUrl}keyParts(e){w(e,"key");const n=u(e),t=[];return this.rootFolderPath&&t.push(this.rootFolderPath),n&&t.push(n),t}itemApiPath(e){const n=this.keyParts(e);return n.length===0?`${this.basePath}/root`:`${this.basePath}/root:/${y(n.join("/"))}`}itemActionPath(e,n){const t=this.keyParts(e);return t.length===0?`${this.basePath}/root/${n}`:`${this.basePath}/root:/${y(t.join("/"))}:/${n}`}folderListChildrenPath(){return this.itemActionPath("","children")}parentReferencePath(e){w(e,"key");const n=u(e),t=[];this.rootFolderPath&&t.push(this.rootFolderPath);const a=n.lastIndexOf("/");if(a!==-1){const i=n.slice(0,a);i&&t.push(i)}return t.length===0?"/drive/root:":`/drive/root:/${y(t.join("/"))}`}itemPathToKey(e){const n=e.parentReference?.path??"",t="/root:",a=n.indexOf(t);let i=a===-1?"":n.slice(a+t.length);i=u(decodeURIComponent(i));const s=this.rootFolderPath&&i.startsWith(this.rootFolderPath)?i.slice(this.rootFolderPath.length):i,o=u(s);return o?`${o}/${e.name}`:e.name}async uploadSimple(e,n,t,a){return await this.runOperation(a,()=>this.client.api(`${this.itemActionPath(e,"content")}?@microsoft.graph.conflictBehavior=replace`).header("Content-Type",t??"application/octet-stream").put(n))}async uploadSession(e,n,t,a){const i=await this.runOperation(a,()=>this.client.api(this.itemActionPath(e,"createUploadSession")).post({item:{"@microsoft.graph.conflictBehavior":"replace",...t&&{file:{mimeType:t}}}})),s=n.byteLength;let o=0,c;for(;o<s;){const l=Math.min(o+$,s),h=n.subarray(o,l),d=await this.runOperation(a,()=>fetch(i.uploadUrl,{body:new Uint8Array(h),headers:{"Content-Length":String(h.byteLength),"Content-Range":`bytes ${o}-${l-1}/${s}`},method:"PUT"}));if(d.status===200||d.status===201)c=await d.json();else if(d.status!==202){const D=await d.text().catch(()=>"");throw p(new Error(D||d.statusText),{adapter:"OneDrive",operation:"upload-session chunk",status:d.status})}o=l}if(!c)throw p(new Error("upload-session terminated without a final DriveItem response"),{adapter:"OneDrive",code:m.STORAGE_ERROR,operation:"write"});return c}async pollCopyMonitor(e,n){const t=Date.now()+this.copyTimeoutMs;for(;;){const a=await this.runOperation(n,()=>fetch(e));if(!a.ok)throw p(new Error(a.statusText),{adapter:"OneDrive",operation:"copy monitor",status:a.status});const i=await a.json();if(i.status==="completed")return i.resourceId;if(i.status==="failed")throw p(new Error(i.error?.message??"unknown error"),{adapter:"OneDrive",code:m.STORAGE_ERROR,operation:"copy"});if(Date.now()>=t)throw new Error(`OneDrive: copy timed out after ${this.copyTimeoutMs}ms (status: ${i.status??"unknown"})`);await new Promise(s=>{setTimeout(s,x)})}}internalOnComplete=e=>this.deleteMeta(e.id)}const R=r=>{const e=u(r),n=e.lastIndexOf("/");return n===-1?e:e.slice(n+1)},ee=r=>C(r);export{ee as buildGraphClient,Z as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{metrics as i}from"@opentelemetry/api";class h{meter;counters=new Map;histograms=new Map;gauges=new Map;constructor(t){this.meter=t||i.getMeter("@visulima/storage","1.0.0")}increment(t,r=1,e){if(!this.counters.has(t)){const o={description:`Counter for ${t}`};this.counters.set(t,this.meter.createCounter(t,o))}const s=this.counters.get(t);if(!s)throw new Error(`Counter ${t} was not created`);s.add(r,e)}timing(t,r,e){if(!this.histograms.has(t)){const o={description:`Duration histogram for ${t}`,unit:"ms"};this.histograms.set(t,this.meter.createHistogram(t,o))}const s=this.histograms.get(t);if(!s)throw new Error(`Histogram ${t} was not created`);s.record(r,e)}gauge(t,r,e){if(!this.gauges.has(t)){const o={description:`Gauge for ${t}`};this.gauges.set(t,this.meter.createUpDownCounter(t,o))}const s=this.gauges.get(t);if(!s)throw new Error(`Gauge ${t} was not created`);s.add(r,e)}}export{h as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./File-DLAa0hBv.js";class a extends e{bucket;path;publicUrl}export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as t}from"./local-meta-storage-Ca6WrUmN.js";class r extends t{constructor(e){super(e)}}export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import u from"./PocketBaseFile-Dl8cnbJo.js";import g from"./PocketBaseMetaStorage-DgKNhi2j.js";import O,{ClientResponseError as E}from"pocketbase";import{throwErrorCode as m,ERRORS as p}from"./ERRORS-olUcTqo2.js";import{B as A}from"./storage-uypoNkqu.js";import{g as k}from"./get-file-status-B8WmWzcM.js";import{u as B}from"./update-size-Dxc1hvbI.js";import{p as T}from"./part-match-Cb6xL9eN.js";import{h as N}from"./has-content-96mmyLn2.js";const S=async o=>{const t=[];for await(const a of o)t.push(Buffer.from(a));return Buffer.concat(t)},d=o=>(o instanceof E||!!o&&typeof o=="object")&&o.status===404,f=(o,t,a,e)=>{const i=o.files.getURL??o.files.getUrl;return i?i(t,a,e):m(p.METHOD_NOT_ALLOWED,"PocketBase: client has no files.getURL()")};class x extends A{static name="pocketbase";checksumTypes=[];meta;client;collectionName;defaultUrlExpiresIn;fileField;keyField;publicBaseUrl;ensureAuth;constructor(t){if(super(t),!t.collection)throw new Error("PocketBase storage: `collection` is required.");if(this.collectionName=t.collection,this.keyField=t.keyField??"key",this.fileField=t.fileField??"file",this.publicBaseUrl=t.publicBaseUrl,this.defaultUrlExpiresIn=t.defaultUrlExpiresIn??3600,t.client)this.client=t.client,this.ensureAuth=async()=>{};else{const a=t.url??process.env.POCKETBASE_URL;if(!a)throw new Error("PocketBase storage: `url` is required (or set POCKETBASE_URL).");const e=new O(a);this.client=e;const i=t.authToken??process.env.POCKETBASE_AUTH_TOKEN,s=t.adminEmail??process.env.POCKETBASE_ADMIN_EMAIL,n=t.adminPassword??process.env.POCKETBASE_ADMIN_PASSWORD;i?(e.authStore.save(i,null),this.ensureAuth=async()=>{}):s&&n?this.ensureAuth=async()=>{e.authStore.isValid||await e.collection("_superusers").authWithPassword(s,n)}:this.ensureAuth=async()=>{}}this.meta=t.metaStorage??new g(t.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(t,a){return this.instrumentOperation("create",async()=>{const e=new u(t);e.name=this.namingFunction(e),e.bucket=this.collectionName,e.path=e.name,await this.validate(e);try{const i=await this.getMeta(e.id);if(i.bytesWritten>=0)return i}catch{}return e.bytesWritten=0,e.status=k(e),await this.saveMeta(e),await this.onCreate(e),e})}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(t.size!==void 0&&B(e,t.size),!T(t,e))throw new Error("File part does not match");const i=await this.lock(t.id);try{if(N(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const s=await S(t.body),n=e.path??e.name;await this.putRecord(n,s,e.contentType,a),e.bytesWritten=s.length,e.size=s.length,e.path=n}return e.status=k(e),e.status==="completed"&&await this.internalOnComplete(e),await this.saveMeta(e),e}finally{await this.unlock(t.id,i)}})}async delete({id:t},a){return this.instrumentOperation("delete",async()=>{let e;try{e=await this.getMeta(t)}catch{}const i=e?.path??e?.name??t;await this.ensureAuth();try{const s=await this.findRecord(i,a);await this.runOperation(a,()=>this.client.collection(this.collectionName).delete(s.id))}catch(s){if(!d(s))throw s}return e?(e.status="deleted",await this.deleteMeta(e.id),await this.onDelete(e),e):Object.assign(new u({contentType:"application/octet-stream",metadata:{},originalName:t}),{bucket:this.collectionName,id:t,name:t,path:i,status:"deleted"})})}async exists({id:t},a){return this.instrumentOperation("exists",async()=>{let e=t;try{e=(await this.getMeta(t)).path??t}catch{}await this.ensureAuth();try{return await this.findRecord(e,a),!0}catch(i){if(d(i))return!1;throw i}})}async get({id:t},a){return this.instrumentOperation("get",async()=>{let e=t,i;try{i=await this.checkIfExpired(await this.getMeta(t)),e=i.path??i.name??t}catch{}await this.ensureAuth();const s=await this.findRecord(e,a),n=String(s[this.fileField]??""),r=f(this.client,s,n),h=await this.runOperation(a,()=>fetch(r));if(!h.ok)return m(p.FILE_NOT_FOUND,`PocketBase: object not found at "${e}"`);const c=Buffer.from(await h.arrayBuffer());return{content:c,contentType:i?.contentType??h.headers.get("content-type")??"application/octet-stream",ETag:i?.ETag,expiredAt:i?.expiredAt,id:t,metadata:i?.metadata??{},modifiedAt:i?.modifiedAt,name:i?.name??e,originalName:i?.originalName??e,size:i?.size??c.length}})}async copy(t,a,e){return this.instrumentOperation("copy",async()=>{const s=(await this.getMetaSafe(t))?.path??t;await this.ensureAuth();const n=await this.findRecord(s,e),r=String(n[this.fileField]??""),h=f(this.client,n,r),c=await this.runOperation(e,()=>fetch(h));if(!c.ok)return m(p.FILE_NOT_FOUND,`PocketBase: object not found at "${s}"`);const w=Buffer.from(await c.arrayBuffer()),y=c.headers.get("content-type")??"application/octet-stream";await this.putRecord(a,w,y,e);const l=new u({contentType:y,metadata:{},originalName:a});return l.id=a,l.name=a,l.path=a,l.bucket=this.collectionName,l.size=w.length,l})}async move(t,a,e){return this.instrumentOperation("move",async()=>{const i=await this.copy(t,a,e),n=(await this.getMetaSafe(t))?.path??t;await this.ensureAuth();try{const r=await this.findRecord(n,e);await this.runOperation(e,()=>this.client.collection(this.collectionName).delete(r.id))}catch(r){if(!d(r))throw r}try{await this.deleteMeta(t)}catch{}return i})}async list(t=1e3,a){return this.instrumentOperation("list",async()=>{await this.ensureAuth();const{items:e}=await this.runOperation(a,()=>this.client.collection(this.collectionName).getList(1,t));return(e??[]).map(i=>{const s=String(i[this.keyField]??i.id),n=String(i[this.fileField]??""),r=new u({contentType:"application/octet-stream",metadata:{},originalName:s});return r.id=s,r.name=s,r.path=s,r.bucket=this.collectionName,r.ETag=n||void 0,r.createdAt=typeof i.created=="string"?i.created:void 0,r.modifiedAt=typeof i.updated=="string"?i.updated:void 0,r})},{limit:t})}async getReadUrl(t,a){if(a?.responseContentDisposition!==void 0||a?.responseContentType!==void 0)return m(p.METHOD_NOT_ALLOWED,"PocketBase: `responseContentDisposition`/`responseContentType` are not supported — PocketBase file URLs have no Content-Disposition/Content-Type override.");if(this.publicBaseUrl)return`${this.publicBaseUrl.replace(/\/+$/,"")}/${t}`;await this.ensureAuth();let e=t;const i=await this.getMetaSafe(t);i?.path&&(e=i.path);const s=await this.findRecord(e),n=String(s[this.fileField]??"");a?.expiresIn??this.defaultUrlExpiresIn;const r=await this.client.files.getToken();return f(this.client,s,n,{token:r})}async findRecord(t,a){const e=this.client.filter(`${this.keyField} = {:k}`,{k:t});return this.runOperation(a,()=>this.client.collection(this.collectionName).getFirstListItem(e))}async putRecord(t,a,e,i){await this.ensureAuth();const s=new FormData;s.append(this.keyField,t),s.append(this.fileField,new Blob([new Uint8Array(a)],{type:e}),t);try{const n=await this.findRecord(t,i);await this.runOperation(i,()=>this.client.collection(this.collectionName).update(n.id,s))}catch(n){if(!d(n))throw n;await this.runOperation(i,()=>this.client.collection(this.collectionName).create(s))}}async getMetaSafe(t){try{return await this.getMeta(t)}catch{return}}internalOnComplete=t=>this.deleteMeta(t.id)}export{x as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as o}from"./headers-erjZrwbT.js";import{hasBody as g}from"type-is";import{b as d,a as l,g as c,r as y}from"./base-handler-core-BvNgdV-9.js";import{B as b}from"./base-handler-node-C83nCFpv.js";import{R as U,v as w,a as B,e as F,b as N,c as O}from"./rest-base-CzhSrUnH.js";class u extends b{static methods=["delete","download","get","head","options","patch","post","put"];restBase;constructor(t){super(t);const e=this;this.restBase=new class extends U{get storage(){return e.storage}buildFileUrl(i,n){return e.buildFileUrlForRest(i,n)}}}compose(){this.registeredHandlers.set("POST",this.post.bind(this)),this.registeredHandlers.set("PUT",this.put.bind(this)),this.registeredHandlers.set("PATCH",this.patch.bind(this)),this.registeredHandlers.set("DELETE",this.delete.bind(this)),this.registeredHandlers.set("HEAD",this.head.bind(this)),this.registeredHandlers.set("GET",this.get.bind(this)),this.registeredHandlers.set("OPTIONS",this.options.bind(this)),this.logger?.debug("Registered handler: %s",[...this.registeredHandlers.keys()].join(", "))}buildFileUrlForRest(t,e){return this.buildFileUrl({url:t},e)}async post(t){const e=d(t,"x-chunked-upload",!0)==="true";w(t,!0);const i=B(t,!0,this.storage.maxUploadSize),n=d(t,"content-type")||"application/octet-stream",s=F(t,i,n),r=t.originalUrl||t.url||"",a=l(t);return this.restBase.handlePost(s,e,r,a,i)}async put(t){let e;try{e=c(t)}catch(p){throw this.checkForUndefinedIdOrPath(p),p}if(!g(t))throw o(400,"Request body is required");const i=Number.parseInt(d(t,"content-length")||"0",10);if(i===0)throw o(400,"Content-Length is required and must be greater than 0");if(i>this.storage.maxUploadSize)throw o(413,`File size exceeds maximum allowed size of ${this.storage.maxUploadSize} bytes`);const n=d(t,"content-type")||"application/octet-stream",s=d(t,"x-file-metadata",!0);let r;if(s)try{r=JSON.parse(s)}catch{}const a=N(t),h={contentType:n,metadata:r||{},originalName:a,size:i},f=t.originalUrl||t.url||"",m=l(t);return this.restBase.handlePut(e,h,f,m,i,r)}async delete(t){const i=new URL(t.url||"","http://localhost").searchParams.get("ids");if(i){const s=i.split(",").map(r=>r.trim()).filter(Boolean);if(s.length===0)throw o(400,"No file IDs provided");return this.restBase.deleteBatch(s)}if((d(t,"content-type")||"").includes("application/json"))try{const s=await y(t,"utf8",1048576),r=JSON.parse(s);if(Array.isArray(r)){if(r.length===0)throw o(400,"No file IDs provided");return this.restBase.deleteBatch(r)}if(typeof r=="object"&&r!==null&&"ids"in r&&Array.isArray(r.ids)){const a=r.ids;if(a.length===0)throw o(400,"No file IDs provided");return this.restBase.deleteBatch(a)}}catch(s){if(s.statusCode===400)throw s}try{const s=c(t);return this.restBase.deleteSingle(s)}catch(s){throw this.checkForUndefinedIdOrPath(s),s.code==="ENOENT"||s.UploadErrorCode==="FILE_NOT_FOUND"?o(404,"File not found"):s}}async patch(t){let e;try{e=c(t)}catch(h){throw this.checkForUndefinedIdOrPath(h),h}if(!g(t))throw o(400,"Request body is required");const i=Number.parseInt(d(t,"content-length")||"0",10);if(i===0)throw o(400,"Content-Length is required and must be greater than 0");const{chunkOffset:n}=O(t);if(n===void 0)throw o(400,"X-Chunk-Offset header is required");const s=d(t,"x-chunk-checksum",!0),r=t.originalUrl||t.url||"",a=l(t);return this.restBase.handlePatch(e,n,i,s,r,a)}async head(t){try{const e=c(t);return this.restBase.handleHead(e)}catch(e){throw this.checkForUndefinedIdOrPath(e),e.UploadErrorCode==="FILE_NOT_FOUND"||e.code==="ENOENT"?o(404,"File not found"):e}}async options(){return this.restBase.handleOptions(u.methods,this.storage.maxUploadSize)}async get(t,e){return super.get(t,e)}}export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as r}from"./headers-erjZrwbT.js";import{B as b}from"./storage-uypoNkqu.js";import{ERRORS as g}from"./ERRORS-olUcTqo2.js";import{a as p}from"./base-handler-core-BvNgdV-9.js";import{B as w}from"./base-handler-fetch-DDSPIzWT.js";import{R as B,p as f}from"./rest-base-CzhSrUnH.js";class m extends w{static methods=["delete","download","get","head","options","patch","post","put"];restBase;constructor(t){super(t);const o=this;this.restBase=new class extends B{get storage(){return o.storage}buildFileUrl(s,e){return o.buildFileUrl({url:s},e)}}}compose(){this.registeredHandlers.set("POST",this.post.bind(this)),this.registeredHandlers.set("PUT",this.put.bind(this)),this.registeredHandlers.set("PATCH",this.patch.bind(this)),this.registeredHandlers.set("DELETE",this.delete.bind(this)),this.registeredHandlers.set("HEAD",this.head.bind(this)),this.registeredHandlers.set("GET",this.get.bind(this)),this.registeredHandlers.set("OPTIONS",this.options.bind(this)),this.logger?.debug("Registered handler: %s",[...this.registeredHandlers.keys()].join(", "))}async post(t){const o=t.headers.get("x-chunked-upload")==="true",s=t.headers.get("content-length"),e=s?Number.parseInt(s,10):0;if(!o){if(!s||Number.isNaN(e)||e===0)throw r(400,"Content-Length is required and must be greater than 0");if(t.body===null)throw r(400,"Request body is required")}if(e>this.storage.maxUploadSize)throw r(413,`File size exceeds maximum allowed size of ${this.storage.maxUploadSize} bytes`);const a=t.headers.get("content-type")||"application/octet-stream",n=E(t,e,a),i=t.url,h=t.body?p(t):void 0;return this.restBase.handlePost(n,o,i,h,e)}async put(t){const o=u(t.url);if(!o)throw r(400,"File ID is required in URL path");if(t.body===null)throw r(400,"Request body is required");const s=t.headers.get("content-length"),e=s?Number.parseInt(s,10):0;if(e===0)throw r(400,"Content-Length is required and must be greater than 0");if(e>this.storage.maxUploadSize)throw r(413,`File size exceeds maximum allowed size of ${this.storage.maxUploadSize} bytes`);const a=t.headers.get("content-type")||"application/octet-stream",n=t.headers.get("x-file-metadata");let i;if(n)try{i=JSON.parse(n)}catch{}const h=f(t.headers.get("content-disposition")),d={contentType:a,metadata:i||{},originalName:h,size:e},l=t.url,y=p(t);return this.restBase.handlePut(o,d,l,y,e,i)}async delete(t){const s=new URL(t.url).searchParams.get("ids");if(s){const n=s.split(",").map(i=>i.trim()).filter(Boolean);if(n.length===0)throw r(400,"No file IDs provided");return this.restBase.deleteBatch(n)}if((t.headers.get("content-type")||"").includes("application/json"))try{const i=Number.parseInt(t.headers.get("content-length")??"",10);if(Number.isFinite(i)&&i>1048576)throw r(413,"Batch delete body exceeds 1 MiB");const h=await t.text();if(Buffer.byteLength(h,"utf8")>1048576)throw r(413,"Batch delete body exceeds 1 MiB");const d=JSON.parse(h);if(Array.isArray(d)){if(d.length===0)throw r(400,"No file IDs provided");return this.restBase.deleteBatch(d)}if(typeof d=="object"&&d!==null&&"ids"in d&&Array.isArray(d.ids)){const l=d.ids;if(l.length===0)throw r(400,"No file IDs provided");return this.restBase.deleteBatch(l)}}catch(n){if(n.statusCode===400)throw n}const a=u(t.url);if(!a)throw r(404,"File not found");try{return this.restBase.deleteSingle(a)}catch(n){const i=n;throw i.UploadErrorCode===g.FILE_NOT_FOUND||i.code==="ENOENT"?r(404,"File not found"):n}}async patch(t){const o=u(t.url);if(!o)throw r(404,"File not found");if(t.body===null)throw r(400,"Request body is required");const s=t.headers.get("content-length"),e=s?Number.parseInt(s,10):0;if(e===0)throw r(400,"Content-Length is required and must be greater than 0");const a=t.headers.get("x-chunk-offset"),n=a?Number.parseInt(a,10):void 0;if(n===void 0)throw r(400,"X-Chunk-Offset header is required");const i=t.headers.get("x-chunk-checksum")||void 0,h=t.url,d=p(t);return this.restBase.handlePatch(o,n,e,i,h,d)}async head(t){const o=u(t.url);if(!o)throw r(404,"File not found");try{return this.restBase.handleHead(o)}catch(s){const e=s;throw e.UploadErrorCode===g.FILE_NOT_FOUND||e.code==="ENOENT"?r(404,"File not found"):s}}async options(t){return this.restBase.handleOptions(m.methods,this.storage.maxUploadSize)}async get(t){throw r(500,"GET requests should be handled via fetch() method")}}const E=(c,t,o)=>{const s=c.headers.get("x-total-size"),e=s?Number.parseInt(s,10):t,a=c.headers.get("x-file-metadata");let n={};if(a)try{n=JSON.parse(a)}catch{}const i=f(c.headers.get("content-disposition"));return{contentType:o,metadata:n,originalName:i,size:e}},u=c=>{let t;try{const s=new URL(c).pathname.split("/").filter(Boolean),e=s[s.length-1];if(!e)return null;t=e.replace(/\.[^.]+$/,"")||void 0}catch{return null}if(!t)return null;try{b.assertSafeId(t)}catch{throw r(400,`Invalid file id: "${t}"`)}return t};export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"./File-DLAa0hBv.js";class s extends r{Parts;UploadId;uri;partsUrls;partSize}export{s as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S3Client as c,HeadObjectCommand as o,DeleteObjectCommand as r,PutObjectCommand as d,waitUntilBucketExists as m}from"@aws-sdk/client-s3";import{fromIni as h}from"@aws-sdk/credential-providers";import f from"./MetaStorage-DPEUyWgN.js";import{parseMetadata as u,stringifyMetadata as l}from"./Metadata-BeQVDFer.js";import{i as p}from"./is-expired-CZlgTFFz.js";class C extends f{constructor(t){super(t),this.config=t;const{client:e,...a}=t,n=a.bucket||process.env.S3_BUCKET;if(e===void 0){if(!n)throw new Error("S3 bucket is not defined");const s=a.keyFile||process.env.S3_KEYFILE;s&&(a.credentials=h({configFilepath:s})),this.client=new c(a),this.accessCheck(n).catch(i=>{throw i})}else this.client=e;this.bucket=n}config;bucket;client;async get(t){const e=this.getMetaName(t),a={Bucket:this.bucket,Key:e},{Expires:n,Metadata:s}=await this.client.send(new o(a));if(n&&p({expiredAt:n}))throw await this.delete(e),new Error(`Metafile ${t} not found`);if(s?.metadata!==void 0){const i=JSON.parse(decodeURIComponent(s.metadata));return i.metadata&&typeof i.metadata=="string"&&(i.metadata=u(i.metadata)),i}throw new Error(`Metafile ${t} not found`)}async touch(t,e){return this.save(t,e)}async delete(t){const e={Bucket:this.bucket,Key:this.getMetaName(t)};await this.client.send(new r(e))}async save(t,e){const a={...e};a.metadata&&(a.metadata=l(e.metadata));const n=encodeURIComponent(JSON.stringify(a)),s={Bucket:this.bucket,ContentLength:0,Key:this.getMetaName(t),Metadata:{metadata:n}};return await this.client.send(new d(s)),e}async accessCheck(t,e=30){await m({client:this.client,maxWaitTime:e},{Bucket:t})}}export{C as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import f from"./S3File-CyL0Q6Nx.js";import k from"./S3MetaStorage-DszTVQMa.js";import{CreateMultipartUploadCommand as w,UploadPartCommand as y,CompleteMultipartUploadCommand as S,AbortMultipartUploadCommand as B,ListPartsCommand as b,GetObjectCommand as C,HeadObjectCommand as T,DeleteObjectCommand as x,CopyObjectCommand as U,ListObjectsV2Command as E,waitUntilBucketExists as K,S3Client as M,PutObjectCommand as L}from"@aws-sdk/client-s3";import{fromIni as I}from"@aws-sdk/credential-providers";import{getSignedUrl as p}from"@aws-sdk/s3-request-presigner";import{S as P,b as A}from"./s3-base-storage-DuHVKzSw.js";import{Readable as m}from"node:stream";import{ReadableStream as g}from"node:stream/web";const r=l=>l?.signal?{abortSignal:l.signal}:void 0;class O{constructor(e,t){this.client=e}client;async createMultipartUpload(e,t){const o=new w({ACL:e.ACL,Bucket:e.Bucket,ContentType:e.ContentType,Key:e.Key,Metadata:e.Metadata}),n=await this.client.send(o,r(t));if(!n.UploadId)throw new Error("Failed to create multipart upload");return{UploadId:n.UploadId}}async uploadPart(e,t){const o=e.Body instanceof g?m.fromWeb(e.Body):e.Body,n=new y({Body:o,Bucket:e.Bucket,ContentLength:e.ContentLength,ContentMD5:e.ContentMD5,Key:e.Key,PartNumber:e.PartNumber,UploadId:e.UploadId}),i=await this.client.send(n,r(t));if(!i.ETag)throw new Error("Failed to upload part");return{ETag:i.ETag}}async completeMultipartUpload(e,t){const o=new S({Bucket:e.Bucket,Key:e.Key,MultipartUpload:{Parts:e.Parts.map(({ETag:i,PartNumber:a})=>({ETag:i,PartNumber:a}))},UploadId:e.UploadId}),n=await this.client.send(o,r(t));if(!n.Location)throw new Error("Failed to complete multipart upload");return{ETag:n.ETag,Location:n.Location}}async abortMultipartUpload(e,t){const o=new B({Bucket:e.Bucket,Key:e.Key,UploadId:e.UploadId});await this.client.send(o,r(t))}async listParts(e,t){const o=new b({Bucket:e.Bucket,Key:e.Key,UploadId:e.UploadId}),n=await this.client.send(o,r(t)),i=[];if(n.Parts)for(const a of n.Parts)a.ETag&&a.PartNumber&&i.push({ETag:a.ETag,PartNumber:a.PartNumber,Size:a.Size});return{Parts:i.length>0?i:void 0}}async getObject(e,t){const o=new C({Bucket:e.Bucket,Key:e.Key,...e.Range!==void 0&&{Range:e.Range}}),n=await this.client.send(o,r(t));let i;if(n.Body){const a=n.Body;a instanceof m||typeof a=="object"&&"transform"in a&&a instanceof g?i=a:i=m.from(a)}return{Body:i,ContentLength:n.ContentLength,ContentType:n.ContentType,ETag:n.ETag,Expires:n.Expires,LastModified:n.LastModified,Metadata:n.Metadata}}async headObject(e,t){const o=new T({Bucket:e.Bucket,Key:e.Key}),n=await this.client.send(o,r(t));return{ContentLength:n.ContentLength,ContentType:n.ContentType,ETag:n.ETag,Expires:n.Expires,LastModified:n.LastModified}}async deleteObject(e,t){const o=new x({Bucket:e.Bucket,Key:e.Key});await this.client.send(o,r(t))}async copyObject(e,t){const o={Bucket:e.Bucket,CopySource:e.CopySource,Key:e.Key};e.StorageClass&&(o.StorageClass=e.StorageClass);const n=new U(o);await this.client.send(n,r(t))}async listObjectsV2(e,t){const o=new E({Bucket:e.Bucket,ContinuationToken:e.ContinuationToken,Delimiter:e.Delimiter,MaxKeys:e.MaxKeys,Prefix:e.Prefix}),n=await this.client.send(o,r(t));return{CommonPrefixes:n.CommonPrefixes?.map(i=>({Prefix:i.Prefix})),Contents:n.Contents?.map(i=>({Key:i.Key,LastModified:i.LastModified})),IsTruncated:n.IsTruncated,NextContinuationToken:n.NextContinuationToken}}async getPresignedUrl(e){const t=new y({Bucket:e.Bucket,Key:e.Key,PartNumber:e.PartNumber,UploadId:e.UploadId});return p(this.client,t,{expiresIn:e.expiresIn})}async checkBucketAccess(e){await K({client:this.client,maxWaitTime:30},{Bucket:e.Bucket})}}class $ extends P{static name="s3";s3Api;rawClient;constructor(e){const{bucket:t=process.env.S3_BUCKET,region:o=process.env.S3_REGION}=e;if(!t)throw new Error("S3 bucket is not defined");if(!o)throw new Error("S3 region is not defined");e.region=o;const n=e.keyFile||process.env.S3_KEYFILE;n&&(e.credentials=I({configFilepath:n}));const i=new M(e);super({bucket:t,clientDirectUpload:e.clientDirectUpload,expiration:e.expiration?.maxAge?{maxAge:String(e.expiration.maxAge)}:void 0,filename:e.filename,logger:e.logger,metaStorage:e.metaStorage,metaStorageConfig:e.metaStorageConfig?{...e.metaStorageConfig,...e}:{...e},partSize:e.partSize,retryConfig:{...e.retryConfig,shouldRetry:c=>{const s=c;if(s.$metadata){const d=s.$metadata.httpStatusCode;if(d&&[408,429,500,502,503,504].includes(d)||s.$fault==="server")return!0}return s.retryable===!0?!0:void 0}}}),this.s3Api=new O(i,t),this.rawClient=i;const{metaStorage:a,metaStorageConfig:u}=e;if(!a){const c={...e,...u,logger:this.logger};"directory"in c||(this.meta=new k(c))}this.config.clientDirectUpload&&(this.onCreate=async()=>{})}normalizeError(e){return e.$metadata?{code:e.Code||e.name,message:e.message,name:e.name,statusCode:e.$metadata.httpStatusCode||500}:super.normalizeError(e)}async update({id:e},t){if(this.config.clientDirectUpload){const o=await this.getMeta(e);return this.buildPresigned({...o,...t})}return super.update({id:e},t)}async getStream({id:e},t){return this.instrumentOperation("getStream",async()=>{const o=this.getS3Api(),n=A(t?.range),{Body:i,ContentLength:a,ContentType:u,ETag:c,Expires:s,LastModified:d}=await this.runOperation(t,h=>o.getObject({Bucket:this.bucket,Key:e,...n!==void 0&&{Range:n}},{signal:h}));return await this.checkIfExpired({expiredAt:s}),{headers:{"Content-Length":a?.toString()??"0","Content-Type":u,...c&&{ETag:c},...s&&{"X-Upload-Expires":s.toString()},...d&&{"Last-Modified":d.toString()}},size:Number(a),stream:i}})}get raw(){return this.rawClient}async getReadUrl(e,t){const o=new C({Bucket:this.bucket,Key:e,...t?.responseContentDisposition&&{ResponseContentDisposition:t.responseContentDisposition},...t?.responseContentType&&{ResponseContentType:t.responseContentType}});return p(this.rawClient,o,{expiresIn:t?.expiresIn??3600})}async getUploadUrl(e,t){const o=new L({Bucket:this.bucket,Key:e,...t?.contentType&&{ContentType:t.contentType},...t?.contentLength!==void 0&&{ContentLength:t.contentLength}});return p(this.rawClient,o,{expiresIn:t?.expiresIn??3600})}getS3Api(){return this.s3Api}getFileClass(){return f}getAcl(){return this.config.acl}async accessCheck(e=30){await this.s3Api.checkBucketAccess({Bucket:this.bucket})}}export{$ as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./File-DLAa0hBv.js";class l extends e{path}export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as a}from"./local-meta-storage-Ca6WrUmN.js";class r extends a{constructor(t){super(t)}}export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import T from"./SftpFile-H8EmE3S_.js";import O from"./SftpMetaStorage-BI-G6aeO.js";import{e as k}from"./index-DKzU1HON.js";import F from"ssh2-sftp-client";import{throwErrorCode as d,ERRORS as p}from"./ERRORS-olUcTqo2.js";import{B as P}from"./storage-uypoNkqu.js";import{t as l,c as S,p as y}from"./posix-dirname-CSjB98Q5.js";import{g as E}from"./get-file-status-B8WmWzcM.js";import{u as b}from"./update-size-Dxc1hvbI.js";import{p as M}from"./part-match-Cb6xL9eN.js";import{h as v}from"./has-content-96mmyLn2.js";const w=c=>{const e=c?.code,a=c instanceof Error?c.message:String(c);return e===2||e==="ENOENT"||/no such file|not exist|no such path/i.test(a)},g=c=>{if(c instanceof Error&&c.name==="AbortError")return c;const e=new Error(c instanceof Error&&c.message?c.message:"The operation was aborted",{cause:c});return e.name="AbortError",e};class U extends P{static name="sftp";checksumTypes=[];supportsRange=!0;meta;connection;rootFolderPath;constructor(e){super(e),this.connection=e.connection,this.rootFolderPath=l(e.rootFolderPath??""),this.meta=e.metaStorage??new O(e.metaStorageConfig),this.isReady=!0}async create(e,a){return this.instrumentOperation("create",async()=>{const t=new T(e);t.name=this.namingFunction(t),t.path=this.keyToPath(t.name),await this.validate(t);try{const n=await this.getMeta(t.id);if(n.status==="completed")return n}catch{}return t.bytesWritten=0,t.status=E(t),await this.saveMeta(t),await this.onCreate(t),t})}async write(e,a){return this.instrumentOperation("write",async()=>{let t;if("contentType"in e&&"metadata"in e&&!("body"in e)&&!("start"in e)?t=e:(t=await this.getMeta(e.id),await this.checkIfExpired(t)),t.status==="completed")return t;if(e.size!==void 0&&b(t,e.size),!M(e,t))return d(p.FILE_CONFLICT);const n=await this.lock(e.id);try{if(v(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))return d(p.UNSUPPORTED_CHECKSUM_ALGORITHM);if(e.start>0)return d(p.METHOD_NOT_ALLOWED,"SFTP storage does not support chunked or resumable uploads; send the file in a single request.");const r=await S(e.body),i=t.path??this.keyToPath(t.name||t.id);await this.runOperation(a,s=>this.run(s,async o=>{const h=y(i);h&&await o.mkdir(h,!0),await o.put(r,i)})),t.bytesWritten=r.length,t.size=r.length,t.path=i,t.ETag=k(r)}return t.status=E(t),await this.saveMeta(t),t}finally{await this.unlock(e.id,n)}})}async get({id:e},a){return this.instrumentOperation("get",async()=>{const t=await this.checkIfExpired(await this.getMeta(e)),n=t.path??this.keyToPath(t.name||e),{range:r}=a??{},i=await this.runOperation(a,s=>this.run(s,async o=>{try{const h=r?{readStreamOptions:{start:r.start,...r.end===void 0?{}:{end:r.end}}}:void 0;return await o.get(n,void 0,h)}catch(h){if(w(h))return d(p.FILE_NOT_FOUND);throw h}}));return{content:i,contentType:t.contentType,ETag:t.ETag??k(i),expiredAt:t.expiredAt,id:e,metadata:t.metadata,modifiedAt:t.modifiedAt,name:t.name,originalName:t.originalName,size:r?i.length:t.size??i.length}})}async delete({id:e},a){return this.instrumentOperation("delete",async()=>{const t=await this.getMeta(e),n=t.path??this.keyToPath(t.name||e);await this.runOperation(a,i=>this.run(i,async s=>{try{await s.delete(n)}catch(o){if(!w(o))throw o}})),await this.deleteMeta(e);const r={...t,status:"deleted"};return await this.onDelete(r),r})}async copy(e,a,t){return this.instrumentOperation("copy",async()=>{const n=await this.getMeta(e),r=n.path??this.keyToPath(n.name||e),i=this.keyToPath(a);await this.runOperation(t,o=>this.run(o,async h=>{const u=await h.get(r),m=y(i);m&&await h.mkdir(m,!0),await h.put(u,i)}));const s={...n,id:a,name:a,path:i};return await this.saveMeta(s),s})}async move(e,a,t){return this.instrumentOperation("move",async()=>{const n=await this.getMeta(e),r=n.path??this.keyToPath(n.name||e),i=this.keyToPath(a);await this.runOperation(t,o=>this.run(o,async h=>{const u=y(i);u&&await h.mkdir(u,!0);try{await h.rename(r,i)}catch(m){try{const f=await h.get(r);await h.put(f,i),await h.delete(r)}catch(f){throw new AggregateError([m,f],`SFTP move failed: rename and copy+delete fallback both failed for "${r}" → "${i}"`)}}}));const s={...n,id:a,name:a,path:i};await this.saveMeta(s);try{await this.deleteMeta(e)}catch{}return s})}async list(e=1e3,a){return this.instrumentOperation("list",async()=>{const t=this.keyToPath("");return this.runOperation(a,n=>this.run(n,async r=>{const i=[];return await this.walkList(r,t,i),i}))})}async exists({id:e},a){return this.instrumentOperation("exists",async()=>{let t;try{t=await this.getMeta(e)}catch{return!1}const n=t.path??this.keyToPath(t.name||e);return this.runOperation(a,r=>this.run(r,async i=>{const s=await i.exists(n);return s==="-"||s==="l"}))})}async walkList(e,a,t){let n;try{n=await e.list(a||".")}catch(r){if(w(r))return;throw r}for(const r of n){const i=a?`${a}/${r.name}`:r.name;if(r.type==="d"){await this.walkList(e,i,t);continue}if(r.type!=="-")continue;const s=this.pathToKey(i);if(!s)continue;const o=new T({contentType:"application/octet-stream",metadata:{},originalName:r.name});o.id=s,o.name=s,o.path=i,o.size=r.size,o.modifiedAt=new Date(r.modifyTime).toISOString(),t.push(o)}}async run(e,a){const t=new F;if(e?.aborted)throw g(e.reason);const n=()=>{t.end()};e?.addEventListener("abort",n,{once:!0});try{if(await t.connect(this.connection),e?.aborted)throw g(e.reason);return await a(t)}catch(r){throw e?.aborted?g(r):r}finally{e?.removeEventListener("abort",n),await t.end()}}keyToPath(e){const a=l(e);a&&P.assertSafeId(a);const t=[];return this.rootFolderPath&&t.push(this.rootFolderPath),a&&t.push(a),t.length===0?"":this.rootFolderPath.startsWith("/")?`/${t.join("/")}`:t.join("/")}pathToKey(e){const a=l(e);if(!this.rootFolderPath)return a;if(a===this.rootFolderPath)return"";const t=`${this.rootFolderPath}/`;return a.startsWith(t)?a.slice(t.length):a}}export{U as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./OneDriveFile-Ccv5bkno.js";class t extends e{}export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as a}from"./local-meta-storage-Ca6WrUmN.js";class r extends a{constructor(t){super(t)}}export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{throwErrorCode as c,ERRORS as d}from"./ERRORS-
|
|
1
|
+
import{throwErrorCode as c,ERRORS as d}from"./ERRORS-olUcTqo2.js";import h,{buildGraphClient as l}from"./OneDriveStorage-CTYdWnnf.js";import{B as I}from"./storage-uypoNkqu.js";import u from"./SharePointMetaStorage-BI-G6aeO.js";const v=a=>{if(!a)return;const e=a.replace(/\/+$/,"").split("/").pop();if(e)try{return decodeURIComponent(e)}catch{return e}},p=a=>{let e;try{e=new URL(a)}catch{return c(d.BAD_REQUEST,`SharePoint storage: invalid \`siteUrl\` "${a}".`)}const t=e.pathname.replace(/\/+$/,"");return{hostname:e.host,sitePath:t===""?"/":t}};class T extends I{static name="sharepoint";checksumTypes=[];meta;client;inner;innerPromise;oneDriveAuth;resolvedConfig;constructor(e){super(e);const t=e.accessToken??process.env.SHAREPOINT_ACCESS_TOKEN??process.env.ONEDRIVE_ACCESS_TOKEN,n=e.clientCredentials??(()=>{const r=process.env.SHAREPOINT_TENANT_ID??process.env.ONEDRIVE_TENANT_ID,o=process.env.SHAREPOINT_CLIENT_ID??process.env.ONEDRIVE_CLIENT_ID,i=process.env.SHAREPOINT_CLIENT_SECRET??process.env.ONEDRIVE_CLIENT_SECRET;if(r&&o&&i)return{clientId:o,clientSecret:i,tenantId:r}})();this.oneDriveAuth={...e.client&&{client:e.client},...t!==void 0&&{accessToken:t},...n&&{clientCredentials:n},...e.oauth&&{oauth:e.oauth}},this.resolvedConfig={...e,...e.driveId??process.env.SHAREPOINT_DRIVE_ID?{driveId:e.driveId??process.env.SHAREPOINT_DRIVE_ID}:{},...e.siteId??process.env.SHAREPOINT_SITE_ID?{siteId:e.siteId??process.env.SHAREPOINT_SITE_ID}:{},...e.siteUrl??process.env.SHAREPOINT_SITE_URL?{siteUrl:e.siteUrl??process.env.SHAREPOINT_SITE_URL}:{},...e.hostname??process.env.SHAREPOINT_HOSTNAME?{hostname:e.hostname??process.env.SHAREPOINT_HOSTNAME}:{}},this.client=l(this.oneDriveAuth),this.meta=e.metaStorage??new u(e.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(e,t){return(await this.getInner()).create(e,t)}async write(e,t){return(await this.getInner()).write(e,t)}async delete(e,t){return(await this.getInner()).delete(e,t)}async get(e,t){return(await this.getInner()).get(e,t)}async copy(e,t,n){return(await this.getInner()).copy(e,t,n)}async move(e,t,n){return(await this.getInner()).move(e,t,n)}async exists(e,t){return(await this.getInner()).exists(e)}async list(e=1e3,t){return(await this.getInner()).list(e,t)}async update(e,t,n){return(await this.getInner()).update(e,t)}async getStream(e,t){return(await this.getInner()).getStream(e)}async getReadUrl(e,t){return(await this.getInner()).getReadUrl(e,t)}async getUploadUrl(e,t){return(await this.getInner()).getUploadUrl(e,t)}async getInner(){return this.inner?this.inner:(this.innerPromise??=this.buildInner(),this.inner=await this.innerPromise,this.inner)}async buildInner(){const e=await this.resolveDriveId(),{documentLibrary:t,hostname:n,siteId:r,sitePath:o,siteUrl:i,...s}=this.genericConfig;return new h({...s,...this.oneDriveAuth,driveId:e,...this.resolvedConfig.copyTimeoutMs!==void 0&&{copyTimeoutMs:this.resolvedConfig.copyTimeoutMs},...this.resolvedConfig.metaStorageConfig&&{metaStorageConfig:this.resolvedConfig.metaStorageConfig},metaStorage:this.meta,...this.resolvedConfig.publicByDefault!==void 0&&{publicByDefault:this.resolvedConfig.publicByDefault},...this.resolvedConfig.rootFolderPath!==void 0&&{rootFolderPath:this.resolvedConfig.rootFolderPath}})}async resolveDriveId(){const e=this.resolvedConfig;if(e.driveId)return e.driveId;const t=await this.resolveSiteId();if(e.documentLibrary){const r=await this.client.api(`/sites/${t}/drives`).get(),o=e.documentLibrary.toLowerCase(),i=(r.value??[]).find(s=>s.name===e.documentLibrary)??(r.value??[]).find(s=>s.name?.toLowerCase()===o||v(s.webUrl)?.toLowerCase()===o);return i?i.id:c(d.FILE_NOT_FOUND,`SharePoint storage: document library "${e.documentLibrary}" not found in site "${t}".`)}const n=await this.client.api(`/sites/${t}/drive`).get();return n?.id?n.id:c(d.FILE_NOT_FOUND,`SharePoint storage: site "${t}" has no default drive.`)}async resolveSiteId(){const e=this.resolvedConfig;if(e.siteId)return e.siteId;let t,n;if(e.siteUrl?{hostname:t,sitePath:n}=p(e.siteUrl):e.hostname&&(t=e.hostname,n=e.sitePath??"/"),!t||!n)return c(d.BAD_REQUEST,"SharePoint storage: missing site targeting. Provide `driveId`, `siteId`, `siteUrl`, or `hostname` (+ `sitePath`).");const r=n==="/"?"":n.replace(/^\/+/,""),o=r?`/sites/${t}:/${r}`:`/sites/${t}`;let i;try{i=await this.client.api(o).get()}catch(s){return c(d.FILE_NOT_FOUND,`SharePoint storage: site not found for "${e.siteUrl??`${t}${n}`}" (${s instanceof Error?s.message:String(s)}).`)}return i?.id?i.id:c(d.FILE_NOT_FOUND,`SharePoint storage: site not found for "${e.siteUrl??`${t}${n}`}".`)}}export{T as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./File-DLAa0hBv.js";class t extends e{bucket;path;publicUrl}export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as e}from"./local-meta-storage-Ca6WrUmN.js";class r extends e{constructor(a){super(a)}}export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import u from"./SupabaseFile-CI0eFAyo.js";import d from"./SupabaseMetaStorage-CRw0xTXk.js";import{StorageClient as f}from"@supabase/storage-js";import{throwErrorCode as h,ERRORS as m}from"./ERRORS-olUcTqo2.js";import{B as g}from"./storage-uypoNkqu.js";import{g as p}from"./get-file-status-B8WmWzcM.js";import{u as w}from"./update-size-Dxc1hvbI.js";import{p as y}from"./part-match-Cb6xL9eN.js";import{h as b}from"./has-content-96mmyLn2.js";const l=3600*24*7,S=c=>{if(!c||!/^attachment(\s*;|\s*$)/i.test(c.trim()))return;const e=c.match(/filename\*?=(?:UTF-8'')?(?:"([^"]+)"|([^;]+))/i),a=e?.[1]??e?.[2];if(!a)return!0;try{return decodeURIComponent(a.trim())}catch{return a.trim()}},E=async c=>{const e=[];for await(const a of c)e.push(Buffer.from(a));return Buffer.concat(e)};class x extends g{static name="supabase";checksumTypes=[];meta;bucket;defaultUrlExpiresIn;storageClient;constructor(e){if(super(e),this.bucket=e.bucket,this.defaultUrlExpiresIn=Math.min(e.defaultUrlExpiresIn??3600,l),e.client)this.storageClient=e.client;else{const a=e.url??process.env.SUPABASE_URL,t=e.serviceKey??process.env.SUPABASE_SERVICE_ROLE_KEY??process.env.SUPABASE_KEY;if(!a)throw new Error("Supabase storage: `url` is required (or set SUPABASE_URL).");if(!t)throw new Error("Supabase storage: `serviceKey` is required (or set SUPABASE_SERVICE_ROLE_KEY / SUPABASE_KEY).");const r=a.replace(/\/+$/,"")+(a.endsWith("/storage/v1")?"":"/storage/v1");this.storageClient=new f(r,{apikey:t,Authorization:`Bearer ${t}`},e.fetch)}this.meta=e.metaStorage??new d(e.metaStorageConfig),this.isReady=!0}get raw(){return this.storageClient}async create(e,a){return this.instrumentOperation("create",async()=>{const t=new u(e);t.name=this.namingFunction(t),t.bucket=this.bucket,t.path=t.name,await this.validate(t);try{const r=await this.getMeta(t.id);if(r.bytesWritten>=0)return r}catch{}return t.bytesWritten=0,t.status=p(t),await this.saveMeta(t),await this.onCreate(t),t})}async write(e,a){return this.instrumentOperation("write",async()=>{let t;if("contentType"in e&&"metadata"in e&&!("body"in e)&&!("start"in e)?t=e:(t=await this.getMeta(e.id),await this.checkIfExpired(t)),t.status==="completed")return t;if(e.size!==void 0&&w(t,e.size),!y(e,t))throw new Error("File part does not match");const r=await this.lock(e.id);try{if(b(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const i=await E(e.body),s=t.path??t.name,{data:n,error:o}=await this.runOperation(a,()=>this.storageClient.from(this.bucket).upload(s,i,{contentType:t.contentType,upsert:!0}));if(o)throw o;t.bytesWritten=i.length,t.size=i.length,t.path=n?.path??s,t.ETag=n?.id}return t.status=p(t),t.status==="completed"&&await this.internalOnComplete(t),await this.saveMeta(t),t}finally{await this.unlock(e.id,r)}})}async delete({id:e},a){return this.instrumentOperation("delete",async()=>{let t;try{t=await this.getMeta(e)}catch{}const r=t?.path??t?.name??e,{error:i}=await this.runOperation(a,()=>this.storageClient.from(this.bucket).remove([r]));if(i&&i.message&&!/not.*found/i.test(i.message))throw i;return t?(t.status="deleted",await this.deleteMeta(t.id),await this.onDelete(t),t):Object.assign(new u({contentType:"application/octet-stream",metadata:{},originalName:e}),{bucket:this.bucket,id:e,name:e,path:r,status:"deleted"})})}async exists({id:e},a){return this.instrumentOperation("exists",async()=>{let t=e;try{t=(await this.getMeta(e)).path??e}catch{}const{data:r,error:i}=await this.runOperation(a,()=>this.storageClient.from(this.bucket).exists(t));return i?!1:!!r})}async get({id:e},a){return this.instrumentOperation("get",async()=>{let t=e,r;try{r=await this.checkIfExpired(await this.getMeta(e)),t=r.path??r.name??e}catch{}const{data:i,error:s}=await this.runOperation(a,()=>this.storageClient.from(this.bucket).download(t));if(s||!i)throw s??new Error(`Supabase: object not found at "${t}"`);const n=Buffer.from(await this.runOperation(a,()=>i.arrayBuffer()));return{content:n,contentType:r?.contentType??i.type??"application/octet-stream",ETag:r?.ETag,expiredAt:r?.expiredAt,id:e,metadata:r?.metadata??{},modifiedAt:r?.modifiedAt,name:r?.name??t,originalName:r?.originalName??t,size:r?.size??n.length}})}async copy(e,a,t){return this.instrumentOperation("copy",async()=>{const i=(await this.getMetaSafe(e))?.path??e,s=a,{error:n}=await this.runOperation(t,()=>this.storageClient.from(this.bucket).copy(i,s));if(n)throw n;const o=new u({contentType:"application/octet-stream",metadata:{},originalName:a});return o.id=a,o.name=a,o.path=s,o.bucket=this.bucket,o})}async move(e,a,t){return this.instrumentOperation("move",async()=>{const i=(await this.getMetaSafe(e))?.path??e,{error:s}=await this.runOperation(t,()=>this.storageClient.from(this.bucket).move(i,a));if(s)throw s;const n=new u({contentType:"application/octet-stream",metadata:{},originalName:a});n.id=a,n.name=a,n.path=a,n.bucket=this.bucket;try{await this.deleteMeta(e)}catch{}return n})}async list(e=1e3,a){return this.instrumentOperation("list",async()=>{const{data:t,error:r}=await this.runOperation(a,()=>this.storageClient.from(this.bucket).list("",{limit:e}));if(r)throw r;return(t??[]).map(i=>{const s=new u({contentType:i.metadata?.mimetype??"application/octet-stream",metadata:i.metadata??{},originalName:i.name});return s.id=i.name,s.name=i.name,s.path=i.name,s.bucket=this.bucket,s.size=typeof i.metadata?.size=="number"?i.metadata.size:void 0,s.createdAt=i.created_at??void 0,s.modifiedAt=i.updated_at??void 0,s.ETag=i.metadata?.eTag??i.id??void 0,s})},{limit:e})}async getReadUrl(e,a){const t=Math.min(a?.expiresIn??this.defaultUrlExpiresIn,l),{data:r,error:i}=await this.storageClient.from(this.bucket).createSignedUrl(e,t,{download:S(a?.responseContentDisposition)});return i||!r?h(m.METHOD_NOT_ALLOWED,i?.message??"Supabase: createSignedUrl failed"):r.signedUrl}async getUploadUrl(e,a){if(a?.contentType!==void 0||a?.contentLength!==void 0)return h(m.BAD_REQUEST,"Supabase: `contentType`/`contentLength` are not supported for upload URLs. A Supabase signed upload URL does not bind the request Content-Type into the signature and cannot enforce a size limit; validate both at your application gateway/proxy before issuing the URL.");const{data:t,error:r}=await this.storageClient.from(this.bucket).createSignedUploadUrl(e);return r||!t?h(m.METHOD_NOT_ALLOWED,r?.message??"Supabase: createSignedUploadUrl failed"):t.signedUrl}async getMetaSafe(e){try{return await this.getMeta(e)}catch{return}}internalOnComplete=e=>this.deleteMeta(e.id)}export{x as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as s,H as N}from"./headers-erjZrwbT.js";import{Metadata as A}from"./Metadata-BeQVDFer.js";const T="1.0.0",z="1.0.0",E=(U="")=>{const t=U.split(",").map(a=>a.split(" ")),e=Object.create(A.prototype);return Object.values(t).forEach(([a,r])=>{a&&(e[a]=r?Buffer.from(r,"base64").toString():"")}),e},F=U=>!U||Object.keys(U).length===0?"":Object.entries(U).map(([t,e])=>e===void 0?t:`${t} ${Buffer.from(String(e)).toString("base64")}`).toString();class _{get storage(){throw new Error("storage must be implemented")}buildFileUrl(t,e){throw new Error("buildFileUrl must be implemented")}handleOptions(t){return{headers:{"Access-Control-Allow-Headers":"Authorization, Content-Type, Location, Tus-Extension, Tus-Max-Size, Tus-Resumable, Tus-Version, Upload-Concat, Upload-Defer-Length, Upload-Length, Upload-Metadata, Upload-Offset, X-HTTP-Method-Override, X-Requested-With","Access-Control-Allow-Methods":t.map(a=>a.toUpperCase()).join(", "),"Access-Control-Max-Age":86400,"Tus-Checksum-Algorithm":this.storage.checksumTypes.join(","),"Tus-Extension":this.storage.tusExtension.toString(),"Tus-Max-Size":this.storage.maxUploadSize,"Tus-Version":z},statusCode:204}}async handlePost(t,e,a,r,c,m,p,C){if(e!==void 0){if(!this.storage.tusExtension.includes("creation-defer-length"))throw s(501,"creation-defer-length extension is not (yet) supported.");if(t===void 0){const u={metadata:r?E(r):{}};let i=await this.storage.create(u);C==="application/offset+octet-stream"&&p>0&&(i=await this.storage.write({...i,body:m,contentLength:p,start:0}));let o={};this.storage.tusExtension.includes("expiration")&&typeof i.expiredAt=="number"&&i.size===void 0&&(o={"Upload-Expires":new Date(i.expiredAt).toUTCString()});const b=this.buildFileUrl(c,i);o={...o,...this.buildHeaders(i,{Location:b})},o.Location||(o.Location=b),i.bytesWritten>0&&(o["Upload-Offset"]=i.bytesWritten.toString()),o["Upload-Defer-Length"]="1";const g=i.bytesWritten>0?200:201;return{...i,headers:o,statusCode:g}}}if(a){if(!this.storage.tusExtension.includes("concatenation"))throw s(501,"Concatenation extension is not (yet) supported. Disable parallel upload in the tus client.");const w=r?E(r):{};if(a==="partial"){const u={metadata:{...w,uploadConcat:"partial"},size:t};let i=await this.storage.create(u);C==="application/offset+octet-stream"&&p>0&&(i=await this.storage.write({...i,body:m,contentLength:p,start:0}));let o={};this.storage.tusExtension.includes("expiration")&&typeof i.expiredAt=="number"&&i.bytesWritten!==(i.size??0)&&(o={"Upload-Expires":new Date(i.expiredAt).toUTCString()});const b=this.buildFileUrl(c,i);o={...o,...this.buildHeaders(i,{Location:b})},o.Location||(o.Location=b),i.bytesWritten>0&&(o["Upload-Offset"]=i.bytesWritten.toString()),o["Upload-Concat"]="partial";const g=i.bytesWritten>0?200:201;return{...i,headers:o,statusCode:g}}if(a.startsWith("final;")){const u=a.slice(6).trim().split(/\s+/).filter(Boolean);if(u.length===0)throw s(400,"Upload-Concat final must include at least one partial upload ID");let i=0;const o=[];for(const x of u)try{const f=await this.storage.getMeta(x);if(await this.storage.checkIfExpired(f),f.metadata?.uploadConcat!=="partial")throw s(400,`Upload ${x} is not a partial upload`);if(f.status!=="completed"||f.size===void 0)throw s(409,`Partial upload ${x} is not completed`);o.push(f),i+=f.size}catch(f){const v=f;throw v.statusCode===404||v.statusCode===410?s(409,`Partial upload ${x} not found or expired`):f}const b={metadata:{...w,partialIds:u,uploadConcat:`final;${u.join(" ")}`},size:i},g=await this.storage.create(b);await this.concatenateFiles(g,o);const O=this.buildFileUrl(c,g),W={...this.buildHeaders(g,{Location:O}),"Upload-Concat":a};return{...g,headers:W,statusCode:201}}throw s(400,"Invalid Upload-Concat header format")}if(t===void 0&&e===void 0)throw s(400,"Either upload-length or upload-defer-length must be specified.");if(t!==void 0&&Number.isNaN(Number(t)))throw s(400,"Invalid upload-length");const y={metadata:r?E(r):{},size:t};let n=await this.storage.create(y);C==="application/offset+octet-stream"&&p>0&&(n=await this.storage.write({...n,body:m,contentLength:p,start:0}));let h={};this.storage.tusExtension.includes("expiration")&&typeof n.expiredAt=="number"&&n.bytesWritten!==Number.parseInt(t,10)&&(h={"Upload-Expires":new Date(n.expiredAt).toUTCString()});const l=this.buildFileUrl(c,n);h={...h,...this.buildHeaders(n,{Location:l})},h.Location||(h.Location=l),n.bytesWritten>0&&(h["Upload-Offset"]=n.bytesWritten.toString());const d=n.bytesWritten>0?200:201;return{...n,headers:h,statusCode:d}}async handlePatch(t,e,a,r,c,m,p,C,S){const y=r?E(r):void 0;if(y)try{await this.storage.update({id:t},{id:t,metadata:y})}catch(d){throw d.UploadErrorCode==="FILE_NOT_FOUND"?s(410,"Upload expired"):d}let n;try{n=await this.storage.getMeta(t),await this.storage.checkIfExpired(n)}catch(d){const w=d;throw w.UploadErrorCode==="GONE"||w.UploadErrorCode==="FILE_NOT_FOUND"?s(410,"Upload expired"):d}const h=n.metadata?.uploadConcat;if(typeof h=="string"&&h.startsWith("final;"))throw s(403,"Cannot PATCH a final concatenation upload");let l=await this.storage.write({body:C,checksum:c,checksumAlgorithm:m,contentLength:S,id:t,start:e});if(a!==void 0){if(!this.storage.tusExtension.includes("creation-defer-length"))throw s(501,"creation-defer-length extension is not (yet) supported.");if(l.size!==void 0&&!Number.isNaN(l.size))throw s(412,"Upload-Length has already been set for this upload");const d=Number.parseInt(a,10);if(Number.isNaN(d))throw s(400,"Invalid Upload-Length value");if(d<l.bytesWritten)throw s(400,"Upload-Length is smaller than the current offset");l=await this.storage.update({id:t},{size:d}),l.bytesWritten===l.size&&(l={...l,status:"completed"})}return{...l,headers:this.buildHeaders(l,{"Upload-Offset":l.bytesWritten}),statusCode:l.status==="completed"?200:204}}async handleHead(t){const e=await this.storage.getMeta(t);await this.storage.checkIfExpired(e);const a={...typeof e.size=="number"&&!Number.isNaN(e.size)?{"Upload-Length":e.size}:{"Upload-Defer-Length":"1"},...this.buildHeaders(e,{"Cache-Control":N.createCacheControlPreset("no-store"),"Upload-Metadata":F(e.metadata),"Upload-Offset":e.bytesWritten})},r=e.metadata?.uploadConcat;return typeof r=="string"&&(a["Upload-Concat"]=r),{headers:a,statusCode:200}}async handleGet(t){const e=await this.storage.getMeta(t);return{...e,body:e,headers:this.buildHeaders(e,{"Content-Type":N.createContentType({mediaType:"application/json"})}),statusCode:200}}async handleDelete(t){if(this.disableTerminationForFinishedUploads&&(await this.storage.getMeta(t)).status==="completed")throw s(400,"Termination of finished uploads is disabled");const e=await this.storage.delete({id:t});if(e.status===void 0)throw s(404,"File not found");return{...e,headers:this.buildHeaders(e),statusCode:204}}buildHeaders(t,e={}){return e["Tus-Resumable"]=T,this.storage.tusExtension.includes("expiration")&&t.expiredAt!==void 0&&(e["Upload-Expires"]=new Date(t.expiredAt).toUTCString()),e}extractChecksum(t){if(!t)return{checksum:void 0,checksumAlgorithm:void 0};const[e,a]=t.split(/\s+/).filter(Boolean);return{checksum:a,checksumAlgorithm:e}}validateTusResumableHeader(t){if(!t)throw s(412,"Missing Tus-Resumable header");if(t!==T)throw s(412,`Unsupported TUS version: ${t}. Server supports: ${T}`)}async concatenateFiles(t,e){let a=0;for(const r of e){if(!this.storage.getStream)throw s(501,"getStream is not supported by this storage backend");const{size:c,stream:m}=await this.storage.getStream({id:r.id});if(c===void 0)throw s(500,"Partial upload size is undefined");const p=await this.storage.write({...t,body:m,contentLength:c,start:a});Object.assign(t,p),a+=c}}}const D=T,L=z;export{D as TUS_RESUMABLE,L as TUS_VERSION,_ as TusBase,E as parseMetadata,F as serializeMetadata};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{format as
|
|
1
|
+
import{format as f}from"node:url";import{c as d}from"./headers-erjZrwbT.js";import{b as o,a as u,g as h}from"./base-handler-core-BvNgdV-9.js";import{B as b}from"./base-handler-node-C83nCFpv.js";import{TusBase as U,TUS_RESUMABLE as T}from"./TUS_RESUMABLE-Dsxqcx-u.js";import{TUS_VERSION as N}from"./TUS_RESUMABLE-Dsxqcx-u.js";class p extends b{static methods=["delete","download","get","head","options","patch","post"];disableTerminationForFinishedUploads=!1;tusBase;constructor(e){super(e),this.disableTerminationForFinishedUploads=e.disableTerminationForFinishedUploads??!1;const t=this;this.tusBase=new class extends U{get storage(){return t.storage}get disableTerminationForFinishedUploads(){return t.disableTerminationForFinishedUploads}buildFileUrl(s,r){return t.buildFileUrlForTus(s,r)}}}async options(){return this.tusBase.handleOptions(p.methods)}async post(e){this.tusBase.validateTusResumableHeader(o(e,"tus-resumable"));const t=e.headers["upload-length"],s=e.headers["upload-defer-length"],r=e.headers["upload-concat"],a=o(e,"upload-metadata",!0),n=o(e,"content-type")||"",i=Number.parseInt(o(e,"content-length")||"0",10),l=e.originalUrl||e.url||"",c=u(e);return this.tusBase.handlePost(t,s,r,a,l,c,i,n)}async patch(e){this.tusBase.validateTusResumableHeader(o(e,"tus-resumable"));try{const t=h(e);if(e.headers["upload-offset"]===void 0)throw d(412,"Missing Upload-Offset header");if(e.headers["content-type"]===void 0)throw d(412,"Content-Type header required");if(e.headers["content-type"]!=="application/offset+octet-stream")throw d(415,"Unsupported Media Type");const s=Number.parseInt(o(e,"upload-offset"),10),r=e.headers["upload-length"],a=o(e,"upload-metadata",!0),n=Number(o(e,"content-length")),i=o(e,"upload-checksum"),{checksum:l,checksumAlgorithm:c}=this.tusBase.extractChecksum(i),m=e.originalUrl||e.url||"",g=u(e);return this.tusBase.handlePatch(t,s,r,a,l,c,m,g,n)}catch(t){this.checkForUndefinedIdOrPath(t);const s=t;throw s.UploadErrorCode==="GONE"||s.UploadErrorCode==="FILE_NOT_FOUND"?d(410,"Upload expired"):t}}async head(e){this.tusBase.validateTusResumableHeader(o(e,"tus-resumable"));try{const t=h(e);return this.tusBase.handleHead(t)}catch(t){this.checkForUndefinedIdOrPath(t);const s=t;throw s.UploadErrorCode==="GONE"||s.UploadErrorCode==="FILE_NOT_FOUND"?d(410,"Upload expired"):t}}async get(e){this.tusBase.validateTusResumableHeader(o(e,"tus-resumable"));try{const t=h(e);return this.tusBase.handleGet(t)}catch(t){throw this.checkForUndefinedIdOrPath(t),t.UploadErrorCode==="GONE"?d(410,"Upload expired"):t}}async delete(e){this.tusBase.validateTusResumableHeader(o(e,"tus-resumable"));try{const t=h(e);return this.tusBase.handleDelete(t)}catch(t){throw this.checkForUndefinedIdOrPath(t),t.code==="ENOENT"?d(404,"File not found"):t}}send(e,{body:t="",headers:s={},statusCode:r=200}){const a={body:t,headers:{...s,"Access-Control-Expose-Headers":"location,upload-expires,upload-offset,upload-length,upload-metadata,upload-defer-length,tus-resumable,tus-extension,tus-max-size,tus-version,tus-checksum-algorithm,cache-control","Tus-Resumable":T},statusCode:r||200};super.send(e,a)}compose(){this.registeredHandlers.set("POST",this.post.bind(this)),this.registeredHandlers.set("PATCH",this.patch.bind(this)),this.registeredHandlers.set("HEAD",this.head.bind(this)),this.registeredHandlers.set("GET",this.get.bind(this)),this.registeredHandlers.set("DELETE",this.delete.bind(this)),this.registeredHandlers.set("OPTIONS",this.options.bind(this)),this.logger?.debug("Registered handler: %s",[...this.registeredHandlers.keys()].join(", "))}buildFileUrlForTus(e,t){const s=new URL(e,"http://localhost"),{pathname:r}=s,a=Object.fromEntries(s.searchParams.entries()),n=f({pathname:`${r}/${t.id}`,query:a});return this.storage.config.useRelativeLocation?n:(/^https?:\/\//iu.test(e)?s.origin:"")+n}}export{T as TUS_RESUMABLE,N as TUS_VERSION,p as Tus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as o}from"./headers-erjZrwbT.js";import{B as F}from"./storage-uypoNkqu.js";import{B as H}from"./base-handler-fetch-DDSPIzWT.js";import{TusBase as v,TUS_RESUMABLE as w}from"./TUS_RESUMABLE-Dsxqcx-u.js";import{TUS_VERSION as N}from"./TUS_RESUMABLE-Dsxqcx-u.js";const h=f=>{let e;try{const t=new URL(f).pathname.split("/").filter(Boolean);e=t[t.length-1]||void 0}catch{return}if(e){try{F.assertSafeId(e)}catch{throw o(400,`Invalid file id: "${e}"`)}return e}};class m extends H{static methods=["delete","download","get","head","options","patch","post"];tusBase;constructor(e){super(e),this.disableTerminationForFinishedUploads=e.disableTerminationForFinishedUploads??!1;const s=this;this.tusBase=new class extends v{get storage(){return s.storage}get disableTerminationForFinishedUploads(){return s.disableTerminationForFinishedUploads??!1}buildFileUrl(t,r){return s.buildFileUrlForTus(t,r)}}}async fetch(e){const s=await super.fetch(e);if(s.headers.has("Tus-Resumable"))return s;const t=new Headers(s.headers);return t.set("Tus-Resumable",w),new Response(s.body,{headers:t,status:s.status,statusText:s.statusText})}async options(){return this.tusBase.handleOptions(m.methods)}async post(e){const s=e.headers.get("tus-resumable");this.tusBase.validateTusResumableHeader(s||void 0);const t=e.headers.get("upload-length")||void 0,r=e.headers.get("upload-defer-length")||void 0,a=e.headers.get("upload-concat")||void 0,d=e.headers.get("upload-metadata")||void 0,l=e.headers.get("content-type")||"",n=e.headers.get("content-length"),i=n?Number.parseInt(n,10):0,c=e.url,u=e.body;return this.tusBase.handlePost(t,r,a,d,c,u,i,l)}async patch(e){const s=e.headers.get("tus-resumable");this.tusBase.validateTusResumableHeader(s||void 0);const t=h(e.url);if(!t)throw o(404,"File not found");const r=e.headers.get("upload-offset");if(!r)throw o(412,"Missing Upload-Offset header");const a=e.headers.get("content-type");if(!a)throw o(412,"Content-Type header required");if(a!=="application/offset+octet-stream")throw o(415,"Unsupported Media Type");const d=Number.parseInt(r,10),l=e.headers.get("upload-length")||void 0,n=e.headers.get("upload-metadata")||void 0,i=e.headers.get("content-length"),c=i?Number.parseInt(i,10):0,u=e.headers.get("upload-checksum")||void 0,{checksum:b,checksumAlgorithm:T}=this.tusBase.extractChecksum(u),U=e.url,y=e.body;try{return this.tusBase.handlePatch(t,d,l,n,b,T,U,y,c)}catch(p){const g=p;throw g.UploadErrorCode==="GONE"||g.UploadErrorCode==="FILE_NOT_FOUND"?o(410,"Upload expired"):p}}async head(e){const s=e.headers.get("tus-resumable");this.tusBase.validateTusResumableHeader(s||void 0);const t=h(e.url);if(!t)throw o(404,"File not found");try{return this.tusBase.handleHead(t)}catch(r){const a=r;throw a.UploadErrorCode==="GONE"||a.UploadErrorCode==="FILE_NOT_FOUND"?o(410,"Upload expired"):r}}async get(e){const s=e.headers.get("tus-resumable");this.tusBase.validateTusResumableHeader(s||void 0);const t=h(e.url);if(!t)throw o(404,"File not found");try{return this.tusBase.handleGet(t)}catch(r){throw r.UploadErrorCode==="GONE"?o(410,"Upload expired"):r}}async delete(e){const s=e.headers.get("tus-resumable");this.tusBase.validateTusResumableHeader(s||void 0);const t=h(e.url);if(!t)throw o(404,"File not found");try{return this.tusBase.handleDelete(t)}catch(r){throw r.code==="ENOENT"?o(404,"File not found"):r}}compose(){this.registeredHandlers.set("POST",this.post.bind(this)),this.registeredHandlers.set("PATCH",this.patch.bind(this)),this.registeredHandlers.set("HEAD",this.head.bind(this)),this.registeredHandlers.set("GET",this.get.bind(this)),this.registeredHandlers.set("DELETE",this.delete.bind(this)),this.registeredHandlers.set("OPTIONS",this.options.bind(this)),this.logger?.debug("Registered handler: %s",[...this.registeredHandlers.keys()].join(", "))}buildFileUrlForTus(e,s){const t=new URL(e),{pathname:r,search:a}=t,d=`${r}/${s.id}${a}`;return this.storage.config.useRelativeLocation?d:t.origin+d}}export{w as TUS_RESUMABLE,N as TUS_VERSION,m as Tus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./File-DLAa0hBv.js";class a extends e{customId;fileHash;ufsKey;url}export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as t}from"./local-meta-storage-Ca6WrUmN.js";class r extends t{constructor(a){super(a)}}export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import p from"./UploadThingFile-DP4kNmpS.js";import w from"./UploadThingMetaStorage-CYWznm7F.js";import{UTApi as g,UTFile as u}from"uploadthing/server";import{throwErrorCode as d,ERRORS as h}from"./ERRORS-olUcTqo2.js";import{B as T}from"./storage-uypoNkqu.js";import{g as m}from"./get-file-status-B8WmWzcM.js";import{u as U}from"./update-size-Dxc1hvbI.js";import{p as I}from"./part-match-Cb6xL9eN.js";import{h as O}from"./has-content-96mmyLn2.js";const f=3600*24*7,E=c=>{let e;try{e=typeof atob=="function"?atob(c):Buffer.from(c,"base64").toString("utf8")}catch(t){throw new Error(`UploadThing: token is not valid base64: ${t.message}`)}let a;try{a=JSON.parse(e)}catch(t){throw new Error(`UploadThing: token does not decode to JSON: ${t.message}`)}if(!a||typeof a!="object"||typeof a.apiKey!="string"||typeof a.appId!="string")throw new Error("UploadThing: token missing `apiKey` or `appId`");return a},k=async c=>{const e=[];for await(const a of c)e.push(Buffer.from(a));return Buffer.concat(e)},y=c=>{const e=c.lastIndexOf("/");return e===-1?c:c.slice(e+1)};class R extends T{static name="uploadthing";checksumTypes=[];meta;acl;appId;defaultUrlExpiresIn;utapi;constructor(e){super(e);const a=e.token??process.env.UPLOADTHING_TOKEN;if(e.client)this.utapi=e.client;else{if(!a)throw new Error("UploadThing: missing token. Pass `token` or set UPLOADTHING_TOKEN.");this.utapi=new g({defaultKeyType:"customId",token:a})}if(!a)throw new Error("UploadThing: `token` is required even when passing `client` so the adapter can derive `appId` for CDN URLs.");this.appId=E(a).appId,this.acl=e.acl??"public-read",this.defaultUrlExpiresIn=Math.min(e.defaultUrlExpiresIn??3600,f),this.meta=e.metaStorage??new w(e.metaStorageConfig),this.isReady=!0}get raw(){return this.utapi}async create(e,a){return this.instrumentOperation("create",async()=>{const t=new p(e);t.name=this.namingFunction(t),t.customId=t.name,await this.validate(t);try{const s=await this.getMeta(t.id);if(s.bytesWritten>=0)return s}catch{}return t.bytesWritten=0,t.status=m(t),await this.saveMeta(t),await this.onCreate(t),t})}async write(e,a){return this.instrumentOperation("write",async()=>{let t;if("contentType"in e&&"metadata"in e&&!("body"in e)&&!("start"in e)?t=e:(t=await this.getMeta(e.id),await this.checkIfExpired(t)),t.status==="completed")return t;if(e.size!==void 0&&U(t,e.size),!I(e,t))throw new Error("File part does not match");const s=await this.lock(e.id);try{if(O(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const r=await k(e.body),i=new Blob([new Uint8Array(r)],{type:t.contentType}),o=new u([i],y(t.name||t.id),{customId:t.name||t.id,type:t.contentType}),n=await this.runOperation(a,()=>this.utapi.uploadFiles(o,{acl:this.acl}));if(n.error)throw new Error(n.error.message);const{data:l}=n;t.bytesWritten=r.length,t.size=r.length,t.ufsKey=l.key,t.url=l.ufsUrl??l.url,t.ETag=l.fileHash,t.fileHash=l.fileHash}return t.status=m(t),t.status==="completed"&&await this.internalOnComplete(t),await this.saveMeta(t),t}finally{await this.unlock(e.id,s)}})}async delete({id:e},a){return this.instrumentOperation("delete",async()=>{let t;try{t=await this.getMeta(e)}catch{}const s=t?.customId??t?.name??e;return await this.runOperation(a,()=>this.utapi.deleteFiles(s)),t?(t.status="deleted",await this.deleteMeta(t.id),await this.onDelete(t),t):Object.assign(new p({contentType:"application/octet-stream",metadata:{},originalName:e}),{customId:s,id:e,name:e,status:"deleted"})})}async get({id:e},a){return this.instrumentOperation("get",async()=>{let t,s=e;try{t=await this.checkIfExpired(await this.getMeta(e)),s=t.customId??t.name??e}catch{}const r=await this.resolveFetchUrl(s,a),i=await this.runOperation(a,()=>fetch(r));if(!i.ok)throw new Error(`UploadThing: fetch failed: ${i.status} ${i.statusText} for ${s}`);const o=Buffer.from(await i.arrayBuffer());return{content:o,contentType:t?.contentType??i.headers.get("content-type")??"application/octet-stream",ETag:t?.ETag??i.headers.get("etag")??void 0,expiredAt:t?.expiredAt,id:e,metadata:t?.metadata??{},modifiedAt:t?.modifiedAt,name:t?.name??s,originalName:t?.originalName??s,size:t?.size??o.length}})}async copy(e,a,t){return this.instrumentOperation("copy",async()=>{const s=await this.get({id:e},t),r=new Blob([new Uint8Array(s.content)],{type:s.contentType}),i=new u([r],y(a),{customId:a,type:s.contentType}),o=await this.runOperation(t,()=>this.utapi.uploadFiles(i,{acl:this.acl}));if(o.error)throw new Error(o.error.message);const n=new p({contentType:s.contentType,metadata:{},originalName:a});return n.id=a,n.name=a,n.customId=a,n.size=typeof s.size=="string"?Number(s.size):s.size,n.ufsKey=o.data.key,n.url=o.data.ufsUrl??o.data.url,n.ETag=o.data.fileHash,n})}async move(e,a,t){return this.instrumentOperation("move",async()=>{const s=await this.copy(e,a,t);return await this.delete({id:e},t),s})}async list(e=1e3,a){return this.instrumentOperation("list",async()=>(await this.runOperation(a,()=>this.utapi.listFiles({limit:e}))).files.map(s=>{const r=s.customId??s.key,i=new p({contentType:"application/octet-stream",metadata:{},originalName:r});return i.id=r,i.name=r,i.customId=s.customId??void 0,i.ufsKey=s.key,i.size=s.size,i.modifiedAt=s.uploadedAt?new Date(s.uploadedAt).toISOString():void 0,i}),{limit:e})}async getReadUrl(e,a){if(a?.responseContentDisposition!==void 0||a?.responseContentType!==void 0)return d(h.METHOD_NOT_ALLOWED,"UploadThing: `responseContentDisposition`/`responseContentType` are not supported — no override exists on UploadThing CDN/signed URLs.");if(this.acl==="public-read")return`https://${this.appId}.ufs.sh/f/${encodeURIComponent(e)}`;const t=Math.min(a?.expiresIn??this.defaultUrlExpiresIn,f),{ufsUrl:s}=await this.utapi.generateSignedURL(e,{expiresIn:t,keyType:"customId"});return s}async getUploadUrl(e,a){return d(h.METHOD_NOT_ALLOWED,"UploadThing: presigned PUT URLs require the UFS ingest signing scheme — use the file-router pattern via `storage.raw` instead.")}async resolveFetchUrl(e,a){if(this.acl==="public-read")return`https://${this.appId}.ufs.sh/f/${encodeURIComponent(e)}`;const{ufsUrl:t}=await this.runOperation(a,()=>this.utapi.generateSignedURL(e,{expiresIn:this.defaultUrlExpiresIn,keyType:"customId"}));return t}internalOnComplete=e=>this.deleteMeta(e.id)}export{R as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class o extends Error{code;details;constructor(a,r,s,i,t,d){super(a),this.name="ValidationError",this.code=r,this.details={invalidParams:i,mediaType:s,suggestions:d,validParams:t}}}export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./File-DLAa0hBv.js";class o extends e{url;downloadUrl;pathname}export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as t}from"./local-meta-storage-Ca6WrUmN.js";class r extends t{constructor(e){super(e)}}export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{put as l,list as u,del as h,copy as d}from"@vercel/blob";import{d as y}from"./detect-file-type-go3r-MOD.js";import{B as E,t as O}from"./storage-uypoNkqu.js";import{L as T}from"./local-meta-storage-Ca6WrUmN.js";import m from"./VercelBlobFile-Censq2sD.js";import{g as p}from"./get-file-status-B8WmWzcM.js";import{u as g}from"./update-size-Dxc1hvbI.js";import{p as k}from"./part-match-Cb6xL9eN.js";import{h as v}from"./has-content-96mmyLn2.js";class f extends E{static name="vercel-blob";checksumTypes=["md5"];get raw(){return{copy:d,credentials:this.credentials,del:h,list:u,put:l}}meta;credentials;multipart;access;constructor(e){super(e),this.credentials=f.resolveCredentials(e),this.multipart=e.multipart??!1,this.access=e.access??"public";const{metaStorage:i,metaStorageConfig:t}=e;this.meta=i||new T(t),this.isReady=!0}static resolveCredentials(e){if(e.token)return{token:e.token};const i=e.oidcToken??process.env.VERCEL_OIDC_TOKEN,t=e.storeId??process.env.BLOB_STORE_ID,r=t?.startsWith("store_")?t.slice(6):t;if(i&&r)return{oidcToken:i,storeId:r};if(i||r)throw new Error(`Vercel Blob OIDC auth requires both \`oidcToken\` and \`storeId\` (or \`VERCEL_OIDC_TOKEN\` and \`BLOB_STORE_ID\` env vars). Got: oidcToken=${i?"set":"missing"}, storeId=${r?"set":"missing"}.`);const s=process.env.BLOB_READ_WRITE_TOKEN||process.env.VERCEL_BLOB_TOKEN;if(s)return{token:s};throw new Error("Vercel Blob credentials are required. Provide `token`, an `oidcToken`+`storeId` pair, or set BLOB_READ_WRITE_TOKEN / (VERCEL_OIDC_TOKEN + BLOB_STORE_ID) env vars.")}async create(e,i){return this.instrumentOperation("create",async()=>{const t={...e};if(e.ttl){const s=typeof e.ttl=="string"?O(e.ttl):e.ttl;t.expiredAt=s===void 0?void 0:Date.now()+s}const r=new m(t);r.name=this.namingFunction(r),await this.validate(r);try{const s=await this.getMeta(r.id);if(s.bytesWritten>=0)return s}catch{}return r.bytesWritten=0,r.status=p(r),await this.saveMeta(r),await this.onCreate(r),r})}async write(e,i){return this.instrumentOperation("write",async()=>{let t;if("contentType"in e&&"metadata"in e&&!("body"in e)&&!("start"in e)?t=e:(t=await this.getMeta(e.id),await this.checkIfExpired(t)),t.status==="completed")return t;if(e.size!==void 0&&g(t,e.size),!k(e,t))throw new Error("File part does not match");const r=await this.lock(e.id);try{if(v(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const s=[],a=e.body;for await(const o of a)s.push(Buffer.from(o));const n=Buffer.concat(s);if((t.bytesWritten===0||Number.isNaN(t.bytesWritten))&&(!t.contentType||t.contentType==="application/octet-stream"))try{const o=await y(n);o?.mime&&(t.contentType=o.mime)}catch{}const w=new Blob([n],{type:t.contentType}),c=await this.runOperation(i,()=>l(t.name,w,{access:this.access,multipart:this.shouldUseMultipart(t),...this.credentials}));t.url=c.url,t.pathname=c.pathname,t.downloadUrl=c.downloadUrl,t.bytesWritten=n.length}return t.status=p(t),t.status==="completed"&&await this.internalOnComplete(t),await this.saveMeta(t),t}finally{await this.unlock(e.id,r)}})}async delete({id:e},i){return this.instrumentOperation("delete",async()=>{const t=await this.getMeta(e);if(!t.url)throw new Error(`File ${e} does not have a valid URL`);const{url:r}=t;t.status="deleted";try{await this.runOperation(i,()=>h(r,{...this.credentials}))}catch(a){this.logger?.error("Failed to delete blob from Vercel Blob:",a);const n=this.normalizeError(a instanceof Error?a:new Error(String(a)));await this.onError(n)}await this.deleteMeta(t.id);const s={...t};return await this.onDelete(s),s})}async exists({id:e},i){return this.instrumentOperation("exists",async()=>{try{const t=await this.getMeta(e);if(!t.url||t.url.length===0)return!1;const{url:r}=t;return(await this.runOperation(i,()=>fetch(r,{method:"HEAD"}))).ok}catch{return!1}})}async get({id:e},i){return this.instrumentOperation("get",async()=>{const t=await this.checkIfExpired(await this.getMeta(e));if(!t.url||t.url.length===0)throw new Error("File URL not found");const{url:r}=t,s=await this.runOperation(i,()=>fetch(r)),a=Buffer.from(await this.runOperation(i,()=>s.arrayBuffer()));return{content:a,contentType:t.contentType,ETag:t.ETag,expiredAt:t.expiredAt,id:e,metadata:t.metadata,modifiedAt:t.modifiedAt,name:t.name,originalName:t.originalName,size:t.size||a.length}})}async copy(e,i,t){return this.instrumentOperation("copy",async()=>{const r=await this.getMeta(e);if(!r.url)throw new Error("Source file URL not found");const s=r.url,a=await this.runOperation(t,()=>d(s,i,{access:"public",...this.credentials}));return{...r,id:i,name:i,pathname:a.pathname,url:a.url}})}async move(e,i,t){return this.instrumentOperation("move",async()=>{const r=await this.copy(e,i,t);return await this.delete({id:e},t),r})}async list(e=1e3,i){return this.instrumentOperation("list",async()=>(await this.runOperation(i,()=>u({limit:e,...this.credentials}))).blobs.map(r=>{const s=new m({contentType:"application/octet-stream",metadata:{},originalName:r.pathname});return s.createdAt=r.uploadedAt?.toISOString(),s.id=r.pathname,s.modifiedAt=r.uploadedAt?.toISOString(),s.name=r.pathname,s.pathname=r.pathname,s.size=r.size,s.url=r.url,s.downloadUrl=r.downloadUrl,s}),{limit:e})}internalOnComplete=e=>this.deleteMeta(e.id);shouldUseMultipart(e){return typeof this.multipart=="boolean"?this.multipart:typeof this.multipart=="number"&&e.size!==void 0?e.size>=this.multipart:!1}}export{f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}export{e as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{tool as a}from"@openai/agents";import{r as F}from"./approval-DcuhtQKs.js";import{T as i,e as o,W as u}from"./executors-DgKT6b1T.js";const g=e=>a({description:i.listFiles.description,execute:t=>o.listFiles(e,t),name:"listFiles",parameters:i.listFiles.input}),m=e=>a({description:i.getFileMetadata.description,execute:t=>o.getFileMetadata(e,t),name:"getFileMetadata",parameters:i.getFileMetadata.input}),U=e=>a({description:i.downloadFile.description,execute:t=>o.downloadFile(e,t),name:"downloadFile",parameters:i.downloadFile.input}),x=e=>a({description:i.getFileUrl.description,execute:t=>o.getFileUrl(e,t),name:"getFileUrl",parameters:i.getFileUrl.input}),O=(e,{needsApproval:t=!0}={})=>a({description:i.uploadFile.description,execute:l=>o.uploadFile(e,l),name:"uploadFile",needsApproval:t,parameters:i.uploadFile.input}),y=(e,{needsApproval:t=!0}={})=>a({description:i.deleteFile.description,execute:l=>o.deleteFile(e,l),name:"deleteFile",needsApproval:t,parameters:i.deleteFile.input}),M=(e,{needsApproval:t=!0}={})=>a({description:i.copyFile.description,execute:l=>o.copyFile(e,l),name:"copyFile",needsApproval:t,parameters:i.copyFile.input}),T=(e,{needsApproval:t=!0}={})=>a({description:i.signUploadUrl.description,execute:l=>o.signUploadUrl(e,l),name:"signUploadUrl",needsApproval:t,parameters:i.signUploadUrl.input});function E({files:e,overrides:t,readOnly:l=!1,requireApproval:c=!0}){const s=n=>({needsApproval:F(n,c)}),r={copyFile:M(e,s("copyFile")),deleteFile:y(e,s("deleteFile")),downloadFile:U(e),getFileMetadata:m(e),getFileUrl:x(e),listFiles:g(e),signUploadUrl:T(e,s("signUploadUrl")),uploadFile:O(e,s("uploadFile"))};if(t){for(const[n,p]of Object.entries(t))if(n in r&&p){const d=n;Object.assign(r,{[d]:{...r[d],...p}})}}return l?Object.fromEntries(Object.entries(r).filter(([n])=>!u.has(n))):r}export{M as agentsCopyFile,y as agentsDeleteFile,U as agentsDownloadFile,m as agentsGetFileMetadata,x as agentsGetFileUrl,g as agentsListFiles,T as agentsSignUploadUrl,O as agentsUploadFile,E as createAgentsFileTools};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n=e=>{const c=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.AKAMAI_ACCESS_KEY_ID,o=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.AKAMAI_SECRET_ACCESS_KEY,s=e?.region??process.env.AKAMAI_REGION;if(!c||!o||!s)throw new Error("Missing required parameters for Akamai Cloud Object Storage client.");return{credentials:{accessKeyId:c,secretAccessKey:o},endpoint:e?.endpoint??`https://${s}.linodeobjects.com`,forcePathStyle:!1,region:s}};export{n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const A=e=>{const c=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.ALIBABA_ACCESS_KEY_ID,o=e?.endpoint??process.env.ALIBABA_ENDPOINT,s=e?.region??process.env.ALIBABA_REGION,n=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.ALIBABA_ACCESS_KEY_SECRET;if(!s||!c||!n)throw new Error("Missing required parameters for Alibaba Cloud OSS client.");return{credentials:{accessKeyId:c,secretAccessKey:n},endpoint:o??`https://s3.oss-${s}.aliyuncs.com`,forcePathStyle:!1,region:s}};export{A as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=(e,r)=>typeof r=="boolean"?r:r[e]??!0;export{t as r};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import w from"./MetaStorage-DPEUyWgN.js";import{parseMetadata as m,stringifyMetadata as x}from"./Metadata-BeQVDFer.js";import{Readable as f}from"node:stream";import{AwsClient as b}from"aws4fetch";import{i as T}from"./is-expired-CZlgTFFz.js";const y=p=>{const t={},s=p.replaceAll(/<\?xml[^>]*\?>/g,"").replaceAll(/xmlns[^=]*="[^"]*"/g,""),o=/<([^>]+)>([^<]*)<\/\1>/g,e=[...s.matchAll(o)];for(const i of e){const[,n,c]=i;n&&c?.trim()&&(t[n]?(Array.isArray(t[n])||(t[n]=[t[n]]),t[n].push(c.trim())):t[n]=c.trim())}const a=/<([^>]+)>([\s\S]*?)<\/\1>/g;let r;for(;(r=a.exec(s))!==null;){const[,i,n]=r;if(i&&n?.includes("<")){const c=y(n);Object.keys(c).length>0&&(t[i]=c)}}return t};class k{aws;bucket;endpoint;constructor(t){this.bucket=t.bucket,this.endpoint=t.endpoint||`https://${t.bucket}.s3.${t.region}.amazonaws.com`,this.aws=new b({accessKeyId:t.accessKeyId,region:t.region,secretAccessKey:t.secretAccessKey,service:t.service||"s3",sessionToken:t.sessionToken})}async createMultipartUpload(t,s){const o={uploads:""},e={};if(t.ContentType&&(e["Content-Type"]=t.ContentType),t.ACL&&(e["x-amz-acl"]=t.ACL),t.Metadata)for(const[l,d]of Object.entries(t.Metadata))e[`x-amz-meta-${l}`]=d;const a=this.buildUrl(t.Key,o),r=await this.aws.fetch(a,{headers:e,method:"POST",signal:s?.signal}),i=await r.text();if(!r.ok)throw new Error(`Failed to create multipart upload: ${r.status} ${i}`);const n=y(i),c=n.UploadId||n.InitiateMultipartUploadResult?.UploadId;if(!c){const l=new Error("Failed to parse UploadId from response");throw l.retryable=!1,l}return{UploadId:c}}async uploadPart(t,s){const o={partNumber:String(t.PartNumber),uploadId:t.UploadId},e={};t.ContentLength&&(e["Content-Length"]=String(t.ContentLength)),t.ContentMD5&&(e["Content-MD5"]=t.ContentMD5);const a=t.Body instanceof f?f.toWeb(t.Body):t.Body,r=this.buildUrl(t.Key,o),i=await this.aws.fetch(r,{body:a,headers:e,method:"PUT",signal:s?.signal});if(!i.ok){const c=await i.text();throw new Error(`Failed to upload part: ${i.status} ${c}`)}const n=i.headers.get("ETag");if(!n)throw new Error("Failed to get ETag from response");return{ETag:n.replaceAll(/(^"|"$)/g,"")}}async completeMultipartUpload(t,s){const o={uploadId:t.UploadId},a=`<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<CompleteMultipartUpload xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
3
|
+
${t.Parts.map(({ETag:h,PartNumber:g})=>`<Part><PartNumber>${g}</PartNumber><ETag>"${h}"</ETag></Part>`).join("")}
|
|
4
|
+
</CompleteMultipartUpload>`,r=this.buildUrl(t.Key,o),i=await this.aws.fetch(r,{body:a,headers:{"Content-Type":"application/xml"},method:"POST",signal:s?.signal}),n=await i.text();if(!i.ok)throw new Error(`Failed to complete multipart upload: ${i.status} ${n}`);const c=y(n),l=c.CompleteMultipartUploadResult||c,d=l.Location||`${this.endpoint}/${t.Key}`;return{ETag:l.ETag?.replaceAll(/(^"|"$)/g,""),Location:d}}async abortMultipartUpload(t,s){const o={uploadId:t.UploadId},e=this.buildUrl(t.Key,o),a=await this.aws.fetch(e,{method:"DELETE",signal:s?.signal});if(!a.ok){const r=await a.text();throw new Error(`Failed to abort multipart upload: ${a.status} ${r}`)}}async listParts(t,s){const o={uploadId:t.UploadId},e=this.buildUrl(t.Key,o),a=await this.aws.fetch(e,{method:"GET",signal:s?.signal}),r=await a.text();if(!a.ok)throw new Error(`Failed to list parts: ${a.status} ${r}`);const i=y(r),n=i.ListPartsResult||i;let c=[];return n.Part&&(c=Array.isArray(n.Part)?n.Part:[n.Part]),{Parts:c.map(l=>({ETag:l.ETag?.replaceAll(/(^"|"$)/g,""),PartNumber:Number(l.PartNumber)||0,Size:l.Size?Number(l.Size):void 0}))}}async getObject(t,s){const o=this.buildUrl(t.Key),e=await this.aws.fetch(o,{method:"GET",signal:s?.signal});if(!e.ok){const u=await e.text();throw new Error(`Failed to get object: ${e.status} ${u}`)}const a=e.headers.get("Content-Length"),r=e.headers.get("Content-Type"),i=e.headers.get("ETag"),n=e.headers.get("Expires"),c=e.headers.get("Last-Modified"),l={};for(const[u,h]of e.headers.entries())if(u.toLowerCase().startsWith("x-amz-meta-")){const g=u.toLowerCase().replace("x-amz-meta-","");l[g]=h}const{body:d}=e;return{Body:d?this.streamToReadable(d):void 0,ContentLength:a?Number(a):void 0,ContentType:r||void 0,ETag:i?.replaceAll(/(^"|"$)/g,"")||void 0,Expires:n?new Date(n):void 0,LastModified:c?new Date(c):void 0,Metadata:Object.keys(l).length>0?l:void 0}}async headObject(t,s){const o=this.buildUrl(t.Key),e=await this.aws.fetch(o,{method:"HEAD",signal:s?.signal});if(!e.ok){const d=await e.text();throw new Error(`Failed to head object: ${e.status} ${d}`)}const a=e.headers.get("Content-Length"),r=e.headers.get("Content-Type"),i=e.headers.get("ETag"),n=e.headers.get("Expires"),c=e.headers.get("Last-Modified"),l={};for(const[d,u]of e.headers.entries())if(d.toLowerCase().startsWith("x-amz-meta-")){const h=d.toLowerCase().replace("x-amz-meta-","");l[h]=u}return{ContentLength:a?Number(a):void 0,ContentType:r||void 0,ETag:i?.replaceAll(/(^"|"$)/g,"")||void 0,Expires:n?new Date(n):void 0,LastModified:c?new Date(c):void 0,Metadata:Object.keys(l).length>0?l:void 0}}async deleteObject(t,s){const o=this.buildUrl(t.Key),e=await this.aws.fetch(o,{method:"DELETE",signal:s?.signal});if(!e.ok){const a=await e.text();throw new Error(`Failed to delete object: ${e.status} ${a}`)}}async copyObject(t,s){const o={"x-amz-copy-source":t.CopySource};t.StorageClass&&(o["x-amz-storage-class"]=t.StorageClass);let e=this.buildUrl(t.Key);t.Bucket!==this.bucket&&(e=e.replace(this.bucket,t.Bucket));const a=await this.aws.fetch(e,{headers:o,method:"PUT",signal:s?.signal});if(!a.ok){const r=await a.text();throw new Error(`Failed to copy object: ${a.status} ${r}`)}}async listObjectsV2(t,s){const o={"list-type":"2"};t.MaxKeys&&(o["max-keys"]=String(t.MaxKeys)),t.ContinuationToken&&(o["continuation-token"]=t.ContinuationToken),t.Delimiter!==void 0&&(o.delimiter=t.Delimiter),t.Prefix!==void 0&&(o.prefix=t.Prefix);const e=this.buildUrl("",o),a=await this.aws.fetch(e,{method:"GET",signal:s?.signal}),r=await a.text();if(!a.ok)throw new Error(`Failed to list objects: ${a.status} ${r}`);const i=y(r),n=i.ListBucketResult||i,c=n.Contents||(Array.isArray(n.Contents)?n.Contents:[]),l=[];for(const d of r.matchAll(/<CommonPrefixes>\s*<Prefix>([^<]*)<\/Prefix>\s*<\/CommonPrefixes>/g))l.push({Prefix:d[1]});return{CommonPrefixes:l,Contents:Array.isArray(c)?c.map(d=>({Key:d.Key,LastModified:d.LastModified?new Date(String(d.LastModified)):void 0})):[],IsTruncated:n.IsTruncated==="true"||n.IsTruncated===!0,NextContinuationToken:n.NextContinuationToken}}async getPresignedUrl(t){const s={partNumber:String(t.PartNumber),uploadId:t.UploadId,"X-Amz-Expires":String(t.expiresIn)};return this.buildUrl(t.Key,s)}async putObject(t){const s=this.buildUrl(t.Key),o={};if(t.ContentType&&(o["Content-Type"]=t.ContentType),t.ContentLength!==void 0&&(o["Content-Length"]=String(t.ContentLength)),t.Metadata)for(const[r,i]of Object.entries(t.Metadata))o[`x-amz-meta-${r}`]=i;let e;t.Body===void 0?e=void 0:t.Body instanceof Uint8Array?e=new Uint8Array(t.Body):t.Body instanceof ReadableStream?e=t.Body:e=void 0;const a=await this.aws.fetch(s,{body:e,headers:o,method:"PUT"});if(!a.ok){const r=await a.text();throw new Error(`Failed to put object: ${a.status} ${r}`)}}async checkBucketAccess(t){const s=this.buildUrl(""),o=await this.aws.fetch(s,{method:"HEAD"});if(!o.ok&&o.status!==404){const e=await o.text();throw new Error(`Failed to access bucket: ${o.status} ${e}`)}}buildUrl(t,s){const o=new URL(t,this.endpoint);if(s)for(const[e,a]of Object.entries(s))o.searchParams.set(e,a);return o.toString()}streamToReadable(t){return f.fromWeb(t)}}class $ extends w{constructor(t){super(t),this.config=t;const s=t.bucket||process.env.S3_BUCKET||process.env.AWS_S3_BUCKET;if(!s)throw new Error("S3 bucket is not defined");this.bucket=s,this.adapter=new k({accessKeyId:t.accessKeyId,bucket:s,endpoint:t.endpoint,region:t.region,secretAccessKey:t.secretAccessKey,service:t.service,sessionToken:t.sessionToken}),this.adapter.checkBucketAccess({Bucket:s}).catch(o=>{throw o})}config;adapter;bucket;async get(t){const s=this.getMetaName(t),{Expires:o,Metadata:e}=await this.adapter.headObject({Bucket:this.bucket,Key:s});if(o&&T({expiredAt:o}))throw await this.delete(s),new Error(`Metafile ${t} not found`);if(e?.metadata!==void 0){const a=JSON.parse(decodeURIComponent(e.metadata));return a.metadata&&typeof a.metadata=="string"&&(a.metadata=m(a.metadata)),a}throw new Error(`Metafile ${t} not found`)}async touch(t,s){return this.save(t,s)}async delete(t){await this.adapter.deleteObject({Bucket:this.bucket,Key:this.getMetaName(t)})}async save(t,s){const o={...s};o.metadata&&(o.metadata=x(s.metadata));const e=encodeURIComponent(JSON.stringify(o));return await this.adapter.putObject({Bucket:this.bucket,ContentLength:0,ContentType:"application/json",Key:this.getMetaName(t),Metadata:{metadata:e}}),s}}export{k as A,$ as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{throwErrorCode as c,ERRORS as d}from"./ERRORS-olUcTqo2.js";import l from"./MetaStorage-DPEUyWgN.js";import{parseMetadata as p,stringifyMetadata as u}from"./Metadata-BeQVDFer.js";import{BlobServiceClient as s,StorageSharedKeyCredential as m,SASProtocol as y,BlobSASPermissions as h}from"@azure/storage-blob";const b=(t,n)=>{const e=n.startsWith("?")?n.slice(1):n;return t.includes("?")?`${t}&${e}`:`${t}?${e}`},g=300*1e3,f=t=>{const n={};for(const e of t.split(";")){const o=e.indexOf("=");o>0&&(n[e.slice(0,o).trim()]=e.slice(o+1).trim())}return n},w=(t,n)=>t||(n?`https://${n}.blob.core.windows.net`:void 0),A=t=>{const n=t.connectionString||process.env.AZURE_STORAGE_CONNECTION_STRING||void 0;if(n){const i=s.fromConnectionString(n);return f(n).AccountKey?{client:i,signer:{kind:"sharedKey"}}:{client:i}}const e=t.accountKey||process.env.AZURE_STORAGE_ACCOUNT_KEY||void 0,o=t.accountName||process.env.AZURE_STORAGE_ACCOUNT||void 0,r=w(t.endpoint,o);if(e){if(!o)throw new Error("Missing required parameter: Azure blob storage account name.");const i=new m(o,e);return{client:new s(r,i),signer:{kind:"sharedKey"}}}if(t.credential){if(!r)throw new Error("Missing required parameter: Azure blob storage account name or endpoint.");const i=new s(r,t.credential);return t.useUserDelegationSas===!1?{client:i}:{client:i,signer:{client:i,kind:"userDelegation"}}}const a=t.sasToken||process.env.AZURE_STORAGE_SAS_TOKEN||void 0;if(a){if(!r)throw new Error("Missing required parameter: Azure blob storage account name or endpoint.");const i=a.startsWith("?")?"":"?";return{client:new s(`${r}${i}${a}`),sasToken:a}}if(!r)throw new Error("Missing required Azure credentials: provide a connectionString, accountKey + accountName, a credential, a sasToken, or an accountName/endpoint for anonymous access.");return{anonymous:!0,client:new s(r)}},C=async(t,n,e)=>{if(t.cachedKey&&t.cachedKey.expiresOn.getTime()>e.getTime())return t.cachedKey.key;if(t.pendingKey&&t.pendingKey.expiresOn.getTime()>e.getTime())return t.pendingKey.promise;const o=new Date(e.getTime()+g),r=t.client.getUserDelegationKey(n,o),a={expiresOn:o,promise:r};t.pendingKey=a;try{const i=await r;return t.cachedKey={expiresOn:o,key:i},i}finally{t.pendingKey===a&&(t.pendingKey=void 0)}},T=async(t,n,e)=>{const o=new Date(Date.now()-6e4),r=new Date(Date.now()+e.expiresIn*1e3),a={expiresOn:r,permissions:h.parse(e.permissions),protocol:y.Https,startsOn:o,...e.contentDisposition&&{contentDisposition:e.contentDisposition},...e.contentType&&{contentType:e.contentType}};if(n.kind==="sharedKey")return t.generateSasUrl(a);const i=await C(n,o,r);return t.generateUserDelegationSasUrl(a,i)};class _ extends l{constructor(n){super(n),this.config=n;const{client:e,...o}=n;if(this.client=e===void 0?A(o).client:e,!(o.containerName||process.env.AZURE_STORAGE_CONTAINER||void 0))throw new Error("Missing required parameter: Azure container name.");this.containerClient=this.client.getContainerClient(o.containerName)}config;client;containerClient;async get(n){const e=this.containerClient.getAppendBlobClient(this.getMetaName(n));let o;try{o=await e.getProperties()}catch{throw c(d.UNKNOWN_ERROR)}if(!o.metadata)throw c(d.FILE_NOT_FOUND);const r=o.metadata;return r.metadata&&typeof r.metadata=="string"&&(r.metadata=p(r.metadata)),r}async touch(n,e){return this.save(n,e)}async delete(n){await this.containerClient.getBlockBlobClient(this.getMetaName(n)).deleteIfExists()}async save(n,e){const o={...e};return o.metadata&&(o.metadata=u(e.metadata)),await this.containerClient.getAppendBlobClient(this.getMetaName(n)).setMetadata(o,{}),e}async list(){const n=[],e=this.containerClient.listBlobsFlat({prefix:this.prefix});for await(const o of e)n.push(o);return n.filter(o=>o.name.endsWith(this.suffix)).map(o=>({createdAt:o.properties.createdOn,id:this.getIdFromMetaName(o.name)}))}}export{_ as A,b as a,T as b,A as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=e=>{const c=e?.applicationKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.B2_APP_KEY??process.env.BACKBLAZE_APP_KEY,n=e?.applicationKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.B2_APP_KEY_ID??process.env.BACKBLAZE_APP_KEY_ID,s=e?.region??process.env.AWS_REGION??process.env.B2_REGION??process.env.BACKBLAZE_REGION;if(!s||!n||!c)throw new Error("Missing required parameters for Backblaze B2 client.");return{credentials:{accessKeyId:n,secretAccessKey:c},endpoint:`https://s3.${s}.backblazeb2.com`,region:s}};export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EventEmitter as g}from"node:events";import{format as u}from"node:url";import p from"mime";import{ErrorMap as b}from"./ERRORS-olUcTqo2.js";import{H as w}from"./headers-erjZrwbT.js";import{Readable as c}from"node:stream";import{B as h}from"./storage-uypoNkqu.js";const T=(e,t)=>{const r={};return t.forEach(o=>{r[o]=e[o]}),r},R=e=>e.at(-1),E=e=>{let t="",r="";const o=f(e,"forwarded");return o&&o.split(";").forEach(l=>{const[a,i]=l.split("=");a==="proto"&&(t=i),a==="host"&&(r=i)}),{host:r,proto:t}},C=(e,t="utf8",r)=>new Promise((o,s)=>{const l=[];let a=0;e.on("data",i=>{const n=Buffer.isBuffer(i)?i:Buffer.from(i,t);if(a+=n.length,a>r){s(new Error("Request body length limit exceeded")),e.destroy();return}l.push(n)}),e.once("end",()=>{o(Buffer.concat(l).toString(t))}),e.once("error",s)}),f=(e,t,r=!1)=>{const o=e.headers?.[t.toLowerCase()];if(!o||o.length===0)return"";if(r)return o.toString().trim();const s=Array.isArray(o)?o:o.split(",");return R(s).trim()},y=(e,t,r)=>{const o=[e.getHeader(t),r].flat().filter(Boolean).toString();e.setHeader(t,o)},A=(e,t={})=>{const r=Object.keys(t);r.length>0&&y(e,"Access-Control-Expose-Headers",r),r.forEach(o=>{if(["link","location"].includes(o.toLowerCase())){const s=encodeURI(t[o].toString()).replaceAll("#","%23");e.setHeader(o,s)}else e.setHeader(o,t[o])})},v=e=>f(e,"host")||f(e,"x-forwarded-host"),L=e=>f(e,"x-forwarded-proto").toLowerCase(),U=e=>{let{host:t,proto:r}=E(e);return t||=v(e),r||=L(e),t?r?`${r}://${t}`:`//${t}`:""},I=e=>{let t=(e.originalUrl||e.url||"").split("?")[0];if(!t)throw new TypeError("Invalid request URL");return t.startsWith("/")||(t=`/${t}`),t.startsWith("http")&&(t=new URL(t).pathname),t},P=/^[\da-z]{4,}(?:-[\da-z]{4,}){2,}$/i,k=e=>{const r=I(e).split("/").filter(Boolean);if(r.length===0)throw new Error("Invalid request URL");for(let a=r.length-1;a>=0;a-=1){const i=r[a];if(!i)continue;const n=i.replace(/\.[^/.]+$/,"");if(!["files","metadata","upload","download","http-rest","http-rest-chunked"].includes(n.toLowerCase())&&P.test(n))return h.assertSafeId(n),n}const o=r[r.length-1];if(!o)throw new Error("Invalid request URL");const s=o.replace(/\.[^/.]+$/,"");if(["files","metadata","upload","download","http-rest","http-rest-chunked"].includes(s.toLowerCase()))throw new Error("Invalid request URL");if(s.length<8)throw new Error("Invalid request URL");if(r.length>1)return h.assertSafeId(s),s;throw new Error("Invalid request URL")},O=e=>"body"in e&&e.body&&typeof e.body.getReader=="function"?c.fromWeb(e.body):"body"in e&&e.body&&e.body instanceof Uint8Array?c.from(Buffer.from(e.body)):e instanceof c?e:c.from(new Uint8Array(0));class W extends g{responseType="json";storage;mediaTransformer;disableTerminationForFinishedUploads;logger;get loggerInstance(){return this.logger}internalErrorResponses={};get errorResponses(){return this.internalErrorResponses}constructor({disableTerminationForFinishedUploads:t,mediaTransformer:r,storage:o}){super(),this.storage=o,this.mediaTransformer=r,this.disableTerminationForFinishedUploads=t,this.logger=this.storage?.logger,this.assembleErrors()}set errorResponses(t){this.assembleErrors(t)}assembleErrors=(t={})=>{this.internalErrorResponses={...b,...this.internalErrorResponses,...this.storage.errorResponses,...t}};parseRangeHeader(t,r){if(!t?.startsWith("bytes="))return;const o=t.slice(6).split(",");if(o.length!==1)return;const s=o[0]?.trim();if(!s)return;const l=s.split("-");if(l.length!==2)return;const[a,i]=l;let n,d;if(a&&i)n=Number.parseInt(a,10),d=Number.parseInt(i,10);else if(a&&!i)n=Number.parseInt(a,10),d=r-1;else if(!a&&i){const m=Number.parseInt(i,10);n=Math.max(0,r-m),d=r-1}else return;if(!(Number.isNaN(n)||Number.isNaN(d)||n>=r||d>=r||n>d))return{end:d,start:n}}buildFileUrlFromString(t,r,o){const s=new URL(t,"http://localhost"),{pathname:l}=s,a=Object.fromEntries(s.searchParams.entries()),i=u({pathname:`${l}/${r.id}`,query:a});let n="";return this.storage.config.useRelativeLocation||(/^https?:\/\//iu.test(t)?n=s.origin:o&&(n=U({headers:o}))),`${n}${i}.${p.getExtension(r.contentType)}`}negotiateContentTypeFromHeader(t,r){if(t)return w.getPreferredMediaType(t,r)}checkForUndefinedIdOrPath(t){if(t instanceof Error&&["Id is undefined","Invalid request URL","Path is undefined"].includes(t.message))throw t}}export{W as B,O as a,f as b,I as c,k as g,T as p,C as r,A as s,P as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as p,h as y}from"./headers-erjZrwbT.js";import{ERRORS as m,isUploadError as C}from"./ERRORS-olUcTqo2.js";import{B as E,p as b}from"./base-handler-core-BvNgdV-9.js";import{i as H}from"./storage-uypoNkqu.js";import{waitForStorage as R}from"./waitForStorage-afkqWeuz.js";class U extends E{static methods=["delete","get","head","options","patch","post","put"];registeredHandlers=new Map;constructor(t){super(t),this.compose()}get handlers(){return this.registeredHandlers}async fetch(t){this.logger?.debug("[fetch request]: %s %s",t.method,t.url);const e=this.registeredHandlers.get(t.method||"GET");if(!e)return this.createErrorResponse({UploadErrorCode:m.METHOD_NOT_ALLOWED});try{await R(this.storage)}catch{return this.createErrorResponse({UploadErrorCode:m.STORAGE_ERROR})}try{const s=await e.call(this,t);return this.handleFetchResponse(t,s)}catch(s){const r=s instanceof Error?s:new Error(String(s)),l={...b(r,["name",...Object.getOwnPropertyNames(r)]),request:{headers:Object.fromEntries(t.headers.entries()),method:t.method,url:t.url}};return this.listenerCount("error")>0&&this.emit("error",l),this.logger?.error("[fetch error]: %O",l),this.createErrorResponse(r)}}async handleFetchResponse(t,e){if(t.method==="HEAD"||t.method==="OPTIONS"){const{headers:n,statusCode:d}=e;return new Response(void 0,{headers:this.convertHeaders({...n,"Access-Control-Expose-Headers":"location,upload-expires,upload-offset,upload-length,upload-metadata,upload-defer-length,tus-resumable,tus-extension,tus-max-size,tus-version,tus-checksum-algorithm,cache-control"}),status:d})}if(t.method==="GET"){const{headers:n,statusCode:d}=e;let c="";return e.content!==void 0?c=new Uint8Array(e.content):typeof e=="object"&&"data"in e&&(c=JSON.stringify(e.data)),new Response(c,{headers:this.convertHeaders({...n,"Access-Control-Expose-Headers":"location,upload-expires,upload-offset,upload-length,upload-metadata,upload-defer-length,tus-resumable,tus-extension,tus-max-size,tus-version,tus-checksum-algorithm,cache-control"}),status:d})}const{headers:s,statusCode:r,...o}=e;if(o.status!==void 0&&this.listenerCount(o.status)>0&&this.emit(o.status,{...o,request:{headers:Object.fromEntries(t.headers.entries()),method:t.method,url:t.url}}),o.status==="completed"){const n=e;n.headers===void 0&&(n.headers={}),n.statusCode===void 0&&(n.statusCode=200);try{await this.storage.onComplete(o,n)}catch(u){throw this.logger?.error("[onComplete error]: %O",u),u}const{headers:d,statusCode:c,...f}=n,{content:O,stream:w,...g}=f;return this.createResponse({body:g,headers:d||s,statusCode:c||r||200})}const l={...s,...e.headers},a=this.convertHeaders({...l,"Access-Control-Expose-Headers":"location,upload-expires,upload-offset,upload-length,upload-metadata,upload-defer-length,tus-resumable,tus-extension,tus-max-size,tus-version,tus-checksum-algorithm,cache-control",...o.hash===void 0?{}:{[`X-Range-${o.hash?.algorithm.toUpperCase()}`]:o.hash?.value}}),h=e.headers||{};h.Location&&!a.location&&!a.Location?a.location=String(h.Location):h.location&&!a.location&&!a.Location?a.location=String(h.location):s.Location&&!a.location&&!a.Location?a.location=String(s.Location):s.location&&!a.location&&!a.Location&&(a.location=String(s.location));let i;return r>=200&&r<300&&(i=Object.keys(o).length>0?{...o}:{},"content"in i&&delete i.content,"stream"in i&&delete i.stream,Object.keys(i).length===0&&(i={})),this.createResponse({body:i,headers:a,statusCode:r||200})}convertHeaders(t){const e={};for(const[s,r]of Object.entries(t))e[s]=Array.isArray(r)?r.join(", "):String(r);return e}createResponse(t){const{body:e,headers:s={},statusCode:r}=t;let o;return r===204?o=null:typeof e=="string"?o=e:e instanceof Buffer?o=new Uint8Array(e):e&&typeof e=="object"?(o=JSON.stringify(e),s["Content-Type"]||(s["Content-Type"]=p.createContentType({charset:"utf8",mediaType:"application/json"}))):e===void 0&&r!==void 0&&r>=200&&r<300&&(o="{}",s["Content-Type"]||(s["Content-Type"]=p.createContentType({charset:"utf8",mediaType:"application/json"}))),new Response(o,{headers:this.convertHeaders(s),status:r})}async createErrorResponse(t){let e;C(t)?e=this.internalErrorResponses[t.UploadErrorCode]:!H(t)&&!y.isHttpError(t)?e=this.storage.normalizeError(t):e={...t,code:t.code||t.name,headers:t.headers||{},message:t.message,name:t.name,statusCode:t.statusCode||500},await this.storage.onError(e);let s;return e.body?typeof e.body=="object"&&e.body!==null?s={body:e.body,headers:e.headers,statusCode:e.statusCode}:s={body:{error:{code:e.code||e.name||"Error",message:e.body||e.message||"Unknown error",name:e.name||"Error"}},headers:e.headers,statusCode:e.statusCode||500}:s={body:{error:{code:e.code||e.name||"Error",message:e.message||"Unknown error",name:e.name||"Error"}},headers:e.headers,statusCode:e.statusCode||500},this.createResponse(s)}buildFileUrl(t,e){return this.buildFileUrlFromString(t.url,e)}negotiateContentType(t,e){return super.negotiateContentTypeFromHeader(t.headers.get("accept")||void 0,e)}}export{U as B};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{paginate as L}from"@visulima/pagination";import{H as b,h as P,c as C}from"./headers-erjZrwbT.js";import S from"mime";import{ERRORS as g,isUploadError as x}from"./ERRORS-olUcTqo2.js";import{match as _}from"path-to-regexp";import{p as F,B as j,s as R,c as U,u as H}from"./base-handler-core-BvNgdV-9.js";import{i as k}from"./storage-uypoNkqu.js";import{waitForStorage as z}from"./waitForStorage-afkqWeuz.js";import{PassThrough as D}from"node:stream";import{e as v}from"./response-builder-tJ84C7n4.js";const $=_(["/:uuid","/*path/:uuid.:ext/:metadata","/*path/:uuid/:metadata","/*path/:uuid.:ext","/*path/:uuid"],{decode:decodeURIComponent}),N=c=>{const e=$(c);if(!e)return;const{params:t}=e;if(!t.uuid)return;const r={uuid:t.uuid};return t.metadata!==void 0&&(r.metadata=t.metadata),t.path!==void 0&&(r.path=t.path),t.ext!==void 0&&(r.ext=t.ext),{params:r,path:e.path}},I=(c,e,t)=>{let r=0,a=0;const s=t-e+1,o=new D({highWaterMark:Math.min(64*1024,s),transform(n,i,d){const h=n.length,u=r,m=u+h-1;if(r+=h,m<e){d();return}if(u>t){this.end(),d();return}const f=Math.max(0,e-u),p=Math.min(h,t-u+1);if(f<p){const E=n.subarray(f,p);a+=E.length,this.push(E)||c.pause()}a>=s&&(this.end(),c.destroy()),d()}});return c.pipe(o),c.on("error",n=>{o.destroy(n)}),o},W=(c,e,t)=>{let r=!1;const a=()=>{r||(r=!0,c.destroy())};e.on("drain",()=>{c.resume()}),e.on("close",a),e.on("finish",a),e.on("error",a),c.on("end",()=>{e.end()}),c.on("error",async s=>{if(!r){if(e.headersSent||e.writableEnded){a(),e.destroy(s);return}try{await t(e,s)}catch{e.destroy(s)}finally{a()}}}),c.on("data",s=>{e.write(s)||c.pause()}),typeof e.listeners=="function"&&e.listeners("close")?.length===0&&e.on("close",a)},X=(c,e,t)=>{const{headers:r,statusCode:a}=c;e(t,{headers:r,statusCode:a})},B=(c,e,t,r,a,s,o)=>{e.body=c?.data===void 0?c:c.data;const{headers:n,statusCode:i}=c,d=c;if(d.stream)if(typeof r=="function")r();else{const h=o(e.headers.range,d.size||0);s(t,d.stream,{headers:n,range:h||void 0,size:d.size,statusCode:i})}else{let h="";c.content!==void 0?h=c.content:typeof c=="object"&&"data"in c&&(h=c.data),typeof r=="function"?r():a(t,{body:h,headers:n,statusCode:i})}},G=async(c,e,t,r,a,s,o)=>{const{headers:n,statusCode:i,...d}=c;if(typeof r=="function")e._body=!0,e.body=d,r();else{const h=c,u=h.headers?{...h.headers}:{};h.headers===void 0&&(h.headers={}),h.statusCode===void 0&&(h.statusCode=200);try{const m=a.onComplete(d,h,e);m instanceof Promise&&await m}catch(m){throw s?.error&&s.error("[onComplete error]: %O",m),m}Object.keys(h.headers||{}).length===0&&Object.keys(u).length>0?h.headers=u:h.headers&&Object.keys(u).length>0&&(h.headers={...u,...h.headers}),o(e,t,h)}},J=(c,e,t,r)=>{const{headers:a,statusCode:s,...o}=c,n=a||{},i=n["X-Chunked-Upload"]==="true"||n["x-chunked-upload"]==="true";let d;const h={...v(n),...a?v(a):{},...o.hash===void 0?{}:{[`X-Range-${o.hash?.algorithm.toUpperCase()}`]:String(o.hash?.value)}};i&&(d=JSON.stringify(o),!h["Content-Type"]&&!h["content-type"]&&(h["Content-Type"]="application/json; charset=utf-8")),e.method==="HEAD"&&(d=""),r(t,{body:d,headers:h,statusCode:s||200})},V=async(c,e,t,r,a,s,o)=>{const n=c instanceof Error?c:new Error(String(c)),d={...F(n,["name",...Object.getOwnPropertyNames(n)]),request:F(e,["headers","method","url"])};r("error")>0&&t("error",d),a?.error&&a.error("[error]: %O",d),await s(o,n)},y="Content-Type";class A extends j{static methods=["delete","get","head","options","patch","post","put"];registeredHandlers=new Map;constructor(e){super(e),this.compose()}get handlers(){return this.registeredHandlers}handle=async(e,t)=>this.upload(e,t);upload=async(e,t,r)=>{e.on("error",s=>this.logger?.error("[request error]: %O",s)),this.logger?.debug("[request]: %s %s",e.method,e.url);const a=this.registeredHandlers.get(e.method);if(!a){await this.sendError(t,{UploadErrorCode:g.METHOD_NOT_ALLOWED});return}try{await z(this.storage)}catch{await this.sendError(t,{UploadErrorCode:g.STORAGE_ERROR});return}try{const s=await a.call(this,e,t);if(["HEAD","OPTIONS"].includes(e.method))X(s,this.send.bind(this),t);else if(e.method==="GET"){const o=s;o&&B(o,e,t,r,this.send.bind(this),this.sendStream.bind(this),this.parseRangeHeader.bind(this))}else{const{headers:o,statusCode:n,...i}=s;this.logger?.debug("[%s]: %s: %d/%d",i.status,i.name,i.bytesWritten,i.size),i.status!==void 0&&this.listenerCount(i.status)>0&&this.emit(i.status,{...i,request:F(e,["headers","method","url"])}),i.status==="completed"?await G(s,e,t,r,this.storage,this.logger,(d,h,u)=>{this.finish(d,h,u)}):J(s,e,t,(d,h)=>{this.send(d,{body:h.body,headers:h.headers,statusCode:h.statusCode})})}}catch(s){await V(s,e,this.emit.bind(this),this.listenerCount.bind(this),this.logger,this.sendError.bind(this),t)}};send(e,{body:t="",headers:r={},statusCode:a=200}){let s;const o={...r};if(typeof t=="string"){if(s=t,o[y]===void 0)o[y]=b.createContentType({mediaType:"text/plain"});else{const n=Array.isArray(o[y])?o[y].join(", "):String(o[y]);o[y]=b.ensureCharset(n)}o["Content-Length"]===void 0&&(o["Content-Length"]=Buffer.byteLength(t))}else t instanceof Buffer?s=t:(s=JSON.stringify(t),o[y]||(o[y]=b.createContentType({charset:"utf8",mediaType:"application/json"})));R(e,o),e.statusCode=a,e.end(s)}async sendError(e,t){let r;x(t)?r=this.internalErrorResponses[t.UploadErrorCode]:!k(t)&&!P.isHttpError(t)?r=this.storage.normalizeError(t):r={...t,code:t.code||t.name,headers:t.headers||{},message:t.message,name:t.name,statusCode:t.statusCode||500},await this.storage.onError(r);let a;r.body?typeof r.body=="object"&&r.body!==null?a={body:r.body,headers:r.headers,statusCode:r.statusCode}:a={body:{error:{code:r.code||r.name||"Error",message:r.body||r.message||"Unknown error",name:r.name||"Error"}},headers:r.headers,statusCode:r.statusCode||500}:a={body:{error:{code:r.code||r.name||"Error",message:r.message||"Unknown error",name:r.name||"Error"}},headers:r.headers,statusCode:r.statusCode||500},this.send(e,a)}sendStream(e,t,{headers:r={},range:a,size:s,statusCode:o=200}){R(e,r),e.statusCode=o;let n=t;a&&s?(e.statusCode=206,e.setHeader("Content-Range",`bytes ${a.start}-${a.end}/${s}`),e.setHeader("Content-Length",a.end-a.start+1),e.setHeader("Accept-Ranges","bytes"),n=I(t,a.start,a.end)):(s&&e.setHeader("Content-Length",s),e.setHeader("Accept-Ranges","bytes")),W(n,e,(i,d)=>this.sendError(i,d))}finish(e,t,r){const a="id"in r&&"headers"in r&&!("body"in r);let s,o,n;if(a){const i=r,d=i.headers||{},h=i.statusCode||200,{headers:u,statusCode:m,...f}=i;s=f,o={...d},n=h}else{const i=r;s=i.body,o=i.headers||{},n=i.statusCode||200}if(s&&typeof s=="object"&&s.content!==void 0){const{content:i,contentType:d}=s;s=i,o={...o,"Content-Type":d}}this.send(t,{body:s||r,headers:o,statusCode:n})}buildFileUrl(e,t){return this.buildFileUrlFromString(e.originalUrl||e.url,t,e.headers)}negotiateContentType(e,t){return super.negotiateContentTypeFromHeader(e.headers.accept,t)}async options(e,t){return{headers:{"Access-Control-Allow-Methods":(this.constructor.methods||A.methods).map(a=>a.toUpperCase()).join(", ")},statusCode:204}}async get(e,t){const r=N(U(e));if(r?.params.uuid){const{ext:a,metadata:s,uuid:o}=r.params,n=a?o.replace(new RegExp(String.raw`\.${a}$`),""):o;if(s==="metadata"&&U(e).endsWith("/metadata"))try{const i=await this.storage.getMeta(n);return{...i,content:JSON.stringify(i),headers:{"Content-Type":b.createContentType({charset:"utf8",mediaType:"application/json"}),...i.expiredAt===void 0?{}:{"X-Upload-Expires":i.expiredAt.toString()},...i.modifiedAt===void 0?{}:{"Last-Modified":i.modifiedAt.toString()}},statusCode:200}}catch(i){const d=i;throw d.UploadErrorCode===g.FILE_NOT_FOUND||d.UploadErrorCode===g.GONE?C(404,"File metadata not found"):i}if(!H.test(n))return this.list(e,t);try{const i=new URL(e.url||"","http://localhost"),d=Object.fromEntries(i.searchParams.entries());if(Object.keys(d).length>0&&this.mediaTransformer&&this.mediaTransformer)try{const l=await this.mediaTransformer.handle(n,d);return{content:l.buffer,headers:{"Content-Length":String(l.size),"Content-Type":`${l.mediaType}/${l.format}`,"X-Media-Type":l.mediaType,"X-Original-Format":l.originalFile?.contentType?.split("/")[1]||"","X-Transformed-Format":l.format,...l.originalFile?.expiredAt===void 0?{}:{"X-Upload-Expires":l.originalFile.expiredAt.toString()},...l.originalFile?.modifiedAt===void 0?{}:{"Last-Modified":l.originalFile.modifiedAt.toString()},...l.originalFile?.ETag===void 0?{}:{ETag:l.originalFile.ETag}},statusCode:200}}catch(l){if(l.name==="ValidationError")throw C(400,l.message);this.logger?.warn(`Media transformation failed: ${l.message}`)}const u=await this.storage.getMeta(n);if((e.headers.range||u.size&&u.size>1024*1024)&&this.storage.getStream)try{const l=await this.storage.getStream({id:n});let T=l.headers?.["Content-Type"]||u.contentType;return T.includes("image")&&typeof a=="string"&&(T=S.getType(a)||T),{headers:{...l.headers,"Accept-Ranges":"bytes","Content-Type":T},size:l.size,statusCode:200,stream:l.stream,...u,contentType:T}}catch(l){this.logger?.warn(`Streaming failed, falling back to buffer: ${l}`)}const f=await this.storage.get({id:n});let{contentType:p}=f;p.includes("image")&&typeof a=="string"&&(p=S.getType(a)||p);const{ETag:E,expiredAt:w,modifiedAt:O,size:M}=f;return{headers:{"Accept-Ranges":"bytes","Content-Length":String(M),"Content-Type":p,...w===void 0?{}:{"X-Upload-Expires":w.toString()},...O===void 0?{}:{"Last-Modified":O.toString()},...E===void 0?{}:{ETag:E}},statusCode:200,...f,contentType:p}}catch(i){const d=i;throw d.UploadErrorCode===g.FILE_NOT_FOUND||d.UploadErrorCode===g.GONE?C(404,"File not found"):i}}return this.list(e,t)}async list(e,t){const r=new URL(e.url||"","http://localhost"),a=r.searchParams.get("limit"),s=r.searchParams.get("page"),o=await this.storage.list(Number(a||1e3));if(o.length===0)return{data:[],headers:{},statusCode:200};const n=Number(s),i=Number(a);return s!==null&&a!==null&&Number.isFinite(n)&&Number.isFinite(i)?{data:L(n,i,o.length,o),headers:{},statusCode:200}:{data:o,headers:{},statusCode:200}}async download(e,t){const r=N(U(e));if(!r?.params.uuid||!H.test(r.params.uuid))throw C(404,"File not found");const{ext:a,uuid:s}=r.params;try{const o=await this.storage.getMeta(s);if(!this.storage.getStream){await this.sendError(t,C(501,"Streaming download not supported"));return}const n=await this.storage.getStream({id:s});let i=n.headers?.["Content-Type"]||o.contentType;i.includes("image")&&typeof a=="string"&&(i=S.getType(a)||i);const d=this.parseRangeHeader(e.headers.range,n.size||0),h={...n.headers,"Accept-Ranges":"bytes","Content-Disposition":b.createContentDisposition({filename:o.originalName||s,type:"attachment"}),"Content-Type":i};this.sendStream(t,n.stream,{headers:h,range:d||void 0,size:n.size,statusCode:d?206:200})}catch(o){const n=o;if(n.UploadErrorCode===g.FILE_NOT_FOUND||n.UploadErrorCode===g.GONE){await this.sendError(t,C(404,"File not found"));return}await this.sendError(t,o)}}checkForUndefinedIdOrPath(e){if(e instanceof Error&&["Id is undefined","Invalid request URL","Path is undefined"].includes(e.message))throw C(404,"File not found")}}export{A as B};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{tool as n}from"@anthropic-ai/claude-agent-sdk";import{T as i,e as a}from"./executors-DgKT6b1T.js";const s={readOnlyHint:!0},r={destructiveHint:!0,readOnlyHint:!1},d={destructiveHint:!1,idempotentHint:!0,readOnlyHint:!1},p=e=>({content:[{text:typeof e=="string"?e:JSON.stringify(e),type:"text"}]}),c=e=>({content:[{text:e instanceof Error?e.message:String(e),type:"text"}],isError:!0}),o=e=>async t=>{try{return p(await e(t))}catch(l){return c(l)}},g=e=>n("listFiles",i.listFiles.description,i.listFiles.input.shape,o(t=>a.listFiles(e,t)),{annotations:s}),U=e=>n("getFileMetadata",i.getFileMetadata.description,i.getFileMetadata.input.shape,o(t=>a.getFileMetadata(e,t)),{annotations:s}),y=e=>n("downloadFile",i.downloadFile.description,i.downloadFile.input.shape,o(t=>a.downloadFile(e,t)),{annotations:s}),O=e=>n("getFileUrl",i.getFileUrl.description,i.getFileUrl.input.shape,o(t=>a.getFileUrl(e,t)),{annotations:s}),T=(e,{annotations:t=r}={})=>n("uploadFile",i.uploadFile.description,i.uploadFile.input.shape,o(l=>a.uploadFile(e,l)),{annotations:t}),N=(e,{annotations:t=r}={})=>n("deleteFile",i.deleteFile.description,i.deleteFile.input.shape,o(l=>a.deleteFile(e,l)),{annotations:t}),h=(e,{annotations:t=d}={})=>n("copyFile",i.copyFile.description,i.copyFile.input.shape,o(l=>a.copyFile(e,l)),{annotations:t}),f=(e,{annotations:t=d}={})=>n("signUploadUrl",i.signUploadUrl.description,i.signUploadUrl.input.shape,o(l=>a.signUploadUrl(e,l)),{annotations:t});export{h as claudeCopyFile,N as claudeDeleteFile,y as claudeDownloadFile,U as claudeGetFileMetadata,O as claudeGetFileUrl,g as claudeListFiles,f as claudeSignUploadUrl,T as claudeUploadFile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=e=>{const s=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.CLOUDFLARE_ACCESS_KEY_ID??process.env.CLOUDFLARE_ACCESS_KEY,c=e?.accountId??process.env.CLOUDFLARE_ACCOUNT_ID,o=e?.jurisdiction??process.env.CLOUDFLARE_JURISDICTION??process.env.CLOUDFLARE_R2_JURISDICTION,n=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.CLOUDFLARE_SECRET_ACCESS_KEY??process.env.CLOUDFLARE_SECRET_KEY;if(!c||!s||!n)throw new Error("Missing required parameters for Cloudflare R2 client.");return{credentials:{accessKeyId:s,secretAccessKey:n},endpoint:`https://${c}.${o?`${o}.`:""}r2.cloudflarestorage.com`,region:"auto"}};export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{toolDefinition as l}from"@tanstack/ai";import{T as e,e as n}from"./executors-DgKT6b1T.js";const s=i=>l({description:e.listFiles.description,inputSchema:e.listFiles.input,name:"listFiles"}).server(t=>n.listFiles(i,t)),a=i=>l({description:e.getFileMetadata.description,inputSchema:e.getFileMetadata.input,name:"getFileMetadata"}).server(t=>n.getFileMetadata(i,t)),d=i=>l({description:e.downloadFile.description,inputSchema:e.downloadFile.input,name:"downloadFile"}).server(t=>n.downloadFile(i,t)),c=i=>l({description:e.getFileUrl.description,inputSchema:e.getFileUrl.input,name:"getFileUrl"}).server(t=>n.getFileUrl(i,t)),F=(i,{needsApproval:t=!0}={})=>l({description:e.uploadFile.description,inputSchema:e.uploadFile.input,name:"uploadFile",needsApproval:t}).server(o=>n.uploadFile(i,o)),u=(i,{needsApproval:t=!0}={})=>l({description:e.deleteFile.description,inputSchema:e.deleteFile.input,name:"deleteFile",needsApproval:t}).server(o=>n.deleteFile(i,o)),m=(i,{needsApproval:t=!0}={})=>l({description:e.copyFile.description,inputSchema:e.copyFile.input,name:"copyFile",needsApproval:t}).server(o=>n.copyFile(i,o)),g=(i,{needsApproval:t=!0}={})=>l({description:e.signUploadUrl.description,inputSchema:e.signUploadUrl.input,name:"signUploadUrl",needsApproval:t}).server(o=>n.signUploadUrl(i,o));export{m as copyFile,u as deleteFile,d as downloadFile,a as getFileMetadata,c as getFileUrl,s as listFiles,g as signUploadUrl,F as uploadFile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{tool as l}from"ai";import{T as e,e as o}from"./executors-DgKT6b1T.js";const d=i=>l({description:e.listFiles.description,execute:t=>o.listFiles(i,t),inputSchema:e.listFiles.input}),s=i=>l({description:e.getFileMetadata.description,execute:t=>o.getFileMetadata(i,t),inputSchema:e.getFileMetadata.input}),a=i=>l({description:e.downloadFile.description,execute:t=>o.downloadFile(i,t),inputSchema:e.downloadFile.input}),r=i=>l({description:e.getFileUrl.description,execute:t=>o.getFileUrl(i,t),inputSchema:e.getFileUrl.input}),u=(i,{needsApproval:t=!0}={})=>l({description:e.uploadFile.description,execute:n=>o.uploadFile(i,n),inputSchema:e.uploadFile.input,needsApproval:t}),F=(i,{needsApproval:t=!0}={})=>l({description:e.deleteFile.description,execute:n=>o.deleteFile(i,n),inputSchema:e.deleteFile.input,needsApproval:t}),g=(i,{needsApproval:t=!0}={})=>l({description:e.copyFile.description,execute:n=>o.copyFile(i,n),inputSchema:e.copyFile.input,needsApproval:t}),m=(i,{needsApproval:t=!0}={})=>l({description:e.signUploadUrl.description,execute:n=>o.signUploadUrl(i,n),inputSchema:e.signUploadUrl.input,needsApproval:t});export{g as copyFile,F as deleteFile,a as downloadFile,s as getFileMetadata,r as getFileUrl,d as listFiles,m as signUploadUrl,u as uploadFile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as m}from"./approval-DcuhtQKs.js";import{T as F,W as h,e as a}from"./executors-DgKT6b1T.js";import*as f from"zod";const S=t=>{const o=f.toJSONSchema(t),{$schema:u,...l}=o;return l},k=["listFiles","getFileMetadata","downloadFile","getFileUrl","uploadFile","deleteFile","copyFile","signUploadUrl"],p=t=>h.has(t),O=async(t,o,u)=>{const r=F[o].input.safeParse(u);if(!r.success)return{issues:r.error.issues,ok:!1};switch(o){case"copyFile":return{ok:!0,output:await a.copyFile(t,r.data)};case"deleteFile":return{ok:!0,output:await a.deleteFile(t,r.data)};case"downloadFile":return{ok:!0,output:await a.downloadFile(t,r.data)};case"getFileMetadata":return{ok:!0,output:await a.getFileMetadata(t,r.data)};case"getFileUrl":return{ok:!0,output:await a.getFileUrl(t,r.data)};case"listFiles":return{ok:!0,output:await a.listFiles(t,r.data)};case"signUploadUrl":return{ok:!0,output:await a.signUploadUrl(t,r.data)};case"uploadFile":return{ok:!0,output:await a.uploadFile(t,r.data)};default:{const c=o;throw new Error(`Unhandled tool: ${String(c)}`)}}},v=({files:t,overrides:o,readOnly:u=!1,requireApproval:l=!0})=>{const r=k.filter(e=>!(u&&p(e))),c=e=>p(e)?m(e,l):!1,g=r.map(e=>{const s=F[e],i=o?.[e];return{description:i?.description??s.description,name:e,parameters:S(s.input),strict:i?.strict??!1,type:"function"}}),w=new Set(r);return{definitions:g,execute:async e=>{const s=n=>({call_id:e.call_id,output:typeof n=="string"?n:JSON.stringify(n),type:"function_call_output"});if(!w.has(e.name))return s({error:`Unknown tool: ${e.name}`});let i;try{i=JSON.parse(e.arguments)}catch(n){return s({error:`Invalid JSON in arguments: ${n.message}`})}const d=await O(t,e.name,i);return d.ok?s(d.output):s({error:"Argument validation failed",issues:d.issues})},needsApproval:c}};export{v as createResponsesFileTools};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o={backoffMultiplier:2,calculateDelay:void 0,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:()=>{}},R=(t,r,u,e)=>{const i=Math.min(r*u**t,e);return Math.floor(Math.random()*i)},m=t=>new Promise(r=>{setTimeout(r,t)}),h=(t,r=o.retryableStatusCodes)=>{if(t instanceof Error){const e=t.code,i=t.name;if(i==="AbortError"||e==="ABORT_ERR")return!1;if(e==="ECONNRESET"||e==="ETIMEDOUT"||e==="ENOTFOUND"||e==="ECONNREFUSED"||e==="EAI_AGAIN"||i==="NetworkError"||i==="TimeoutError")return!0;const a=t;if(a.$metadata){const c=a.$metadata.httpStatusCode;if(c&&r.includes(c)||a.$fault==="server")return!0}if(a.statusCode&&r.includes(a.statusCode))return!0;const{retryable:s}=a;return s===!0||typeof s=="string"&&s==="true"}return!1},C=async(t,r={})=>{const{backoffMultiplier:u=o.backoffMultiplier,calculateDelay:e=o.calculateDelay,initialDelay:i=o.initialDelay,maxDelay:a=o.maxDelay,maxRetries:s=o.maxRetries,onRetry:c,retryableStatusCodes:d=o.retryableStatusCodes,shouldRetry:E=o.shouldRetry}=r;let y;for(let l=0;l<=s;l+=1)try{return await t()}catch(n){if(y=n,l>=s)break;if(!(E(n)??h(n,d)))throw n;const f=e?e(l,n):R(l,i,u,a);if(c)try{c(l+1,n)}catch{}f!==void 0&&f>0&&await m(f)}throw y},p=(t={})=>r=>C(r,t);export{p as createRetryWrapper,h as isRetryableError,C as retry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PassThrough as h,Transform as l}from"node:stream";import{fileTypeFromBuffer as m}from"file-type";const g=async n=>{try{return await m(n)}catch{return}},S=async(n,y)=>{let c;const a=[];let f=0,o=!1,s;const r=new h({highWaterMark:0}),i=new l({flush(e){!o&&a.length>0&&(o=!0,s=m(Buffer.concat(a)).then(t=>(c=t,t)).catch(()=>{})),e()},objectMode:!1,transform(e,t,p){if(!o&&(a.push(e),f+=e.length,f>=4100)){o=!0;const d=Buffer.concat(a);s=m(d).then(u=>(c=u,u)).catch(()=>{})}p(void 0,e)}});return n.pipe(i).pipe(r),n.on("error",e=>{i.destroy(e),r.destroy(e)}),i.on("error",e=>{r.destroyed||r.destroy(e)}),await Promise.race([new Promise(e=>{if(o){e();return}const t=setTimeout(e,10);i.once("data",()=>{clearTimeout(t),e()}),i.once("end",()=>{clearTimeout(t),e()})}),new Promise(e=>{setTimeout(e,10)})]),s&&await Promise.race([s.then(()=>{}),new Promise(e=>{setTimeout(e,150)})]).catch(()=>{}),{fileType:c,stream:r}};export{S as a,g as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=e=>{const s=e?.key??process.env.AWS_ACCESS_KEY_ID??process.env.SPACES_KEY,c=e?.region??process.env.AWS_REGION??process.env.SPACES_REGION,n=e?.secret??process.env.AWS_SECRET_ACCESS_KEY??process.env.SPACES_SECRET;if(!c||!s||!n)throw new Error("Missing required parameters for DigitalOcean Spaces client.");return{credentials:{accessKeyId:s,secretAccessKey:n},endpoint:`https://${c}.digitaloceanspaces.com`,forcePathStyle:!1,region:"us-east-1"}};export{r as default};
|