@visulima/storage 1.0.10 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE.md +33 -22
  3. package/dist/adapter/nuxt/module.d.ts +5 -4
  4. package/dist/ai/ai-sdk/index.d.ts +4 -3
  5. package/dist/ai/claude/index.d.ts +3 -2
  6. package/dist/ai/openai/index.d.ts +4 -3
  7. package/dist/ai/tanstack/index.d.ts +3 -2
  8. package/dist/handler/http/fetch/index.d.ts +8 -7
  9. package/dist/handler/http/fetch/index.js +1 -1
  10. package/dist/handler/http/hono/index.d.ts +5 -4
  11. package/dist/handler/http/hono/index.js +1 -1
  12. package/dist/handler/http/nextjs/index.d.ts +5 -4
  13. package/dist/handler/http/nextjs/index.js +1 -1
  14. package/dist/handler/http/node/index.d.ts +8 -7
  15. package/dist/handler/http/node/index.js +1 -1
  16. package/dist/handler/http/solid-start/index.d.ts +5 -4
  17. package/dist/handler/http/solid-start/index.js +1 -1
  18. package/dist/index.d.ts +8 -7
  19. package/dist/index.js +1 -1
  20. package/dist/packem_shared/{AbstractBaseStorage-CiPEMcuo.js → AbstractBaseStorage-CLsYmMZg.js} +1 -1
  21. package/dist/packem_shared/AwsLightStorage-DGSPFUqr.js +1 -0
  22. package/dist/packem_shared/AzureStorage-DvKk_hhz.js +1 -0
  23. package/dist/packem_shared/BoxMetaStorage-CJsyeQ63.js +1 -0
  24. package/dist/packem_shared/{BoxStorage-B8_oCz27.js → BoxStorage-CmM95wi2.js} +1 -1
  25. package/dist/packem_shared/BunS3MetaStorage-CJsyeQ63.js +1 -0
  26. package/dist/packem_shared/{BunS3Storage-_PVXu_na.js → BunS3Storage-B_roVJ29.js} +1 -1
  27. package/dist/packem_shared/BunnyMetaStorage-CJsyeQ63.js +1 -0
  28. package/dist/packem_shared/{BunnyStorage-BsoWjScH.js → BunnyStorage-eZ1QDVaY.js} +1 -1
  29. package/dist/packem_shared/CloudinaryMetaStorage-Bv_YCZ0Q.js +1 -0
  30. package/dist/packem_shared/{CloudinaryStorage-BNwiLF9V.js → CloudinaryStorage-CpH2f0Fv.js} +1 -1
  31. package/dist/packem_shared/DiskStorage-DzjjqCzo.js +1 -0
  32. package/dist/packem_shared/{DiskStorageWithChecksum-UnCtyEvs.js → DiskStorageWithChecksum-MZkDEyts.js} +1 -1
  33. package/dist/packem_shared/DropboxMetaStorage-CJsyeQ63.js +1 -0
  34. package/dist/packem_shared/{DropboxStorage-BS9kj0nH.js → DropboxStorage-BB9NoWK2.js} +1 -1
  35. package/dist/packem_shared/{Files-CpIcMjP0.js → Files-DyMJ9FPN.js} +1 -1
  36. package/dist/packem_shared/FirebaseMetaStorage-Bv_YCZ0Q.js +1 -0
  37. package/dist/packem_shared/{FirebaseStorage-DNquii2p.js → FirebaseStorage-BgbxzYNC.js} +1 -1
  38. package/dist/packem_shared/FtpMetaStorage-CJsyeQ63.js +1 -0
  39. package/dist/packem_shared/{FtpStorage-Bd004--s.js → FtpStorage-CNqXDz7P.js} +1 -1
  40. package/dist/packem_shared/{GCSMetaStorage-Bf4qDFB1.js → GCSMetaStorage-Cm_XzR0C.js} +1 -1
  41. package/dist/packem_shared/GCStorage-DcvsI7eu.js +1 -0
  42. package/dist/packem_shared/GoogleDriveMetaStorage-B0gLF7Io.js +1 -0
  43. package/dist/packem_shared/{GoogleDriveStorage-v1glykjd.js → GoogleDriveStorage-Du7uBhSm.js} +1 -1
  44. package/dist/packem_shared/{LocalMetaStorage-YWPBYEe7.js → LocalMetaStorage-CcGfFG39.js} +1 -1
  45. package/dist/packem_shared/{MemoryStorage-9gbWd09l.js → MemoryStorage-ChKyI6OY.js} +1 -1
  46. package/dist/packem_shared/{Multipart-D0ok6BBy.js → Multipart-C35TR2qL.js} +1 -1
  47. package/dist/packem_shared/{Multipart-CQjYqU--.js → Multipart-V64Bg5dt.js} +1 -1
  48. package/dist/packem_shared/NetlifyBlobMetaStorage-Bv_YCZ0Q.js +1 -0
  49. package/dist/packem_shared/NetlifyBlobStorage-CZsr_0DF.js +1 -0
  50. package/dist/packem_shared/OneDriveMetaStorage-B0gLF7Io.js +1 -0
  51. package/dist/packem_shared/{OneDriveStorage-BJ3Kzxc5.js → OneDriveStorage-B8qFgMq1.js} +1 -1
  52. package/dist/packem_shared/PocketBaseMetaStorage-Cm3v8g1-.js +1 -0
  53. package/dist/packem_shared/{PocketBaseStorage-DqKHbbvn.js → PocketBaseStorage-D2vMN-oY.js} +1 -1
  54. package/dist/packem_shared/{Rest-DvfN4-kf.js → Rest-BrEMYgxZ.js} +1 -1
  55. package/dist/packem_shared/{Rest-CI_BiZPv.js → Rest-aPVP2ww1.js} +1 -1
  56. package/dist/packem_shared/{S3Storage-BiI2k6d1.js → S3Storage-CTe_BMDl.js} +1 -1
  57. package/dist/packem_shared/SftpMetaStorage-CJsyeQ63.js +1 -0
  58. package/dist/packem_shared/{SftpStorage-w8XdtZtw.js → SftpStorage-BKeAzuej.js} +1 -1
  59. package/dist/packem_shared/SharePointMetaStorage-CJsyeQ63.js +1 -0
  60. package/dist/packem_shared/{SharePointStorage-DpDpI7Ln.js → SharePointStorage-Dtnt5-wk.js} +1 -1
  61. package/dist/packem_shared/SupabaseMetaStorage-B0gLF7Io.js +1 -0
  62. package/dist/packem_shared/{SupabaseStorage-B_ugUCs7.js → SupabaseStorage-CmGQjqXf.js} +1 -1
  63. package/dist/packem_shared/{Tus-BlBZykIL.js → Tus-CJBgnJrn.js} +1 -1
  64. package/dist/packem_shared/{Tus-BBVt2ky3.js → Tus-D9c7KDnl.js} +1 -1
  65. package/dist/packem_shared/UploadThingMetaStorage-Bv_YCZ0Q.js +1 -0
  66. package/dist/packem_shared/{UploadThingStorage-_H45IVqX.js → UploadThingStorage-DZ4zNvDH.js} +1 -1
  67. package/dist/packem_shared/VercelBlobMetaStorage-CJsyeQ63.js +1 -0
  68. package/dist/packem_shared/{VercelBlobStorage-U1YMKeHs.js → VercelBlobStorage-DDNEofR3.js} +1 -1
  69. package/dist/packem_shared/{base-handler-core-D-9Ku1h-.js → base-handler-core-BJP9jHCE.js} +1 -1
  70. package/dist/packem_shared/{base-handler-fetch-CfkNakv8.js → base-handler-fetch-yrYrukwL.js} +1 -1
  71. package/dist/packem_shared/base-handler-node-C8P9rkaH.js +1 -0
  72. package/dist/packem_shared/{createRetryWrapper-CxgiV_hH.js → createRetryWrapper-DgmeHPNF.js} +1 -1
  73. package/dist/packem_shared/disk-storage-DqnnFQAQ.js +1 -0
  74. package/dist/packem_shared/{disk-storage-with-checksum.d-CQucFacO.d.ts → disk-storage-with-checksum.d-Dgwyza8a.d.ts} +1 -1
  75. package/dist/packem_shared/{executors.d-DeDH3Ilt.d.ts → executors.d-B9dIy3NT.d.ts} +2 -1
  76. package/dist/packem_shared/{files.d-D8H_ge9Y.d.ts → files.d-CmSZi3M0.d.ts} +1 -1
  77. package/dist/packem_shared/gcs-meta-storage-Bu2upyHK.js +1 -0
  78. package/dist/packem_shared/local-meta-storage-BELb1YwO.js +11 -0
  79. package/dist/packem_shared/{local-meta-storage.d-DuTEzyii.d.ts → local-meta-storage.d-cRTXr1kb.d.ts} +1 -1
  80. package/dist/packem_shared/{media-transformer.d-CvMFjINm.d.ts → media-transformer.d-C8tn4J2Z.d.ts} +2 -2
  81. package/dist/packem_shared/{memory-storage.d-BRdTiY8y.d.ts → memory-storage.d-BNZvDG1b.d.ts} +1 -1
  82. package/dist/packem_shared/path-C-OWflAo-_mqb5p5d.js +1 -0
  83. package/dist/packem_shared/{rest-base-e0reNDE_.js → rest-base-BQ_dhWyV.js} +1 -1
  84. package/dist/packem_shared/s3-base-storage-CX94H-Za.js +1 -0
  85. package/dist/packem_shared/{s3-base-storage.d-Cg7m4FuH.d.ts → s3-base-storage.d-ks99NSs-.d.ts} +1 -1
  86. package/dist/packem_shared/storage-DR7qdwBN.js +1 -0
  87. package/dist/packem_shared/{storage.d-DIav_lF1.d.ts → storage.d-DwdJrArF.d.ts} +26 -3
  88. package/dist/packem_shared/{tus-base.d-BiEg5t4t.d.ts → tus-base.d-BKBoJVy0.d.ts} +4 -3
  89. package/dist/packem_shared/{types.d-DgHhkCAl.d.ts → types.d-B1_xZIhu.d.ts} +1 -1
  90. package/dist/packem_shared/{types.d-CAAzKiI6.d.ts → types.d-BEUv414z.d.ts} +1 -1
  91. package/dist/packem_shared/{types.d-jAs_Rp_v.d.ts → types.d-D7Zlz5RE.d.ts} +2 -2
  92. package/dist/storage/aws/index.d.ts +3 -2
  93. package/dist/storage/aws/index.js +1 -1
  94. package/dist/storage/aws-light/index.d.ts +3 -2
  95. package/dist/storage/aws-light/index.js +1 -1
  96. package/dist/storage/azure/index.d.ts +2 -1
  97. package/dist/storage/azure/index.js +1 -1
  98. package/dist/storage/box/index.d.ts +3 -2
  99. package/dist/storage/box/index.js +1 -1
  100. package/dist/storage/bun-s3/index.d.ts +3 -2
  101. package/dist/storage/bun-s3/index.js +1 -1
  102. package/dist/storage/bunny/index.d.ts +3 -2
  103. package/dist/storage/bunny/index.js +1 -1
  104. package/dist/storage/cloudinary/index.d.ts +3 -2
  105. package/dist/storage/cloudinary/index.js +1 -1
  106. package/dist/storage/dropbox/index.d.ts +3 -2
  107. package/dist/storage/dropbox/index.js +1 -1
  108. package/dist/storage/firebase/index.d.ts +3 -2
  109. package/dist/storage/firebase/index.js +1 -1
  110. package/dist/storage/ftp/index.d.ts +3 -2
  111. package/dist/storage/ftp/index.js +1 -1
  112. package/dist/storage/gcs/index.d.ts +2 -1
  113. package/dist/storage/gcs/index.js +1 -1
  114. package/dist/storage/google-drive/index.d.ts +3 -2
  115. package/dist/storage/google-drive/index.js +1 -1
  116. package/dist/storage/local/index.d.ts +4 -3
  117. package/dist/storage/local/index.js +1 -1
  118. package/dist/storage/memory/index.d.ts +3 -2
  119. package/dist/storage/memory/index.js +1 -1
  120. package/dist/storage/netlify-blob/index.d.ts +3 -2
  121. package/dist/storage/netlify-blob/index.js +1 -1
  122. package/dist/storage/onedrive/index.d.ts +5 -4
  123. package/dist/storage/onedrive/index.js +1 -1
  124. package/dist/storage/pocketbase/index.d.ts +3 -2
  125. package/dist/storage/pocketbase/index.js +1 -1
  126. package/dist/storage/sftp/index.d.ts +3 -2
  127. package/dist/storage/sftp/index.js +1 -1
  128. package/dist/storage/sharepoint/index.d.ts +4 -3
  129. package/dist/storage/sharepoint/index.js +1 -1
  130. package/dist/storage/supabase/index.d.ts +3 -2
  131. package/dist/storage/supabase/index.js +1 -1
  132. package/dist/storage/uploadthing/index.d.ts +3 -2
  133. package/dist/storage/uploadthing/index.js +1 -1
  134. package/dist/storage/vercel-blob/index.d.ts +3 -2
  135. package/dist/storage/vercel-blob/index.js +1 -1
  136. package/dist/transformer/audio-transformer.d.ts +3 -2
  137. package/dist/transformer/image-transformer.d.ts +3 -2
  138. package/dist/transformer/index.d.ts +4 -3
  139. package/dist/transformer/video-transformer.d.ts +3 -2
  140. package/package.json +2 -2
  141. package/dist/packem_shared/AwsLightStorage-EsqkAtU5.js +0 -1
  142. package/dist/packem_shared/AzureStorage-DL-U7qFG.js +0 -1
  143. package/dist/packem_shared/BoxMetaStorage-CHWrhgg2.js +0 -1
  144. package/dist/packem_shared/BunS3MetaStorage-CHWrhgg2.js +0 -1
  145. package/dist/packem_shared/BunnyMetaStorage-CHWrhgg2.js +0 -1
  146. package/dist/packem_shared/CloudinaryMetaStorage-BI9YXcwU.js +0 -1
  147. package/dist/packem_shared/DiskStorage-D-NtQDms.js +0 -1
  148. package/dist/packem_shared/DropboxMetaStorage-CHWrhgg2.js +0 -1
  149. package/dist/packem_shared/FirebaseMetaStorage-BI9YXcwU.js +0 -1
  150. package/dist/packem_shared/FtpMetaStorage-CHWrhgg2.js +0 -1
  151. package/dist/packem_shared/GCStorage-ChqEpgqR.js +0 -1
  152. package/dist/packem_shared/GoogleDriveMetaStorage-xlHfKwmR.js +0 -1
  153. package/dist/packem_shared/NetlifyBlobMetaStorage-BI9YXcwU.js +0 -1
  154. package/dist/packem_shared/NetlifyBlobStorage-BPyEWSnx.js +0 -1
  155. package/dist/packem_shared/OneDriveMetaStorage-xlHfKwmR.js +0 -1
  156. package/dist/packem_shared/PocketBaseMetaStorage-DnrxOQhO.js +0 -1
  157. package/dist/packem_shared/SftpMetaStorage-CHWrhgg2.js +0 -1
  158. package/dist/packem_shared/SharePointMetaStorage-CHWrhgg2.js +0 -1
  159. package/dist/packem_shared/SupabaseMetaStorage-xlHfKwmR.js +0 -1
  160. package/dist/packem_shared/UploadThingMetaStorage-BI9YXcwU.js +0 -1
  161. package/dist/packem_shared/VercelBlobMetaStorage-CHWrhgg2.js +0 -1
  162. package/dist/packem_shared/base-handler-node-BF1v1qDa.js +0 -1
  163. package/dist/packem_shared/disk-storage-BwPk2IRa.js +0 -1
  164. package/dist/packem_shared/gcs-meta-storage-DQGu_cHq.js +0 -1
  165. package/dist/packem_shared/local-meta-storage-DJDcuxf1.js +0 -11
  166. package/dist/packem_shared/path-0oTTdkvl-DvWvbDbh.js +0 -1
  167. package/dist/packem_shared/s3-base-storage-CMUui93V.js +0 -1
  168. package/dist/packem_shared/storage-0j5nCAUp.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## @visulima/storage [2.0.0](https://github.com/visulima/visulima/compare/%40visulima%2Fstorage%401.0.11...%40visulima%2Fstorage%402.0.0) (2026-08-08)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/pagination:** upgraded to 7.0.0
7
+ * **@visulima/fs:** upgraded to 6.0.0
8
+ * **@visulima/humanizer:** upgraded to 4.0.0
9
+ * **@visulima/path:** upgraded to 4.0.0
10
+
11
+ ## @visulima/storage [1.0.11](https://github.com/visulima/visulima/compare/%40visulima%2Fstorage%401.0.10...%40visulima%2Fstorage%401.0.11) (2026-08-02)
12
+
13
+
14
+ ### Dependencies
15
+
16
+ * **@visulima/pagination:** upgraded to 6.0.0
17
+ * **@visulima/fs:** upgraded to 5.1.0
18
+ * **@visulima/humanizer:** upgraded to 3.1.0
19
+ * **@visulima/path:** upgraded to 3.1.0
20
+
1
21
  ## @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
22
 
3
23
 
package/LICENSE.md CHANGED
@@ -375,9 +375,41 @@ Repository: git+https://github.com/visulima/visulima.git
375
375
  >
376
376
  > # Licenses of bundled types
377
377
  > The published @visulima/fs artifact additionally contains code with the following licenses:
378
- > ISC, MIT
378
+ > MIT
379
379
  >
380
380
  > # Bundled types:
381
+ > ## @visulima/yaml
382
+ > License: MIT
383
+ > By: Daniel Bannert
384
+ > Repository: git+https://github.com/visulima/visulima.git
385
+ >
386
+ > > MIT License
387
+ > >
388
+ > > Copyright (c) 2026 visulima
389
+ > >
390
+ > > Permission is hereby granted, free of charge, to any person obtaining a copy
391
+ > > of this software and associated documentation files (the "Software"), to deal
392
+ > > in the Software without restriction, including without limitation the rights
393
+ > > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
394
+ > > copies of the Software, and to permit persons to whom the Software is
395
+ > > furnished to do so, subject to the following conditions:
396
+ > >
397
+ > > The above copyright notice and this permission notice shall be included in all
398
+ > > copies or substantial portions of the Software.
399
+ > >
400
+ > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
401
+ > > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
402
+ > > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
403
+ > > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
404
+ > > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
405
+ > > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
406
+ > > SOFTWARE.
407
+ > >
408
+ > >
409
+ > >
410
+ >
411
+ > ---------------------------------------
412
+ >
381
413
  > ## is-fs-case-sensitive
382
414
  > License: MIT
383
415
  > By: Hiroki Osame
@@ -433,27 +465,6 @@ Repository: git+https://github.com/visulima/visulima.git
433
465
  > > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
434
466
  > > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
435
467
  > > SOFTWARE.
436
- >
437
- > ---------------------------------------
438
- >
439
- > ## yaml
440
- > License: ISC
441
- > By: Eemeli Aro
442
- > Repository: github:eemeli/yaml
443
- >
444
- > > Copyright Eemeli Aro <eemeli@gmail.com>
445
- > >
446
- > > Permission to use, copy, modify, and/or distribute this software for any purpose
447
- > > with or without fee is hereby granted, provided that the above copyright notice
448
- > > and this permission notice appear in all copies.
449
- > >
450
- > > THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
451
- > > REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
452
- > > FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
453
- > > INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
454
- > > OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
455
- > > TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
456
- > > THIS SOFTWARE.
457
468
 
458
469
  ---------------------------------------
459
470
 
@@ -1,11 +1,12 @@
1
- import { U as UploadOptions } from "../../packem_shared/types.d-jAs_Rp_v.js";
2
- import { U as UploadFile, B as BaseStorage } from "../../packem_shared/storage.d-DIav_lF1.js";
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-CvMFjINm.js";
8
- import "../../packem_shared/types.d-CAAzKiI6.js";
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-D8H_ge9Y.js";
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-DeDH3Ilt.js";
10
- import "../../packem_shared/storage.d-DIav_lF1.js";
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-D8H_ge9Y.js";
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-DIav_lF1.js";
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-D8H_ge9Y.js";
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-DeDH3Ilt.js";
10
+ import { e as executors } from "../../packem_shared/executors.d-B9dIy3NT.js";
10
11
  import 'zod';
11
- import "../../packem_shared/storage.d-DIav_lF1.js";
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-D8H_ge9Y.js";
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-DIav_lF1.js";
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-DIav_lF1.js";
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-jAs_Rp_v.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-jAs_Rp_v.js";
5
- import { B as BaseHandlerCore } from "../../../packem_shared/tus-base.d-BiEg5t4t.js";
6
- export { T as TUS_RESUMABLE, a as TUS_VERSION } from "../../../packem_shared/tus-base.d-BiEg5t4t.js";
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-CvMFjINm.js";
13
- import "../../../packem_shared/types.d-CAAzKiI6.js";
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-CQjYqU--.js";import{default as f}from"../../../packem_shared/Rest-CI_BiZPv.js";import{Tus as p}from"../../../packem_shared/Tus-BBVt2ky3.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
+ import{default as o}from"../../../packem_shared/Multipart-V64Bg5dt.js";import{default as f}from"../../../packem_shared/Rest-aPVP2ww1.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-DIav_lF1.js";
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-jAs_Rp_v.js";
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-CvMFjINm.js";
11
- import "../../../packem_shared/types.d-CAAzKiI6.js";
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-CQjYqU--.js";import i from"../../../packem_shared/Rest-CI_BiZPv.js";import{Tus as d}from"../../../packem_shared/Tus-BBVt2ky3.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
+ import c from"../../../packem_shared/Multipart-V64Bg5dt.js";import i from"../../../packem_shared/Rest-aPVP2ww1.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-DIav_lF1.js";
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-jAs_Rp_v.js";
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-CvMFjINm.js";
11
- import "../../../packem_shared/types.d-CAAzKiI6.js";
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-CQjYqU--.js";import c from"../../../packem_shared/Rest-CI_BiZPv.js";import{Tus as m}from"../../../packem_shared/Tus-BBVt2ky3.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
+ import{NextResponse as o}from"next/server.js";import u from"../../../packem_shared/Multipart-V64Bg5dt.js";import c from"../../../packem_shared/Rest-aPVP2ww1.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-DIav_lF1.js";
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-jAs_Rp_v.js";
5
- export type { B as BaseHandler, b as RequestEvent, c as UploadErrorEvent, d as UploadEvent } from "../../../packem_shared/types.d-jAs_Rp_v.js";
6
- import { B as BaseHandlerCore } from "../../../packem_shared/tus-base.d-BiEg5t4t.js";
7
- export { T as TUS_RESUMABLE, a as TUS_VERSION } from "../../../packem_shared/tus-base.d-BiEg5t4t.js";
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-CvMFjINm.js";
13
- import "../../../packem_shared/types.d-CAAzKiI6.js";
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-D0ok6BBy.js";import m from"../../../packem_shared/Rest-DvfN4-kf.js";import{Tus as f}from"../../../packem_shared/Tus-BlBZykIL.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
+ 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-DIav_lF1.js";
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-jAs_Rp_v.js";
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-CvMFjINm.js";
11
- import "../../../packem_shared/types.d-CAAzKiI6.js";
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-CQjYqU--.js";import u from"../../../packem_shared/Rest-CI_BiZPv.js";import{Tus as p}from"../../../packem_shared/Tus-BBVt2ky3.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};
1
+ import o from"../../../packem_shared/Multipart-V64Bg5dt.js";import u from"../../../packem_shared/Rest-aPVP2ww1.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-D8H_ge9Y.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-D8H_ge9Y.js";
3
- import { n as Metrics } from "./packem_shared/storage.d-DIav_lF1.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-DIav_lF1.js";
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-CQucFacO.js";
7
- export { L as LocalMetaStorage } from "./packem_shared/local-meta-storage.d-DuTEzyii.js";
8
- export { M as MemoryMetaStorage, a as MemoryStorage, type b as MemoryStorageOptions } from "./packem_shared/memory-storage.d-BRdTiY8y.js";
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{F as a}from"./packem_shared/disk-storage-BwPk2IRa.js";import{default as f}from"./packem_shared/DiskStorageWithChecksum-UnCtyEvs.js";import{y as m}from"./packem_shared/local-meta-storage-DJDcuxf1.js";import{default as i}from"./packem_shared/MemoryMetaStorage-Ksgh9pe7.js";import{default as x}from"./packem_shared/MemoryStorage-9gbWd09l.js";import{default as y}from"./packem_shared/MetaStorage-DPEUyWgN.js";import{B as g,d as F,a as M}from"./packem_shared/storage-0j5nCAUp.js";import{ERRORS as E,ErrorMap as c,UploadError as T,extractHttpStatus as C,isUploadError as R,mapStatusToErrorCode as k,throwErrorCode as B,wrapStorageError as b}from"./packem_shared/ERRORS-BIBxE2oR.js";import{createRetryWrapper as w,isRetryableError as N,retry as O}from"./packem_shared/createRetryWrapper-CxgiV_hH.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-CpIcMjP0.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,E 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,w as createRetryWrapper,F as defaultCloudStorageFileNameValidation,M 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,B as throwErrorCode,_ as transfer,o as waitForStorage,b as wrapStorageError};
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};
@@ -1 +1 @@
1
- import"node:stream";import"node:timers";import"node:util";import{B as u,d as F,a as g}from"./storage-0j5nCAUp.js";import"./path-0oTTdkvl-DvWvbDbh.js";import"type-is";import"./NoOpMetrics-BLo6u4NY.js";import"./cache-Cw3QjoVN.js";import"./ERRORS-BIBxE2oR.js";import"./createRetryWrapper-CxgiV_hH.js";import"./is-expired-CBEk6XBi.js";export{u as BaseStorage,F as defaultCloudStorageFileNameValidation,g as defaultFilesystemFileNameValidation};
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-0j5nCAUp.js";import d from"./BunS3File-BcYmsz1n.js";import E from"./BunS3MetaStorage-CHWrhgg2.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};
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-0j5nCAUp.js";import m from"./BunnyFile-BgEOlcYI.js";import T from"./BunnyMetaStorage-CHWrhgg2.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};
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};