@visulima/storage 1.0.0-alpha.1 → 1.0.0-alpha.3

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 (224) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +33 -14
  3. package/dist/adapter/nuxt/module.d.ts +39 -0
  4. package/dist/adapter/nuxt/module.js +93 -0
  5. package/dist/adapter/nuxt/package.json +20 -0
  6. package/dist/handler/base/base-handler-core.d.ts +91 -0
  7. package/dist/handler/base/base-handler-fetch.d.ts +76 -0
  8. package/dist/handler/base/base-handler-node.d.ts +137 -0
  9. package/dist/handler/http/fetch/index.d.ts +4 -0
  10. package/dist/handler/http/fetch/index.js +4 -0
  11. package/dist/handler/http/hono/index.d.ts +67 -0
  12. package/dist/handler/http/hono/index.js +65 -0
  13. package/dist/handler/http/nextjs/index.d.ts +61 -0
  14. package/dist/handler/http/nextjs/index.js +37 -0
  15. package/dist/handler/http/node/index.d.ts +4 -0
  16. package/dist/handler/http/node/index.js +4 -0
  17. package/dist/handler/http/solid-start/index.d.ts +60 -0
  18. package/dist/handler/http/solid-start/index.js +44 -0
  19. package/dist/handler/multipart/multipart-base.d.ts +84 -0
  20. package/dist/handler/multipart/multipart-fetch.d.ts +64 -0
  21. package/dist/handler/multipart/multipart.d.ts +49 -0
  22. package/dist/handler/rest/rest-base.d.ts +106 -0
  23. package/dist/handler/rest/rest-fetch.d.ts +88 -0
  24. package/dist/handler/rest/rest.d.ts +93 -0
  25. package/dist/handler/tus/tus-base.d.ts +152 -0
  26. package/dist/handler/tus/tus-fetch.d.ts +72 -0
  27. package/dist/handler/tus/tus.d.ts +78 -0
  28. package/dist/handler/types.d.ts +53 -0
  29. package/dist/handler/utils/request-parser.d.ts +72 -0
  30. package/dist/handler/utils/response-builder.d.ts +83 -0
  31. package/dist/handler/utils/storage-utils.d.ts +10 -0
  32. package/dist/handler/utils/stream-utils.d.ts +29 -0
  33. package/dist/handler/utils/upload-handlers.d.ts +76 -0
  34. package/dist/index.d.ts +17 -0
  35. package/dist/index.js +13 -0
  36. package/dist/metrics/index.d.ts +2 -0
  37. package/dist/metrics/no-op-metrics.d.ts +15 -0
  38. package/dist/metrics/opentelemetry-metrics.d.ts +55 -0
  39. package/dist/openapi/index.d.ts +5 -0
  40. package/dist/openapi/index.js +5 -0
  41. package/dist/openapi/rest.d.ts +7 -0
  42. package/dist/openapi/shared.d.ts +13 -0
  43. package/dist/openapi/transform.d.ts +3 -0
  44. package/dist/openapi/tus.d.ts +7 -0
  45. package/dist/openapi/xhr.d.ts +7 -0
  46. package/dist/packem_shared/AwsLightFile-tTneXZgG.js +11 -0
  47. package/dist/packem_shared/AwsLightMetaStorage-BWSOtVaN.js +4 -0
  48. package/dist/packem_shared/AwsLightStorage-Blv-GP4v.js +133 -0
  49. package/dist/packem_shared/AzureFile-CesgFzps.js +8 -0
  50. package/dist/packem_shared/AzureSMetaStorage-CFs-OYJT.js +88 -0
  51. package/dist/packem_shared/AzureStorage-B0v048hG.js +357 -0
  52. package/dist/packem_shared/BaseTransformer-C2gLib6v.js +82 -0
  53. package/dist/packem_shared/DiskStorage-BlltBst6.js +12 -0
  54. package/dist/packem_shared/DiskStorageWithChecksum-BJTmMklc.js +238 -0
  55. package/dist/packem_shared/ERRORS-D0apMqnc.js +97 -0
  56. package/dist/packem_shared/File-Bb3P23dr.js +69 -0
  57. package/dist/packem_shared/GCSConfig-vPP22kN6.js +11 -0
  58. package/dist/packem_shared/GCSFile-BIEunhAN.js +8 -0
  59. package/dist/packem_shared/GCSMetaStorage-BMFEdzJ7.js +7 -0
  60. package/dist/packem_shared/GCStorage-DnhiwaS9.js +406 -0
  61. package/dist/packem_shared/LocalMetaStorage-CZHhKkMd.js +7 -0
  62. package/dist/packem_shared/MediaTransformer-D6658DL1.js +1197 -0
  63. package/dist/packem_shared/MetaStorage-pECeFOad.js +46 -0
  64. package/dist/packem_shared/Metadata-DRLXeJ0F.js +89 -0
  65. package/dist/packem_shared/Multipart-CNFK_Okz.js +163 -0
  66. package/dist/packem_shared/Multipart-CtUL7BQw.js +128 -0
  67. package/dist/packem_shared/NetlifyBlobFile-CXzyjqrD.js +14 -0
  68. package/dist/packem_shared/NetlifyBlobMetaStorage-DxZ5aDvD.js +9 -0
  69. package/dist/packem_shared/NetlifyBlobStorage-CLPtjHqd.js +376 -0
  70. package/dist/packem_shared/NoOpMetrics-DhAk5rXc.js +10 -0
  71. package/dist/packem_shared/OpenTelemetryMetrics-BnxhqIaH.js +67 -0
  72. package/dist/packem_shared/Rest-CAOAEkOj.js +267 -0
  73. package/dist/packem_shared/Rest-DNuLwBrK.js +228 -0
  74. package/dist/packem_shared/S3File-DZiyk9Qt.js +11 -0
  75. package/dist/packem_shared/S3MetaStorage-Dz9aDabA.js +76 -0
  76. package/dist/packem_shared/S3Storage-DHmTk-hU.js +316 -0
  77. package/dist/packem_shared/TUS_RESUMABLE-GJzZ9R-f.js +434 -0
  78. package/dist/packem_shared/Tus-B8PmlMgR.js +200 -0
  79. package/dist/packem_shared/Tus-C4F1aYOl.js +195 -0
  80. package/dist/packem_shared/ValidationError-BfF1aE4h.js +26 -0
  81. package/dist/packem_shared/VercelBlobFile-BCg4aTEq.js +18 -0
  82. package/dist/packem_shared/VercelBlobMetaStorage-Bd9F-VFm.js +9 -0
  83. package/dist/packem_shared/VercelBlobStorage-DD9LMOS6.js +261 -0
  84. package/dist/packem_shared/_commonjsHelpers-B85MJLTf.js +5 -0
  85. package/dist/packem_shared/aws-light-meta-storage-DKJBgbR6.js +446 -0
  86. package/dist/packem_shared/backblaze-BlMnIcBC.js +20 -0
  87. package/dist/packem_shared/base-handler-core-BKuf4YLT.js +303 -0
  88. package/dist/packem_shared/base-handler-fetch-Cr0hLiqg.js +291 -0
  89. package/dist/packem_shared/base-handler-node-gk5aN9Cx.js +730 -0
  90. package/dist/packem_shared/cache-B88MXQ_2.js +18 -0
  91. package/dist/packem_shared/cloudflare-Bi1q8wXE.js +21 -0
  92. package/dist/packem_shared/defaultCloudStorageFileNameValidation-DUuacjWv.js +11 -0
  93. package/dist/packem_shared/digitalOcean-CWQRJM3L.js +21 -0
  94. package/dist/packem_shared/disk-storage-Bh2wy3YW.js +810 -0
  95. package/dist/packem_shared/gcs-meta-storage-0tgMNnPO.js +158 -0
  96. package/dist/packem_shared/has-content-CY66ehMK.js +3 -0
  97. package/dist/packem_shared/headers-DoS5nwM-.js +3220 -0
  98. package/dist/packem_shared/is-expired-CTThU1q5.js +8 -0
  99. package/dist/packem_shared/isRetryableError-Dycp7127.js +82 -0
  100. package/dist/packem_shared/isValidMediaType-BeDgiObq.js +35 -0
  101. package/dist/packem_shared/local-meta-storage-By-3SNBI.js +649 -0
  102. package/dist/packem_shared/minio-C2YBZQOw.js +22 -0
  103. package/dist/packem_shared/multipart-base-B3i67SSX.js +102 -0
  104. package/dist/packem_shared/part-match-BMNqHDYD.js +96 -0
  105. package/dist/packem_shared/path-CR6YkPXX-7R1-9CMk.js +161 -0
  106. package/dist/packem_shared/response-builder-BtnRiBUI.js +45 -0
  107. package/dist/packem_shared/rest-base-GRCcnan7.js +457 -0
  108. package/dist/packem_shared/restOpenApiSpec-CwcHHY2C.js +800 -0
  109. package/dist/packem_shared/s3-base-storage-C1DIHTYY.js +510 -0
  110. package/dist/packem_shared/sharedGet-Cpo7QUyu.js +1019 -0
  111. package/dist/packem_shared/storage-C6NSXb8h.js +1175 -0
  112. package/dist/packem_shared/tigris-Hac8TKnX.js +21 -0
  113. package/dist/packem_shared/transformOpenApiSpec-DWM5WtnN.js +975 -0
  114. package/dist/packem_shared/tusOpenApiSpec-6ohiToBy.js +740 -0
  115. package/dist/packem_shared/update-size-CCGm6i1J.js +8 -0
  116. package/dist/packem_shared/validator-BeX_lJet.js +78 -0
  117. package/dist/packem_shared/waitForStorage-Cscw85sx.js +18 -0
  118. package/dist/packem_shared/wasabi-DIyflHSd.js +21 -0
  119. package/dist/packem_shared/xhrOpenApiSpec-DS17brnx.js +264 -0
  120. package/dist/storage/aws/clients/backblaze.d.ts +12 -0
  121. package/dist/storage/aws/clients/cloudflare.d.ts +13 -0
  122. package/dist/storage/aws/clients/digital-ocean.d.ts +12 -0
  123. package/dist/storage/aws/clients/index.d.ts +6 -0
  124. package/dist/storage/aws/clients/index.js +6 -0
  125. package/dist/storage/aws/clients/minio.d.ts +13 -0
  126. package/dist/storage/aws/clients/tigris.d.ts +12 -0
  127. package/dist/storage/aws/clients/types.d.ts +95 -0
  128. package/dist/storage/aws/clients/wasabi.d.ts +12 -0
  129. package/dist/storage/aws/index.d.ts +4 -0
  130. package/dist/storage/aws/index.js +3 -0
  131. package/dist/storage/aws/s3-base-storage.d.ts +248 -0
  132. package/dist/storage/aws/s3-client-adapter.d.ts +110 -0
  133. package/dist/storage/aws/s3-file.d.ts +10 -0
  134. package/dist/storage/aws/s3-meta-storage.d.ts +15 -0
  135. package/dist/storage/aws/s3-storage.d.ts +70 -0
  136. package/dist/storage/aws/types.d.ts +119 -0
  137. package/dist/storage/aws-light/aws-light-api-adapter.d.ts +130 -0
  138. package/dist/storage/aws-light/aws-light-file.d.ts +10 -0
  139. package/dist/storage/aws-light/aws-light-meta-storage.d.ts +19 -0
  140. package/dist/storage/aws-light/aws-light-storage.d.ts +65 -0
  141. package/dist/storage/aws-light/index.d.ts +4 -0
  142. package/dist/storage/aws-light/index.js +3 -0
  143. package/dist/storage/aws-light/types.d.ts +37 -0
  144. package/dist/storage/azure/azure-file.d.ts +6 -0
  145. package/dist/storage/azure/azure-meta-storage.d.ts +15 -0
  146. package/dist/storage/azure/azure-storage.d.ts +69 -0
  147. package/dist/storage/azure/index.d.ts +4 -0
  148. package/dist/storage/azure/index.js +3 -0
  149. package/dist/storage/azure/types.d.ts +62 -0
  150. package/dist/storage/gcs/fetch-error.d.ts +11 -0
  151. package/dist/storage/gcs/gcs-config.d.ts +2 -0
  152. package/dist/storage/gcs/gcs-file.d.ts +6 -0
  153. package/dist/storage/gcs/gcs-meta-storage.d.ts +27 -0
  154. package/dist/storage/gcs/gcs-storage.d.ts +91 -0
  155. package/dist/storage/gcs/index.d.ts +5 -0
  156. package/dist/storage/gcs/index.js +4 -0
  157. package/dist/storage/gcs/types.d.ts +55 -0
  158. package/dist/storage/gcs/utils.d.ts +7 -0
  159. package/dist/storage/local/disk-storage-with-checksum.d.ts +15 -0
  160. package/dist/storage/local/disk-storage.d.ts +135 -0
  161. package/dist/storage/local/index.d.ts +4 -0
  162. package/dist/storage/local/index.js +3 -0
  163. package/dist/storage/local/local-meta-storage.d.ts +32 -0
  164. package/dist/storage/meta-storage.d.ts +30 -0
  165. package/dist/storage/netlify-blob/index.d.ts +4 -0
  166. package/dist/storage/netlify-blob/index.js +3 -0
  167. package/dist/storage/netlify-blob/netlify-blob-file.d.ts +12 -0
  168. package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +7 -0
  169. package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +93 -0
  170. package/dist/storage/netlify-blob/types.d.ts +30 -0
  171. package/dist/storage/storage.d.ts +353 -0
  172. package/dist/storage/types.d.ts +221 -0
  173. package/dist/storage/utils/file/file.d.ts +25 -0
  174. package/dist/storage/utils/file/get-file-status.d.ts +9 -0
  175. package/dist/storage/utils/file/has-content.d.ts +9 -0
  176. package/dist/storage/utils/file/index.d.ts +10 -0
  177. package/dist/storage/utils/file/is-expired.d.ts +8 -0
  178. package/dist/storage/utils/file/metadata.d.ts +18 -0
  179. package/dist/storage/utils/file/part-match.d.ts +11 -0
  180. package/dist/storage/utils/file/types.d.ts +37 -0
  181. package/dist/storage/utils/file/update-metadata.d.ts +10 -0
  182. package/dist/storage/utils/file/update-size.d.ts +10 -0
  183. package/dist/storage/vercel-blob/index.d.ts +4 -0
  184. package/dist/storage/vercel-blob/index.js +3 -0
  185. package/dist/storage/vercel-blob/types.d.ts +32 -0
  186. package/dist/storage/vercel-blob/vercel-blob-file.d.ts +16 -0
  187. package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +7 -0
  188. package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +76 -0
  189. package/dist/transformer/audio-transformer.d.ts +128 -0
  190. package/dist/transformer/audio-transformer.js +278 -0
  191. package/dist/transformer/base-transformer.d.ts +63 -0
  192. package/dist/transformer/image-transformer.d.ts +571 -0
  193. package/dist/transformer/image-transformer.js +1100 -0
  194. package/dist/transformer/index.d.ts +5 -0
  195. package/dist/transformer/index.js +4 -0
  196. package/dist/transformer/media-transformer.d.ts +332 -0
  197. package/dist/transformer/types.d.ts +652 -0
  198. package/dist/transformer/utils.d.ts +33 -0
  199. package/dist/transformer/validation-error.d.ts +23 -0
  200. package/dist/transformer/video-transformer.d.ts +145 -0
  201. package/dist/transformer/video-transformer.js +310 -0
  202. package/dist/utils/cache.d.ts +32 -0
  203. package/dist/utils/chunked-upload.d.ts +65 -0
  204. package/dist/utils/detect-file-type.d.ts +28 -0
  205. package/dist/utils/errors.d.ts +74 -0
  206. package/dist/utils/file-path-url-matcher.d.ts +18 -0
  207. package/dist/utils/headers.d.ts +111 -0
  208. package/dist/utils/http.d.ts +92 -0
  209. package/dist/utils/locker.d.ts +26 -0
  210. package/dist/utils/pipes/stream-checksum.d.ts +47 -0
  211. package/dist/utils/pipes/stream-length.d.ts +22 -0
  212. package/dist/utils/primitives/get-last-one.d.ts +3 -0
  213. package/dist/utils/primitives/is-record.d.ts +2 -0
  214. package/dist/utils/primitives/map-values.d.ts +9 -0
  215. package/dist/utils/primitives/pick.d.ts +2 -0
  216. package/dist/utils/primitives/to-milliseconds.d.ts +12 -0
  217. package/dist/utils/primitives/to-seconds.d.ts +12 -0
  218. package/dist/utils/range-checksum.d.ts +33 -0
  219. package/dist/utils/range-hasher.d.ts +46 -0
  220. package/dist/utils/retry.d.ts +64 -0
  221. package/dist/utils/types.d.ts +108 -0
  222. package/dist/utils/validation-error.d.ts +22 -0
  223. package/dist/utils/validator.d.ts +36 -0
  224. package/package.json +5 -5
@@ -0,0 +1,76 @@
1
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
+ import type { Readable } from "node:stream";
3
+ import type { UploadFile } from "../../storage/utils/index.d.ts";
4
+ import type { ResponseBody, UploadResponse } from "../../utils/types.d.ts";
5
+ import type { ResponseFile, ResponseList } from "../types.d.ts";
6
+ /**
7
+ * Handles HEAD/OPTIONS requests.
8
+ * @param file Response file with headers and status code
9
+ * @param send Function to send response
10
+ */
11
+ export declare const handleHeadOptionsRequest: <TFile extends UploadFile, NodeResponse extends ServerResponse>(file: ResponseFile<TFile>, send: (response: NodeResponse, data: {
12
+ headers: Record<string, string | number>;
13
+ statusCode: number;
14
+ }) => void, response: NodeResponse) => void;
15
+ /**
16
+ * Handles GET requests with streaming support.
17
+ * @param file Response file (may contain stream)
18
+ * @param request HTTP request
19
+ * @param response HTTP response
20
+ * @param next Optional Express next function
21
+ * @param send Function to send regular response
22
+ * @param sendStream Function to send stream response
23
+ * @param parseRangeHeader Function to parse range header
24
+ */
25
+ export declare const handleGetRequest: <TFile extends UploadFile, NodeResponse extends ServerResponse>(file: ResponseFile<TFile> | ResponseList<TFile>, request: IncomingMessage, response: NodeResponse, next: (() => void) | undefined, send: (response: NodeResponse, data: UploadResponse<ResponseBody>) => void, sendStream: (response: NodeResponse, stream: Readable, options: {
26
+ headers: Record<string, string | number>;
27
+ range?: {
28
+ end: number;
29
+ start: number;
30
+ };
31
+ size?: number;
32
+ statusCode: number;
33
+ }) => void, parseRangeHeader: (rangeHeader: string | undefined, fileSize: number) => {
34
+ end: number;
35
+ start: number;
36
+ } | undefined) => void;
37
+ /**
38
+ * Handles completed upload responses.
39
+ * @param file Response file
40
+ * @param request HTTP request
41
+ * @param response HTTP response
42
+ * @param next Optional Express next function
43
+ * @param storage Storage instance for onComplete hook
44
+ * @param logger Optional logger
45
+ * @param finish Function to finish the response
46
+ */
47
+ export declare const handleCompletedUpload: <TFile extends UploadFile, NodeResponse extends ServerResponse>(file: ResponseFile<TFile>, request: IncomingMessage, response: NodeResponse, next: (() => void) | undefined, storage: {
48
+ onComplete: (file: TFile, responseFile: ResponseFile<TFile>, request?: IncomingMessage) => void | Promise<void>;
49
+ }, logger: {
50
+ error?: (message: string, error: unknown) => void;
51
+ } | undefined, finish: (request: IncomingMessage, response: NodeResponse, uploadResponse: ResponseFile<TFile>) => void) => Promise<void>;
52
+ /**
53
+ * Handles partial upload responses.
54
+ * @param file Response file
55
+ * @param request HTTP request
56
+ * @param response HTTP response
57
+ * @param send Function to send response
58
+ */
59
+ export declare const handlePartialUpload: <TFile extends UploadFile, NodeResponse extends ServerResponse>(file: ResponseFile<TFile>, request: IncomingMessage, response: NodeResponse, send: (response: NodeResponse, data: {
60
+ body: Buffer | string | undefined;
61
+ headers: Record<string, string>;
62
+ statusCode: number;
63
+ }) => void) => void;
64
+ /**
65
+ * Handles errors during upload processing.
66
+ * @param error The error that occurred
67
+ * @param request HTTP request
68
+ * @param emit Function to emit events
69
+ * @param listenerCount Function to count event listeners
70
+ * @param logger Optional logger
71
+ * @param sendError Function to send error response
72
+ * @param response HTTP response
73
+ */
74
+ export declare const handleUploadError: <NodeResponse extends ServerResponse>(error: unknown, request: IncomingMessage, emit: (event: string, data: unknown) => boolean, listenerCount: (event: string) => number, logger: {
75
+ error?: (message: string, error: unknown) => void;
76
+ } | undefined, sendError: (response: NodeResponse, error: Error) => Promise<void>, response: NodeResponse) => Promise<void>;
@@ -0,0 +1,17 @@
1
+ export { waitForStorage } from "./handler/utils/storage-utils.d.ts";
2
+ export { NoOpMetrics, OpenTelemetryMetrics } from "./metrics/index.d.ts";
3
+ export { default as DiskStorage } from "./storage/local/disk-storage.d.ts";
4
+ export { default as DiskStorageWithChecksum } from "./storage/local/disk-storage-with-checksum.d.ts";
5
+ export type { LocalMetaStorageOptions } from "./storage/local/local-meta-storage.d.ts";
6
+ export { default as LocalMetaStorage } from "./storage/local/local-meta-storage.d.ts";
7
+ export { default as MetaStorage } from "./storage/meta-storage.d.ts";
8
+ export { BaseStorage as AbstractBaseStorage, defaultCloudStorageFileNameValidation, defaultFilesystemFileNameValidation } from "./storage/storage.d.ts";
9
+ export type { BaseStorageOptions, BatchOperationResponse, BatchOperationResult, DiskStorageOptions, DiskStorageWithChecksumOptions, ExpirationOptions, MetaStorageOptions, OnComplete, OnCreate, OnDelete, OnError, OnUpdate, PurgeList, } from "./storage/types.d.ts";
10
+ export type { FileInit, FilePart, FileQuery, UploadEventType, UploadFile } from "./storage/utils/file/index.d.ts";
11
+ export { File, Metadata } from "./storage/utils/file/index.d.ts";
12
+ export { ErrorMap, ERRORS, isUploadError, throwErrorCode, UploadError } from "./utils/errors.d.ts";
13
+ export type { RetryConfig } from "./utils/retry.d.ts";
14
+ export { createRetryWrapper, isRetryableError, retry } from "./utils/retry.d.ts";
15
+ export type { Header, Headers, HttpError, HttpErrorBody, IncomingMessageWithBody, Metrics, RangeChecksum, RangeHasher, ResponseBody, ResponseBodyType, ResponseTuple, UploadResponse, Validation, ValidationError, ValidatorConfig, } from "./utils/types.d.ts";
16
+ export type { AnyWebReadableByteStreamWithFileType, AnyWebReadableStream, Detector, FileTypeOptions, FileTypeParser, FileTypeResult, StreamOptions, TokenizerPositionError, } from "file-type";
17
+ export { fileTypeFromBlob, fileTypeFromBuffer, fileTypeFromTokenizer, supportedExtensions, supportedMimeTypes } from "file-type";
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ export { waitForStorage } from './packem_shared/waitForStorage-Cscw85sx.js';
2
+ export { D as DiskStorage } from './packem_shared/disk-storage-Bh2wy3YW.js';
3
+ export { default as DiskStorageWithChecksum } from './packem_shared/DiskStorageWithChecksum-BJTmMklc.js';
4
+ export { L as LocalMetaStorage } from './packem_shared/local-meta-storage-By-3SNBI.js';
5
+ export { default as MetaStorage } from './packem_shared/MetaStorage-pECeFOad.js';
6
+ export { B as AbstractBaseStorage, d as defaultCloudStorageFileNameValidation, a as defaultFilesystemFileNameValidation } from './packem_shared/storage-C6NSXb8h.js';
7
+ export { ERRORS, ErrorMap, UploadError, isUploadError, throwErrorCode } from './packem_shared/ERRORS-D0apMqnc.js';
8
+ export { createRetryWrapper, isRetryableError, retry } from './packem_shared/isRetryableError-Dycp7127.js';
9
+ export { fileTypeFromBlob, fileTypeFromBuffer, fileTypeFromTokenizer, supportedExtensions, supportedMimeTypes } from 'file-type';
10
+ export { default as NoOpMetrics } from './packem_shared/NoOpMetrics-DhAk5rXc.js';
11
+ export { default as OpenTelemetryMetrics } from './packem_shared/OpenTelemetryMetrics-BnxhqIaH.js';
12
+ export { default as File } from './packem_shared/File-Bb3P23dr.js';
13
+ export { Metadata } from './packem_shared/Metadata-DRLXeJ0F.js';
@@ -0,0 +1,2 @@
1
+ export { default as NoOpMetrics } from "./no-op-metrics.d.ts";
2
+ export { default as OpenTelemetryMetrics } from "./opentelemetry-metrics.d.ts";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * No-op metrics implementation.
3
+ * Used when metrics are not provided, ensuring no overhead when metrics are disabled.
4
+ */
5
+ import type { Metrics } from "../utils/types.d.ts";
6
+ /**
7
+ * No-op metrics that does nothing.
8
+ * Used as a default when metrics are not provided.
9
+ */
10
+ declare class NoOpMetrics implements Metrics {
11
+ increment(_name: string, _value?: number, _attributes?: Record<string, string | number>): void;
12
+ timing(_name: string, _duration: number, _attributes?: Record<string, string | number>): void;
13
+ gauge(_name: string, _value: number, _attributes?: Record<string, string | number>): void;
14
+ }
15
+ export default NoOpMetrics;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * OpenTelemetry Metrics implementation for storage operations.
3
+ *
4
+ * Provides counters, timers, and gauges using OpenTelemetry Metrics API.
5
+ * This allows integration with any OpenTelemetry-compatible observability backend
6
+ * (Prometheus, Datadog, New Relic, etc.).
7
+ * @example
8
+ * ```typescript
9
+ * import { metrics } from "@opentelemetry/api";
10
+ * import { OpenTelemetryMetrics } from "@visulima/storage/metrics";
11
+ * import { S3Storage } from "@visulima/storage/provider/aws";
12
+ *
13
+ * // Initialize OpenTelemetry (typically done once in your app)
14
+ * const meter = metrics.getMeter("@visulima/storage", "1.0.0");
15
+ *
16
+ * // Create metrics instance
17
+ * const storageMetrics = new OpenTelemetryMetrics(meter);
18
+ *
19
+ * // Use with storage
20
+ * const storage = new S3Storage({
21
+ * bucket: "my-bucket",
22
+ * metrics: storageMetrics,
23
+ * });
24
+ * ```
25
+ */
26
+ import type { Meter } from "@opentelemetry/api";
27
+ import type { Metrics } from "../utils/types.d.ts";
28
+ /**
29
+ * OpenTelemetry-based metrics implementation.
30
+ */
31
+ declare class OpenTelemetryMetrics implements Metrics {
32
+ private readonly meter;
33
+ private readonly counters;
34
+ private readonly histograms;
35
+ private readonly gauges;
36
+ /**
37
+ * Creates a new OpenTelemetryMetrics instance.
38
+ * @param meter OpenTelemetry Meter instance. If not provided, uses the default meter.
39
+ * @throws {Error} If \@opentelemetry/api is not installed
40
+ */
41
+ constructor(meter?: Meter);
42
+ /**
43
+ * Increment a counter metric.
44
+ */
45
+ increment(name: string, value?: number, attributes?: Record<string, string | number>): void;
46
+ /**
47
+ * Record a duration/timing metric in milliseconds.
48
+ */
49
+ timing(name: string, duration: number, attributes?: Record<string, string | number>): void;
50
+ /**
51
+ * Set a gauge metric value.
52
+ */
53
+ gauge(name: string, value: number, attributes?: Record<string, string | number>): void;
54
+ }
55
+ export default OpenTelemetryMetrics;
@@ -0,0 +1,5 @@
1
+ export { default as restOpenApiSpec } from "./rest.d.ts";
2
+ export { sharedErrorSchemaObject, sharedFileMetaExampleObject, sharedFileMetaSchemaObject, sharedGet, sharedGetList } from "./shared.d.ts";
3
+ export { default as transformOpenApiSpec } from "./transform.d.ts";
4
+ export { default as tusOpenApiSpec } from "./tus.d.ts";
5
+ export { default as xhrOpenApiSpec } from "./xhr.d.ts";
@@ -0,0 +1,5 @@
1
+ export { default as restOpenApiSpec } from '../packem_shared/restOpenApiSpec-CwcHHY2C.js';
2
+ export { sharedErrorSchemaObject, sharedFileMetaExampleObject, sharedFileMetaSchemaObject, sharedGet, sharedGetList } from '../packem_shared/sharedGet-Cpo7QUyu.js';
3
+ export { default as transformOpenApiSpec } from '../packem_shared/transformOpenApiSpec-DWM5WtnN.js';
4
+ export { default as tusOpenApiSpec } from '../packem_shared/tusOpenApiSpec-6ohiToBy.js';
5
+ export { default as xhrOpenApiSpec } from '../packem_shared/xhrOpenApiSpec-DS17brnx.js';
@@ -0,0 +1,7 @@
1
+ import type { OpenAPIV3 } from "openapi-types";
2
+ declare const swaggerSpec: (origin: string, path: string, options: {
3
+ supportedTransformerFormat?: string[];
4
+ tags?: string[] | undefined;
5
+ transformer?: boolean | "audio" | "video" | "image";
6
+ }) => Partial<OpenAPIV3.Document>;
7
+ export default swaggerSpec;
@@ -0,0 +1,13 @@
1
+ import type { OpenAPIV3 } from "openapi-types";
2
+ type TransformType = boolean | "audio" | "video" | "image";
3
+ declare const getOrganizedTransformationParameters: (transform?: TransformType, format?: string[]) => {
4
+ groups: Record<string, string[]>;
5
+ parameters: OpenAPIV3.ParameterObject[];
6
+ };
7
+ export { getOrganizedTransformationParameters };
8
+ export declare const sharedGet: (operationId: string, tags: string[] | undefined, transform?: TransformType, transformerFormat?: string[]) => OpenAPIV3.OperationObject;
9
+ export declare const sharedGetMeta: (operationId: string, tags: string[] | undefined) => OpenAPIV3.OperationObject;
10
+ export declare const sharedErrorSchemaObject: Record<string, OpenAPIV3.NonArraySchemaObject>;
11
+ export declare const sharedFileMetaSchemaObject: Record<string, OpenAPIV3.NonArraySchemaObject>;
12
+ export declare const sharedFileMetaExampleObject: Record<string, OpenAPIV3.ExampleObject>;
13
+ export declare const sharedGetList: (operationId: string, tags: string[] | undefined) => OpenAPIV3.OperationObject;
@@ -0,0 +1,3 @@
1
+ import type { OpenAPIV3 } from "openapi-types";
2
+ declare const swaggerSpec: (path?: string, tags?: string[] | undefined) => Partial<OpenAPIV3.Document>;
3
+ export default swaggerSpec;
@@ -0,0 +1,7 @@
1
+ import type { OpenAPIV3 } from "openapi-types";
2
+ declare const swaggerSpec: (path: string, options: {
3
+ supportedTransformerFormat?: string[];
4
+ tags?: string[] | undefined;
5
+ transformer?: boolean | "audio" | "video" | "image";
6
+ }) => Partial<OpenAPIV3.Document>;
7
+ export default swaggerSpec;
@@ -0,0 +1,7 @@
1
+ import type { OpenAPIV3 } from "openapi-types";
2
+ declare const swaggerSpec: (origin: string, path: string, options: {
3
+ supportedTransformerFormat?: string[];
4
+ tags?: string[] | undefined;
5
+ transformer?: boolean | "audio" | "video" | "image";
6
+ }) => Partial<OpenAPIV3.Document>;
7
+ export default swaggerSpec;
@@ -0,0 +1,11 @@
1
+ import File from './File-Bb3P23dr.js';
2
+
3
+ class AwsLightFile extends File {
4
+ Parts;
5
+ UploadId;
6
+ uri;
7
+ partsUrls;
8
+ partSize;
9
+ }
10
+
11
+ export { AwsLightFile as default };
@@ -0,0 +1,4 @@
1
+ import './MetaStorage-pECeFOad.js';
2
+ import './Metadata-DRLXeJ0F.js';
3
+ export { A as default } from './aws-light-meta-storage-DKJBgbR6.js';
4
+ import './is-expired-CTThU1q5.js';
@@ -0,0 +1,133 @@
1
+ import { Readable } from 'node:stream';
2
+ import { S as S3BaseStorage } from './s3-base-storage-C1DIHTYY.js';
3
+ import { a as AwsLightApiAdapter, A as AwsLightMetaStorage } from './aws-light-meta-storage-DKJBgbR6.js';
4
+ import AwsLightFile from './AwsLightFile-tTneXZgG.js';
5
+
6
+ class AwsLightStorage extends S3BaseStorage {
7
+ static name = "aws-light";
8
+ s3Api;
9
+ constructor(config) {
10
+ const { bucket = process.env.S3_BUCKET || process.env.AWS_S3_BUCKET, region = process.env.S3_REGION || process.env.AWS_REGION } = config;
11
+ if (!bucket) {
12
+ throw new Error("S3 bucket is not defined");
13
+ }
14
+ if (!region) {
15
+ throw new Error("S3 region is not defined");
16
+ }
17
+ if (!config.accessKeyId) {
18
+ throw new Error("accessKeyId is required");
19
+ }
20
+ if (!config.secretAccessKey) {
21
+ throw new Error("secretAccessKey is required");
22
+ }
23
+ super({
24
+ bucket,
25
+ clientDirectUpload: config.clientDirectUpload,
26
+ expiration: config.expiration?.maxAge ? { maxAge: String(config.expiration.maxAge) } : void 0,
27
+ filename: config.filename,
28
+ logger: config.logger,
29
+ metaStorage: config.metaStorage,
30
+ metaStorageConfig: config.metaStorageConfig ? { ...config.metaStorageConfig, ...config } : { ...config },
31
+ partSize: config.partSize,
32
+ retryConfig: {
33
+ ...config.retryConfig,
34
+ shouldRetry: (error) => {
35
+ const errorWithStatus = error;
36
+ if (errorWithStatus.statusCode && [408, 429, 500, 502, 503, 504].includes(errorWithStatus.statusCode)) {
37
+ return true;
38
+ }
39
+ return errorWithStatus.retryable ?? false;
40
+ }
41
+ }
42
+ });
43
+ this.s3Api = new AwsLightApiAdapter({
44
+ accessKeyId: config.accessKeyId,
45
+ bucket,
46
+ endpoint: config.endpoint,
47
+ region,
48
+ secretAccessKey: config.secretAccessKey,
49
+ service: config.service,
50
+ sessionToken: config.sessionToken
51
+ });
52
+ const { metaStorage, metaStorageConfig } = config;
53
+ if (!metaStorage) {
54
+ const metaConfig = { ...config, ...metaStorageConfig, logger: this.logger };
55
+ this.meta = new AwsLightMetaStorage(metaConfig);
56
+ }
57
+ }
58
+ /**
59
+ * Normalizes AWS S3 errors with S3-specific context.
60
+ */
61
+ normalizeError(error) {
62
+ const awsError = error;
63
+ if (awsError.statusCode || awsError.code) {
64
+ return {
65
+ code: awsError.code || awsError.name,
66
+ message: awsError.message,
67
+ name: awsError.name,
68
+ statusCode: awsError.statusCode || 500
69
+ };
70
+ }
71
+ return super.normalizeError(error);
72
+ }
73
+ async update({ id }, metadata) {
74
+ if (this.config.clientDirectUpload) {
75
+ const file = await this.getMeta(id);
76
+ return this.buildPresigned({ ...file, ...metadata });
77
+ }
78
+ return super.update({ id }, metadata);
79
+ }
80
+ async getStream({ id }) {
81
+ return this.instrumentOperation("getStream", async () => {
82
+ const s3Api = this.getS3Api();
83
+ const { Body, ContentLength, ContentType, ETag, Expires, LastModified } = await this.retry(
84
+ () => s3Api.getObject({
85
+ Bucket: this.bucket,
86
+ Key: id
87
+ })
88
+ );
89
+ await this.checkIfExpired({ expiredAt: Expires });
90
+ const stream = Body instanceof ReadableStream ? Readable.fromWeb(Body) : Body;
91
+ const readableStream = new Readable({
92
+ read() {
93
+ stream.on("data", (chunk) => {
94
+ this.push(chunk);
95
+ });
96
+ stream.on("end", () => {
97
+ this.push(null);
98
+ });
99
+ stream.on("error", (error) => {
100
+ this.destroy(error);
101
+ });
102
+ }
103
+ });
104
+ return {
105
+ headers: {
106
+ "Content-Length": ContentLength?.toString() ?? "0",
107
+ "Content-Type": ContentType,
108
+ ...ETag && { ETag },
109
+ ...Expires && { "X-Upload-Expires": Expires.toString() },
110
+ ...LastModified && { "Last-Modified": LastModified.toString() }
111
+ },
112
+ size: Number(ContentLength),
113
+ stream: readableStream
114
+ };
115
+ });
116
+ }
117
+ getS3Api() {
118
+ return this.s3Api;
119
+ }
120
+ // eslint-disable-next-line class-methods-use-this
121
+ getFileClass() {
122
+ return AwsLightFile;
123
+ }
124
+ // eslint-disable-next-line class-methods-use-this
125
+ getAcl() {
126
+ return void 0;
127
+ }
128
+ async accessCheck(_maxWaitTime = 30) {
129
+ await this.s3Api.checkBucketAccess({ Bucket: this.bucket });
130
+ }
131
+ }
132
+
133
+ export { AwsLightStorage as default };
@@ -0,0 +1,8 @@
1
+ import File from './File-Bb3P23dr.js';
2
+
3
+ class AzureFile extends File {
4
+ requestId;
5
+ uri;
6
+ }
7
+
8
+ export { AzureFile as default };
@@ -0,0 +1,88 @@
1
+ import { BlobServiceClient, StorageSharedKeyCredential } from '@azure/storage-blob';
2
+ import { throwErrorCode, ERRORS } from './ERRORS-D0apMqnc.js';
3
+ import MetaStorage from './MetaStorage-pECeFOad.js';
4
+ import { parseMetadata, stringifyMetadata } from './Metadata-DRLXeJ0F.js';
5
+
6
+ class AzureMetaStorage extends MetaStorage {
7
+ constructor(config) {
8
+ super(config);
9
+ this.config = config;
10
+ const { client, ...metaConfig } = config;
11
+ if (client === void 0) {
12
+ const connectionString = metaConfig.connectionString || process.env.AZURE_STORAGE_CONNECTION_STRING || void 0;
13
+ if (connectionString) {
14
+ this.client = BlobServiceClient.fromConnectionString(connectionString);
15
+ } else {
16
+ const accountKey = metaConfig.accountKey || process.env.AZURE_STORAGE_ACCOUNT_KEY || void 0;
17
+ const accountName = metaConfig.accountName || process.env.AZURE_STORAGE_ACCOUNT || void 0;
18
+ if (!metaConfig.accountKey) {
19
+ throw new Error("Missing required parameter: Azure blob storage account key.");
20
+ }
21
+ if (!metaConfig.accountName) {
22
+ throw new Error("Missing required parameter: Azure blob storage account name.");
23
+ }
24
+ const signedCredentials = new StorageSharedKeyCredential(accountName, accountKey);
25
+ this.client = new BlobServiceClient(config.endpoint ?? `https://${accountName}.blob.core.windows.net`, signedCredentials);
26
+ }
27
+ } else {
28
+ this.client = client;
29
+ }
30
+ const containerName = metaConfig.containerName || process.env.AZURE_STORAGE_CONTAINER || void 0;
31
+ if (!containerName) {
32
+ throw new Error("Missing required parameter: Azure container name.");
33
+ }
34
+ this.containerClient = this.client.getContainerClient(metaConfig.containerName);
35
+ }
36
+ client;
37
+ containerClient;
38
+ async get(id) {
39
+ const appendBlobClient = this.containerClient.getAppendBlobClient(this.getMetaName(id));
40
+ let propertyData;
41
+ try {
42
+ propertyData = await appendBlobClient.getProperties();
43
+ } catch {
44
+ throw throwErrorCode(ERRORS.UNKNOWN_ERROR);
45
+ }
46
+ if (!propertyData.metadata) {
47
+ throw throwErrorCode(ERRORS.FILE_NOT_FOUND);
48
+ }
49
+ const file = propertyData.metadata;
50
+ if (file.metadata && typeof file.metadata === "string") {
51
+ file.metadata = parseMetadata(file.metadata);
52
+ }
53
+ return file;
54
+ }
55
+ async touch(id, file) {
56
+ return this.save(id, file);
57
+ }
58
+ async delete(id) {
59
+ const blobClient = this.containerClient.getBlockBlobClient(this.getMetaName(id));
60
+ await blobClient.deleteIfExists();
61
+ }
62
+ async save(id, file) {
63
+ const transformedMetadata = { ...file };
64
+ if (transformedMetadata.metadata) {
65
+ transformedMetadata.metadata = stringifyMetadata(file.metadata);
66
+ }
67
+ const appendBlobClient = this.containerClient.getAppendBlobClient(this.getMetaName(id));
68
+ await appendBlobClient.setMetadata(transformedMetadata, {});
69
+ return file;
70
+ }
71
+ async list() {
72
+ const blobs = [];
73
+ const iterator = this.containerClient.listBlobsFlat({
74
+ prefix: this.prefix
75
+ });
76
+ for await (const blob of iterator) {
77
+ blobs.push(blob);
78
+ }
79
+ return blobs.filter((blob) => blob.name.endsWith(this.suffix)).map((blob) => {
80
+ return {
81
+ createdAt: blob.properties.createdOn,
82
+ id: this.getIdFromMetaName(blob.name)
83
+ };
84
+ });
85
+ }
86
+ }
87
+
88
+ export { AzureMetaStorage as default };