@visulima/storage 1.0.0-alpha.27 → 1.0.0-alpha.29

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 (190) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +2 -2
  3. package/dist/adapter/nuxt/module.d.ts +4 -4
  4. package/dist/adapter/nuxt/node_modules/.bin/nuxi +2 -2
  5. package/dist/adapter/nuxt/node_modules/.bin/nuxt +2 -2
  6. package/dist/ai/ai-sdk/index.d.ts +3 -3
  7. package/dist/ai/claude/index.d.ts +2 -2
  8. package/dist/ai/openai/index.d.ts +3 -3
  9. package/dist/ai/tanstack/index.d.ts +2 -2
  10. package/dist/handler/http/fetch/index.d.ts +7 -7
  11. package/dist/handler/http/fetch/index.js +1 -1
  12. package/dist/handler/http/hono/index.d.ts +4 -4
  13. package/dist/handler/http/hono/index.js +1 -1
  14. package/dist/handler/http/nextjs/index.d.ts +4 -4
  15. package/dist/handler/http/nextjs/index.js +1 -1
  16. package/dist/handler/http/node/index.d.ts +7 -7
  17. package/dist/handler/http/node/index.js +1 -1
  18. package/dist/handler/http/solid-start/index.d.ts +4 -4
  19. package/dist/handler/http/solid-start/index.js +1 -1
  20. package/dist/index.d.ts +5 -5
  21. package/dist/index.js +1 -1
  22. package/dist/packem_shared/{AwsLightMetaStorage-DHz1nf_H.js → AwsLightMetaStorage-B-iQbToR.js} +1 -1
  23. package/dist/packem_shared/AwsLightStorage-w21RxjUm.js +1 -0
  24. package/dist/packem_shared/AzureSMetaStorage-CR-lfQNQ.js +1 -0
  25. package/dist/packem_shared/AzureStorage-2kl7JDXs.js +1 -0
  26. package/dist/packem_shared/BoxMetaStorage-DLdXbZaV.js +1 -0
  27. package/dist/packem_shared/BoxStorage-BUeEJoGL.js +1 -0
  28. package/dist/packem_shared/BunS3File-D-SRiyrm.js +1 -0
  29. package/dist/packem_shared/BunS3MetaStorage-Bv_CTTMz.js +1 -0
  30. package/dist/packem_shared/BunS3Storage-WM3rF6Fw.js +1 -0
  31. package/dist/packem_shared/BunnyMetaStorage-DNMTSeoN.js +1 -0
  32. package/dist/packem_shared/BunnyStorage-D3s2fRB3.js +1 -0
  33. package/dist/packem_shared/CloudinaryFile-B5-m33eS.js +1 -0
  34. package/dist/packem_shared/CloudinaryMetaStorage-DEBk5eQy.js +1 -0
  35. package/dist/packem_shared/CloudinaryStorage-BBE2-aVz.js +1 -0
  36. package/dist/packem_shared/DiskStorage-DL0GiG6k.js +1 -0
  37. package/dist/packem_shared/{DiskStorageWithChecksum-CbXWpSOr.js → DiskStorageWithChecksum-BvUTn7O-.js} +1 -1
  38. package/dist/packem_shared/{DropboxMetaStorage-CICuUZ1n.js → DropboxMetaStorage-C6vj1QDA.js} +1 -1
  39. package/dist/packem_shared/DropboxStorage-BL3OIdE_.js +1 -0
  40. package/dist/packem_shared/{Files-B7hlJcB4.js → Files-CJh9_N-9.js} +1 -1
  41. package/dist/packem_shared/FirebaseFile-JEu3plMP.js +1 -0
  42. package/dist/packem_shared/FirebaseMetaStorage-CzyOim-J.js +1 -0
  43. package/dist/packem_shared/FirebaseStorage-lXMXy3Pm.js +2 -0
  44. package/dist/packem_shared/FtpFile-B8jaICTB.js +1 -0
  45. package/dist/packem_shared/FtpMetaStorage-1Njy0DpU.js +1 -0
  46. package/dist/packem_shared/FtpStorage-Dw94efNW.js +1 -0
  47. package/dist/packem_shared/{GCSMetaStorage-CqP9ifYB.js → GCSMetaStorage-DvRxZhmq.js} +1 -1
  48. package/dist/packem_shared/GCStorage-U4f4WsWC.js +1 -0
  49. package/dist/packem_shared/{GoogleDriveMetaStorage-rghGy3Fa.js → GoogleDriveMetaStorage-WGuUZPyx.js} +1 -1
  50. package/dist/packem_shared/GoogleDriveStorage-C0NhBBWH.js +1 -0
  51. package/dist/packem_shared/{LocalMetaStorage-B5uh1snG.js → LocalMetaStorage-QMKL7McF.js} +1 -1
  52. package/dist/packem_shared/{Multipart-7FSSy2n1.js → Multipart-CIFfQksD.js} +1 -1
  53. package/dist/packem_shared/{Multipart-DACQFsrn.js → Multipart-D9WIud9R.js} +1 -1
  54. package/dist/packem_shared/NetlifyBlobMetaStorage-ClIFdTkT.js +1 -0
  55. package/dist/packem_shared/NetlifyBlobStorage-CO89TGvF.js +1 -0
  56. package/dist/packem_shared/OneDriveMetaStorage-DS4f83X2.js +1 -0
  57. package/dist/packem_shared/OneDriveStorage-jAN46vRm.js +1 -0
  58. package/dist/packem_shared/PocketBaseFile-CkAiSBb0.js +1 -0
  59. package/dist/packem_shared/PocketBaseMetaStorage-B6utPncj.js +1 -0
  60. package/dist/packem_shared/PocketBaseStorage-DpOjOKAt.js +1 -0
  61. package/dist/packem_shared/{Rest-5NwM1xYj.js → Rest-BuD3ySAg.js} +1 -1
  62. package/dist/packem_shared/{Rest-y8Vz2Rt0.js → Rest-URrQ5FYM.js} +1 -1
  63. package/dist/packem_shared/S3Storage-n1ohEZj4.js +1 -0
  64. package/dist/packem_shared/SftpFile-CQCxZNVq.js +1 -0
  65. package/dist/packem_shared/SftpMetaStorage-DYqXwCdM.js +1 -0
  66. package/dist/packem_shared/SftpStorage-Ban-WN8v.js +1 -0
  67. package/dist/packem_shared/SharePointFile-BA6X9Sxr.js +1 -0
  68. package/dist/packem_shared/SharePointMetaStorage-DVM5-X6g.js +1 -0
  69. package/dist/packem_shared/SharePointStorage-BY90zh1c.js +1 -0
  70. package/dist/packem_shared/SupabaseMetaStorage-ivXoYVUu.js +1 -0
  71. package/dist/packem_shared/SupabaseStorage-pNbHAE1Y.js +1 -0
  72. package/dist/packem_shared/{Tus-CJMcygk7.js → Tus-Fp_hx5ug.js} +1 -1
  73. package/dist/packem_shared/{Tus-BCVAbJIi.js → Tus-TNG9HAY8.js} +1 -1
  74. package/dist/packem_shared/UploadThingMetaStorage-BvKNzgm7.js +1 -0
  75. package/dist/packem_shared/UploadThingStorage-BcmIE2dI.js +1 -0
  76. package/dist/packem_shared/{VercelBlobMetaStorage-Do9ZoKrl.js → VercelBlobMetaStorage-CwaqWucZ.js} +1 -1
  77. package/dist/packem_shared/VercelBlobStorage-C89IUiQ1.js +1 -0
  78. package/dist/packem_shared/alibaba-BJQ6ijoK.js +1 -0
  79. package/dist/packem_shared/aws-light-meta-storage-CstQBYXG.js +4 -0
  80. package/dist/packem_shared/azure-meta-storage-C4SrMtT2.js +1 -0
  81. package/dist/packem_shared/{base-handler-core-BfwZ1RS1.js → base-handler-core-BYDQditz.js} +1 -1
  82. package/dist/packem_shared/{base-handler-fetch-CLxqXTQf.js → base-handler-fetch-DWzsPkmV.js} +1 -1
  83. package/dist/packem_shared/{base-handler-node-DBZjcqsp.js → base-handler-node-Dety2rQB.js} +1 -1
  84. package/dist/packem_shared/defaultCloudStorageFileNameValidation-shIZX_7L.js +1 -0
  85. package/dist/packem_shared/disk-storage-CKAJvhcj.js +1 -0
  86. package/dist/packem_shared/{disk-storage-with-checksum.d-BQMXA4Wl.d.ts → disk-storage-with-checksum.d-mHcg2uLw.d.ts} +1 -1
  87. package/dist/packem_shared/{executors.d-UtkeCbk1.d.ts → executors.d-X4hz3zfu.d.ts} +1 -1
  88. package/dist/packem_shared/exoscale-O0HzxoDz.js +1 -0
  89. package/dist/packem_shared/filebase-D-urO4Ob.js +1 -0
  90. package/dist/packem_shared/{gcs-meta-storage-XB-UPJn6.js → gcs-meta-storage-Br_I-m9X.js} +1 -1
  91. package/dist/packem_shared/ibmCos-Rx_yku4H.js +1 -0
  92. package/dist/packem_shared/idriveE2-BFhw0Vwy.js +1 -0
  93. package/dist/packem_shared/index-B4ETk0Lu.js +5 -0
  94. package/dist/packem_shared/{index.d-DotjipuX.d.ts → index.d-C4Fivh4I.d.ts} +7 -2
  95. package/dist/packem_shared/isRetryableError-BhizNeAz.js +1 -0
  96. package/dist/packem_shared/{local-meta-storage-CT1audnK.js → local-meta-storage-Bi0mK6gD.js} +1 -1
  97. package/dist/packem_shared/{local-meta-storage.d-B5R1nswK.d.ts → local-meta-storage.d-B11vHYNm.d.ts} +1 -1
  98. package/dist/packem_shared/{media-transformer.d-DK7NJncf.d.ts → media-transformer.d-j1W9HAXw.d.ts} +2 -2
  99. package/dist/packem_shared/oracleCloud-D5T9s4JV.js +1 -0
  100. package/dist/packem_shared/ovhCloud-DCwef2fe.js +1 -0
  101. package/dist/packem_shared/posix-dirname-CiHXPPnw.js +1 -0
  102. package/dist/packem_shared/{rest-base-CCv78k7h.js → rest-base-DI7xFXr5.js} +1 -1
  103. package/dist/packem_shared/s3-base-storage-Dbexfg7p.js +1 -0
  104. package/dist/packem_shared/{s3-base-storage.d-BROGYJ4F.d.ts → s3-base-storage.d-V3N2nKCt.d.ts} +31 -22
  105. package/dist/packem_shared/scaleway-ygRXOss9.js +1 -0
  106. package/dist/packem_shared/storage-Dh0tJh7j.js +1 -0
  107. package/dist/packem_shared/{storage.d-Cr6f2lac.d.ts → storage.d-RteRC-cG.d.ts} +131 -65
  108. package/dist/packem_shared/tencent-CAcAGaIW.js +1 -0
  109. package/dist/packem_shared/{tus-base.d-4-ZfDQwl.d.ts → tus-base.d-wZsb3umJ.d.ts} +3 -3
  110. package/dist/packem_shared/{types.d-C8eSxqX9.d.ts → types.d-B5qPfCr5.d.ts} +2 -2
  111. package/dist/packem_shared/types.d-ChNXbbHG.d.ts +104 -0
  112. package/dist/packem_shared/{types.d-BgCmSE94.d.ts → types.d-DzPvh74p.d.ts} +2 -2
  113. package/dist/packem_shared/vultr-lK9L-sFk.js +1 -0
  114. package/dist/packem_shared/yandex-ZwvE77v4.js +1 -0
  115. package/dist/storage/aws/clients/index.d.ts +372 -1
  116. package/dist/storage/aws/clients/index.js +1 -1
  117. package/dist/storage/aws/index.d.ts +13 -13
  118. package/dist/storage/aws/index.js +1 -1
  119. package/dist/storage/aws-light/index.d.ts +13 -13
  120. package/dist/storage/aws-light/index.js +1 -1
  121. package/dist/storage/azure/index.d.ts +82 -14
  122. package/dist/storage/azure/index.js +1 -1
  123. package/dist/storage/box/index.d.ts +12 -9
  124. package/dist/storage/box/index.js +1 -1
  125. package/dist/storage/bun-s3/index.d.ts +200 -0
  126. package/dist/storage/bun-s3/index.js +1 -0
  127. package/dist/storage/bunny/index.d.ts +13 -10
  128. package/dist/storage/bunny/index.js +1 -1
  129. package/dist/storage/cloudinary/index.d.ts +121 -0
  130. package/dist/storage/cloudinary/index.js +1 -0
  131. package/dist/storage/dropbox/index.d.ts +13 -10
  132. package/dist/storage/dropbox/index.js +1 -1
  133. package/dist/storage/firebase/index.d.ts +192 -0
  134. package/dist/storage/firebase/index.js +1 -0
  135. package/dist/storage/ftp/index.d.ts +85 -0
  136. package/dist/storage/ftp/index.js +1 -0
  137. package/dist/storage/gcs/index.d.ts +19 -10
  138. package/dist/storage/gcs/index.js +1 -1
  139. package/dist/storage/google-drive/index.d.ts +12 -9
  140. package/dist/storage/google-drive/index.js +1 -1
  141. package/dist/storage/local/index.d.ts +3 -3
  142. package/dist/storage/local/index.js +1 -1
  143. package/dist/storage/netlify-blob/index.d.ts +15 -12
  144. package/dist/storage/netlify-blob/index.js +1 -1
  145. package/dist/storage/onedrive/index.d.ts +22 -111
  146. package/dist/storage/onedrive/index.js +1 -1
  147. package/dist/storage/pocketbase/index.d.ts +172 -0
  148. package/dist/storage/pocketbase/index.js +1 -0
  149. package/dist/storage/sftp/index.d.ts +86 -0
  150. package/dist/storage/sftp/index.js +1 -0
  151. package/dist/storage/sharepoint/index.d.ts +180 -0
  152. package/dist/storage/sharepoint/index.js +1 -0
  153. package/dist/storage/supabase/index.d.ts +14 -10
  154. package/dist/storage/supabase/index.js +1 -1
  155. package/dist/storage/uploadthing/index.d.ts +14 -10
  156. package/dist/storage/uploadthing/index.js +1 -1
  157. package/dist/storage/vercel-blob/index.d.ts +13 -10
  158. package/dist/storage/vercel-blob/index.js +1 -1
  159. package/dist/transformer/audio-transformer.d.ts +2 -2
  160. package/dist/transformer/image-transformer.d.ts +2 -2
  161. package/dist/transformer/index.d.ts +3 -3
  162. package/dist/transformer/video-transformer.d.ts +2 -2
  163. package/package.json +55 -3
  164. package/dist/packem_shared/AwsLightStorage-SH7j-myh.js +0 -1
  165. package/dist/packem_shared/AzureSMetaStorage-DV2tNjKh.js +0 -1
  166. package/dist/packem_shared/AzureStorage-BVYMFEBP.js +0 -1
  167. package/dist/packem_shared/BoxMetaStorage-BUe5Qmqe.js +0 -1
  168. package/dist/packem_shared/BoxStorage-CgC81_So.js +0 -1
  169. package/dist/packem_shared/BunnyMetaStorage-D0mT6veJ.js +0 -1
  170. package/dist/packem_shared/BunnyStorage-Bl4usdVT.js +0 -1
  171. package/dist/packem_shared/DiskStorage-B5uIDVXr.js +0 -1
  172. package/dist/packem_shared/DropboxStorage-CPjhDN5B.js +0 -1
  173. package/dist/packem_shared/GCStorage-XSBKVx90.js +0 -1
  174. package/dist/packem_shared/GoogleDriveStorage-DuB6glUk.js +0 -1
  175. package/dist/packem_shared/NetlifyBlobMetaStorage-BcRFPky8.js +0 -1
  176. package/dist/packem_shared/NetlifyBlobStorage-C4qkJv1R.js +0 -1
  177. package/dist/packem_shared/OneDriveMetaStorage-B_BkGLzW.js +0 -1
  178. package/dist/packem_shared/OneDriveStorage-Cu0cGcrh.js +0 -1
  179. package/dist/packem_shared/S3Storage-D8dopWoO.js +0 -1
  180. package/dist/packem_shared/SupabaseMetaStorage-BR1UGqnj.js +0 -1
  181. package/dist/packem_shared/SupabaseStorage-CCtMTiN5.js +0 -1
  182. package/dist/packem_shared/UploadThingMetaStorage-DyGNyaAq.js +0 -1
  183. package/dist/packem_shared/UploadThingStorage-B_fNzNFO.js +0 -1
  184. package/dist/packem_shared/VercelBlobStorage-D5zy4PPQ.js +0 -1
  185. package/dist/packem_shared/aws-light-meta-storage-TPyQwLvk.js +0 -4
  186. package/dist/packem_shared/defaultCloudStorageFileNameValidation-6URTv-Mp.js +0 -1
  187. package/dist/packem_shared/disk-storage-CbSSPnOf.js +0 -5
  188. package/dist/packem_shared/isRetryableError-B6ZS_-5I.js +0 -1
  189. package/dist/packem_shared/s3-base-storage-f_EyFAAt.js +0 -1
  190. package/dist/packem_shared/storage-CoyB2O-Y.js +0 -1
@@ -1,7 +1,7 @@
1
1
  import { UTApi } from 'uploadthing/server';
2
- import { L as LocalMetaStorageOptions, l as BaseStorageOptions, F as File, M as MetaStorage, e as FileInit, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-Cr6f2lac.js";
2
+ import { L as LocalMetaStorageOptions, i as BaseStorageOptions, F as File, M as MetaStorage, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-RteRC-cG.js";
3
3
  import 'node:stream';
4
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-B5R1nswK.js";
4
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-B11vHYNm.js";
5
5
  import 'node:crypto';
6
6
  import 'node:http';
7
7
  import 'lru-cache';
@@ -48,11 +48,13 @@ declare class UploadThingMetaStorage extends LocalMetaStorage<UploadThingFile> {
48
48
  * keyed by user-supplied `customId` so subsequent operations (delete, signed
49
49
  * URL, list) round-trip on the user's key, not UploadThing's internal fileKey.
50
50
  *
51
- * **Limitations** (mirroring files-sdk):
51
+ * **Limitations**:
52
52
  * - No native server-side `copy` — implemented as download + re-upload.
53
53
  * - `list` has no server-side prefix filter; prefix filtering happens client-
54
54
  * side within a page.
55
55
  * - No `responseContentDisposition` override on signed URLs.
56
+ * @remarks
57
+ * - ⚠️ Per-operation `signal`/`timeout` are best-effort: the underlying SDK does not support request cancellation, so an in-flight call may complete server-side even after abort. `retries` is honored.
56
58
  */
57
59
  declare class UploadThingStorage extends BaseStorage<UploadThingFile> {
58
60
  static override readonly name: string;
@@ -64,17 +66,19 @@ declare class UploadThingStorage extends BaseStorage<UploadThingFile> {
64
66
  private readonly utapi;
65
67
  constructor(config: UploadThingStorageOptions);
66
68
  override get raw(): UTApi;
67
- create(config: FileInit): Promise<UploadThingFile>;
68
- write(part: FilePart | FileQuery | UploadThingFile): Promise<UploadThingFile>;
69
+ create(config: FileInit, _options?: OperationOptions): Promise<UploadThingFile>;
70
+ write(part: FilePart | FileQuery | UploadThingFile, options?: OperationOptions): Promise<UploadThingFile>;
69
71
  delete({
70
72
  id
71
- }: FileQuery): Promise<UploadThingFile>;
73
+ }: FileQuery, options?: OperationOptions): Promise<UploadThingFile>;
72
74
  get({
73
75
  id
74
- }: FileQuery): Promise<FileReturn>;
75
- copy(name: string, destination: string): Promise<UploadThingFile>;
76
- move(name: string, destination: string): Promise<UploadThingFile>;
77
- override list(limit?: number): Promise<UploadThingFile[]>;
76
+ }: FileQuery, options?: OperationOptions): Promise<FileReturn>;
77
+ copy(name: string, destination: string, options?: OperationOptions & {
78
+ storageClass?: string;
79
+ }): Promise<UploadThingFile>;
80
+ move(name: string, destination: string, options?: OperationOptions): Promise<UploadThingFile>;
81
+ override list(limit?: number, options?: OperationOptions): Promise<UploadThingFile[]>;
78
82
  override getReadUrl(key: string, options?: {
79
83
  expiresIn?: number;
80
84
  responseContentDisposition?: string;
@@ -1 +1 @@
1
- import{default as e}from"../../packem_shared/UploadThingFile-BpG9mE8K.js";import{default as r}from"../../packem_shared/UploadThingMetaStorage-DyGNyaAq.js";import{default as d}from"../../packem_shared/UploadThingStorage-B_fNzNFO.js";export{e as UploadThingFile,r as UploadThingMetaStorage,d as UploadThingStorage};
1
+ import{default as e}from"../../packem_shared/UploadThingFile-BpG9mE8K.js";import{default as r}from"../../packem_shared/UploadThingMetaStorage-BvKNzgm7.js";import{default as d}from"../../packem_shared/UploadThingStorage-BcmIE2dI.js";export{e as UploadThingFile,r as UploadThingMetaStorage,d as UploadThingStorage};
@@ -1,6 +1,6 @@
1
- import { L as LocalMetaStorageOptions, l as BaseStorageOptions, F as File, M as MetaStorage, e as FileInit, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-Cr6f2lac.js";
1
+ import { L as LocalMetaStorageOptions, i as BaseStorageOptions, F as File, M as MetaStorage, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-RteRC-cG.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-B5R1nswK.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-B11vHYNm.js";
4
4
  import { copy, del, list, put } from '@vercel/blob';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -76,6 +76,7 @@ declare class VercelBlobMetaStorage extends LocalMetaStorage {
76
76
  * - ❌ update: Not implemented (Vercel Blob API doesn't support metadata updates)
77
77
  * - ❌ getUrl: Not implemented (Vercel Blob URLs available via Vercel Blob API)
78
78
  * - ❌ getUploadUrl: Not implemented (Vercel Blob upload URLs handled internally)
79
+ * - ⚠️ Per-operation `signal`/`timeout` are best-effort: the underlying SDK does not support request cancellation, so an in-flight call may complete server-side even after abort. `retries` is honored.
79
80
  */
80
81
  declare class VercelBlobStorage extends BaseStorage<VercelBlobFile> {
81
82
  static override readonly name: string;
@@ -92,8 +93,8 @@ declare class VercelBlobStorage extends BaseStorage<VercelBlobFile> {
92
93
  private readonly multipart;
93
94
  private readonly access;
94
95
  constructor(config: VercelBlobStorageOptions);
95
- create(config: FileInit): Promise<VercelBlobFile>;
96
- write(part: FilePart | FileQuery | VercelBlobFile): Promise<VercelBlobFile>;
96
+ create(config: FileInit, _options?: OperationOptions): Promise<VercelBlobFile>;
97
+ write(part: FilePart | FileQuery | VercelBlobFile, options?: OperationOptions): Promise<VercelBlobFile>;
97
98
  /**
98
99
  * Deletes an upload and its metadata.
99
100
  * @param query File query containing the file ID to delete.
@@ -103,7 +104,7 @@ declare class VercelBlobStorage extends BaseStorage<VercelBlobFile> {
103
104
  */
104
105
  delete({
105
106
  id
106
- }: FileQuery): Promise<VercelBlobFile>;
107
+ }: FileQuery, options?: OperationOptions): Promise<VercelBlobFile>;
107
108
  /**
108
109
  * Checks if a file exists by verifying both metadata and the actual Vercel Blob.
109
110
  * Returns true only if both the metadata and the blob exist.
@@ -112,10 +113,10 @@ declare class VercelBlobStorage extends BaseStorage<VercelBlobFile> {
112
113
  */
113
114
  override exists({
114
115
  id
115
- }: FileQuery): Promise<boolean>;
116
+ }: FileQuery, options?: OperationOptions): Promise<boolean>;
116
117
  get({
117
118
  id
118
- }: FileQuery): Promise<FileReturn>;
119
+ }: FileQuery, options?: OperationOptions): Promise<FileReturn>;
119
120
  /**
120
121
  * Copies an upload file to a new location.
121
122
  * @param name Source file name/ID.
@@ -123,7 +124,9 @@ declare class VercelBlobStorage extends BaseStorage<VercelBlobFile> {
123
124
  * @returns Promise resolving to the copied file object.
124
125
  * @throws {UploadError} If the source file cannot be found.
125
126
  */
126
- copy(name: string, destination: string): Promise<VercelBlobFile>;
127
+ copy(name: string, destination: string, options?: OperationOptions & {
128
+ storageClass?: string;
129
+ }): Promise<VercelBlobFile>;
127
130
  /**
128
131
  * Moves an upload file to a new location.
129
132
  * @param name Source file name/ID.
@@ -131,8 +134,8 @@ declare class VercelBlobStorage extends BaseStorage<VercelBlobFile> {
131
134
  * @returns Promise resolving to the moved file object.
132
135
  * @throws {UploadError} If the source file cannot be found.
133
136
  */
134
- move(name: string, destination: string): Promise<VercelBlobFile>;
135
- override list(limit?: number): Promise<VercelBlobFile[]>;
137
+ move(name: string, destination: string, options?: OperationOptions): Promise<VercelBlobFile>;
138
+ override list(limit?: number, options?: OperationOptions): Promise<VercelBlobFile[]>;
136
139
  private internalOnComplete;
137
140
  /**
138
141
  * Determines if multipart upload should be used for the given file.
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/VercelBlobFile-Cni_1qwD.js";import{default as a}from"../../packem_shared/VercelBlobMetaStorage-Do9ZoKrl.js";import{default as f}from"../../packem_shared/VercelBlobStorage-D5zy4PPQ.js";export{r as VercelBlobFile,a as VercelBlobMetaStorage,f as VercelBlobStorage};
1
+ import{default as r}from"../../packem_shared/VercelBlobFile-Cni_1qwD.js";import{default as a}from"../../packem_shared/VercelBlobMetaStorage-CwaqWucZ.js";import{default as f}from"../../packem_shared/VercelBlobStorage-C89IUiQ1.js";export{r as VercelBlobFile,a as VercelBlobMetaStorage,f as VercelBlobStorage};
@@ -1,5 +1,5 @@
1
- import { F as File, a as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-Cr6f2lac.js";
2
- import { A as AudioTransformerConfig, g as AudioTransformResult, h as AudioResampleOptions, i as AudioChannelMixOptions, j as AudioTransformOptions, k as AudioTransformationStep, B as BaseTransformer } from "../packem_shared/types.d-C8eSxqX9.js";
1
+ import { F as File, a as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-RteRC-cG.js";
2
+ import { A as AudioTransformerConfig, a as AudioTransformResult, b as AudioResampleOptions, c as AudioChannelMixOptions, d as AudioTransformOptions, e as AudioTransformationStep, B as BaseTransformer } from "../packem_shared/types.d-B5qPfCr5.js";
3
3
  import 'node:stream';
4
4
  import 'node:crypto';
5
5
  import 'node:http';
@@ -1,6 +1,6 @@
1
1
  import { Readable } from 'node:stream';
2
- import { F as File, a as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-Cr6f2lac.js";
3
- import { I as ImageTransformerConfig, T as TransformResult, R as ResizeOptions, C as CropOptions, l as RotateOptions, m as ImageFormat, n as TransformOptions, S as SharpenOptions, o as BlurOptions, M as MedianOptions, p as CLAHEOptions, q as ConvolveOptions, r as ThresholdOptions, s as BooleanOptions, L as LinearOptions, t as RecombineOptions, u as ModulateOptions, v as TintOptions, G as GreyscaleOptions, w as ColourspaceOptions, E as ExtractChannelOptions, J as JoinChannelOptions, x as BandboolOptions, y as AffineOptions, D as DilateOptions, z as ErodeOptions, P as PipelineColourspaceOptions, F as ToColourspaceOptions, H as RemoveAlphaOptions, K as EnsureAlphaOptions, N as TransformationStep, B as BaseTransformer } from "../packem_shared/types.d-C8eSxqX9.js";
2
+ import { F as File, a as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-RteRC-cG.js";
3
+ import { I as ImageTransformerConfig, T as TransformResult, R as ResizeOptions, C as CropOptions, m as RotateOptions, n as ImageFormat, o as TransformOptions, S as SharpenOptions, p as BlurOptions, q as MedianOptions, r as CLAHEOptions, s as ConvolveOptions, t as ThresholdOptions, u as BooleanOptions, L as LinearOptions, v as RecombineOptions, w as ModulateOptions, x as TintOptions, G as GreyscaleOptions, y as ColourspaceOptions, E as ExtractChannelOptions, J as JoinChannelOptions, z as BandboolOptions, D as AffineOptions, F as DilateOptions, H as ErodeOptions, P as PipelineColourspaceOptions, K as ToColourspaceOptions, N as RemoveAlphaOptions, O as EnsureAlphaOptions, Q as TransformationStep, B as BaseTransformer } from "../packem_shared/types.d-B5qPfCr5.js";
4
4
  import 'node:crypto';
5
5
  import 'node:http';
6
6
  import 'lru-cache';
@@ -1,6 +1,6 @@
1
- export { type i as AudioChannelMixOptions, type h as AudioResampleOptions, type j as AudioTransformOptions, type g as AudioTransformResult, type k as AudioTransformationStep, type A as AudioTransformerConfig, B as BaseTransformer, type C as CropOptions, type m as ImageFormat, type I as ImageTransformerConfig, type U as MediaTransformQuery, type Q as MediaTransformResult, type W as MediaTransformationStep, type O as MediaTransformerConfig, type R as ResizeOptions, type l as RotateOptions, type n as TransformOptions, type T as TransformResult, type N as TransformationStep, type c as VideoCropOptions, type b as VideoResizeOptions, type d as VideoRotateOptions, type e as VideoTransformOptions, type a as VideoTransformResult, type f as VideoTransformationStep, type V as VideoTransformerConfig } from "../packem_shared/types.d-C8eSxqX9.js";
2
- export { M as MediaTransformer } from "../packem_shared/media-transformer.d-DK7NJncf.js";
3
- import { a as FileReturn } from "../packem_shared/storage.d-Cr6f2lac.js";
1
+ export { type c as AudioChannelMixOptions, type b as AudioResampleOptions, type d as AudioTransformOptions, type a as AudioTransformResult, type e as AudioTransformationStep, type A as AudioTransformerConfig, B as BaseTransformer, type C as CropOptions, type n as ImageFormat, type I as ImageTransformerConfig, type U as MediaTransformQuery, type l as MediaTransformResult, type W as MediaTransformationStep, type M as MediaTransformerConfig, type R as ResizeOptions, type m as RotateOptions, type o as TransformOptions, type T as TransformResult, type Q as TransformationStep, type h as VideoCropOptions, type g as VideoResizeOptions, type i as VideoRotateOptions, type j as VideoTransformOptions, type f as VideoTransformResult, type k as VideoTransformationStep, type V as VideoTransformerConfig } from "../packem_shared/types.d-B5qPfCr5.js";
2
+ export { M as MediaTransformer } from "../packem_shared/media-transformer.d-j1W9HAXw.js";
3
+ import { a as FileReturn } from "../packem_shared/storage.d-RteRC-cG.js";
4
4
  import 'node:stream';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1,5 +1,5 @@
1
- import { F as File, a as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-Cr6f2lac.js";
2
- import { V as VideoTransformerConfig, a as VideoTransformResult, b as VideoResizeOptions, c as VideoCropOptions, d as VideoRotateOptions, e as VideoTransformOptions, f as VideoTransformationStep, B as BaseTransformer } from "../packem_shared/types.d-C8eSxqX9.js";
1
+ import { F as File, a as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-RteRC-cG.js";
2
+ import { V as VideoTransformerConfig, f as VideoTransformResult, g as VideoResizeOptions, h as VideoCropOptions, i as VideoRotateOptions, j as VideoTransformOptions, k as VideoTransformationStep, B as BaseTransformer } from "../packem_shared/types.d-B5qPfCr5.js";
3
3
  import 'node:stream';
4
4
  import 'node:crypto';
5
5
  import 'node:http';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/storage",
3
- "version": "1.0.0-alpha.27",
3
+ "version": "1.0.0-alpha.29",
4
4
  "description": "Visulima upload - Store files in a web-accessible location via a simplified API. Can automatically scale and rotate images. Includes S3, Azure, GCS and local filesystem-based backends with the most convenient features of each.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -120,6 +120,14 @@
120
120
  "types": "./dist/storage/local/index.d.ts",
121
121
  "import": "./dist/storage/local/index.js"
122
122
  },
123
+ "./provider/ftp": {
124
+ "types": "./dist/storage/ftp/index.d.ts",
125
+ "import": "./dist/storage/ftp/index.js"
126
+ },
127
+ "./provider/sftp": {
128
+ "types": "./dist/storage/sftp/index.d.ts",
129
+ "import": "./dist/storage/sftp/index.js"
130
+ },
123
131
  "./provider/supabase": {
124
132
  "types": "./dist/storage/supabase/index.d.ts",
125
133
  "import": "./dist/storage/supabase/index.js"
@@ -144,10 +152,30 @@
144
152
  "types": "./dist/storage/box/index.d.ts",
145
153
  "import": "./dist/storage/box/index.js"
146
154
  },
155
+ "./provider/bun-s3": {
156
+ "types": "./dist/storage/bun-s3/index.d.ts",
157
+ "import": "./dist/storage/bun-s3/index.js"
158
+ },
147
159
  "./provider/bunny": {
148
160
  "types": "./dist/storage/bunny/index.d.ts",
149
161
  "import": "./dist/storage/bunny/index.js"
150
162
  },
163
+ "./provider/cloudinary": {
164
+ "types": "./dist/storage/cloudinary/index.d.ts",
165
+ "import": "./dist/storage/cloudinary/index.js"
166
+ },
167
+ "./provider/firebase": {
168
+ "types": "./dist/storage/firebase/index.d.ts",
169
+ "import": "./dist/storage/firebase/index.js"
170
+ },
171
+ "./provider/pocketbase": {
172
+ "types": "./dist/storage/pocketbase/index.d.ts",
173
+ "import": "./dist/storage/pocketbase/index.js"
174
+ },
175
+ "./provider/sharepoint": {
176
+ "types": "./dist/storage/sharepoint/index.d.ts",
177
+ "import": "./dist/storage/sharepoint/index.js"
178
+ },
151
179
  "./openapi": {
152
180
  "types": "./dist/openapi/index.d.ts",
153
181
  "import": "./dist/openapi/index.js"
@@ -237,11 +265,11 @@
237
265
  "@sindresorhus/fnv1a": "3.1.0",
238
266
  "@visulima/pagination": "5.0.0-alpha.11",
239
267
  "file-type": "22.0.1",
240
- "lru-cache": "11.3.6",
268
+ "lru-cache": "11.4.0",
241
269
  "mime": "^4.1.0",
242
270
  "nanoid": "5.1.11",
243
271
  "path-to-regexp": "8.4.2",
244
- "type-is": "^2.0.1",
272
+ "type-is": "^2.1.0",
245
273
  "zod": "4.4.3"
246
274
  },
247
275
  "peerDependencies": {
@@ -251,6 +279,7 @@
251
279
  "@aws-sdk/s3-request-presigner": ">=3.901.0",
252
280
  "@aws-sdk/signature-v4-crt": ">=3.901.0",
253
281
  "@aws-sdk/types": ">=3.930.0",
282
+ "@azure/core-auth": ">=1.9.0",
254
283
  "@azure/storage-blob": ">=12.28.0",
255
284
  "@bunny.net/storage-sdk": ">=0.3.0",
256
285
  "@googleapis/drive": ">=20.0.0",
@@ -266,15 +295,20 @@
266
295
  "ai": ">=5.0.0",
267
296
  "aws-crt": ">=1.27.3",
268
297
  "aws4fetch": ">=1.0.0",
298
+ "basic-ftp": ">=5.0.0",
269
299
  "box-typescript-sdk-gen": ">=1.19.0",
300
+ "cloudinary": ">=2.0.0",
270
301
  "dropbox": ">=10.34.0",
302
+ "firebase-admin": ">=10.0.0",
271
303
  "gaxios": ">=7.1.2",
272
304
  "google-auth-library": ">=10.4.0",
273
305
  "hono": ">=4.0.0",
274
306
  "mediabunny": ">=1.23.0",
275
307
  "next": ">=15",
276
308
  "openai": ">=5.0.0",
309
+ "pocketbase": ">=0.23.0",
277
310
  "sharp": ">=0.34.5",
311
+ "ssh2-sftp-client": ">=11.0.0",
278
312
  "uploadthing": ">=7.0.0"
279
313
  },
280
314
  "peerDependenciesMeta": {
@@ -296,6 +330,9 @@
296
330
  "@aws-sdk/types": {
297
331
  "optional": true
298
332
  },
333
+ "@azure/core-auth": {
334
+ "optional": true
335
+ },
299
336
  "@azure/storage-blob": {
300
337
  "optional": true
301
338
  },
@@ -341,12 +378,21 @@
341
378
  "aws4fetch": {
342
379
  "optional": true
343
380
  },
381
+ "basic-ftp": {
382
+ "optional": true
383
+ },
344
384
  "box-typescript-sdk-gen": {
345
385
  "optional": true
346
386
  },
387
+ "cloudinary": {
388
+ "optional": true
389
+ },
347
390
  "dropbox": {
348
391
  "optional": true
349
392
  },
393
+ "firebase-admin": {
394
+ "optional": true
395
+ },
350
396
  "gaxios": {
351
397
  "optional": true
352
398
  },
@@ -365,9 +411,15 @@
365
411
  "openai": {
366
412
  "optional": true
367
413
  },
414
+ "pocketbase": {
415
+ "optional": true
416
+ },
368
417
  "sharp": {
369
418
  "optional": true
370
419
  },
420
+ "ssh2-sftp-client": {
421
+ "optional": true
422
+ },
371
423
  "uploadthing": {
372
424
  "optional": true
373
425
  }
@@ -1 +0,0 @@
1
- var l=Object.defineProperty;var u=(o,e)=>l(o,"name",{value:e,configurable:!0});import{Readable as p}from"node:stream";import{S as h}from"./s3-base-storage-f_EyFAAt.js";import{w as f,l as S}from"./aws-light-meta-storage-TPyQwLvk.js";import y from"./AwsLightFile-BSqjc_rD.js";var w=Object.defineProperty,C=u((o,e)=>w(o,"name",{value:e,configurable:!0}),"l");class K extends h{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:C(i=>{const s=i;return s.statusCode&&[408,429,500,502,503,504].includes(s.statusCode)?!0:s.retryable??!1},"shouldRetry")}}),this.s3Api=new f({accessKeyId:e.accessKeyId,bucket:t,endpoint:e.endpoint,region:r,secretAccessKey:e.secretAccessKey,service:e.service,sessionToken:e.sessionToken});const{metaStorage:a,metaStorageConfig:n}=e;if(!a){const i={...e,...n,logger:this.logger};this.meta=new S(i)}}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}){return this.instrumentOperation("getStream",async()=>{const t=this.getS3Api(),{Body:r,ContentLength:a,ContentType:n,ETag:i,Expires:s,LastModified:g}=await this.retry(()=>t.getObject({Bucket:this.bucket,Key:e}));await this.checkIfExpired({expiredAt:s});const c=r instanceof ReadableStream?p.fromWeb(r):r,m=new p({read(){c.on("data",d=>{this.push(d)}),c.on("end",()=>{this.push(null)}),c.on("error",d=>{this.destroy(d)})}});return{headers:{"Content-Length":a?.toString()??"0","Content-Type":n,...i&&{ETag:i},...s&&{"X-Upload-Expires":s.toString()},...g&&{"Last-Modified":g.toString()}},size:Number(a),stream:m}})}get raw(){return this.s3Api.aws}getS3Api(){return this.s3Api}getFileClass(){return y}getAcl(){}async accessCheck(e=30){await this.s3Api.checkBucketAccess({Bucket:this.bucket})}}export{K as default};
@@ -1 +0,0 @@
1
- var h=Object.defineProperty;var r=(i,t)=>h(i,"name",{value:t,configurable:!0});import{BlobServiceClient as s,StorageSharedKeyCredential as p}from"@azure/storage-blob";import{throwErrorCode as c,ERRORS as l}from"./ERRORS-CyOuSMLY.js";import u from"./MetaStorage-Y4m1dWgd.js";import{parseMetadata as f,stringifyMetadata as g}from"./Metadata-B6Ir0KO7.js";var N=Object.defineProperty,C=r((i,t)=>N(i,"name",{value:t,configurable:!0}),"c");let v=class extends u{static{r(this,"N")}constructor(t){super(t),this.config=t;const{client:a,...e}=t;if(a===void 0){const n=e.connectionString||process.env.AZURE_STORAGE_CONNECTION_STRING||void 0;if(n)this.client=s.fromConnectionString(n);else{const d=e.accountKey||process.env.AZURE_STORAGE_ACCOUNT_KEY||void 0,o=e.accountName||process.env.AZURE_STORAGE_ACCOUNT||void 0;if(!e.accountKey)throw new Error("Missing required parameter: Azure blob storage account key.");if(!e.accountName)throw new Error("Missing required parameter: Azure blob storage account name.");const m=new p(o,d);this.client=new s(t.endpoint??`https://${o}.blob.core.windows.net`,m)}}else this.client=a;if(!(e.containerName||process.env.AZURE_STORAGE_CONTAINER))throw new Error("Missing required parameter: Azure container name.");this.containerClient=this.client.getContainerClient(e.containerName)}config;static{C(this,"AzureMetaStorage")}client;containerClient;async get(t){const a=this.containerClient.getAppendBlobClient(this.getMetaName(t));let e;try{e=await a.getProperties()}catch{throw c(l.UNKNOWN_ERROR)}if(!e.metadata)throw c(l.FILE_NOT_FOUND);const n=e.metadata;return n.metadata&&typeof n.metadata=="string"&&(n.metadata=f(n.metadata)),n}async touch(t,a){return this.save(t,a)}async delete(t){await this.containerClient.getBlockBlobClient(this.getMetaName(t)).deleteIfExists()}async save(t,a){const e={...a};return e.metadata&&(e.metadata=g(a.metadata)),await this.containerClient.getAppendBlobClient(this.getMetaName(t)).setMetadata(e,{}),a}async list(){const t=[],a=this.containerClient.listBlobsFlat({prefix:this.prefix});for await(const e of a)t.push(e);return t.filter(e=>e.name.endsWith(this.suffix)).map(e=>({createdAt:e.properties.createdOn,id:this.getIdFromMetaName(e.name)}))}};export{v as default};
@@ -1 +0,0 @@
1
- var y=Object.defineProperty;var d=(h,t)=>y(h,"name",{value:t,configurable:!0});import{BlobServiceClient as m,StorageSharedKeyCredential as g}from"@azure/storage-blob";import{L as p}from"./path-D7rMc9nq-B718mbm6.js";import{d as f}from"./detect-file-type-5JhzC9RU.js";import{throwErrorCode as c,ERRORS as l}from"./ERRORS-CyOuSMLY.js";import{B as w,t as b}from"./storage-CoyB2O-Y.js";import{createRetryWrapper as C}from"./isRetryableError-B6ZS_-5I.js";import{v as E}from"./local-meta-storage-CT1audnK.js";import O from"./AzureFile-Dgj2Tef4.js";import T from"./AzureSMetaStorage-DV2tNjKh.js";import{r as N,o as R}from"./part-match-B5fLLmFw.js";import{o as S}from"./has-content-Bx2p8Okx.js";var v=Object.defineProperty,F=d((h,t)=>v(h,"name",{value:t,configurable:!0}),"h");class z extends w{static name="azure";checksumTypes=["md5"];get raw(){return this.client}meta;client;containerClient;root;retry;constructor(t){if(super(t),!t.containerName)throw new Error("Missing required parameter: Azure container name.");const e=t.connectionString||process.env.AZURE_STORAGE_CONNECTION_STRING||void 0;if(e)this.client=m.fromConnectionString(e);else{const i=t.accountKey||process.env.AZURE_STORAGE_ACCOUNT_KEY||void 0,n=t.accountName||process.env.AZURE_STORAGE_ACCOUNT||void 0;if(!t.accountKey)throw new Error("Missing required parameter: Azure blob storage account key.");if(!t.accountName)throw new Error("Missing required parameter: Azure blob storage account name.");const a=new g(n,i);this.client=new m(t.endpoint??`https://${n}.blob.core.windows.net`,a)}this.containerClient=this.client.getContainerClient(t.containerName),this.root=t.root?p(t.root).replace(/^\//,""):"";const r={backoffMultiplier:2,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:F(i=>{const n=i;if(n.statusCode&&[408,429,500,502,503,504].includes(n.statusCode))return!0;if(i instanceof Error){const a=n.code;if(a==="ECONNRESET"||a==="ETIMEDOUT"||a==="ENOTFOUND"||a==="ECONNREFUSED")return!0}return!1},"shouldRetry"),...t.retryConfig};if(this.retry=C(r),t.metaStorage)this.meta=t.metaStorage;else{let i={...t,...t.metaStorageConfig,logger:this.logger};"directory"in i?(this.logger?.debug("Using local meta storage"),this.meta=new E(i)):(e===i.connectionString&&(i={...i,client:this.client}),this.meta=new T(i))}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(i=>{this.logger?.error("Storage access check failed: %O",i)})}async create(t){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const o=typeof t.ttl=="string"?b(t.ttl):t.ttl;o!==void 0&&(e.expiredAt=Date.now()+o)}const r=new O(e);r.name=this.namingFunction(r),await this.validate(r);try{const o=await this.getMeta(r.id);if(o.bytesWritten>=0)return o}catch{}const i=this.containerClient.getBlockBlobClient(this.getFullPath(r.name)),n={};for(const[o,s]of Object.entries(r.metadata||{}))n[o]=JSON.stringify(s);const a=await this.retry(()=>i.uploadData(Buffer.from(""),{blobHTTPHeaders:{blobContentType:r.contentType},metadata:{name:r.name,originalName:r.originalName,...n}}));return a.requestId===void 0?c(l.FILE_ERROR,"azure create upload error"):(r.requestId=a.requestId,r.uri=a._response.headers.get("location"),r.bytesWritten=0,await this.saveMeta(r),r.status="created",await this.onCreate(r),r)})}async delete({id:t}){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);e.status="deleted",await this.retry(()=>this.containerClient.getBlockBlobClient(this.getFullPath(e.name)).deleteIfExists()),await this.deleteMeta(e.id);const r={...e};return await this.onDelete(r),r})}async move(t,e){return this.instrumentOperation("move",async()=>{const r=await this.copy(t,e),i=this.getFullPath(t);return await this.retry(()=>this.containerClient.getBlockBlobClient(i).deleteIfExists()),r})}async write(t){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(!N(t,e))return c(l.FILE_CONFLICT);const r=await this.lock(t.id);try{if(S(t)){if((e.bytesWritten===0||Number.isNaN(e.bytesWritten))&&(!e.contentType||e.contentType==="application/octet-stream"))try{const{fileType:o,stream:s}=await f(t.body);o?.mime&&(e.contentType=o.mime),t.body=s}catch{}const i=this.containerClient.getBlockBlobClient(this.getFullPath(e.name)),n=new AbortController;t.body.on("error",()=>{n.abort()});const a=await this.retry(()=>i.uploadStream(t.body,void 0,void 0,{abortSignal:n.signal,blobHTTPHeaders:{blobContentType:e.contentType??"application/octet-stream"},metadata:e.metadata}));if(a.requestId===void 0)return c(l.FILE_ERROR,"azure write upload error");e.requestId=a.requestId,e.bytesWritten+=t.contentLength||0,e.status=R(e),e.status==="completed"&&(e.uri=a._response.headers.get("location"),await this.deleteMeta(e.id))}}finally{await this.unlock(t.id,r)}return e})}async get({id:t}){return this.instrumentOperation("get",async()=>{const e=this.containerClient.getBlockBlobClient(t);if(!await this.retry(()=>e.exists()))try{return await this.getMeta(t),c(l.GONE)}catch{return c(l.FILE_NOT_FOUND)}const r=await this.retry(()=>e.getProperties()),{contentLength:i,contentType:n,etag:a,expiresOn:o,lastModified:s,metadata:u}=r;return{content:await this.retry(()=>e.downloadToBuffer()),contentType:n,ETag:a,expiredAt:o,id:t,metadata:u||{},modifiedAt:s,name:u?.name||t,originalName:u?.originalName||"",size:i}})}async exists({id:t}){return this.instrumentOperation("exists",async()=>{try{await this.getMeta(t);const e=this.containerClient.getBlockBlobClient(t);return await this.retry(()=>e.exists())}catch{return!1}})}async copy(t,e){return this.instrumentOperation("copy",async()=>{const r=this.containerClient.getBlockBlobClient(this.getFullPath(t));if(!await this.retry(()=>r.exists()))try{return await this.getMeta(t),c(l.GONE)}catch{return c(l.FILE_NOT_FOUND)}const i=this.containerClient.getBlockBlobClient(this.getFullPath(e)),n=await this.retry(()=>i.beginCopyFromURL(r.url));return await this.retry(()=>n.pollUntilDone()),{...await this.getMeta(t),id:e,name:e}})}async list(t=1e3){return this.instrumentOperation("list",async()=>{const e=[];let r=!0,i;for(;r&&e.length<t;)try{const n=Math.min(t-e.length,1e3),a=this.containerClient.listBlobsFlat({includeMetadata:!0,prefix:this.root}).byPage({continuationToken:i,maxPageSize:n}),o=(await this.retry(()=>a.next())).value;if(o!==void 0&&"segment"in o){for(const s of o.segment.blobItems)if(!s.deleted&&(e.push({createdAt:s.properties.createdOn,id:s.name,modifiedAt:s.properties.lastModified}),e.length>=t))break}r=o?.continuationToken!==void 0,r&&(i=o.continuationToken)}catch(n){const a=this.normalizeError(n instanceof Error?n:new Error(String(n)));throw await this.onError(a),n}return e},{limit:t})}getFullPath(t){return this.assetFolder!==void 0?`${this.assetFolder}/${t}`:t}async accessCheck(){await this.retry(()=>this.containerClient.getProperties())}}export{z as default};
@@ -1 +0,0 @@
1
- var a=Object.defineProperty;var r=(t,e)=>a(t,"name",{value:e,configurable:!0});import{v as o}from"./local-meta-storage-CT1audnK.js";var s=Object.defineProperty,c=r((t,e)=>s(t,"name",{value:e,configurable:!0}),"e");class l extends o{static{r(this,"l")}static{c(this,"BoxMetaStorage")}constructor(e){super(e)}}export{l as default};
@@ -1 +0,0 @@
1
- var x=Object.defineProperty;var I=(r,t)=>x(r,"name",{value:t,configurable:!0});import{Readable as b}from"node:stream";import{BoxDeveloperTokenAuth as C,BoxClient as u,OAuthConfig as T,BoxOAuth as O,CcgConfig as S,BoxCcgAuth as U,BoxJwtAuth as L,JwtConfig as F}from"box-typescript-sdk-gen";import{throwErrorCode as v,ERRORS as B}from"./ERRORS-CyOuSMLY.js";import{B as R}from"./storage-CoyB2O-Y.js";import p from"./BoxFile-Be0S4N1L.js";import A from"./BoxMetaStorage-BUe5Qmqe.js";import{o as k,r as D}from"./part-match-B5fLLmFw.js";import{u as H}from"./update-size-DANV7aa2.js";import{o as _}from"./has-content-Bx2p8Okx.js";var M=Object.defineProperty,d=I((r,t)=>M(r,"name",{value:t,configurable:!0}),"c");const N="0",j=50*1024*1024,w={ensureReady:d(()=>Promise.resolve(),"ensureReady")},z=d(r=>{let t=0,e=r.length;for(;t<e&&r[t]==="/";)t+=1;for(;e>t&&r[e-1]==="/";)e-=1;return t===0&&e===r.length?r:r.slice(t,e)},"trimSlashes"),m=d(r=>{const t=z(r);if(!t)throw new Error("Box: key must not be empty");const e=t.split("/").filter(o=>o.length>0),a=e.pop()??"";if(!a)throw new Error(`Box: key "${r}" has no file name segment`);return{leaf:a,parents:e}},"splitKey"),P=d(async r=>{const t=[];for await(const e of r)t.push(Buffer.from(e));return Buffer.concat(t)},"collectStream"),g=d(r=>b.from(r),"bufferToReadable"),$=d(r=>"configJsonString"in r?F.fromConfigJsonString(r.configJsonString):F.fromConfigFile(r.configFilePath),"buildJwtConfig"),J=d(r=>[r.developerToken,r.oauth,r.ccg,r.jwt].filter(t=>t!==void 0).length,"countAuthMethods"),K=d(r=>{if(r.client)return{authHandle:w,client:r.client};if(J(r)>1)throw new Error("Box storage: pass exactly one of `developerToken`, `oauth`, `ccg`, or `jwt`.");if(r.developerToken!==void 0){const e=new C({token:r.developerToken});return{authHandle:w,client:new u({auth:e})}}if(r.oauth){const{clientId:e,clientSecret:a,refreshToken:o}=r.oauth,i=new T({clientId:e,clientSecret:a}),l=new O({config:i});let n;const s=d(async()=>{await l.tokenStorage.store({accessToken:"",refreshToken:o})},"seed");return{authHandle:{ensureReady:d(()=>(n||(n=s()),n),"ensureReady")},client:new u({auth:l})}}if(r.ccg){const{clientId:e,clientSecret:a,enterpriseId:o,userId:i}=r.ccg;if(!o&&!i)throw new Error("Box storage: `ccg` auth requires either `enterpriseId` or `userId`.");const l=new S({clientId:e,clientSecret:a,...o!==void 0&&{enterpriseId:o},...i!==void 0&&{userId:i}}),n=new U({config:l});return{authHandle:w,client:new u({auth:n})}}if(r.jwt){const e=$(r.jwt),a=new L({config:e});return{authHandle:w,client:new u({auth:a})}}const t=process.env.BOX_DEVELOPER_TOKEN;if(t){const e=new C({token:t});return{authHandle:w,client:new u({auth:e})}}throw new Error("Box storage: missing auth. Pass `client`, `developerToken`, `oauth`, `ccg`, or `jwt`. Env fallback: BOX_DEVELOPER_TOKEN.")},"resolveAuth"),q=d(r=>{if(r&&typeof r=="object"){const t=r,e=t.responseInfo?.code??t.responseInfo?.body?.code;return t.responseInfo?.statusCode===404||e==="not_found"||e==="file_not_found"||e==="folder_not_found"||e==="trashed"}return!1},"isNotFoundError"),E=d(r=>{if(r&&typeof r=="object"){const t=r,e=t.responseInfo?.code??t.responseInfo?.body?.code;return t.responseInfo?.statusCode===409||e==="item_name_in_use"||e==="conflict"}return!1},"isConflictError");class ne extends R{static name="box";checksumTypes=[];meta;authHandle;client;fileIdCache;folderIdCache;publicByDefault;rootFolderId;constructor(t){super(t),this.rootFolderId=t.rootFolderId??N,this.publicByDefault=t.publicByDefault??!1;const e=K(t);this.client=e.client,this.authHandle=e.authHandle,this.folderIdCache=new Map,this.fileIdCache=new Map,this.meta=t.metaStorage??new A(t.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(t){return this.instrumentOperation("create",async()=>{const e=new p(t);e.name=this.namingFunction(e),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=k(e),await this.saveMeta(e),await this.onCreate(e),e})}async write(t){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&&H(e,t.size),!D(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");await this.authHandle.ensureReady();const o=await P(t.body),i=e.name||e.id,{leaf:l,parents:n}=m(i),s=await this.resolveFolderId(n,{create:!0}),h=await this.resolveExistingFileForUpload(i,s,l),c=await this.performUpload(h,s,l,o);c.id&&(this.fileIdCache.set(i,c.id),this.publicByDefault&&await this.ensureSharedLink(c.id)),e.bytesWritten=o.length,e.size=o.length,e.boxFileId=c.id,e.eTag=c.etag??void 0,e.ETag=c.etag??void 0}return e.status=k(e),e.status==="completed"&&await this.internalOnComplete(e),await this.saveMeta(e),e}finally{await this.unlock(t.id,a)}})}async delete({id:t}){return this.instrumentOperation("delete",async()=>{let e;try{e=await this.getMeta(t)}catch{}const a=e?.name??t;await this.authHandle.ensureReady();try{const o=e?.boxFileId??await this.resolveFileId(a);await this.client.files.deleteFileById(o),this.fileIdCache.delete(a)}catch(o){if(!q(o))throw o}return e?(e.status="deleted",await this.deleteMeta(e.id),await this.onDelete(e),e):Object.assign(new p({contentType:"application/octet-stream",metadata:{},originalName:t}),{id:t,name:t,status:"deleted"})})}async get({id:t}){return this.instrumentOperation("get",async()=>{let e,a=t;try{e=await this.checkIfExpired(await this.getMeta(t)),a=e.name??t}catch{}await this.authHandle.ensureReady();const o=e?.boxFileId??await this.resolveFileId(a),i=await this.client.files.getFileById(o),l=await this.client.downloads.getDownloadFileUrl(o),n=await fetch(l);if(!n.ok)throw new Error(`Box: download fetch failed (${n.status})`);const s=await n.arrayBuffer(),h=Buffer.from(s);return{content:h,contentType:e?.contentType??"application/octet-stream",ETag:e?.ETag??i.etag??void 0,expiredAt:e?.expiredAt,id:t,metadata:e?.metadata??{},modifiedAt:e?.modifiedAt??i.modifiedAt??i.contentModifiedAt??void 0,name:e?.name??i.name??a,originalName:e?.originalName??i.name??a,size:e?.size??i.size??h.length}})}async copy(t,e){return this.instrumentOperation("copy",async()=>{await this.authHandle.ensureReady();const a=await this.resolveFileId(t),{leaf:o,parents:i}=m(e),l=await this.resolveFolderId(i,{create:!0}),n=await this.client.files.copyFile(a,{name:o,parent:{id:l}});n.id&&this.fileIdCache.set(e,n.id);const s=new p({contentType:"application/octet-stream",metadata:{},originalName:e});return s.id=e,s.name=e,s.boxFileId=n.id,s.eTag=n.etag??void 0,s.ETag=n.etag??void 0,s})}async move(t,e){return this.instrumentOperation("move",async()=>{await this.authHandle.ensureReady();const a=await this.resolveFileId(t),{leaf:o,parents:i}=m(e),l=await this.resolveFolderId(i,{create:!0}),n=await this.client.files.updateFileById(a,{requestBody:{name:o,parent:{id:l}}});this.fileIdCache.delete(t),n.id&&this.fileIdCache.set(e,n.id);const s=new p({contentType:"application/octet-stream",metadata:{},originalName:e});s.id=e,s.name=e,s.boxFileId=n.id,s.eTag=n.etag??void 0,s.ETag=n.etag??void 0;try{await this.deleteMeta(t)}catch{}return s})}async list(t=1e3){return this.instrumentOperation("list",async()=>{await this.authHandle.ensureReady();const e=[];let a=0;const o=Math.min(t,1e3);for(;e.length<t;){const i=(await this.client.folders.getFolderItems(this.rootFolderId,{queryParams:{fields:["id","name","size","modified_at","etag","type"],limit:o,offset:a}})).entries??[];for(const l of i){const n=l;if(n.type!=="file"||!n.id||!n.name)continue;this.fileIdCache.set(n.name,n.id);const s=new p({contentType:"application/octet-stream",metadata:{},originalName:n.name});if(s.id=n.name,s.name=n.name,s.boxFileId=n.id,s.eTag=n.etag??void 0,s.ETag=n.etag??void 0,s.size=n.size??0,s.modifiedAt=n.modifiedAt??n.contentModifiedAt??void 0,e.push(s),e.length>=t)break}if(i.length<o)break;a+=i.length}return e},{limit:t})}async getReadUrl(t,e){if(e?.responseContentDisposition||e?.responseContentType)return v(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 a=await this.resolveFileId(t);return this.publicByDefault?this.ensureSharedLink(a):this.client.downloads.getDownloadFileUrl(a)}async getUploadUrl(t,e){return v(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(t,e){let a=0;const o=1e3;for(;;){const i=(await this.client.folders.getFolderItems(t,{queryParams:{fields:["id","name","type"],limit:o,offset:a}})).entries??[];for(const l of i){const n=l;if(n.name===e&&n.id&&n.type)return{id:n.id,type:n.type}}if(i.length<o)return;a+=i.length}}folderCacheKey(t){return t.join("/")}async resolveFolderId(t,e){if(t.length===0)return this.rootFolderId;const a=this.folderCacheKey(t),o=this.folderIdCache.get(a);if(o)return o;let i=this.rootFolderId;const l=[];for(const n of t){l.push(n);const s=this.folderCacheKey(l),h=this.folderIdCache.get(s);if(h){i=h;continue}const c=await this.findChildByName(i,n);if(c&&c.type==="folder"){i=c.id,this.folderIdCache.set(s,i);continue}if(c&&c.type!=="folder")throw new Error(`Box: path segment "${n}" exists but is not a folder`);if(!e.create)throw new Error(`Box: folder "${l.join("/")}" not found`);try{const f=await this.client.folders.createFolder({name:n,parent:{id:i}});if(!f.id)throw new Error(`Box: createFolder did not return an id for "${n}"`);i=f.id,this.folderIdCache.set(s,i)}catch(f){if(E(f)){const y=await this.findChildByName(i,n);if(y&&y.type==="folder"){i=y.id,this.folderIdCache.set(s,i);continue}}throw f}}return this.folderIdCache.set(a,i),i}async resolveFileId(t){const e=this.fileIdCache.get(t);if(e)return e;const{leaf:a,parents:o}=m(t),i=await this.resolveFolderId(o,{create:!1}),l=await this.findChildByName(i,a);if(!l||l.type!=="file")throw new Error(`Box: file "${t}" not found`);return this.fileIdCache.set(t,l.id),l.id}async resolveExistingFileForUpload(t,e,a){const o=this.fileIdCache.get(t);if(o)return o;const i=await this.findChildByName(e,a);if(i){if(i.type==="file")return this.fileIdCache.set(t,i.id),i.id;throw new Error(`Box: "${t}" already exists as a non-file (${i.type})`)}}async performUpload(t,e,a,o){if(o.byteLength>j)return await this.client.chunkedUploads.uploadBigFile(g(o),a,o.byteLength,e);if(t){const l=((await this.client.uploads.uploadFileVersion(t,{attributes:{name:a},file:g(o)})).entries??[])[0];if(!l)throw new Error("Box: uploadFileVersion returned no file");return l}const i=((await this.client.uploads.uploadFile({attributes:{name:a,parent:{id:e}},file:g(o)})).entries??[])[0];if(!i)throw new Error("Box: uploadFile returned no file");return i}async ensureSharedLink(t){try{const e=(await this.client.sharedLinksFiles.addShareLinkToFile(t,{sharedLink:{access:"open"}},{fields:"shared_link"})).sharedLink;return(e?.downloadUrl??e?.url)||this.fetchSharedLinkUrl(t)}catch(e){if(E(e))return this.fetchSharedLinkUrl(t);throw e}}async fetchSharedLinkUrl(t){const e=(await this.client.sharedLinksFiles.getSharedLinkForFile(t,{fields:"shared_link"})).sharedLink,a=e?.downloadUrl??e?.url;if(!a)throw new Error("Box: file has no shared link. Call write() with publicByDefault: true, or addShareLinkToFile via storage.raw.");return a}internalOnComplete=d(t=>this.deleteMeta(t.id),"internalOnComplete")}export{ne as default};
@@ -1 +0,0 @@
1
- var a=Object.defineProperty;var r=(t,e)=>a(t,"name",{value:e,configurable:!0});import{v as o}from"./local-meta-storage-CT1audnK.js";var s=Object.defineProperty,n=r((t,e)=>s(t,"name",{value:e,configurable:!0}),"e");class i extends o{static{r(this,"l")}static{n(this,"BunnyMetaStorage")}constructor(e){super(e)}}export{i as default};
@@ -1 +0,0 @@
1
- var T=Object.defineProperty;var w=(n,t)=>T(n,"name",{value:t,configurable:!0});import*as c from"@bunny.net/storage-sdk";import{throwErrorCode as d,ERRORS as y,wrapStorageError as p}from"./ERRORS-CyOuSMLY.js";import{B as N}from"./storage-CoyB2O-Y.js";import m from"./BunnyFile-Dotl-lO9.js";import B from"./BunnyMetaStorage-D0mT6veJ.js";import{o as f,r as b}from"./part-match-B5fLLmFw.js";import{u as A}from"./update-size-DANV7aa2.js";import{o as _}from"./has-content-Bx2p8Okx.js";var R=Object.defineProperty,o=w((n,t)=>R(n,"name",{value:t,configurable:!0}),"o");const E=new Set(Object.values(c.regions.StorageRegion)),l=o(n=>`/${n.replace(/^\/+/u,"")}`,"toBunnyPath"),g=o(n=>n.replace(/^\/+/u,""),"fromBunnyPath"),U=o((n,t)=>{const e=n.replace(/\/+$/u,""),a=t.replace(/^\/+/u,"");return`${e}/${a}`},"joinPublicUrl"),C=o(async n=>{const t=[];for await(const e of n)t.push(Buffer.from(e));return Buffer.concat(t)},"collectStream"),S=o(n=>new ReadableStream({start(t){t.enqueue(new Uint8Array(n)),t.close()}}),"streamFromBuffer"),v=o(n=>{if(n){if(!E.has(n))throw new Error(`Bunny Storage: unsupported region "${n}". Pass one of ${[...E].join(", ")}.`);return n}},"parseRegion"),z=o(n=>{if(n.client)return n.client;const t=n.zone??process.env.BUNNY_STORAGE_ZONE??process.env.STORAGE_ZONE,e=n.accessKey??process.env.BUNNY_STORAGE_ACCESS_KEY??process.env.BUNNY_ACCESS_KEY??process.env.STORAGE_ACCESS_KEY,a=v(n.region??process.env.BUNNY_STORAGE_REGION??process.env.STORAGE_REGION);if(!t||!e||!a)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(a,t,e)},"resolveClient"),P=o(async n=>Buffer.from(await new Response(n).arrayBuffer()),"collectFromWebStream"),h=o((n,t)=>{const e=n?.message,a=typeof e=="string"?e:"";return/^file not found/iu.test(a)?p(n,{adapter:"Bunny Storage",operation:t,status:404}):/^unauthorized access/iu.test(a)?p(n,{adapter:"Bunny Storage",operation:t,status:401}):/^unable to upload file/iu.test(a)?p(n,{adapter:"Bunny Storage",operation:t,status:400}):p(n,{adapter:"Bunny Storage",operation:t})},"wrapBunnyError");class L extends N{static name="bunny";checksumTypes=["SHA256"];meta;client;publicBaseUrl;zoneName;constructor(t){super(t),this.client=z(t),this.zoneName=c.zone.name(this.client),this.publicBaseUrl=t.publicBaseUrl,this.meta=t.metaStorage??new B(t.metaStorageConfig),this.isReady=!0}get raw(){return this.client}get zone(){return this.zoneName}async create(t){return this.instrumentOperation("create",async()=>{const e=new m(t);e.name=this.namingFunction(e),e.bunnyPath=l(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=f(e),await this.saveMeta(e),await this.onCreate(e),e})}async write(t){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&&A(e,t.size),!b(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 r=await C(t.body),s=l(e.name||e.id);try{await c.file.upload(this.client,s,S(r),{contentType:e.contentType,...t.checksum&&t.checksumAlgorithm==="sha256"&&{sha256Checksum:t.checksum}})}catch(i){throw h(i,"upload")}e.bytesWritten=r.length,e.size=r.length,e.bunnyPath=s}return e.status=f(e),e.status==="completed"&&await this.internalOnComplete(e),await this.saveMeta(e),e}finally{await this.unlock(t.id,a)}})}async delete({id:t}){return this.instrumentOperation("delete",async()=>{let e;try{e=await this.getMeta(t)}catch{}const a=e?.bunnyPath??l(e?.name??t);try{await c.file.remove(this.client,a)}catch(s){throw h(s,"delete")}if(e)return e.status="deleted",await this.deleteMeta(e.id),await this.onDelete(e),e;const r=new m({contentType:"application/octet-stream",metadata:{},originalName:t});return r.id=t,r.name=t,r.bunnyPath=a,r.status="deleted",r})}async get({id:t}){return this.instrumentOperation("get",async()=>{let e,a;try{e=await this.checkIfExpired(await this.getMeta(t)),a=e.bunnyPath??l(e.name??t)}catch{a=l(t)}let r;try{r=await c.file.get(this.client,a)}catch(i){throw h(i,"get")}let s;try{const i=await r.data();s=await P(i.stream)}catch(i){throw h(i,"download")}return{content:s,contentType:e?.contentType??r.contentType??"application/octet-stream",ETag:e?.ETag??r.checksum??void 0,expiredAt:e?.expiredAt,id:t,metadata:e?.metadata??{},modifiedAt:e?.modifiedAt??r.lastChanged?.toISOString(),name:e?.name??g(a),originalName:e?.originalName??g(a),size:e?.size??r.length??s.length}})}async copy(t,e){return this.instrumentOperation("copy",async()=>{const a=await this.get({id:t}),r=l(e),s=a.content,i=typeof a.size=="string"?Number(a.size):a.size??s.length;try{await c.file.upload(this.client,r,S(s),{contentType:a.contentType})}catch(O){throw h(O,"copy")}const u=new m({contentType:a.contentType,metadata:{},originalName:e});return u.id=e,u.name=e,u.bunnyPath=r,u.size=i,u.ETag=a.ETag,u.bunnyChecksum=a.ETag,u})}async move(t,e){return this.instrumentOperation("move",async()=>{const a=await this.copy(t,e);return await this.delete({id:t}),a})}async list(t=1e3){return this.instrumentOperation("list",async()=>{let e;try{e=await c.file.list(this.client,"/")}catch(a){throw h(a,"list")}return e.filter(a=>!a.isDirectory).slice(0,t).map(a=>{const r=a.path.endsWith(a.objectName)||!a.objectName?a.path:`${a.path.replace(/\/+$/u,"")}/${a.objectName}`,s=g(r),i=new m({contentType:a.contentType||"application/octet-stream",metadata:{},originalName:s});return i.id=s,i.name=s,i.bunnyPath=l(s),i.bunnyChecksum=a.checksum??void 0,i.ETag=a.checksum??void 0,i.size=a.length,i.modifiedAt=a.lastChanged?.toISOString(),i})},{limit:t})}async getReadUrl(t,e){return e?.responseContentDisposition?d(y.METHOD_NOT_ALLOWED,"Bunny Storage: `responseContentDisposition` is not supported — no override exists on Bunny Storage / Pull Zone URLs."):this.publicBaseUrl?U(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,e){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=o(t=>this.deleteMeta(t.id),"internalOnComplete")}export{L as default};
@@ -1 +0,0 @@
1
- import"node:fs";import"node:fs/promises";import"node:stream";import"./local-meta-storage-CT1audnK.js";import{f as b}from"./disk-storage-CbSSPnOf.js";import"./path-D7rMc9nq-B718mbm6.js";import"./detect-file-type-5JhzC9RU.js";import"./ERRORS-CyOuSMLY.js";import"./storage-CoyB2O-Y.js";import"./File-BhfUgJjs.js";import"./part-match-B5fLLmFw.js";import"./update-size-DANV7aa2.js";import"./has-content-Bx2p8Okx.js";export{b as default};
@@ -1 +0,0 @@
1
- var v=Object.defineProperty;var g=(a,t)=>v(a,"name",{value:t,configurable:!0});import{DropboxResponseError as _,DropboxAuth as d,Dropbox as f}from"dropbox";import{throwErrorCode as m,ERRORS as y}from"./ERRORS-CyOuSMLY.js";import{c as E}from"./oauth-refresh-Dg2ybc6_.js";import{B as D}from"./storage-CoyB2O-Y.js";import p from"./DropboxFile-BGVG2kXM.js";import S from"./DropboxMetaStorage-CICuUZ1n.js";import{o as b,r as x}from"./part-match-B5fLLmFw.js";import{u as B}from"./update-size-DANV7aa2.js";import{o as R}from"./has-content-Bx2p8Okx.js";var H=Object.defineProperty,c=g((a,t)=>H(a,"name",{value:t,configurable:!0}),"c");const w=14400,U=150*1024*1024,u=8*1024*1024,k=c((a,t)=>{a.auth.setAccessToken(t)},"setAccessToken"),C=c(a=>a.auth.getAccessToken(),"getAccessToken"),T=c(a=>{let t=0,e=a.length;for(;t<e&&a[t]==="/";)t+=1;for(;e>t&&a[e-1]==="/";)e-=1;return t===0&&e===a.length?a:a.slice(t,e)},"trimSlashes"),L=c(async a=>{const t=[];for await(const e of a)t.push(Buffer.from(e));return Buffer.concat(t)},"collectStream"),A=c(a=>a.includes("?dl=0")?a.replace("?dl=0","?dl=1"):a.includes("?dl=")?a:a+(a.includes("?")?"&dl=1":"?dl=1"),"rewriteSharedLinkForDirectDownload"),P=c((a,t)=>(k(a,t),{ensureAccessToken:c(()=>Promise.resolve(),"ensureAccessToken"),getAccessToken:c(()=>Promise.resolve(t),"getAccessToken")}),"createStaticAccessTokenAuth"),F=c((a,t)=>{const e=c(async()=>{const s=await t();return k(a,s),s},"ensure");return{async ensureAccessToken(){await e()},getAccessToken:e}},"createCallableAccessTokenAuth"),O=c((a,t)=>{const e=E({buildBody:c(()=>new URLSearchParams({client_id:t.appKey,grant_type:"refresh_token",refresh_token:t.refreshToken,...t.appSecret&&{client_secret:t.appSecret}}),"buildBody"),onRefresh:c(s=>{k(a,s)},"onRefresh"),provider:"Dropbox",tokenUrl:"https://api.dropboxapi.com/oauth2/token"});return{async ensureAccessToken(){await e.getAccessToken()},getAccessToken:c(()=>e.getAccessToken(),"getAccessToken")}},"createRefreshTokenAuth"),K=c(a=>{if(a.client){const o=a.client;return{authHandle:{ensureAccessToken:c(()=>Promise.resolve(),"ensureAccessToken"),getAccessToken:c(()=>Promise.resolve(C(o)),"getAccessToken")},client:o}}const t=a.accessToken,e=a.refreshToken!==void 0||a.appKey!==void 0||a.appSecret!==void 0;if(t!==void 0&&e)throw new Error("Dropbox storage: pass exactly one of `accessToken` or `refreshToken` (with `appKey`).");if(t!==void 0){const o=new d({accessToken:typeof t=="string"?t:void 0}),n=new f({auth:o});return{authHandle:typeof t=="function"?F(n,t):P(n,t),client:n}}if(e){if(!a.refreshToken||!a.appKey)throw new Error("Dropbox storage: refresh-token auth requires both `refreshToken` and `appKey`.");const o=new d({}),n=new f({auth:o});return{authHandle:O(n,{appKey:a.appKey,...a.appSecret&&{appSecret:a.appSecret},refreshToken:a.refreshToken}),client:n}}const s=process.env.DROPBOX_ACCESS_TOKEN;if(s){const o=new d({accessToken:s}),n=new f({auth:o});return{authHandle:P(n,s),client:n}}const r=process.env.DROPBOX_REFRESH_TOKEN,i=process.env.DROPBOX_APP_KEY;if(r&&i){const o=process.env.DROPBOX_APP_SECRET,n=new d({}),h=new f({auth:n});return{authHandle:O(h,{appKey:i,...o&&{appSecret:o},refreshToken:r}),client:h}}throw new Error("Dropbox storage: missing auth. Pass `client`, `accessToken`, or `refreshToken` + `appKey`. Env fallbacks: DROPBOX_ACCESS_TOKEN, or DROPBOX_REFRESH_TOKEN + DROPBOX_APP_KEY (+ DROPBOX_APP_SECRET).")},"resolveAuth");class Y extends D{static name="dropbox";checksumTypes=[];meta;authHandle;client;defaultUrlExpiresIn;publicByDefault;rootFolderPath;constructor(t){super(t),this.rootFolderPath=T(t.rootFolderPath??""),this.publicByDefault=t.publicByDefault??!1,this.defaultUrlExpiresIn=Math.min(t.defaultUrlExpiresIn??3600,w);const e=K(t);this.client=e.client,this.authHandle=e.authHandle,this.meta=t.metaStorage??new S(t.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(t){return this.instrumentOperation("create",async()=>{const e=new p(t);e.name=this.namingFunction(e),e.path=this.keyToPath(e.name),await this.validate(e);try{const s=await this.getMeta(e.id);if(s.bytesWritten>=0)return s}catch{}return e.bytesWritten=0,e.status=b(e),await this.saveMeta(e),await this.onCreate(e),e})}async write(t){return this.instrumentOperation("write",async()=>{let e;if("contentType"in t&&"metadata"in t&&!("body"in t)&&!("start"in t)?e=t:(e=await this.getMeta(t.id),await this.checkIfExpired(e)),e.status==="completed")return e;if(t.size!==void 0&&B(e,t.size),!x(t,e))throw new Error("File part does not match");const s=await this.lock(t.id);try{if(R(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const r=await L(t.body),i=e.path??this.keyToPath(e.name||e.id);await this.authHandle.ensureAccessToken();const o=r.byteLength<=U?await this.uploadSimple(i,r):await this.uploadSession(i,r);e.bytesWritten=r.length,e.size=r.length,e.path=o.path_display??i,e.rev=o.rev,e.ETag=o.rev}return e.status=b(e),e.status==="completed"&&await this.internalOnComplete(e),await this.saveMeta(e),e}finally{await this.unlock(t.id,s)}})}async delete({id:t}){return this.instrumentOperation("delete",async()=>{let e;try{e=await this.getMeta(t)}catch{}const s=e?.path??this.keyToPath(e?.name??t);await this.authHandle.ensureAccessToken();try{await this.client.filesDeleteV2({path:s})}catch(r){if(!M(r))throw r}return e?(e.status="deleted",await this.deleteMeta(e.id),await this.onDelete(e),e):Object.assign(new p({contentType:"application/octet-stream",metadata:{},originalName:t}),{id:t,name:t,path:s,status:"deleted"})})}async get({id:t}){return this.instrumentOperation("get",async()=>{let e,s=this.keyToPath(t);try{e=await this.checkIfExpired(await this.getMeta(t)),s=e.path??this.keyToPath(e.name??t)}catch{}await this.authHandle.ensureAccessToken();const r=(await this.client.filesDownload({path:s})).result;let i;if(r.fileBinary instanceof Uint8Array)i=Buffer.from(r.fileBinary.buffer,r.fileBinary.byteOffset,r.fileBinary.byteLength);else if(r.fileBlob instanceof Blob)i=Buffer.from(await r.fileBlob.arrayBuffer());else throw new TypeError("Dropbox: unexpected download response shape — neither fileBinary nor fileBlob present");return{content:i,contentType:e?.contentType??"application/octet-stream",ETag:e?.ETag??r.rev,expiredAt:e?.expiredAt,id:t,metadata:e?.metadata??{},modifiedAt:e?.modifiedAt??r.server_modified,name:e?.name??r.name,originalName:e?.originalName??r.name,size:e?.size??r.size??i.length}})}async copy(t,e){return this.instrumentOperation("copy",async()=>{const s=this.keyToPath(t),r=this.keyToPath(e);await this.authHandle.ensureAccessToken(),await this.client.filesCopyV2({from_path:s,to_path:r});const i=new p({contentType:"application/octet-stream",metadata:{},originalName:e});return i.id=e,i.name=e,i.path=r,i})}async move(t,e){return this.instrumentOperation("move",async()=>{const s=this.keyToPath(t),r=this.keyToPath(e);await this.authHandle.ensureAccessToken(),await this.client.filesMoveV2({from_path:s,to_path:r});const i=new p({contentType:"application/octet-stream",metadata:{},originalName:e});i.id=e,i.name=e,i.path=r;try{await this.deleteMeta(t)}catch{}return i})}async list(t=1e3){return this.instrumentOperation("list",async()=>{await this.authHandle.ensureAccessToken();const e=await this.client.filesListFolder({limit:t,path:this.rootFolderPath?`/${this.rootFolderPath}`:"",recursive:!0}),{result:s}=e,r=[];for(const i of s.entries){if(i[".tag"]!=="file")continue;const o=i,n=o.path_display??o.path_lower??`/${o.name}`,h=this.pathToKey(n);if(!h)continue;const l=new p({contentType:"application/octet-stream",metadata:{},originalName:o.name});l.id=h,l.name=h,l.path=n,l.size=o.size,l.rev=o.rev,l.ETag=o.rev,l.modifiedAt=o.server_modified,r.push(l)}return r},{limit:t})}async getReadUrl(t,e){if(e?.responseContentDisposition)return m(y.METHOD_NOT_ALLOWED,"Dropbox: `responseContentDisposition` is not supported — Dropbox temporary links have no Content-Disposition override.");const s=e?.expiresIn??this.defaultUrlExpiresIn;return s>w?m(y.METHOD_NOT_ALLOWED,`Dropbox: \`expiresIn\` of ${s}s exceeds the ${w}s (4h) maximum. Use \`publicByDefault: true\` for a permanent shared link.`):(await this.authHandle.ensureAccessToken(),this.publicByDefault?await this.createPublicSharedLink(t):(await this.client.filesGetTemporaryLink({path:this.keyToPath(t)})).result.link)}async getUploadUrl(t,e){return m(y.METHOD_NOT_ALLOWED,"Dropbox: presigned upload URLs use POST with a raw body, which doesn't fit the PUT-style upload-url contract. Use `write()` or `storage.raw.filesGetTemporaryUploadLink(...)` directly.")}keyToPath(t){const e=T(t),s=[];return this.rootFolderPath&&s.push(this.rootFolderPath),e&&s.push(e),s.length===0?"":`/${s.join("/")}`}pathToKey(t){const e=T(t);if(!this.rootFolderPath)return e;if(e===this.rootFolderPath)return"";const s=`${this.rootFolderPath}/`;return e.startsWith(s)?e.slice(s.length):e}async uploadSimple(t,e){return(await this.client.filesUpload({contents:e,mode:{".tag":"overwrite"},mute:!0,path:t})).result}async uploadSession(t,e){const s=e.byteLength;let r=0;const i=(await this.client.filesUploadSessionStart({close:!1,contents:e.subarray(r,Math.min(r+u,s))})).result.session_id;for(r=Math.min(r+u,s);s-r>u;){const n=e.subarray(r,r+u);await this.client.filesUploadSessionAppendV2({close:!1,contents:n,cursor:{offset:r,session_id:i}}),r+=u}const o=e.subarray(r,s);return(await this.client.filesUploadSessionFinish({commit:{mode:{".tag":"overwrite"},mute:!0,path:t},contents:o,cursor:{offset:r,session_id:i}})).result}async createPublicSharedLink(t){try{const e=await this.client.sharingCreateSharedLinkWithSettings({path:this.keyToPath(t),settings:{requested_visibility:{".tag":"public"}}});return A(e.result.url)}catch(e){if(e instanceof _){const s=e.error?.shared_link_already_exists?.metadata?.url;if(typeof s=="string"&&s.length>0)return A(s)}throw e}}internalOnComplete=c(t=>this.deleteMeta(t.id),"internalOnComplete")}const M=c(a=>{if(!(a instanceof _))return!1;if(a.status===404)return!0;const t=[],e=c((s,r)=>{if(r>6||s===null||typeof s!="object")return;const i=s,o=i[".tag"];typeof o=="string"&&t.push(o);for(const n of Object.values(i))n&&typeof n=="object"&&e(n,r+1)},"walk");return e(a.error,0),t.includes("not_found")||t.includes("not_file")||t.includes("not_folder")},"isNotFoundError");export{Y as default};
@@ -1 +0,0 @@
1
- var g=Object.defineProperty;var l=(u,t)=>g(u,"name",{value:t,configurable:!0});import{randomUUID as f}from"node:crypto";import{request as y}from"gaxios";import{GoogleAuth as w}from"google-auth-library";import{r as C,E as R,b,g as E,d}from"./gcs-meta-storage-XB-UPJn6.js";import{d as U}from"./detect-file-type-5JhzC9RU.js";import{throwErrorCode as k,ERRORS as $}from"./ERRORS-CyOuSMLY.js";import{B as I,t as S}from"./storage-CoyB2O-Y.js";import{v as T}from"./local-meta-storage-CT1audnK.js";import m from"./GCSConfig-BQ0OpVhe.js";import v from"./GCSFile-CDQ6IWAz.js";import{r as O,o as A}from"./part-match-B5fLLmFw.js";import{o as B}from"./has-content-Bx2p8Okx.js";var j=Object.defineProperty,x=l((u,t)=>j(u,"name",{value:t,configurable:!0}),"e");class P extends Error{static{l(this,"o")}constructor(t,e,r){super(t),this.code=e,this.config=r}code;config;static{x(this,"FetchError")}name="FetchError"}var G=Object.defineProperty,p=l((u,t)=>G(u,"name",{value:t,configurable:!0}),"m");const q=p(u=>u>=200&&u<300||u===308||u===499,"validateStatus");class V extends I{static name="gcs";checksumTypes=["md5","crc32c"];get raw(){return this.authClient}meta;bucket;authClient;storageBaseURI;uploadBaseURI;isCustomEndpoint=!1;retryOptions={};useAuthWithCustomEndpoint;userProject;constructor(t){super(t);const e=t.bucket||process.env.GCS_BUCKET;if(!e)throw new Error("GCS bucket is not defined");if(!t.projectId)throw new Error("Sorry, we cannot connect to Cloud Services without a project ID.");this.bucket=e,this.storageBaseURI=`${t.storageAPI||m.storageAPI}/${this.bucket}/o`,this.uploadBaseURI=`${t.uploadAPI||m.uploadAPI}/${this.bucket}/o`,this.isCustomEndpoint=new URL(this.storageBaseURI).hostname!=="storage.googleapis.com";const{retryOptions:r,useAuthWithCustomEndpoint:s,userProject:i}=t;this.userProject=i,this.useAuthWithCustomEndpoint=s||!1,this.retryOptions={...C,...r},t.scopes||=m.authScopes,this.authClient=new w(t);const{bucket:o,metaStorage:n,metaStorageConfig:a,projectId:c}=t;if(n)this.meta=n;else{let h={...t,...a,logger:this.logger};"directory"in h?(this.logger?.debug("Using local meta storage"),this.meta=new T(h)):(o===h.bucket&&c===h.projectId&&(h={...h,authClient:this.authClient}),this.meta=new R(h))}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(h=>{this.logger?.error("Storage access check failed: %O",h)})}normalizeError(t){if(t.config){const e=+t.code||500;return{code:`GCS${e}`,message:t.message,name:t.name,retryable:e>=499,statusCode:e}}return{code:"GenericUploadError",message:`[${this.constructor.name}] ${t.message}`,name:t.name,statusCode:500}}async create(t){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const a=typeof t.ttl=="string"?S(t.ttl):t.ttl;a!==void 0&&(e.expiredAt=Date.now()+a)}const r=new v(e);r.name=this.namingFunction(r),await this.validate(r);try{const a=await this.getMeta(r.id);return a.bytesWritten=await this.internalWrite(a),a}catch{}const s={"Content-Type":"application/json; charset=utf-8","X-Goog-Upload-Command":"start","X-Goog-Upload-Protocol":"resumable","X-Upload-Content-Length":r.size.toString(),"X-Upload-Content-Type":r.contentType},i={body:JSON.stringify({metadata:r.metadata}),headers:s,method:"POST",params:{name:r.name,size:r.size,uploadType:"resumable"},url:this.uploadBaseURI},o=await this.makeRequest(i);if(o.status!==200)throw new Error("Expected 200 response from GCS");const n=o.headers.get("X-Goog-Upload-Status")||o.headers.get("x-goog-upload-status");if(n!=="active")throw new Error(`X-Goog-Upload-Status response header expected 'active' got: ${n}`);return r.uri=o.headers.get("location"),this.config.clientDirectUpload?(r.GCSUploadURI=r.uri,this.logger?.debug("send uploadURI to client: %s",r.GCSUploadURI),r.status="created",r):(r.bytesWritten=0,await this.saveMeta(r),r.status="created",await this.onCreate(r),r)})}async write(t){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(!O(t,e))return k($.FILE_CONFLICT);const r=await this.lock(t.id);try{if(B(t)&&(e.bytesWritten===0||Number.isNaN(e.bytesWritten))&&(!e.contentType||e.contentType==="application/octet-stream"))try{const{fileType:s,stream:i}=await U(t.body);s?.mime&&(e.contentType=s.mime),t.body=i}catch{}e.bytesWritten=await this.internalWrite({...e,...t}),e.status=A(e),e.status==="completed"&&(e.uri=`${this.storageBaseURI}/${e.name}`,await this.internalOnComplete(e))}finally{await this.unlock(t.id,r)}return e})}async delete({id:t}){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);if(!e.uri)throw new Error(`File ${t} does not have a valid URI`);e.status="deleted",await this.makeRequest({method:"DELETE",url:e.uri,validateStatus:q}),await this.deleteMeta(e.id);const r={...e};return await this.onDelete(r),r})}async copy(t,e){return this.instrumentOperation("copy",async()=>{const r=new URL(`/${this.bucket}/${t}`,"file://"),s=new URL(encodeURI(e),r).pathname,[,i,...o]=s.split("/"),n=o.join("/"),a=`${this.storageBaseURI}/${t}/rewriteTo/b/${i}/o/${n}`;let c={};const h={body:"",headers:{"Content-Type":"application/json"},method:"POST",url:a};do h.body=c.rewriteToken?JSON.stringify({rewriteToken:c.rewriteToken}):"",c=(await this.makeRequest(h)).data||{};while(c.rewriteToken);return await this.getMeta(e)})}async move(t,e){return this.instrumentOperation("move",async()=>{const r=await this.copy(t,e),s=`${this.storageBaseURI}/${t}`;return await this.makeRequest({method:"DELETE",url:s}),r})}async get({id:t}){return this.instrumentOperation("get",async()=>{const{data:e}=await this.makeRequest({params:{alt:"json"},url:`${this.storageBaseURI}/${t}`});if(await this.checkIfExpired({expiredAt:e.timeDeleted}),!e.uri)throw new Error("File URI not found");const r=(await this.makeRequest({params:{alt:"media"},url:e.uri})).data;let s;if(typeof r=="string")s=Buffer.from(r,"utf8");else if(r&&typeof r=="object"&&"data"in r){const i=r.data;s=Buffer.from(i)}else s=Buffer.from(r);return{...e,content:s}})}async exists({id:t}){return this.instrumentOperation("exists",async()=>{try{return await this.getMeta(t),await this.makeRequest({method:"HEAD",url:`${this.storageBaseURI}/${t}`}),!0}catch{return!1}})}async list(t=1e3){return this.instrumentOperation("list",async()=>{const e=[],r=Math.min(t,1e3);let s=!0,i={params:{maxResults:r},url:this.storageBaseURI};for(;s&&e.length<t;)try{const{data:o}=await this.makeRequest(i);for(const{name:n,timeCreated:a,updated:c}of o?.items||[]){if(e.length>=t)break;e.push({createdAt:a,id:n,modifiedAt:c})}s=o?.nextPageToken!==void 0,s&&e.length<t&&(i={...i,params:{...i.params,maxResults:Math.min(r,t-e.length),pageToken:o.nextPageToken}})}catch(o){const n=this.normalizeError(o instanceof Error?o:new Error(String(o)));throw await this.onError(n),o}return e},{limit:t})}async internalWrite(t){const{body:e,bytesWritten:r,size:s,uri:i=""}=t,o=b(t),n={method:"PUT"};if(e?.on){const a=new AbortController;e.on("aborted",()=>{a.abort()}),n.body=e,n.signal=a.signal}n.headers={Accept:"application/json","Content-Range":o,...s===r?{"X-Goog-Upload-Command":"upload, finalize"}:{}};try{const a=await this.makeRequest({url:i,...n});if(a.status===308){const c=a.headers.get("range");return c?E(c):0}if(a.status===200)return this.logger?.debug("uploaded %O",a.data),s;throw new P(String(a.data),`GCS${a.status}`,{uri:i})}catch(a){this.logger?.error(i,a);const c=this.normalizeError(a instanceof Error?a:new Error(String(a)));throw await this.onError(c),a}}internalOnComplete=p(t=>this.deleteMeta(t.id),"internalOnComplete");async makeRequest(t){return typeof t.url=="string"&&(t.url=t.url.replaceAll("/:",":")),t={...t,headers:{"User-Agent":`${d.name}/${d.version}`,"x-goog-api-client":`gl-node/${process.versions.node} gccl/${d.version} gccl-invocation-id/${f()}`,...t.headers},params:{...this.userProject===void 0?{}:{userProject:this.userProject},...t.params},retry:!0,retryConfig:this.retryOptions,timeout:6e4},this.isCustomEndpoint&&!this.useAuthWithCustomEndpoint?y(t):this.authClient.request(t)}async accessCheck(){return this.makeRequest({url:this.storageBaseURI.replace("/o","")})}}export{V as default};
@@ -1 +0,0 @@
1
- var b=Object.defineProperty;var f=(i,e)=>b(i,"name",{value:e,configurable:!0});import{Readable as C}from"node:stream";import{drive as k}from"@googleapis/drive";import{JWT as g,GoogleAuth as T,OAuth2Client as F}from"google-auth-library";import{throwErrorCode as y,ERRORS as p,wrapStorageError as E}from"./ERRORS-CyOuSMLY.js";import{B as _}from"./storage-CoyB2O-Y.js";import m from"./GoogleDriveFile-D0aGfGbL.js";import L from"./GoogleDriveMetaStorage-rghGy3Fa.js";import{o as I,r as G}from"./part-match-B5fLLmFw.js";import{u as A}from"./update-size-DANV7aa2.js";import{o as R}from"./has-content-Bx2p8Okx.js";var P=Object.defineProperty,c=f((i,e)=>P(i,"name",{value:e,configurable:!0}),"c");const u="https://www.googleapis.com/auth/drive",B=1024,h="fsdkKey",v="fsdkContentType",D="id, name, size, mimeType, md5Checksum, modifiedTime, appProperties",w=c(i=>{const e=i.lastIndexOf("/");return e===-1?i:i.slice(e+1)},"basename"),O=c(i=>i.replaceAll("\\","\\\\").replaceAll("'",String.raw`\'`),"escapeQueryValue");class U{static{f(this,"L")}static{c(this,"LRU")}#t;#e=new Map;constructor(e){this.#t=Math.max(1,e)}delete(e){this.#e.delete(e)}get(e){const t=this.#e.get(e);if(t!==void 0)return this.#e.delete(e),this.#e.set(e,t),t}set(e,t){if(this.#e.has(e)&&this.#e.delete(e),this.#e.set(e,t),this.#e.size>this.#t){const r=this.#e.keys().next().value;r!==void 0&&this.#e.delete(r)}}}const z=c(i=>{const e=i.subject??process.env.GOOGLE_DRIVE_SUBJECT;if(i.credentials)return new g({email:i.credentials.client_email,key:i.credentials.private_key,scopes:[u],...e&&{subject:e}});if(i.keyFilename)return new T({keyFile:i.keyFilename,scopes:[u],...e&&{clientOptions:{subject:e}}});if(i.oauth){const s=new F({clientId:i.oauth.clientId,clientSecret:i.oauth.clientSecret});return s.setCredentials({refresh_token:i.oauth.refreshToken}),s}const t=process.env.GOOGLE_DRIVE_CLIENT_EMAIL,r=process.env.GOOGLE_DRIVE_PRIVATE_KEY;if(t&&r)return new g({email:t,key:r,scopes:[u],...e&&{subject:e}});const a=process.env.GOOGLE_DRIVE_KEY_FILE;if(a)return new T({keyFile:a,scopes:[u],...e&&{clientOptions:{subject:e}}})},"buildAuth"),S=c(async i=>{const e=[];for await(const t of i)e.push(Buffer.from(t));return Buffer.concat(e)},"collectStream"),x=c(i=>{if(i instanceof Uint8Array)return i;if(i instanceof ArrayBuffer)return new Uint8Array(i);if(Buffer.isBuffer(i))return new Uint8Array(i.buffer,i.byteOffset,i.byteLength);if(ArrayBuffer.isView(i)){const e=i;return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}if(typeof i=="string")return new TextEncoder().encode(i);throw new Error("Google Drive: unexpected response payload shape")},"toUint8");class Q extends _{static name="google-drive";checksumTypes=[];meta;authForTokens;driveClient;fileIdCache;publicByDefault;rootFolderId;sharedDriveParams;constructor(e){if(super(e),e.client)this.driveClient=e.client,this.authForTokens=void 0;else{const r=z(e);if(!r)throw new Error("Google Drive storage: missing auth. Pass `client`, `credentials`, `keyFilename`, or `oauth`. Env fallbacks: GOOGLE_DRIVE_CLIENT_EMAIL + GOOGLE_DRIVE_PRIVATE_KEY, or GOOGLE_DRIVE_KEY_FILE.");this.authForTokens=r,this.driveClient=k({auth:r,version:"v3"})}const t=e.driveId??process.env.GOOGLE_DRIVE_ID;this.rootFolderId=e.rootFolderId??process.env.GOOGLE_DRIVE_ROOT_FOLDER_ID??t??"root",this.publicByDefault=e.publicByDefault??!1,this.fileIdCache=new U(e.fileIdCacheSize??B),this.sharedDriveParams={includeItemsFromAllDrives:!0,supportsAllDrives:!0,...t&&{corpora:"drive",driveId:t}},this.meta=e.metaStorage??new L(e.metaStorageConfig),this.isReady=!0}get raw(){return this.driveClient}async create(e){return this.instrumentOperation("create",async()=>{const t=new m(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=I(t),await this.saveMeta(t),await this.onCreate(t),t})}async write(e){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&&A(t,e.size),!G(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");const a=await S(e.body),s=t.name||t.id,o={[v]:t.contentType,[h]:s},n=await this.driveClient.files.create({...this.sharedDriveParams,fields:"id, size, mimeType, md5Checksum, modifiedTime",media:{body:C.from(a),mimeType:t.contentType},requestBody:{appProperties:o,mimeType:t.contentType,name:w(s),parents:[this.rootFolderId]}}),{data:d}=n,l=d.id??void 0;l&&(this.fileIdCache.set(s,l),this.publicByDefault&&await this.driveClient.permissions.create({...this.sharedDriveParams,fileId:l,requestBody:{role:"reader",type:"anyone"}})),t.bytesWritten=a.length,t.size=a.length,t.driveFileId=l,t.mimeType=d.mimeType??t.contentType,t.ETag=d.md5Checksum??void 0}return t.status=I(t),t.status==="completed"&&await this.internalOnComplete(t),await this.saveMeta(t),t}finally{await this.unlock(e.id,r)}})}async delete({id:e}){return this.instrumentOperation("delete",async()=>{let t;const r=e;try{t=await this.getMeta(e)}catch{}try{const a=t?.driveFileId??await this.resolveFileId(r);await this.driveClient.files.delete({...this.sharedDriveParams,fileId:a}),this.fileIdCache.delete(r)}catch(a){if(!M(a))throw a;this.fileIdCache.delete(r)}return t?(t.status="deleted",await this.deleteMeta(t.id),await this.onDelete(t),t):Object.assign(new m({contentType:"application/octet-stream",metadata:{},originalName:e}),{id:e,name:e,status:"deleted"})})}async get({id:e}){return this.instrumentOperation("get",async()=>{let t,r;try{t=await this.checkIfExpired(await this.getMeta(e)),r=t.driveFileId??await this.resolveFileId(t.name??e)}catch{r=await this.resolveFileId(e)}const[a,s]=await Promise.all([this.driveClient.files.get({...this.sharedDriveParams,fields:D,fileId:r}),this.driveClient.files.get({...this.sharedDriveParams,alt:"media",fileId:r},{responseType:"arraybuffer"})]),{data:o}=a,n=x(s.data),d=Buffer.from(n.buffer,n.byteOffset,n.byteLength),l=o.appProperties??{};return{content:d,contentType:t?.contentType??l[v]??o.mimeType??"application/octet-stream",ETag:t?.ETag??o.md5Checksum??void 0,expiredAt:t?.expiredAt,id:e,metadata:t?.metadata??{},modifiedAt:t?.modifiedAt??o.modifiedTime??void 0,name:t?.name??o.name??e,originalName:t?.originalName??o.name??e,size:t?.size??Number(o.size??d.length)}})}async copy(e,t){return this.instrumentOperation("copy",async()=>{const r=await this.resolveFileId(e),a=await this.driveClient.files.copy({...this.sharedDriveParams,fields:"id, size, mimeType, md5Checksum",fileId:r,requestBody:{appProperties:{[h]:t},name:w(t),parents:[this.rootFolderId]}}),s=a.data.id??void 0;s&&this.fileIdCache.set(t,s);const o=new m({contentType:a.data.mimeType??"application/octet-stream",metadata:{},originalName:t});return o.id=t,o.name=t,o.driveFileId=s,o.mimeType=a.data.mimeType??void 0,o.ETag=a.data.md5Checksum??void 0,o.size=Number(a.data.size??0),o})}async move(e,t){return this.instrumentOperation("move",async()=>{const r=await this.copy(e,t);return await this.delete({id:e}),r})}async list(e=1e3){return this.instrumentOperation("list",async()=>{const t=`'${O(this.rootFolderId)}' in parents and trashed=false`,r=(await this.driveClient.files.list({...this.sharedDriveParams,fields:`nextPageToken, files(${D})`,pageSize:e,q:t})).data.files??[],a=[];for(const s of r){const o=s.appProperties??{},n=o[h];if(!n)continue;s.id&&this.fileIdCache.set(n,s.id);const d=new m({contentType:o[v]??s.mimeType??"application/octet-stream",metadata:{},originalName:s.name??n});d.id=n,d.name=n,d.driveFileId=s.id??void 0,d.mimeType=s.mimeType??void 0,d.size=Number(s.size??0),d.modifiedAt=s.modifiedTime??void 0,d.ETag=s.md5Checksum??void 0,a.push(d)}return a},{limit:e})}async getReadUrl(e,t){return t?.responseContentDisposition?y(p.METHOD_NOT_ALLOWED,"Google Drive: `responseContentDisposition` is not supported — Drive's webContentLink has no Content-Disposition override."):this.publicByDefault?`https://drive.google.com/uc?export=download&id=${await this.resolveFileId(e)}`:y(p.METHOD_NOT_ALLOWED,"Google Drive: getReadUrl() requires the adapter to be constructed with `publicByDefault: true`. Drive has no signed URL primitive — use get() for private files.")}async getUploadUrl(e,t){if(!this.authForTokens)return y(p.METHOD_NOT_ALLOWED,"Google Drive: getUploadUrl() requires `credentials`, `keyFilename`, or `oauth` — not the pre-built `client` escape hatch.");const r=await this.authForTokens.getAccessToken(),a=typeof r=="string"?r:r?.token;if(!a)throw new Error("Google Drive: failed to mint access token for resumable upload session");const s={Authorization:`Bearer ${a}`,"Content-Type":"application/json; charset=UTF-8"};t?.contentType&&(s["X-Upload-Content-Type"]=t.contentType),t?.contentLength!==void 0&&(s["X-Upload-Content-Length"]=String(t.contentLength));const o={appProperties:{[h]:e},name:w(e),parents:[this.rootFolderId]},n=await fetch("https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&supportsAllDrives=true",{body:JSON.stringify(o),headers:s,method:"POST"});if(!n.ok){const l=await n.text().catch(()=>"");throw E(new Error(`${n.statusText} ${l}`.trim()||n.statusText),{adapter:"Google Drive",operation:"resumable upload session",status:n.status})}const d=n.headers.get("location")??n.headers.get("Location");if(!d)throw E(new Error("response missing Location header"),{adapter:"Google Drive",code:p.STORAGE_ERROR,operation:"resumable upload session"});return d}async resolveFileId(e){const t=this.fileIdCache.get(e);if(t)return t;const r=`appProperties has { key='${h}' and value='${O(e)}' } and trashed=false`,a=(await this.driveClient.files.list({...this.sharedDriveParams,fields:"files(id)",pageSize:2,q:r})).data.files??[];if(a.length===0)throw new Error(`Google Drive: not found: ${e}`);if(a.length>1)throw new Error(`Google Drive: multiple files share virtual key '${e}'. Resolve via storage.raw.`);const s=a[0]?.id;if(!s)throw new Error(`Google Drive: list returned no fileId for ${e}`);return this.fileIdCache.set(e,s),s}internalOnComplete=c(e=>this.deleteMeta(e.id),"internalOnComplete")}const M=c(i=>{if(i===null||typeof i!="object")return!1;const e=i;return typeof e.code=="number"&&e.code===404||typeof e.status=="number"&&e.status===404?!0:typeof e.response?.status=="number"&&e.response.status===404},"isNotFoundError");export{Q as default};
@@ -1 +0,0 @@
1
- var a=Object.defineProperty;var r=(t,e)=>a(t,"name",{value:e,configurable:!0});import{v as o}from"./local-meta-storage-CT1audnK.js";var s=Object.defineProperty,l=r((t,e)=>s(t,"name",{value:e,configurable:!0}),"a");class u extends o{static{r(this,"l")}static{l(this,"NetlifyBlobMetaStorage")}constructor(e){super(e)}}export{u as default};
@@ -1 +0,0 @@
1
- var p=Object.defineProperty;var h=(o,e)=>p(o,"name",{value:e,configurable:!0});import{getStore as d}from"@netlify/blobs";import{a as w}from"./detect-file-type-5JhzC9RU.js";import{B as b,t as f,u as g}from"./storage-CoyB2O-Y.js";import{createRetryWrapper as E}from"./isRetryableError-B6ZS_-5I.js";import{v as N}from"./local-meta-storage-CT1audnK.js";import m from"./NetlifyBlobFile-PMZLJ8AC.js";import{o as u,r as O}from"./part-match-B5fLLmFw.js";import{u as T}from"./update-size-DANV7aa2.js";import{o as B}from"./has-content-Bx2p8Okx.js";var k=Object.defineProperty,y=h((o,e)=>k(o,"name",{value:e,configurable:!0}),"f");class z extends b{static name="netlify-blob";checksumTypes=["md5"];get raw(){return this.store}meta;storeName;siteID;token;store;retry;constructor(e){super(e),this.storeName=e.storeName||"default",this.siteID=e.siteID||process.env.NETLIFY_SITE_ID,this.token=e.token||process.env.NETLIFY_TOKEN,this.store=d({name:this.storeName,...this.siteID&&{siteID:this.siteID},...this.token&&{token:this.token}});const t={backoffMultiplier:2,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:y(s=>{if(s instanceof Error){const n=s.code;if(n==="ECONNRESET"||n==="ETIMEDOUT"||n==="ENOTFOUND"||n==="ECONNREFUSED")return!0}const i=s;return!!(i.status&&[408,429,500,502,503,504].includes(i.status))},"shouldRetry"),...e.retryConfig};this.retry=E(t);const{metaStorage:a,metaStorageConfig:r}=e;this.meta=a||new N(r),this.isReady=!0}async create(e){return this.instrumentOperation("create",async()=>{const t={...e};if(e.ttl){const r=typeof e.ttl=="string"?f(e.ttl):e.ttl;t.expiredAt=r===void 0?void 0:Date.now()+r}const a=new m(t);a.name=this.namingFunction(a),await this.validate(a);try{const r=await this.getMeta(a.id);if(r.bytesWritten>=0)return r}catch{}return a.bytesWritten=0,a.status=u(a),await this.saveMeta(a),await this.onCreate(a),a})}async write(e){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&&T(t,e.size),!O(e,t))throw new Error("File part does not match");const a=await this.lock(e.id);try{if(B(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const r=[],s=e.body;for await(const n of s)r.push(Buffer.from(n));const i=Buffer.concat(r);if((t.bytesWritten===0||Number.isNaN(t.bytesWritten))&&(!t.contentType||t.contentType==="application/octet-stream"))try{const n=await w(i);n?.mime&&(t.contentType=n.mime)}catch{}await this.retry(()=>this.store.set(t.name,i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),{metadata:{...t.metadata,contentType:t.contentType}})),t.pathname=t.name,t.url=this.getBlobUrl(t.name),t.bytesWritten=i.length}return t.status=u(t),t.status==="completed"&&await this.internalOnComplete(t),await this.saveMeta(t),t}finally{await this.unlock(e.id,a)}})}async delete({id:e}){return this.instrumentOperation("delete",async()=>{const t=await this.getMeta(e);if(!t.pathname)throw new Error(`File ${e} does not have a valid pathname`);t.status="deleted";try{await this.retry(()=>this.store.delete(t.pathname))}catch(r){this.logger?.error("Failed to delete blob from Netlify Blob:",r);const s=this.normalizeError(r instanceof Error?r:new Error(String(r)));await this.onError(s)}await this.deleteMeta(t.id);const a={...t};return await this.onDelete(a),a})}async exists({id:e}){return this.instrumentOperation("exists",async()=>{try{const t=await this.getMeta(e);return!t.pathname||t.pathname.length<=0?!1:await this.retry(()=>this.store.get(t.pathname,{type:"blob"}))!=null}catch{return!1}})}async get({id:e}){return this.instrumentOperation("get",async()=>{const t=await this.checkIfExpired(await this.getMeta(e));if(!t.pathname||t.pathname.length<=0)throw new Error("File pathname not found");const a=await this.retry(()=>this.store.get(t.pathname,{type:"blob"}));if(!a)throw new Error("File not found in Netlify Blob");let r;if(typeof a=="string")r=Buffer.from(a,"utf8").buffer;else if(a&&typeof a=="object"&&"arrayBuffer"in a&&typeof a.arrayBuffer=="function")r=await this.retry(()=>a.arrayBuffer());else throw new Error("Invalid blob type returned from Netlify Blob");const s=Buffer.from(r);let i=null;try{i=await this.store.getMetadata?.(t.pathname)??null}catch{}return{content:s,contentType:i?.contentType||t.contentType,ETag:t.ETag,expiredAt:t.expiredAt,id:e,metadata:{...t.metadata,...i?.metadata},modifiedAt:t.modifiedAt,name:t.name,originalName:t.originalName,size:t.size||s.length}})}async copy(e,t){return this.instrumentOperation("copy",async()=>{const a=await this.getMeta(e);if(!a.pathname)throw new Error("Source file pathname not found");const r=await this.retry(()=>this.store.get(a.pathname,{type:"blob"}));if(!r)throw new Error("Source file not found in Netlify Blob");let s=null;try{const l=this.store;l.getMetadata&&a.pathname&&(s=await l.getMetadata(a.pathname))}catch{}let i;if(typeof r=="string")i=Buffer.from(r,"utf8").buffer;else if(r&&typeof r=="object"&&"arrayBuffer"in r){const l=r;i=await this.retry(()=>l.arrayBuffer())}else throw new Error("Invalid blob type returned from Netlify Blob");const n=Buffer.from(i);await this.retry(()=>this.store.set(t,n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),{metadata:s||{contentType:a.contentType,...a.metadata}}));const c={...a,id:t,name:t,pathname:t,url:this.getBlobUrl(t)};return await this.saveMeta(c),c})}async move(e,t){return this.instrumentOperation("move",async()=>{const a=await this.copy(e,t);return await this.delete({id:e}),a})}async update({id:e},t){return this.instrumentOperation("update",async()=>{const a=await this.getMeta(e),r={...t};if("ttl"in r&&r.ttl!==void 0){const i=r.ttl,n=typeof i=="string"?f(i):i;n!==void 0&&(r.expiredAt=Date.now()+n),delete r.ttl}g(a,r),await this.saveMeta(a);const s={...a,status:"updated"};return await this.onUpdate(s),s})}async list(e=1e3){return this.instrumentOperation("list",async()=>{const t=await this.retry(()=>this.store.list()),a=[];for await(const r of t.blobs){let s=null;try{s=await this.store.getMetadata?.(r.key)??null}catch{}const i=new m({contentType:s?.contentType||"application/octet-stream",metadata:s?.metadata||{},originalName:r.key}),n=r;if(i.createdAt=n.createdAt?.toISOString(),i.id=r.key,i.modifiedAt=n.updatedAt?.toISOString(),i.name=r.key,i.pathname=r.key,i.size=n.size,i.url=this.getBlobUrl(r.key),a.push(i),a.length>=e)break}return a},{limit:e})}internalOnComplete=y(e=>this.deleteMeta(e.id),"internalOnComplete");getBlobUrl(e){return`/api/blobs/${this.storeName}/${e}`}}export{z as default};
@@ -1 +0,0 @@
1
- var a=Object.defineProperty;var t=(r,e)=>a(r,"name",{value:e,configurable:!0});import{v as o}from"./local-meta-storage-CT1audnK.js";var s=Object.defineProperty,i=t((r,e)=>s(r,"name",{value:e,configurable:!0}),"t");class u extends o{static{t(this,"i")}static{i(this,"OneDriveMetaStorage")}constructor(e){super(e)}}export{u as default};
@@ -1 +0,0 @@
1
- var D=Object.defineProperty;var y=(i,t)=>D(i,"name",{value:t,configurable:!0});import{ResponseType as T,Client as k,GraphError as A}from"@microsoft/microsoft-graph-client";import{wrapStorageError as p,ERRORS as u,throwErrorCode as b}from"./ERRORS-CyOuSMLY.js";import{c as O}from"./oauth-refresh-Dg2ybc6_.js";import{B as N}from"./storage-CoyB2O-Y.js";import f from"./OneDriveFile-XbVVKIJh.js";import U from"./OneDriveMetaStorage-B_BkGLzW.js";import{o as g,r as _}from"./part-match-B5fLLmFw.js";import{u as S}from"./update-size-DANV7aa2.js";import{o as $}from"./has-content-Bx2p8Okx.js";var L=Object.defineProperty,c=y((i,t)=>L(i,"name",{value:t,configurable:!0}),"c");const P="https://graph.microsoft.com/.default",M=250*1024*1024,B=16*320*1024,F=1e3,m=c(i=>{let t=0,e=i.length;for(;t<e&&i[t]==="/";)t+=1;for(;e>t&&i[e-1]==="/";)e-=1;return t===0&&e===i.length?i:i.slice(t,e)},"trimSlashes"),w=c(i=>i.split("/").map(t=>encodeURIComponent(t)).join("/"),"encodePathSegments"),x=c(async i=>{const t=[];for await(const e of i)t.push(Buffer.from(e));return Buffer.concat(t)},"collectStream"),E=c(i=>({getAccessToken:c(()=>Promise.resolve(i),"getAccessToken")}),"createStaticAccessTokenAuth"),V=c(i=>({getAccessToken:c(async()=>i(),"ensure")}),"createCallableAccessTokenAuth"),I=c(i=>O({buildBody:c(()=>new URLSearchParams({client_id:i.clientId,client_secret:i.clientSecret,grant_type:"client_credentials",scope:P}),"buildBody"),provider:"OneDrive",tokenUrl:`https://login.microsoftonline.com/${encodeURIComponent(i.tenantId)}/oauth2/v2.0/token`}),"createClientCredentialsAuth"),v=c(i=>O({buildBody:c(()=>new URLSearchParams({client_id:i.clientId,grant_type:"refresh_token",refresh_token:i.refreshToken,scope:P,...i.clientSecret&&{client_secret:i.clientSecret}}),"buildBody"),provider:"OneDrive",tokenUrl:`https://login.microsoftonline.com/${encodeURIComponent(i.tenantId??"common")}/oauth2/v2.0/token`}),"createRefreshTokenAuth"),j=c(i=>({getAccessToken:c(()=>i.getAccessToken(),"getAccessToken")}),"makeAuthProvider"),z=c(i=>{if(i.client)return i.client;const t=i.accessToken!==void 0,e=i.clientCredentials!==void 0,o=i.oauth!==void 0;if([t,e,o].filter(Boolean).length>1)throw new Error("OneDrive storage: pass exactly one of `accessToken`, `clientCredentials`, or `oauth`.");let a;if(i.accessToken!==void 0?a=typeof i.accessToken=="function"?V(i.accessToken):E(i.accessToken):i.clientCredentials?a=I(i.clientCredentials):i.oauth&&(a=v({clientId:i.oauth.clientId,refreshToken:i.oauth.refreshToken,...i.oauth.clientSecret&&{clientSecret:i.oauth.clientSecret},...i.oauth.tenantId&&{tenantId:i.oauth.tenantId}})),!a){const r=process.env.ONEDRIVE_ACCESS_TOKEN;if(r)a=E(r);else{const n=process.env.ONEDRIVE_CLIENT_ID,s=process.env.ONEDRIVE_CLIENT_SECRET,l=process.env.ONEDRIVE_TENANT_ID,h=process.env.ONEDRIVE_REFRESH_TOKEN;h&&n?a=v({clientId:n,refreshToken:h,...s&&{clientSecret:s},...l&&{tenantId:l}}):n&&s&&l&&(a=I({clientId:n,clientSecret:s,tenantId:l}))}}if(!a)throw new Error("OneDrive storage: missing auth. Pass `client`, `accessToken`, `clientCredentials`, or `oauth`. Env fallbacks: ONEDRIVE_ACCESS_TOKEN; or ONEDRIVE_REFRESH_TOKEN + ONEDRIVE_CLIENT_ID (+ optional ONEDRIVE_CLIENT_SECRET, ONEDRIVE_TENANT_ID); or ONEDRIVE_CLIENT_ID + ONEDRIVE_CLIENT_SECRET + ONEDRIVE_TENANT_ID.");return k.initWithMiddleware({authProvider:j(a)})},"resolveAuth"),G=c(i=>{if(i instanceof A)return i.statusCode===404||i.code==="itemNotFound";if(i&&typeof i=="object"){const t=i;return t.statusCode===404||t.status===404||t.code==="itemNotFound"}return!1},"isNotFoundError");class te extends N{static name="onedrive";checksumTypes=[];meta;basePath;client;copyTimeoutMs;publicByDefault;rootFolderPath;constructor(t){if(super(t),[t.driveId,t.siteId,t.userId].filter(e=>e!==void 0).length>1)throw new Error("OneDrive storage: pass at most one of `driveId`, `siteId`, or `userId`.");if(t.driveId)this.basePath=`/drives/${encodeURIComponent(t.driveId)}`;else if(t.siteId)this.basePath=`/sites/${encodeURIComponent(t.siteId)}/drive`;else if(t.userId)this.basePath=`/users/${encodeURIComponent(t.userId)}/drive`;else{if(t.clientCredentials)throw new Error("OneDrive storage: `clientCredentials` (app-only) auth requires `driveId`, `siteId`, or `userId`.");this.basePath="/me/drive"}this.rootFolderPath=m(t.rootFolderPath??""),this.publicByDefault=t.publicByDefault??!1,this.copyTimeoutMs=t.copyTimeoutMs??6e4,this.client=z(t),this.meta=t.metaStorage??new U(t.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(t){return this.instrumentOperation("create",async()=>{const e=new f(t);e.name=this.namingFunction(e),await this.validate(e);try{const o=await this.getMeta(e.id);if(o.bytesWritten>=0)return o}catch{}return e.bytesWritten=0,e.status=g(e),await this.saveMeta(e),await this.onCreate(e),e})}async write(t){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&&S(e,t.size),!_(t,e))throw new Error("File part does not match");const o=await this.lock(t.id);try{if($(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const a=await x(t.body),r=e.name||e.id,n=a.byteLength<=M?await this.uploadSimple(r,a,e.contentType):await this.uploadSession(r,a,e.contentType);e.bytesWritten=a.length,e.size=a.length,e.driveItemId=n.id,e.webUrl=n.webUrl,e.eTag=n.eTag,e.ETag=n.eTag}return e.status=g(e),e.status==="completed"&&await this.internalOnComplete(e),await this.saveMeta(e),e}finally{await this.unlock(t.id,o)}})}async delete({id:t}){return this.instrumentOperation("delete",async()=>{let e;try{e=await this.getMeta(t)}catch{}const o=e?.name??t;try{await this.client.api(this.itemApiPath(o)).delete()}catch(a){if(!G(a))throw a}return e?(e.status="deleted",await this.deleteMeta(e.id),await this.onDelete(e),e):Object.assign(new f({contentType:"application/octet-stream",metadata:{},originalName:t}),{id:t,name:t,status:"deleted"})})}async get({id:t}){return this.instrumentOperation("get",async()=>{let e,o=t;try{e=await this.checkIfExpired(await this.getMeta(t)),o=e.name??t}catch{}const a=await this.client.api(this.itemApiPath(o)).get(),r=await this.client.api(this.itemActionPath(o,"content")).responseType(T.ARRAYBUFFER).get(),n=Buffer.from(r);return{content:n,contentType:e?.contentType??a.file?.mimeType??"application/octet-stream",ETag:e?.ETag??a.eTag,expiredAt:e?.expiredAt,id:t,metadata:e?.metadata??{},modifiedAt:e?.modifiedAt??a.lastModifiedDateTime,name:e?.name??a.name,originalName:e?.originalName??a.name,size:e?.size??a.size??n.length}})}async copy(t,e){return this.instrumentOperation("copy",async()=>{const o=this.parentReferencePath(e),a={name:R(e),parentReference:{path:o}},r=await this.client.api(this.itemActionPath(t,"copy")).responseType(T.RAW).post(a);if(r.status!==202){const h=await r.text().catch(()=>"");throw p(new Error(h||r.statusText),{adapter:"OneDrive",operation:"copy",status:r.status})}const n=r.headers.get("Location");if(!n)throw p(new Error("response missing Location monitor URL"),{adapter:"OneDrive",code:u.STORAGE_ERROR,operation:"copy"});const s=await this.pollCopyMonitor(n),l=new f({contentType:"application/octet-stream",metadata:{},originalName:e});return l.id=e,l.name=e,l.driveItemId=s,l})}async move(t,e){return this.instrumentOperation("move",async()=>{const o=this.parentReferencePath(e),a=R(e),r=await this.client.api(this.itemApiPath(t)).patch({name:a,parentReference:{path:o}}),n=new f({contentType:"application/octet-stream",metadata:{},originalName:e});n.id=e,n.name=e,n.driveItemId=r.id,n.webUrl=r.webUrl,n.eTag=r.eTag,n.ETag=r.eTag;try{await this.deleteMeta(t)}catch{}return n})}async list(t=1e3){return this.instrumentOperation("list",async()=>{const e=[];let o=`${this.folderListChildrenPath()}?$top=${Math.min(t,1e3)}`;for(;o&&e.length<t;){const a=await this.client.api(o).get();for(const r of a.value){if(!r.file)continue;const n=this.itemPathToKey(r);if(!n)continue;const s=new f({contentType:r.file.mimeType??"application/octet-stream",metadata:{},originalName:r.name});if(s.id=n,s.name=n,s.driveItemId=r.id,s.webUrl=r.webUrl,s.eTag=r.eTag,s.ETag=r.eTag,s.size=r.size??0,s.modifiedAt=r.lastModifiedDateTime,e.push(s),e.length>=t)break}o=a["@odata.nextLink"]??null}return e},{limit:t})}async getReadUrl(t,e){if(e?.responseContentDisposition||e?.responseContentType)return b(u.METHOD_NOT_ALLOWED,"OneDrive: `responseContentDisposition` / `responseContentType` are not supported — Graph download URLs have no overrides.");if(this.publicByDefault){const a=(await this.client.api(this.itemActionPath(t,"createLink")).post({scope:"anonymous",type:"view"})).link?.webUrl;if(!a)throw new Error("OneDrive: createLink response missing webUrl");return a}const o=(await this.client.api(this.itemApiPath(t)).select("@microsoft.graph.downloadUrl").get())["@microsoft.graph.downloadUrl"];if(!o)throw new Error("OneDrive: item has no `@microsoft.graph.downloadUrl` — it may be a folder or have no content.");return o}async getUploadUrl(t,e){const o=await this.client.api(this.itemActionPath(t,"createUploadSession")).post({item:{"@microsoft.graph.conflictBehavior":"replace",...e?.contentType&&{file:{mimeType:e.contentType}}}});if(!o.uploadUrl)throw p(new Error("createUploadSession response missing uploadUrl"),{adapter:"OneDrive",code:u.STORAGE_ERROR,operation:"getUploadUrl"});return o.uploadUrl}keyParts(t){const e=m(t),o=[];return this.rootFolderPath&&o.push(this.rootFolderPath),e&&o.push(e),o}itemApiPath(t){const e=this.keyParts(t);return e.length===0?`${this.basePath}/root`:`${this.basePath}/root:/${w(e.join("/"))}`}itemActionPath(t,e){const o=this.keyParts(t);return o.length===0?`${this.basePath}/root/${e}`:`${this.basePath}/root:/${w(o.join("/"))}:/${e}`}folderListChildrenPath(){return this.itemActionPath("","children")}parentReferencePath(t){const e=m(t),o=[];this.rootFolderPath&&o.push(this.rootFolderPath);const a=e.lastIndexOf("/");if(a!==-1){const r=e.slice(0,a);r&&o.push(r)}return o.length===0?"/drive/root:":`/drive/root:/${w(o.join("/"))}`}itemPathToKey(t){const e=t.parentReference?.path??"",o="/root:",a=e.indexOf(o);let r=a===-1?"":e.slice(a+o.length);r=m(decodeURIComponent(r));const n=this.rootFolderPath&&r.startsWith(this.rootFolderPath)?r.slice(this.rootFolderPath.length):r,s=m(n);return s?`${s}/${t.name}`:t.name}async uploadSimple(t,e,o){return await this.client.api(`${this.itemActionPath(t,"content")}?@microsoft.graph.conflictBehavior=replace`).header("Content-Type",o??"application/octet-stream").put(e)}async uploadSession(t,e,o){const a=await this.client.api(this.itemActionPath(t,"createUploadSession")).post({item:{"@microsoft.graph.conflictBehavior":"replace",...o&&{file:{mimeType:o}}}}),r=e.byteLength;let n=0,s;for(;n<r;){const l=Math.min(n+B,r),h=e.subarray(n,l),d=await fetch(a.uploadUrl,{body:new Uint8Array(h),headers:{"Content-Length":String(h.byteLength),"Content-Range":`bytes ${n}-${l-1}/${r}`},method:"PUT"});if(d.status===200||d.status===201)s=await d.json();else if(d.status!==202){const C=await d.text().catch(()=>"");throw p(new Error(C||d.statusText),{adapter:"OneDrive",operation:"upload-session chunk",status:d.status})}n=l}if(!s)throw p(new Error("upload-session terminated without a final DriveItem response"),{adapter:"OneDrive",code:u.STORAGE_ERROR,operation:"write"});return s}async pollCopyMonitor(t){const e=Date.now()+this.copyTimeoutMs;for(;;){const o=await fetch(t);if(!o.ok)throw p(new Error(o.statusText),{adapter:"OneDrive",operation:"copy monitor",status:o.status});const a=await o.json();if(a.status==="completed")return a.resourceId;if(a.status==="failed")throw p(new Error(a.error?.message??"unknown error"),{adapter:"OneDrive",code:u.STORAGE_ERROR,operation:"copy"});if(Date.now()>=e)throw new Error(`OneDrive: copy timed out after ${this.copyTimeoutMs}ms (status: ${a.status??"unknown"})`);await new Promise(r=>{setTimeout(r,F)})}}internalOnComplete=c(t=>this.deleteMeta(t.id),"internalOnComplete")}const R=c(i=>{const t=m(i),e=t.lastIndexOf("/");return e===-1?t:t.slice(e+1)},"baseName");export{te as default};
@@ -1 +0,0 @@
1
- var h=Object.defineProperty;var p=(r,e)=>h(r,"name",{value:e,configurable:!0});import{CreateMultipartUploadCommand as f,UploadPartCommand as g,CompleteMultipartUploadCommand as w,AbortMultipartUploadCommand as k,ListPartsCommand as b,GetObjectCommand as C,HeadObjectCommand as B,DeleteObjectCommand as T,CopyObjectCommand as S,ListObjectsV2Command as E,waitUntilBucketExists as U,S3Client as x,PutObjectCommand as K}from"@aws-sdk/client-s3";import{fromIni as L}from"@aws-sdk/credential-providers";import{getSignedUrl as l}from"@aws-sdk/s3-request-presigner";import{S as I}from"./s3-base-storage-f_EyFAAt.js";import{Readable as u}from"node:stream";import{ReadableStream as y}from"node:stream/web";import M from"./S3File-BfmCOET4.js";import P from"./S3MetaStorage-vcriiosn.js";var A=Object.defineProperty,O=p((r,e)=>A(r,"name",{value:e,configurable:!0}),"s");class j{static{p(this,"T")}constructor(e,t){this.client=e}client;static{O(this,"S3ClientAdapter")}async createMultipartUpload(e){const t=new f({ACL:e.ACL,Bucket:e.Bucket,ContentType:e.ContentType,Key:e.Key,Metadata:e.Metadata}),n=await this.client.send(t);if(!n.UploadId)throw new Error("Failed to create multipart upload");return{UploadId:n.UploadId}}async uploadPart(e){const t=e.Body instanceof y?u.fromWeb(e.Body):e.Body,n=new g({Body:t,Bucket:e.Bucket,ContentLength:e.ContentLength,ContentMD5:e.ContentMD5,Key:e.Key,PartNumber:e.PartNumber,UploadId:e.UploadId}),a=await this.client.send(n);if(!a.ETag)throw new Error("Failed to upload part");return{ETag:a.ETag}}async completeMultipartUpload(e){const t=new w({Bucket:e.Bucket,Key:e.Key,MultipartUpload:{Parts:e.Parts.map(({ETag:a,PartNumber:o})=>({ETag:a,PartNumber:o}))},UploadId:e.UploadId}),n=await this.client.send(t);if(!n.Location)throw new Error("Failed to complete multipart upload");return{ETag:n.ETag,Location:n.Location}}async abortMultipartUpload(e){const t=new k({Bucket:e.Bucket,Key:e.Key,UploadId:e.UploadId});await this.client.send(t)}async listParts(e){const t=new b({Bucket:e.Bucket,Key:e.Key,UploadId:e.UploadId}),n=await this.client.send(t),a=[];if(n.Parts)for(const o of n.Parts)o.ETag&&o.PartNumber&&a.push({ETag:o.ETag,PartNumber:o.PartNumber,Size:o.Size});return{Parts:a.length>0?a:void 0}}async getObject(e){const t=new C({Bucket:e.Bucket,Key:e.Key}),n=await this.client.send(t);let a;if(n.Body){const o=n.Body;o instanceof u||typeof o=="object"&&"transform"in o&&o instanceof y?a=o:a=u.from(o)}return{Body:a,ContentLength:n.ContentLength,ContentType:n.ContentType,ETag:n.ETag,Expires:n.Expires,LastModified:n.LastModified,Metadata:n.Metadata}}async headObject(e){const t=new B({Bucket:e.Bucket,Key:e.Key}),n=await this.client.send(t);return{ContentLength:n.ContentLength,ContentType:n.ContentType,ETag:n.ETag,Expires:n.Expires,LastModified:n.LastModified}}async deleteObject(e){const t=new T({Bucket:e.Bucket,Key:e.Key});await this.client.send(t)}async copyObject(e){const t={Bucket:e.Bucket,CopySource:e.CopySource,Key:e.Key};e.StorageClass&&(t.StorageClass=e.StorageClass);const n=new S(t);await this.client.send(n)}async listObjectsV2(e){const t=new E({Bucket:e.Bucket,ContinuationToken:e.ContinuationToken,MaxKeys:e.MaxKeys}),n=await this.client.send(t);return{Contents:n.Contents?.map(a=>({Key:a.Key,LastModified:a.LastModified})),IsTruncated:n.IsTruncated,NextContinuationToken:n.NextContinuationToken}}async getPresignedUrl(e){const t=new g({Bucket:e.Bucket,Key:e.Key,PartNumber:e.PartNumber,UploadId:e.UploadId});return l(this.client,t,{expiresIn:e.expiresIn})}async checkBucketAccess(e){await U({client:this.client,maxWaitTime:30},{Bucket:e.Bucket})}}var v=Object.defineProperty,N=p((r,e)=>v(r,"name",{value:e,configurable:!0}),"c");class H extends I{static name="s3";s3Api;rawClient;constructor(e){const{bucket:t=process.env.S3_BUCKET,region:n=process.env.S3_REGION}=e;if(!t)throw new Error("S3 bucket is not defined");if(!n)throw new Error("S3 region is not defined");e.region=n;const a=e.keyFile||process.env.S3_KEYFILE;a&&(e.credentials=L({configFilepath:a}));const o=new x(e);super({bucket:t,clientDirectUpload:e.clientDirectUpload,expiration:e.expiration?.maxAge?{maxAge:String(e.expiration.maxAge)}:void 0,filename:e.filename,logger:e.logger,metaStorage:e.metaStorage,metaStorageConfig:e.metaStorageConfig?{...e.metaStorageConfig,...e}:{...e},partSize:e.partSize,retryConfig:{...e.retryConfig,shouldRetry:N(i=>{const d=i;if(d.$metadata){const m=d.$metadata.httpStatusCode;if(m&&[408,429,500,502,503,504].includes(m)||d.$fault==="server")return!0}return d.retryable??!1},"shouldRetry")}}),this.s3Api=new j(o,t),this.rawClient=o;const{metaStorage:c,metaStorageConfig:s}=e;if(!c){const i={...e,...s,logger:this.logger};"directory"in i||(this.meta=new P(i))}this.config.clientDirectUpload&&(this.onCreate=async()=>{})}normalizeError(e){return e.$metadata?{code:e.Code||e.name,message:e.message,name:e.name,statusCode:e.$metadata.httpStatusCode||500}:super.normalizeError(e)}async update({id:e},t){if(this.config.clientDirectUpload){const n=await this.getMeta(e);return this.buildPresigned({...n,...t})}return super.update({id:e},t)}async getStream({id:e}){return this.instrumentOperation("getStream",async()=>{const t=this.getS3Api(),{Body:n,ContentLength:a,ContentType:o,ETag:c,Expires:s,LastModified:i}=await this.retry(()=>t.getObject({Bucket:this.bucket,Key:e}));return await this.checkIfExpired({expiredAt:s}),{headers:{"Content-Length":a?.toString()??"0","Content-Type":o,...c&&{ETag:c},...s&&{"X-Upload-Expires":s.toString()},...i&&{"Last-Modified":i.toString()}},size:Number(a),stream:n}})}get raw(){return this.rawClient}async getReadUrl(e,t){const n=new C({Bucket:this.bucket,Key:e,...t?.responseContentDisposition&&{ResponseContentDisposition:t.responseContentDisposition},...t?.responseContentType&&{ResponseContentType:t.responseContentType}});return l(this.rawClient,n,{expiresIn:t?.expiresIn??3600})}async getUploadUrl(e,t){const n=new K({Bucket:this.bucket,Key:e,...t?.contentType&&{ContentType:t.contentType},...t?.contentLength!==void 0&&{ContentLength:t.contentLength}});return l(this.rawClient,n,{expiresIn:t?.expiresIn??3600})}getS3Api(){return this.s3Api}getFileClass(){return M}getAcl(){return this.config.acl}async accessCheck(e=30){await this.s3Api.checkBucketAccess({Bucket:this.bucket})}}export{H as default};
@@ -1 +0,0 @@
1
- var r=Object.defineProperty;var a=(t,e)=>r(t,"name",{value:e,configurable:!0});import{v as o}from"./local-meta-storage-CT1audnK.js";var s=Object.defineProperty,u=a((t,e)=>s(t,"name",{value:e,configurable:!0}),"t");class i extends o{static{a(this,"p")}static{u(this,"SupabaseMetaStorage")}constructor(e){super(e)}}export{i as default};