@visulima/storage 1.0.10 → 1.0.11
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 +10 -0
- package/dist/adapter/nuxt/module.d.ts +5 -4
- package/dist/ai/ai-sdk/index.d.ts +4 -3
- package/dist/ai/claude/index.d.ts +3 -2
- package/dist/ai/openai/index.d.ts +4 -3
- package/dist/ai/tanstack/index.d.ts +3 -2
- package/dist/handler/http/fetch/index.d.ts +8 -7
- package/dist/handler/http/fetch/index.js +1 -1
- package/dist/handler/http/hono/index.d.ts +5 -4
- package/dist/handler/http/hono/index.js +1 -1
- package/dist/handler/http/nextjs/index.d.ts +5 -4
- package/dist/handler/http/nextjs/index.js +1 -1
- package/dist/handler/http/node/index.d.ts +8 -7
- package/dist/handler/http/node/index.js +1 -1
- package/dist/handler/http/solid-start/index.d.ts +5 -4
- package/dist/handler/http/solid-start/index.js +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.js +1 -1
- package/dist/packem_shared/{AbstractBaseStorage-CiPEMcuo.js → AbstractBaseStorage-CLsYmMZg.js} +1 -1
- package/dist/packem_shared/AwsLightStorage-DGSPFUqr.js +1 -0
- package/dist/packem_shared/AzureStorage-DvKk_hhz.js +1 -0
- package/dist/packem_shared/BoxMetaStorage-CJsyeQ63.js +1 -0
- package/dist/packem_shared/{BoxStorage-B8_oCz27.js → BoxStorage-CmM95wi2.js} +1 -1
- package/dist/packem_shared/BunS3MetaStorage-CJsyeQ63.js +1 -0
- package/dist/packem_shared/{BunS3Storage-_PVXu_na.js → BunS3Storage-B_roVJ29.js} +1 -1
- package/dist/packem_shared/BunnyMetaStorage-CJsyeQ63.js +1 -0
- package/dist/packem_shared/{BunnyStorage-BsoWjScH.js → BunnyStorage-eZ1QDVaY.js} +1 -1
- package/dist/packem_shared/CloudinaryMetaStorage-Bv_YCZ0Q.js +1 -0
- package/dist/packem_shared/{CloudinaryStorage-BNwiLF9V.js → CloudinaryStorage-CpH2f0Fv.js} +1 -1
- package/dist/packem_shared/DiskStorage-DzjjqCzo.js +1 -0
- package/dist/packem_shared/{DiskStorageWithChecksum-UnCtyEvs.js → DiskStorageWithChecksum-MZkDEyts.js} +1 -1
- package/dist/packem_shared/DropboxMetaStorage-CJsyeQ63.js +1 -0
- package/dist/packem_shared/{DropboxStorage-BS9kj0nH.js → DropboxStorage-BB9NoWK2.js} +1 -1
- package/dist/packem_shared/{Files-CpIcMjP0.js → Files-DyMJ9FPN.js} +1 -1
- package/dist/packem_shared/FirebaseMetaStorage-Bv_YCZ0Q.js +1 -0
- package/dist/packem_shared/{FirebaseStorage-DNquii2p.js → FirebaseStorage-BgbxzYNC.js} +1 -1
- package/dist/packem_shared/FtpMetaStorage-CJsyeQ63.js +1 -0
- package/dist/packem_shared/{FtpStorage-Bd004--s.js → FtpStorage-CNqXDz7P.js} +1 -1
- package/dist/packem_shared/{GCSMetaStorage-Bf4qDFB1.js → GCSMetaStorage-gEhWlpfS.js} +1 -1
- package/dist/packem_shared/{GCStorage-ChqEpgqR.js → GCStorage-CRd5vjok.js} +1 -1
- package/dist/packem_shared/GoogleDriveMetaStorage-B0gLF7Io.js +1 -0
- package/dist/packem_shared/{GoogleDriveStorage-v1glykjd.js → GoogleDriveStorage-Du7uBhSm.js} +1 -1
- package/dist/packem_shared/{LocalMetaStorage-YWPBYEe7.js → LocalMetaStorage-CcGfFG39.js} +1 -1
- package/dist/packem_shared/{MemoryStorage-9gbWd09l.js → MemoryStorage-ChKyI6OY.js} +1 -1
- package/dist/packem_shared/{Multipart-D0ok6BBy.js → Multipart-C35TR2qL.js} +1 -1
- package/dist/packem_shared/{Multipart-CQjYqU--.js → Multipart-V64Bg5dt.js} +1 -1
- package/dist/packem_shared/NetlifyBlobMetaStorage-Bv_YCZ0Q.js +1 -0
- package/dist/packem_shared/NetlifyBlobStorage-CZsr_0DF.js +1 -0
- package/dist/packem_shared/OneDriveMetaStorage-B0gLF7Io.js +1 -0
- package/dist/packem_shared/{OneDriveStorage-BJ3Kzxc5.js → OneDriveStorage-B8qFgMq1.js} +1 -1
- package/dist/packem_shared/PocketBaseMetaStorage-Cm3v8g1-.js +1 -0
- package/dist/packem_shared/{PocketBaseStorage-DqKHbbvn.js → PocketBaseStorage-D2vMN-oY.js} +1 -1
- package/dist/packem_shared/{Rest-CI_BiZPv.js → Rest-B7g1sgkq.js} +1 -1
- package/dist/packem_shared/{Rest-DvfN4-kf.js → Rest-BrEMYgxZ.js} +1 -1
- package/dist/packem_shared/{S3Storage-BiI2k6d1.js → S3Storage-CTe_BMDl.js} +1 -1
- package/dist/packem_shared/SftpMetaStorage-CJsyeQ63.js +1 -0
- package/dist/packem_shared/{SftpStorage-w8XdtZtw.js → SftpStorage-BKeAzuej.js} +1 -1
- package/dist/packem_shared/SharePointMetaStorage-CJsyeQ63.js +1 -0
- package/dist/packem_shared/{SharePointStorage-DpDpI7Ln.js → SharePointStorage-Dtnt5-wk.js} +1 -1
- package/dist/packem_shared/SupabaseMetaStorage-B0gLF7Io.js +1 -0
- package/dist/packem_shared/{SupabaseStorage-B_ugUCs7.js → SupabaseStorage-CmGQjqXf.js} +1 -1
- package/dist/packem_shared/{Tus-BlBZykIL.js → Tus-CJBgnJrn.js} +1 -1
- package/dist/packem_shared/{Tus-BBVt2ky3.js → Tus-D9c7KDnl.js} +1 -1
- package/dist/packem_shared/UploadThingMetaStorage-Bv_YCZ0Q.js +1 -0
- package/dist/packem_shared/{UploadThingStorage-_H45IVqX.js → UploadThingStorage-DZ4zNvDH.js} +1 -1
- package/dist/packem_shared/VercelBlobMetaStorage-CJsyeQ63.js +1 -0
- package/dist/packem_shared/{VercelBlobStorage-U1YMKeHs.js → VercelBlobStorage-DDNEofR3.js} +1 -1
- package/dist/packem_shared/{base-handler-core-D-9Ku1h-.js → base-handler-core-BJP9jHCE.js} +1 -1
- package/dist/packem_shared/{base-handler-fetch-CfkNakv8.js → base-handler-fetch-yrYrukwL.js} +1 -1
- package/dist/packem_shared/base-handler-node-C8P9rkaH.js +1 -0
- package/dist/packem_shared/{createRetryWrapper-CxgiV_hH.js → createRetryWrapper-DgmeHPNF.js} +1 -1
- package/dist/packem_shared/disk-storage-DqnnFQAQ.js +1 -0
- package/dist/packem_shared/{disk-storage-with-checksum.d-CQucFacO.d.ts → disk-storage-with-checksum.d-Dgwyza8a.d.ts} +1 -1
- package/dist/packem_shared/{executors.d-DeDH3Ilt.d.ts → executors.d-B9dIy3NT.d.ts} +2 -1
- package/dist/packem_shared/{files.d-D8H_ge9Y.d.ts → files.d-CmSZi3M0.d.ts} +1 -1
- package/dist/packem_shared/gcs-meta-storage-C9F78Sqq.js +1 -0
- package/dist/packem_shared/local-meta-storage-BELb1YwO.js +11 -0
- package/dist/packem_shared/{local-meta-storage.d-DuTEzyii.d.ts → local-meta-storage.d-cRTXr1kb.d.ts} +1 -1
- package/dist/packem_shared/{media-transformer.d-CvMFjINm.d.ts → media-transformer.d-C8tn4J2Z.d.ts} +2 -2
- package/dist/packem_shared/{memory-storage.d-BRdTiY8y.d.ts → memory-storage.d-BNZvDG1b.d.ts} +1 -1
- package/dist/packem_shared/path-C-OWflAo-_mqb5p5d.js +1 -0
- package/dist/packem_shared/{rest-base-e0reNDE_.js → rest-base-BQ_dhWyV.js} +1 -1
- package/dist/packem_shared/s3-base-storage-CX94H-Za.js +1 -0
- package/dist/packem_shared/{s3-base-storage.d-Cg7m4FuH.d.ts → s3-base-storage.d-ks99NSs-.d.ts} +1 -1
- package/dist/packem_shared/storage-DR7qdwBN.js +1 -0
- package/dist/packem_shared/{storage.d-DIav_lF1.d.ts → storage.d-DwdJrArF.d.ts} +26 -3
- package/dist/packem_shared/{tus-base.d-BiEg5t4t.d.ts → tus-base.d-BKBoJVy0.d.ts} +4 -3
- package/dist/packem_shared/{types.d-DgHhkCAl.d.ts → types.d-B1_xZIhu.d.ts} +1 -1
- package/dist/packem_shared/{types.d-CAAzKiI6.d.ts → types.d-BEUv414z.d.ts} +1 -1
- package/dist/packem_shared/{types.d-jAs_Rp_v.d.ts → types.d-D7Zlz5RE.d.ts} +2 -2
- package/dist/storage/aws/index.d.ts +3 -2
- package/dist/storage/aws/index.js +1 -1
- package/dist/storage/aws-light/index.d.ts +3 -2
- package/dist/storage/aws-light/index.js +1 -1
- package/dist/storage/azure/index.d.ts +2 -1
- package/dist/storage/azure/index.js +1 -1
- package/dist/storage/box/index.d.ts +3 -2
- package/dist/storage/box/index.js +1 -1
- package/dist/storage/bun-s3/index.d.ts +3 -2
- package/dist/storage/bun-s3/index.js +1 -1
- package/dist/storage/bunny/index.d.ts +3 -2
- package/dist/storage/bunny/index.js +1 -1
- package/dist/storage/cloudinary/index.d.ts +3 -2
- package/dist/storage/cloudinary/index.js +1 -1
- package/dist/storage/dropbox/index.d.ts +3 -2
- package/dist/storage/dropbox/index.js +1 -1
- package/dist/storage/firebase/index.d.ts +3 -2
- package/dist/storage/firebase/index.js +1 -1
- package/dist/storage/ftp/index.d.ts +3 -2
- package/dist/storage/ftp/index.js +1 -1
- package/dist/storage/gcs/index.d.ts +2 -1
- package/dist/storage/gcs/index.js +1 -1
- package/dist/storage/google-drive/index.d.ts +3 -2
- package/dist/storage/google-drive/index.js +1 -1
- package/dist/storage/local/index.d.ts +4 -3
- package/dist/storage/local/index.js +1 -1
- package/dist/storage/memory/index.d.ts +3 -2
- package/dist/storage/memory/index.js +1 -1
- package/dist/storage/netlify-blob/index.d.ts +3 -2
- package/dist/storage/netlify-blob/index.js +1 -1
- package/dist/storage/onedrive/index.d.ts +5 -4
- package/dist/storage/onedrive/index.js +1 -1
- package/dist/storage/pocketbase/index.d.ts +3 -2
- package/dist/storage/pocketbase/index.js +1 -1
- package/dist/storage/sftp/index.d.ts +3 -2
- package/dist/storage/sftp/index.js +1 -1
- package/dist/storage/sharepoint/index.d.ts +4 -3
- package/dist/storage/sharepoint/index.js +1 -1
- package/dist/storage/supabase/index.d.ts +3 -2
- package/dist/storage/supabase/index.js +1 -1
- package/dist/storage/uploadthing/index.d.ts +3 -2
- package/dist/storage/uploadthing/index.js +1 -1
- package/dist/storage/vercel-blob/index.d.ts +3 -2
- package/dist/storage/vercel-blob/index.js +1 -1
- package/dist/transformer/audio-transformer.d.ts +3 -2
- package/dist/transformer/image-transformer.d.ts +3 -2
- package/dist/transformer/index.d.ts +4 -3
- package/dist/transformer/video-transformer.d.ts +3 -2
- package/package.json +2 -2
- package/dist/packem_shared/AwsLightStorage-EsqkAtU5.js +0 -1
- package/dist/packem_shared/AzureStorage-DL-U7qFG.js +0 -1
- package/dist/packem_shared/BoxMetaStorage-CHWrhgg2.js +0 -1
- package/dist/packem_shared/BunS3MetaStorage-CHWrhgg2.js +0 -1
- package/dist/packem_shared/BunnyMetaStorage-CHWrhgg2.js +0 -1
- package/dist/packem_shared/CloudinaryMetaStorage-BI9YXcwU.js +0 -1
- package/dist/packem_shared/DiskStorage-D-NtQDms.js +0 -1
- package/dist/packem_shared/DropboxMetaStorage-CHWrhgg2.js +0 -1
- package/dist/packem_shared/FirebaseMetaStorage-BI9YXcwU.js +0 -1
- package/dist/packem_shared/FtpMetaStorage-CHWrhgg2.js +0 -1
- package/dist/packem_shared/GoogleDriveMetaStorage-xlHfKwmR.js +0 -1
- package/dist/packem_shared/NetlifyBlobMetaStorage-BI9YXcwU.js +0 -1
- package/dist/packem_shared/NetlifyBlobStorage-BPyEWSnx.js +0 -1
- package/dist/packem_shared/OneDriveMetaStorage-xlHfKwmR.js +0 -1
- package/dist/packem_shared/PocketBaseMetaStorage-DnrxOQhO.js +0 -1
- package/dist/packem_shared/SftpMetaStorage-CHWrhgg2.js +0 -1
- package/dist/packem_shared/SharePointMetaStorage-CHWrhgg2.js +0 -1
- package/dist/packem_shared/SupabaseMetaStorage-xlHfKwmR.js +0 -1
- package/dist/packem_shared/UploadThingMetaStorage-BI9YXcwU.js +0 -1
- package/dist/packem_shared/VercelBlobMetaStorage-CHWrhgg2.js +0 -1
- package/dist/packem_shared/base-handler-node-BF1v1qDa.js +0 -1
- package/dist/packem_shared/disk-storage-BwPk2IRa.js +0 -1
- package/dist/packem_shared/gcs-meta-storage-DQGu_cHq.js +0 -1
- package/dist/packem_shared/local-meta-storage-DJDcuxf1.js +0 -11
- package/dist/packem_shared/path-0oTTdkvl-DvWvbDbh.js +0 -1
- package/dist/packem_shared/s3-base-storage-CMUui93V.js +0 -1
- package/dist/packem_shared/storage-0j5nCAUp.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## @visulima/storage [1.0.11](https://github.com/visulima/visulima/compare/%40visulima%2Fstorage%401.0.10...%40visulima%2Fstorage%401.0.11) (2026-08-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Dependencies
|
|
5
|
+
|
|
6
|
+
* **@visulima/pagination:** upgraded to 6.0.0
|
|
7
|
+
* **@visulima/fs:** upgraded to 5.1.0
|
|
8
|
+
* **@visulima/humanizer:** upgraded to 3.1.0
|
|
9
|
+
* **@visulima/path:** upgraded to 3.1.0
|
|
10
|
+
|
|
1
11
|
## @visulima/storage [1.0.10](https://github.com/visulima/visulima/compare/%40visulima%2Fstorage%401.0.9...%40visulima%2Fstorage%401.0.10) (2026-07-27)
|
|
2
12
|
|
|
3
13
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { U as UploadOptions } from "../../packem_shared/types.d-
|
|
2
|
-
import { U as UploadFile, B as BaseStorage } from "../../packem_shared/storage.d-
|
|
1
|
+
import { U as UploadOptions } from "../../packem_shared/types.d-D7Zlz5RE.js";
|
|
2
|
+
import { U as UploadFile, B as BaseStorage } from "../../packem_shared/storage.d-DwdJrArF.js";
|
|
3
3
|
import 'node:stream';
|
|
4
4
|
import 'node:events';
|
|
5
5
|
import 'node:http';
|
|
6
6
|
import '@visulima/pagination';
|
|
7
|
-
import "../../packem_shared/media-transformer.d-
|
|
8
|
-
import "../../packem_shared/types.d-
|
|
7
|
+
import "../../packem_shared/media-transformer.d-C8tn4J2Z.js";
|
|
8
|
+
import "../../packem_shared/types.d-BEUv414z.js";
|
|
9
|
+
import 'node:timers';
|
|
9
10
|
import 'node:crypto';
|
|
10
11
|
import 'lru-cache';
|
|
11
12
|
/**
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { F as Files } from "../../packem_shared/files.d-
|
|
1
|
+
import { F as Files } from "../../packem_shared/files.d-CmSZi3M0.js";
|
|
2
2
|
import 'node:stream';
|
|
3
|
+
import 'node:timers';
|
|
3
4
|
import 'node:crypto';
|
|
4
5
|
import 'node:http';
|
|
5
6
|
import 'lru-cache';
|
|
6
7
|
import { C as CopyFileInput, D as DeleteFileInput, a as DownloadFileInput, G as GetFileMetadataInput, b as GetFileUrlInput, L as ListFilesInput, S as SignUploadUrlInput, U as UploadFileInput, F as FileToolName, A as ApprovalConfig, c as FileReadToolName } from "../../packem_shared/approval.d-C-d-t94D.js";
|
|
7
8
|
export type { d as FileWriteToolName } from "../../packem_shared/approval.d-C-d-t94D.js";
|
|
8
9
|
import { Tool } from 'ai';
|
|
9
|
-
import { e as executors } from "../../packem_shared/executors.d-
|
|
10
|
-
import "../../packem_shared/storage.d-
|
|
10
|
+
import { e as executors } from "../../packem_shared/executors.d-B9dIy3NT.js";
|
|
11
|
+
import "../../packem_shared/storage.d-DwdJrArF.js";
|
|
11
12
|
import 'zod';
|
|
12
13
|
/**
|
|
13
14
|
* Common options accepted by every write-tool factory.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { SdkMcpToolDefinition, CanUseTool, McpSdkServerConfigWithInstance } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
-
import { F as Files } from "../../packem_shared/files.d-
|
|
2
|
+
import { F as Files } from "../../packem_shared/files.d-CmSZi3M0.js";
|
|
3
3
|
import 'node:stream';
|
|
4
|
+
import 'node:timers';
|
|
4
5
|
import 'node:crypto';
|
|
5
6
|
import 'node:http';
|
|
6
7
|
import 'lru-cache';
|
|
7
8
|
import { T as TOOL_SCHEMAS, F as FileToolName, A as ApprovalConfig } from "../../packem_shared/approval.d-C-d-t94D.js";
|
|
8
9
|
export type { c as FileReadToolName, d as FileWriteToolName } from "../../packem_shared/approval.d-C-d-t94D.js";
|
|
9
|
-
import "../../packem_shared/storage.d-
|
|
10
|
+
import "../../packem_shared/storage.d-DwdJrArF.js";
|
|
10
11
|
import 'zod';
|
|
11
12
|
/**
|
|
12
13
|
* MCP tool annotations as accepted by `tool()` and exposed on
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { T as TOOL_SCHEMAS, F as FileToolName, A as ApprovalConfig, c as FileReadToolName } from "../../packem_shared/approval.d-C-d-t94D.js";
|
|
2
2
|
export type { d as FileWriteToolName } from "../../packem_shared/approval.d-C-d-t94D.js";
|
|
3
3
|
import { UnknownContext, FunctionTool } from '@openai/agents';
|
|
4
|
-
import { F as Files } from "../../packem_shared/files.d-
|
|
4
|
+
import { F as Files } from "../../packem_shared/files.d-CmSZi3M0.js";
|
|
5
5
|
import 'node:stream';
|
|
6
|
+
import 'node:timers';
|
|
6
7
|
import 'node:crypto';
|
|
7
8
|
import 'node:http';
|
|
8
9
|
import 'lru-cache';
|
|
9
|
-
import { e as executors } from "../../packem_shared/executors.d-
|
|
10
|
+
import { e as executors } from "../../packem_shared/executors.d-B9dIy3NT.js";
|
|
10
11
|
import 'zod';
|
|
11
|
-
import "../../packem_shared/storage.d-
|
|
12
|
+
import "../../packem_shared/storage.d-DwdJrArF.js";
|
|
12
13
|
/**
|
|
13
14
|
* Per-tool overrides for `createResponsesFileTools`. `name`, `parameters`, and
|
|
14
15
|
* `type` are intentionally not overridable — the contract that drives tool
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { F as Files } from "../../packem_shared/files.d-
|
|
1
|
+
import { F as Files } from "../../packem_shared/files.d-CmSZi3M0.js";
|
|
2
2
|
import 'node:stream';
|
|
3
|
+
import 'node:timers';
|
|
3
4
|
import 'node:crypto';
|
|
4
5
|
import 'node:http';
|
|
5
6
|
import 'lru-cache';
|
|
6
7
|
import { T as TOOL_SCHEMAS, c as FileReadToolName, F as FileToolName, A as ApprovalConfig } from "../../packem_shared/approval.d-C-d-t94D.js";
|
|
7
8
|
export type { d as FileWriteToolName } from "../../packem_shared/approval.d-C-d-t94D.js";
|
|
8
9
|
import { ServerTool } from '@tanstack/ai';
|
|
9
|
-
import "../../packem_shared/storage.d-
|
|
10
|
+
import "../../packem_shared/storage.d-DwdJrArF.js";
|
|
10
11
|
import 'zod';
|
|
11
12
|
/**
|
|
12
13
|
* Common options accepted by every write-tool factory.
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { U as UploadFile, m as UploadResponse } from "../../../packem_shared/storage.d-
|
|
1
|
+
import { U as UploadFile, m as UploadResponse } from "../../../packem_shared/storage.d-DwdJrArF.js";
|
|
2
2
|
import 'node:stream';
|
|
3
|
-
import { H as Handlers, R as ResponseFile, a as ResponseList, U as UploadOptions } from "../../../packem_shared/types.d-
|
|
4
|
-
export type { A as AsyncHandler, B as BaseHandler, M as MethodHandler, b as RequestEvent, c as UploadErrorEvent, d as UploadEvent } from "../../../packem_shared/types.d-
|
|
5
|
-
import { B as BaseHandlerCore } from "../../../packem_shared/tus-base.d-
|
|
6
|
-
export { T as TUS_RESUMABLE, a as TUS_VERSION } from "../../../packem_shared/tus-base.d-
|
|
3
|
+
import { H as Handlers, R as ResponseFile, a as ResponseList, U as UploadOptions } from "../../../packem_shared/types.d-D7Zlz5RE.js";
|
|
4
|
+
export type { A as AsyncHandler, B as BaseHandler, M as MethodHandler, b as RequestEvent, c as UploadErrorEvent, d as UploadEvent } from "../../../packem_shared/types.d-D7Zlz5RE.js";
|
|
5
|
+
import { B as BaseHandlerCore } from "../../../packem_shared/tus-base.d-BKBoJVy0.js";
|
|
6
|
+
export { T as TUS_RESUMABLE, a as TUS_VERSION } from "../../../packem_shared/tus-base.d-BKBoJVy0.js";
|
|
7
7
|
import 'node:crypto';
|
|
8
8
|
import 'node:http';
|
|
9
9
|
import 'lru-cache';
|
|
10
|
+
import 'node:timers';
|
|
10
11
|
import 'node:events';
|
|
11
12
|
import '@visulima/pagination';
|
|
12
|
-
import "../../../packem_shared/media-transformer.d-
|
|
13
|
-
import "../../../packem_shared/types.d-
|
|
13
|
+
import "../../../packem_shared/media-transformer.d-C8tn4J2Z.js";
|
|
14
|
+
import "../../../packem_shared/types.d-BEUv414z.js";
|
|
14
15
|
/**
|
|
15
16
|
* Base handler for Web API Fetch platform (Request/Response).
|
|
16
17
|
* Extends BaseHandlerCore with Fetch-specific request/response handling.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"../../../packem_shared/Multipart-
|
|
1
|
+
import{default as o}from"../../../packem_shared/Multipart-V64Bg5dt.js";import{default as f}from"../../../packem_shared/Rest-B7g1sgkq.js";import{Tus as p}from"../../../packem_shared/Tus-D9c7KDnl.js";import{TUS_RESUMABLE as s,TUS_VERSION as u}from"../../../packem_shared/TUS_RESUMABLE-CyTSRvPU.js";export{o as Multipart,f as Rest,s as TUS_RESUMABLE,u as TUS_VERSION,p as Tus};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import { U as UploadFile } from "../../../packem_shared/storage.d-
|
|
2
|
+
import { U as UploadFile } from "../../../packem_shared/storage.d-DwdJrArF.js";
|
|
3
3
|
import 'node:stream';
|
|
4
|
-
import { U as UploadOptions } from "../../../packem_shared/types.d-
|
|
4
|
+
import { U as UploadOptions } from "../../../packem_shared/types.d-D7Zlz5RE.js";
|
|
5
|
+
import 'node:timers';
|
|
5
6
|
import 'node:crypto';
|
|
6
7
|
import 'node:http';
|
|
7
8
|
import 'lru-cache';
|
|
8
9
|
import 'node:events';
|
|
9
10
|
import '@visulima/pagination';
|
|
10
|
-
import "../../../packem_shared/media-transformer.d-
|
|
11
|
-
import "../../../packem_shared/types.d-
|
|
11
|
+
import "../../../packem_shared/media-transformer.d-C8tn4J2Z.js";
|
|
12
|
+
import "../../../packem_shared/types.d-BEUv414z.js";
|
|
12
13
|
/**
|
|
13
14
|
* Registers upload handler routes on a Hono app instance.
|
|
14
15
|
* Automatically registers all required HTTP methods for the specified handler type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import c from"../../../packem_shared/Multipart-
|
|
1
|
+
import c from"../../../packem_shared/Multipart-V64Bg5dt.js";import i from"../../../packem_shared/Rest-B7g1sgkq.js";import{Tus as d}from"../../../packem_shared/Tus-D9c7KDnl.js";const u=t=>async o=>{try{const e=o.req.raw;return await t.fetch(e)}catch(e){const a=e,s=a.statusCode||(a.status?Number.parseInt(a.status,10):void 0)||500;return Response.json({error:a.message||"Request failed"},{status:s})}},m=(t,o)=>{const{path:e,type:a,...s}=o;let n;switch(a){case"multipart":{n=new c(s);break}case"rest":{n=new i(s);break}case"tus":{n=new d(s);break}default:throw new Error(`Unknown handler type: ${String(a??"unknown")}`)}const r=u(n);switch(a){case"multipart":{t.post(e,r),t.get(`${e}/:id?/:metadata?`,r),t.delete(`${e}/:id`,r),t.on("OPTIONS",e,r);break}case"rest":{t.post(e,r),t.put(`${e}/:id`,r),t.patch(`${e}/:id`,r),t.get(`${e}/:id?`,r),t.on("HEAD",`${e}/:id`,r),t.delete(`${e}/:id?`,r),t.on("OPTIONS",e,r);break}case"tus":{t.all(e,r),t.all(`${e}/:id`,r);break}default:throw new Error(`Unknown handler type: ${String(a)}`)}};export{m as createStorageHandler};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server.js';
|
|
2
|
-
import { U as UploadFile } from "../../../packem_shared/storage.d-
|
|
2
|
+
import { U as UploadFile } from "../../../packem_shared/storage.d-DwdJrArF.js";
|
|
3
3
|
import 'node:stream';
|
|
4
|
-
import { U as UploadOptions } from "../../../packem_shared/types.d-
|
|
4
|
+
import { U as UploadOptions } from "../../../packem_shared/types.d-D7Zlz5RE.js";
|
|
5
|
+
import 'node:timers';
|
|
5
6
|
import 'node:crypto';
|
|
6
7
|
import 'node:http';
|
|
7
8
|
import 'lru-cache';
|
|
8
9
|
import 'node:events';
|
|
9
10
|
import '@visulima/pagination';
|
|
10
|
-
import "../../../packem_shared/media-transformer.d-
|
|
11
|
-
import "../../../packem_shared/types.d-
|
|
11
|
+
import "../../../packem_shared/media-transformer.d-C8tn4J2Z.js";
|
|
12
|
+
import "../../../packem_shared/types.d-BEUv414z.js";
|
|
12
13
|
/**
|
|
13
14
|
* Configuration for Next.js handler.
|
|
14
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NextResponse as o}from"next/server.js";import u from"../../../packem_shared/Multipart-
|
|
1
|
+
import{NextResponse as o}from"next/server.js";import u from"../../../packem_shared/Multipart-V64Bg5dt.js";import c from"../../../packem_shared/Rest-B7g1sgkq.js";import{Tus as m}from"../../../packem_shared/Tus-D9c7KDnl.js";const d=t=>{let r;switch(t.type){case"multipart":{r=new u(t);break}case"rest":{r=new c(t);break}case"tus":{r=new m(t);break}default:throw new Error(`Unknown handler type: ${String(t.type??"unknown")}`)}return async s=>{try{return await r.fetch(s)}catch(n){const e=n,a=e.statusCode||(e.status?Number.parseInt(e.status,10):void 0)||500;return o.json({error:e.message||"Request failed"},{status:a})}}};export{d as createHandler};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { U as UploadFile, m as UploadResponse } from "../../../packem_shared/storage.d-
|
|
2
|
+
import { U as UploadFile, m as UploadResponse } from "../../../packem_shared/storage.d-DwdJrArF.js";
|
|
3
3
|
import { Readable } from 'node:stream';
|
|
4
|
-
import { H as Handlers, A as AsyncHandler, U as UploadOptions, R as ResponseFile, a as ResponseList, M as MethodHandler } from "../../../packem_shared/types.d-
|
|
5
|
-
export type { B as BaseHandler, b as RequestEvent, c as UploadErrorEvent, d as UploadEvent } from "../../../packem_shared/types.d-
|
|
6
|
-
import { B as BaseHandlerCore } from "../../../packem_shared/tus-base.d-
|
|
7
|
-
export { T as TUS_RESUMABLE, a as TUS_VERSION } from "../../../packem_shared/tus-base.d-
|
|
4
|
+
import { H as Handlers, A as AsyncHandler, U as UploadOptions, R as ResponseFile, a as ResponseList, M as MethodHandler } from "../../../packem_shared/types.d-D7Zlz5RE.js";
|
|
5
|
+
export type { B as BaseHandler, b as RequestEvent, c as UploadErrorEvent, d as UploadEvent } from "../../../packem_shared/types.d-D7Zlz5RE.js";
|
|
6
|
+
import { B as BaseHandlerCore } from "../../../packem_shared/tus-base.d-BKBoJVy0.js";
|
|
7
|
+
export { T as TUS_RESUMABLE, a as TUS_VERSION } from "../../../packem_shared/tus-base.d-BKBoJVy0.js";
|
|
8
|
+
import 'node:timers';
|
|
8
9
|
import 'node:crypto';
|
|
9
10
|
import 'lru-cache';
|
|
10
11
|
import 'node:events';
|
|
11
12
|
import '@visulima/pagination';
|
|
12
|
-
import "../../../packem_shared/media-transformer.d-
|
|
13
|
-
import "../../../packem_shared/types.d-
|
|
13
|
+
import "../../../packem_shared/media-transformer.d-C8tn4J2Z.js";
|
|
14
|
+
import "../../../packem_shared/types.d-BEUv414z.js";
|
|
14
15
|
/**
|
|
15
16
|
* Base handler for Node.js platform (IncomingMessage/ServerResponse).
|
|
16
17
|
* Extends BaseHandlerCore with Node.js-specific request/response handling.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"../../../packem_shared/Multipart-
|
|
1
|
+
import o from"../../../packem_shared/Multipart-C35TR2qL.js";import m from"../../../packem_shared/Rest-BrEMYgxZ.js";import{Tus as f}from"../../../packem_shared/Tus-CJBgnJrn.js";import{TUS_RESUMABLE as S,TUS_VERSION as a}from"../../../packem_shared/TUS_RESUMABLE-CyTSRvPU.js";export{o as Multipart,m as Rest,S as TUS_RESUMABLE,a as TUS_VERSION,f as Tus};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import { U as UploadFile } from "../../../packem_shared/storage.d-
|
|
2
|
+
import { U as UploadFile } from "../../../packem_shared/storage.d-DwdJrArF.js";
|
|
3
3
|
import 'node:stream';
|
|
4
|
-
import { U as UploadOptions } from "../../../packem_shared/types.d-
|
|
4
|
+
import { U as UploadOptions } from "../../../packem_shared/types.d-D7Zlz5RE.js";
|
|
5
|
+
import 'node:timers';
|
|
5
6
|
import 'node:crypto';
|
|
6
7
|
import 'node:http';
|
|
7
8
|
import 'lru-cache';
|
|
8
9
|
import 'node:events';
|
|
9
10
|
import '@visulima/pagination';
|
|
10
|
-
import "../../../packem_shared/media-transformer.d-
|
|
11
|
-
import "../../../packem_shared/types.d-
|
|
11
|
+
import "../../../packem_shared/media-transformer.d-C8tn4J2Z.js";
|
|
12
|
+
import "../../../packem_shared/types.d-BEUv414z.js";
|
|
12
13
|
/**
|
|
13
14
|
* Configuration for SolidStart handler.
|
|
14
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"../../../packem_shared/Multipart-
|
|
1
|
+
import o from"../../../packem_shared/Multipart-V64Bg5dt.js";import u from"../../../packem_shared/Rest-B7g1sgkq.js";import{Tus as p}from"../../../packem_shared/Tus-D9c7KDnl.js";const w=t=>{let e;switch(t.type){case"multipart":{e=new o(t);break}case"rest":{e=new u(t);break}case"tus":{e=new p(t);break}default:throw new Error(`Unknown handler type: ${String(t.type??"unknown")}`)}return async n=>{try{return await e.fetch(n.request)}catch(s){const r=s,a=r.statusCode||(r.status?Number.parseInt(r.status,10):void 0)||500;return Response.json({error:r.message||"Request failed"},{headers:{"Content-Type":"application/json"},status:a})}}};export{w as createSolidStartHandler};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { F as Files, S as SyncOptions, a as SyncResult, T as TransferOptions, b as TransferResult } from "./packem_shared/files.d-
|
|
2
|
-
export { type B as BulkDeleteResult, type c as BulkDownloadOptions, type d as BulkDownloadResult, type e as BulkError, type f as BulkExistsResult, type g as BulkHeadResult, type h as BulkMoveItem, type i as BulkMoveResult, type j as BulkOptions, type k as BulkUploadItem, type l as BulkUploadOptions, type m as BulkUploadResult, type D as DownloadOptions, type n as DownloadRange, type o as DownloadResult, type p as DownloadStreamResult, type q as FileBody, type r as FileObject, type s as FilesHooks, type t as FilesOptions, type H as HookActionType, type u as HookEvent, type L as ListAllOptions, type v as ListDirectoryResult, type w as ListOptions, type M as MultipartOptions, type x as SignedReadUrlOptions, type y as SignedUploadUrlOptions, type z as StorageCapabilities, type A as SyncProgress, type C as TransferProgress, U as UploadControl, type E as UploadControlState, type G as UploadControlToken, type I as UploadOptions, type J as UploadProgress, type K as UploadProgressCallback } from "./packem_shared/files.d-
|
|
3
|
-
import { n as Metrics } from "./packem_shared/storage.d-
|
|
4
|
-
export { B as AbstractBaseStorage, type l as BaseStorageOptions, type o as BatchOperationResponse, type p as BatchOperationResult, type D as DiskStorageOptions, type j as DiskStorageWithChecksumOptions, i as ERRORS, q as ErrorMap, type r as ExpirationOptions, F as File, type d as FileInit, type e as FilePart, type f as FileQuery, type s as Header, type t as Headers, type H as HttpError, type u as HttpErrorBody, type I as IncomingMessageWithBody, type L as LocalMetaStorageOptions, M as MetaStorage, type k as MetaStorageOptions, v as Metadata, type w as OnComplete, type x as OnCreate, type y as OnDelete, type z as OnError, type A as OnUpdate, type P as PurgeList, type G as RangeChecksum, type J as RangeHasher, type K as ResponseBody, type h as ResponseBodyType, type N as ResponseTuple, type R as RetryConfig, a as UploadError, type b as UploadEventType, type U as UploadFile, type m as UploadResponse, type V as Validation, type Q as ValidationError, type S as ValidatorConfig, c as createRetryWrapper, T as defaultCloudStorageFileNameValidation, W as defaultFilesystemFileNameValidation, X as extractHttpStatus, Y as isRetryableError, Z as isUploadError, _ as mapStatusToErrorCode, $ as retry, a0 as throwErrorCode, a1 as wrapStorageError } from "./packem_shared/storage.d-
|
|
1
|
+
import { F as Files, S as SyncOptions, a as SyncResult, T as TransferOptions, b as TransferResult } from "./packem_shared/files.d-CmSZi3M0.js";
|
|
2
|
+
export { type B as BulkDeleteResult, type c as BulkDownloadOptions, type d as BulkDownloadResult, type e as BulkError, type f as BulkExistsResult, type g as BulkHeadResult, type h as BulkMoveItem, type i as BulkMoveResult, type j as BulkOptions, type k as BulkUploadItem, type l as BulkUploadOptions, type m as BulkUploadResult, type D as DownloadOptions, type n as DownloadRange, type o as DownloadResult, type p as DownloadStreamResult, type q as FileBody, type r as FileObject, type s as FilesHooks, type t as FilesOptions, type H as HookActionType, type u as HookEvent, type L as ListAllOptions, type v as ListDirectoryResult, type w as ListOptions, type M as MultipartOptions, type x as SignedReadUrlOptions, type y as SignedUploadUrlOptions, type z as StorageCapabilities, type A as SyncProgress, type C as TransferProgress, U as UploadControl, type E as UploadControlState, type G as UploadControlToken, type I as UploadOptions, type J as UploadProgress, type K as UploadProgressCallback } from "./packem_shared/files.d-CmSZi3M0.js";
|
|
3
|
+
import { n as Metrics } from "./packem_shared/storage.d-DwdJrArF.js";
|
|
4
|
+
export { B as AbstractBaseStorage, type l as BaseStorageOptions, type o as BatchOperationResponse, type p as BatchOperationResult, type D as DiskStorageOptions, type j as DiskStorageWithChecksumOptions, i as ERRORS, q as ErrorMap, type r as ExpirationOptions, F as File, type d as FileInit, type e as FilePart, type f as FileQuery, type s as Header, type t as Headers, type H as HttpError, type u as HttpErrorBody, type I as IncomingMessageWithBody, type L as LocalMetaStorageOptions, M as MetaStorage, type k as MetaStorageOptions, v as Metadata, type w as OnComplete, type x as OnCreate, type y as OnDelete, type z as OnError, type A as OnUpdate, type P as PurgeList, type G as RangeChecksum, type J as RangeHasher, type K as ResponseBody, type h as ResponseBodyType, type N as ResponseTuple, type R as RetryConfig, a as UploadError, type b as UploadEventType, type U as UploadFile, type m as UploadResponse, type V as Validation, type Q as ValidationError, type S as ValidatorConfig, c as createRetryWrapper, T as defaultCloudStorageFileNameValidation, W as defaultFilesystemFileNameValidation, X as extractHttpStatus, Y as isRetryableError, Z as isUploadError, _ as mapStatusToErrorCode, $ as retry, a0 as throwErrorCode, a1 as wrapStorageError } from "./packem_shared/storage.d-DwdJrArF.js";
|
|
5
5
|
import { Meter } from '@opentelemetry/api';
|
|
6
|
-
export { D as DiskStorage, a as DiskStorageWithChecksum } from "./packem_shared/disk-storage-with-checksum.d-
|
|
7
|
-
export { L as LocalMetaStorage } from "./packem_shared/local-meta-storage.d-
|
|
8
|
-
export { M as MemoryMetaStorage, a as MemoryStorage, type b as MemoryStorageOptions } from "./packem_shared/memory-storage.d-
|
|
6
|
+
export { D as DiskStorage, a as DiskStorageWithChecksum } from "./packem_shared/disk-storage-with-checksum.d-Dgwyza8a.js";
|
|
7
|
+
export { L as LocalMetaStorage } from "./packem_shared/local-meta-storage.d-cRTXr1kb.js";
|
|
8
|
+
export { M as MemoryMetaStorage, a as MemoryStorage, type b as MemoryStorageOptions } from "./packem_shared/memory-storage.d-BNZvDG1b.js";
|
|
9
9
|
export { type AnyWebReadableByteStreamWithFileType, type AnyWebReadableStream, type Detector, type FileTypeOptions, type FileTypeParser, type FileTypeResult, type StreamOptions, type TokenizerPositionError, fileTypeFromBlob, fileTypeFromBuffer, fileTypeFromTokenizer, supportedExtensions, supportedMimeTypes } from 'file-type';
|
|
10
10
|
import 'node:stream';
|
|
11
|
+
import 'node:timers';
|
|
11
12
|
import 'node:crypto';
|
|
12
13
|
import 'node:http';
|
|
13
14
|
import 'lru-cache';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{waitForStorage as o}from"./packem_shared/waitForStorage-ByQmG4xF.js";import{
|
|
1
|
+
import{waitForStorage as o}from"./packem_shared/waitForStorage-ByQmG4xF.js";import{w as a}from"./packem_shared/disk-storage-DqnnFQAQ.js";import{default as f}from"./packem_shared/DiskStorageWithChecksum-MZkDEyts.js";import{y as m}from"./packem_shared/local-meta-storage-BELb1YwO.js";import{default as i}from"./packem_shared/MemoryMetaStorage-Ksgh9pe7.js";import{default as x}from"./packem_shared/MemoryStorage-ChKyI6OY.js";import{default as y}from"./packem_shared/MetaStorage-DPEUyWgN.js";import{B as g,d as M,a as n}from"./packem_shared/storage-DR7qdwBN.js";import{ERRORS as F,ErrorMap as c,UploadError as T,extractHttpStatus as C,isUploadError as R,mapStatusToErrorCode as k,throwErrorCode as w,wrapStorageError as B}from"./packem_shared/ERRORS-BIBxE2oR.js";import{createRetryWrapper as h,isRetryableError as N,retry as O}from"./packem_shared/createRetryWrapper-DgmeHPNF.js";import{fileTypeFromBlob as D,fileTypeFromBuffer as V,fileTypeFromTokenizer as W,supportedExtensions as z,supportedMimeTypes as A}from"file-type";import{default as L}from"./packem_shared/File-W8aOo15X.js";import{default as q}from"./packem_shared/NoOpMetrics-BLo6u4NY.js";import{default as G}from"./packem_shared/OpenTelemetryMetrics-DJDQsNKp.js";import{Files as J}from"./packem_shared/Files-DyMJ9FPN.js";import{Metadata as P}from"./packem_shared/Metadata-B7CcBueg.js";import{UploadControl as X}from"./packem_shared/UploadControl-DZJhI9Wh.js";import{sync as Z,transfer as _}from"./packem_shared/sync-DhR3536K.js";export{g as AbstractBaseStorage,a as DiskStorage,f as DiskStorageWithChecksum,F as ERRORS,c as ErrorMap,L as File,J as Files,m as LocalMetaStorage,i as MemoryMetaStorage,x as MemoryStorage,y as MetaStorage,P as Metadata,q as NoOpMetrics,G as OpenTelemetryMetrics,X as UploadControl,T as UploadError,h as createRetryWrapper,M as defaultCloudStorageFileNameValidation,n as defaultFilesystemFileNameValidation,C as extractHttpStatus,D as fileTypeFromBlob,V as fileTypeFromBuffer,W as fileTypeFromTokenizer,N as isRetryableError,R as isUploadError,k as mapStatusToErrorCode,O as retry,z as supportedExtensions,A as supportedMimeTypes,Z as sync,w as throwErrorCode,_ as transfer,o as waitForStorage,B as wrapStorageError};
|
package/dist/packem_shared/{AbstractBaseStorage-CiPEMcuo.js → AbstractBaseStorage-CLsYmMZg.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"node:stream";import"node:timers";import"node:util";import{B as u,d as F,a as g}from"./storage-
|
|
1
|
+
import"node:stream";import"node:timers";import"node:util";import{B as u,d as F,a as g}from"./storage-DR7qdwBN.js";import"./path-C-OWflAo-_mqb5p5d.js";import"type-is";import"./NoOpMetrics-BLo6u4NY.js";import"./cache-Cw3QjoVN.js";import"./ERRORS-BIBxE2oR.js";import"./createRetryWrapper-DgmeHPNF.js";import"./is-expired-CBEk6XBi.js";export{u as BaseStorage,F as defaultCloudStorageFileNameValidation,g as defaultFilesystemFileNameValidation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Readable as u}from"node:stream";import{S as m}from"./s3-base-storage-CX94H-Za.js";import{b as h,p as l}from"./aws-light-meta-storage-DGrn72VJ.js";import f from"./AwsLightFile-CpZrubaV.js";class b extends m{static name="aws-light";s3Api;constructor(e){const{bucket:t=process.env.S3_BUCKET||process.env.AWS_S3_BUCKET,region:r}=e;if(!t)throw new Error("S3 bucket is not defined");if(!r)throw new Error("S3 region is not defined");if(!e.accessKeyId)throw new Error("accessKeyId is required");if(!e.secretAccessKey)throw new Error("secretAccessKey is required");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:o=>{const s=o;return s.statusCode&&[408,429,500,502,503,504].includes(s.statusCode)||s.retryable===!0?!0:void 0}}}),this.s3Api=new h({accessKeyId:e.accessKeyId,bucket:t,endpoint:e.endpoint,region:r,secretAccessKey:e.secretAccessKey,service:e.service,sessionToken:e.sessionToken});const{metaStorage:i,metaStorageConfig:a}=e;if(!i){const o={...e,...a,logger:this.logger};this.meta=new l(o)}}normalizeError(e){const t=e;return t.statusCode||t.code?{code:t.code||t.name,message:t.message,name:t.name,statusCode:t.statusCode||500}:super.normalizeError(e)}async update({id:e},t){if(this.config.clientDirectUpload){const r=await this.getMeta(e);return this.buildPresigned({...r,...t})}return super.update({id:e},t)}async getStream({id:e},t){return this.instrumentOperation("getStream",async()=>{const r=this.getS3Api(),{Body:i,ContentLength:a,ContentType:o,ETag:s,Expires:c,LastModified:g}=await this.runOperation(t,n=>r.getObject({Bucket:this.bucket,Key:e},{signal:n}));await this.checkIfExpired({expiredAt:c});const d=i instanceof ReadableStream?u.fromWeb(i):i,p=new u({read(){d.on("data",n=>{this.push(n)}),d.on("end",()=>{this.push(null)}),d.on("error",n=>{this.destroy(n)})}});return{headers:{"Content-Length":a?.toString()??"0","Content-Type":o,...s&&{ETag:s},...c&&{"X-Upload-Expires":c.toString()},...g&&{"Last-Modified":g.toString()}},size:Number(a),stream:p}})}get raw(){return this.s3Api.aws}getS3Api(){return this.s3Api}getFileClass(){return f}getAcl(){}async accessCheck(e=30){await this.s3Api.checkBucketAccess({Bucket:this.bucket})}}export{b as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{W as f}from"./path-C-OWflAo-_mqb5p5d.js";import{d as b}from"./detect-file-type-BA7UBLKA.js";import{throwErrorCode as u,ERRORS as h}from"./ERRORS-BIBxE2oR.js";import{B as C,c as w}from"./storage-DR7qdwBN.js";import{y as T}from"./local-meta-storage-BELb1YwO.js";import{a as O,c as S,b as m,d as y}from"./azure-meta-storage-ClbEsfI4.js";import k from"./AzureFile-DFSaVe25.js";import{i as E}from"./part-match-D-9dGX42.js";import{e as B}from"./has-content-50BsqrWw.js";import{t as F}from"./get-file-status-y3wTtDQs.js";class z extends C{static name="azure";checksumTypes=["md5"];get raw(){return this.client}meta;client;containerClient;root;resolvedRetryConfig;signer;sasToken;anonymous;constructor(t){if(super(t),!t.containerName)throw new Error("Missing required parameter: Azure container name.");const{anonymous:r,client:e,sasToken:n,signer:s}=O(t);this.client=e,this.signer=s,this.sasToken=n,this.anonymous=r,this.containerClient=this.client.getContainerClient(t.containerName),this.root=t.root?f(t.root).replace(/^\//,""):"";const o={backoffMultiplier:2,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:i=>{const a=i;if(a.statusCode&&[408,429,500,502,503,504].includes(a.statusCode))return!0;if(i instanceof Error){const l=a.code;if(l==="ECONNRESET"||l==="ETIMEDOUT"||l==="ENOTFOUND"||l==="ECONNREFUSED")return!0}},...t.retryConfig};if(this.resolvedRetryConfig=o,t.metaStorage)this.meta=t.metaStorage;else{let i={...t,...t.metaStorageConfig,logger:this.logger};if("directory"in i)this.logger?.debug("Using local meta storage"),this.meta=new T(i);else{const a=t.metaStorageConfig;a&&["accountKey","accountName","connectionString","credential","endpoint","sasToken"].some(l=>l in a)||(i={...i,client:this.client}),this.meta=new S(i)}}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(i=>{this.logger?.error("Storage access check failed: %O",i)})}getRetryConfig(){return this.resolvedRetryConfig}async create(t,r){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const a=typeof t.ttl=="string"?w(t.ttl):t.ttl;a!==void 0&&(e.expiredAt=Date.now()+a)}const n=new k(e);n.name=this.namingFunction(n),await this.validate(n);try{const a=await this.getMeta(n.id);if(a.bytesWritten>=0)return a}catch{}const s=this.containerClient.getBlockBlobClient(this.getFullPath(n.name)),o={};for(const[a,l]of Object.entries(n.metadata||{}))o[a]=JSON.stringify(l);const i=await this.runOperation(r,a=>s.uploadData(Buffer.from(""),{abortSignal:a,blobHTTPHeaders:{blobContentType:n.contentType},metadata:{name:n.name,originalName:n.originalName,...o}}));return i.requestId===void 0?u(h.FILE_ERROR,"azure create upload error"):(n.requestId=i.requestId,n.uri=i._response.headers.get("location"),n.bytesWritten=0,await this.saveMeta(n),n.status="created",await this.onCreate(n),n)})}async delete({id:t},r){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);e.status="deleted",await this.runOperation(r,s=>this.containerClient.getBlockBlobClient(this.getFullPath(e.name)).deleteIfExists({abortSignal:s})),await this.deleteMeta(e.id);const n={...e};return await this.onDelete(n),n})}async deleteBatch(t,r){if(t.length===0)return{failed:[],failedCount:0,successful:[],successfulCount:0};const e=256;try{const n=this.client.getBlobBatchClient(),s=[],o=[];for(let i=0;i<t.length;i+=e){const a=t.slice(i,i+e),l=a.map(c=>this.containerClient.getBlockBlobClient(this.getFullPath(c))),d=await this.runOperation(r,c=>n.deleteBlobs(l,{abortSignal:c}));for(const[c,p]of d.subResponses.entries()){const g=a[c];p.status===202||p.status===404?s.push({id:g,name:g,status:"deleted"}):o.push({error:p.errorCode??`HTTP ${p.status}`,id:g})}}return await Promise.all(s.map(async i=>{try{await this.deleteMeta(i.id),await this.onDelete(i)}catch{}})),{failed:o,failedCount:o.length,successful:s,successfulCount:s.length}}catch(n){return this.logger?.warn(`Azure Blob Batch delete unavailable, falling back to per-key delete: ${n instanceof Error?n.message:String(n)}`),super.deleteBatch(t,r)}}async move(t,r,e){return this.instrumentOperation("move",async()=>{const n=await this.copy(t,r,e),s=this.getFullPath(t);return await this.runOperation(e,o=>this.containerClient.getBlockBlobClient(s).deleteIfExists({abortSignal:o})),n})}async write(t,r){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(!E(t,e))return u(h.FILE_CONFLICT);const n=await this.lock(t.id);try{if(B(t)){if((e.bytesWritten===0||Number.isNaN(e.bytesWritten))&&(!e.contentType||e.contentType==="application/octet-stream"))try{const{fileType:a,stream:l}=await b(t.body);a?.mime&&(e.contentType=a.mime),t.body=l}catch{}const s=this.containerClient.getBlockBlobClient(this.getFullPath(e.name)),o=new AbortController;t.body.on("error",()=>{o.abort()});const i=await this.runOperation(r,a=>{const l=a?AbortSignal.any([o.signal,a]):o.signal;return s.uploadStream(t.body,void 0,void 0,{abortSignal:l,blobHTTPHeaders:{blobContentType:e.contentType??"application/octet-stream"},metadata:e.metadata})},{replayable:!1});if(i.requestId===void 0)return u(h.FILE_ERROR,"azure write upload error");e.requestId=i.requestId,e.bytesWritten+=t.contentLength||0,e.status=F(e),e.status==="completed"&&(e.uri=i._response.headers.get("location"),await this.deleteMeta(e.id))}}finally{await this.unlock(t.id,n)}return e})}async get({id:t},r){return this.instrumentOperation("get",async()=>{const e=this.containerClient.getBlockBlobClient(this.getFullPath(t));if(!await this.runOperation(r,c=>e.exists({abortSignal:c})))try{return await this.getMeta(t),u(h.GONE)}catch{return u(h.FILE_NOT_FOUND)}const n=await this.runOperation(r,c=>e.getProperties({abortSignal:c})),{contentLength:s,contentType:o,etag:i,expiresOn:a,lastModified:l,metadata:d}=n;return{content:await this.runOperation(r,c=>e.downloadToBuffer(0,void 0,{abortSignal:c})),contentType:o,ETag:i,expiredAt:a,id:t,metadata:d||{},modifiedAt:l,name:d?.name||t,originalName:d?.originalName||"",size:s}})}async exists({id:t},r){return this.instrumentOperation("exists",async()=>{try{await this.getMeta(t);const e=this.containerClient.getBlockBlobClient(this.getFullPath(t));return await this.runOperation(r,n=>e.exists({abortSignal:n}))}catch{return!1}})}async copy(t,r,e){return this.instrumentOperation("copy",async()=>{const n=this.containerClient.getBlockBlobClient(this.getFullPath(t));if(!await this.runOperation(e,a=>n.exists({abortSignal:a})))try{return await this.getMeta(t),u(h.GONE)}catch{return u(h.FILE_NOT_FOUND)}const s=this.containerClient.getBlockBlobClient(this.getFullPath(r));let o=n.url;this.signer?.kind==="userDelegation"?o=await m(this.containerClient.getBlobClient(this.getFullPath(t)),this.signer,{expiresIn:300,permissions:"r"}):this.sasToken&&(o=y(n.url,this.sasToken));const i=await this.runOperation(e,a=>s.beginCopyFromURL(o,{abortSignal:a}));return await this.runOperation(e,()=>i.pollUntilDone()),{...await this.getMeta(t),id:r,name:r}})}async list(t=1e3,r){return this.instrumentOperation("list",async()=>{const e=[];let n=!0,s;for(;n&&e.length<t;)try{const o=Math.min(t-e.length,1e3),i=(await this.runOperation(r,a=>this.containerClient.listBlobsFlat({abortSignal:a,includeMetadata:!0,prefix:this.root}).byPage({continuationToken:s,maxPageSize:o}).next())).value;if(i!==void 0&&"segment"in i){for(const a of i.segment.blobItems)if(!a.deleted&&(e.push({createdAt:a.properties.createdOn,id:a.name,modifiedAt:a.properties.lastModified}),e.length>=t))break}n=i?.continuationToken!==void 0,n&&(s=i.continuationToken)}catch(o){const i=this.normalizeError(o instanceof Error?o:new Error(String(o)));throw await this.onError(i),o}return e},{limit:t})}async getReadUrl(t,r){const e=this.containerClient.getBlobClient(this.getFullPath(t));return this.signer?m(e,this.signer,{expiresIn:r?.expiresIn??3600,permissions:"r",...r?.responseContentDisposition&&{contentDisposition:r.responseContentDisposition},...r?.responseContentType&&{contentType:r.responseContentType}}):r?.responseContentDisposition!==void 0||r?.responseContentType!==void 0?u(h.BAD_REQUEST,"azure: `responseContentDisposition`/`responseContentType` require a freshly minted SAS (construct with a shared key or Microsoft Entra credential). A pre-issued `sasToken` or anonymous public-container URL has no signature in which to bind the override, so it cannot be enforced."):this.sasToken?y(e.url,this.sasToken):this.anonymous?e.url:u(h.METHOD_NOT_ALLOWED,"azure: cannot produce a read URL without a shared key, Microsoft Entra credential, or SAS token. Construct the adapter with accountKey + accountName, a connectionString containing an account key, a credential + accountName, or a sasToken.")}async getUploadUrl(t,r){if(r?.contentType!==void 0||r?.contentLength!==void 0)return u(h.BAD_REQUEST,"azure: `contentType`/`contentLength` are not supported for upload URLs. An Azure SAS 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 SAS, or omit them and accept the unbounded PUT.");const e=this.containerClient.getBlobClient(this.getFullPath(t));return this.signer?m(e,this.signer,{expiresIn:r?.expiresIn??3600,permissions:"cw"}):this.sasToken?y(e.url,this.sasToken):u(h.METHOD_NOT_ALLOWED,"azure: cannot produce an upload URL without a shared key, Microsoft Entra credential, or SAS token. Anonymous (public-container) access is read-only.")}getFullPath(t){return this.assetFolder!==void 0?`${this.assetFolder}/${t}`:t}async accessCheck(){await this.runOperation(void 0,t=>this.containerClient.getProperties({abortSignal:t}))}}export{z as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as r}from"./local-meta-storage-BELb1YwO.js";class o extends r{constructor(e){super(e)}}export{o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Readable as x}from"node:stream";import{BoxDeveloperTokenAuth as I,BoxClient as u,OAuthConfig as E,BoxOAuth as O,CcgConfig as T,BoxCcgAuth as b,BoxJwtAuth as U,JwtConfig as F}from"box-typescript-sdk-gen";import{throwErrorCode as C,ERRORS as B}from"./ERRORS-BIBxE2oR.js";import{B as L}from"./storage-0j5nCAUp.js";import p from"./BoxFile-CseIoPW1.js";import S from"./BoxMetaStorage-CHWrhgg2.js";import{t as v}from"./get-file-status-y3wTtDQs.js";import{t as D}from"./update-size-DuNuLyxj.js";import{i as H}from"./part-match-D-9dGX42.js";import{e as R}from"./has-content-50BsqrWw.js";const _="0",A=50*1024*1024,w={ensureReady:()=>Promise.resolve()},M=a=>{let e=0,i=a.length;for(;e<i&&a[e]==="/";)e+=1;for(;i>e&&a[i-1]==="/";)i-=1;return e===0&&i===a.length?a:a.slice(e,i)},m=a=>{const e=M(a);if(!e)throw new Error("Box: key must not be empty");const i=e.split("/").filter(r=>r.length>0),t=i.pop()??"";if(!t)throw new Error(`Box: key "${a}" has no file name segment`);return{leaf:t,parents:i}},N=async a=>{const e=[];for await(const i of a)e.push(Buffer.from(i));return Buffer.concat(e)},g=a=>x.from(a),j=a=>"configJsonString"in a?F.fromConfigJsonString(a.configJsonString):F.fromConfigFile(a.configFilePath),z=a=>[a.developerToken,a.oauth,a.ccg,a.jwt].filter(e=>e!==void 0).length,P=a=>{if(a.client)return{authHandle:w,client:a.client};if(z(a)>1)throw new Error("Box storage: pass exactly one of `developerToken`, `oauth`, `ccg`, or `jwt`.");if(a.developerToken!==void 0){const i=new I({token:a.developerToken});return{authHandle:w,client:new u({auth:i})}}if(a.oauth){const{clientId:i,clientSecret:t,refreshToken:r}=a.oauth,s=new E({clientId:i,clientSecret:t}),n=new O({config:s});let l;const o=async()=>{await n.tokenStorage.store({accessToken:"",refreshToken:r})};return{authHandle:{ensureReady:()=>(l||(l=o()),l)},client:new u({auth:n})}}if(a.ccg){const{clientId:i,clientSecret:t,enterpriseId:r,userId:s}=a.ccg;if(!r&&!s)throw new Error("Box storage: `ccg` auth requires either `enterpriseId` or `userId`.");const n=new T({clientId:i,clientSecret:t,...r!==void 0&&{enterpriseId:r},...s!==void 0&&{userId:s}}),l=new b({config:n});return{authHandle:w,client:new u({auth:l})}}if(a.jwt){const i=j(a.jwt),t=new U({config:i});return{authHandle:w,client:new u({auth:t})}}const e=process.env.BOX_DEVELOPER_TOKEN;if(e){const i=new I({token:e});return{authHandle:w,client:new u({auth:i})}}throw new Error("Box storage: missing auth. Pass `client`, `developerToken`, `oauth`, `ccg`, or `jwt`. Env fallback: BOX_DEVELOPER_TOKEN.")},J=a=>{if(a&&typeof a=="object"){const e=a,i=e.responseInfo?.code??e.responseInfo?.body?.code;return e.responseInfo?.statusCode===404||i==="not_found"||i==="file_not_found"||i==="folder_not_found"||i==="trashed"}return!1},k=a=>{if(a&&typeof a=="object"){const e=a,i=e.responseInfo?.code??e.responseInfo?.body?.code;return e.responseInfo?.statusCode===409||i==="item_name_in_use"||i==="conflict"}return!1};class ee extends L{static name="box";checksumTypes=[];meta;authHandle;client;fileIdCache;folderIdCache;publicByDefault;rootFolderId;constructor(e){super(e),this.rootFolderId=e.rootFolderId??_,this.publicByDefault=e.publicByDefault??!1;const i=P(e);this.client=i.client,this.authHandle=i.authHandle,this.folderIdCache=new Map,this.fileIdCache=new Map,this.meta=e.metaStorage??new S(e.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(e,i){return this.instrumentOperation("create",async()=>{const t=new p(e);t.name=this.namingFunction(t),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=v(t),await this.saveMeta(t),await this.onCreate(t),t})}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&&D(t,e.size),!H(e,t))throw new Error("File part does not match");const r=await this.lock(e.id);try{if(R(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");await this.authHandle.ensureReady();const s=await N(e.body),n=t.name||t.id,{leaf:l,parents:o}=m(n),d=await this.resolveFolderId(o,{create:!0},i),c=await this.resolveExistingFileForUpload(n,d,l,i),h=await this.performUpload(c,d,l,s,i);h.id&&(this.fileIdCache.set(n,h.id),this.publicByDefault&&await this.ensureSharedLink(h.id,i)),t.bytesWritten=s.length,t.size=s.length,t.boxFileId=h.id,t.eTag=h.etag??void 0,t.ETag=h.etag??void 0}return t.status=v(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()=>{let t;try{t=await this.getMeta(e)}catch{}const r=t?.name??e;await this.authHandle.ensureReady();try{const s=t?.boxFileId??await this.resolveFileId(r,i);await this.runOperation(i,()=>this.client.files.deleteFileById(s)),this.fileIdCache.delete(r)}catch(s){if(!J(s))throw s}return 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}),{id:e,name:e,status:"deleted"})})}async get({id:e},i){return this.instrumentOperation("get",async()=>{let t,r=e;try{t=await this.checkIfExpired(await this.getMeta(e)),r=t.name??e}catch{}await this.authHandle.ensureReady();const s=t?.boxFileId??await this.resolveFileId(r,i),n=await this.runOperation(i,()=>this.client.files.getFileById(s)),l=await this.runOperation(i,()=>this.client.downloads.getDownloadFileUrl(s)),o=await this.runOperation(i,()=>fetch(l));if(!o.ok)throw new Error(`Box: download fetch failed (${o.status})`);const d=await this.runOperation(i,()=>o.arrayBuffer()),c=Buffer.from(d);return{content:c,contentType:t?.contentType??"application/octet-stream",ETag:t?.ETag??n.etag??void 0,expiredAt:t?.expiredAt,id:e,metadata:t?.metadata??{},modifiedAt:t?.modifiedAt??n.modifiedAt??n.contentModifiedAt??void 0,name:t?.name??n.name??r,originalName:t?.originalName??n.name??r,size:t?.size??n.size??c.length}})}async copy(e,i,t){return this.instrumentOperation("copy",async()=>{await this.authHandle.ensureReady();const r=await this.resolveFileId(e,t),{leaf:s,parents:n}=m(i),l=await this.resolveFolderId(n,{create:!0},t),o=await this.runOperation(t,()=>this.client.files.copyFile(r,{name:s,parent:{id:l}}));o.id&&this.fileIdCache.set(i,o.id);const d=new p({contentType:"application/octet-stream",metadata:{},originalName:i});return d.id=i,d.name=i,d.boxFileId=o.id,d.eTag=o.etag??void 0,d.ETag=o.etag??void 0,d})}async move(e,i,t){return this.instrumentOperation("move",async()=>{await this.authHandle.ensureReady();const r=await this.resolveFileId(e,t),{leaf:s,parents:n}=m(i),l=await this.resolveFolderId(n,{create:!0},t),o=await this.runOperation(t,()=>this.client.files.updateFileById(r,{requestBody:{name:s,parent:{id:l}}}));this.fileIdCache.delete(e),o.id&&this.fileIdCache.set(i,o.id);const d=new p({contentType:"application/octet-stream",metadata:{},originalName:i});d.id=i,d.name=i,d.boxFileId=o.id,d.eTag=o.etag??void 0,d.ETag=o.etag??void 0;try{await this.deleteMeta(e)}catch{}return d})}async list(e=1e3,i){return this.instrumentOperation("list",async()=>{await this.authHandle.ensureReady();const t=[];let r=0;const s=Math.min(e,1e3);for(;t.length<e;){const n=(await this.runOperation(i,()=>this.client.folders.getFolderItems(this.rootFolderId,{queryParams:{fields:["id","name","size","modified_at","etag","type"],limit:s,offset:r}}))).entries??[];for(const l of n){const o=l;if(o.type!=="file"||!o.id||!o.name)continue;this.fileIdCache.set(o.name,o.id);const d=new p({contentType:"application/octet-stream",metadata:{},originalName:o.name});if(d.id=o.name,d.name=o.name,d.boxFileId=o.id,d.eTag=o.etag??void 0,d.ETag=o.etag??void 0,d.size=o.size??0,d.modifiedAt=o.modifiedAt??o.contentModifiedAt??void 0,t.push(d),t.length>=e)break}if(n.length<s)break;r+=n.length}return t},{limit:e})}async getReadUrl(e,i){if(i?.responseContentDisposition||i?.responseContentType)return C(B.METHOD_NOT_ALLOWED,"Box: `responseContentDisposition` / `responseContentType` are not supported — Box download URLs and shared-link URLs have no overrides.");await this.authHandle.ensureReady();const t=await this.resolveFileId(e);return this.publicByDefault?this.ensureSharedLink(t):this.client.downloads.getDownloadFileUrl(t)}async getUploadUrl(e,i){return C(B.METHOD_NOT_ALLOWED,"Box: `getUploadUrl` is not supported. Box uploads require a multipart POST with an `attributes` JSON part and a file bytes part; this doesn't fit the PUT-style upload-url contract. Use `write()` server-side, or the Box UI Elements / Box Content Uploader for browser flows.")}async findChildByName(e,i,t){let r=0;const s=1e3;for(;;){const n=(await this.runOperation(t,()=>this.client.folders.getFolderItems(e,{queryParams:{fields:["id","name","type"],limit:s,offset:r}}))).entries??[];for(const l of n){const o=l;if(o.name===i&&o.id&&o.type)return{id:o.id,type:o.type}}if(n.length<s)return;r+=n.length}}folderCacheKey(e){return e.join("/")}async resolveFolderId(e,i,t){if(e.length===0)return this.rootFolderId;const r=this.folderCacheKey(e),s=this.folderIdCache.get(r);if(s)return s;let n=this.rootFolderId;const l=[];for(const o of e){l.push(o);const d=this.folderCacheKey(l),c=this.folderIdCache.get(d);if(c){n=c;continue}const h=await this.findChildByName(n,o,t);if(h&&h.type==="folder"){n=h.id,this.folderIdCache.set(d,n);continue}if(h&&h.type!=="folder")throw new Error(`Box: path segment "${o}" exists but is not a folder`);if(!i.create)throw new Error(`Box: folder "${l.join("/")}" not found`);try{const f=await this.runOperation(t,()=>this.client.folders.createFolder({name:o,parent:{id:n}}));if(!f.id)throw new Error(`Box: createFolder did not return an id for "${o}"`);n=f.id,this.folderIdCache.set(d,n)}catch(f){if(k(f)){const y=await this.findChildByName(n,o,t);if(y&&y.type==="folder"){n=y.id,this.folderIdCache.set(d,n);continue}}throw f}}return this.folderIdCache.set(r,n),n}async resolveFileId(e,i){const t=this.fileIdCache.get(e);if(t)return t;const{leaf:r,parents:s}=m(e),n=await this.resolveFolderId(s,{create:!1},i),l=await this.findChildByName(n,r,i);if(!l||l.type!=="file")throw new Error(`Box: file "${e}" not found`);return this.fileIdCache.set(e,l.id),l.id}async resolveExistingFileForUpload(e,i,t,r){const s=this.fileIdCache.get(e);if(s)return s;const n=await this.findChildByName(i,t,r);if(n){if(n.type==="file")return this.fileIdCache.set(e,n.id),n.id;throw new Error(`Box: "${e}" already exists as a non-file (${n.type})`)}}async performUpload(e,i,t,r,s){if(r.byteLength>A)return await this.runOperation(s,()=>this.client.chunkedUploads.uploadBigFile(g(r),t,r.byteLength,i));if(e){const l=((await this.runOperation(s,()=>this.client.uploads.uploadFileVersion(e,{attributes:{name:t},file:g(r)}))).entries??[])[0];if(!l)throw new Error("Box: uploadFileVersion returned no file");return l}const n=((await this.runOperation(s,()=>this.client.uploads.uploadFile({attributes:{name:t,parent:{id:i}},file:g(r)}))).entries??[])[0];if(!n)throw new Error("Box: uploadFile returned no file");return n}async ensureSharedLink(e,i){try{const t=(await this.runOperation(i,()=>this.client.sharedLinksFiles.addShareLinkToFile(e,{sharedLink:{access:"open"}},{fields:"shared_link"}))).sharedLink;return(t?.downloadUrl??t?.url)||this.fetchSharedLinkUrl(e,i)}catch(t){if(k(t))return this.fetchSharedLinkUrl(e,i);throw t}}async fetchSharedLinkUrl(e,i){const t=(await this.runOperation(i,()=>this.client.sharedLinksFiles.getSharedLinkForFile(e,{fields:"shared_link"}))).sharedLink,r=t?.downloadUrl??t?.url;if(!r)throw new Error("Box: file has no shared link. Call write() with publicByDefault: true, or addShareLinkToFile via storage.raw.");return r}internalOnComplete=e=>this.deleteMeta(e.id)}export{ee as default};
|
|
1
|
+
import{Readable as x}from"node:stream";import{BoxDeveloperTokenAuth as I,BoxClient as u,OAuthConfig as E,BoxOAuth as O,CcgConfig as T,BoxCcgAuth as b,BoxJwtAuth as U,JwtConfig as F}from"box-typescript-sdk-gen";import{throwErrorCode as C,ERRORS as B}from"./ERRORS-BIBxE2oR.js";import{B as L}from"./storage-DR7qdwBN.js";import p from"./BoxFile-CseIoPW1.js";import S from"./BoxMetaStorage-CJsyeQ63.js";import{t as v}from"./get-file-status-y3wTtDQs.js";import{t as D}from"./update-size-DuNuLyxj.js";import{i as H}from"./part-match-D-9dGX42.js";import{e as R}from"./has-content-50BsqrWw.js";const _="0",A=50*1024*1024,w={ensureReady:()=>Promise.resolve()},M=a=>{let e=0,i=a.length;for(;e<i&&a[e]==="/";)e+=1;for(;i>e&&a[i-1]==="/";)i-=1;return e===0&&i===a.length?a:a.slice(e,i)},m=a=>{const e=M(a);if(!e)throw new Error("Box: key must not be empty");const i=e.split("/").filter(r=>r.length>0),t=i.pop()??"";if(!t)throw new Error(`Box: key "${a}" has no file name segment`);return{leaf:t,parents:i}},N=async a=>{const e=[];for await(const i of a)e.push(Buffer.from(i));return Buffer.concat(e)},g=a=>x.from(a),j=a=>"configJsonString"in a?F.fromConfigJsonString(a.configJsonString):F.fromConfigFile(a.configFilePath),z=a=>[a.developerToken,a.oauth,a.ccg,a.jwt].filter(e=>e!==void 0).length,P=a=>{if(a.client)return{authHandle:w,client:a.client};if(z(a)>1)throw new Error("Box storage: pass exactly one of `developerToken`, `oauth`, `ccg`, or `jwt`.");if(a.developerToken!==void 0){const i=new I({token:a.developerToken});return{authHandle:w,client:new u({auth:i})}}if(a.oauth){const{clientId:i,clientSecret:t,refreshToken:r}=a.oauth,s=new E({clientId:i,clientSecret:t}),n=new O({config:s});let l;const o=async()=>{await n.tokenStorage.store({accessToken:"",refreshToken:r})};return{authHandle:{ensureReady:()=>(l||(l=o()),l)},client:new u({auth:n})}}if(a.ccg){const{clientId:i,clientSecret:t,enterpriseId:r,userId:s}=a.ccg;if(!r&&!s)throw new Error("Box storage: `ccg` auth requires either `enterpriseId` or `userId`.");const n=new T({clientId:i,clientSecret:t,...r!==void 0&&{enterpriseId:r},...s!==void 0&&{userId:s}}),l=new b({config:n});return{authHandle:w,client:new u({auth:l})}}if(a.jwt){const i=j(a.jwt),t=new U({config:i});return{authHandle:w,client:new u({auth:t})}}const e=process.env.BOX_DEVELOPER_TOKEN;if(e){const i=new I({token:e});return{authHandle:w,client:new u({auth:i})}}throw new Error("Box storage: missing auth. Pass `client`, `developerToken`, `oauth`, `ccg`, or `jwt`. Env fallback: BOX_DEVELOPER_TOKEN.")},J=a=>{if(a&&typeof a=="object"){const e=a,i=e.responseInfo?.code??e.responseInfo?.body?.code;return e.responseInfo?.statusCode===404||i==="not_found"||i==="file_not_found"||i==="folder_not_found"||i==="trashed"}return!1},k=a=>{if(a&&typeof a=="object"){const e=a,i=e.responseInfo?.code??e.responseInfo?.body?.code;return e.responseInfo?.statusCode===409||i==="item_name_in_use"||i==="conflict"}return!1};class ee extends L{static name="box";checksumTypes=[];meta;authHandle;client;fileIdCache;folderIdCache;publicByDefault;rootFolderId;constructor(e){super(e),this.rootFolderId=e.rootFolderId??_,this.publicByDefault=e.publicByDefault??!1;const i=P(e);this.client=i.client,this.authHandle=i.authHandle,this.folderIdCache=new Map,this.fileIdCache=new Map,this.meta=e.metaStorage??new S(e.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(e,i){return this.instrumentOperation("create",async()=>{const t=new p(e);t.name=this.namingFunction(t),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=v(t),await this.saveMeta(t),await this.onCreate(t),t})}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&&D(t,e.size),!H(e,t))throw new Error("File part does not match");const r=await this.lock(e.id);try{if(R(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");await this.authHandle.ensureReady();const s=await N(e.body),n=t.name||t.id,{leaf:l,parents:o}=m(n),d=await this.resolveFolderId(o,{create:!0},i),c=await this.resolveExistingFileForUpload(n,d,l,i),h=await this.performUpload(c,d,l,s,i);h.id&&(this.fileIdCache.set(n,h.id),this.publicByDefault&&await this.ensureSharedLink(h.id,i)),t.bytesWritten=s.length,t.size=s.length,t.boxFileId=h.id,t.eTag=h.etag??void 0,t.ETag=h.etag??void 0}return t.status=v(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()=>{let t;try{t=await this.getMeta(e)}catch{}const r=t?.name??e;await this.authHandle.ensureReady();try{const s=t?.boxFileId??await this.resolveFileId(r,i);await this.runOperation(i,()=>this.client.files.deleteFileById(s)),this.fileIdCache.delete(r)}catch(s){if(!J(s))throw s}return 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}),{id:e,name:e,status:"deleted"})})}async get({id:e},i){return this.instrumentOperation("get",async()=>{let t,r=e;try{t=await this.checkIfExpired(await this.getMeta(e)),r=t.name??e}catch{}await this.authHandle.ensureReady();const s=t?.boxFileId??await this.resolveFileId(r,i),n=await this.runOperation(i,()=>this.client.files.getFileById(s)),l=await this.runOperation(i,()=>this.client.downloads.getDownloadFileUrl(s)),o=await this.runOperation(i,()=>fetch(l));if(!o.ok)throw new Error(`Box: download fetch failed (${o.status})`);const d=await this.runOperation(i,()=>o.arrayBuffer()),c=Buffer.from(d);return{content:c,contentType:t?.contentType??"application/octet-stream",ETag:t?.ETag??n.etag??void 0,expiredAt:t?.expiredAt,id:e,metadata:t?.metadata??{},modifiedAt:t?.modifiedAt??n.modifiedAt??n.contentModifiedAt??void 0,name:t?.name??n.name??r,originalName:t?.originalName??n.name??r,size:t?.size??n.size??c.length}})}async copy(e,i,t){return this.instrumentOperation("copy",async()=>{await this.authHandle.ensureReady();const r=await this.resolveFileId(e,t),{leaf:s,parents:n}=m(i),l=await this.resolveFolderId(n,{create:!0},t),o=await this.runOperation(t,()=>this.client.files.copyFile(r,{name:s,parent:{id:l}}));o.id&&this.fileIdCache.set(i,o.id);const d=new p({contentType:"application/octet-stream",metadata:{},originalName:i});return d.id=i,d.name=i,d.boxFileId=o.id,d.eTag=o.etag??void 0,d.ETag=o.etag??void 0,d})}async move(e,i,t){return this.instrumentOperation("move",async()=>{await this.authHandle.ensureReady();const r=await this.resolveFileId(e,t),{leaf:s,parents:n}=m(i),l=await this.resolveFolderId(n,{create:!0},t),o=await this.runOperation(t,()=>this.client.files.updateFileById(r,{requestBody:{name:s,parent:{id:l}}}));this.fileIdCache.delete(e),o.id&&this.fileIdCache.set(i,o.id);const d=new p({contentType:"application/octet-stream",metadata:{},originalName:i});d.id=i,d.name=i,d.boxFileId=o.id,d.eTag=o.etag??void 0,d.ETag=o.etag??void 0;try{await this.deleteMeta(e)}catch{}return d})}async list(e=1e3,i){return this.instrumentOperation("list",async()=>{await this.authHandle.ensureReady();const t=[];let r=0;const s=Math.min(e,1e3);for(;t.length<e;){const n=(await this.runOperation(i,()=>this.client.folders.getFolderItems(this.rootFolderId,{queryParams:{fields:["id","name","size","modified_at","etag","type"],limit:s,offset:r}}))).entries??[];for(const l of n){const o=l;if(o.type!=="file"||!o.id||!o.name)continue;this.fileIdCache.set(o.name,o.id);const d=new p({contentType:"application/octet-stream",metadata:{},originalName:o.name});if(d.id=o.name,d.name=o.name,d.boxFileId=o.id,d.eTag=o.etag??void 0,d.ETag=o.etag??void 0,d.size=o.size??0,d.modifiedAt=o.modifiedAt??o.contentModifiedAt??void 0,t.push(d),t.length>=e)break}if(n.length<s)break;r+=n.length}return t},{limit:e})}async getReadUrl(e,i){if(i?.responseContentDisposition||i?.responseContentType)return C(B.METHOD_NOT_ALLOWED,"Box: `responseContentDisposition` / `responseContentType` are not supported — Box download URLs and shared-link URLs have no overrides.");await this.authHandle.ensureReady();const t=await this.resolveFileId(e);return this.publicByDefault?this.ensureSharedLink(t):this.client.downloads.getDownloadFileUrl(t)}async getUploadUrl(e,i){return C(B.METHOD_NOT_ALLOWED,"Box: `getUploadUrl` is not supported. Box uploads require a multipart POST with an `attributes` JSON part and a file bytes part; this doesn't fit the PUT-style upload-url contract. Use `write()` server-side, or the Box UI Elements / Box Content Uploader for browser flows.")}async findChildByName(e,i,t){let r=0;const s=1e3;for(;;){const n=(await this.runOperation(t,()=>this.client.folders.getFolderItems(e,{queryParams:{fields:["id","name","type"],limit:s,offset:r}}))).entries??[];for(const l of n){const o=l;if(o.name===i&&o.id&&o.type)return{id:o.id,type:o.type}}if(n.length<s)return;r+=n.length}}folderCacheKey(e){return e.join("/")}async resolveFolderId(e,i,t){if(e.length===0)return this.rootFolderId;const r=this.folderCacheKey(e),s=this.folderIdCache.get(r);if(s)return s;let n=this.rootFolderId;const l=[];for(const o of e){l.push(o);const d=this.folderCacheKey(l),c=this.folderIdCache.get(d);if(c){n=c;continue}const h=await this.findChildByName(n,o,t);if(h&&h.type==="folder"){n=h.id,this.folderIdCache.set(d,n);continue}if(h&&h.type!=="folder")throw new Error(`Box: path segment "${o}" exists but is not a folder`);if(!i.create)throw new Error(`Box: folder "${l.join("/")}" not found`);try{const f=await this.runOperation(t,()=>this.client.folders.createFolder({name:o,parent:{id:n}}));if(!f.id)throw new Error(`Box: createFolder did not return an id for "${o}"`);n=f.id,this.folderIdCache.set(d,n)}catch(f){if(k(f)){const y=await this.findChildByName(n,o,t);if(y&&y.type==="folder"){n=y.id,this.folderIdCache.set(d,n);continue}}throw f}}return this.folderIdCache.set(r,n),n}async resolveFileId(e,i){const t=this.fileIdCache.get(e);if(t)return t;const{leaf:r,parents:s}=m(e),n=await this.resolveFolderId(s,{create:!1},i),l=await this.findChildByName(n,r,i);if(!l||l.type!=="file")throw new Error(`Box: file "${e}" not found`);return this.fileIdCache.set(e,l.id),l.id}async resolveExistingFileForUpload(e,i,t,r){const s=this.fileIdCache.get(e);if(s)return s;const n=await this.findChildByName(i,t,r);if(n){if(n.type==="file")return this.fileIdCache.set(e,n.id),n.id;throw new Error(`Box: "${e}" already exists as a non-file (${n.type})`)}}async performUpload(e,i,t,r,s){if(r.byteLength>A)return await this.runOperation(s,()=>this.client.chunkedUploads.uploadBigFile(g(r),t,r.byteLength,i));if(e){const l=((await this.runOperation(s,()=>this.client.uploads.uploadFileVersion(e,{attributes:{name:t},file:g(r)}))).entries??[])[0];if(!l)throw new Error("Box: uploadFileVersion returned no file");return l}const n=((await this.runOperation(s,()=>this.client.uploads.uploadFile({attributes:{name:t,parent:{id:i}},file:g(r)}))).entries??[])[0];if(!n)throw new Error("Box: uploadFile returned no file");return n}async ensureSharedLink(e,i){try{const t=(await this.runOperation(i,()=>this.client.sharedLinksFiles.addShareLinkToFile(e,{sharedLink:{access:"open"}},{fields:"shared_link"}))).sharedLink;return(t?.downloadUrl??t?.url)||this.fetchSharedLinkUrl(e,i)}catch(t){if(k(t))return this.fetchSharedLinkUrl(e,i);throw t}}async fetchSharedLinkUrl(e,i){const t=(await this.runOperation(i,()=>this.client.sharedLinksFiles.getSharedLinkForFile(e,{fields:"shared_link"}))).sharedLink,r=t?.downloadUrl??t?.url;if(!r)throw new Error("Box: file has no shared link. Call write() with publicByDefault: true, or addShareLinkToFile via storage.raw.");return r}internalOnComplete=e=>this.deleteMeta(e.id)}export{ee as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as r}from"./local-meta-storage-BELb1YwO.js";class o extends r{constructor(e){super(e)}}export{o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Readable as w}from"node:stream";import{throwErrorCode as S,ERRORS as T,wrapStorageError as l}from"./ERRORS-BIBxE2oR.js";import{B as b}from"./storage-
|
|
1
|
+
import{Readable as w}from"node:stream";import{throwErrorCode as S,ERRORS as T,wrapStorageError as l}from"./ERRORS-BIBxE2oR.js";import{B as b}from"./storage-DR7qdwBN.js";import d from"./BunS3File-BcYmsz1n.js";import E from"./BunS3MetaStorage-CJsyeQ63.js";import{t as y}from"./get-file-status-y3wTtDQs.js";import{t as O}from"./update-size-DuNuLyxj.js";import{i as I}from"./part-match-D-9dGX42.js";import{e as v}from"./has-content-50BsqrWw.js";const c=s=>s.replace(/^\/+/u,""),C=async s=>{const e=[];for await(const i of s)e.push(Buffer.from(i));return Buffer.concat(e)},k=s=>{const e=s?.code;return typeof e=="string"&&/nosuchkey|notfound/iu.test(e)},p=(s,e)=>{const i=s?.code,t=typeof i=="string"?i:"";return/nosuchkey|notfound/iu.test(t)?l(s,{adapter:"Bun S3",operation:e,status:404}):/accessdenied|forbidden|ERR_S3_INVALID_SIGNATURE|ERR_S3_MISSING_CREDENTIALS/iu.test(t)?l(s,{adapter:"Bun S3",operation:e,status:403}):l(s,{adapter:"Bun S3",operation:e})},z=s=>{if(s.client)return s.client;const e=globalThis.Bun;if(!e?.S3Client)throw new Error("BunS3Storage requires the Bun runtime (Bun.S3Client). Run this under Bun, or pass a pre-built `client` instance. For Node/edge runtimes use the `aws` or `aws-light` provider instead.");return new e.S3Client({accessKeyId:s.accessKeyId,acl:s.acl,bucket:s.bucket,endpoint:s.endpoint,region:s.region,secretAccessKey:s.secretAccessKey,sessionToken:s.sessionToken,virtualHostedStyle:s.virtualHostedStyle})};class L extends b{static name="bun-s3";meta;client;constructor(e){super(e),this.client=z(e),this.meta=e.metaStorage??new E(e.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(e,i){return this.instrumentOperation("create",async()=>{const t=new d(e);t.name=this.namingFunction(t),t.bunS3Key=c(t.name),await this.validate(t);try{const n=await this.getMeta(t.id);if(n.bytesWritten>=0)return n}catch{}return t.bytesWritten=0,t.status=y(t),await this.saveMeta(t),await this.onCreate(t),t})}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&&O(t,e.size),!I(e,t))throw new Error("File part does not match");const n=await this.lock(e.id);try{if(v(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const r=await C(e.body),a=c(t.name||t.id);try{await this.runOperation(i,()=>this.client.write(a,r,{type:t.contentType}))}catch(o){throw p(o,"upload")}t.bytesWritten=r.length,t.size=r.length,t.bunS3Key=a}return t.status=y(t),t.status==="completed"&&await this.internalOnComplete(t),await this.saveMeta(t),t}finally{await this.unlock(e.id,n)}})}async delete({id:e},i){return this.instrumentOperation("delete",async()=>{let t;try{t=await this.getMeta(e)}catch{}const n=t?.bunS3Key??c(t?.name??e);try{await this.runOperation(i,()=>this.client.delete(n))}catch(a){if(!k(a))throw p(a,"delete")}if(t)return t.status="deleted",await this.deleteMeta(t.id),await this.onDelete(t),t;const r=new d({contentType:"application/octet-stream",metadata:{},originalName:e});return r.id=e,r.name=e,r.bunS3Key=n,r.status="deleted",r})}async get({id:e},i){return this.instrumentOperation("get",async()=>{let t,n;try{t=await this.checkIfExpired(await this.getMeta(e)),n=t.bunS3Key??c(t.name??e)}catch{n=c(e)}const r=this.client.file(n);let a,o;try{t||(o=await this.runOperation(i,()=>r.stat())),a=Buffer.from(await this.runOperation(i,()=>r.arrayBuffer()))}catch(u){throw p(u,"get")}return{content:a,contentType:t?.contentType??o?.type??"application/octet-stream",ETag:t?.ETag??o?.etag??void 0,expiredAt:t?.expiredAt,id:e,metadata:t?.metadata??{},modifiedAt:t?.modifiedAt??o?.lastModified?.toISOString(),name:t?.name??n,originalName:t?.originalName??n,size:t?.size??o?.size??a.length}})}async getStream({id:e},i){return this.instrumentOperation("getStream",async()=>{let t,n;try{t=await this.checkIfExpired(await this.getMeta(e)),n=t.bunS3Key??c(t.name??e)}catch{n=c(e)}const r=this.client.file(n);let a,o;try{a=await this.runOperation(i,()=>r.stat()),o=r.stream()}catch(f){throw p(f,"getStream")}const u=t?.size??a.size,g=t?.contentType??a.type??"application/octet-stream",h=t?.ETag??a.etag,m=t?.modifiedAt??a.lastModified?.toISOString();return{headers:{"Content-Length":String(u??0),"Content-Type":g,...h&&{ETag:h},...m&&{"Last-Modified":String(m)}},size:typeof u=="number"?u:void 0,stream:w.fromWeb(o)}})}async copy(e,i,t){return this.instrumentOperation("copy",async()=>{const n=await this.get({id:e},t),r=c(i);try{await this.runOperation(t,()=>this.client.write(r,n.content,{type:n.contentType}))}catch(o){throw p(o,"copy")}const a=new d({contentType:n.contentType,metadata:{},originalName:i});return a.id=i,a.name=i,a.bunS3Key=r,a.size=typeof n.size=="string"?Number(n.size):n.size??n.content.length,a.ETag=n.ETag,a.bunS3ETag=n.ETag,a})}async move(e,i,t){return this.instrumentOperation("move",async()=>{const n=await this.copy(e,i,t);return await this.delete({id:e},t),n})}async list(e=1e3,i){return this.instrumentOperation("list",async()=>{let t;try{t=await this.runOperation(i,()=>this.client.list({maxKeys:e}))}catch(n){throw p(n,"list")}return(t.contents??[]).filter(n=>!!n.key).slice(0,e).map(n=>{const r=c(n.key),a=new d({contentType:"application/octet-stream",metadata:{},originalName:r});return a.id=r,a.name=r,a.bunS3Key=r,a.size=n.size,a.ETag=n.eTag??void 0,a.bunS3ETag=n.eTag??void 0,a.modifiedAt=n.lastModified?new Date(n.lastModified).toISOString():void 0,a})},{limit:e})}async getReadUrl(e,i){return this.client.file(c(e)).presign({...i?.responseContentDisposition&&{contentDisposition:i.responseContentDisposition},...i?.expiresIn!==void 0&&{expiresIn:i.expiresIn},method:"GET",...i?.responseContentType&&{type:i.responseContentType}})}async getUploadUrl(e,i){return i?.contentLength!==void 0?S(T.BAD_REQUEST,"bun-s3: `contentLength` is not supported for upload URLs. A Bun presigned PUT has no content-length-range policy, so the cap would not bind; enforce size limits at your application gateway/proxy, or use a presigned POST form."):this.client.presign(c(e),{...i?.expiresIn!==void 0&&{expiresIn:i.expiresIn},method:"PUT",...i?.contentType&&{type:i.contentType}})}internalOnComplete=e=>this.deleteMeta(e.id)}export{L as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as r}from"./local-meta-storage-BELb1YwO.js";class o extends r{constructor(e){super(e)}}export{o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as c from"@bunny.net/storage-sdk";import{throwErrorCode as d,ERRORS as y,wrapStorageError as l}from"./ERRORS-BIBxE2oR.js";import{B as O}from"./storage-
|
|
1
|
+
import*as c from"@bunny.net/storage-sdk";import{throwErrorCode as d,ERRORS as y,wrapStorageError as l}from"./ERRORS-BIBxE2oR.js";import{B as O}from"./storage-DR7qdwBN.js";import m from"./BunnyFile-BgEOlcYI.js";import T from"./BunnyMetaStorage-CJsyeQ63.js";import{t as w}from"./get-file-status-y3wTtDQs.js";import{t as N}from"./update-size-DuNuLyxj.js";import{i as A}from"./part-match-D-9dGX42.js";import{e as _}from"./has-content-50BsqrWw.js";const f=new Set(Object.values(c.regions.StorageRegion)),h=r=>`/${r.replace(/^\/+/u,"")}`,g=r=>r.replace(/^\/+/u,""),B=(r,t)=>{const n=r.replace(/\/+$/u,""),e=t.replace(/^\/+/u,"");return`${n}/${e}`},b=async r=>{const t=[];for await(const n of r)t.push(Buffer.from(n));return Buffer.concat(t)},E=r=>new ReadableStream({start(t){t.enqueue(new Uint8Array(r)),t.close()}}),R=r=>{if(r){if(!f.has(r))throw new Error(`Bunny Storage: unsupported region "${r}". Pass one of ${[...f].join(", ")}.`);return r}},C=r=>{if(r.client)return r.client;const t=r.zone??process.env.BUNNY_STORAGE_ZONE??process.env.STORAGE_ZONE,n=r.accessKey??process.env.BUNNY_STORAGE_ACCESS_KEY??process.env.BUNNY_ACCESS_KEY??process.env.STORAGE_ACCESS_KEY,e=R(r.region??process.env.BUNNY_STORAGE_REGION??process.env.STORAGE_REGION);if(!t||!n||!e)throw new Error("Bunny Storage: missing credentials. Pass `zone` + `accessKey` + `region`, or set BUNNY_STORAGE_ZONE / BUNNY_STORAGE_ACCESS_KEY / BUNNY_STORAGE_REGION (SDK aliases: STORAGE_ZONE / STORAGE_ACCESS_KEY / STORAGE_REGION).");return c.zone.connect_with_accesskey(e,t,n)},U=async r=>Buffer.from(await new Response(r).arrayBuffer()),p=(r,t)=>{const n=r?.message,e=typeof n=="string"?n:"";return/^file not found/iu.test(e)?l(r,{adapter:"Bunny Storage",operation:t,status:404}):/^unauthorized access/iu.test(e)?l(r,{adapter:"Bunny Storage",operation:t,status:401}):/^unable to upload file/iu.test(e)?l(r,{adapter:"Bunny Storage",operation:t,status:400}):l(r,{adapter:"Bunny Storage",operation:t})};class M extends O{static name="bunny";checksumTypes=["SHA256"];meta;client;publicBaseUrl;zoneName;constructor(t){super(t),this.client=C(t),this.zoneName=c.zone.name(this.client),this.publicBaseUrl=t.publicBaseUrl,this.meta=t.metaStorage??new T(t.metaStorageConfig),this.isReady=!0}get raw(){return this.client}get zone(){return this.zoneName}async create(t,n){return this.instrumentOperation("create",async()=>{const e=new m(t);e.name=this.namingFunction(e),e.bunnyPath=h(e.name),await this.validate(e);try{const a=await this.getMeta(e.id);if(a.bytesWritten>=0)return a}catch{}return e.bytesWritten=0,e.status=w(e),await this.saveMeta(e),await this.onCreate(e),e})}async write(t,n){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&&N(e,t.size),!A(t,e))throw new Error("File part does not match");const a=await this.lock(t.id);try{if(_(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const i=await b(t.body),o=h(e.name||e.id);try{await this.runOperation(n,()=>c.file.upload(this.client,o,E(i),{contentType:e.contentType,...t.checksum&&t.checksumAlgorithm==="sha256"&&{sha256Checksum:t.checksum}}))}catch(s){throw p(s,"upload")}e.bytesWritten=i.length,e.size=i.length,e.bunnyPath=o}return e.status=w(e),e.status==="completed"&&await this.internalOnComplete(e),await this.saveMeta(e),e}finally{await this.unlock(t.id,a)}})}async delete({id:t},n){return this.instrumentOperation("delete",async()=>{let e;try{e=await this.getMeta(t)}catch{}const a=e?.bunnyPath??h(e?.name??t);try{await this.runOperation(n,()=>c.file.remove(this.client,a))}catch(o){throw p(o,"delete")}if(e)return e.status="deleted",await this.deleteMeta(e.id),await this.onDelete(e),e;const i=new m({contentType:"application/octet-stream",metadata:{},originalName:t});return i.id=t,i.name=t,i.bunnyPath=a,i.status="deleted",i})}async get({id:t},n){return this.instrumentOperation("get",async()=>{let e,a;try{e=await this.checkIfExpired(await this.getMeta(t)),a=e.bunnyPath??h(e.name??t)}catch{a=h(t)}let i;try{i=await this.runOperation(n,()=>c.file.get(this.client,a))}catch(s){throw p(s,"get")}let o;try{const s=await this.runOperation(n,()=>i.data());o=await U(s.stream)}catch(s){throw p(s,"download")}return{content:o,contentType:e?.contentType??i.contentType??"application/octet-stream",ETag:e?.ETag??i.checksum??void 0,expiredAt:e?.expiredAt,id:t,metadata:e?.metadata??{},modifiedAt:e?.modifiedAt??i.lastChanged?.toISOString(),name:e?.name??g(a),originalName:e?.originalName??g(a),size:e?.size??i.length??o.length}})}async copy(t,n,e){return this.instrumentOperation("copy",async()=>{const a=await this.get({id:t},e),i=h(n),o=a.content,s=typeof a.size=="string"?Number(a.size):a.size??o.length;try{await this.runOperation(e,()=>c.file.upload(this.client,i,E(o),{contentType:a.contentType}))}catch(S){throw p(S,"copy")}const u=new m({contentType:a.contentType,metadata:{},originalName:n});return u.id=n,u.name=n,u.bunnyPath=i,u.size=s,u.ETag=a.ETag,u.bunnyChecksum=a.ETag,u})}async move(t,n,e){return this.instrumentOperation("move",async()=>{const a=await this.copy(t,n,e);return await this.delete({id:t},e),a})}async list(t=1e3,n){return this.instrumentOperation("list",async()=>{let e;try{e=await this.runOperation(n,()=>c.file.list(this.client,"/"))}catch(a){throw p(a,"list")}return e.filter(a=>!a.isDirectory).slice(0,t).map(a=>{const i=a.path.endsWith(a.objectName)||!a.objectName?a.path:`${a.path.replace(/\/+$/u,"")}/${a.objectName}`,o=g(i),s=new m({contentType:a.contentType||"application/octet-stream",metadata:{},originalName:o});return s.id=o,s.name=o,s.bunnyPath=h(o),s.bunnyChecksum=a.checksum??void 0,s.ETag=a.checksum??void 0,s.size=a.length,s.modifiedAt=a.lastChanged?.toISOString(),s})},{limit:t})}async getReadUrl(t,n){return n?.responseContentDisposition!==void 0||n?.responseContentType!==void 0?d(y.METHOD_NOT_ALLOWED,"Bunny Storage: `responseContentDisposition`/`responseContentType` are not supported — no override exists on Bunny Storage / Pull Zone URLs."):this.publicBaseUrl?B(this.publicBaseUrl,t):d(y.METHOD_NOT_ALLOWED,"Bunny Storage: `getReadUrl` requires `publicBaseUrl` (for example a Bunny Pull Zone or custom CDN hostname). The Storage API URL itself requires an AccessKey header and cannot be handed out as a public URL.")}async getUploadUrl(t,n){return d(y.METHOD_NOT_ALLOWED,"Bunny Storage: presigned PUT URLs are not supported — writes go through the Storage API with an AccessKey header. Upload server-side via the SDK or proxy through your application.")}internalOnComplete=t=>this.deleteMeta(t.id)}export{M as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as s}from"./local-meta-storage-BELb1YwO.js";class o extends s{constructor(r){super(r)}}export{o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v2 as p}from"cloudinary";import{throwErrorCode as u,ERRORS as l}from"./ERRORS-BIBxE2oR.js";import{B as d}from"./storage-
|
|
1
|
+
import{v2 as p}from"cloudinary";import{throwErrorCode as u,ERRORS as l}from"./ERRORS-BIBxE2oR.js";import{B as d}from"./storage-DR7qdwBN.js";import c from"./CloudinaryFile-Bo5B-vM1.js";import h from"./CloudinaryMetaStorage-Bv_YCZ0Q.js";import{t as y}from"./get-file-status-y3wTtDQs.js";import{t as m}from"./update-size-DuNuLyxj.js";import{i as f}from"./part-match-D-9dGX42.js";import{e as w}from"./has-content-50BsqrWw.js";const v=async o=>{const e=[];for await(const a of o)e.push(Buffer.from(a));return Buffer.concat(e)},_=o=>{if(!o)return{};const e=o.match(/^cloudinary:\/\/([^:]+):([^@]+)@(.+)$/);return e?{apiKey:e[1],apiSecret:e[2],cloudName:e[3]}:{}};class M extends d{static name="cloudinary";checksumTypes=[];meta;client;defaultUrlExpiresIn;deliveryType;resourceType;secure;constructor(e){if(super(e),this.resourceType=e.resourceType??"raw",this.deliveryType=e.type??"upload",this.secure=e.secure??!0,this.defaultUrlExpiresIn=e.defaultUrlExpiresIn??3600,e.client)this.client=e.client;else{const a=_(process.env.CLOUDINARY_URL),t=e.cloudName??process.env.CLOUDINARY_CLOUD_NAME??a.cloudName,r=e.apiKey??process.env.CLOUDINARY_API_KEY??a.apiKey,i=e.apiSecret??process.env.CLOUDINARY_API_SECRET??a.apiSecret;if(!t)throw new Error("Cloudinary storage: `cloudName` is required (or set CLOUDINARY_CLOUD_NAME / CLOUDINARY_URL).");p.config({api_key:r,api_secret:i,cloud_name:t,secure:this.secure}),this.client=p}this.meta=e.metaStorage??new h(e.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(e,a){return this.instrumentOperation("create",async()=>{const t=new c(e);t.name=this.namingFunction(t),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=y(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&&m(t,e.size),!f(e,t))throw new Error("File part does not match");const r=await this.lock(e.id);try{if(w(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const i=await v(e.body),s=t.path??t.name,n=await this.runOperation(a,()=>this.uploadBuffer(s,i));t.bytesWritten=i.length,t.size=i.length,t.path=n.public_id??s,t.publicUrl=n.secure_url??n.url,t.ETag=n.version===void 0?void 0:String(n.version)}return t.status=y(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;return await this.runOperation(a,()=>this.client.uploader.destroy(r,{invalidate:!0,resource_type:this.resourceType,type:this.deliveryType})),t?(t.status="deleted",await this.deleteMeta(t.id),await this.onDelete(t),t):Object.assign(new c({contentType:"application/octet-stream",metadata:{},originalName:e}),{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{}try{return await this.runOperation(a,()=>this.client.api.resource(t,{resource_type:this.resourceType,type:this.deliveryType})),!0}catch{return!1}})}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 i=await this.runOperation(a,()=>this.client.api.resource(t,{resource_type:this.resourceType,type:this.deliveryType})),s=await this.runOperation(a,()=>fetch(this.client.url(t,{resource_type:this.resourceType,secure:this.secure,type:this.deliveryType})));if(!s.ok)throw new Error(`Cloudinary: object not found at "${t}"`);const n=Buffer.from(await s.arrayBuffer());return{content:n,contentType:r?.contentType??(i.resource_type&&i.format?`${i.resource_type}/${i.format}`:void 0)??"application/octet-stream",ETag:r?.ETag??(i.version===void 0?void 0:String(i.version)),expiredAt:r?.expiredAt,id:e,metadata:r?.metadata??{},modifiedAt:r?.modifiedAt,name:r?.name??t,originalName:r?.originalName??t,size:r?.size??(typeof i.bytes=="number"?i.bytes:n.length)}})}async copy(e,a,t){return this.instrumentOperation("copy",async()=>{const r=(await this.getMetaSafe(e))?.path??e,i=this.client.url(r,{resource_type:this.resourceType,secure:this.secure,type:this.deliveryType});await this.runOperation(t,()=>this.client.uploader.upload(i,{overwrite:!0,public_id:a,resource_type:this.resourceType,type:this.deliveryType}));const s=new c({contentType:"application/octet-stream",metadata:{},originalName:a});return s.id=a,s.name=a,s.path=a,s})}async move(e,a,t){return this.instrumentOperation("move",async()=>{const r=(await this.getMetaSafe(e))?.path??e;await this.runOperation(t,()=>this.client.uploader.rename(r,a,{resource_type:this.resourceType}));const i=new c({contentType:"application/octet-stream",metadata:{},originalName:a});i.id=a,i.name=a,i.path=a;try{await this.deleteMeta(e)}catch{}return i})}async list(e=1e3,a){return this.instrumentOperation("list",async()=>{const{resources:t}=await this.runOperation(a,()=>this.client.api.resources({max_results:e,resource_type:this.resourceType,type:this.deliveryType}));return(t??[]).map(r=>{const i=new c({contentType:r.resource_type&&r.format?`${r.resource_type}/${r.format}`:"application/octet-stream",metadata:{},originalName:r.public_id});return i.id=r.public_id,i.name=r.public_id,i.path=r.public_id,i.size=typeof r.bytes=="number"?r.bytes:void 0,i.createdAt=r.created_at??void 0,i.ETag=r.version===void 0?void 0:String(r.version),i})},{limit:e})}async getReadUrl(e,a){if(a?.responseContentDisposition!==void 0||a?.responseContentType!==void 0)return u(l.BAD_REQUEST,"cloudinary: `responseContentDisposition`/`responseContentType` are not supported. A public delivery URL has no signature in which to bind the override, and Cloudinary's signed download URL cannot pin an arbitrary Content-Disposition/Content-Type; set the disposition via a Cloudinary delivery transformation instead.");if(this.deliveryType==="upload")return this.client.url(e,{resource_type:this.resourceType,secure:this.secure,type:this.deliveryType});const t=a?.expiresIn??this.defaultUrlExpiresIn,r=e.lastIndexOf("."),i=r>0?e.slice(r+1):"";try{return this.client.utils.private_download_url(e,i,{expires_at:Math.floor(Date.now()/1e3)+t,resource_type:this.resourceType,type:this.deliveryType})}catch(s){return u(l.METHOD_NOT_ALLOWED,s instanceof Error?s.message:"Cloudinary: private_download_url failed")}}uploadBuffer(e,a){return new Promise((t,r)=>{this.client.uploader.upload_stream({overwrite:!0,public_id:e,resource_type:this.resourceType,type:this.deliveryType},(i,s)=>{if(i||!s){r(i instanceof Error?i:new Error(i?.message??"Cloudinary: upload failed"));return}t(s)}).end(a)})}async getMetaSafe(e){try{return await this.getMeta(e)}catch{return}}internalOnComplete=e=>this.deleteMeta(e.id)}export{M as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:fs";import"node:fs/promises";import"node:stream";import"./local-meta-storage-BELb1YwO.js";import"./path-C-OWflAo-_mqb5p5d.js";import"./index-nZWCQrSe.js";import"./detect-file-type-BA7UBLKA.js";import"./ERRORS-BIBxE2oR.js";import{w as c}from"./disk-storage-DqnnFQAQ.js";import"./storage-DR7qdwBN.js";import"./File-W8aOo15X.js";import"./get-file-status-y3wTtDQs.js";import"./update-size-DuNuLyxj.js";import"./part-match-D-9dGX42.js";import"./has-content-50BsqrWw.js";export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createReadStream as l,createWriteStream as y}from"node:fs";import{truncate as g}from"node:fs/promises";import{Transform as f,pipeline as w}from"node:stream";import{u as b,h as E}from"./local-meta-storage-
|
|
1
|
+
import{createReadStream as l,createWriteStream as y}from"node:fs";import{truncate as g}from"node:fs/promises";import{Transform as f,pipeline as w}from"node:stream";import{u as b,h as E}from"./local-meta-storage-BELb1YwO.js";import{d as F}from"./detect-file-type-BA7UBLKA.js";import{throwErrorCode as c,ERRORS as h}from"./ERRORS-BIBxE2oR.js";import{w as C,n as T,s as W}from"./disk-storage-DqnnFQAQ.js";import{LRUCache as N}from"lru-cache";import{createHash as S}from"node:crypto";import{t as R}from"./update-size-DuNuLyxj.js";import{i as x}from"./part-match-D-9dGX42.js";import{e as M}from"./has-content-50BsqrWw.js";import{t as _}from"./get-file-status-y3wTtDQs.js";class k extends f{constructor(t,e){super(),this.path=e,this.hashes=t,this.hash=this.hashes.get(e)||S(this.hashes.algorithm),this.hashCopy=this.hash.copy()}path;hash;hashCopy;hashes;reset(){this.hashes.set(this.path,this.hashCopy)}digest(t="hex"){return this.hash.copy().digest(t)}_transform(t,e,s){this.push(t),this.hash.update(t),s()}_flush(t){t()}}class I extends N{constructor(t="sha1",e){super({ttl:1e3,ttlAutopurge:!0,...e}),this.algorithm=t}algorithm;hex(t){return this.get(t)?.copy().digest("hex")||""}base64(t){return this.get(t)?.copy().digest("base64")||""}async init(t,e=0){return this.get(t)?.copy()||this.updateFromFs(t,e)}digester(t){return new k(this,t)}async updateFromFs(t,e=0,s){const r=await this.fromFs(t,e,s);return this.set(t,r),r}fromFs(t,e=0,s){return new Promise((r,i)=>{const a=this.digester(t);s!==void 0&&(a.hash=s),l(t,{start:e}).on("error",i).on("end",()=>{r(a.hash)}).pipe(a).resume()})}}class j extends C{hashes;constructor(t){super(t),this.hashes=new I(t?.checksum==="sha1"?"sha1":"md5")}async delete({id:t}){try{const e=await this.getMeta(t),s=this.getFilePath(e.name);this.hashes.delete(s),await b(s),await this.deleteMeta(t);const r={...e,status:"deleted"};return await this.onDelete(r),r}catch(e){this.logger?.error("[error]: Could not delete file: %O",e);const s=this.normalizeError(e instanceof Error?e:new Error(String(e)));await this.onError(s)}return{id:t}}async write(t){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&&R(e,t.size),!x(t,e))return c(h.FILE_CONFLICT);const s=this.getFilePath(e.name);try{const r=t.start||0;if(await E(s),(e.bytesWritten===0||Number.isNaN(e.bytesWritten))&&(e.bytesWritten=r),await this.hashes.init(s),M(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))return c(h.UNSUPPORTED_CHECKSUM_ALGORITHM);if((t.start===0||t.start===void 0)&&(e.bytesWritten===0||Number.isNaN(e.bytesWritten))&&(!e.contentType||e.contentType==="application/octet-stream"))try{const{fileType:o,stream:n}=await F(t.body);o?.mime&&(e.contentType=o.mime),t.body=n}catch{}const[i,a]=await this.lazyWrite({...t,...e});if(a)return await g(s,e.bytesWritten),c(a);typeof i!="number"&&await this.hashes.updateFromFs(s,e.bytesWritten),e.bytesWritten=i}return e.status=_(e),e.hash={algorithm:this.hashes.algorithm,value:this.hashes.hex(s)},e.status==="completed"&&this.hashes.delete(s),await this.saveMeta(e),e}catch(r){await this.hashes.updateFromFs(s,e.bytesWritten);const i=this.normalizeError(r instanceof Error?r:new Error(String(r)));return await this.onError(i),c(h.FILE_ERROR,(typeof i.message=="string"?i.message:String(r))||String(r))}}lazyWrite(t){return new Promise((e,s)=>{const r=this.getFilePath(t.name),i=y(r,{flags:"r+",start:t.start}),a=new T(t.contentLength||Number(t.size)-t.start),o=W(t.checksum,t.checksumAlgorithm),n=this.hashes.digester(r),d=!t.checksum,u=m=>{n.reset(),i.close(),e([Number.NaN,m])};a.on("error",()=>{u(h.FILE_CONFLICT)}),o.on("error",()=>{u(h.CHECKSUM_MISMATCH)}),t.body.on("aborted",()=>{u(d?void 0:h.REQUEST_ABORTED)}),w(t.body,a,o,n,i,m=>{if(m){n.reset(),s(m);return}e([t.start+i.bytesWritten])})})}}export{j as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as r}from"./local-meta-storage-BELb1YwO.js";class o extends r{constructor(e){super(e)}}export{o as default};
|