@visulima/storage 1.0.0-alpha.32 → 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 (182) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +1 -1
  3. package/dist/adapter/nuxt/module.d.ts +4 -4
  4. package/dist/adapter/nuxt/node_modules/.bin/nuxi +2 -2
  5. package/dist/adapter/nuxt/node_modules/.bin/nuxt +2 -2
  6. package/dist/ai/ai-sdk/index.d.ts +3 -3
  7. package/dist/ai/ai-sdk/index.js +1 -1
  8. package/dist/ai/claude/index.d.ts +2 -2
  9. package/dist/ai/claude/index.js +1 -1
  10. package/dist/ai/openai/index.d.ts +3 -3
  11. package/dist/ai/openai/index.js +1 -1
  12. package/dist/ai/tanstack/index.d.ts +2 -2
  13. package/dist/ai/tanstack/index.js +1 -1
  14. package/dist/handler/http/fetch/index.d.ts +7 -7
  15. package/dist/handler/http/fetch/index.js +1 -1
  16. package/dist/handler/http/hono/index.d.ts +4 -4
  17. package/dist/handler/http/hono/index.js +1 -1
  18. package/dist/handler/http/nextjs/index.d.ts +4 -4
  19. package/dist/handler/http/nextjs/index.js +1 -1
  20. package/dist/handler/http/node/index.d.ts +7 -7
  21. package/dist/handler/http/node/index.js +1 -1
  22. package/dist/handler/http/solid-start/index.d.ts +4 -4
  23. package/dist/handler/http/solid-start/index.js +1 -1
  24. package/dist/index.d.ts +6 -6
  25. package/dist/index.js +1 -1
  26. package/dist/packem_shared/{AwsLightMetaStorage-B-iQbToR.js → AwsLightMetaStorage-Cj7ym1qI.js} +1 -1
  27. package/dist/packem_shared/{AwsLightStorage-B1jNF7sv.js → AwsLightStorage-CWBRVcn5.js} +1 -1
  28. package/dist/packem_shared/AzureSMetaStorage-YCj-X8a1.js +1 -0
  29. package/dist/packem_shared/AzureStorage-nhAojuEU.js +1 -0
  30. package/dist/packem_shared/{BoxMetaStorage-nESVquA1.js → BoxMetaStorage-XMZn5yvp.js} +1 -1
  31. package/dist/packem_shared/{BoxStorage-CHYDrcxw.js → BoxStorage-C3--16du.js} +1 -1
  32. package/dist/packem_shared/{BunS3MetaStorage-BkZx5q4w.js → BunS3MetaStorage-DomG8mVK.js} +1 -1
  33. package/dist/packem_shared/BunS3Storage-0oYNi2Os.js +1 -0
  34. package/dist/packem_shared/{BunnyMetaStorage-bB8NXGUI.js → BunnyMetaStorage-luemw1pL.js} +1 -1
  35. package/dist/packem_shared/BunnyStorage-CIkpp1Rc.js +1 -0
  36. package/dist/packem_shared/{CloudinaryMetaStorage-BzibHydK.js → CloudinaryMetaStorage-DpxjshXZ.js} +1 -1
  37. package/dist/packem_shared/{CloudinaryStorage-Cj00ZXWV.js → CloudinaryStorage-9Y1Gq0gr.js} +1 -1
  38. package/dist/packem_shared/DiskStorage-BkP8c0MY.js +1 -0
  39. package/dist/packem_shared/{DiskStorageWithChecksum-BX85CHJ6.js → DiskStorageWithChecksum-CUXj5mE9.js} +1 -1
  40. package/dist/packem_shared/{DropboxMetaStorage-Bfm5bblb.js → DropboxMetaStorage-h0eTJuk5.js} +1 -1
  41. package/dist/packem_shared/{DropboxStorage-Btz9h9Mj.js → DropboxStorage-CuA9MkpH.js} +1 -1
  42. package/dist/packem_shared/ERRORS-vMSqlI69.js +1 -0
  43. package/dist/packem_shared/{FirebaseMetaStorage-CshnJMb0.js → FirebaseMetaStorage-CCBnEE8_.js} +1 -1
  44. package/dist/packem_shared/FirebaseStorage-DUskfjh_.js +2 -0
  45. package/dist/packem_shared/{FtpMetaStorage-CoyWJafY.js → FtpMetaStorage-DxHcXk9x.js} +1 -1
  46. package/dist/packem_shared/FtpStorage-DMpDY7oG.js +1 -0
  47. package/dist/packem_shared/{GCSMetaStorage-CfZj52hQ.js → GCSMetaStorage-DCBR02C7.js} +1 -1
  48. package/dist/packem_shared/GCStorage-RCw58CoD.js +1 -0
  49. package/dist/packem_shared/{GoogleDriveMetaStorage-CBSdEQr6.js → GoogleDriveMetaStorage-koEiYfFw.js} +1 -1
  50. package/dist/packem_shared/GoogleDriveStorage-DNlVE5Uo.js +1 -0
  51. package/dist/packem_shared/LocalMetaStorage-BKC34woF.js +1 -0
  52. package/dist/packem_shared/MemoryStorage-CgEFb9yw.js +1 -0
  53. package/dist/packem_shared/{Multipart-qaEOWKz1.js → Multipart-D2eF0kMq.js} +1 -1
  54. package/dist/packem_shared/{Multipart-kQ5wJQaV.js → Multipart-mlcj2Wm8.js} +1 -1
  55. package/dist/packem_shared/{NetlifyBlobMetaStorage-CqluIgV0.js → NetlifyBlobMetaStorage-DLJLr0fD.js} +1 -1
  56. package/dist/packem_shared/{NetlifyBlobStorage-CkMw9Uyv.js → NetlifyBlobStorage-DqeW_OGE.js} +1 -1
  57. package/dist/packem_shared/{OneDriveMetaStorage-DPTNMpeq.js → OneDriveMetaStorage-Cuw5g3cr.js} +1 -1
  58. package/dist/packem_shared/OneDriveStorage-D41BZtkz.js +1 -0
  59. package/dist/packem_shared/{PocketBaseMetaStorage-CemTT_01.js → PocketBaseMetaStorage-BkzeMDP0.js} +1 -1
  60. package/dist/packem_shared/{PocketBaseStorage-BZNzWj09.js → PocketBaseStorage-CdvEL3YX.js} +1 -1
  61. package/dist/packem_shared/{Rest-BAcUFAgk.js → Rest-08Oi3-WZ.js} +1 -1
  62. package/dist/packem_shared/{Rest-DukkeDZe.js → Rest-BpyZYW-e.js} +1 -1
  63. package/dist/packem_shared/S3Storage-adY1XLfH.js +1 -0
  64. package/dist/packem_shared/{SftpMetaStorage-Cs8b7uBO.js → SftpMetaStorage-DN00oxqH.js} +1 -1
  65. package/dist/packem_shared/SftpStorage-CDKtnw6a.js +1 -0
  66. package/dist/packem_shared/{SharePointMetaStorage-DTVKAx6f.js → SharePointMetaStorage-WkQcni-I.js} +1 -1
  67. package/dist/packem_shared/{SharePointStorage-D1cWu-14.js → SharePointStorage-CZkO7FSl.js} +1 -1
  68. package/dist/packem_shared/{SupabaseMetaStorage-D_fGv0d6.js → SupabaseMetaStorage-FaEVpmT5.js} +1 -1
  69. package/dist/packem_shared/SupabaseStorage-O29RNXWx.js +1 -0
  70. package/dist/packem_shared/{Tus-BYTcw17H.js → Tus-B7k9LUeY.js} +1 -1
  71. package/dist/packem_shared/{Tus-BrP4RFTg.js → Tus-BZT2Jhl5.js} +1 -1
  72. package/dist/packem_shared/UploadControl-jgusdgDN.js +1 -0
  73. package/dist/packem_shared/{UploadThingMetaStorage-CAQ1uTfv.js → UploadThingMetaStorage-CdDfhiyy.js} +1 -1
  74. package/dist/packem_shared/UploadThingStorage-ByryGerX.js +1 -0
  75. package/dist/packem_shared/{VercelBlobMetaStorage-DY4zAB6M.js → VercelBlobMetaStorage-CC1zy35k.js} +1 -1
  76. package/dist/packem_shared/{VercelBlobStorage-u6xmp8ox.js → VercelBlobStorage-C4QUjBfu.js} +1 -1
  77. package/dist/packem_shared/{agentsListFiles-R-CnGKc4.js → agentsListFiles-Bl2TOnMy.js} +1 -1
  78. package/dist/packem_shared/aws-light-meta-storage-CXIZfLXR.js +4 -0
  79. package/dist/packem_shared/{azure-meta-storage-C4SrMtT2.js → azure-meta-storage-B-D-tBVw.js} +1 -1
  80. package/dist/packem_shared/{base-handler-core-Ccvdhx-k.js → base-handler-core-ty4J6Ji6.js} +1 -1
  81. package/dist/packem_shared/{base-handler-fetch-DzbThEWy.js → base-handler-fetch-BAjJyP84.js} +1 -1
  82. package/dist/packem_shared/{base-handler-node-CmCpLlBt.js → base-handler-node-BCqhH22o.js} +1 -1
  83. package/dist/packem_shared/{claudeListFiles-DAezbKEi.js → claudeListFiles-yLqM5iFS.js} +1 -1
  84. package/dist/packem_shared/{createResponsesFileTools-BCep-qdO.js → createResponsesFileTools-DFFHq35s.js} +1 -1
  85. package/dist/packem_shared/{defaultCloudStorageFileNameValidation-DwDn0XB5.js → defaultCloudStorageFileNameValidation-DSAf6C4S.js} +1 -1
  86. package/dist/packem_shared/detect-file-type-DRWGvQW4.js +1 -0
  87. package/dist/packem_shared/disk-storage-DJ2Nic2v.js +1 -0
  88. package/dist/packem_shared/{disk-storage-with-checksum.d-aYBmkg45.d.ts → disk-storage-with-checksum.d-BT_ll5b8.d.ts} +1 -1
  89. package/dist/packem_shared/executors-MzQbS9FT.js +1 -0
  90. package/dist/packem_shared/{executors.d-WGJGPSZs.d.ts → executors.d-D8esmhum.d.ts} +1 -1
  91. package/dist/packem_shared/{gcs-meta-storage-COq32th7.js → gcs-meta-storage-BXcsC7xV.js} +1 -1
  92. package/dist/packem_shared/{index.d-CYdFIB-w.d.ts → index.d-DB1VD8RP.d.ts} +229 -12
  93. package/dist/packem_shared/{listFiles-BtP6VnUp.js → listFiles-BNGQbV_d.js} +1 -1
  94. package/dist/packem_shared/{listFiles-B6VF05d-.js → listFiles-BdBngq3i.js} +1 -1
  95. package/dist/packem_shared/local-meta-storage-tayO1ARY.js +1 -0
  96. package/dist/packem_shared/{local-meta-storage.d-CuvN-KQ3.d.ts → local-meta-storage.d-DUuLtPik.d.ts} +1 -1
  97. package/dist/packem_shared/{media-transformer.d-DfU7VbFl.d.ts → media-transformer.d-B9dfBdoV.d.ts} +2 -2
  98. package/dist/packem_shared/{memory-storage.d-DRbE0WMO.d.ts → memory-storage.d-BpxSYO-D.d.ts} +1 -1
  99. package/dist/packem_shared/{path-D7rMc9nq-CPbxyMDy.js → path-D7rMc9nq-B718mbm6.js} +1 -1
  100. package/dist/packem_shared/{rest-base-xrnOBxS9.js → rest-base-BG0e-6E0.js} +1 -1
  101. package/dist/packem_shared/s3-base-storage-FiC4s91g.js +1 -0
  102. package/dist/packem_shared/{s3-base-storage.d-BrHiKWFw.d.ts → s3-base-storage.d-CoYAf_hG.d.ts} +21 -1
  103. package/dist/packem_shared/storage-CI88PmRw.js +1 -0
  104. package/dist/packem_shared/{storage.d-X6TimMHY.d.ts → storage.d-C6HtvSoY.d.ts} +43 -1
  105. package/dist/packem_shared/{tus-base.d-Ds7xYAJC.d.ts → tus-base.d-Dv25OXL0.d.ts} +3 -3
  106. package/dist/packem_shared/{types.d-a1grKnaX.d.ts → types.d-Cd2-3e-F.d.ts} +1 -1
  107. package/dist/packem_shared/{types.d-B72PbsLY.d.ts → types.d-CmBrgo0d.d.ts} +2 -2
  108. package/dist/packem_shared/{types.d-C4QumoP1.d.ts → types.d-CmT_ubPu.d.ts} +2 -2
  109. package/dist/storage/aws/index.d.ts +7 -2
  110. package/dist/storage/aws/index.js +1 -1
  111. package/dist/storage/aws-light/index.d.ts +7 -2
  112. package/dist/storage/aws-light/index.js +1 -1
  113. package/dist/storage/azure/index.d.ts +26 -7
  114. package/dist/storage/azure/index.js +1 -1
  115. package/dist/storage/box/index.d.ts +2 -2
  116. package/dist/storage/box/index.js +1 -1
  117. package/dist/storage/bun-s3/index.d.ts +2 -2
  118. package/dist/storage/bun-s3/index.js +1 -1
  119. package/dist/storage/bunny/index.d.ts +2 -2
  120. package/dist/storage/bunny/index.js +1 -1
  121. package/dist/storage/cloudinary/index.d.ts +2 -2
  122. package/dist/storage/cloudinary/index.js +1 -1
  123. package/dist/storage/dropbox/index.d.ts +2 -2
  124. package/dist/storage/dropbox/index.js +1 -1
  125. package/dist/storage/firebase/index.d.ts +2 -2
  126. package/dist/storage/firebase/index.js +1 -1
  127. package/dist/storage/ftp/index.d.ts +9 -3
  128. package/dist/storage/ftp/index.js +1 -1
  129. package/dist/storage/gcs/index.d.ts +15 -1
  130. package/dist/storage/gcs/index.js +1 -1
  131. package/dist/storage/google-drive/index.d.ts +2 -2
  132. package/dist/storage/google-drive/index.js +1 -1
  133. package/dist/storage/local/index.d.ts +3 -3
  134. package/dist/storage/local/index.js +1 -1
  135. package/dist/storage/memory/index.d.ts +2 -2
  136. package/dist/storage/memory/index.js +1 -1
  137. package/dist/storage/netlify-blob/index.d.ts +2 -2
  138. package/dist/storage/netlify-blob/index.js +1 -1
  139. package/dist/storage/onedrive/index.d.ts +4 -4
  140. package/dist/storage/onedrive/index.js +1 -1
  141. package/dist/storage/pocketbase/index.d.ts +2 -2
  142. package/dist/storage/pocketbase/index.js +1 -1
  143. package/dist/storage/sftp/index.d.ts +9 -3
  144. package/dist/storage/sftp/index.js +1 -1
  145. package/dist/storage/sharepoint/index.d.ts +3 -3
  146. package/dist/storage/sharepoint/index.js +1 -1
  147. package/dist/storage/supabase/index.d.ts +3 -3
  148. package/dist/storage/supabase/index.js +1 -1
  149. package/dist/storage/uploadthing/index.d.ts +2 -2
  150. package/dist/storage/uploadthing/index.js +1 -1
  151. package/dist/storage/vercel-blob/index.d.ts +2 -2
  152. package/dist/storage/vercel-blob/index.js +1 -1
  153. package/dist/transformer/audio-transformer.d.ts +2 -2
  154. package/dist/transformer/image-transformer.d.ts +2 -2
  155. package/dist/transformer/index.d.ts +3 -3
  156. package/dist/transformer/video-transformer.d.ts +2 -2
  157. package/package.json +2 -2
  158. package/dist/packem_shared/AzureSMetaStorage-CR-lfQNQ.js +0 -1
  159. package/dist/packem_shared/AzureStorage-B4E6VLn5.js +0 -1
  160. package/dist/packem_shared/BunS3Storage-BopE7kmX.js +0 -1
  161. package/dist/packem_shared/BunnyStorage-C3IBxJqr.js +0 -1
  162. package/dist/packem_shared/DiskStorage-BrAb28Je.js +0 -1
  163. package/dist/packem_shared/ERRORS-CyOuSMLY.js +0 -1
  164. package/dist/packem_shared/Files-tnc_buzM.js +0 -1
  165. package/dist/packem_shared/FirebaseStorage-Y9P6Dx8I.js +0 -2
  166. package/dist/packem_shared/FtpStorage-DCKPMX0z.js +0 -1
  167. package/dist/packem_shared/GCStorage-hfL1u2KQ.js +0 -1
  168. package/dist/packem_shared/GoogleDriveStorage-C7iuV7qb.js +0 -1
  169. package/dist/packem_shared/LocalMetaStorage-DSwsmdt7.js +0 -1
  170. package/dist/packem_shared/OneDriveStorage-CEGYb6OC.js +0 -1
  171. package/dist/packem_shared/S3Storage-7hG3izjU.js +0 -1
  172. package/dist/packem_shared/SftpStorage-DnigT9GT.js +0 -1
  173. package/dist/packem_shared/SupabaseStorage-DbIUa6NZ.js +0 -1
  174. package/dist/packem_shared/UploadThingStorage-B1qw1GrM.js +0 -1
  175. package/dist/packem_shared/aws-light-meta-storage-CstQBYXG.js +0 -4
  176. package/dist/packem_shared/default-BrhEhSqN.js +0 -1
  177. package/dist/packem_shared/detect-file-type-5JhzC9RU.js +0 -1
  178. package/dist/packem_shared/disk-storage-fWizVrge.js +0 -1
  179. package/dist/packem_shared/executors-DG6hGtvm.js +0 -1
  180. package/dist/packem_shared/local-meta-storage-Dr891Iy7.js +0 -1
  181. package/dist/packem_shared/s3-base-storage-CqAyWHR6.js +0 -1
  182. package/dist/packem_shared/storage-uhIhcN-O.js +0 -1
@@ -1,4 +1,4 @@
1
- import { O as OperationOptions, B as BaseStorage } from "./storage.d-X6TimMHY.js";
1
+ import { O as OperationOptions, B as BaseStorage } from "./storage.d-C6HtvSoY.js";
2
2
  /**
3
3
  * Web-standard and Node-native body types accepted by {@link Files.upload}.
4
4
  */
@@ -23,6 +23,65 @@ interface UploadProgress {
23
23
  total?: number;
24
24
  }
25
25
  type UploadProgressCallback = (event: UploadProgress) => void;
26
+ /** Lifecycle state of an {@link UploadControl}. */
27
+ type UploadControlState = "aborted" | "completed" | "idle" | "paused" | "uploading";
28
+ /**
29
+ * Serializable snapshot of an {@link UploadControl}, returned by {@link UploadControl.serialize}
30
+ * and accepted by {@link UploadControl.from}. Captures the key and bytes observed so a UI can
31
+ * restore progress display across reloads. Note: byte-accurate *resume* of the transfer itself is
32
+ * a protocol concern handled by the TUS / multipart handlers and `@visulima/storage-client`; a
33
+ * rehydrated control restarts the body from the beginning.
34
+ */
35
+ interface UploadControlToken {
36
+ key?: string;
37
+ loaded: number;
38
+ version: 1;
39
+ }
40
+ /**
41
+ * Pause / resume / abort handle threaded into {@link Files.upload} via {@link UploadOptions.control}.
42
+ *
43
+ * `pause()` applies backpressure to the body stream; `resume()` releases it. This is effective for
44
+ * streaming bodies feeding streaming adapters (S3, GCS, Azure, FTP/SFTP). Buffered adapters
45
+ * (memory, disk) read the whole body in one shot and cannot be paused mid-transfer.
46
+ * `abort()` cancels the operation through the merged {@link OperationOptions.signal}.
47
+ * `serialize()` / {@link UploadControl.from} round-trip the key + bytes observed for UI continuity.
48
+ * @example
49
+ * ```ts
50
+ * const control = new UploadControl();
51
+ * const promise = files.upload("big.bin", stream, { size, control });
52
+ * pauseButton.onclick = () => control.pause();
53
+ * resumeButton.onclick = () => control.resume();
54
+ * cancelButton.onclick = () => control.abort();
55
+ * await promise;
56
+ * ```
57
+ */
58
+ declare class UploadControl {
59
+ /** Caller-facing key being uploaded; populated once the upload starts. */
60
+ key?: string;
61
+ private readonly controller;
62
+ private internalState;
63
+ private loadedBytes;
64
+ private startPaused;
65
+ private boundStream?;
66
+ constructor(initial?: {
67
+ key?: string;
68
+ loaded?: number;
69
+ });
70
+ /**
71
+ * Rehydrate a control from a {@link serialize} token (object or JSON string). The returned
72
+ * control is `idle` with its `loaded` counter pre-seeded for progress display.
73
+ */
74
+ static from(token: UploadControlToken | string): UploadControl;
75
+ /** Abort signal merged into the upload operation. */
76
+ get signal(): AbortSignal;
77
+ get state(): UploadControlState;
78
+ /** Bytes observed leaving the facade so far. */
79
+ get loaded(): number;
80
+ pause(): void;
81
+ resume(): void;
82
+ abort(reason?: unknown): void;
83
+ serialize(): UploadControlToken;
84
+ }
26
85
  /**
27
86
  * Multipart tuning for {@link Files.upload}. `true` enables multipart with
28
87
  * adapter defaults; an object lets the caller tune the per-part size and the
@@ -36,6 +95,13 @@ interface MultipartOptions {
36
95
  }
37
96
  interface UploadOptions {
38
97
  contentType?: string;
98
+ /**
99
+ * Pause / resume / abort handle for this upload. Pausing applies backpressure to the body
100
+ * stream (effective for streaming bodies and streaming adapters; buffered adapters consume the
101
+ * whole body at once and cannot be paused mid-flight); aborting cancels the operation via the
102
+ * merged {@link OperationOptions.signal}. See {@link UploadControl}.
103
+ */
104
+ control?: UploadControl;
39
105
  metadata?: Record<string, unknown>;
40
106
  /**
41
107
  * Enable multipart/chunked upload for large bodies. `true` uses the
@@ -69,14 +135,45 @@ interface SignedUploadUrlOptions {
69
135
  expiresIn?: number;
70
136
  }
71
137
  interface ListOptions {
138
+ /**
139
+ * Collapse keys that share a path segment into S3-style common prefixes ("directories").
140
+ * When set, {@link Files.list} returns a {@link ListDirectoryResult} (`{ files, prefixes }`)
141
+ * instead of a flat array: keys with no further `delimiter` after the listing prefix come back
142
+ * as `files`, and everything below a shared boundary is folded into a single `prefixes` entry.
143
+ * Pass `"/"` for conventional folder semantics.
144
+ */
145
+ delimiter?: string;
72
146
  limit?: number;
73
147
  prefix?: string;
74
148
  }
149
+ /**
150
+ * Directory-style listing returned by {@link Files.list} when a `delimiter` is supplied.
151
+ */
152
+ interface ListDirectoryResult {
153
+ /** Objects that live directly under the listing prefix (no further delimiter). */
154
+ files: FileObject[];
155
+ /** Common prefixes ("subdirectories") one delimiter level below the listing prefix. */
156
+ prefixes: string[];
157
+ }
75
158
  interface ListAllOptions {
76
159
  /** Per-page size requested from the adapter. */
77
160
  limit?: number;
78
161
  prefix?: string;
79
162
  }
163
+ /**
164
+ * Capability snapshot for the adapter behind a {@link Files} instance, surfaced so callers can
165
+ * branch (or fail fast) instead of discovering an unsupported operation mid-flight.
166
+ */
167
+ interface StorageCapabilities {
168
+ /** The adapter honours an object `cacheControl` directive on write. */
169
+ cacheControl: boolean;
170
+ /** The adapter persists and returns user-supplied key/value metadata. */
171
+ metadata: boolean;
172
+ /** The adapter honours byte-range downloads (`download({ range })`). */
173
+ range: boolean;
174
+ /** This `Files` view rejects every mutating operation. */
175
+ readonly: boolean;
176
+ }
80
177
  interface DownloadOptions extends OperationOptions {
81
178
  /**
82
179
  * Fetch a contiguous byte slice instead of the whole object. Throws
@@ -160,6 +257,14 @@ interface FilesOptions<TStorage extends BaseStorage = BaseStorage> {
160
257
  * `users-archive/`.
161
258
  */
162
259
  prefix?: string;
260
+ /**
261
+ * When `true`, every mutating operation (`upload`, `delete`, `copy`, `move`, `signedUploadUrl`)
262
+ * fails immediately with `FilesError { code: "ReadOnly" }` before the adapter is touched; reads
263
+ * (`download`, `head`, `exists`, `list`, `listAll`, `url`) pass through. Derive a locked view of
264
+ * an existing client with {@link Files.readonly} instead of threading the flag manually.
265
+ * @default false
266
+ */
267
+ readonly?: boolean;
163
268
  }
164
269
  /**
165
270
  * One item in a bulk upload call.
@@ -266,8 +371,30 @@ declare class Files<TStorage extends BaseStorage = BaseStorage> {
266
371
  private readonly defaults;
267
372
  private readonly hooks;
268
373
  private readonly prefix;
374
+ private readonly readonlyMode;
269
375
  constructor(options: FilesOptions<TStorage>);
270
376
  /**
377
+ * Adapter capability + mode snapshot. Read before relying on an optional operation
378
+ * (`range` downloads, custom `metadata`, `cacheControl`) so callers can branch instead of
379
+ * hitting a `MethodNotAllowed` mid-flight. `readonly` reflects this view, not the adapter.
380
+ */
381
+ get capabilities(): StorageCapabilities;
382
+ /**
383
+ * Derive a read-only view sharing this instance's adapter, prefix, defaults, and hooks. Every
384
+ * mutating call on the returned client fails with `FilesError { code: "ReadOnly" }` before the
385
+ * adapter is touched. Cheaper and safer than handing a writable client to code that should only
386
+ * read.
387
+ * @example
388
+ * ```ts
389
+ * const ro = files.readonly();
390
+ * await ro.download("a.txt"); // ok
391
+ * await ro.delete("a.txt"); // throws ReadOnly
392
+ * ```
393
+ */
394
+ readonly(): Files<TStorage>;
395
+ /** Fail closed before any adapter mutation when this view is read-only. */
396
+ private assertWritable;
397
+ /**
271
398
  * Escape hatch to the adapter's native client (S3Client, BlobServiceClient, ...).
272
399
  * Typed via the `TStorage` parameter, so pinning the adapter type at construction yields a
273
400
  * typed view of the native client. Returns `undefined` when the adapter has no native client
@@ -359,12 +486,27 @@ declare class Files<TStorage extends BaseStorage = BaseStorage> {
359
486
  * keys outside the prefix namespace (e.g. `users-archive/` when prefix is `users`) are filtered
360
487
  * out. The optional `prefix` filter is interpreted *relative to the constructor prefix*.
361
488
  *
489
+ * Pass `delimiter` for directory-style listing: keys are collapsed into S3-style common
490
+ * prefixes and the call returns `{ files, prefixes }` instead of a flat array (see
491
+ * {@link ListDirectoryResult}). Objects with no further delimiter after the listing prefix come
492
+ * back as `files`; everything below a shared boundary folds into a single `prefixes` entry.
493
+ *
362
494
  * **Caveat with constructor prefix**: `limit` is applied by the underlying adapter *before*
363
495
  * the path-boundary filter runs, so the returned array may contain fewer than `limit` items
364
496
  * even when more in-namespace objects exist. Use {@link Files.listAll} when you need every
365
497
  * in-namespace object.
366
498
  */
367
- list(options?: ListOptions & OperationOptions): Promise<FileObject[]>;
499
+ list(options?: Omit<ListOptions, "delimiter"> & OperationOptions): Promise<FileObject[]>;
500
+ list(options: ListOptions & OperationOptions & {
501
+ delimiter: string;
502
+ }): Promise<ListDirectoryResult>;
503
+ /**
504
+ * Native directory listing: push the `delimiter` down to an adapter that collapses common
505
+ * prefixes server-side ({@link BaseStorage.supportsDelimiter}). Resolves the listing prefix
506
+ * against the constructor prefix, then strips it back off the returned keys and prefixes so the
507
+ * result matches the facade-synthesized shape.
508
+ */
509
+ private listDirectoryNative;
368
510
  /**
369
511
  * Walk every object in the bucket. Yields one {@link FileObject} at a time as an async
370
512
  * iterable; pages internally so callers don't have to thread a cursor. Returned keys have any
@@ -375,7 +517,6 @@ declare class Files<TStorage extends BaseStorage = BaseStorage> {
375
517
  * so this is effectively `list` + iteration for them. Adapters that paginate natively can
376
518
  * override `list` to honour the per-page `limit` and `listAll` will keep pulling pages until
377
519
  * the page is short.
378
- *
379
520
  * @example
380
521
  * ```ts
381
522
  * for await (const file of files.listAll({ prefix: "avatars/" })) {
@@ -408,6 +549,13 @@ interface TransferOptions extends OperationOptions {
408
549
  /** Fire-and-forget progress reporter. Throws are swallowed. */
409
550
  onProgress?: (event: TransferProgress) => void;
410
551
  /**
552
+ * When `false`, skip keys that already exist at the destination. When `true`, always upload.
553
+ * @default false
554
+ */
555
+ overwrite?: boolean;
556
+ /** Restrict the walk to this prefix on the source. */
557
+ prefix?: string;
558
+ /**
411
559
  * When `true`, the first failing transfer rejects {@link transfer} instead of being
412
560
  * collected in `errors`.
413
561
  * @default false
@@ -415,13 +563,6 @@ interface TransferOptions extends OperationOptions {
415
563
  stopOnError?: boolean;
416
564
  /** Transform each source key into the destination key. Defaults to identity. */
417
565
  transformKey?: (key: string) => string;
418
- /**
419
- * When `false`, skip keys that already exist at the destination. When `true`, always upload.
420
- * @default false
421
- */
422
- overwrite?: boolean;
423
- /** Restrict the walk to this prefix on the source. */
424
- prefix?: string;
425
566
  }
426
567
  interface TransferResult {
427
568
  errors?: BulkError[];
@@ -439,7 +580,6 @@ interface TransferResult {
439
580
  *
440
581
  * Like the other bulk methods, `transfer` doesn't throw on partial failure: results come back as
441
582
  * `{ transferred, skipped, errors? }`.
442
- *
443
583
  * @example
444
584
  * ```ts
445
585
  * const from = new Files({ adapter: new S3Storage({ bucket: "old", ... }) });
@@ -452,4 +592,81 @@ interface TransferResult {
452
592
  * ```
453
593
  */
454
594
  declare const transfer: (source: Files, destination: Files, options?: TransferOptions) => Promise<TransferResult>;
455
- export { BulkDeleteResult as B, DownloadOptions as D, Files as F, HookActionType as H, ListAllOptions as L, MultipartOptions as M, SignedReadUrlOptions as S, TransferOptions as T, UploadOptions as U, BulkDownloadOptions as a, BulkDownloadResult as b, BulkError as c, BulkExistsResult as d, BulkHeadResult as e, BulkMoveItem as f, BulkMoveResult as g, BulkOptions as h, BulkUploadItem as i, BulkUploadOptions as j, BulkUploadResult as k, DownloadRange as l, DownloadResult as m, FileBody as n, FileObject as o, FilesHooks as p, FilesOptions as q, HookEvent as r, ListOptions as s, SignedUploadUrlOptions as t, TransferProgress as u, TransferResult as v, UploadProgress as w, UploadProgressCallback as x, transfer as y };
595
+ /**
596
+ * Per-key event reported to {@link SyncOptions.onProgress}.
597
+ */
598
+ interface SyncProgress {
599
+ /** 1-based index of the current key in walk order. */
600
+ done: number;
601
+ error?: Error;
602
+ key: string;
603
+ status: "deleted" | "errored" | "skipped" | "unchanged" | "updated" | "uploaded";
604
+ }
605
+ interface SyncOptions extends OperationOptions {
606
+ /**
607
+ * In-flight key operations.
608
+ * @default 8
609
+ */
610
+ concurrency?: number;
611
+ /**
612
+ * Compute the plan without writing anything. The returned `uploaded`/`updated`/`deleted` lists
613
+ * describe what *would* happen; the destination is left untouched.
614
+ * @default false
615
+ */
616
+ dryRun?: boolean;
617
+ /** Per-page size requested from the source adapter while walking. */
618
+ limit?: number;
619
+ /** Fire-and-forget progress reporter. Throws are swallowed. */
620
+ onProgress?: (event: SyncProgress) => void;
621
+ /** Restrict the sync to this prefix on both source and destination. */
622
+ prefix?: string;
623
+ /**
624
+ * Delete destination keys that no longer exist on the source (mirror semantics). Pruning runs
625
+ * after the copy pass so a failed upload never triggers a delete of its counterpart.
626
+ * @default false
627
+ */
628
+ prune?: boolean;
629
+ /**
630
+ * When `true`, the first failing operation rejects {@link sync} instead of being collected in
631
+ * `errors`. Pruning is skipped when a copy-phase error stops the run.
632
+ * @default false
633
+ */
634
+ stopOnError?: boolean;
635
+ /** Transform each source key into the destination key. Defaults to identity. */
636
+ transformKey?: (key: string) => string;
637
+ }
638
+ interface SyncResult {
639
+ /** Destination keys removed because they were absent from the source (only when `prune`). */
640
+ deleted: string[];
641
+ errors?: BulkError[];
642
+ /** Source keys whose destination copy already matched and was left untouched. */
643
+ unchanged: string[];
644
+ /** Source keys re-uploaded because the destination copy differed. */
645
+ updated: string[];
646
+ /** Source keys newly created at the destination. */
647
+ uploaded: string[];
648
+ }
649
+ /**
650
+ * Incremental, optionally-pruning mirror from `source` to `destination`. Built entirely on the
651
+ * public {@link Files} surface — no adapter implements anything new.
652
+ *
653
+ * Each source object is compared against its destination counterpart (by size, then etag, then
654
+ * modification time) and only copied when missing or differing; matching objects are skipped. With
655
+ * `prune: true`, destination keys absent from the source are deleted afterwards (full mirror).
656
+ * Pass `dryRun: true` to compute the plan without writing.
657
+ *
658
+ * Like the other bulk methods, `sync` doesn't throw on partial failure: results come back as
659
+ * `{ uploaded, updated, unchanged, deleted, errors? }`.
660
+ * @example
661
+ * ```ts
662
+ * const from = new Files({ adapter: new S3Storage({ bucket: "primary", ... }) });
663
+ * const to = new Files({ adapter: new GCSStorage({ bucket: "mirror", ... }) });
664
+ *
665
+ * // Preview first…
666
+ * const plan = await sync(from, to, { prefix: "assets/", prune: true, dryRun: true });
667
+ * // …then apply.
668
+ * const result = await sync(from, to, { prefix: "assets/", prune: true });
669
+ * ```
670
+ */
671
+ declare const sync: (source: Files, destination: Files, options?: SyncOptions) => Promise<SyncResult>;
672
+ export { TransferResult as A, BulkDeleteResult as B, UploadControlState as C, DownloadOptions as D, UploadControlToken as E, Files as F, UploadOptions as G, HookActionType as H, UploadProgress as I, UploadProgressCallback as J, sync as K, ListAllOptions as L, MultipartOptions as M, transfer as N, SignedReadUrlOptions as S, TransferOptions as T, UploadControl as U, BulkDownloadOptions as a, BulkDownloadResult as b, BulkError as c, BulkExistsResult as d, BulkHeadResult as e, BulkMoveItem as f, BulkMoveResult as g, BulkOptions as h, BulkUploadItem as i, BulkUploadOptions as j, BulkUploadResult as k, DownloadRange as l, DownloadResult as m, FileBody as n, FileObject as o, FilesHooks as p, FilesOptions as q, HookEvent as r, ListDirectoryResult as s, ListOptions as t, SignedUploadUrlOptions as u, StorageCapabilities as v, SyncOptions as w, SyncProgress as x, SyncResult as y, TransferProgress as z };
@@ -1 +1 @@
1
- var a=Object.defineProperty;var n=(e,i)=>a(e,"name",{value:i,configurable:!0});import{tool as p}from"ai";import{T as t,e as o}from"./executors-DG6hGtvm.js";var r=Object.defineProperty,l=n((e,i)=>r(e,"name",{value:i,configurable:!0}),"i");const F=l(e=>p({description:t.listFiles.description,execute:l(i=>o.listFiles(e,i),"execute"),inputSchema:t.listFiles.input}),"listFiles"),x=l(e=>p({description:t.getFileMetadata.description,execute:l(i=>o.getFileMetadata(e,i),"execute"),inputSchema:t.getFileMetadata.input}),"getFileMetadata"),g=l(e=>p({description:t.downloadFile.description,execute:l(i=>o.downloadFile(e,i),"execute"),inputSchema:t.downloadFile.input}),"downloadFile"),U=l(e=>p({description:t.getFileUrl.description,execute:l(i=>o.getFileUrl(e,i),"execute"),inputSchema:t.getFileUrl.input}),"getFileUrl"),m=l((e,{needsApproval:i=!0}={})=>p({description:t.uploadFile.description,execute:l(d=>o.uploadFile(e,d),"execute"),inputSchema:t.uploadFile.input,needsApproval:i}),"uploadFile"),v=l((e,{needsApproval:i=!0}={})=>p({description:t.deleteFile.description,execute:l(d=>o.deleteFile(e,d),"execute"),inputSchema:t.deleteFile.input,needsApproval:i}),"deleteFile"),S=l((e,{needsApproval:i=!0}={})=>p({description:t.copyFile.description,execute:l(d=>o.copyFile(e,d),"execute"),inputSchema:t.copyFile.input,needsApproval:i}),"copyFile"),A=l((e,{needsApproval:i=!0}={})=>p({description:t.signUploadUrl.description,execute:l(d=>o.signUploadUrl(e,d),"execute"),inputSchema:t.signUploadUrl.input,needsApproval:i}),"signUploadUrl");export{S as copyFile,v as deleteFile,g as downloadFile,x as getFileMetadata,U as getFileUrl,F as listFiles,A as signUploadUrl,m as uploadFile};
1
+ var a=Object.defineProperty;var n=(e,i)=>a(e,"name",{value:i,configurable:!0});import{tool as p}from"ai";import{T as t,e as o}from"./executors-MzQbS9FT.js";var r=Object.defineProperty,l=n((e,i)=>r(e,"name",{value:i,configurable:!0}),"i");const F=l(e=>p({description:t.listFiles.description,execute:l(i=>o.listFiles(e,i),"execute"),inputSchema:t.listFiles.input}),"listFiles"),x=l(e=>p({description:t.getFileMetadata.description,execute:l(i=>o.getFileMetadata(e,i),"execute"),inputSchema:t.getFileMetadata.input}),"getFileMetadata"),g=l(e=>p({description:t.downloadFile.description,execute:l(i=>o.downloadFile(e,i),"execute"),inputSchema:t.downloadFile.input}),"downloadFile"),U=l(e=>p({description:t.getFileUrl.description,execute:l(i=>o.getFileUrl(e,i),"execute"),inputSchema:t.getFileUrl.input}),"getFileUrl"),m=l((e,{needsApproval:i=!0}={})=>p({description:t.uploadFile.description,execute:l(d=>o.uploadFile(e,d),"execute"),inputSchema:t.uploadFile.input,needsApproval:i}),"uploadFile"),v=l((e,{needsApproval:i=!0}={})=>p({description:t.deleteFile.description,execute:l(d=>o.deleteFile(e,d),"execute"),inputSchema:t.deleteFile.input,needsApproval:i}),"deleteFile"),S=l((e,{needsApproval:i=!0}={})=>p({description:t.copyFile.description,execute:l(d=>o.copyFile(e,d),"execute"),inputSchema:t.copyFile.input,needsApproval:i}),"copyFile"),A=l((e,{needsApproval:i=!0}={})=>p({description:t.signUploadUrl.description,execute:l(d=>o.signUploadUrl(e,d),"execute"),inputSchema:t.signUploadUrl.input,needsApproval:i}),"signUploadUrl");export{S as copyFile,v as deleteFile,g as downloadFile,x as getFileMetadata,U as getFileUrl,F as listFiles,A as signUploadUrl,m as uploadFile};
@@ -1 +1 @@
1
- var o=Object.defineProperty;var n=(e,i)=>o(e,"name",{value:i,configurable:!0});import{toolDefinition as t}from"@tanstack/ai";import{T as l,e as p}from"./executors-DG6hGtvm.js";var d=Object.defineProperty,r=n((e,i)=>d(e,"name",{value:i,configurable:!0}),"i");const u=r(e=>t({description:l.listFiles.description,inputSchema:l.listFiles.input,name:"listFiles"}).server(i=>p.listFiles(e,i)),"listFiles"),m=r(e=>t({description:l.getFileMetadata.description,inputSchema:l.getFileMetadata.input,name:"getFileMetadata"}).server(i=>p.getFileMetadata(e,i)),"getFileMetadata"),g=r(e=>t({description:l.downloadFile.description,inputSchema:l.downloadFile.input,name:"downloadFile"}).server(i=>p.downloadFile(e,i)),"downloadFile"),v=r(e=>t({description:l.getFileUrl.description,inputSchema:l.getFileUrl.input,name:"getFileUrl"}).server(i=>p.getFileUrl(e,i)),"getFileUrl"),U=r((e,{needsApproval:i=!0}={})=>t({description:l.uploadFile.description,inputSchema:l.uploadFile.input,name:"uploadFile",needsApproval:i}).server(a=>p.uploadFile(e,a)),"uploadFile"),S=r((e,{needsApproval:i=!0}={})=>t({description:l.deleteFile.description,inputSchema:l.deleteFile.input,name:"deleteFile",needsApproval:i}).server(a=>p.deleteFile(e,a)),"deleteFile"),A=r((e,{needsApproval:i=!0}={})=>t({description:l.copyFile.description,inputSchema:l.copyFile.input,name:"copyFile",needsApproval:i}).server(a=>p.copyFile(e,a)),"copyFile"),h=r((e,{needsApproval:i=!0}={})=>t({description:l.signUploadUrl.description,inputSchema:l.signUploadUrl.input,name:"signUploadUrl",needsApproval:i}).server(a=>p.signUploadUrl(e,a)),"signUploadUrl");export{A as copyFile,S as deleteFile,g as downloadFile,m as getFileMetadata,v as getFileUrl,u as listFiles,h as signUploadUrl,U as uploadFile};
1
+ var o=Object.defineProperty;var n=(e,i)=>o(e,"name",{value:i,configurable:!0});import{toolDefinition as t}from"@tanstack/ai";import{T as l,e as p}from"./executors-MzQbS9FT.js";var d=Object.defineProperty,r=n((e,i)=>d(e,"name",{value:i,configurable:!0}),"i");const u=r(e=>t({description:l.listFiles.description,inputSchema:l.listFiles.input,name:"listFiles"}).server(i=>p.listFiles(e,i)),"listFiles"),m=r(e=>t({description:l.getFileMetadata.description,inputSchema:l.getFileMetadata.input,name:"getFileMetadata"}).server(i=>p.getFileMetadata(e,i)),"getFileMetadata"),g=r(e=>t({description:l.downloadFile.description,inputSchema:l.downloadFile.input,name:"downloadFile"}).server(i=>p.downloadFile(e,i)),"downloadFile"),v=r(e=>t({description:l.getFileUrl.description,inputSchema:l.getFileUrl.input,name:"getFileUrl"}).server(i=>p.getFileUrl(e,i)),"getFileUrl"),U=r((e,{needsApproval:i=!0}={})=>t({description:l.uploadFile.description,inputSchema:l.uploadFile.input,name:"uploadFile",needsApproval:i}).server(a=>p.uploadFile(e,a)),"uploadFile"),S=r((e,{needsApproval:i=!0}={})=>t({description:l.deleteFile.description,inputSchema:l.deleteFile.input,name:"deleteFile",needsApproval:i}).server(a=>p.deleteFile(e,a)),"deleteFile"),A=r((e,{needsApproval:i=!0}={})=>t({description:l.copyFile.description,inputSchema:l.copyFile.input,name:"copyFile",needsApproval:i}).server(a=>p.copyFile(e,a)),"copyFile"),h=r((e,{needsApproval:i=!0}={})=>t({description:l.signUploadUrl.description,inputSchema:l.signUploadUrl.input,name:"signUploadUrl",needsApproval:i}).server(a=>p.signUploadUrl(e,a)),"signUploadUrl");export{A as copyFile,S as deleteFile,g as downloadFile,m as getFileMetadata,v as getFileUrl,u as listFiles,h as signUploadUrl,U as uploadFile};
@@ -0,0 +1 @@
1
+ var re=Object.defineProperty;var o=(e,t)=>re(e,"name",{value:t,configurable:!0});import{utimes as ae}from"node:fs/promises";import{tmpdir as oe}from"node:os";import{createRequire as m}from"node:module";import{A as T,M as _,J as ie,K as ne,L as R}from"./path-D7rMc9nq-B718mbm6.js";import{throwErrorCode as j,ERRORS as P}from"./ERRORS-vMSqlI69.js";import se from"./MetaStorage-Y4m1dWgd.js";import{stringifyMetadata as ce,parseMetadata as ue}from"./Metadata-B6Ir0KO7.js";const E=0,le=4;var fe=Object.defineProperty,pe=o((e,t)=>fe(e,"name",{value:t,configurable:!0}),"t$6"),me=Object.defineProperty,de=pe((e,t)=>me(e,"name",{value:t,configurable:!0}),"t"),ge=Object.defineProperty,be=de((e,t)=>ge(e,"name",{value:t,configurable:!0}),"n");const $=be(e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},"assertValidFileOrDirectoryPath");var ve=Object.defineProperty,ye=o((e,t)=>ve(e,"name",{value:t,configurable:!0}),"i$8"),he=Object.defineProperty,$e=ye((e,t)=>he(e,"name",{value:t,configurable:!0}),"r"),we=Object.defineProperty,Oe=$e((e,t)=>we(e,"name",{value:t,configurable:!0}),"i");const S=Oe(e=>{if(e.isFile())return"file";if(e.isDirectory())return"dir";if(e.isSymbolicLink())return"symlink"},"getFileInfoType");var je=Object.defineProperty,Pe=o((e,t)=>je(e,"name",{value:t,configurable:!0}),"i$7"),xe=Object.defineProperty,q=Pe((e,t)=>xe(e,"name",{value:t,configurable:!0}),"s");const Ee=m(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Te=q(e=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[t,r]=d.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return d.getBuiltinModule(e)}return Ee(e)},"__cjs_getBuiltinModule"),{lstat:I,mkdir:_e}=Te("node:fs/promises");var Me=Object.defineProperty,ke=q((e,t)=>Me(e,"name",{value:t,configurable:!0}),"o");const Ne=ke(async e=>{$(e);try{const t=await I(e);if(!t.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(S(t))}'`);return}catch(t){if(t.code!=="ENOENT")throw t}try{await _e(e,{recursive:!0})}catch(t){if(t.code!=="EEXIST")throw t;const r=await I(e);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(S(r))}'`,{cause:t})}},"ensureDir");var ze=Object.defineProperty,l=o((e,t)=>ze(e,"name",{value:t,configurable:!0}),"n$6"),Be=Object.defineProperty,s=l((e,t)=>Be(e,"name",{value:t,configurable:!0}),"a");const Fe=m(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ae=s(e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[t,r]=g.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return g.getBuiltinModule(e)}return Fe(e)},"__cjs_getBuiltinModule"),{fileURLToPath:De}=Ae("node:url");var Re=Object.defineProperty,p=s((e,t)=>Re(e,"name",{value:t,configurable:!0}),"t$1");function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o(O,"m$2");l(O,"d");s(O,"getDefaultExportFromCjs");p(O,"getDefaultExportFromCjs");function M(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o(M,"h$1");l(M,"O");s(M,"getDefaultExportFromNamespaceIfPresent");p(M,"getDefaultExportFromNamespaceIfPresent");function k(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.keys(e).length===1?e.default:e}o(k,"x");l(k,"P");s(k,"getDefaultExportFromNamespaceIfNotNamed");p(k,"getDefaultExportFromNamespaceIfNotNamed");function N(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var r=p(s(l(o(function a(){var i=!1;try{i=this instanceof a}catch{}return i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)},"a"),"s"),"a"),"a");r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(a){var i=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(r,a,i.get?i:{enumerable:!0,get:p(function(){return e[a]},"get")})}),r}o(N,"y$2");l(N,"_");s(N,"getAugmentedNamespace");p(N,"getAugmentedNamespace");var L,U;function z(){return U||(U=1,L=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),L}o(z,"w$2");l(z,"k");s(z,"requireBinaryExtensions");var Se=z();const Ie=O(Se);var Le=Object.defineProperty,n=s((e,t)=>Le(e,"name",{value:t,configurable:!0}),"r");const Ue=new Set(Ie),Ce=new Set(["/","\\",void 0]),C=Symbol.for("pathe:normalizedAlias"),We=/(^|[/\\])([^/\\]+?)(?=(?:\.[^.]+)?$)/,qe=n((e,t)=>t.split("/").length-e.split("/").length,"compareAliases"),w=n((e="/")=>{const t=e.at(-1);return t==="/"||t==="\\"},"hasTrailingSlash"),V=n(e=>{if(e[C])return e;const t=Object.fromEntries(Object.entries(e).toSorted(([r],[a])=>qe(r,a)));for(const r in t)for(const a in t)a===r||r.startsWith(a)||t[r].startsWith(a)&&Ce.has(t[r][a.length])&&(t[r]=t[a]+t[r].slice(a.length));return Object.defineProperty(t,C,{enumerable:!1,value:!0}),t},"normalizeAliases");n((e,t)=>{e=T(e),t=V(t);for(const[r,a]of Object.entries(t)){if(!e.startsWith(r))continue;const i=w(r)?r.slice(0,-1):r;if(w(e[i.length]))return _(a,e.slice(r.length))}return e},"resolveAlias");n(e=>We.exec(e)?.[2],"filename");n((e,t)=>{e=T(e),t=V(t);for(const[r,a]of Object.entries(t).toReversed()){if(!e.startsWith(a))continue;const i=w(a)?a.slice(0,-1):a;if(w(e[i.length]))return _(r,e.slice(a.length))}return e},"reverseResolveAlias");const Ve=/^(?:\.?\.[/\\]|\.\.\B)/,Je=/^(?:msys|cygwin)$/;n(e=>Ve.test(e)||e==="..","isRelative");n(e=>Ue.has(ie(e).slice(1).toLowerCase()),"isBinaryPath");const B=n(e=>T(e instanceof URL?De(e):e),"toPath");n(()=>{if(!globalThis.process)return!1;if(globalThis.process.platform==="win32"||globalThis.process.platform==="cygwin")return!0;const e=globalThis.process.env.OSTYPE;return typeof e!="string"?!1:Je.test(e)},"isWindows");var Ke=Object.defineProperty,J=o((e,t)=>Ke(e,"name",{value:t,configurable:!0}),"t$4"),Xe=Object.defineProperty,F=J((e,t)=>Xe(e,"name",{value:t,configurable:!0}),"s");const Ye=m(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ge=F(e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,r]=b.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return b.getBuiltinModule(e)}return Ye(e)},"__cjs_getBuiltinModule"),{access:He}=Ge("node:fs/promises");var Qe=Object.defineProperty,Ze=F((e,t)=>Qe(e,"name",{value:t,configurable:!0}),"o");async function u(e,t=E){$(e),e=B(e);try{return await He(e,t),!0}catch{return!1}}o(u,"i$5");J(u,"d");F(u,"m");Ze(u,"isAccessible");var et=Object.defineProperty,K=o((e,t)=>et(e,"name",{value:t,configurable:!0}),"t$3"),tt=Object.defineProperty,X=K((e,t)=>tt(e,"name",{value:t,configurable:!0}),"t"),rt=Object.defineProperty,at=X((e,t)=>rt(e,"name",{value:t,configurable:!0}),"o");let ot=class extends Error{static{o(this,"c")}static{K(this,"i")}static{X(this,"n")}static{at(this,"PermissionError")}constructor(t){super(`EPERM: Operation not permitted, ${t}`)}get code(){return"EPERM"}set code(t){throw new Error("Cannot overwrite code EPERM")}get name(){return"PermissionError"}set name(t){throw new Error("Cannot overwrite name of PermissionError")}};var it=Object.defineProperty,nt=o((e,t)=>it(e,"name",{value:t,configurable:!0}),"l$2"),st=Object.defineProperty,Y=nt((e,t)=>st(e,"name",{value:t,configurable:!0}),"i");const ct=m(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=Y(e=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[t,r]=v.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return v.getBuiltinModule(e)}return ct(e)},"__cjs_getBuiltinModule"),{readFile:ut}=G("node:fs/promises"),{unzip:lt,brotliDecompress:ft}=G("node:zlib");var pt=Object.defineProperty,H=Y((e,t)=>pt(e,"name",{value:t,configurable:!0}),"n");const mt={brotli:ft,gzip:lt,none:H((e,t)=>{t(null,e)},"none")},dt=H(async(e,t)=>{if($(e),e=B(e),!await u(e))throw new ot(`unable to read the non-accessible file: ${e}`);if(!await u(e,le))throw new Error(`Unable to read the non-readable file: ${e}`);const{buffer:r,compression:a,encoding:i,flag:c}=t??{};return await ut(e,c?{flag:c}:{}).then(async f=>await new Promise((ee,te)=>{mt[a??"none"](f,(A,D)=>{A?te(A):ee(r?D:D.toString(i??"utf8"))})})).catch(f=>{throw f})},"readFile");var gt=Object.defineProperty,bt=o((e,t)=>gt(e,"name",{value:t,configurable:!0}),"a$4"),vt=Object.defineProperty,yt=bt((e,t)=>vt(e,"name",{value:t,configurable:!0}),"t"),ht=Object.defineProperty,$t=yt((e,t)=>ht(e,"name",{value:t,configurable:!0}),"t");const wt=$t(e=>{const t={force:!0,recursive:!0};return e?.maxRetries!==void 0&&(t.maxRetries=e.maxRetries),e?.retryDelay!==void 0&&(t.retryDelay=e.retryDelay),t},"buildRmOptions");var Ot=Object.defineProperty,jt=o((e,t)=>Ot(e,"name",{value:t,configurable:!0}),"i$2"),Pt=Object.defineProperty,Q=jt((e,t)=>Pt(e,"name",{value:t,configurable:!0}),"s");const xt=m(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Et=Q(e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[t,r]=y.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return y.getBuiltinModule(e)}return xt(e)},"__cjs_getBuiltinModule"),{unlink:Tt,rm:_t}=Et("node:fs/promises");var Mt=Object.defineProperty,kt=Q((e,t)=>Mt(e,"name",{value:t,configurable:!0}),"i");const Nt=kt(async(e,t={})=>{$(e);try{await Tt(e)}catch{}try{await _t(e,wt(t))}catch{}},"remove");var zt=Object.defineProperty,Bt=o((e,t)=>zt(e,"name",{value:t,configurable:!0}),"a$2"),Ft=Object.defineProperty,At=Bt((e,t)=>Ft(e,"name",{value:t,configurable:!0}),"t"),Dt=Object.defineProperty,Rt=At((e,t)=>Dt(e,"name",{value:t,configurable:!0}),"e");const St=Rt(e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},"assertValidFileContents");var It=Object.defineProperty,Lt=o((e,t)=>It(e,"name",{value:t,configurable:!0}),"t"),Ut=Object.defineProperty,Ct=Lt((e,t)=>Ut(e,"name",{value:t,configurable:!0}),"r"),Wt=Object.defineProperty,qt=Ct((e,t)=>Wt(e,"name",{value:t,configurable:!0}),"f");const Vt=new TextEncoder,Jt=qt(e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return Vt.encode(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e)){const t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},"toUint8Array");var Kt=Object.defineProperty,Xt=o((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"c"),Yt=Object.defineProperty,Z=Xt((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"n");const Gt=m(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ht=Z(e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[t,r]=h.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return h.getBuiltinModule(e)}return Gt(e)},"__cjs_getBuiltinModule"),{mkdir:Qt,writeFile:Zt,stat:er,rename:W,chown:tr,chmod:rr,unlink:ar}=Ht("node:fs/promises");var or=Object.defineProperty,ir=Z((e,t)=>or(e,"name",{value:t,configurable:!0}),"w");const nr=ir(async(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},$(e),St(t),e=B(e);const a=`${e}.tmp`;try{const i=await u(e,E);if(!i&&r.recursive){const f=ne(e);await u(f,E)||await Qt(f,{recursive:!0})}let c;if(await Zt(a,typeof t=="string"?Buffer.from(t,r.encoding??"utf8"):Jt(t),{flag:r.flag}),i&&!r.overwrite&&(c=await er(e),r.chown??={gid:c.gid,uid:c.uid},await W(e,`${e}.bak`)),r.chown)try{await tr(a,r.chown.uid,r.chown.gid)}catch{}await rr(a,c&&!r.mode?c.mode:r.mode??438),await W(a,e)}catch(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{await u(a)&&await ar(`${e}.tmp`)}},"writeFile");var sr=Object.defineProperty,x=o((e,t)=>sr(e,"name",{value:t,configurable:!0}),"a");let vr=class extends se{static{o(this,"v")}static{x(this,"LocalMetaStorage")}directory;constructor(t){super(t),this.directory=R(t?.directory||_(oe(),"Upload_meta")),this.accessCheck().catch(r=>{this.logger?.error("Metadata storage access check failed: %O",r)})}getMetaPath=x(t=>{const r=R(`${this.directory}/${this.prefix}${t}${this.suffix}`),a=this.directory.endsWith("/")?this.directory:`${this.directory}/`;return r.startsWith(a)?r:j(P.INVALID_FILE_NAME,`Invalid id: "${t}" resolves outside the meta directory`)},"getMetaPath");getIdFromPath=x(t=>t.slice(`${this.directory}/${this.prefix}`.length,-this.suffix.length),"getIdFromPath");async save(t,r){await this.accessCheck();const a={...r};return a.metadata&&(a.metadata=ce(r.metadata)),await nr(this.getMetaPath(t),JSON.stringify(a),{recursive:!0}),r}async touch(t,r){const a=new Date;return await ae(this.getMetaPath(t),a,a),r}async get(t){try{const r=await dt(this.getMetaPath(t));if(r===void 0)throw j(P.FILE_NOT_FOUND);const a=JSON.parse(r);return a.metadata&&typeof a.metadata=="string"&&(a.metadata=ue(a.metadata)),a}catch(r){const a=r,i=r instanceof SyntaxError;throw a.code==="ENOENT"||i?j(P.FILE_NOT_FOUND):r}}async delete(t){await Nt(this.getMetaPath(t))}async accessCheck(){await Ne(this.directory)}};export{dt as E,B as U,E as _,$ as f,u as i,S as l,vr as v,Ne as w,Nt as y};
@@ -1,4 +1,4 @@
1
- import { F as File, L as LocalMetaStorageOptions, M as MetaStorage } from "./storage.d-X6TimMHY.js";
1
+ import { F as File, L as LocalMetaStorageOptions, M as MetaStorage } from "./storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
3
  /**
4
4
  * Stores upload metafiles on local disk
@@ -1,5 +1,5 @@
1
- import { F as File, a as FileReturn, B as BaseStorage } from "./storage.d-X6TimMHY.js";
2
- import { M as MediaTransformerConfig, g as MediaTransformResult } from "./types.d-C4QumoP1.js";
1
+ import { F as File, a as FileReturn, B as BaseStorage } from "./storage.d-C6HtvSoY.js";
2
+ import { O as MediaTransformerConfig, Q as MediaTransformResult } from "./types.d-CmT_ubPu.js";
3
3
  /**
4
4
  * Unified media transformer that automatically detects media type and routes to appropriate transformer.
5
5
  * @template TFile The file type used by this transformer.
@@ -1,5 +1,5 @@
1
1
  import { Readable } from 'node:stream';
2
- import { F as File, h as MetaStorageOptions, M as MetaStorage, i as BaseStorageOptions, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "./storage.d-X6TimMHY.js";
2
+ import { F as File, i as MetaStorageOptions, M as MetaStorage, j as BaseStorageOptions, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "./storage.d-C6HtvSoY.js";
3
3
  /**
4
4
  * Map-backed metadata storage used by {@link MemoryStorage}. Holds a deep-copied
5
5
  * snapshot of each `File` so callers can mutate the returned object without leaking
@@ -1 +1 @@
1
- var Vt=Object.defineProperty;var he=(s,u)=>Vt(s,"name",{value:u,configurable:!0});var Ht=Object.defineProperty,Jt=he((s,u)=>Ht(s,"name",{value:u,configurable:!0}),"$e"),Kt=Object.defineProperty,V=Jt((s,u)=>Kt(s,"name",{value:u,configurable:!0}),"W"),Qt=Object.defineProperty,a=V((s,u)=>Qt(s,"name",{value:u,configurable:!0}),"u$1");let ge=a(()=>{var s=(()=>{var u=Object.defineProperty,c=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,b=a((e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},"ne"),A=a((e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of p(t))!g.call(e,r)&&r!==n&&u(e,r,{get:a(()=>t[r],"get"),enumerable:!(o=c(t,r))||o.enumerable});return e},"ae"),m=a(e=>A(u({},"__esModule",{value:!0}),e),"oe"),P={};b(P,{zeptomatch:a(()=>pe,"zeptomatch")});var H=a(e=>{const t=new Set,n=[e];for(let o=0;o<n.length;o++){const r=n[o];if(t.has(r))continue;t.add(r);const{children:l}=r;if(l?.length)for(let i=0,h=l.length;i<h;i++)n.push(l[i])}return Array.from(t)},"M"),be=a(e=>{let t="";const n=H(e);for(let o=0,r=n.length;o<r;o++){const l=n[o];if(!l.regex)continue;const i=l.regex.flags;if(t||(t=i),t!==i)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${i}"`)}return t},"se"),J=a((e,t,n)=>{const o=n.get(e);if(o!==void 0)return o;const r=e.partial??t;let l="";if(e.regex&&(l+=r?"(?:$|":"",l+=e.regex.source),e.children?.length){const i=ve(e.children.map(h=>J(h,t,n)).filter(Boolean));if(i?.length){const h=e.children.some(W=>!W.regex||!(W.partial??t)),x=i.length>1||r&&(!l.length||h);l+=x?r?"(?:$|":"(?:":"",l+=i.join("|"),l+=x?")":""}}return e.regex&&(l+=r?")":""),n.set(e,l),l},"O"),we=a((e,t)=>{const n=new Map,o=H(e);for(let r=o.length-1;r>=0;r--){const l=J(o[r],t,n);if(!(r>0))return l}return""},"ie"),ve=a(e=>Array.from(new Set(e)),"ue"),S=a((e,t,n)=>S.compile(e,n).test(t),"R");S.compile=(e,t)=>{const n=t?.partial??!1,o=we(e,n),r=be(e);return new RegExp(`^(?:${o})$`,r)};var ye=S,je=a((e,t)=>{const n=ye.compile(e,t),o=`${n.source.slice(0,-1)}[\\\\/]?$`,r=n.flags;return new RegExp(o,r)},"le"),Me=je,Ae=a(e=>{const t=e.map(o=>o.source).join("|")||"$^",n=e[0]?.flags;return new RegExp(t,n)},"ve"),ze=Ae,K=a(e=>Array.isArray(e),"j"),R=a(e=>typeof e=="function","_"),ke=a(e=>e.length===0,"he"),Oe=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return n=>(n.length===0||n.length===1)&&t.test(e.call(n))})(),Ee=a(e=>typeof e=="number","de"),Ie=a(e=>typeof e=="object"&&e!==null,"xe"),Pe=a(e=>e instanceof RegExp,"me"),Re=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),Be=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),Q=a(e=>typeof e=="string","A"),y=a(e=>e===void 0,"f"),We=a(e=>{const t=new Map;return n=>{const o=t.get(n);if(o!==void 0)return o;const r=e(n);return t.set(n,r),r}},"ye"),T=a((e,t,n={})=>{const o={cache:{},input:e,index:0,indexBacktrackMax:0,options:n,output:[]},r=j(t)(o),l=Math.max(o.index,o.indexBacktrackMax);if(r&&o.index===e.length)return o.output;throw new Error(`Failed to parse at index ${l}`)},"I"),f=a((e,t)=>K(e)?Ze(e,t):Q(e)?X(e,t):_e(e,t),"i"),Ze=a((e,t)=>{const n={};for(const o of e){if(o.length!==1)throw new Error(`Invalid character: "${o}"`);const r=o.charCodeAt(0);n[r]=!0}return o=>{const r=o.input;let l=o.index,i=l;for(;i<r.length&&r.charCodeAt(i)in n;)i+=1;if(i>l){if(!y(t)&&!o.options.silent){const h=r.slice(l,i),x=R(t)?t(h,r,`${l}`):t;y(x)||o.output.push(x)}o.index=i}return!0}},"we"),_e=a((e,t)=>{if(Be(e))return X(e.source,t);{const n=e.source,o=e.flags.replace(/y|$/,"y"),r=new RegExp(n,o);return Re(e)&&R(t)&&!Oe(t)?Ce(r,t):Se(r,t)}},"$e"),Ce=a((e,t)=>n=>{const o=n.index,r=n.input;e.lastIndex=o;const l=e.exec(r);if(l){const i=e.lastIndex;if(!n.options.silent){const h=t(...l,r,`${o}`);y(h)||n.output.push(h)}return n.index=i,!0}else return!1},"Ee"),Se=a((e,t)=>n=>{const o=n.index,r=n.input;if(e.lastIndex=o,e.test(r)){const l=e.lastIndex;if(!y(t)&&!n.options.silent){const i=R(t)?t(r.slice(o,l),r,`${o}`):t;y(i)||n.output.push(i)}return n.index=l,!0}else return!1},"Ce"),X=a((e,t)=>n=>{const o=n.index,r=n.input;if(r.startsWith(e,o)){if(!y(t)&&!n.options.silent){const l=R(t)?t(e,r,`${o}`):t;y(l)||n.output.push(l)}return n.index+=e.length,!0}else return!1},"F"),q=a((e,t,n,o)=>{const r=j(e),l=t>1;return F(L(ee(i=>{let h=0;for(;h<n;){const x=i.index;if(!r(i)||(h+=1,i.index===x))break}return h>=t},l),o))},"k"),Y=a((e,t)=>q(e,0,1,t),"L"),C=a((e,t)=>q(e,0,1/0,t),"$"),qe=a((e,t)=>q(e,1,1/0,t),"Re"),O=a((e,t)=>{const n=e.map(j);return F(L(ee(o=>{for(let r=0,l=n.length;r<l;r++)if(!n[r](o))return!1;return!0}),t))},"x"),w=a((e,t)=>{const n=e.map(j);return F(L(o=>{for(let r=0,l=n.length;r<l;r++)if(n[r](o))return!0;return!1},t))},"p"),ee=a((e,t=!0,n=!1)=>{const o=j(e);return t?r=>{const l=r.index,i=r.output.length,h=o(r);return!h&&!n&&(r.indexBacktrackMax=Math.max(r.indexBacktrackMax,r.index)),(!h||n)&&(r.index=l,r.output.length!==i&&(r.output.length=i)),h}:o},"q"),L=a((e,t)=>{const n=j(e);return t?o=>{if(o.options.silent)return n(o);const r=o.output.length;if(n(o)){const l=o.output.splice(r,1/0),i=t(l);return y(i)||o.output.push(i),!0}else return!1}:n},"B"),F=(()=>{let e=0;return t=>{const n=j(t),o=e+=1;return r=>{var l;if(r.options.memoization===!1)return n(r);const i=r.index,h=(l=r.cache)[o]||(l[o]={indexMax:-1,queue:[]}),x=h.queue;if(i<=h.indexMax){const Z=h.store||(h.store=new Map);if(x.length){for(let I=0,Gt=x.length;I<Gt;I+=2){const Ut=x[I*2],Dt=x[I*2+1];Z.set(Ut,Dt)}x.length=0}const v=Z.get(i);if(v===!1)return!1;if(Ee(v))return r.index=v,!0;if(v)return r.index=v.index,v.output?.length&&r.output.push(...v.output),!0}const W=r.output.length,Nt=n(r);if(h.indexMax=Math.max(h.indexMax,i),Nt){const Z=r.index,v=r.output.length;if(v>W){const I=r.output.slice(W,v);x.push(i,{index:Z,output:I})}else x.push(i,Z);return!0}else return x.push(i,!1),!1}}})(),te=a(e=>{let t;return n=>(t||(t=j(e())),t(n))},"G"),j=We(e=>{if(R(e))return ke(e)?te(e):e;if(Q(e)||Pe(e))return f(e);if(K(e))return O(e);if(Ie(e))return w(Object.values(e));throw new Error("Invalid rule")}),z=a(e=>e,"d"),Le=a(e=>typeof e=="string","ke"),Fe=a(e=>{const t=new WeakMap,n=new WeakMap;return(o,r)=>{const l=r?.partial?n:t,i=l.get(o);if(i!==void 0)return i;const h=e(o,r);return l.set(o,h),h}},"Be"),Ne=a(e=>{const t={},n={};return(o,r)=>{const l=r?.partial?n:t;return l[o]??(l[o]=e(o,r))}},"Pe"),Ge=f(/\\./,z),Ue=f(/./,z),De=f(/\*\*\*+/,"*"),Ve=f(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),He=f(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),Je=C(w([Ge,De,Ve,He,Ue])),Ke=Je,Qe=a(e=>T(e,Ke,{memoization:!1}).join(""),"Ie"),Te=Qe,ne="abcdefghijklmnopqrstuvwxyz",Xe=a(e=>{let t="";for(;e>0;){const n=(e-1)%26;t=ne[n]+t,e=Math.floor((e-1)/26)}return t},"Le"),re=a(e=>{let t=0;for(let n=0,o=e.length;n<o;n++)t=t*26+ne.indexOf(e[n])+1;return t},"V"),N=a((e,t)=>{if(t<e)return N(t,e);const n=[];for(;e<=t;)n.push(e++);return n},"b"),Ye=a((e,t,n)=>N(e,t).map(o=>String(o).padStart(n,"0")),"qe"),oe=a((e,t)=>N(re(e),re(t)).map(Xe),"W"),d=a(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),B=a(e=>({children:e}),"y"),E=(()=>{const e=a((t,n,o)=>{if(o.has(t))return;o.add(t);const{children:r}=t;if(!r.length)r.push(n);else for(let l=0,i=r.length;l<i;l++)e(r[l],n,o)},"e");return t=>{if(!t.length)return B([]);for(let n=t.length-1;n>=1;n--){const o=new Set,r=t[n-1],l=t[n];e(r,l,o)}return t[0]}})(),M=a(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),et=f(/\\./,d),tt=f(/[$.*+?^(){}[\]\|]/,e=>d(`\\${e}`)),nt=f(/[\\\/]/,M),rt=f(/[^$.*+?^(){}[\]\|\\\/]+/,d),ot=f(/^(?:!!)*!(.*)$/,(e,t)=>d(`(?!^${pe.compile(t).source}$).*?`)),st=f(/^(!!)+/),lt=w([ot,st]),ut=f(/\/(\*\*\/)+/,()=>B([E([M(),d(".+?"),M()]),M()])),at=f(/^(\*\*\/)+/,()=>B([d("^"),E([d(".*?"),M()])])),ct=f(/\/(\*\*)$/,()=>B([E([M(),d(".*?")]),d("$")])),it=f(/\*\*/,()=>d(".*?")),se=w([ut,at,ct,it]),ft=f(/\*\/(?!\*\*\/|\*$)/,()=>E([d("[^\\\\/]*?"),M()])),pt=f(/\*/,()=>d("[^\\\\/]*")),le=w([ft,pt]),ue=f("?",()=>d("[^\\\\/]")),ht=f("[",z),gt=f("]",z),dt=f(/[!^]/,"^\\\\/"),xt=f(/[a-z]-[a-z]|[0-9]-[0-9]/i,z),$t=f(/\\./,z),mt=f(/[$.*+?^(){}[\|]/,e=>`\\${e}`),bt=f(/[\\\/]/,"\\\\/"),wt=f(/[^$.*+?^(){}[\]\|\\\/]+/,z),vt=w([$t,mt,bt,xt,wt]),ae=O([ht,Y(dt),C(vt),gt],e=>d(e.join(""))),yt=f("{","(?:"),jt=f("}",")"),Mt=f(/(\d+)\.\.(\d+)/,(e,t,n)=>Ye(+t,+n,Math.min(t.length,n.length)).join("|")),At=f(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>oe(t,n).join("|")),zt=f(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>oe(t.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),kt=w([Mt,At,zt]),ce=O([yt,kt,jt],e=>d(e.join(""))),Ot=f("{"),Et=f("}"),It=f(","),Pt=f(/\\./,d),Rt=f(/[$.*+?^(){[\]\|]/,e=>d(`\\${e}`)),Bt=f(/[\\\/]/,M),Wt=f(/[^$.*+?^(){}[\]\|\\\/,]+/,d),Zt=te(()=>fe),_t=f("",()=>d("(?:)")),Ct=qe(w([se,le,ue,ae,ce,Zt,Pt,Rt,Bt,Wt]),E),ie=w([Ct,_t]),fe=O([Ot,Y(O([ie,C(O([It,ie]))])),Et],B),St=C(w([lt,se,le,ue,ae,ce,fe,et,tt,nt,rt]),E),qt=St,Lt=a(e=>T(e,qt,{memoization:!1})[0],"kr"),Ft=Lt,G=a((e,t,n)=>G.compile(e,n).test(t),"N");G.compile=(()=>{const e=Ne((n,o)=>Me(Ft(Te(n)),o)),t=Fe((n,o)=>ze(n.map(r=>e(r,o))));return(n,o)=>Le(n)?e(n,o):t(n,o)})();var pe=G;return m(P)})();return s.default||s},"_lazyMatch"),U;const Tt=a((s,u)=>(U||(U=ge(),ge=null),U(s,u)),"default");var Xt=Object.defineProperty,Yt=V((s,u)=>Xt(s,"name",{value:u,configurable:!0}),"t$1");const en=/^[A-Z]:\//i,k=Yt((s="")=>s&&s.replaceAll("\\","/").replace(en,u=>u.toUpperCase()),"normalizeWindowsPath");var tn=Object.defineProperty,$=V((s,u)=>tn(s,"name",{value:u,configurable:!0}),"r");const nn=/^[/\\]{2}/,rn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,xe=/^[A-Z]:$/i,de=/^\/([A-Z]:)?$/i,on=/.(\.[^./]+)$/,sn=/^[/\\]|^[a-z]:[/\\]/i,ln=/\/$/,un=$(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),$e=$((s,u)=>{let c="",p=0,g=-1,b=0,A;for(let m=0;m<=s.length;++m){if(m<s.length)A=s[m];else{if(A==="/")break;A="/"}if(A==="/"){if(!(g===m-1||b===1))if(b===2){if(c.length<2||p!==2||!c.endsWith(".")||c.at(-2)!=="."){if(c.length>2){const P=c.lastIndexOf("/");P===-1?(c="",p=0):(c=c.slice(0,P),p=c.length-1-c.lastIndexOf("/")),g=m,b=0;continue}else if(c.length>0){c="",p=0,g=m,b=0;continue}}u&&(c+=c.length>0?"/..":"..",p=2)}else c.length>0?c+=`/${s.slice(g+1,m)}`:c=s.slice(g+1,m),p=m-g-1;g=m,b=0}else A==="."&&b!==-1?++b:b=-1}return c},"normalizeString"),_=$(s=>rn.test(s),"isAbsolute"),me=$(function(s){if(s.length===0)return".";s=k(s);const u=nn.exec(s),c=_(s),p=s.at(-1)==="/";return s=$e(s,!c),s.length===0?c?"/":p?"./":".":(p&&(s+="/"),xe.test(s)&&(s+="/"),u?c?`//${s}`:`//./${s}`:c&&!_(s)?`/${s}`:s)},"normalize"),hn=$((...s)=>{let u="";for(const c of s)if(c)if(u.length>0){const p=u.at(-1)==="/",g=c[0]==="/";p&&g?u+=c.slice(1):u+=p||g?c:`/${c}`}else u+=c;return me(u)},"join"),D=$(function(...s){s=s.map(p=>k(p));let u="",c=!1;for(let p=s.length-1;p>=-1&&!c;p--){const g=p>=0?s[p]:un();!g||g.length===0||(u=`${g}/${u}`,c=_(g))}return u=$e(u,!c),c&&!_(u)?`/${u}`:u.length>0?u:"."},"resolve");$(function(s){return k(s)},"toNamespacedPath");const an=$(function(s){return on.exec(k(s))?.[1]??""},"extname");$(function(s,u){const c=D(s).replace(de,"$1").split("/"),p=D(u).replace(de,"$1").split("/");if(p[0][1]===":"&&c[0][1]===":"&&c[0]!==p[0])return p.join("/");const g=[...c];for(const b of g){if(p[0]!==b)break;c.shift(),p.shift()}return[...c.map(()=>".."),...p].join("/")},"relative");const cn=$(s=>{const u=k(s).replace(ln,"").split("/").slice(0,-1);return u.length===1&&xe.test(u[0])&&(u[0]=`${u[0]}/`),u.join("/")||(_(s)?"/":".")},"dirname");$(function(s){const u=[s.root,s.dir,s.base??s.name+s.ext].filter(Boolean);return k(s.root?D(...u):u.join("/"))},"format");const fn=$((s,u)=>{const c=k(s).split("/").pop();return u&&c.endsWith(u)?c.slice(0,-u.length):c},"basename");$(function(s){const u=sn.exec(s)?.[0]?.replaceAll("\\","/")??"",c=fn(s),p=an(c);return{base:c,dir:cn(s),ext:p,name:c.slice(0,c.length-p.length),root:u}},"parse");$((s,u)=>Tt(u,me(s)),"matchesGlob");export{me as L,hn as M,_ as O};
1
+ var Vt=Object.defineProperty;var he=(s,u)=>Vt(s,"name",{value:u,configurable:!0});var Ht=Object.defineProperty,Jt=he((s,u)=>Ht(s,"name",{value:u,configurable:!0}),"$e"),Kt=Object.defineProperty,V=Jt((s,u)=>Kt(s,"name",{value:u,configurable:!0}),"W"),Qt=Object.defineProperty,a=V((s,u)=>Qt(s,"name",{value:u,configurable:!0}),"u$1");let ge=a(()=>{var s=(()=>{var u=Object.defineProperty,c=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,b=a((e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},"ne"),A=a((e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of p(t))!g.call(e,r)&&r!==n&&u(e,r,{get:a(()=>t[r],"get"),enumerable:!(o=c(t,r))||o.enumerable});return e},"ae"),m=a(e=>A(u({},"__esModule",{value:!0}),e),"oe"),P={};b(P,{zeptomatch:a(()=>pe,"zeptomatch")});var H=a(e=>{const t=new Set,n=[e];for(let o=0;o<n.length;o++){const r=n[o];if(t.has(r))continue;t.add(r);const{children:l}=r;if(l?.length)for(let i=0,h=l.length;i<h;i++)n.push(l[i])}return Array.from(t)},"M"),be=a(e=>{let t="";const n=H(e);for(let o=0,r=n.length;o<r;o++){const l=n[o];if(!l.regex)continue;const i=l.regex.flags;if(t||(t=i),t!==i)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${i}"`)}return t},"se"),J=a((e,t,n)=>{const o=n.get(e);if(o!==void 0)return o;const r=e.partial??t;let l="";if(e.regex&&(l+=r?"(?:$|":"",l+=e.regex.source),e.children?.length){const i=ve(e.children.map(h=>J(h,t,n)).filter(Boolean));if(i?.length){const h=e.children.some(W=>!W.regex||!(W.partial??t)),x=i.length>1||r&&(!l.length||h);l+=x?r?"(?:$|":"(?:":"",l+=i.join("|"),l+=x?")":""}}return e.regex&&(l+=r?")":""),n.set(e,l),l},"O"),we=a((e,t)=>{const n=new Map,o=H(e);for(let r=o.length-1;r>=0;r--){const l=J(o[r],t,n);if(!(r>0))return l}return""},"ie"),ve=a(e=>Array.from(new Set(e)),"ue"),S=a((e,t,n)=>S.compile(e,n).test(t),"R");S.compile=(e,t)=>{const n=t?.partial??!1,o=we(e,n),r=be(e);return new RegExp(`^(?:${o})$`,r)};var ye=S,je=a((e,t)=>{const n=ye.compile(e,t),o=`${n.source.slice(0,-1)}[\\\\/]?$`,r=n.flags;return new RegExp(o,r)},"le"),Me=je,Ae=a(e=>{const t=e.map(o=>o.source).join("|")||"$^",n=e[0]?.flags;return new RegExp(t,n)},"ve"),ze=Ae,K=a(e=>Array.isArray(e),"j"),R=a(e=>typeof e=="function","_"),ke=a(e=>e.length===0,"he"),Oe=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return n=>(n.length===0||n.length===1)&&t.test(e.call(n))})(),Ee=a(e=>typeof e=="number","de"),Ie=a(e=>typeof e=="object"&&e!==null,"xe"),Pe=a(e=>e instanceof RegExp,"me"),Re=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),Be=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),Q=a(e=>typeof e=="string","A"),y=a(e=>e===void 0,"f"),We=a(e=>{const t=new Map;return n=>{const o=t.get(n);if(o!==void 0)return o;const r=e(n);return t.set(n,r),r}},"ye"),T=a((e,t,n={})=>{const o={cache:{},input:e,index:0,indexBacktrackMax:0,options:n,output:[]},r=j(t)(o),l=Math.max(o.index,o.indexBacktrackMax);if(r&&o.index===e.length)return o.output;throw new Error(`Failed to parse at index ${l}`)},"I"),f=a((e,t)=>K(e)?Ze(e,t):Q(e)?X(e,t):_e(e,t),"i"),Ze=a((e,t)=>{const n={};for(const o of e){if(o.length!==1)throw new Error(`Invalid character: "${o}"`);const r=o.charCodeAt(0);n[r]=!0}return o=>{const r=o.input;let l=o.index,i=l;for(;i<r.length&&r.charCodeAt(i)in n;)i+=1;if(i>l){if(!y(t)&&!o.options.silent){const h=r.slice(l,i),x=R(t)?t(h,r,`${l}`):t;y(x)||o.output.push(x)}o.index=i}return!0}},"we"),_e=a((e,t)=>{if(Be(e))return X(e.source,t);{const n=e.source,o=e.flags.replace(/y|$/,"y"),r=new RegExp(n,o);return Re(e)&&R(t)&&!Oe(t)?Ce(r,t):Se(r,t)}},"$e"),Ce=a((e,t)=>n=>{const o=n.index,r=n.input;e.lastIndex=o;const l=e.exec(r);if(l){const i=e.lastIndex;if(!n.options.silent){const h=t(...l,r,`${o}`);y(h)||n.output.push(h)}return n.index=i,!0}else return!1},"Ee"),Se=a((e,t)=>n=>{const o=n.index,r=n.input;if(e.lastIndex=o,e.test(r)){const l=e.lastIndex;if(!y(t)&&!n.options.silent){const i=R(t)?t(r.slice(o,l),r,`${o}`):t;y(i)||n.output.push(i)}return n.index=l,!0}else return!1},"Ce"),X=a((e,t)=>n=>{const o=n.index,r=n.input;if(r.startsWith(e,o)){if(!y(t)&&!n.options.silent){const l=R(t)?t(e,r,`${o}`):t;y(l)||n.output.push(l)}return n.index+=e.length,!0}else return!1},"F"),q=a((e,t,n,o)=>{const r=j(e),l=t>1;return F(L(ee(i=>{let h=0;for(;h<n;){const x=i.index;if(!r(i)||(h+=1,i.index===x))break}return h>=t},l),o))},"k"),Y=a((e,t)=>q(e,0,1,t),"L"),C=a((e,t)=>q(e,0,1/0,t),"$"),qe=a((e,t)=>q(e,1,1/0,t),"Re"),O=a((e,t)=>{const n=e.map(j);return F(L(ee(o=>{for(let r=0,l=n.length;r<l;r++)if(!n[r](o))return!1;return!0}),t))},"x"),w=a((e,t)=>{const n=e.map(j);return F(L(o=>{for(let r=0,l=n.length;r<l;r++)if(n[r](o))return!0;return!1},t))},"p"),ee=a((e,t=!0,n=!1)=>{const o=j(e);return t?r=>{const l=r.index,i=r.output.length,h=o(r);return!h&&!n&&(r.indexBacktrackMax=Math.max(r.indexBacktrackMax,r.index)),(!h||n)&&(r.index=l,r.output.length!==i&&(r.output.length=i)),h}:o},"q"),L=a((e,t)=>{const n=j(e);return t?o=>{if(o.options.silent)return n(o);const r=o.output.length;if(n(o)){const l=o.output.splice(r,1/0),i=t(l);return y(i)||o.output.push(i),!0}else return!1}:n},"B"),F=(()=>{let e=0;return t=>{const n=j(t),o=e+=1;return r=>{var l;if(r.options.memoization===!1)return n(r);const i=r.index,h=(l=r.cache)[o]||(l[o]={indexMax:-1,queue:[]}),x=h.queue;if(i<=h.indexMax){const Z=h.store||(h.store=new Map);if(x.length){for(let I=0,Gt=x.length;I<Gt;I+=2){const Ut=x[I*2],Dt=x[I*2+1];Z.set(Ut,Dt)}x.length=0}const v=Z.get(i);if(v===!1)return!1;if(Ee(v))return r.index=v,!0;if(v)return r.index=v.index,v.output?.length&&r.output.push(...v.output),!0}const W=r.output.length,Nt=n(r);if(h.indexMax=Math.max(h.indexMax,i),Nt){const Z=r.index,v=r.output.length;if(v>W){const I=r.output.slice(W,v);x.push(i,{index:Z,output:I})}else x.push(i,Z);return!0}else return x.push(i,!1),!1}}})(),te=a(e=>{let t;return n=>(t||(t=j(e())),t(n))},"G"),j=We(e=>{if(R(e))return ke(e)?te(e):e;if(Q(e)||Pe(e))return f(e);if(K(e))return O(e);if(Ie(e))return w(Object.values(e));throw new Error("Invalid rule")}),z=a(e=>e,"d"),Le=a(e=>typeof e=="string","ke"),Fe=a(e=>{const t=new WeakMap,n=new WeakMap;return(o,r)=>{const l=r?.partial?n:t,i=l.get(o);if(i!==void 0)return i;const h=e(o,r);return l.set(o,h),h}},"Be"),Ne=a(e=>{const t={},n={};return(o,r)=>{const l=r?.partial?n:t;return l[o]??(l[o]=e(o,r))}},"Pe"),Ge=f(/\\./,z),Ue=f(/./,z),De=f(/\*\*\*+/,"*"),Ve=f(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),He=f(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),Je=C(w([Ge,De,Ve,He,Ue])),Ke=Je,Qe=a(e=>T(e,Ke,{memoization:!1}).join(""),"Ie"),Te=Qe,ne="abcdefghijklmnopqrstuvwxyz",Xe=a(e=>{let t="";for(;e>0;){const n=(e-1)%26;t=ne[n]+t,e=Math.floor((e-1)/26)}return t},"Le"),re=a(e=>{let t=0;for(let n=0,o=e.length;n<o;n++)t=t*26+ne.indexOf(e[n])+1;return t},"V"),N=a((e,t)=>{if(t<e)return N(t,e);const n=[];for(;e<=t;)n.push(e++);return n},"b"),Ye=a((e,t,n)=>N(e,t).map(o=>String(o).padStart(n,"0")),"qe"),oe=a((e,t)=>N(re(e),re(t)).map(Xe),"W"),d=a(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),B=a(e=>({children:e}),"y"),E=(()=>{const e=a((t,n,o)=>{if(o.has(t))return;o.add(t);const{children:r}=t;if(!r.length)r.push(n);else for(let l=0,i=r.length;l<i;l++)e(r[l],n,o)},"e");return t=>{if(!t.length)return B([]);for(let n=t.length-1;n>=1;n--){const o=new Set,r=t[n-1],l=t[n];e(r,l,o)}return t[0]}})(),M=a(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),et=f(/\\./,d),tt=f(/[$.*+?^(){}[\]\|]/,e=>d(`\\${e}`)),nt=f(/[\\\/]/,M),rt=f(/[^$.*+?^(){}[\]\|\\\/]+/,d),ot=f(/^(?:!!)*!(.*)$/,(e,t)=>d(`(?!^${pe.compile(t).source}$).*?`)),st=f(/^(!!)+/),lt=w([ot,st]),ut=f(/\/(\*\*\/)+/,()=>B([E([M(),d(".+?"),M()]),M()])),at=f(/^(\*\*\/)+/,()=>B([d("^"),E([d(".*?"),M()])])),ct=f(/\/(\*\*)$/,()=>B([E([M(),d(".*?")]),d("$")])),it=f(/\*\*/,()=>d(".*?")),se=w([ut,at,ct,it]),ft=f(/\*\/(?!\*\*\/|\*$)/,()=>E([d("[^\\\\/]*?"),M()])),pt=f(/\*/,()=>d("[^\\\\/]*")),le=w([ft,pt]),ue=f("?",()=>d("[^\\\\/]")),ht=f("[",z),gt=f("]",z),dt=f(/[!^]/,"^\\\\/"),xt=f(/[a-z]-[a-z]|[0-9]-[0-9]/i,z),$t=f(/\\./,z),mt=f(/[$.*+?^(){}[\|]/,e=>`\\${e}`),bt=f(/[\\\/]/,"\\\\/"),wt=f(/[^$.*+?^(){}[\]\|\\\/]+/,z),vt=w([$t,mt,bt,xt,wt]),ae=O([ht,Y(dt),C(vt),gt],e=>d(e.join(""))),yt=f("{","(?:"),jt=f("}",")"),Mt=f(/(\d+)\.\.(\d+)/,(e,t,n)=>Ye(+t,+n,Math.min(t.length,n.length)).join("|")),At=f(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>oe(t,n).join("|")),zt=f(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>oe(t.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),kt=w([Mt,At,zt]),ce=O([yt,kt,jt],e=>d(e.join(""))),Ot=f("{"),Et=f("}"),It=f(","),Pt=f(/\\./,d),Rt=f(/[$.*+?^(){[\]\|]/,e=>d(`\\${e}`)),Bt=f(/[\\\/]/,M),Wt=f(/[^$.*+?^(){}[\]\|\\\/,]+/,d),Zt=te(()=>fe),_t=f("",()=>d("(?:)")),Ct=qe(w([se,le,ue,ae,ce,Zt,Pt,Rt,Bt,Wt]),E),ie=w([Ct,_t]),fe=O([Ot,Y(O([ie,C(O([It,ie]))])),Et],B),St=C(w([lt,se,le,ue,ae,ce,fe,et,tt,nt,rt]),E),qt=St,Lt=a(e=>T(e,qt,{memoization:!1})[0],"kr"),Ft=Lt,G=a((e,t,n)=>G.compile(e,n).test(t),"N");G.compile=(()=>{const e=Ne((n,o)=>Me(Ft(Te(n)),o)),t=Fe((n,o)=>ze(n.map(r=>e(r,o))));return(n,o)=>Le(n)?e(n,o):t(n,o)})();var pe=G;return m(P)})();return s.default||s},"_lazyMatch"),U;const Tt=a((s,u)=>(U||(U=ge(),ge=null),U(s,u)),"default");var Xt=Object.defineProperty,Yt=V((s,u)=>Xt(s,"name",{value:u,configurable:!0}),"t$1");const en=/^[A-Z]:\//i,k=Yt((s="")=>s&&s.replaceAll("\\","/").replace(en,u=>u.toUpperCase()),"normalizeWindowsPath");var tn=Object.defineProperty,$=V((s,u)=>tn(s,"name",{value:u,configurable:!0}),"r");const nn=/^[/\\]{2}/,rn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,xe=/^[A-Z]:$/i,de=/^\/([A-Z]:)?$/i,on=/.(\.[^./]+)$/,sn=/^[/\\]|^[a-z]:[/\\]/i,ln=/\/$/,un=$(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),$e=$((s,u)=>{let c="",p=0,g=-1,b=0,A;for(let m=0;m<=s.length;++m){if(m<s.length)A=s[m];else{if(A==="/")break;A="/"}if(A==="/"){if(!(g===m-1||b===1))if(b===2){if(c.length<2||p!==2||!c.endsWith(".")||c.at(-2)!=="."){if(c.length>2){const P=c.lastIndexOf("/");P===-1?(c="",p=0):(c=c.slice(0,P),p=c.length-1-c.lastIndexOf("/")),g=m,b=0;continue}else if(c.length>0){c="",p=0,g=m,b=0;continue}}u&&(c+=c.length>0?"/..":"..",p=2)}else c.length>0?c+=`/${s.slice(g+1,m)}`:c=s.slice(g+1,m),p=m-g-1;g=m,b=0}else A==="."&&b!==-1?++b:b=-1}return c},"normalizeString"),_=$(s=>rn.test(s),"isAbsolute"),me=$(function(s){if(s.length===0)return".";s=k(s);const u=nn.exec(s),c=_(s),p=s.at(-1)==="/";return s=$e(s,!c),s.length===0?c?"/":p?"./":".":(p&&(s+="/"),xe.test(s)&&(s+="/"),u?c?`//${s}`:`//./${s}`:c&&!_(s)?`/${s}`:s)},"normalize"),hn=$((...s)=>{let u="";for(const c of s)if(c)if(u.length>0){const p=u.at(-1)==="/",g=c[0]==="/";p&&g?u+=c.slice(1):u+=p||g?c:`/${c}`}else u+=c;return me(u)},"join"),D=$(function(...s){s=s.map(p=>k(p));let u="",c=!1;for(let p=s.length-1;p>=-1&&!c;p--){const g=p>=0?s[p]:un();!g||g.length===0||(u=`${g}/${u}`,c=_(g))}return u=$e(u,!c),c&&!_(u)?`/${u}`:u.length>0?u:"."},"resolve");$(function(s){return k(s)},"toNamespacedPath");const an=$(function(s){return on.exec(k(s))?.[1]??""},"extname");$(function(s,u){const c=D(s).replace(de,"$1").split("/"),p=D(u).replace(de,"$1").split("/");if(p[0][1]===":"&&c[0][1]===":"&&c[0]!==p[0])return p.join("/");const g=[...c];for(const b of g){if(p[0]!==b)break;c.shift(),p.shift()}return[...c.map(()=>".."),...p].join("/")},"relative");const cn=$(s=>{const u=k(s).replace(ln,"").split("/").slice(0,-1);return u.length===1&&xe.test(u[0])&&(u[0]=`${u[0]}/`),u.join("/")||(_(s)?"/":".")},"dirname");$(function(s){const u=[s.root,s.dir,s.base??s.name+s.ext].filter(Boolean);return k(s.root?D(...u):u.join("/"))},"format");const fn=$((s,u)=>{const c=k(s).split("/").pop();return u&&c.endsWith(u)?c.slice(0,-u.length):c},"basename");$(function(s){const u=sn.exec(s)?.[0]?.replaceAll("\\","/")??"",c=fn(s),p=an(c);return{base:c,dir:cn(s),ext:p,name:c.slice(0,c.length-p.length),root:u}},"parse");$((s,u)=>Tt(u,me(s)),"matchesGlob");export{k as A,D as C,an as J,cn as K,me as L,hn as M,_ as O,fn as Q};
@@ -1 +1 @@
1
- var E=Object.defineProperty;var y=(a,t)=>E(a,"name",{value:t,configurable:!0});import{n as u}from"./headers-DC2MEOrK.js";import{hasBody as X}from"type-is";import{a as c}from"./base-handler-core-Ccvdhx-k.js";import{ERRORS as A}from"./ERRORS-CyOuSMLY.js";import{b,a as z,c as v,d as L}from"./response-builder-Wdo_fvcF.js";var T=Object.defineProperty,f=y((a,t)=>T(a,"name",{value:t,configurable:!0}),"a$1");const D=f((a,t={})=>{const e=c(a,"x-file-metadata",!0);if(!e)return t;try{return{...t,...JSON.parse(e)}}catch{return t}},"parseMetadata"),P=f(a=>{if(!a)return;const t=2e3,e=a.length>t?a.slice(0,Math.max(0,t)):a,r=e.toLowerCase().indexOf("filename");if(r===-1)return;let s=r+8;for(;s<e.length&&(e[s]==="*"||e[s]===" "||e[s]===" ");)s++;if(s>=e.length||e[s]!=="=")return;for(s++;s<e.length&&(e[s]===" "||e[s]===" ");)s++;if(s>=e.length)return;let n=s,o;const i=e[s];return i==='"'||i==="'"?(n=s+1,o=e.indexOf(i,n),o===-1&&(o=e.indexOf(";",n),o===-1&&(o=e.length))):(o=e.indexOf(";",n),o===-1&&(o=e.length)),n>=o?void 0:e.substring(n,o).trim()||void 0},"parseContentDispositionValue"),I=f(a=>{const t=c(a,"content-disposition",!0);return P(t)},"parseContentDisposition"),R=f(a=>{const t=c(a,"x-chunked-upload",!0)==="true",e=c(a,"x-chunk-offset",!0),r=c(a,"x-total-size",!0),s={isChunkedUpload:t};if(e){const n=Number.parseInt(e,10);!Number.isNaN(n)&&n>=0&&(s.chunkOffset=n)}if(r){const n=Number.parseInt(r,10);!Number.isNaN(n)&&n>0&&(s.totalSize=n)}return s},"parseChunkHeaders"),Z=f((a,t=!1)=>{const e=c(a,"x-chunked-upload",!0)==="true";if(!(t&&e)){if(!X(a))throw u(400,"Request body is required");if(Number.parseInt(c(a,"content-length")||"0",10)===0&&!e)throw u(400,"Content-Length is required and must be greater than 0")}},"validateRequestBody"),ee=f((a,t=!1,e)=>{const r=c(a,"x-chunked-upload",!0)==="true",s=Number.parseInt(c(a,"content-length")||"0",10);if(!t&&!r&&s===0)throw u(400,"Content-Length is required and must be greater than 0");if(e!==void 0&&s>e)throw u(413,`File size exceeds maximum allowed size of ${e} bytes`);return s},"validateContentLength"),te=f((a,t,e="application/octet-stream")=>{const r=I(a),s=D(a),{isChunkedUpload:n,totalSize:o}=R(a),i=n&&o?o:t;return n&&o&&(s._chunkedUpload=!0,s._chunks=[],s._totalSize=o),{contentType:e,metadata:s,originalName:r,size:i}},"extractFileInit");f((a,t,e)=>{if(Number.isNaN(a)||a<0)throw u(400,"X-Chunk-Offset must be a valid non-negative number");if(a+t>e)throw u(400,`Chunk exceeds file size. Offset: ${a}, Size: ${t}, Total: ${e}`)},"validateChunk");f((a,t="application/octet-stream")=>c(a,"content-type")||t,"getContentType");var W=Object.defineProperty,g=y((a,t)=>W(a,"name",{value:t,configurable:!0}),"a");const N=g((a,t)=>{if(a.length===0)return!1;const e=[...a].toSorted((n,o)=>n.offset-o.offset),r=e[0];if(r?.offset!==0)return!1;let s=r.length;for(let n=1;n<e.length;n+=1){const o=e[n];if(o){if(o.offset>s)return!1;s=Math.max(s,o.offset+o.length)}}return s>=t},"isUploadComplete"),H=g((a,t,e,r)=>{if(Number.isNaN(a)||a<0)throw new Error("Chunk offset must be a valid non-negative number");if(t<=0)throw new Error("Chunk length must be greater than 0");if(r!==void 0&&t>r)throw new Error(`Chunk size exceeds maximum allowed size of ${r} bytes`);if(a+t>e)throw new Error(`Chunk exceeds file size. Offset: ${a}, Size: ${t}, Total: ${e}`)},"validateChunk"),B=g((a,t)=>{const e=a.find(r=>r.offset===t.offset&&r.length===t.length);return e?t.checksum&&e.checksum!==t.checksum?a.map(r=>r.offset===t.offset?{...r,checksum:t.checksum}:r):a:[...a,t]},"trackChunk"),j=g((a,t)=>{if(a.length===0||t===0)return{bytesWritten:0,percentage:0};const e=[...a].toSorted((o,i)=>o.offset-i.offset);let r=0,s=0;for(const o of e){const i=o.offset+o.length;o.offset<=s?r=Math.max(r,i):r+=o.length,s=Math.max(s,i)}r=Math.min(r,t);const n=t>0?r/t*100:0;return{bytesWritten:r,percentage:n}},"calculateUploadProgress");g(a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&Array.isArray(t._chunks)){const e=typeof t._totalSize=="number"?t._totalSize:a.size||0;return j(t._chunks,e).bytesWritten}return a.bytesWritten||0},"getBytesWritten");const _=g(a=>(a.metadata||{})._chunkedUpload===!0,"isChunkedUpload"),U=g(a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&typeof t._totalSize=="number")return t._totalSize},"getTotalSize");var q=Object.defineProperty,$=y((a,t)=>q(a,"name",{value:t,configurable:!0}),"y");class ae{static{y(this,"M")}static{$(this,"RestBase")}async deleteSingle(t){const e=await this.storage.delete({id:t});if(e.status===void 0)throw u(404,"File not found");return{...e,headers:{},statusCode:204}}async handlePost(t,e,r,s,n){if(e&&t.size!==void 0){const d=typeof t.size=="number"?t.size:Number.parseInt(String(t.size),10);if(d>0&&d>this.storage.maxUploadSize)throw u(413,`File size exceeds maximum allowed size of ${this.storage.maxUploadSize} bytes`)}const o=await this.storage.create(t);if(e){const d=this.buildFileUrl(r,o);return b(o,{...z(o,d),"X-Chunked-Upload":"true","X-Upload-ID":o.id},201)}const i=await this.storage.write({body:s,contentLength:n,id:o.id,start:0}),h=this.buildFileUrl(r,i);return b(i,z(i,h),201)}async handlePut(t,e,r,s,n,o){let i,h=!1;try{await this.storage.getMeta(t),h=!0,o&&await this.storage.update({id:t},{metadata:o}),i=await this.storage.write({body:s,contentLength:n,id:t,start:0})}catch(m){const S=m;if(S.UploadErrorCode===A.FILE_NOT_FOUND||S.code==="ENOENT")try{const w=await this.storage.create(e);i=await this.storage.write({body:s,contentLength:n,id:w.id,start:0})}catch(w){throw w}else throw m}const d=this.buildFileUrl(r,i);return b(i,z(i,d),h?200:201)}async handlePatch(t,e,r,s,n,o){let i=await this.storage.getMeta(t);const h=i.metadata||{},d=_(i);if(d){const l=U(i);l&&i.size!==l&&(i={...i,size:l})}const m=typeof h._totalSize=="number"?h._totalSize:i.size||0;if(!d)throw u(400,"File is not a chunked upload. Use POST or PUT for full file uploads.");const S=100*1024*1024;try{H(e,r,m,S)}catch(l){throw l instanceof Error&&l.message.includes("exceeds maximum")?u(413,l.message):u(400,l instanceof Error?l.message:String(l))}if(i.status==="completed"){const l=this.buildFileUrl(n,i);return b(i,{...z(i,l),"X-Upload-Complete":"true"},200)}const w=await this.storage.withLock(`chunks:${t}`,async()=>{const l=(await this.storage.getMeta(t)).metadata??{},M=Array.isArray(l._chunks)?l._chunks:[],x=B(M,{checksum:s,length:r,offset:e});return await this.storage.update({id:t},{metadata:{...l,_chunks:x}}),x});let p=await this.storage.write({body:o,contentLength:r,id:t,start:e}),C=p.bytesWritten>=m;d&&(C=N(w,m),p.status==="completed"&&!C&&(await this.storage.update({id:t},{status:"part"}),p={...p,status:"part"}));const k=C&&p.bytesWritten!==m?{...p,bytesWritten:m}:p,F=this.buildFileUrl(n,k),O={...z(k,F),...v(k,C),"x-upload-offset":String(k.bytesWritten||0)};return b(k,O,C?200:202)}async handleHead(t){let e=await this.storage.getMeta(t);const r=_(e);if(r){const n=U(e);n&&e.size!==n&&(e={...e,size:n})}const s={...L(e)};if(r){const n=e.metadata||{},o=U(e)||e.size||0,i=Array.isArray(n._chunks)?n._chunks:[],h=N(i,o);Object.assign(s,v(e,h))}return b(e,s,200)}handleOptions(t,e){return{headers:{"Access-Control-Allow-Headers":"Authorization, Content-Type, Content-Length, Content-Disposition, X-File-Metadata, X-Chunked-Upload, X-Total-Size, X-Chunk-Offset, X-Chunk-Checksum","Access-Control-Allow-Methods":t.map(r=>r.toUpperCase()).join(", "),"Access-Control-Max-Age":86400,"X-Max-Upload-Size":String(e)},statusCode:204}}async deleteBatch(t){const e=await this.storage.deleteBatch(t);if(e.successfulCount===0&&e.failedCount>0){const r=e.failed.map(s=>s.id).join(", ");throw u(404,`Failed to delete files: ${r}`)}return{data:e.successful,headers:e.failedCount>0?{"X-Delete-Errors":JSON.stringify(e.failed),"X-Delete-Failed":String(e.failedCount),"X-Delete-Successful":String(e.successfulCount)}:{"X-Delete-Successful":String(e.successfulCount)},statusCode:e.successfulCount===t.length?204:207}}get storage(){throw new Error("storage must be implemented")}buildFileUrl(t,e){throw new Error("buildFileUrl must be implemented")}}export{ae as M,ee as a,R as b,P as c,te as e,I as p,Z as v};
1
+ var E=Object.defineProperty;var y=(a,t)=>E(a,"name",{value:t,configurable:!0});import{n as u}from"./headers-DC2MEOrK.js";import{hasBody as X}from"type-is";import{a as c}from"./base-handler-core-ty4J6Ji6.js";import{ERRORS as A}from"./ERRORS-vMSqlI69.js";import{b,a as z,c as v,d as L}from"./response-builder-Wdo_fvcF.js";var T=Object.defineProperty,f=y((a,t)=>T(a,"name",{value:t,configurable:!0}),"a$1");const D=f((a,t={})=>{const e=c(a,"x-file-metadata",!0);if(!e)return t;try{return{...t,...JSON.parse(e)}}catch{return t}},"parseMetadata"),P=f(a=>{if(!a)return;const t=2e3,e=a.length>t?a.slice(0,Math.max(0,t)):a,r=e.toLowerCase().indexOf("filename");if(r===-1)return;let s=r+8;for(;s<e.length&&(e[s]==="*"||e[s]===" "||e[s]===" ");)s++;if(s>=e.length||e[s]!=="=")return;for(s++;s<e.length&&(e[s]===" "||e[s]===" ");)s++;if(s>=e.length)return;let n=s,o;const i=e[s];return i==='"'||i==="'"?(n=s+1,o=e.indexOf(i,n),o===-1&&(o=e.indexOf(";",n),o===-1&&(o=e.length))):(o=e.indexOf(";",n),o===-1&&(o=e.length)),n>=o?void 0:e.substring(n,o).trim()||void 0},"parseContentDispositionValue"),I=f(a=>{const t=c(a,"content-disposition",!0);return P(t)},"parseContentDisposition"),R=f(a=>{const t=c(a,"x-chunked-upload",!0)==="true",e=c(a,"x-chunk-offset",!0),r=c(a,"x-total-size",!0),s={isChunkedUpload:t};if(e){const n=Number.parseInt(e,10);!Number.isNaN(n)&&n>=0&&(s.chunkOffset=n)}if(r){const n=Number.parseInt(r,10);!Number.isNaN(n)&&n>0&&(s.totalSize=n)}return s},"parseChunkHeaders"),Z=f((a,t=!1)=>{const e=c(a,"x-chunked-upload",!0)==="true";if(!(t&&e)){if(!X(a))throw u(400,"Request body is required");if(Number.parseInt(c(a,"content-length")||"0",10)===0&&!e)throw u(400,"Content-Length is required and must be greater than 0")}},"validateRequestBody"),ee=f((a,t=!1,e)=>{const r=c(a,"x-chunked-upload",!0)==="true",s=Number.parseInt(c(a,"content-length")||"0",10);if(!t&&!r&&s===0)throw u(400,"Content-Length is required and must be greater than 0");if(e!==void 0&&s>e)throw u(413,`File size exceeds maximum allowed size of ${e} bytes`);return s},"validateContentLength"),te=f((a,t,e="application/octet-stream")=>{const r=I(a),s=D(a),{isChunkedUpload:n,totalSize:o}=R(a),i=n&&o?o:t;return n&&o&&(s._chunkedUpload=!0,s._chunks=[],s._totalSize=o),{contentType:e,metadata:s,originalName:r,size:i}},"extractFileInit");f((a,t,e)=>{if(Number.isNaN(a)||a<0)throw u(400,"X-Chunk-Offset must be a valid non-negative number");if(a+t>e)throw u(400,`Chunk exceeds file size. Offset: ${a}, Size: ${t}, Total: ${e}`)},"validateChunk");f((a,t="application/octet-stream")=>c(a,"content-type")||t,"getContentType");var W=Object.defineProperty,g=y((a,t)=>W(a,"name",{value:t,configurable:!0}),"a");const N=g((a,t)=>{if(a.length===0)return!1;const e=[...a].toSorted((n,o)=>n.offset-o.offset),r=e[0];if(r?.offset!==0)return!1;let s=r.length;for(let n=1;n<e.length;n+=1){const o=e[n];if(o){if(o.offset>s)return!1;s=Math.max(s,o.offset+o.length)}}return s>=t},"isUploadComplete"),H=g((a,t,e,r)=>{if(Number.isNaN(a)||a<0)throw new Error("Chunk offset must be a valid non-negative number");if(t<=0)throw new Error("Chunk length must be greater than 0");if(r!==void 0&&t>r)throw new Error(`Chunk size exceeds maximum allowed size of ${r} bytes`);if(a+t>e)throw new Error(`Chunk exceeds file size. Offset: ${a}, Size: ${t}, Total: ${e}`)},"validateChunk"),B=g((a,t)=>{const e=a.find(r=>r.offset===t.offset&&r.length===t.length);return e?t.checksum&&e.checksum!==t.checksum?a.map(r=>r.offset===t.offset?{...r,checksum:t.checksum}:r):a:[...a,t]},"trackChunk"),j=g((a,t)=>{if(a.length===0||t===0)return{bytesWritten:0,percentage:0};const e=[...a].toSorted((o,i)=>o.offset-i.offset);let r=0,s=0;for(const o of e){const i=o.offset+o.length;o.offset<=s?r=Math.max(r,i):r+=o.length,s=Math.max(s,i)}r=Math.min(r,t);const n=t>0?r/t*100:0;return{bytesWritten:r,percentage:n}},"calculateUploadProgress");g(a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&Array.isArray(t._chunks)){const e=typeof t._totalSize=="number"?t._totalSize:a.size||0;return j(t._chunks,e).bytesWritten}return a.bytesWritten||0},"getBytesWritten");const _=g(a=>(a.metadata||{})._chunkedUpload===!0,"isChunkedUpload"),U=g(a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&typeof t._totalSize=="number")return t._totalSize},"getTotalSize");var q=Object.defineProperty,$=y((a,t)=>q(a,"name",{value:t,configurable:!0}),"y");class ae{static{y(this,"M")}static{$(this,"RestBase")}async deleteSingle(t){const e=await this.storage.delete({id:t});if(e.status===void 0)throw u(404,"File not found");return{...e,headers:{},statusCode:204}}async handlePost(t,e,r,s,n){if(e&&t.size!==void 0){const d=typeof t.size=="number"?t.size:Number.parseInt(String(t.size),10);if(d>0&&d>this.storage.maxUploadSize)throw u(413,`File size exceeds maximum allowed size of ${this.storage.maxUploadSize} bytes`)}const o=await this.storage.create(t);if(e){const d=this.buildFileUrl(r,o);return b(o,{...z(o,d),"X-Chunked-Upload":"true","X-Upload-ID":o.id},201)}const i=await this.storage.write({body:s,contentLength:n,id:o.id,start:0}),h=this.buildFileUrl(r,i);return b(i,z(i,h),201)}async handlePut(t,e,r,s,n,o){let i,h=!1;try{await this.storage.getMeta(t),h=!0,o&&await this.storage.update({id:t},{metadata:o}),i=await this.storage.write({body:s,contentLength:n,id:t,start:0})}catch(m){const S=m;if(S.UploadErrorCode===A.FILE_NOT_FOUND||S.code==="ENOENT")try{const w=await this.storage.create(e);i=await this.storage.write({body:s,contentLength:n,id:w.id,start:0})}catch(w){throw w}else throw m}const d=this.buildFileUrl(r,i);return b(i,z(i,d),h?200:201)}async handlePatch(t,e,r,s,n,o){let i=await this.storage.getMeta(t);const h=i.metadata||{},d=_(i);if(d){const l=U(i);l&&i.size!==l&&(i={...i,size:l})}const m=typeof h._totalSize=="number"?h._totalSize:i.size||0;if(!d)throw u(400,"File is not a chunked upload. Use POST or PUT for full file uploads.");const S=100*1024*1024;try{H(e,r,m,S)}catch(l){throw l instanceof Error&&l.message.includes("exceeds maximum")?u(413,l.message):u(400,l instanceof Error?l.message:String(l))}if(i.status==="completed"){const l=this.buildFileUrl(n,i);return b(i,{...z(i,l),"X-Upload-Complete":"true"},200)}const w=await this.storage.withLock(`chunks:${t}`,async()=>{const l=(await this.storage.getMeta(t)).metadata??{},M=Array.isArray(l._chunks)?l._chunks:[],x=B(M,{checksum:s,length:r,offset:e});return await this.storage.update({id:t},{metadata:{...l,_chunks:x}}),x});let p=await this.storage.write({body:o,contentLength:r,id:t,start:e}),C=p.bytesWritten>=m;d&&(C=N(w,m),p.status==="completed"&&!C&&(await this.storage.update({id:t},{status:"part"}),p={...p,status:"part"}));const k=C&&p.bytesWritten!==m?{...p,bytesWritten:m}:p,F=this.buildFileUrl(n,k),O={...z(k,F),...v(k,C),"x-upload-offset":String(k.bytesWritten||0)};return b(k,O,C?200:202)}async handleHead(t){let e=await this.storage.getMeta(t);const r=_(e);if(r){const n=U(e);n&&e.size!==n&&(e={...e,size:n})}const s={...L(e)};if(r){const n=e.metadata||{},o=U(e)||e.size||0,i=Array.isArray(n._chunks)?n._chunks:[],h=N(i,o);Object.assign(s,v(e,h))}return b(e,s,200)}handleOptions(t,e){return{headers:{"Access-Control-Allow-Headers":"Authorization, Content-Type, Content-Length, Content-Disposition, X-File-Metadata, X-Chunked-Upload, X-Total-Size, X-Chunk-Offset, X-Chunk-Checksum","Access-Control-Allow-Methods":t.map(r=>r.toUpperCase()).join(", "),"Access-Control-Max-Age":86400,"X-Max-Upload-Size":String(e)},statusCode:204}}async deleteBatch(t){const e=await this.storage.deleteBatch(t);if(e.successfulCount===0&&e.failedCount>0){const r=e.failed.map(s=>s.id).join(", ");throw u(404,`Failed to delete files: ${r}`)}return{data:e.successful,headers:e.failedCount>0?{"X-Delete-Errors":JSON.stringify(e.failed),"X-Delete-Failed":String(e.failedCount),"X-Delete-Successful":String(e.successfulCount)}:{"X-Delete-Successful":String(e.successfulCount)},statusCode:e.successfulCount===t.length?204:207}}get storage(){throw new Error("storage must be implemented")}buildFileUrl(t,e){throw new Error("buildFileUrl must be implemented")}}export{ae as M,ee as a,R as b,P as c,te as e,I as p,Z as v};
@@ -0,0 +1 @@
1
+ var U=Object.defineProperty;var g=(l,t)=>U(l,"name",{value:t,configurable:!0});import{Readable as k}from"node:stream";import{c as C,B as T,$ as A,t as R}from"./storage-CI88PmRw.js";import{d as x}from"./detect-file-type-DRWGvQW4.js";import{throwErrorCode as y,ERRORS as f}from"./ERRORS-vMSqlI69.js";import{createRetryWrapper as v}from"./isRetryableError-CBZ65V6T.js";import{v as P}from"./local-meta-storage-tayO1ARY.js";import{u as I}from"./update-size-DANV7aa2.js";import{r as z}from"./part-match-D_NwyoF3.js";import{o as B}from"./has-content-Bx2p8Okx.js";import{o as E}from"./get-file-status-DLS18Zvd.js";var K=Object.defineProperty,L=g((l,t)=>K(l,"name",{value:t,configurable:!0}),"o$1");const N=L((l,t)=>{const i={};return Object.keys(l).forEach(e=>{i[e]=t(l[e])}),i},"mapValues");var $=Object.defineProperty,D=g((l,t)=>$(l,"name",{value:t,configurable:!0}),"t");const j=D(l=>l===Number(l)?l:(C(l)??0)/1e3,"toSeconds");var F=Object.defineProperty,b=g((l,t)=>F(l,"name",{value:t,configurable:!0}),"m");const W=5*1024*1024,_=16*1024*1024,q=b(l=>{if(l)return`bytes=${Math.max(0,l.start)}-${l.end===void 0?"":l.end}`},"buildRangeHeader");class S extends T{static{g(this,"S3BaseStorage")}static{b(this,"S3BaseStorage")}checksumTypes=["md5","crc32","crc32c","sha1","sha256"];supportsRange=!0;supportsDelimiter=!0;bucket;meta;MAX_PARTS=1e4;partSize;retry;resolvedRetryConfig;constructor(t){if(super(t),this.bucket=t.bucket,this.partSize=typeof t.partSize=="string"?A(t.partSize):t.partSize||_,this.partSize<W)throw new Error("Minimum allowed partSize value is 5MB");const i={backoffMultiplier:2,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:b(a=>{const s=a;return s.statusCode&&[408,429,500,502,503,504].includes(s.statusCode)?!0:s.retryable??!1},"shouldRetry"),...t.retryConfig};this.retry=v(i),this.resolvedRetryConfig=i;const{metaStorage:e,metaStorageConfig:r}=t;if(e)this.meta=e;else{const a={...t,...r,logger:this.logger};"directory"in a?(this.logger?.debug("Using local meta storage"),this.meta=new P(a)):this.meta=new P(a)}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(a=>{this.logger?.error("Storage access check failed: %O",a)})}getRetryConfig(){return this.resolvedRetryConfig}async create(t,i){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const n=typeof t.ttl=="string"?R(t.ttl):t.ttl;n!==void 0&&(e.expiredAt=Date.now()+n)}const r=new(this.getFileClass())(e);r.name=this.namingFunction(r),await this.validate(r);try{const n=await this.getMeta(r.id);if(n.bytesWritten>=0)return n}catch{}const a=this.getS3Api();let s;try{s=await this.runOperation(i,n=>a.createMultipartUpload({ACL:this.getAcl(),Bucket:this.bucket,ContentType:r.contentType,Key:r.name,Metadata:N({originalName:r.originalName,...r.metadata},o=>encodeURI(String(o)))},{signal:n}))}catch{return y(f.FILE_ERROR,"s3 create upload error")}const{UploadId:c}=s||{};return c?(r.UploadId=c,r.bytesWritten=0,this.config.clientDirectUpload&&(r.partSize??=this.partSize),await this.saveMeta(r),r.status="created",await this.onCreate(r),this.config.clientDirectUpload?this.buildPresigned(r):r):y(f.FILE_ERROR,"s3 create upload error")})}async write(t,i){return this.instrumentOperation("write",async()=>{let e;if("contentType"in t&&"metadata"in t&&!("body"in t)&&!("start"in t)?e=t:(e=await this.getMeta(t.id),await this.checkIfExpired(e)),e.status==="completed")return e;if(typeof t.size=="number"&&t.size>0&&I(e,t.size),!z(t,e))return y(f.FILE_CONFLICT);if(this.config.clientDirectUpload)return this.buildPresigned(e);e.Parts??=await this.getParts(e),e.bytesWritten=e.Parts.map(a=>a.Size||0).reduce((a,s)=>a+s,0);const r=await this.lock(t.id);try{if(B(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))return y(f.UNSUPPORTED_CHECKSUM_ALGORITHM);if(e.Parts.length===0&&(!e.contentType||e.contentType==="application/octet-stream"))try{const h=t.body instanceof k?t.body:k.fromWeb(t.body),{fileType:m,stream:w}=await x(h);m?.mime&&(e.contentType=m.mime),t.body=w}catch{}if(e.Parts.length>this.MAX_PARTS)throw new Error(`Exceeded ${this.MAX_PARTS} as part of the upload to ${this.bucket}.`);const a=e.Parts.length+1,s=this.getS3Api(),c=e.UploadId;if(!c)throw new Error("UploadId is required");const n=t.body,o=n instanceof Uint8Array,{ETag:u}=await this.runOperation(i,h=>s.uploadPart({Body:n,Bucket:this.bucket,ContentLength:t.contentLength||0,Key:e.name,PartNumber:a,UploadId:c,...t.checksumAlgorithm==="md5"?{ContentMD5:t.checksum}:{}},{signal:h}),{replayable:o}),p={ETag:u,PartNumber:a,Size:t.contentLength};e.Parts=[...e.Parts,p],e.bytesWritten+=t.contentLength||0}if(this.cache.set(e.id,e),e.status=E(e),e.status==="completed"){const[a]=await this.internalOnComplete(e);delete e.Parts,e.uri=a.Location,e.ETag=a.ETag}}finally{await this.unlock(t.id,r)}return e})}async delete({id:t},i){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);e.status="deleted",await this.abortMultipartUpload(e,i),await this.deleteMeta(e.id);const r={...e};return await this.onDelete(r),r})}async copy(t,i,e){return this.instrumentOperation("copy",async()=>{S.assertSafeId(t),S.assertSafeId(i);const r=await this.getMeta(t),a=`${this.bucket}/${t}`,s=this.bucket,c=i,n=this.getS3Api();return await this.runOperation(e,o=>n.copyObject({Bucket:s,CopySource:a,Key:c,...e?.storageClass&&{StorageClass:e.storageClass}},{signal:o})),{...r,id:c,name:c}})}async move(t,i,e){return this.instrumentOperation("move",async()=>{await this.copy(t,i,e);const r=this.getS3Api();return await this.runOperation(e,a=>r.deleteObject({Bucket:this.bucket,Key:t},{signal:a})),await this.getMeta(i)})}async list(t=1e3,i){return this.instrumentOperation("list",async()=>{const e=this.getS3Api(),r=Math.min(t,1e3);let a={Bucket:this.bucket,MaxKeys:r};const s=[];let c=!0;for(;c&&s.length<t;)try{const n=await this.runOperation(i,o=>e.listObjectsV2(a,{signal:o}));for(const{Key:o,LastModified:u}of n?.Contents||[]){if(s.length>=t)break;o!==void 0&&s.push({id:o,...u&&{createdAt:u}})}c=n.IsTruncated||!1,c&&n.NextContinuationToken&&s.length<t&&(a={...a,ContinuationToken:n.NextContinuationToken,MaxKeys:Math.min(r,t-s.length)})}catch(n){const o=this.normalizeError(n instanceof Error?n:new Error(String(n)));throw await this.onError(o),n}return s},{limit:t})}async listDirectory(t){return this.instrumentOperation("listDirectory",async()=>{const i=this.getS3Api(),e=t?.limit??1e3,r=Math.min(e,1e3);let a={Bucket:this.bucket,Delimiter:t?.delimiter,MaxKeys:r,...t?.prefix!==void 0&&{Prefix:t.prefix}};const s=[],c=new Set;let n=!0;for(;n&&s.length<e;)try{const o=await this.runOperation(t,u=>i.listObjectsV2(a,{signal:u}));for(const{Prefix:u}of o?.CommonPrefixes||[])u!==void 0&&c.add(u);for(const{Key:u,LastModified:p}of o?.Contents||[]){if(s.length>=e)break;u!==void 0&&s.push({id:u,...p&&{createdAt:p}})}n=o.IsTruncated||!1,n&&o.NextContinuationToken&&s.length<e&&(a={...a,ContinuationToken:o.NextContinuationToken,MaxKeys:Math.min(r,e-s.length)})}catch(o){const u=this.normalizeError(o instanceof Error?o:new Error(String(o)));throw await this.onError(u),o}return{files:s,prefixes:[...c]}},{limit:t?.limit??1e3})}async exists({id:t},i){return this.instrumentOperation("exists",async()=>{try{await this.getMeta(t);const e=this.getS3Api();return await this.runOperation(i,r=>e.headObject({Bucket:this.bucket,Key:t},{signal:r})),!0}catch{return!1}})}async get({id:t},i){return this.instrumentOperation("get",async()=>{const e=this.getS3Api(),r=q(i?.range),{Body:a,ContentLength:s,ContentType:c,ETag:n,Expires:o,LastModified:u,Metadata:p}=await this.runOperation(i,d=>e.getObject({Bucket:this.bucket,Key:t,...r!==void 0&&{Range:r}},{signal:d}));await this.checkIfExpired({expiredAt:o});const h=[];if(a)if(a instanceof k)for await(const d of a)h.push(d instanceof Uint8Array?d:new Uint8Array(d));else{const d=a.getReader();try{for(;;){const{done:M,value:O}=await d.read();if(M)break;h.push(O)}}finally{d.releaseLock()}}const{originalName:m,...w}=p||{};return{content:Buffer.concat(h),contentType:c,ETag:n,expiredAt:o,id:t,metadata:w,modifiedAt:u,name:t,originalName:m||t,size:Number(s)}})}async buildPresigned(t){const i=t;if(i.Parts?.length||(i.Parts=await this.getParts(t)),i.bytesWritten=i.Parts.map(e=>e.Size||0).reduce((e,r)=>e+r,0),t.status=E(i),i.partsUrls?.length||(i.partsUrls=await this.getPartsPresignedUrls(t)),t.status==="completed"){const[e]=await this.internalOnComplete(t);return delete i.Parts,i.uri=e.Location,t}return t}async getPartsPresignedUrls(t){t.partSize??=this.partSize;const i=t.UploadId;if(!i)throw new Error("UploadId is required for getting presigned URLs");const e=Math.trunc(t.size/this.partSize)+1,r=[],a=Math.trunc(j(this.config.expiration?.maxAge||"6hrs")),s=this.getS3Api();for(let c=0;c<e;c++)r.push(s.getPresignedUrl({Bucket:this.bucket,expiresIn:a,Key:t.name,PartNumber:c+1,UploadId:i}));return Promise.all(r)}async getParts(t){const i=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const{Parts:r=[]}=await this.runOperation(void 0,a=>i.listParts({Bucket:this.bucket,Key:t.name,UploadId:e},{signal:a}));return r}completeMultipartUpload(t){const i=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const r=t.Parts?.map(({ETag:a,PartNumber:s})=>{if(!a||!s)throw new Error("ETag and PartNumber are required");return{ETag:a,PartNumber:s}})||[];return this.runOperation(void 0,a=>i.completeMultipartUpload({Bucket:this.bucket,Key:t.name,Parts:r,UploadId:e},{signal:a}))}async abortMultipartUpload(t,i){if(t.status!=="completed")try{const e=this.getS3Api(),r=t.UploadId;if(!r)return;await this.runOperation(i,a=>e.abortMultipartUpload({Bucket:this.bucket,Key:t.name,UploadId:r},{signal:a}))}catch(e){this.logger?.error("abortMultipartUploadError: ",e);const r=this.normalizeError(e instanceof Error?e:new Error(String(e)));await this.onError(r)}}internalOnComplete=b(async t=>{const[i]=await Promise.all([this.completeMultipartUpload(t),this.deleteMeta(t.id)]);return[i,t]},"internalOnComplete")}export{S,q as b};
@@ -1,5 +1,5 @@
1
1
  import { Readable } from 'node:stream';
2
- import { F as File, M as MetaStorage, d as createRetryWrapper, R as RetryConfig, e as FileInit, B as BaseStorage, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn } from "./storage.d-X6TimMHY.js";
2
+ import { F as File, M as MetaStorage, c as createRetryWrapper, R as RetryConfig, b as FileInit, B as BaseStorage, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn } from "./storage.d-C6HtvSoY.js";
3
3
  /**
4
4
  * Part interface for multipart uploads.
5
5
  */
@@ -102,8 +102,13 @@ interface S3ApiOperations {
102
102
  listObjectsV2: (params: {
103
103
  Bucket: string;
104
104
  ContinuationToken?: string;
105
+ Delimiter?: string;
105
106
  MaxKeys?: number;
107
+ Prefix?: string;
106
108
  }, options?: S3CallOptions) => Promise<{
109
+ CommonPrefixes?: {
110
+ Prefix?: string;
111
+ }[];
107
112
  Contents?: {
108
113
  Key?: string;
109
114
  LastModified?: Date;
@@ -138,6 +143,7 @@ interface S3ApiOperations {
138
143
  declare abstract class S3BaseStorage<TFile extends S3CompatibleFile = S3CompatibleFile> extends BaseStorage<TFile> {
139
144
  override checksumTypes: string[];
140
145
  override readonly supportsRange: boolean;
146
+ override readonly supportsDelimiter: boolean;
141
147
  protected bucket: string;
142
148
  protected meta: MetaStorage<TFile>;
143
149
  /**
@@ -206,6 +212,20 @@ declare abstract class S3BaseStorage<TFile extends S3CompatibleFile = S3Compatib
206
212
  */
207
213
  override list(limit?: number, options?: OperationOptions): Promise<TFile[]>;
208
214
  /**
215
+ * Directory-style listing via S3's native `Delimiter`/`Prefix` — the provider returns the direct
216
+ * child objects plus the `CommonPrefixes` ("subdirectories") one delimiter level below `prefix`,
217
+ * so the whole subtree never has to be fetched. Pages until exhausted or `limit` direct files
218
+ * have been collected; common prefixes are accumulated (deduped) across pages.
219
+ */
220
+ override listDirectory(options?: OperationOptions & {
221
+ delimiter: string;
222
+ limit?: number;
223
+ prefix?: string;
224
+ }): Promise<{
225
+ files: TFile[];
226
+ prefixes: string[];
227
+ }>;
228
+ /**
209
229
  * Checks if a file exists by verifying both metadata and the actual S3 object.
210
230
  * Returns true only if both the metadata and the S3 object exist.
211
231
  * @param query File query containing the file ID to check.