@visulima/storage 1.0.0-alpha.33 → 1.0.0-alpha.34

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 (144) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/adapter/nuxt/module.d.ts +4 -4
  3. package/dist/ai/ai-sdk/index.d.ts +5 -5
  4. package/dist/ai/claude/index.d.ts +4 -4
  5. package/dist/ai/openai/index.d.ts +5 -5
  6. package/dist/ai/tanstack/index.d.ts +4 -4
  7. package/dist/handler/http/fetch/index.d.ts +7 -7
  8. package/dist/handler/http/fetch/index.js +1 -1
  9. package/dist/handler/http/hono/index.d.ts +4 -4
  10. package/dist/handler/http/hono/index.js +1 -1
  11. package/dist/handler/http/nextjs/index.d.ts +4 -4
  12. package/dist/handler/http/nextjs/index.js +1 -1
  13. package/dist/handler/http/node/index.d.ts +7 -7
  14. package/dist/handler/http/node/index.js +1 -1
  15. package/dist/handler/http/solid-start/index.d.ts +4 -4
  16. package/dist/handler/http/solid-start/index.js +1 -1
  17. package/dist/index.d.ts +6 -6
  18. package/dist/index.js +1 -1
  19. package/dist/packem_shared/{AwsLightStorage-6Z1ovz9R.js → AwsLightStorage-CWBRVcn5.js} +1 -1
  20. package/dist/packem_shared/{AzureStorage-CbAN4vPm.js → AzureStorage-nhAojuEU.js} +1 -1
  21. package/dist/packem_shared/{BoxMetaStorage-BGBPZWoL.js → BoxMetaStorage-XMZn5yvp.js} +1 -1
  22. package/dist/packem_shared/{BoxStorage-DitlyKVB.js → BoxStorage-C3--16du.js} +1 -1
  23. package/dist/packem_shared/{BunS3MetaStorage-DAskpG_G.js → BunS3MetaStorage-DomG8mVK.js} +1 -1
  24. package/dist/packem_shared/{BunS3Storage-D1gxh5Tt.js → BunS3Storage-0oYNi2Os.js} +1 -1
  25. package/dist/packem_shared/{BunnyMetaStorage-ByUvvuPc.js → BunnyMetaStorage-luemw1pL.js} +1 -1
  26. package/dist/packem_shared/{BunnyStorage-r6DptjUt.js → BunnyStorage-CIkpp1Rc.js} +1 -1
  27. package/dist/packem_shared/{CloudinaryMetaStorage-DsJyN0iQ.js → CloudinaryMetaStorage-DpxjshXZ.js} +1 -1
  28. package/dist/packem_shared/{CloudinaryStorage-BR8CZhlL.js → CloudinaryStorage-9Y1Gq0gr.js} +1 -1
  29. package/dist/packem_shared/DiskStorage-BkP8c0MY.js +1 -0
  30. package/dist/packem_shared/{DiskStorageWithChecksum--U7zOz-0.js → DiskStorageWithChecksum-CUXj5mE9.js} +1 -1
  31. package/dist/packem_shared/{DropboxMetaStorage-B7eY16fU.js → DropboxMetaStorage-h0eTJuk5.js} +1 -1
  32. package/dist/packem_shared/{DropboxStorage-9-jj7H8C.js → DropboxStorage-CuA9MkpH.js} +1 -1
  33. package/dist/packem_shared/{FirebaseMetaStorage-BpYykWhG.js → FirebaseMetaStorage-CCBnEE8_.js} +1 -1
  34. package/dist/packem_shared/{FirebaseStorage-DB87abIF.js → FirebaseStorage-DUskfjh_.js} +1 -1
  35. package/dist/packem_shared/{FtpMetaStorage-v2wXTwqX.js → FtpMetaStorage-DxHcXk9x.js} +1 -1
  36. package/dist/packem_shared/{FtpStorage-DdRf0Wg6.js → FtpStorage-DMpDY7oG.js} +1 -1
  37. package/dist/packem_shared/{GCSMetaStorage-BMtou9o7.js → GCSMetaStorage-DCBR02C7.js} +1 -1
  38. package/dist/packem_shared/{GCStorage-CRVpuZ5_.js → GCStorage-RCw58CoD.js} +1 -1
  39. package/dist/packem_shared/{GoogleDriveMetaStorage-BT9N1Wji.js → GoogleDriveMetaStorage-koEiYfFw.js} +1 -1
  40. package/dist/packem_shared/{GoogleDriveStorage-BzuSZZzN.js → GoogleDriveStorage-DNlVE5Uo.js} +1 -1
  41. package/dist/packem_shared/{LocalMetaStorage-BFQz8VPm.js → LocalMetaStorage-BKC34woF.js} +1 -1
  42. package/dist/packem_shared/{MemoryStorage-BuNY963D.js → MemoryStorage-CgEFb9yw.js} +1 -1
  43. package/dist/packem_shared/{Multipart-IE3j_gAJ.js → Multipart-D2eF0kMq.js} +1 -1
  44. package/dist/packem_shared/{Multipart-UIRqOPCf.js → Multipart-mlcj2Wm8.js} +1 -1
  45. package/dist/packem_shared/{NetlifyBlobMetaStorage-DNgncijZ.js → NetlifyBlobMetaStorage-DLJLr0fD.js} +1 -1
  46. package/dist/packem_shared/{NetlifyBlobStorage-eP0pkR0o.js → NetlifyBlobStorage-DqeW_OGE.js} +1 -1
  47. package/dist/packem_shared/{OneDriveMetaStorage-CkaFJFHe.js → OneDriveMetaStorage-Cuw5g3cr.js} +1 -1
  48. package/dist/packem_shared/{OneDriveStorage-3Iq5vBfd.js → OneDriveStorage-D41BZtkz.js} +1 -1
  49. package/dist/packem_shared/{PocketBaseMetaStorage-CxnGde_n.js → PocketBaseMetaStorage-BkzeMDP0.js} +1 -1
  50. package/dist/packem_shared/{PocketBaseStorage-DHphg8yi.js → PocketBaseStorage-CdvEL3YX.js} +1 -1
  51. package/dist/packem_shared/{Rest-DItHKz-N.js → Rest-08Oi3-WZ.js} +1 -1
  52. package/dist/packem_shared/{Rest-B_E4TrqF.js → Rest-BpyZYW-e.js} +1 -1
  53. package/dist/packem_shared/{S3Storage-Bc9eq5vJ.js → S3Storage-adY1XLfH.js} +1 -1
  54. package/dist/packem_shared/{SftpMetaStorage-CBcUhZRU.js → SftpMetaStorage-DN00oxqH.js} +1 -1
  55. package/dist/packem_shared/{SftpStorage-DSsMhTZC.js → SftpStorage-CDKtnw6a.js} +1 -1
  56. package/dist/packem_shared/{SharePointMetaStorage-yzxvwgKr.js → SharePointMetaStorage-WkQcni-I.js} +1 -1
  57. package/dist/packem_shared/{SharePointStorage-C6KIGN2r.js → SharePointStorage-CZkO7FSl.js} +1 -1
  58. package/dist/packem_shared/{SupabaseMetaStorage-D26wob-R.js → SupabaseMetaStorage-FaEVpmT5.js} +1 -1
  59. package/dist/packem_shared/{SupabaseStorage-B_knTpFQ.js → SupabaseStorage-O29RNXWx.js} +1 -1
  60. package/dist/packem_shared/{Tus-KQ8J2WF3.js → Tus-B7k9LUeY.js} +1 -1
  61. package/dist/packem_shared/{Tus-CAestp2j.js → Tus-BZT2Jhl5.js} +1 -1
  62. package/dist/packem_shared/UploadControl-jgusdgDN.js +1 -0
  63. package/dist/packem_shared/{UploadThingMetaStorage-DPIokkHa.js → UploadThingMetaStorage-CdDfhiyy.js} +1 -1
  64. package/dist/packem_shared/{UploadThingStorage-B3aIKSMh.js → UploadThingStorage-ByryGerX.js} +1 -1
  65. package/dist/packem_shared/{VercelBlobMetaStorage-Bx0l9Xt6.js → VercelBlobMetaStorage-CC1zy35k.js} +1 -1
  66. package/dist/packem_shared/{VercelBlobStorage-CGxoGkv4.js → VercelBlobStorage-C4QUjBfu.js} +1 -1
  67. package/dist/packem_shared/{approval.d-3sw7wbPG.d.ts → approval.d-CMAYH9GF.d.ts} +1 -1
  68. package/dist/packem_shared/{base-handler-core-OdTz4-Pm.js → base-handler-core-ty4J6Ji6.js} +1 -1
  69. package/dist/packem_shared/{base-handler-fetch-B0FWPun7.js → base-handler-fetch-BAjJyP84.js} +1 -1
  70. package/dist/packem_shared/{base-handler-node-CR2Bg43M.js → base-handler-node-BCqhH22o.js} +1 -1
  71. package/dist/packem_shared/{defaultCloudStorageFileNameValidation-De0HFP7m.js → defaultCloudStorageFileNameValidation-DSAf6C4S.js} +1 -1
  72. package/dist/packem_shared/detect-file-type-DRWGvQW4.js +1 -0
  73. package/dist/packem_shared/disk-storage-DJ2Nic2v.js +1 -0
  74. package/dist/packem_shared/{disk-storage-with-checksum.d-Z_Z-OQpm.d.ts → disk-storage-with-checksum.d-BT_ll5b8.d.ts} +1 -1
  75. package/dist/packem_shared/{executors.d-CRI3jlk4.d.ts → executors.d-D8esmhum.d.ts} +2 -2
  76. package/dist/packem_shared/{gcs-meta-storage-Dh0TAqB_.js → gcs-meta-storage-BXcsC7xV.js} +1 -1
  77. package/dist/packem_shared/{index.d-C4o9jVLx.d.ts → index.d-DB1VD8RP.d.ts} +1 -1
  78. package/dist/packem_shared/{local-meta-storage-Bvl0Flac.js → local-meta-storage-tayO1ARY.js} +1 -1
  79. package/dist/packem_shared/{local-meta-storage.d-CobcjyWu.d.ts → local-meta-storage.d-DUuLtPik.d.ts} +1 -1
  80. package/dist/packem_shared/{media-transformer.d-B5cQJz30.d.ts → media-transformer.d-B9dfBdoV.d.ts} +2 -2
  81. package/dist/packem_shared/{memory-storage.d-CunLnxmE.d.ts → memory-storage.d-BpxSYO-D.d.ts} +1 -1
  82. package/dist/packem_shared/{rest-base-DHkzq0rj.js → rest-base-BG0e-6E0.js} +1 -1
  83. package/dist/packem_shared/{s3-base-storage-o_zkj15Y.js → s3-base-storage-FiC4s91g.js} +1 -1
  84. package/dist/packem_shared/{s3-base-storage.d-ByfwKeid.d.ts → s3-base-storage.d-CoYAf_hG.d.ts} +1 -1
  85. package/dist/packem_shared/storage-CI88PmRw.js +1 -0
  86. package/dist/packem_shared/{storage.d-D5UN5mRz.d.ts → storage.d-C6HtvSoY.d.ts} +1 -1
  87. package/dist/packem_shared/{tus-base.d-D7UPhqdW.d.ts → tus-base.d-Dv25OXL0.d.ts} +3 -3
  88. package/dist/packem_shared/{types.d-GogSTfRh.d.ts → types.d-Cd2-3e-F.d.ts} +1 -1
  89. package/dist/packem_shared/{types.d-CPUyyEj9.d.ts → types.d-CmBrgo0d.d.ts} +2 -2
  90. package/dist/packem_shared/{types.d-BsjUOfBJ.d.ts → types.d-CmT_ubPu.d.ts} +2 -2
  91. package/dist/storage/aws/index.d.ts +2 -2
  92. package/dist/storage/aws/index.js +1 -1
  93. package/dist/storage/aws-light/index.d.ts +2 -2
  94. package/dist/storage/aws-light/index.js +1 -1
  95. package/dist/storage/azure/index.d.ts +1 -1
  96. package/dist/storage/azure/index.js +1 -1
  97. package/dist/storage/box/index.d.ts +2 -2
  98. package/dist/storage/box/index.js +1 -1
  99. package/dist/storage/bun-s3/index.d.ts +2 -2
  100. package/dist/storage/bun-s3/index.js +1 -1
  101. package/dist/storage/bunny/index.d.ts +2 -2
  102. package/dist/storage/bunny/index.js +1 -1
  103. package/dist/storage/cloudinary/index.d.ts +2 -2
  104. package/dist/storage/cloudinary/index.js +1 -1
  105. package/dist/storage/dropbox/index.d.ts +2 -2
  106. package/dist/storage/dropbox/index.js +1 -1
  107. package/dist/storage/firebase/index.d.ts +2 -2
  108. package/dist/storage/firebase/index.js +1 -1
  109. package/dist/storage/ftp/index.d.ts +2 -2
  110. package/dist/storage/ftp/index.js +1 -1
  111. package/dist/storage/gcs/index.d.ts +1 -1
  112. package/dist/storage/gcs/index.js +1 -1
  113. package/dist/storage/google-drive/index.d.ts +2 -2
  114. package/dist/storage/google-drive/index.js +1 -1
  115. package/dist/storage/local/index.d.ts +3 -3
  116. package/dist/storage/local/index.js +1 -1
  117. package/dist/storage/memory/index.d.ts +2 -2
  118. package/dist/storage/memory/index.js +1 -1
  119. package/dist/storage/netlify-blob/index.d.ts +2 -2
  120. package/dist/storage/netlify-blob/index.js +1 -1
  121. package/dist/storage/onedrive/index.d.ts +4 -4
  122. package/dist/storage/onedrive/index.js +1 -1
  123. package/dist/storage/pocketbase/index.d.ts +2 -2
  124. package/dist/storage/pocketbase/index.js +1 -1
  125. package/dist/storage/sftp/index.d.ts +2 -2
  126. package/dist/storage/sftp/index.js +1 -1
  127. package/dist/storage/sharepoint/index.d.ts +3 -3
  128. package/dist/storage/sharepoint/index.js +1 -1
  129. package/dist/storage/supabase/index.d.ts +2 -2
  130. package/dist/storage/supabase/index.js +1 -1
  131. package/dist/storage/uploadthing/index.d.ts +2 -2
  132. package/dist/storage/uploadthing/index.js +1 -1
  133. package/dist/storage/vercel-blob/index.d.ts +2 -2
  134. package/dist/storage/vercel-blob/index.js +1 -1
  135. package/dist/transformer/audio-transformer.d.ts +2 -2
  136. package/dist/transformer/image-transformer.d.ts +2 -2
  137. package/dist/transformer/index.d.ts +3 -3
  138. package/dist/transformer/video-transformer.d.ts +2 -2
  139. package/package.json +2 -2
  140. package/dist/packem_shared/DiskStorage-DHcHDZeO.js +0 -1
  141. package/dist/packem_shared/UploadControl-Otw_5jxw.js +0 -1
  142. package/dist/packem_shared/detect-file-type-5JhzC9RU.js +0 -1
  143. package/dist/packem_shared/disk-storage-CklneE2m.js +0 -1
  144. package/dist/packem_shared/storage-z0o24zmZ.js +0 -1
@@ -1,6 +1,6 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, 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-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import { drive_v3 } from '@googleapis/drive';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/GoogleDriveFile-D0aGfGbL.js";import{default as t}from"../../packem_shared/GoogleDriveMetaStorage-BT9N1Wji.js";import{default as f}from"../../packem_shared/GoogleDriveStorage-BzuSZZzN.js";export{r as GoogleDriveFile,t as GoogleDriveMetaStorage,f as GoogleDriveStorage};
1
+ import{default as r}from"../../packem_shared/GoogleDriveFile-D0aGfGbL.js";import{default as t}from"../../packem_shared/GoogleDriveMetaStorage-koEiYfFw.js";import{default as f}from"../../packem_shared/GoogleDriveStorage-DNlVE5Uo.js";export{r as GoogleDriveFile,t as GoogleDriveMetaStorage,f as GoogleDriveStorage};
@@ -1,6 +1,6 @@
1
- export { D as DiskStorage, a as DiskStorageWithChecksum } from "../../packem_shared/disk-storage-with-checksum.d-Z_Z-OQpm.js";
2
- export { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
- export { type L as LocalMetaStorageOptions } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ export { D as DiskStorage, a as DiskStorageWithChecksum } from "../../packem_shared/disk-storage-with-checksum.d-BT_ll5b8.js";
2
+ export { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
3
+ export { type L as LocalMetaStorageOptions } from "../../packem_shared/storage.d-C6HtvSoY.js";
4
4
  import 'node:stream';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1 +1 @@
1
- import{p as e}from"../../packem_shared/disk-storage-CklneE2m.js";import{default as t}from"../../packem_shared/DiskStorageWithChecksum--U7zOz-0.js";import{v as f}from"../../packem_shared/local-meta-storage-Bvl0Flac.js";export{e as DiskStorage,t as DiskStorageWithChecksum,f as LocalMetaStorage};
1
+ import{p as e}from"../../packem_shared/disk-storage-DJ2Nic2v.js";import{default as t}from"../../packem_shared/DiskStorageWithChecksum-CUXj5mE9.js";import{v as f}from"../../packem_shared/local-meta-storage-tayO1ARY.js";export{e as DiskStorage,t as DiskStorageWithChecksum,f as LocalMetaStorage};
@@ -1,6 +1,6 @@
1
- export { M as MemoryMetaStorage, a as MemoryStorage, type b as MemoryStorageOptions, a as default } from "../../packem_shared/memory-storage.d-CunLnxmE.js";
1
+ export { M as MemoryMetaStorage, a as MemoryStorage, type b as MemoryStorageOptions, a as default } from "../../packem_shared/memory-storage.d-BpxSYO-D.js";
2
2
  import 'node:stream';
3
- import "../../packem_shared/storage.d-D5UN5mRz.js";
3
+ import "../../packem_shared/storage.d-C6HtvSoY.js";
4
4
  import 'node:crypto';
5
5
  import 'node:http';
6
6
  import 'lru-cache';
@@ -1 +1 @@
1
- import{default as o}from"../../packem_shared/MemoryMetaStorage-DEzfBNgL.js";import{default as t,default as f}from"../../packem_shared/MemoryStorage-BuNY963D.js";export{o as MemoryMetaStorage,t as MemoryStorage,f as default};
1
+ import{default as o}from"../../packem_shared/MemoryMetaStorage-DEzfBNgL.js";import{default as t,default as f}from"../../packem_shared/MemoryStorage-CgEFb9yw.js";export{o as MemoryMetaStorage,t as MemoryStorage,f as default};
@@ -1,6 +1,6 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, R as RetryConfig, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, R as RetryConfig, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import { getStore } from '@netlify/blobs';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1 +1 @@
1
- import{default as o}from"../../packem_shared/NetlifyBlobFile-PMZLJ8AC.js";import{default as a}from"../../packem_shared/NetlifyBlobMetaStorage-DNgncijZ.js";import{default as r}from"../../packem_shared/NetlifyBlobStorage-eP0pkR0o.js";export{o as NetlifyBlobFile,a as NetlifyBlobMetaStorage,r as NetlifyBlobStorage};
1
+ import{default as o}from"../../packem_shared/NetlifyBlobFile-PMZLJ8AC.js";import{default as a}from"../../packem_shared/NetlifyBlobMetaStorage-DLJLr0fD.js";import{default as r}from"../../packem_shared/NetlifyBlobStorage-DqeW_OGE.js";export{o as NetlifyBlobFile,a as NetlifyBlobMetaStorage,r as NetlifyBlobStorage};
@@ -1,7 +1,7 @@
1
- import { O as OneDriveFile, a as OneDriveStorageOptions } from "../../packem_shared/types.d-GogSTfRh.js";
2
- export { type b as OneDriveClientCredentialsAuth, type c as OneDriveOAuthRefreshAuth } from "../../packem_shared/types.d-GogSTfRh.js";
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
4
- import { L as LocalMetaStorageOptions, 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-D5UN5mRz.js";
1
+ import { O as OneDriveFile, a as OneDriveStorageOptions } from "../../packem_shared/types.d-Cd2-3e-F.js";
2
+ export { type b as OneDriveClientCredentialsAuth, type c as OneDriveOAuthRefreshAuth } from "../../packem_shared/types.d-Cd2-3e-F.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
+ import { L as LocalMetaStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
5
5
  import { Client } from '@microsoft/microsoft-graph-client';
6
6
  import 'node:stream';
7
7
  import 'node:crypto';
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/OneDriveFile-XbVVKIJh.js";import{default as o}from"../../packem_shared/OneDriveMetaStorage-CkaFJFHe.js";import{default as i}from"../../packem_shared/OneDriveStorage-3Iq5vBfd.js";export{a as OneDriveFile,o as OneDriveMetaStorage,i as OneDriveStorage};
1
+ import{default as a}from"../../packem_shared/OneDriveFile-XbVVKIJh.js";import{default as o}from"../../packem_shared/OneDriveMetaStorage-Cuw5g3cr.js";import{default as i}from"../../packem_shared/OneDriveStorage-D41BZtkz.js";export{a as OneDriveFile,o as OneDriveMetaStorage,i as OneDriveStorage};
@@ -1,6 +1,6 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, 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-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import 'node:crypto';
5
5
  import 'node:http';
6
6
  import 'lru-cache';
@@ -1 +1 @@
1
- import{default as t}from"../../packem_shared/PocketBaseFile-CkAiSBb0.js";import{default as r}from"../../packem_shared/PocketBaseMetaStorage-CxnGde_n.js";import{default as s}from"../../packem_shared/PocketBaseStorage-DHphg8yi.js";export{t as PocketBaseFile,r as PocketBaseMetaStorage,s as PocketBaseStorage};
1
+ import{default as t}from"../../packem_shared/PocketBaseFile-CkAiSBb0.js";import{default as r}from"../../packem_shared/PocketBaseMetaStorage-BkzeMDP0.js";import{default as s}from"../../packem_shared/PocketBaseStorage-CdvEL3YX.js";export{t as PocketBaseFile,r as PocketBaseMetaStorage,s as PocketBaseStorage};
@@ -1,6 +1,6 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, 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-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import { ConnectOptions } from 'ssh2-sftp-client';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/SftpFile-CQCxZNVq.js";import{default as o}from"../../packem_shared/SftpMetaStorage-CBcUhZRU.js";import{default as p}from"../../packem_shared/SftpStorage-DSsMhTZC.js";export{a as SftpFile,o as SftpMetaStorage,p as SftpStorage};
1
+ import{default as a}from"../../packem_shared/SftpFile-CQCxZNVq.js";import{default as o}from"../../packem_shared/SftpMetaStorage-DN00oxqH.js";import{default as p}from"../../packem_shared/SftpStorage-CDKtnw6a.js";export{a as SftpFile,o as SftpMetaStorage,p as SftpStorage};
@@ -1,6 +1,6 @@
1
- import { O as OneDriveFile, a as OneDriveStorageOptions } from "../../packem_shared/types.d-GogSTfRh.js";
2
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
- import { L as LocalMetaStorageOptions, j as BaseStorageOptions, 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-D5UN5mRz.js";
1
+ import { O as OneDriveFile, a as OneDriveStorageOptions } from "../../packem_shared/types.d-Cd2-3e-F.js";
2
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
3
+ import { L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
4
4
  import { Readable } from 'node:stream';
5
5
  import { Client } from '@microsoft/microsoft-graph-client';
6
6
  import 'node:crypto';
@@ -1 +1 @@
1
- import{default as t}from"../../packem_shared/SharePointFile-BA6X9Sxr.js";import{default as r}from"../../packem_shared/SharePointMetaStorage-yzxvwgKr.js";import{default as S}from"../../packem_shared/SharePointStorage-C6KIGN2r.js";export{t as SharePointFile,r as SharePointMetaStorage,S as SharePointStorage};
1
+ import{default as t}from"../../packem_shared/SharePointFile-BA6X9Sxr.js";import{default as r}from"../../packem_shared/SharePointMetaStorage-WkQcni-I.js";import{default as S}from"../../packem_shared/SharePointStorage-CZkO7FSl.js";export{t as SharePointFile,r as SharePointMetaStorage,S as SharePointStorage};
@@ -1,6 +1,6 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, 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-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import { StorageClient } from '@supabase/storage-js';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1 +1 @@
1
- import{default as t}from"../../packem_shared/SupabaseFile-DZ1iv9gM.js";import{default as r}from"../../packem_shared/SupabaseMetaStorage-D26wob-R.js";import{default as p}from"../../packem_shared/SupabaseStorage-B_knTpFQ.js";export{t as SupabaseFile,r as SupabaseMetaStorage,p as SupabaseStorage};
1
+ import{default as t}from"../../packem_shared/SupabaseFile-DZ1iv9gM.js";import{default as r}from"../../packem_shared/SupabaseMetaStorage-FaEVpmT5.js";import{default as p}from"../../packem_shared/SupabaseStorage-O29RNXWx.js";export{t as SupabaseFile,r as SupabaseMetaStorage,p as SupabaseStorage};
@@ -1,7 +1,7 @@
1
1
  import { UTApi } from 'uploadthing/server';
2
- import { L as LocalMetaStorageOptions, j 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-D5UN5mRz.js";
2
+ import { L as LocalMetaStorageOptions, j as BaseStorageOptions, F as File, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
3
3
  import 'node:stream';
4
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
4
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
5
5
  import 'node:crypto';
6
6
  import 'node:http';
7
7
  import 'lru-cache';
@@ -1 +1 @@
1
- import{default as e}from"../../packem_shared/UploadThingFile-BpG9mE8K.js";import{default as r}from"../../packem_shared/UploadThingMetaStorage-DPIokkHa.js";import{default as d}from"../../packem_shared/UploadThingStorage-B3aIKSMh.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-CdDfhiyy.js";import{default as d}from"../../packem_shared/UploadThingStorage-ByryGerX.js";export{e as UploadThingFile,r as UploadThingMetaStorage,d as UploadThingStorage};
@@ -1,6 +1,6 @@
1
- import { L as LocalMetaStorageOptions, j 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-D5UN5mRz.js";
1
+ import { L as LocalMetaStorageOptions, j as BaseStorageOptions, F as File, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import { copy, del, list, put } from '@vercel/blob';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/VercelBlobFile-Cni_1qwD.js";import{default as a}from"../../packem_shared/VercelBlobMetaStorage-Bx0l9Xt6.js";import{default as f}from"../../packem_shared/VercelBlobStorage-CGxoGkv4.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-CC1zy35k.js";import{default as f}from"../../packem_shared/VercelBlobStorage-C4QUjBfu.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-D5UN5mRz.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-BsjUOfBJ.js";
1
+ import { F as File, a as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-C6HtvSoY.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-CmT_ubPu.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-D5UN5mRz.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-BsjUOfBJ.js";
2
+ import { F as File, a as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-C6HtvSoY.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-CmT_ubPu.js";
4
4
  import 'node:crypto';
5
5
  import 'node:http';
6
6
  import 'lru-cache';
@@ -1,6 +1,6 @@
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-BsjUOfBJ.js";
2
- export { M as MediaTransformer } from "../packem_shared/media-transformer.d-B5cQJz30.js";
3
- import { a as FileReturn } from "../packem_shared/storage.d-D5UN5mRz.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 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 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-CmT_ubPu.js";
2
+ export { M as MediaTransformer } from "../packem_shared/media-transformer.d-B9dfBdoV.js";
3
+ import { a as FileReturn } from "../packem_shared/storage.d-C6HtvSoY.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-D5UN5mRz.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-BsjUOfBJ.js";
1
+ import { F as File, a as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-C6HtvSoY.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-CmT_ubPu.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.33",
3
+ "version": "1.0.0-alpha.34",
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",
@@ -267,7 +267,7 @@
267
267
  "dependencies": {
268
268
  "@remix-run/multipart-parser": "0.16.0",
269
269
  "@sindresorhus/fnv1a": "3.1.0",
270
- "@visulima/pagination": "5.0.0-alpha.12",
270
+ "@visulima/pagination": "5.0.0-alpha.13",
271
271
  "file-type": "22.0.1",
272
272
  "lru-cache": "11.4.0",
273
273
  "mime": "^4.1.0",
@@ -1 +0,0 @@
1
- import"node:fs";import"node:fs/promises";import"node:stream";import"./local-meta-storage-Bvl0Flac.js";import{p as g}from"./disk-storage-CklneE2m.js";import"./path-D7rMc9nq-B718mbm6.js";import"./index-B4ETk0Lu.js";import"./detect-file-type-5JhzC9RU.js";import"./ERRORS-vMSqlI69.js";import"./storage-z0o24zmZ.js";import"./File-BhfUgJjs.js";import"./get-file-status-DLS18Zvd.js";import"./update-size-DANV7aa2.js";import"./part-match-D_NwyoF3.js";import"./has-content-Bx2p8Okx.js";export{g as default};
@@ -1 +0,0 @@
1
- var V=Object.defineProperty;var K=(s,t)=>V(s,"name",{value:t,configurable:!0});import{PassThrough as J,Readable as D}from"node:stream";import{B as P}from"./storage-z0o24zmZ.js";import{throwErrorCode as L,ERRORS as W}from"./ERRORS-vMSqlI69.js";var Y=Object.defineProperty,m=K((s,t)=>Y(s,"name",{value:t,configurable:!0}),"y");class _{static{K(this,"UploadControl")}static{m(this,"UploadControl")}key;controller=new AbortController;internalState="idle";loadedBytes;startPaused=!1;boundStream;constructor(t){this.loadedBytes=t?.loaded??0,this.key=t?.key}static from(t){const e=typeof t=="string"?JSON.parse(t):t;return new _({key:e.key,loaded:e.loaded})}get signal(){return this.controller.signal}get state(){return this.internalState}get loaded(){return this.loadedBytes}pause(){(this.internalState==="uploading"||this.internalState==="idle")&&(this.internalState="paused",this.startPaused=!0,this.boundStream?.pause())}resume(){this.internalState==="paused"&&(this.internalState="uploading",this.startPaused=!1,this.boundStream?.resume())}abort(t){this.internalState!=="completed"&&this.internalState!=="aborted"&&(this.internalState="aborted",this.controller.abort(t))}serialize(){return{key:this.key,loaded:this.loadedBytes,version:1}}_bind(t,e){this.boundStream=t,this.key??=e,this.internalState!=="aborted"&&(this.internalState=this.startPaused?"paused":"uploading"),this.startPaused&&t.pause()}_progress(t){this.loadedBytes=t}_complete(){this.internalState!=="aborted"&&(this.internalState="completed"),this.boundStream=void 0}}const R=8,q=m(s=>typeof s=="object"&&s!==null&&typeof s.getReader=="function","isWebReadableStream"),G=m(s=>typeof s=="object"&&s!==null&&typeof s.pipe=="function"&&typeof s.read=="function","isNodeReadable"),Q=m(async(s,t)=>{if(typeof s=="string"){const e=Buffer.from(s);return{size:e.byteLength,stream:D.from(e)}}if(Buffer.isBuffer(s))return{size:s.byteLength,stream:D.from(s)};if(s instanceof Uint8Array){const e=Buffer.from(s.buffer,s.byteOffset,s.byteLength);return{size:e.byteLength,stream:D.from(e)}}if(s instanceof ArrayBuffer){const e=Buffer.from(s);return{size:e.byteLength,stream:D.from(e)}}if(ArrayBuffer.isView(s)){const e=s,r=Buffer.from(e.buffer,e.byteOffset,e.byteLength);return{size:r.byteLength,stream:D.from(r)}}if(typeof Blob<"u"&&s instanceof Blob)return{size:s.size,stream:D.fromWeb(s.stream())};if(q(s))return{size:t,stream:D.fromWeb(s)};if(G(s))return{size:t,stream:s};throw new TypeError(`Unsupported body type: ${Object.prototype.toString.call(s)}`)},"normalizeBody"),U=m((s,t)=>({contentType:s.contentType??"application/octet-stream",etag:s.ETag,key:s.name||s.id||t||"",lastModified:s.modifiedAt??s.createdAt,metadata:s.metadata,size:typeof s.size=="number"?s.size:void 0}),"toFileObject"),$=m((s,t)=>{s.split("/").some(e=>e==="."||e==="..")&&L(W.INVALID_FILE_NAME,`${t} must not contain "." or ".." path segments: "${s}"`)},"assertNoRelativeSegments"),X=m(s=>{if(!s)return"";const t=s.split("/").filter(e=>e.length>0).join("/");return $(t,"prefix"),t},"normalizePrefix"),Z=m((s,t)=>{if(!t&&!s.signal&&s.timeout===void 0&&s.retries===void 0)return;const e={...s};return t&&(t.signal!==void 0&&(e.signal=t.signal),t.timeout!==void 0&&(e.timeout=t.timeout),t.retries!==void 0&&(e.retries=t.retries)),s.signal&&t?.signal&&(e.signal=AbortSignal.any([s.signal,t.signal])),e},"mergeOperationOptions"),I=m(async(s,t,e)=>{const r=Array.from({length:s.length});let n=0,o=!1;const u=m(async()=>{for(;n<s.length;){if(o||e.signal?.aborted)return;const a=n;n+=1;try{const i=await t(s[a],a);r[a]={status:"fulfilled",value:i}}catch(i){r[a]={reason:i,status:"rejected"},e.stopOnError&&(o=!0)}}},"worker"),c=Math.max(1,Math.min(e.concurrency,s.length)),l=Array.from({length:c},()=>u());return await Promise.all(l),r},"runConcurrent"),b=m((s,t)=>t instanceof Error?{error:t,key:s}:{error:new Error(typeof t=="string"?t:"Unknown error",{cause:t}),key:s},"toBulkError"),j=m((s,t)=>{if(s)try{s(t)}catch{}},"safeInvoke");class F{static{K(this,"Files")}static{m(this,"Files")}adapter;defaults;hooks;prefix;readonlyMode;constructor(t){this.adapter=t.adapter,this.defaults=t.defaults??{},this.hooks=t.hooks??{},this.prefix=X(t.prefix??""),this.readonlyMode=t.readonly??!1}get capabilities(){return{cacheControl:this.adapter.supportsCacheControl,metadata:this.adapter.supportsMetadata,range:this.adapter.supportsRange,readonly:this.readonlyMode}}readonly(){return new F({adapter:this.adapter,defaults:this.defaults,hooks:this.hooks,prefix:this.prefix,readonly:!0})}assertWritable(){this.readonlyMode&&L(W.READ_ONLY,"This Files instance is read-only")}get raw(){return this.adapter.raw}resolveKey(t){if(!this.prefix)return t;const e=t.replace(/^\/+/u,"");return $(e,"key"),`${this.prefix}/${e}`}stripPrefix(t){const e=t.startsWith("/")?t.slice(1):t;if(!this.prefix)return e;const r=`${this.prefix}/`;return e.startsWith(r)?e.slice(r.length):null}mergeOptions(t,e){const r=Z(this.defaults,t);if(!e||!this.hooks.onRetry)return r;const n=r?.retries,o=typeof n=="number"?{maxRetries:n}:{...n},u=o.onRetry,c=this.hooks.onRetry;return o.onRetry=(l,a)=>{if(u)try{u(l,a)}catch{}try{const i=typeof a=="string"?a:"Unknown error",d=a instanceof Error?a:new Error(i,{cause:a});c({...e,attempt:l,error:d})}catch{}},{...r,retries:o}}emitAction(t,e){if(this.hooks.onAction)try{this.hooks.onAction({type:t,...e})}catch{}}emitError(t,e,r){if(this.hooks.onError)try{this.hooks.onError({error:r,type:t,...e})}catch{}}async withHooks(t,e,r){const n=Date.now();try{const o=await r();return this.emitAction(t,{...e,durationMs:Date.now()-n}),o}catch(o){const u=typeof o=="string"?o:"Unknown error",c=o instanceof Error?o:new Error(u,{cause:o});throw this.emitError(t,{...e,durationMs:Date.now()-n},c),c}}async upload(t,e,r){return Array.isArray(t)?this.uploadMany(t,e):this.uploadOne(t,e,r)}async uploadOne(t,e,r){this.assertWritable(),r?.metadata&&Object.keys(r.metadata).length>0&&!this.adapter.supportsMetadata&&L(W.METHOD_NOT_ALLOWED,`Adapter ${this.adapter.constructor.name} does not persist custom metadata`);const n=r?.control;return this.withHooks("upload",{key:t},async()=>{const o=this.resolveKey(t);P.assertSafeId(o);const{size:u,stream:c}=await Q(e,r?.size),l=r?.size??u,a={...r?.metadata??{},name:o,...r?.contentType?{type:r.contentType}:{},...l===void 0?{}:{size:l}},i=n?{...r,signal:r?.signal?AbortSignal.any([r.signal,n.signal]):n.signal}:r,d=this.mergeOptions(i,{key:t,type:"upload"}),p=r?.multipart;n?._bind(c,t);const y=await this.adapter.create({contentType:r?.contentType,id:o,metadata:a,originalName:o,size:l,storageClass:r?.storageClass},d),f=this.adapter.reportsUploadProgress,h=r?.onProgress,S=!!h||!!n;let w=c;if(S&&!f){let N=0;const M=new J;l!==void 0&&h&&j(h,{loaded:0,total:l}),c.on("data",T=>{const O=typeof T=="string"?Buffer.byteLength(T):T.byteLength;N+=O,n?._progress(N),h&&j(h,{loaded:N,total:l})}),c.pipe(M),w=M}const E={body:w,contentLength:l,id:y.id,start:0,...p!==void 0&&{multipart:p},...f&&h&&{onProgress:h}},k=await this.adapter.write(E,d);n?._complete();const A=U(k,o),g=this.stripPrefix(A.key);return g!==null&&(A.key=g),A})}async uploadMany(t,e){this.assertWritable();const{concurrency:r=R,multipart:n,onProgress:o,stopOnError:u=!1,...c}=e??{},l=await I(t,async({body:d,key:p,...y})=>{const f=y.onProgress??(o?h=>{o({...h,key:p})}:void 0);return this.uploadOne(p,d,{...c,multipart:n,...y,...f&&{onProgress:f}})},{concurrency:r,signal:c.signal,stopOnError:u}),a=[],i=[];for(const[d,p]of l.entries()){const y=t[d];if(!p){i.push(b(y.key,new Error("Operation skipped (stopOnError)")));continue}p.status==="fulfilled"?a.push(p.value):i.push(b(y.key,p.reason))}return i.length>0?{errors:i,uploaded:a}:{uploaded:a}}async download(t,e){return Array.isArray(t)?this.downloadMany(t,e):this.downloadOne(t,e)}assertRangeSupported(t){if(t){if(!Number.isFinite(t.start)||t.start<0)throw new TypeError(`Invalid range.start: ${String(t.start)}`);if(t.end!==void 0&&(!Number.isFinite(t.end)||t.end<t.start))throw new TypeError(`Invalid range.end: ${String(t.end)}`);if(!this.adapter.supportsRange)throw new Error(`Adapter ${this.adapter.constructor.name} does not support range downloads`)}}async downloadOne(t,e){return this.withHooks("download",{key:t},async()=>{const r=this.resolveKey(t);P.assertSafeId(r),this.assertRangeSupported(e?.range);const n=this.mergeOptions(e,{key:t,type:"download"})??{},o=e?.range?{...n,range:e.range}:n,u=await this.adapter.get({id:r},o);return{body:u.content,contentType:u.contentType??"application/octet-stream",etag:u.ETag,key:t,lastModified:u.modifiedAt,metadata:u.metadata,size:typeof u.size=="number"?u.size:void 0}})}async downloadMany(t,e){const{concurrency:r=R,range:n,stopOnError:o=!1,...u}=e??{},c=await I(t,async i=>this.downloadOne(i,n?{...u,range:n}:u),{concurrency:r,signal:u.signal,stopOnError:o}),l=[],a=[];for(const[i,d]of c.entries()){const p=t[i];if(!d){a.push(b(p,new Error("Operation skipped (stopOnError)")));continue}d.status==="fulfilled"?l.push(d.value):a.push(b(p,d.reason))}return a.length>0?{downloaded:l,errors:a}:{downloaded:l}}async head(t,e){return Array.isArray(t)?this.headMany(t,e):this.headOne(t,e)}async headOne(t,e){return this.withHooks("head",{key:t},async()=>{const r=this.resolveKey(t);P.assertSafeId(r);const n=await this.adapter.getMeta(r,this.mergeOptions(e,{key:t,type:"head"})),o=U(n,r);return o.key=t,o})}async headMany(t,e){const{concurrency:r=R,stopOnError:n=!1,...o}=e??{},u=await I(t,async a=>this.headOne(a,o),{concurrency:r,signal:o.signal,stopOnError:n}),c=[],l=[];for(const[a,i]of u.entries()){const d=t[a];if(!i){l.push(b(d,new Error("Operation skipped (stopOnError)")));continue}i.status==="fulfilled"?c.push(i.value):l.push(b(d,i.reason))}return l.length>0?{errors:l,files:c}:{files:c}}async exists(t,e){return Array.isArray(t)?this.existsMany(t,e):this.existsOne(t,e)}async existsOne(t,e){return this.withHooks("exists",{key:t},async()=>{const r=this.resolveKey(t);return P.assertSafeId(r),this.adapter.exists({id:r},this.mergeOptions(e,{key:t,type:"exists"}))})}async existsMany(t,e){const{concurrency:r=R,stopOnError:n=!1,...o}=e??{},u=await I(t,async i=>this.existsOne(i,o),{concurrency:r,signal:o.signal,stopOnError:n}),c=[],l=[],a=[];for(const[i,d]of u.entries()){const p=t[i];if(!d){a.push(b(p,new Error("Operation skipped (stopOnError)")));continue}d.status==="fulfilled"?d.value?c.push(p):l.push(p):a.push(b(p,d.reason))}return a.length>0?{errors:a,existing:c,missing:l}:{existing:c,missing:l}}async delete(t,e){if(this.assertWritable(),Array.isArray(t))return this.deleteMany(t,e);await this.deleteOne(t,e)}async deleteOne(t,e){await this.withHooks("delete",{key:t},async()=>{const r=this.resolveKey(t);P.assertSafeId(r),await this.adapter.delete({id:r},this.mergeOptions(e,{key:t,type:"delete"}))})}async deleteMany(t,e){const{concurrency:r=R,stopOnError:n=!1,...o}=e??{},u=this.mergeOptions(o,{keys:t,type:"delete"});if(!n&&typeof this.adapter.deleteBatch=="function"){const i=[],d=[],p=[];for(const y of t){const f=this.resolveKey(y);try{P.assertSafeId(f),i.push(y),d.push(f)}catch(h){p.push(b(y,h))}}return this.withHooks("delete",{keys:i},async()=>{const y=d.length>0?await this.adapter.deleteBatch(d,u):{failed:[],successful:[]},f=new Map(d.map((w,E)=>[w,E])),h=y.successful.map(w=>this.stripPrefix(w.id)??w.id),S=[...p,...y.failed.map(({error:w,id:E})=>{const k=f.get(E),A=k===void 0?E:i[k];return b(A,new Error(w))})];return S.length>0?{deleted:h,errors:S}:{deleted:h}})}const c=await I(t,async i=>this.deleteOne(i,o),{concurrency:r,signal:o.signal,stopOnError:n}),l=[],a=[];for(const[i,d]of c.entries()){const p=t[i];if(!d){a.push(b(p,new Error("Operation skipped (stopOnError)")));continue}d.status==="fulfilled"?l.push(p):a.push(b(p,d.reason))}return a.length>0?{deleted:l,errors:a}:{deleted:l}}async copy(t,e,r){return this.assertWritable(),this.withHooks("copy",{from:t,to:e},async()=>{const n=this.resolveKey(t),o=this.resolveKey(e);P.assertSafeId(n),P.assertSafeId(o);const u=await this.adapter.copy(n,o,{...this.mergeOptions(r,{from:t,to:e,type:"copy"}),storageClass:r?.storageClass}),c=U(u,o);return c.key=e,c})}async move(t,e,r){return this.assertWritable(),Array.isArray(t)?this.moveMany(t,e):this.moveOne(t,e,r)}async moveOne(t,e,r){return this.withHooks("move",{from:t,to:e},async()=>{const n=this.resolveKey(t);if(P.assertSafeId(n),t===e){const a=await this.adapter.getMeta(n,this.mergeOptions(r,{from:t,to:e,type:"move"})),i=U(a,n);return i.key=t,i}const o=this.resolveKey(e);P.assertSafeId(o);const u={...this.mergeOptions(r,{from:t,to:e,type:"move"}),...r?.storageClass!==void 0&&{storageClass:r.storageClass}},c=await this.adapter.move(n,o,u),l=U(c,o);return l.key=e,l})}async moveMany(t,e){const{concurrency:r=R,stopOnError:n=!1,...o}=e??{},u=await I(t,async({from:a,to:i})=>this.moveOne(a,i,o),{concurrency:r,signal:o.signal,stopOnError:n}),c=[],l=[];for(const[a,i]of u.entries()){const d=t[a];if(!i){l.push(b(d.from,new Error("Operation skipped (stopOnError)")));continue}i.status==="fulfilled"?c.push(i.value):l.push(b(d.from,i.reason))}return l.length>0?{errors:l,moved:c}:{moved:c}}async list(t={}){return this.withHooks("list",{},async()=>{const{delimiter:e,limit:r,prefix:n,...o}=t;if(e!==void 0&&this.adapter.supportsDelimiter)return this.listDirectoryNative(e,n,r,o);const u=await this.adapter.list(r??1e3,this.mergeOptions(o,{type:"list"})),c=[];for(const p of u){const y=U(p),f=this.stripPrefix(y.key);f!==null&&(y.key=f,c.push(y))}const l=n?c.filter(p=>p.key.startsWith(n)):c;if(e===void 0)return l;const a=n??"",i=[],d=new Set;for(const p of l){const y=p.key.slice(a.length),f=y.indexOf(e);f===-1?i.push(p):d.add(a+y.slice(0,f+e.length))}return{files:i,prefixes:[...d].toSorted()}})}async listDirectoryNative(t,e,r,n){const o=[this.prefix,e].filter(Boolean).join("/"),{files:u,prefixes:c}=await this.adapter.listDirectory({delimiter:t,...r!==void 0&&{limit:r},...o&&{prefix:o},...this.mergeOptions(n,{type:"list"})}),l=[];for(const i of u){const d=U(i),p=this.stripPrefix(d.key);p!==null&&(d.key=p,l.push(d))}const a=[];for(const i of c){const d=this.stripPrefix(i);d!==null&&a.push(d)}return{files:l,prefixes:a.toSorted()}}async*listAll(t={}){const{limit:e,prefix:r,...n}=t,o=Math.max(1,e??1e3),u=Date.now(),c=new Set;let l;try{for(;;){const a=await this.adapter.list(o,this.mergeOptions(n,{type:"listAll"}));let i=0;for(const d of a){const p=U(d),y=this.stripPrefix(p.key);y!==null&&(p.key=y,!(r&&!p.key.startsWith(r))&&(c.has(p.key)||(c.add(p.key),i+=1,yield p)))}if(i===0||a.length<o)break}}catch(a){const i=typeof a=="string"?a:"Unknown error";throw l=a instanceof Error?a:new Error(i,{cause:a}),l}finally{const a=Date.now()-u;l?this.emitError("listAll",{durationMs:a},l):this.emitAction("listAll",{durationMs:a})}}async url(t,e){return this.withHooks("url",{key:t},async()=>{const r=this.resolveKey(t);return P.assertSafeId(r),this.adapter.getReadUrl(r,{...this.mergeOptions(e,{key:t,type:"url"}),...e})})}async signedUploadUrl(t,e){return this.assertWritable(),this.withHooks("signedUploadUrl",{key:t},async()=>{const r=this.resolveKey(t);return P.assertSafeId(r),this.adapter.getUploadUrl(r,{...this.mergeOptions(e,{key:t,type:"signedUploadUrl"}),...e})})}}const ot=m(async(s,t,e={})=>{const{concurrency:r=R,limit:n,onProgress:o,overwrite:u=!1,prefix:c,signal:l,stopOnError:a=!1,transformKey:i}=e,d=[],p=[],y=[];let f=!1,h=0;const S=m(g=>{if(o)try{o(g)}catch{}},"emit"),w=s.listAll({...c!==void 0&&{prefix:c},...n!==void 0&&{limit:n}}),E=m(async g=>{if(f||l?.aborted)return;const N=i?i(g):g;try{if(!u&&await t.exists(N,{signal:l})){p.push(g),h+=1,S({done:h,key:g,status:"skipped"});return}const M=await s.download(g,{signal:l});await t.upload(N,M.body,{...M.contentType&&{contentType:M.contentType},...M.metadata&&{metadata:M.metadata},signal:l}),d.push(g),h+=1,S({done:h,key:g,status:"transferred"})}catch(M){const T=b(g,M);if(y.push(T),h+=1,S({done:h,error:T.error,key:g,status:"errored"}),a)throw f=!0,T.error}},"transferOne");if(a){try{for await(const g of w){if(f||l?.aborted)break;try{await E(g.key)}catch{break}}}finally{await w.return?.()}return y.length>0?{errors:y,skipped:p,transferred:d}:{skipped:p,transferred:d}}const k=Math.max(1,r),A=m(async()=>{for(;!f&&!l?.aborted;){const g=await w.next();if(g.done)return;await E(g.value.key)}},"worker");try{await Promise.all(Array.from({length:k},()=>A()))}finally{await w.return?.()}return y.length>0?{errors:y,skipped:p,transferred:d}:{skipped:p,transferred:d}},"transfer"),tt=m((s,t)=>{if(typeof s.size=="number"&&typeof t.size=="number"&&s.size!==t.size)return!1;if(s.etag&&t.etag)return s.etag===t.etag;if(typeof s.size=="number"&&typeof t.size=="number")return!0;const e=s.lastModified===void 0?void 0:Number(new Date(s.lastModified)),r=t.lastModified===void 0?void 0:Number(new Date(t.lastModified));return e!==void 0&&r!==void 0&&!Number.isNaN(e)&&!Number.isNaN(r)?e<=r:!0},"objectsMatch"),it=m(async(s,t,e={})=>{const{concurrency:r=R,dryRun:n=!1,limit:o,onProgress:u,prefix:c,prune:l=!1,signal:a,stopOnError:i=!1,transformKey:d}=e,p=[],y=[],f=[],h=[],S=[],w=new Set;let E=!1,k=0;const A=m(O=>{if(u)try{u(O)}catch{}},"emit"),g=s.listAll({...c!==void 0&&{prefix:c},...o!==void 0&&{limit:o}}),N=m(async O=>{if(E||a?.aborted)return;const x=O.key,C=d?d(x):x;w.add(C);try{let v;try{v=await t.head(C,{signal:a})}catch{v=void 0}if(v){let z=O;if(O.size===void 0&&O.etag===void 0)try{z=await s.head(x,{signal:a})}catch{}if(tt(z,v)){f.push(x),k+=1,A({done:k,key:x,status:"unchanged"});return}}const B=v!==void 0;if(!n){const z=await s.download(x,{signal:a});await t.upload(C,z.body,{...z.contentType&&{contentType:z.contentType},...z.metadata&&{metadata:z.metadata},signal:a})}B?y.push(x):p.push(x),k+=1,A({done:k,key:x,status:B?"updated":"uploaded"})}catch(v){const B=b(x,v);if(S.push(B),k+=1,A({done:k,error:B.error,key:x,status:"errored"}),i)throw E=!0,B.error}},"syncOne"),M=Math.max(1,r),T=m(async()=>{for(;!E&&!a?.aborted;){const O=await g.next();if(O.done)return;await N(O.value)}},"worker");try{await Promise.all(Array.from({length:M},()=>T()))}finally{await g.return?.()}if(l&&!E&&!a?.aborted){const O=[],x=t.listAll({...c!==void 0&&{prefix:c},...o!==void 0&&{limit:o}});try{for await(const v of x)w.has(v.key)||O.push(v.key)}finally{await x.return?.()}const C=await I(O,async v=>(n||await t.delete(v,{signal:a}),v),{concurrency:M,signal:a,stopOnError:i});for(const[v,B]of C.entries()){const z=O[v];if(B)if(B.status==="fulfilled")h.push(z),k+=1,A({done:k,key:z,status:"deleted"});else{const H=b(z,B.reason);S.push(H),k+=1,A({done:k,error:H.error,key:z,status:"errored"})}}}return S.length>0?{deleted:h,errors:S,unchanged:f,updated:y,uploaded:p}:{deleted:h,unchanged:f,updated:y,uploaded:p}},"sync");export{F as Files,_ as UploadControl,F as default,it as sync,ot as transfer};
@@ -1 +0,0 @@
1
- var F=Object.defineProperty;var l=(r,t)=>F(r,"name",{value:t,configurable:!0});import{PassThrough as w,Transform as P}from"node:stream";import{fileTypeFromBuffer as d}from"file-type";var g=Object.defineProperty,p=l((r,t)=>g(r,"name",{value:t,configurable:!0}),"f");const S=p(async r=>{try{return await d(r)}catch{return}},"detectFileTypeFromBuffer"),j=p(async(r,t)=>{const y=t?.sampleSize??4100;let m;const f=[];let s=0,i=!1,n;const o=new w({highWaterMark:0}),a=new P({objectMode:!1,transform(e,c,T){if(!i&&(f.push(e),s+=e.length,s>=y||s>0)){i=!0;const h=Buffer.concat(f);n=d(h).then(u=>(m=u,u)).catch(()=>{})}T(void 0,e)}});return r.pipe(a).pipe(o),r.on("error",e=>{a.destroy(e),o.destroy(e)}),a.on("error",e=>{o.destroyed||o.destroy(e)}),await Promise.race([new Promise(e=>{if(i){e();return}const c=setTimeout(e,10);a.once("data",()=>{clearTimeout(c),e()}),a.once("end",()=>{clearTimeout(c),e()})}),new Promise(e=>{setTimeout(e,10)})]),n&&await Promise.race([n.then(()=>{}),new Promise(e=>{setTimeout(e,150)})]).catch(()=>{}),{fileType:m,stream:o}},"detectFileTypeFromStream");export{S as a,j as d};
@@ -1 +0,0 @@
1
- var mt=Object.defineProperty;var h=(e,t)=>mt(e,"name",{value:t,configurable:!0});import{createReadStream as dt,createWriteStream as ht}from"node:fs";import{truncate as yt,stat as B,copyFile as U}from"node:fs/promises";import{Transform as X,PassThrough as ft,pipeline as gt}from"node:stream";import{f as C,l as pt,w as q,U as v,_ as wt,i as bt,v as vt,B as Et,y as V}from"./local-meta-storage-Bvl0Flac.js";import{createRequire as _}from"node:module";import{K as b,C as P,M as Y,L as St,Q as $t,O as Ot}from"./path-D7rMc9nq-B718mbm6.js";import{S as Tt}from"./index-B4ETk0Lu.js";import{d as Ft}from"./detect-file-type-5JhzC9RU.js";import{throwErrorCode as w,ERRORS as y,isUploadError as kt}from"./ERRORS-vMSqlI69.js";import{createHash as Nt}from"node:crypto";import{B as Pt,a as Dt,t as Mt}from"./storage-z0o24zmZ.js";import _t from"./File-BhfUgJjs.js";import{o as Q}from"./get-file-status-DLS18Zvd.js";import{u as It}from"./update-size-DANV7aa2.js";import{r as Rt}from"./part-match-D_NwyoF3.js";import{o as xt}from"./has-content-Bx2p8Okx.js";var Lt=Object.defineProperty,jt=h((e,t)=>Lt(e,"name",{value:t,configurable:!0}),"i$4"),At=Object.defineProperty,G=jt((e,t)=>At(e,"name",{value:t,configurable:!0}),"t");const Ct=_(import.meta.url),F=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,zt=G(e=>{if(typeof F<"u"&&F.versions&&F.versions.node){const[t,r]=F.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return F.getBuiltinModule(e)}return Ct(e)},"__cjs_getBuiltinModule"),{lstat:Wt,writeFile:Bt}=zt("node:fs/promises");var Ut=Object.defineProperty,Vt=G((e,t)=>Ut(e,"name",{value:t,configurable:!0}),"o");const j=Vt(async e=>{C(e);try{const t=await Wt(e);if(!t.isFile())throw new Error(`Ensure path exists, expected 'file', got '${String(pt(t))}'`)}catch(t){if(t.code==="ENOENT"){await q(b(v(e))),await Bt(e,new Uint8Array);return}throw t}},"ensureFile");var Qt=Object.defineProperty,J=h((e,t)=>Qt(e,"name",{value:t,configurable:!0}),"t$1"),Ht=Object.defineProperty,Z=J((e,t)=>Ht(e,"name",{value:t,configurable:!0}),"t"),Kt=Object.defineProperty,Xt=Z((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"t");let H=class extends Error{static{h(this,"l")}static{J(this,"c")}static{Z(this,"i")}static{Xt(this,"WalkError")}root;constructor(t,r){super(`${t instanceof Error?t.message:String(t)} for path "${r}"`),this.cause=t,this.root=r}get name(){return"WalkError"}set name(t){throw new Error("Cannot overwrite name of WalkError")}};var qt=Object.defineProperty,Yt=h((e,t)=>qt(e,"name",{value:t,configurable:!0}),"l$1"),Gt=Object.defineProperty,tt=Yt((e,t)=>Gt(e,"name",{value:t,configurable:!0}),"t"),Jt=Object.defineProperty,Zt=tt((e,t)=>Jt(e,"name",{value:t,configurable:!0}),"g");const K=Zt(e=>{const t=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,String.raw`\.`).replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${t}$`)},"globToRegExp");var te=Object.defineProperty,ee=tt((e,t)=>te(e,"name",{value:t,configurable:!0}),"t");const M=ee((e,t,r,i)=>{if(Array.isArray(t)&&t.length>0&&!t.some(a=>e.endsWith(a)))return!1;const n=e.includes("\\")?e.replaceAll("\\","/"):e;return r&&!r.some(a=>a.test(n))?!1:!i?.some(a=>a.test(n))},"walkInclude");var re=Object.defineProperty,et=h((e,t)=>re(e,"name",{value:t,configurable:!0}),"f$1"),ie=Object.defineProperty,z=et((e,t)=>ie(e,"name",{value:t,configurable:!0}),"y");const ae=_(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=z(e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[t,r]=k.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return k.getBuiltinModule(e)}return ae(e)},"__cjs_getBuiltinModule"),{readdir:ne,realpath:oe,stat:ce}=se("node:fs/promises");var le=Object.defineProperty,p=z((e,t)=>le(e,"name",{value:t,configurable:!0}),"r");const ue=p(async e=>{const t=St(e),r=$t(t),i=await ce(t);return{isDirectory:p(()=>i.isDirectory(),"isDirectory"),isFile:p(()=>i.isFile(),"isFile"),isSymbolicLink:p(()=>i.isSymbolicLink(),"isSymbolicLink"),name:r,path:t}},"_createWalkEntry");async function*D(e,{extensions:t,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:n=!0,includeSymlinks:a=!0,match:s,maxDepth:l=Number.POSITIVE_INFINITY,skip:m}={}){if(C(e),l<0)return;const u=s?s.map(c=>typeof c=="string"?K(c):c):void 0,d=m?m.map(c=>typeof c=="string"?K(c):c):void 0;if(e=P(v(e)),i&&M(e,t,u,d)&&(yield await ue(e)),!(l<1||!M(e,void 0,void 0,d)))try{const c=await ne(e,{withFileTypes:!0});for(const o of c){let g=Y(e,o.name);if(o.isSymbolicLink())if(r)g=await oe(g);else if(a&&M(g,t,u,d)){yield{isDirectory:p(()=>o.isDirectory(),"isDirectory"),isFile:p(()=>o.isFile(),"isFile"),isSymbolicLink:p(()=>o.isSymbolicLink(),"isSymbolicLink"),name:o.name,path:g};continue}else continue;o.isDirectory()?yield*D(g,{extensions:t,followSymlinks:r,includeDirs:i,includeFiles:n,includeSymlinks:a,match:u,maxDepth:l-1,skip:d}):o.isFile()&&n&&M(g,t,u,d)&&(yield{isDirectory:p(()=>o.isDirectory(),"isDirectory"),isFile:p(()=>o.isFile(),"isFile"),isSymbolicLink:p(()=>o.isSymbolicLink(),"isSymbolicLink"),name:o.name,path:g})}}catch(c){throw c instanceof H?c:new H(c,e)}}h(D,"p$2");et(D,"D");z(D,"g");p(D,"walk");var me=Object.defineProperty,rt=h((e,t)=>me(e,"name",{value:t,configurable:!0}),"t"),de=Object.defineProperty,W=rt((e,t)=>de(e,"name",{value:t,configurable:!0}),"t");const he=_(import.meta.url),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ye=W(e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,r]=N.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return N.getBuiltinModule(e)}return he(e)},"__cjs_getBuiltinModule"),{accessSync:fe}=ye("node:fs");var ge=Object.defineProperty,pe=W((e,t)=>ge(e,"name",{value:t,configurable:!0}),"o");function I(e,t=wt){C(e),e=v(e);try{return fe(e,t),!0}catch{return!1}}h(I,"i$1");rt(I,"d");W(I,"m");pe(I,"isAccessibleSync");var we=Object.defineProperty,it=h((e,t)=>we(e,"name",{value:t,configurable:!0}),"v"),be=Object.defineProperty,T=it((e,t)=>be(e,"name",{value:t,configurable:!0}),"i");const ve=_(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,at=T(e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,r]=$.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return $.getBuiltinModule(e)}return ve(e)},"__cjs_getBuiltinModule"),{cwd:R}=$,{mkdir:Ee,rename:Se,copyFile:$e,unlink:Oe}=at("node:fs/promises"),{mkdirSync:Te,renameSync:Fe,copyFileSync:ke,unlinkSync:Ne}=at("node:fs");var Pe=Object.defineProperty,st=T((e,t)=>Pe(e,"name",{value:t,configurable:!0}),"o");class De extends Error{static{h(this,"V")}static{it(this,"O")}static{T(this,"a")}static{st(this,"SameDirectoryError")}constructor(t,r){super(`Source directory "${b(t)}" does not match destination directory "${b(r)}"`),this.name="SameDirectoryError"}}const nt=st((e,t)=>{if(!e||!t)throw new Error("Source and destination paths must not be empty");if(b(e)!==b(t))throw new De(e,t)},"validateSameDirectory");var Me=Object.defineProperty,_e=T((e,t)=>Me(e,"name",{value:t,configurable:!0}),"m$1");const ot=_e(async(e,t,{cwd:r,directoryMode:i,overwrite:n,validateDirectory:a})=>{if(r&&(e=P(r,e),t=P(r,t)),a&&nt(e,t),!n&&await bt(t))throw new Error(`The destination file exists: ${t}`);await Ee(b(t),{mode:i,recursive:!0});try{await Se(e,t)}catch(s){if(s.code==="EXDEV")await $e(e,t),await Oe(e);else throw s}},"internalMoveFile");var Ie=Object.defineProperty,Re=T((e,t)=>Ie(e,"name",{value:t,configurable:!0}),"m");const ct=Re((e,t,{cwd:r,directoryMode:i,overwrite:n,validateDirectory:a})=>{if(r&&(e=P(r,e),t=P(r,t)),a&&nt(e,t),!n&&I(t))throw new Error(`The destination file exists: ${t}`);Te(b(t),{mode:i,recursive:!0});try{Fe(e,t)}catch(s){if(s.code==="EXDEV")ke(e,t),Ne(e);else throw s}},"internalMoveFileSync");var xe=Object.defineProperty,x=T((e,t)=>xe(e,"name",{value:t,configurable:!0}),"i");const Le=x(async(e,t,r={})=>{const i={overwrite:!0,validateDirectory:!1,...r,cwd:r.cwd?v(r.cwd):R()};await ot(e,t,i)},"move");x((e,t,r)=>{const i={overwrite:!0,validateDirectory:!1,...r};i.cwd=i.cwd?v(i.cwd):R(),ct(e,t,i)},"moveSync");x(async(e,t,r)=>{const i={overwrite:!0,...r,validateDirectory:!0};i.cwd=i.cwd?v(i.cwd):R(),await ot(e,t,i)},"rename");x((e,t,r)=>{const i={overwrite:!0,...r,validateDirectory:!0};i.cwd=i.cwd?v(i.cwd):R(),ct(e,t,i)},"renameSync");var je=Object.defineProperty,lt=h((e,t)=>je(e,"name",{value:t,configurable:!0}),"r");class Ae extends X{static{h(this,"StreamChecksum")}constructor(t,r,i="base64"){super(),this.checksum=t,this.algorithm=r,this.encoding=i,this.hash=Nt(r)}checksum;algorithm;encoding;static{lt(this,"StreamChecksum")}length=0;digest="";hash;get calculatedDigest(){return this.digest}_transform(t,r,i){this.push(t),this.hash.update(t),this.length+=t.length,i()}_flush(t){this.digest=this.hash.digest(this.encoding),this.checksum&&this.checksum!==this.digest?t(new Error("Checksum mismatch")):t()}}const Ce=lt((e,t,r="base64")=>t?new Ae(e,t,r):new ft,"streamChecksum");var ze=Object.defineProperty,We=h((e,t)=>ze(e,"name",{value:t,configurable:!0}),"o");class Be extends X{static{h(this,"m")}constructor(t=Number.POSITIVE_INFINITY){super(),this.limit=t}limit;static{We(this,"StreamLength")}length=0;_transform(t,r,i){const n=this.length+t.length;this.limit>=n?(this.push(t),this.length=n,i()):i(new Error("Stream length limit exceeded"))}}var Ue=Object.defineProperty,A=h((e,t)=>Ue(e,"name",{value:t,configurable:!0}),"F");class O extends Pt{static name="disk";checksumTypes=["md5","sha1"];supportsRange=!0;get raw(){return{directory:this.directory}}directory;meta;constructor(t){const r={...t,fileNameValidation:t.fileNameValidation??Dt};if(super(r),this.directory=r.directory,r.metaStorage)this.meta=r.metaStorage;else{const i={...r,...r.metaStorageConfig,logger:this.logger};this.meta=new vt(i)}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(i=>{this.logger?.error("Storage access check failed: %O",i)})}normalizeError(t){return super.normalizeError(t)}async create(t){return this.instrumentOperation("create",async()=>{const r={...t};if(t.ttl){const a=typeof t.ttl=="string"?Mt(t.ttl):t.ttl;a!==void 0&&(r.expiredAt=Date.now()+a)}r.size!==void 0&&Number(r.size)<0&&w(y.REQUEST_ENTITY_TOO_LARGE,"Request entity too large");const i=new _t(r);try{const a=await this.getMeta(i.id);if(a.status==="completed")return a}catch{}i.name=this.namingFunction(i),(i.size===void 0||Number.isNaN(i.size))&&(i.size===void 0||(i.size=this.maxUploadSize)),await this.validate(i);const n=this.getFilePath(i.name);try{await j(n),i.bytesWritten=0}catch(a){const s=this.normalizeError(a instanceof Error?a:new Error(String(a)));await this.onError(s),w(y.FILE_ERROR,s.message)}return i.status=Q(i),await this.saveMeta(i),await this.onCreate(i),i})}async write(t){return this.instrumentOperation("write",async()=>{let r;if("contentType"in t&&"metadata"in t&&!("body"in t)&&!("start"in t)?r=t:(r=await this.getMeta(t.id),await this.checkIfExpired(r)),r.status==="completed")return r;if(t.size!==void 0&&It(r,t.size),!Rt(t,r))return w(y.FILE_CONFLICT);const i=this.getFilePath(r.name),n=await this.lock(i);try{const a=t.start||0;if(await j(i),r.bytesWritten===0&&(r.bytesWritten=a),xt(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))return w(y.UNSUPPORTED_CHECKSUM_ALGORITHM);if((t.start===0||t.start===void 0)&&(r.bytesWritten===0||Number.isNaN(r.bytesWritten))&&(!r.contentType||r.contentType==="application/octet-stream"))try{const{fileType:c,stream:o}=await Ft(t.body);c?.mime&&(r.contentType=c.mime),t.body=o}catch{}const s=t.signal,l={...r,...t,body:t.body};s&&(l.signal=s);const[m,u]=await this.lazyWrite(l);if(u)return await yt(i,r.bytesWritten),w(u);const d=a+(t.contentLength||0);r.bytesWritten=Math.max(r.bytesWritten||0,d),r.bytesWritten=Math.max(r.bytesWritten||0,m),r.status=Q(r),await this.saveMeta(r)}else await j(i),r.bytesWritten=0;return r}catch(a){if(kt(a))throw a;const s=this.normalizeError(a instanceof Error?a:new Error(String(a)));return await this.onError(s),w(y.FILE_ERROR,(typeof s.message=="string"?s.message:String(a))||String(a))}finally{await this.unlock(i,n)}})}async get({id:t},r){return this.instrumentOperation("get",async()=>{const i=await this.checkIfExpired(await this.meta.get(t)),{bytesWritten:n,contentType:a,expiredAt:s,metadata:l,modifiedAt:m,name:u,originalName:d,size:c}=i;let o;try{o=await Et(this.getFilePath(u),{buffer:!0})}catch(f){const S=f;if(S.code==="ENOENT"||S.code==="EPERM"){const L=this.normalizeError(f instanceof Error?f:new Error(S.message||String(f)));return await this.onError(L),w(y.FILE_NOT_FOUND,(typeof L.message=="string"?L.message:String(f))||String(f))}const ut=this.normalizeError(f instanceof Error?f:new Error(String(f)));throw await this.onError(ut),f}const g=Tt(o),E=r?.range;if(E){const f=Math.max(0,E.start),S=E.end===void 0?o.length-1:Math.min(o.length-1,E.end);if(f>S||f>=o.length)return w(y.BAD_REQUEST,`Invalid range ${f}-${E.end??""}`);o=o.subarray(f,S+1)}return{content:o,contentType:a,ETag:g,expiredAt:s,id:t,metadata:l,modifiedAt:m,name:u,originalName:d,size:E?o.length:c||n}})}async exists({id:t}){return this.instrumentOperation("exists",async()=>{try{const r=await this.getMeta(t),i=this.getFilePath(r.name);return await B(i),!0}catch{return!1}})}async getStream({id:t}){return this.instrumentOperation("getStream",async()=>{try{const r=await this.checkIfExpired(await this.meta.get(t)),{bytesWritten:i,contentType:n,expiredAt:a,modifiedAt:s,name:l,size:m}=r,u=dt(this.getFilePath(l));return{headers:{"Content-Length":String(m||i),"Content-Type":n,...a&&{"X-Upload-Expires":a.toString()},...s&&{"Last-Modified":s.toString()}},size:m||i,stream:u}}catch(r){const i=this.normalizeError(r instanceof Error?r:new Error(String(r)));throw await this.onError(i),w(y.FILE_NOT_FOUND,(typeof i.message=="string"?i.message:String(r))||String(r))}})}async delete({id:t}){return this.instrumentOperation("delete",async()=>{const r=await this.getMeta(t);await V(this.getFilePath(r.name)),await this.deleteMeta(t);const i={...r,status:"deleted"};return await this.onDelete(i),i})}async copy(t,r){return this.instrumentOperation("copy",async()=>{O.assertSafeId(t),O.assertSafeId(r);const i=await this.getMeta(t);return await U(this.getFilePath(i.name),this.getFilePath(r)),{...i,name:r}})}async move(t,r){return this.instrumentOperation("move",async()=>{O.assertSafeId(t),O.assertSafeId(r);const i=await this.getMeta(t),n=this.getFilePath(i.name),a=this.getFilePath(r);try{await Le(n,a)}catch(s){if(s?.code==="EXDEV")await U(n,a),await V(n);else{const l=this.normalizeError(s instanceof Error?s:new Error(String(s)));throw await this.onError(l),s}}return{...i,id:i.id,name:r}})}async list(){return this.instrumentOperation("list",async()=>{const t={followSymlinks:!1,includeDirs:!1,includeFiles:!0,skip:["*.META$"]},r=[],{directory:i}=this,n=A(s=>s.replaceAll("\\","/"),"toPosix"),a=n(i);for await(const s of D(i,t)){const{suffix:l}=this.meta,{path:m}=s;if(!m.includes(l)){const{birthtime:u,ctime:d,mtime:c}=await B(m),o=n(m),g=o.startsWith(a)?o.slice(a.length):o;r.push({createdAt:u||d,id:g,modifiedAt:c})}}return r})}getFilePath(t){return O.assertSafeId(t),Ot(t)&&w(y.INVALID_FILE_NAME,`Invalid file id: "${t}"`),Y(this.directory,t)}lazyWrite(t){return new Promise((r,i)=>{const n=ht(this.getFilePath(t.name),{flags:"r+",start:t.start}),a=new Be(t.contentLength||t.size-t.start),s=Ce(t.checksum,t.checksumAlgorithm),l=!t.checksum,{signal:m}=t,u=A(()=>{n.close(),a.destroy(),s.destroy()},"cleanupStreams"),d=A(c=>{u(),r([Number.NaN,c])},"failWithCode");if(a.on("error",()=>{d(y.FILE_CONFLICT)}),s.on("error",()=>{d(y.CHECKSUM_MISMATCH)}),t.body.on("aborted",()=>{d(l?void 0:y.REQUEST_ABORTED)}),t.body.on("error",c=>{u(),i(c)}),m?.aborted){d(l?void 0:y.REQUEST_ABORTED);return}m&&m.addEventListener("abort",()=>{u(),n.destroy(),a.destroy(),s.destroy(),t.body.destroy(),r([Number.NaN,l?void 0:y.REQUEST_ABORTED])}),gt(t.body,a,s,n,c=>{if(c){if(u(),m?.aborted){r([Number.NaN,l?void 0:y.REQUEST_ABORTED]);return}r([Number.NaN,y.FILE_ERROR]);return}r([t.start+n.bytesWritten])})})}async accessCheck(){await q(this.directory)}}export{Be as m,O as p,Ce as s,j as y};
@@ -1 +0,0 @@
1
- var q=Object.defineProperty;var p=(t,e)=>q(t,"name",{value:e,configurable:!0});import{Readable as X}from"node:stream";import{setInterval as J}from"node:timers";import{inspect as Q}from"node:util";import{L as ee,O as I}from"./path-D7rMc9nq-B718mbm6.js";import te from"type-is";import re from"./NoOpMetrics-Dky06sf1.js";import{N as oe}from"./cache-qV_5Umeq.js";import{ErrorMap as M,throwErrorCode as v,ERRORS as E}from"./ERRORS-vMSqlI69.js";import{randomUUID as se}from"node:crypto";import{LRUCache as ae}from"lru-cache";import{retry as ie}from"./isRetryableError-CBZ65V6T.js";import{o as ne}from"./is-expired-1JuZjDtb.js";var ce=Object.defineProperty,le=p((t,e)=>ce(t,"name",{value:e,configurable:!0}),"y$3"),ue=Object.defineProperty,me=le((t,e)=>ue(t,"name",{value:e,configurable:!0}),"y"),ge=Object.defineProperty,C=me((t,e)=>ge(t,"name",{value:e,configurable:!0}),"i");const de=/^(?<value>-?\d+(?:[.,]\d+)*) *(?<type>[a-z]+)?$/i,he=/^KIBI/,pe=/^MIBI/,fe=/^GIBI/,ye=/^TEBI/,be=/^PEBI/,we=/^EXBI/,ve=/^ZEBI/,Ee=/^YIBI/,$e=/^(.)IB$/,k={iec:[{long:"Bytes",short:"B"},{long:"Kibibytes",short:"KiB"},{long:"Mebibytes",short:"MiB"},{long:"Gibibytes",short:"GiB"},{long:"Tebibytes",short:"TiB"},{long:"Pebibytes",short:"PiB"},{long:"Exbibytes",short:"EiB"},{long:"Zebibytes",short:"ZiB"},{long:"Yobibytes",short:"YiB"}],iec_octet:[{long:"Octets",short:"o"},{long:"Kibioctets",short:"Kio"},{long:"Mebioctets",short:"Mio"},{long:"Gibioctets",short:"Gio"},{long:"Tebioctets",short:"Tio"},{long:"Pebioctets",short:"Pio"},{long:"Exbioctets",short:"Eio"},{long:"Zebioctets",short:"Zio"},{long:"Yobioctets",short:"Yio"}],metric:[{long:"Bytes",short:"Bytes"},{long:"Kilobytes",short:"KB"},{long:"Megabytes",short:"MB"},{long:"Gigabytes",short:"GB"},{long:"Terabytes",short:"TB"},{long:"Petabytes",short:"PB"},{long:"Exabytes",short:"EB"},{long:"Zettabytes",short:"ZB"},{long:"Yottabytes",short:"YB"}],metric_octet:[{long:"Octets",short:"o"},{long:"Kilo-octets",short:"ko"},{long:"Mega-octets",short:"Mo"},{long:"Giga-octets",short:"Go"},{long:"Tera-octets",short:"To"},{long:"Peta-octets",short:"Po"},{long:"Exa-octets",short:"Eo"},{long:"Zetta-octets",short:"Zo"},{long:"Yotta-octets",short:"Yo"}]},xe=C((t,e)=>{const r=new Intl.NumberFormat(e).format(11111).replaceAll(new RegExp("\\p{Number}","gu"),""),o=new Intl.NumberFormat(e).format(1.1).replaceAll(new RegExp("\\p{Number}","gu"),"");return Number.parseFloat(t.replaceAll(new RegExp(`\\${r}`,"g"),"").replace(new RegExp(`\\${o}`),"."))},"parseLocalizedNumber"),R=C(t=>{switch(t){case 2:return 1024;case 10:return 1e3;default:throw new Error("Unsupported base.")}},"fromBase"),j=C((t,e)=>{const r={base:2,locale:"en-US",units:"metric",...e};if(typeof t!="string"||t.length===0)throw new TypeError("Value is not a string or is empty.");if(t.length>100)throw new TypeError("Value exceeds the maximum length of 100 characters.");const o=de.exec(t)?.groups;if(!o)return Number.NaN;const s=xe(o.value,r.locale),a=(o.type??"Bytes").toUpperCase().replace(he,"KILO").replace(pe,"MEGA").replace(fe,"GIGA").replace(ye,"TERA").replace(be,"PETA").replace(we,"EXA").replace(ve,"ZETTA").replace(Ee,"YOTTA").replace($e,"$1B"),i=k[r.units].findIndex(u=>u.short[0].toUpperCase()===a[0]),l=R(r.base);return s*l**i},"parseBytes");C((t,e)=>{if(typeof t!="number"||!Number.isFinite(t))throw new TypeError("Bytesize is not a number.");const{base:r,decimals:o,locale:s,long:a,unit:i,units:l,...u}={base:2,decimals:0,locale:"en-US",long:!1,units:"metric",...e},n=R(r),m=Math.abs(t),g=e?.space??!0?" ":"",c=k[l],d=c.findIndex(w=>w.short===i);if(t===0){const w=Math.min(0,Math.max(d,c.length-1));return"0"+g+c[w][a?"long":"short"]}const h=d===-1?Math.min(Math.floor(Math.log(m)/Math.log(n)),c.length-1):d,O=c[h][a?"long":"short"],N=t/n**h,$=o<0?void 0:o;return new Intl.NumberFormat(s,{maximumFractionDigits:$,minimumFractionDigits:$,...u}).format(N)+g+O},"formatBytes");var Me=Object.defineProperty,Oe=p((t,e)=>Me(t,"name",{value:e,configurable:!0}),"u$3"),Ne=Object.defineProperty,Ae=Oe((t,e)=>Ne(t,"name",{value:e,configurable:!0}),"v"),Te=Object.defineProperty,Ce=Ae((t,e)=>Te(t,"name",{value:e,configurable:!0}),"D");const Se=Ce((t,e,r,o,s,a,i,l,u,n,m,g,c,d)=>{const h={d:o,h:s,m:a,mo:e,ms:l,s:i,w:r,y:t};return u!==void 0&&(h.future=u),n!==void 0&&(h.past=n),m!==void 0&&(h.decimal=m),g!==void 0&&(h.unitMap=g),c!==void 0&&(h.groupSeparator=c),d!==void 0&&(h.placeholderSeparator=d),h},"createDurationLanguage"),F={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},Ie=Se(t=>`year${t===1?"":"s"}`,t=>`month${t===1?"":"s"}`,t=>`week${t===1?"":"s"}`,t=>`day${t===1?"":"s"}`,t=>`hour${t===1?"":"s"}`,t=>`minute${t===1?"":"s"}`,t=>`second${t===1?"":"s"}`,t=>`millisecond${t===1?"":"s"}`,"in %s","%s ago",".",F,",","_");var Pe=Object.defineProperty,Be=p((t,e)=>Pe(t,"name",{value:e,configurable:!0}),"o"),De=Object.defineProperty,Ue=Be((t,e)=>De(t,"name",{value:e,configurable:!0}),"o"),ze=Object.defineProperty,je=Ue((t,e)=>ze(t,"name",{value:e,configurable:!0}),"o");const _e=je(t=>{const e=["y","mo","w","d","h","m","s","ms","future","past"];for(const o of e)if(!Object.hasOwn(t,o))throw new TypeError(`Missing required property: ${o}`);if(typeof t.future!="string"||typeof t.past!="string")throw new TypeError("Properties future and past must be of type string");const r=["y","mo","w","d","h","m","s","ms"];for(const o of r)if(typeof t[o]!="string"&&typeof t[o]!="function")throw new TypeError(`Property ${o} must be of type string or function`);if(t.decimal&&typeof t.decimal!="string")throw new TypeError("Property decimal must be of type string");if(t.delimiter&&typeof t.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(t._digitReplacements&&!Array.isArray(t._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(t._numberFirst&&typeof t._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(t.unitMap&&typeof t.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(t.unitMap&&Object.values(t.unitMap).some(o=>typeof o!="string"))throw new TypeError("All values in unitMap must be of type string")},"validateDurationLanguage");var ke=Object.defineProperty,Re=p((t,e)=>ke(t,"name",{value:e,configurable:!0}),"w"),Fe=Object.defineProperty,Le=Re((t,e)=>Fe(t,"name",{value:e,configurable:!0}),"S"),Ve=Object.defineProperty,Ge=Le((t,e)=>Ve(t,"name",{value:e,configurable:!0}),"h");const _={d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},A=/[-/\\^$*+?.()|[\]{}]/g,Ye=/^PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?$/i,Ze=/^(?:(\d+):)?(?:(\d+):)?(\d+)$/,Ke=/^[+-]?\d+(?:\.\d+)?$/,We=/^[-+]/,He=Ge((t,e)=>{if(typeof t!="string"||t.length===0)return;const{defaultUnit:r="ms",language:o=Ie}=e??{};_e(o);const s=o.decimal??".",a=o.groupSeparator??",",i=o.placeholderSeparator??"_",l=s.replaceAll(A,String.raw`\$&`),u=a.replaceAll(A,String.raw`\$&`),n=i.replaceAll(A,String.raw`\$&`),m=o.unitMap??F;let g=t.replaceAll(new RegExp(String.raw`(\d)[${n}${u}](\d)`,"g"),"$1$2");if(s!=="."&&(g=g.replace(l,".")),Ke.test(t)){const f=Number.parseFloat(g.trim());if(!Number.isNaN(f)){const y=m[r];if(y!==void 0)return f*_[y]}return}const c=Ye.exec(t);if(c){const f=Number.parseInt(c[1]??"0",10),y=Number.parseInt(c[2]??"0",10),x=Number.parseInt(c[3]??"0",10);return f*36e5+y*6e4+x*1e3}const d=Ze.exec(t);if(d){let f=0,y=0;d[2]!==void 0?(f=Number.parseInt(d[1]??"0",10),y=Number.parseInt(d[2],10)):d[1]!==void 0&&(y=Number.parseInt(d[1],10));const x=Number.parseInt(d[3]??"0",10);return f*36e5+y*6e4+x*1e3}const h=Object.keys(m).toSorted((f,y)=>y.length-f.length).map(f=>f.replaceAll(A,String.raw`\$&`)).join("|"),O=new RegExp(String.raw`(-?\d*\.?\d+)\s*(${h})`,"gi");let N=0,$,w=!1,B=-1,D=0;for(O.lastIndex=0;($=O.exec(g))!==null;){w||(B=$.index),w=!0;const f=$[1],y=$[2];if(!f||!y)continue;const x=f.trim(),K=x.startsWith("-")?-1:1,W=x.replace(We,""),U=Number.parseFloat(W),z=m[y.toLowerCase()];if(z===void 0)continue;const H=_[z];if(Number.isNaN(U))return;N+=K*U*H,D=O.lastIndex}const Y=g.slice(0,B).trim(),Z=g.slice(D).trim();if(!(w&&(Y.length>0||Z.length>0))&&w)return N},"parseDuration");var qe=Object.defineProperty,Xe=p((t,e)=>qe(t,"name",{value:e,configurable:!0}),"n$1");let Je=class extends ae{static{p(this,"u")}static{Xe(this,"Locker")}constructor(e){super({ttl:3e4,ttlAutopurge:!0,...e})}lock(e){if(this.get(e)!==void 0)throw new Error(`${e} is locked`);const r=se();return this.set(e,r),r}unlock(e,r){return this.get(e)!==r?!1:this.delete(e)}};var Qe=Object.defineProperty,et=p((t,e)=>Qe(t,"name",{value:e,configurable:!0}),"e$1");const T=et(t=>{if(t===Number(t))return t;if(!t)return;const e=He(t);if(e!==void 0)return e},"toMilliseconds");var tt=Object.defineProperty,rt=p((t,e)=>tt(t,"name",{value:e,configurable:!0}),"t");let ot=class extends Error{static{p(this,"d")}static{rt(this,"ValidationError")}code;statusCode;body;headers;name="ValidationError";constructor(e,r,o,s){const a=typeof o=="string"?o:o?.message||"Validation error";super(a),this.code=e,this.statusCode=r,this.body=o,this.headers=s}};var st=Object.defineProperty,S=p((t,e)=>st(t,"name",{value:e,configurable:!0}),"e");const at=S(t=>t&&t[0].toUpperCase()+t.slice(1),"capitalize"),it=S(t=>{if(!Array.isArray(t))return t;const[e,r,o]=t;return{body:r,headers:o,statusCode:e}},"toResponse");class nt{static{p(this,"Validator")}constructor(e="ValidationError"){this.prefix=e}prefix;static{S(this,"Validator")}validators={};add(e){Object.entries(e).forEach(([r,o])=>{const s=`${this.prefix}${at(r)}`;if(this.validators[s]={...this.validators[s],...o},typeof this.validators[s].isValid!="function")throw new TypeError('Validation config "isValid" is missing, or it is not a function!')})}async verify(e){for(const[r,o]of Object.entries(this.validators))if(!await o.isValid(e)){const s=o.response||(r in M?M[r]:M.UnknownError),a=it(s),{body:i,headers:l,message:u,statusCode:n}=a;throw new ot(r,n,i||u,l)}}}const St=S(t=>t.name==="ValidationError","isValidationError");var ct=Object.defineProperty,P=p((t,e)=>ct(t,"name",{value:e,configurable:!0}),"i");const lt=P(t=>{if(typeof t.name=="string")return t.name;if(typeof t.title=="string")return t.title;if(typeof t.originalName=="string")return t.originalName;if(typeof t.filename=="string")return t.filename},"extractOriginalName"),L=P((t,e)=>{const r={...t};return Object.keys(e).forEach(o=>{const s=e[o];if(s!==null&&typeof s=="object"&&!Array.isArray(s)){const a=r[o],i=a&&typeof a=="object"&&!Array.isArray(a)?a:{};r[o]=L(i,s)}else r[o]=s}),r},"deepMerge"),ut=P((t,e)=>{const r=L(t,e);Object.assign(t,r),t.originalName=lt(t.metadata)||t.originalName},"updateMetadata");var mt=Object.defineProperty,b=p((t,e)=>mt(t,"name",{value:e,configurable:!0}),"d");const gt=/(secret|password|passwd|pwd|token|api[_-]?key|credential|authorization|sas|signature|sessiontoken|connectionstring)/i,V=b(t=>{const e={};for(const[r,o]of Object.entries(t))typeof o=="string"&&gt.test(r)?e[r]="[REDACTED]":o&&typeof o=="object"&&!Array.isArray(o)&&o.constructor===Object?e[r]=V(o):e[r]=o;return e},"redactSecrets"),dt={allowMIME:["*/*"],filename:b(({id:t})=>t,"filename"),maxMetadataSize:"8MB",maxUploadSize:"5TB",onComplete:b(()=>{},"onComplete"),onCreate:b(()=>{},"onCreate"),onDelete:b(()=>{},"onDelete"),onError:b(()=>{},"onError"),onUpdate:b(()=>{},"onUpdate"),useRelativeLocation:!1,validation:{}},ht=b(t=>!t||t.length<3||t.length>255||I(t)?!1:!(t.toUpperCase().includes("../")||t.includes("\0")),"defaultCloudStorageFileNameValidation"),It=b(t=>{if(!t||t.length<3||t.length>255||I(t))return!1;const e=t.toUpperCase();return!['"',"*",":","<",">","?","\\","|","../","\0"].some(r=>e.includes(r))},"defaultFilesystemFileNameValidation");class G{static{p(this,"BaseStorage")}static{b(this,"BaseStorage")}onCreate;onUpdate;onComplete;onDelete;onError;isReady=!0;errorResponses={};cache;logger;metrics;genericConfig;maxMetadataSize;checksumTypes=[];supportsRange=!1;supportsMetadata=!0;supportsCacheControl=!1;supportsDelimiter=!1;reportsUploadProgress=!1;maxUploadSize;expiration;locker;namingFunction;validation=new nt;assetFolder=void 0;concurrency;constructor(e){const r={...dt,...e};this.onCreate=r.onCreate,this.onUpdate=r.onUpdate,this.onComplete=r.onComplete,this.onDelete=r.onDelete,this.onError=r.onError,this.namingFunction=r.filename,this.maxUploadSize=typeof r.maxUploadSize=="string"?j(r.maxUploadSize):r.maxUploadSize,this.maxMetadataSize=typeof r.maxMetadataSize=="string"?j(r.maxMetadataSize):r.maxMetadataSize,this.expiration=r.expiration,this.genericConfig=r,r.assetFolder!==void 0&&(this.assetFolder=ee(r.assetFolder)),this.locker=new Je({max:1e3,ttl:3e4,ttlAutopurge:!0}),this.cache=r.cache??new oe,this.logger=r.logger,this.metrics=r.metrics??new re,this.logger?.debug(`${this.constructor.name} config: ${Q(V({...e,logger:this.logger.constructor}))}`);const o=T(r.expiration?.purgeInterval);o&&this.startAutoPurge(o);const s={isValid(u){if(u.size===void 0)return!0;const n=u.size;if(n==null)return!1;const m=typeof n=="number"?n:Number(n);if(Number.isNaN(m)||m<0)return!1;const g=typeof this.value=="number"?this.value:Number(this.value);return!Number.isNaN(g)&&m<=g},response:M.RequestEntityTooLarge,value:this.maxUploadSize},a={isValid(u){return!!te.is(u.contentType,this.value)},response:M.UnsupportedMediaType,value:r.allowMIME},i=r.fileNameValidation??ht,l={isValid(u){return i(u.name)},response:M.InvalidFileName};this.validation.add({filename:l,mime:a,size:s}),this.validation.add({...r.validation})}get raw(){}async getReadUrl(e,r){return v(E.METHOD_NOT_ALLOWED,`${this.constructor.name} does not implement getReadUrl()`)}async getUploadUrl(e,r){return v(E.METHOD_NOT_ALLOWED,`${this.constructor.name} does not implement getUploadUrl()`)}get tusExtension(){const e=["creation","creation-with-upload","termination","checksum","creation-defer-length","concatenation"];return this.expiration&&e.push("expiration"),e}async validate(e){await this.validation.verify(e)}async exists(e,r){return this.instrumentOperation("exists",async()=>{try{return await this.getMeta(e.id,r),!0}catch{return!1}})}normalizeError(e){const r={code:e.name,message:e.message,name:e.name,statusCode:500};return{...r,message:`[${this.constructor.name}] ${r.message}`}}get config(){return this.genericConfig}async saveMeta(e){return G.assertSafeId(e.id),this.updateTimestamps(e),this.cache.set(e.id,e),this.meta.save(e.id,e)}static assertSafeId(e){(!e||typeof e!="string"||e.includes("\0")||e.includes("../")||e.includes("..\\")||e===".."||e.startsWith("../")||e.startsWith("..\\")||I(e)||/^[A-Z]:[/\\]/i.test(e))&&v(E.INVALID_FILE_NAME,`Invalid file id: "${e}"`)}async deleteMeta(e){return this.cache.delete(e),this.meta.delete(e)}async getMeta(e,r){try{const o=await this.meta.get(e);return this.cache.set(o.id,o),{...o}}catch(o){const s=this.normalizeError(o instanceof Error?o:new Error(String(o)));return await this.onError(s),v(E.FILE_NOT_FOUND)}}async checkIfExpired(e){return ne(e)?(this.delete(e).catch(()=>{}),this.deleteMeta(e.id).catch(()=>{}),v(E.GONE)):e}async purge(e){return this.instrumentOperation("purge",async()=>{const r=T(e||this.expiration?.maxAge),o={items:[],maxAgeMs:r};if(r){const s=Date.now()-r,a=(await this.list()).filter(i=>Number(new Date(this.expiration?.rolling&&i.modifiedAt||i.createdAt))<s);for await(const{id:i,...l}of a)try{const u=await this.delete({id:i});o.items.push({...u,...l})}catch(u){this.logger?.warn(`Failed to delete file ${i} during purge: ${u instanceof Error?u.message:String(u)}`)}o.items.length>0&&(this.logger?.info(`Purge: removed ${o.items.length} uploads`),this.metrics.gauge("storage.operations.purge.items_count",o.items.length,{storage:this.constructor.name.toLowerCase().replace("storage","")}))}return o})}async getStream({id:e}){return this.instrumentOperation("getStream",async()=>{const r=await this.get({id:e}),o=X.from(r.content);return{headers:{"Content-Length":String(r.size),"Content-Type":r.contentType,...r.ETag&&{ETag:r.ETag},...r.modifiedAt&&{"Last-Modified":r.modifiedAt.toString()}},size:typeof r.size=="number"?r.size:void 0,stream:o}})}async list(e=1e3,r){return this.instrumentOperation("list",async()=>{throw new Error("Not implemented")})}async listDirectory(e){return v(E.METHOD_NOT_ALLOWED,`${this.constructor.name} does not implement listDirectory()`)}async update({id:e},r){return this.instrumentOperation("update",async()=>{const o=await this.getMeta(e),s={...r};if("ttl"in s&&s.ttl!==void 0){const i=s.ttl,l=typeof i=="string"?T(i):i;l!==void 0&&(s.expiredAt=Date.now()+l),delete s.ttl}ut(o,s),await this.saveMeta(o);const a={...o,status:"updated"};return await this.onUpdate(a),a})}async deleteBatch(e,r){const o=Date.now(),s=this.constructor.name.toLowerCase().replace("storage","");this.metrics.increment("storage.operations.batch.delete.count",1,{batch_size:e.length,storage:s});const a=[],i=[],l=e.map(async m=>{try{return{file:await this.delete({id:m},r),id:m,success:!0}}catch(g){const c=g instanceof Error?g.message:"Delete failed";return this.metrics.increment("storage.operations.delete.error.count",1,{error:c,storage:s}),{error:c,id:m,success:!1}}}),u=await Promise.allSettled(l);for(const m of u)m.status==="fulfilled"?m.value.success?a.push(m.value.file):i.push({error:m.value.error,id:m.value.id}):i.push({error:m.reason?.message||"Delete failed",id:""});const n=Date.now()-o;return this.metrics.timing("storage.operations.batch.delete.duration",n,{batch_size:e.length,storage:s}),this.metrics.gauge("storage.operations.batch.delete.success_count",a.length,{storage:s}),this.metrics.gauge("storage.operations.batch.delete.failed_count",i.length,{storage:s}),{failed:i,failedCount:i.length,successful:a,successfulCount:a.length}}async copyBatch(e){const r=Date.now(),o=this.constructor.name.toLowerCase().replace("storage","");this.metrics.increment("storage.operations.batch.copy.count",1,{batch_size:e.length,storage:o});const s=[],a=[],i=e.map(async({destination:n,options:m,source:g})=>{try{return{file:await this.copy(g,n,m),id:n,success:!0}}catch(c){const d=c instanceof Error?c.message:"Copy failed";return this.metrics.increment("storage.operations.copy.error.count",1,{error:d,storage:o}),{error:d,id:n,success:!1}}}),l=await Promise.allSettled(i);for(const n of l)n.status==="fulfilled"?n.value.success&&n.value.file?s.push(n.value.file):a.push({error:n.value.error||"Copy failed",id:n.value.id}):a.push({error:n.reason?.message||"Copy failed",id:""});const u=Date.now()-r;return this.metrics.timing("storage.operations.batch.copy.duration",u,{batch_size:e.length,storage:o}),this.metrics.gauge("storage.operations.batch.copy.success_count",s.length,{storage:o}),this.metrics.gauge("storage.operations.batch.copy.failed_count",a.length,{storage:o}),{failed:a,failedCount:a.length,successful:s,successfulCount:s.length}}async moveBatch(e){const r=Date.now(),o=this.constructor.name.toLowerCase().replace("storage","");this.metrics.increment("storage.operations.batch.move.count",1,{batch_size:e.length,storage:o});const s=[],a=[],i=e.map(async({destination:n,source:m})=>{try{return{file:await this.move(m,n),id:n,success:!0}}catch(g){const c=g instanceof Error?g.message:"Move failed";return this.metrics.increment("storage.operations.move.error.count",1,{error:c,storage:o}),{error:c,id:n,success:!1}}}),l=await Promise.allSettled(i);for(const n of l)n.status==="fulfilled"?n.value.success&&n.value.file?s.push(n.value.file):a.push({error:n.value.error||"Move failed",id:n.value.id}):a.push({error:n.reason?.message||"Move failed",id:n.reason?.id||""});const u=Date.now()-r;return this.metrics.timing("storage.operations.batch.move.duration",u,{batch_size:e.length,storage:o}),this.metrics.gauge("storage.operations.batch.move.success_count",s.length,{storage:o}),this.metrics.gauge("storage.operations.batch.move.failed_count",a.length,{storage:o}),{failed:a,failedCount:a.length,successful:s,successfulCount:s.length}}async lock(e){const r=[...this.locker.keys()];return r.includes(e)?v(E.FILE_LOCKED):this.config.concurrency&&typeof this.config.concurrency=="number"&&this.config.concurrency<r.length?v(E.STORAGE_BUSY):this.locker.lock(e)}async unlock(e,r){if(r===void 0){this.locker.delete(e);return}this.locker.unlock(e,r)}async withLock(e,r){const o=await this.lock(e);try{return await r()}finally{await this.unlock(e,o)}}isUnsupportedChecksum(e=""){return!!e&&!this.checksumTypes.includes(e)}startAutoPurge(e){if(e>=2147483647)throw new Error("“purgeInterval” must be less than 2147483647 ms");J(()=>{this.purge().catch(r=>this.logger?.error(r))},e)}updateTimestamps(e){e.createdAt??=new Date().toISOString();const r=T(this.expiration?.maxAge);return r&&!e.expiredAt&&(e.expiredAt=this.expiration?.rolling?Date.now()+r:+new Date(e.createdAt)+r),e}getRetryConfig(){}runOperation(e,r,o){let s;typeof e?.retries=="number"?s={maxRetries:e.retries}:e?.retries&&(s=e.retries);const a={...this.getRetryConfig(),...s};o?.replayable===!1&&(a.maxRetries=0);const i=[];this.genericConfig.defaultSignal&&i.push(this.genericConfig.defaultSignal),e?.signal&&i.push(e.signal);let l;i.length===1?[l]=i:i.length>1&&(l=AbortSignal.any(i));const u=typeof e?.timeout=="number"?e.timeout:this.genericConfig.defaultTimeout,n=typeof u=="number"&&u>0?u:void 0,m=a.shouldRetry;a.shouldRetry=c=>l?.aborted||c instanceof Error&&c.name==="AbortError"?!1:m?m(c):!1;const g=b(c=>{if(c instanceof Error&&c.name==="AbortError")return c;const d=c instanceof Error&&c.message?c.message:"The operation was aborted",h=new Error(d,{cause:c});return h.name="AbortError",h},"toAbortError");return ie(async()=>{if(l?.aborted)throw g(l.reason);let c,d;if(n===void 0)d=l;else{const h=new AbortController;c=setTimeout(()=>{h.abort(new DOMException(`The operation timed out after ${n}ms`,"TimeoutError"))},n),d=l?AbortSignal.any([l,h.signal]):h.signal}try{return await r(d)}catch(h){throw d?.aborted?g(h):h}finally{c&&clearTimeout(c)}},a)}async instrumentOperation(e,r,o){const s=Date.now(),a={storage:this.constructor.name.toLowerCase().replace("storage",""),...o};try{this.metrics.increment(`storage.operations.${e}.count`,1,a);const i=await r(),l=Date.now()-s;return this.metrics.timing(`storage.operations.${e}.duration`,l,a),i&&typeof i=="object"&&"size"in i&&typeof i.size=="number"&&this.metrics.gauge("storage.files.size",i.size,{...a,operation:e}),i}catch(i){const l=Date.now()-s,u=i instanceof Error?i.message:"Unknown error";throw this.metrics.timing(`storage.operations.${e}.duration`,l,{...a,error:"true"}),this.metrics.increment(`storage.operations.${e}.error.count`,1,{...a,error:u}),i}}}export{j as $,G as B,It as a,ot as b,ht as d,St as i,T as t,ut as u,He as z};