@visulima/storage 1.0.0-alpha.15 → 1.0.0-alpha.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE.md +1094 -382
  3. package/dist/adapter/nuxt/module.d.ts +41 -34
  4. package/dist/handler/http/fetch/index.d.ts +297 -4
  5. package/dist/handler/http/hono/index.d.ts +1474 -58
  6. package/dist/handler/http/nextjs/index.d.ts +66 -58
  7. package/dist/handler/http/node/index.d.ts +361 -4
  8. package/dist/handler/http/solid-start/index.d.ts +66 -57
  9. package/dist/index.d.ts +376 -17
  10. package/dist/openapi/index.d.ts +24 -5
  11. package/dist/packem_shared/{GCSMetaStorage-BkUIdJ5m.js → GCSMetaStorage-CNXq7vGd.js} +1 -1
  12. package/dist/packem_shared/{GCStorage-BnsSAjdW.js → GCStorage-CdnSuQwa.js} +1 -1
  13. package/dist/packem_shared/S3Client.d-CZ62Jztg.d.ts +20357 -0
  14. package/dist/packem_shared/disk-storage-with-checksum.d-hEoe2ugb.d.ts +148 -0
  15. package/dist/packem_shared/{gcs-meta-storage-DBeGn2ix.js → gcs-meta-storage-B5AVt1aS.js} +1 -1
  16. package/dist/packem_shared/local-meta-storage.d-Dop9RP9k.d.ts +20 -0
  17. package/dist/packem_shared/media-transformer.d-DeHZkBVx.d.ts +331 -0
  18. package/dist/packem_shared/s3-base-storage.d-CczjSe98.d.ts +251 -0
  19. package/dist/packem_shared/storage.d-BOMUJD96.d.ts +939 -0
  20. package/dist/packem_shared/tus-base.d-BftIixIA.d.ts +99 -0
  21. package/dist/packem_shared/types.d-BPd_JkW1.d.ts +708 -0
  22. package/dist/packem_shared/types.d-D-mlfmef.d.ts +49 -0
  23. package/dist/storage/aws/clients/index.d.ts +166 -6
  24. package/dist/storage/aws/index.d.ts +320 -4
  25. package/dist/storage/aws-light/index.d.ts +252 -4
  26. package/dist/storage/azure/index.d.ts +10422 -4
  27. package/dist/storage/gcs/index.d.ts +4107 -5
  28. package/dist/storage/gcs/index.js +2 -2
  29. package/dist/storage/local/index.d.ts +7 -4
  30. package/dist/storage/netlify-blob/index.d.ts +142 -4
  31. package/dist/storage/vercel-blob/index.d.ts +129 -4
  32. package/dist/transformer/audio-transformer.d.ts +127 -125
  33. package/dist/transformer/image-transformer.d.ts +569 -568
  34. package/dist/transformer/index.d.ts +62 -5
  35. package/dist/transformer/video-transformer.d.ts +144 -142
  36. package/package.json +37 -37
  37. package/dist/handler/base/base-handler-core.d.ts +0 -91
  38. package/dist/handler/base/base-handler-fetch.d.ts +0 -76
  39. package/dist/handler/base/base-handler-node.d.ts +0 -137
  40. package/dist/handler/multipart/multipart-base.d.ts +0 -84
  41. package/dist/handler/multipart/multipart-fetch.d.ts +0 -64
  42. package/dist/handler/multipart/multipart.d.ts +0 -49
  43. package/dist/handler/rest/rest-base.d.ts +0 -106
  44. package/dist/handler/rest/rest-fetch.d.ts +0 -88
  45. package/dist/handler/rest/rest.d.ts +0 -93
  46. package/dist/handler/tus/tus-base.d.ts +0 -152
  47. package/dist/handler/tus/tus-fetch.d.ts +0 -72
  48. package/dist/handler/tus/tus.d.ts +0 -78
  49. package/dist/handler/types.d.ts +0 -53
  50. package/dist/handler/utils/request-parser.d.ts +0 -72
  51. package/dist/handler/utils/response-builder.d.ts +0 -83
  52. package/dist/handler/utils/storage-utils.d.ts +0 -10
  53. package/dist/handler/utils/stream-utils.d.ts +0 -29
  54. package/dist/handler/utils/upload-handlers.d.ts +0 -76
  55. package/dist/metrics/index.d.ts +0 -2
  56. package/dist/metrics/no-op-metrics.d.ts +0 -15
  57. package/dist/metrics/opentelemetry-metrics.d.ts +0 -55
  58. package/dist/openapi/rest.d.ts +0 -7
  59. package/dist/openapi/shared.d.ts +0 -13
  60. package/dist/openapi/transform.d.ts +0 -3
  61. package/dist/openapi/tus.d.ts +0 -7
  62. package/dist/openapi/xhr.d.ts +0 -7
  63. package/dist/storage/aws/clients/backblaze.d.ts +0 -12
  64. package/dist/storage/aws/clients/cloudflare.d.ts +0 -13
  65. package/dist/storage/aws/clients/digital-ocean.d.ts +0 -12
  66. package/dist/storage/aws/clients/minio.d.ts +0 -13
  67. package/dist/storage/aws/clients/tigris.d.ts +0 -12
  68. package/dist/storage/aws/clients/types.d.ts +0 -95
  69. package/dist/storage/aws/clients/wasabi.d.ts +0 -12
  70. package/dist/storage/aws/s3-base-storage.d.ts +0 -248
  71. package/dist/storage/aws/s3-client-adapter.d.ts +0 -110
  72. package/dist/storage/aws/s3-file.d.ts +0 -10
  73. package/dist/storage/aws/s3-meta-storage.d.ts +0 -15
  74. package/dist/storage/aws/s3-storage.d.ts +0 -70
  75. package/dist/storage/aws/types.d.ts +0 -118
  76. package/dist/storage/aws-light/aws-light-api-adapter.d.ts +0 -130
  77. package/dist/storage/aws-light/aws-light-file.d.ts +0 -10
  78. package/dist/storage/aws-light/aws-light-meta-storage.d.ts +0 -19
  79. package/dist/storage/aws-light/aws-light-storage.d.ts +0 -66
  80. package/dist/storage/aws-light/types.d.ts +0 -36
  81. package/dist/storage/azure/azure-file.d.ts +0 -6
  82. package/dist/storage/azure/azure-meta-storage.d.ts +0 -15
  83. package/dist/storage/azure/azure-storage.d.ts +0 -69
  84. package/dist/storage/azure/types.d.ts +0 -61
  85. package/dist/storage/gcs/fetch-error.d.ts +0 -11
  86. package/dist/storage/gcs/gcs-config.d.ts +0 -2
  87. package/dist/storage/gcs/gcs-file.d.ts +0 -6
  88. package/dist/storage/gcs/gcs-meta-storage.d.ts +0 -27
  89. package/dist/storage/gcs/gcs-storage.d.ts +0 -91
  90. package/dist/storage/gcs/types.d.ts +0 -54
  91. package/dist/storage/gcs/utils.d.ts +0 -7
  92. package/dist/storage/local/disk-storage-with-checksum.d.ts +0 -15
  93. package/dist/storage/local/disk-storage.d.ts +0 -135
  94. package/dist/storage/local/local-meta-storage.d.ts +0 -27
  95. package/dist/storage/meta-storage-options.d.ts +0 -11
  96. package/dist/storage/meta-storage.d.ts +0 -30
  97. package/dist/storage/netlify-blob/netlify-blob-file.d.ts +0 -12
  98. package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +0 -6
  99. package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +0 -93
  100. package/dist/storage/netlify-blob/types.d.ts +0 -29
  101. package/dist/storage/storage.d.ts +0 -353
  102. package/dist/storage/types.d.ts +0 -217
  103. package/dist/storage/utils/file/file.d.ts +0 -25
  104. package/dist/storage/utils/file/get-file-status.d.ts +0 -9
  105. package/dist/storage/utils/file/has-content.d.ts +0 -9
  106. package/dist/storage/utils/file/index.d.ts +0 -10
  107. package/dist/storage/utils/file/is-expired.d.ts +0 -8
  108. package/dist/storage/utils/file/metadata.d.ts +0 -18
  109. package/dist/storage/utils/file/part-match.d.ts +0 -11
  110. package/dist/storage/utils/file/types.d.ts +0 -37
  111. package/dist/storage/utils/file/update-metadata.d.ts +0 -10
  112. package/dist/storage/utils/file/update-size.d.ts +0 -10
  113. package/dist/storage/vercel-blob/types.d.ts +0 -31
  114. package/dist/storage/vercel-blob/vercel-blob-file.d.ts +0 -16
  115. package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +0 -6
  116. package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +0 -76
  117. package/dist/transformer/base-transformer.d.ts +0 -63
  118. package/dist/transformer/media-transformer.d.ts +0 -332
  119. package/dist/transformer/transformer-config.d.ts +0 -16
  120. package/dist/transformer/types.d.ts +0 -639
  121. package/dist/transformer/utils.d.ts +0 -33
  122. package/dist/transformer/validation-error.d.ts +0 -23
  123. package/dist/utils/cache.d.ts +0 -32
  124. package/dist/utils/chunked-upload.d.ts +0 -65
  125. package/dist/utils/detect-file-type.d.ts +0 -28
  126. package/dist/utils/errors.d.ts +0 -74
  127. package/dist/utils/file-path-url-matcher.d.ts +0 -18
  128. package/dist/utils/headers.d.ts +0 -111
  129. package/dist/utils/http.d.ts +0 -92
  130. package/dist/utils/locker.d.ts +0 -26
  131. package/dist/utils/pipes/stream-checksum.d.ts +0 -47
  132. package/dist/utils/pipes/stream-length.d.ts +0 -22
  133. package/dist/utils/primitives/get-last-one.d.ts +0 -3
  134. package/dist/utils/primitives/is-record.d.ts +0 -2
  135. package/dist/utils/primitives/map-values.d.ts +0 -9
  136. package/dist/utils/primitives/pick.d.ts +0 -2
  137. package/dist/utils/primitives/to-milliseconds.d.ts +0 -12
  138. package/dist/utils/primitives/to-seconds.d.ts +0 -12
  139. package/dist/utils/range-checksum.d.ts +0 -33
  140. package/dist/utils/range-hasher.d.ts +0 -46
  141. package/dist/utils/retry.d.ts +0 -64
  142. package/dist/utils/types.d.ts +0 -108
  143. package/dist/utils/validation-error.d.ts +0 -22
  144. package/dist/utils/validator.d.ts +0 -36
@@ -0,0 +1,49 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import { IncomingMessage } from 'node:http';
3
+ import { Readable } from 'node:stream';
4
+ import { PaginationResult } from '@visulima/pagination';
5
+ import { U as UploadFile, B as BaseStorage, f as UploadError, g as UploadEventType } from "./storage.d-BOMUJD96.js";
6
+ import { M as MediaTransformer } from "./media-transformer.d-DeHZkBVx.js";
7
+ type WebRequest = globalThis.Request;
8
+ type WebResponse = globalThis.Response;
9
+ interface BaseResponse {
10
+ headers: Record<string, number | string>;
11
+ statusCode: number;
12
+ }
13
+ interface StreamingResponse extends BaseResponse {
14
+ /** Total size of the stream (for Content-Length header) */
15
+ size?: number;
16
+ /** Stream of data to send */
17
+ stream: Readable;
18
+ }
19
+ interface RequestEvent {
20
+ request: Pick<IncomingMessage, "headers" | "method" | "url">;
21
+ }
22
+ type AsyncHandler<Request, Response> = (request: Request, response: Response) => Promise<void | ResponseFile<UploadFile> | ResponseList<UploadFile> | StreamingResponse>;
23
+ type Handlers = "delete" | "download" | "get" | "head" | "options" | "patch" | "post" | "put";
24
+ type MethodHandler<Request, Response> = { [h in Handlers]?: AsyncHandler<Request, Response> };
25
+ type UploadEvent<TFile extends UploadFile> = RequestEvent & TFile;
26
+ type UploadErrorEvent = RequestEvent & UploadError;
27
+ type ResponseFile<TFile extends UploadFile> = BaseResponse & TFile & {
28
+ /** Optional stream for streaming responses instead of content buffer */
29
+ stream?: Readable;
30
+ };
31
+ type ResponseList<TFile extends UploadFile> = BaseResponse & {
32
+ data: PaginationResult<TFile> | TFile[];
33
+ };
34
+ interface BaseHandler<TFile extends UploadFile> extends EventEmitter {
35
+ emit: ((event: "error", error: UploadErrorEvent) => boolean) & ((event: UploadEventType, payload: UploadEvent<TFile>) => boolean);
36
+ fetch: (request: WebRequest) => Promise<WebResponse>;
37
+ off: ((event: "error", listener: (error: UploadErrorEvent) => void) => this) & ((event: UploadEventType, listener: (payload: UploadEvent<TFile>) => void) => this);
38
+ on: ((event: "error", listener: (error: UploadErrorEvent) => void) => this) & ((event: UploadEventType, listener: (payload: UploadEvent<TFile>) => void) => this);
39
+ }
40
+ interface UploadOptions<TFile extends UploadFile> {
41
+ disableTerminationForFinishedUploads?: boolean;
42
+ /** Maximum file size for multipart parser (default: min(storage.maxUploadSize, 1GB)) */
43
+ maxFileSize?: number;
44
+ /** Maximum header size for multipart parser (default: 64KB) */
45
+ maxHeaderSize?: number;
46
+ mediaTransformer?: MediaTransformer;
47
+ storage: BaseStorage<TFile>;
48
+ }
49
+ export { AsyncHandler as A, BaseHandler as B, Handlers as H, MethodHandler as M, ResponseFile as R, UploadOptions as U, ResponseList as a, RequestEvent as b, UploadErrorEvent as c, UploadEvent as d };
@@ -1,6 +1,166 @@
1
- export { default as backblaze } from "./backblaze.d.ts";
2
- export { default as cloudflare } from "./cloudflare.d.ts";
3
- export { default as digitalOcean } from "./digital-ocean.d.ts";
4
- export { default as minio } from "./minio.d.ts";
5
- export { default as tigris } from "./tigris.d.ts";
6
- export { default as wasabi } from "./wasabi.d.ts";
1
+ import { S as S3ClientConfig } from "../../../packem_shared/S3Client.d-CZ62Jztg.js";
2
+ import '@aws-sdk/middleware-flexible-checksums';
3
+ import '@aws-sdk/middleware-host-header';
4
+ import '@aws-sdk/middleware-sdk-s3';
5
+ import '@aws-sdk/middleware-user-agent';
6
+ import '@smithy/types';
7
+ import '@smithy/config-resolver';
8
+ import '@smithy/eventstream-serde-config-resolver';
9
+ import '@smithy/middleware-endpoint';
10
+ import '@smithy/middleware-retry';
11
+ import '@smithy/protocol-http';
12
+ import '@smithy/smithy-client';
13
+ import 'node:stream';
14
+ import '@aws-sdk/core/httpAuthSchemes';
15
+ type CreateCloudflareClientParameters = {
16
+ /**
17
+ * Cloudflare R2 access key ID.
18
+ */
19
+ accessKeyId: string;
20
+ /**
21
+ * Cloudflare account ID.
22
+ */
23
+ accountId: string;
24
+ /**
25
+ * The jurisdiction where the data is stored.
26
+ *
27
+ * Only use this if you created your R2 bucket using a jurisdiction.
28
+ */
29
+ jurisdiction?: "eu" | "fedramp";
30
+ /**
31
+ * Cloudflare R2 secret access key.
32
+ */
33
+ secretAccessKey: string;
34
+ };
35
+ type CreateMinioClientParameters = {
36
+ /**
37
+ * Minio access key ID.
38
+ */
39
+ accessKeyId: string;
40
+ /**
41
+ * Minio endpoint.
42
+ */
43
+ endpoint: string;
44
+ /**
45
+ * Minio region.
46
+ */
47
+ region: string;
48
+ /**
49
+ * Minio secret access key.
50
+ */
51
+ secretAccessKey: string;
52
+ };
53
+ type CreateBackblazeClientParameters = {
54
+ /**
55
+ * Backblaze B2 application key.
56
+ */
57
+ applicationKey: string;
58
+ /**
59
+ * Backblaze B2 application key ID.
60
+ */
61
+ applicationKeyId: string;
62
+ /**
63
+ * Backblaze B2 region.
64
+ */
65
+ region: string;
66
+ };
67
+ type CreateWasabiClientParameters = {
68
+ /**
69
+ * Wasabi access key ID.
70
+ */
71
+ accessKeyId: string;
72
+ /**
73
+ * Wasabi region.
74
+ */
75
+ region: string;
76
+ /**
77
+ * Wasabi secret access key.
78
+ */
79
+ secretAccessKey: string;
80
+ };
81
+ type CreateDigitalOceanClientParameters = {
82
+ /**
83
+ * DigitalOcean Spaces key.
84
+ */
85
+ key: string;
86
+ /**
87
+ * DigitalOcean Spaces region.
88
+ */
89
+ region: string;
90
+ /**
91
+ * DigitalOcean Spaces secret.
92
+ */
93
+ secret: string;
94
+ };
95
+ type CreateTigrisClientParameters = {
96
+ /**
97
+ * Tigris access key ID.
98
+ */
99
+ accessKeyId: string;
100
+ /**
101
+ * Tigris endpoint.
102
+ * @default `https://t3.storage.dev`
103
+ */
104
+ endpoint?: string;
105
+ /**
106
+ * Tigris secret access key.
107
+ */
108
+ secretAccessKey: string;
109
+ };
110
+ /**
111
+ * Create a Backblaze B2 client, compatible with the S3 API.
112
+ *
113
+ * Optionally, you can omit the parameters and use the following environment variables:
114
+ * - `B2_REGION`
115
+ * - `B2_APP_KEY_ID`
116
+ * - `B2_APP_KEY`
117
+ */
118
+ declare const backblaze: (parameters?: CreateBackblazeClientParameters) => S3ClientConfig;
119
+ /**
120
+ * Create a Cloudflare R2 client, compatible with the S3 API.
121
+ *
122
+ * Optionally, you can omit the parameters and use the following environment variables:
123
+ * - `CLOUDFLARE_ACCOUNT_ID`
124
+ * - `AWS_ACCESS_KEY_ID`
125
+ * - `AWS_SECRET_ACCESS_KEY`
126
+ * - `CLOUDFLARE_JURISDICTION`
127
+ */
128
+ declare const cloudflare: (parameters?: CreateCloudflareClientParameters) => S3ClientConfig;
129
+ /**
130
+ * Create a DigitalOcean Spaces client, compatible with the S3 API.
131
+ *
132
+ * Optionally, you can omit the parameters and use the following environment variables:
133
+ * - `SPACES_REGION`
134
+ * - `SPACES_KEY`
135
+ * - `SPACES_SECRET`
136
+ */
137
+ declare const digitalOcean: (parameters?: CreateDigitalOceanClientParameters) => S3ClientConfig;
138
+ /**
139
+ * Create a Minio client, compatible with the S3 API.
140
+ *
141
+ * Optionally, you can omit the parameters and use the following environment variables:
142
+ * - `AWS_REGION`
143
+ * - `AWS_ACCESS_KEY_ID`
144
+ * - `AWS_SECRET_ACCESS_KEY`
145
+ * - `MINIO_ENDPOINT`
146
+ */
147
+ declare const minio: (parameters?: CreateMinioClientParameters) => S3ClientConfig;
148
+ /**
149
+ * Create a Tigris client, compatible with the S3 API.
150
+ *
151
+ * Optionally, you can omit the parameters and use the following environment variables:
152
+ * - `AWS_ACCESS_KEY_ID`
153
+ * - `AWS_SECRET_ACCESS_KEY`
154
+ * - `TIGRIS_ENDPOINT`
155
+ */
156
+ declare const tigris: (parameters?: CreateTigrisClientParameters) => S3ClientConfig;
157
+ /**
158
+ * Create a Wasabi client, compatible with the S3 API.
159
+ *
160
+ * Optionally, you can omit the parameters and use the following environment variables:
161
+ * - `WASABI_REGION`
162
+ * - `AWS_ACCESS_KEY_ID`
163
+ * - `AWS_SECRET_ACCESS_KEY`
164
+ */
165
+ declare const wasabi: (parameters?: CreateWasabiClientParameters) => S3ClientConfig;
166
+ export { backblaze, cloudflare, digitalOcean, minio, tigris, wasabi };
@@ -1,4 +1,320 @@
1
- export { default as S3File } from "./s3-file.d.ts";
2
- export { default as S3MetaStorage } from "./s3-meta-storage.d.ts";
3
- export { default as S3Storage } from "./s3-storage.d.ts";
4
- export type { AwsError, AWSErrorV2, S3MetaStorageOptions, S3StorageOptions } from "./types.d.ts";
1
+ import { F as File, m as MetaStorageOptions, k as BaseStorageOptions, L as LocalMetaStorageOptions, M as MetaStorage, H as HttpError, e as FileQuery, b as FileInit } from "../../packem_shared/storage.d-BOMUJD96.js";
2
+ import { Readable } from 'node:stream';
3
+ import { P as Part, S as S3ApiOperations, a as S3BaseStorage } from "../../packem_shared/s3-base-storage.d-CczjSe98.js";
4
+ import { S as S3ClientConfig, O as ObjectCannedACL, a as S3Client } from "../../packem_shared/S3Client.d-CZ62Jztg.js";
5
+ import { ResponseMetadata } from '@smithy/types';
6
+ import 'node:crypto';
7
+ import 'node:http';
8
+ import 'lru-cache';
9
+ import '@aws-sdk/middleware-flexible-checksums';
10
+ import '@aws-sdk/middleware-host-header';
11
+ import '@aws-sdk/middleware-sdk-s3';
12
+ import '@aws-sdk/middleware-user-agent';
13
+ import '@smithy/config-resolver';
14
+ import '@smithy/eventstream-serde-config-resolver';
15
+ import '@smithy/middleware-endpoint';
16
+ import '@smithy/middleware-retry';
17
+ import '@smithy/protocol-http';
18
+ import '@smithy/smithy-client';
19
+ import '@aws-sdk/core/httpAuthSchemes';
20
+ declare class S3File extends File {
21
+ Parts?: Part[];
22
+ UploadId?: string;
23
+ uri?: string;
24
+ partsUrls?: string[];
25
+ partSize?: number;
26
+ }
27
+ type S3MetaStorageOptions = MetaStorageOptions & S3ClientConfig & {
28
+ bucket?: string;
29
+ keyFile?: string;
30
+ };
31
+ type S3StorageOptions = BaseStorageOptions & S3ClientConfig & {
32
+ /**
33
+ * Specifying access rules for uploaded files.
34
+ */
35
+ acl?: ObjectCannedACL;
36
+ /**
37
+ * S3 bucket name.
38
+ * @default 'node-Upload'
39
+ */
40
+ bucket?: string;
41
+ /**
42
+ * Force compatible client upload directly to S3 storage
43
+ */
44
+ clientDirectUpload?: boolean;
45
+ /**
46
+ * @deprecated Use standard auth providers
47
+ */
48
+ keyFile?: string;
49
+ /**
50
+ * Configure metafiles storage
51
+ * @example
52
+ * Using local metafiles
53
+ * ```ts
54
+ * const storage = new S3Storage({
55
+ * bucket: 'upload',
56
+ * region: 'eu-west-3',
57
+ * metaStorageConfig: { directory: '/tmp/upload-metafiles' }
58
+ * })
59
+ * ```
60
+ * Using a separate bucket for metafiles
61
+ * ```ts
62
+ * const storage = new S3Storage({
63
+ * bucket: 'upload',
64
+ * region: 'eu-west-3',
65
+ * metaStorageConfig: { bucket: 'upload-metafiles' }
66
+ * })
67
+ * ```
68
+ */
69
+ metaStorageConfig?: LocalMetaStorageOptions | S3MetaStorageOptions;
70
+ /**
71
+ * The parts size that the client should use for presigned multipart unloading.
72
+ * @default '16MB'
73
+ */
74
+ partSize?: number | string;
75
+ };
76
+ /**
77
+ * SDK V3
78
+ * A structure containing information about a service or networking error.
79
+ */
80
+ interface AwsError extends Error {
81
+ $fault?: "client" | "server";
82
+ $metadata: ResponseMetadata;
83
+ $service?: string;
84
+ Code?: string;
85
+ Type?: string;
86
+ }
87
+ /**
88
+ * SDK V2
89
+ * A structure containing information about a service or networking error.
90
+ */
91
+ interface AWSErrorV2 extends Error {
92
+ /**
93
+ * CloudFront request ID associated with the response.
94
+ */
95
+ cfId: string;
96
+ /**
97
+ * A unique short code representing the error that was emitted.
98
+ */
99
+ code: string;
100
+ /**
101
+ * Second request ID associated with the response from S3.
102
+ */
103
+ extendedRequestId: string;
104
+ /**
105
+ * Set when a networking error occurs to easily identify the endpoint of the request.
106
+ */
107
+ hostname: string;
108
+ /**
109
+ * A longer human readable error message.
110
+ */
111
+ message: string;
112
+ /**
113
+ * Set when a networking error occurs to easily identify the region of the request.
114
+ */
115
+ region: string;
116
+ /**
117
+ * The unique request ID associated with the response.
118
+ */
119
+ requestId: string;
120
+ /**
121
+ * Whether the error message is retryable.
122
+ */
123
+ retryable: boolean;
124
+ /**
125
+ * Amount of time (in seconds) that the request waited before being resent.
126
+ */
127
+ retryDelay: number;
128
+ /**
129
+ * In the case of a request that reached the service, this value contains the response status code.
130
+ */
131
+ statusCode: number;
132
+ /**
133
+ * The date time object when the error occurred.
134
+ */
135
+ time: Date;
136
+ }
137
+ declare class S3MetaStorage<T extends File = File> extends MetaStorage<T> {
138
+ config: S3MetaStorageOptions;
139
+ private readonly bucket;
140
+ private readonly client;
141
+ constructor(config: S3MetaStorageOptions);
142
+ override get(id: string): Promise<T>;
143
+ override touch(id: string, file: T): Promise<T>;
144
+ override delete(id: string): Promise<void>;
145
+ override save(id: string, file: T): Promise<T>;
146
+ private accessCheck;
147
+ }
148
+ type ReadableStream = globalThis.ReadableStream;
149
+ /**
150
+ * Adapter that wraps AWS SDK S3Client to implement S3ApiOperations interface.
151
+ */
152
+ declare class S3ClientAdapter implements S3ApiOperations {
153
+ private readonly client;
154
+ constructor(client: S3Client, _bucket: string);
155
+ createMultipartUpload(params: {
156
+ ACL?: string;
157
+ Bucket: string;
158
+ ContentType?: string;
159
+ Key: string;
160
+ Metadata?: Record<string, string>;
161
+ }): Promise<{
162
+ UploadId: string;
163
+ }>;
164
+ uploadPart(params: {
165
+ Body: Readable | ReadableStream | Uint8Array;
166
+ Bucket: string;
167
+ ContentLength?: number;
168
+ ContentMD5?: string;
169
+ Key: string;
170
+ PartNumber: number;
171
+ UploadId: string;
172
+ }): Promise<{
173
+ ETag: string;
174
+ }>;
175
+ completeMultipartUpload(params: {
176
+ Bucket: string;
177
+ Key: string;
178
+ Parts: {
179
+ ETag: string;
180
+ PartNumber: number;
181
+ }[];
182
+ UploadId: string;
183
+ }): Promise<{
184
+ ETag?: string;
185
+ Location: string;
186
+ }>;
187
+ abortMultipartUpload(params: {
188
+ Bucket: string;
189
+ Key: string;
190
+ UploadId: string;
191
+ }): Promise<void>;
192
+ listParts(params: {
193
+ Bucket: string;
194
+ Key: string;
195
+ UploadId: string;
196
+ }): Promise<{
197
+ Parts?: Part[];
198
+ }>;
199
+ getObject(params: {
200
+ Bucket: string;
201
+ Key: string;
202
+ }): Promise<{
203
+ Body?: ReadableStream | Readable;
204
+ ContentLength?: number;
205
+ ContentType?: string;
206
+ ETag?: string;
207
+ Expires?: Date;
208
+ LastModified?: Date;
209
+ Metadata?: Record<string, string>;
210
+ }>;
211
+ headObject(params: {
212
+ Bucket: string;
213
+ Key: string;
214
+ }): Promise<{
215
+ ContentLength?: number;
216
+ ContentType?: string;
217
+ ETag?: string;
218
+ Expires?: Date;
219
+ LastModified?: Date;
220
+ }>;
221
+ deleteObject(params: {
222
+ Bucket: string;
223
+ Key: string;
224
+ }): Promise<void>;
225
+ copyObject(params: {
226
+ Bucket: string;
227
+ CopySource: string;
228
+ Key: string;
229
+ StorageClass?: string;
230
+ }): Promise<void>;
231
+ listObjectsV2(params: {
232
+ Bucket: string;
233
+ ContinuationToken?: string;
234
+ MaxKeys?: number;
235
+ }): Promise<{
236
+ Contents?: {
237
+ Key?: string;
238
+ LastModified?: Date;
239
+ }[];
240
+ IsTruncated?: boolean;
241
+ NextContinuationToken?: string;
242
+ }>;
243
+ getPresignedUrl(params: {
244
+ Bucket: string;
245
+ expiresIn: number;
246
+ Key: string;
247
+ PartNumber: number;
248
+ UploadId: string;
249
+ }): Promise<string>;
250
+ checkBucketAccess(params: {
251
+ Bucket: string;
252
+ }): Promise<void>;
253
+ }
254
+ /**
255
+ * Amazon S3 storage implementation.
256
+ * @example
257
+ * ```ts
258
+ * const storage = new S3Storage({
259
+ * bucket: <YOUR_BUCKET>,
260
+ * endpoint: <YOUR_ENDPOINT>,
261
+ * region: <YOUR_REGION>,
262
+ * credentials: {
263
+ * accessKeyId: <YOUR_ACCESS_KEY_ID>,
264
+ * secretAccessKey: <YOUR_SECRET_ACCESS_KEY>
265
+ * },
266
+ * metaStorageConfig: { directory: '/tmp/upload-metafiles' }
267
+ * });
268
+ * ```
269
+ * @remarks
270
+ * ## Error Handling
271
+ * - S3 API errors are normalized with AWS-specific context
272
+ * - Errors include S3 error codes and metadata for debugging
273
+ * - Batch operations handle individual failures gracefully
274
+ *
275
+ * ## Retry Behavior
276
+ * - All S3 API calls are wrapped with configurable retry logic via `retryConfig` option
277
+ * - Default retryable status codes: 408 (Request Timeout), 429 (Too Many Requests),
278
+ * 500 (Internal Server Error), 502 (Bad Gateway), 503 (Service Unavailable), 504 (Gateway Timeout)
279
+ * - Retries server-side faults ($fault === "server") automatically
280
+ * - Custom `shouldRetry` function can be provided for advanced retry logic
281
+ * - Default retry configuration: maxRetries: 3, initialDelay: 1000ms, maxDelay: 30000ms, backoffMultiplier: 2 (exponential backoff)
282
+ * - Retry wrapper handles transient network errors and rate limiting
283
+ *
284
+ * ## Multipart Uploads
285
+ * - Large files are automatically split into multipart uploads
286
+ * - Maximum 10,000 parts per upload (S3 limitation)
287
+ * - Part size is configurable (default: 16MB, minimum: 5MB)
288
+ * - Failed multipart uploads are automatically aborted
289
+ *
290
+ * ## Supported Operations
291
+ * - ✅ create, write, delete, get, getStream, list, update, copy, move
292
+ * - ✅ Batch operations: deleteBatch, copyBatch, moveBatch (inherited from BaseStorage)
293
+ * - ✅ exists: Implemented (checks metadata and S3 object)
294
+ * - ❌ getUrl: Not implemented (presigned URLs available via buildPresigned for clientDirectUpload)
295
+ * - ❌ getUploadUrl: Not implemented (presigned URLs available via buildPresigned for clientDirectUpload)
296
+ */
297
+ declare class S3Storage extends S3BaseStorage {
298
+ static override readonly name: string;
299
+ private s3Api;
300
+ constructor(config: S3StorageOptions);
301
+ /**
302
+ * Normalizes AWS S3 errors with S3-specific context.
303
+ */
304
+ override normalizeError(error: AwsError): HttpError;
305
+ override update({
306
+ id
307
+ }: FileQuery, metadata: Partial<S3File>): Promise<S3File>;
308
+ override getStream({
309
+ id
310
+ }: FileQuery): Promise<{
311
+ headers?: Record<string, string>;
312
+ size?: number;
313
+ stream: Readable;
314
+ }>;
315
+ protected getS3Api(): S3ClientAdapter;
316
+ protected getFileClass(): new (config: FileInit) => S3File;
317
+ protected getAcl(): string | undefined;
318
+ protected accessCheck(_maxWaitTime?: number): Promise<void>;
319
+ }
320
+ export { type AWSErrorV2, type AwsError, S3File, S3MetaStorage, type S3MetaStorageOptions, S3Storage, type S3StorageOptions };