@visulima/storage 1.0.0-alpha.14 → 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 +25 -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-BjdSXKri.js → GCSMetaStorage-CNXq7vGd.js} +1 -1
  12. package/dist/packem_shared/{GCStorage-D3JVWisH.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-C8rMsqR_.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 +38 -38
  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
@@ -1,70 +0,0 @@
1
- import { Readable } from "node:stream";
2
- import type { HttpError } from "../../utils/types.d.ts";
3
- import type { FileInit, FileQuery } from "../utils/index.d.ts";
4
- import { S3BaseStorage } from "./s3-base-storage.d.ts";
5
- import S3ClientAdapter from "./s3-client-adapter.d.ts";
6
- import S3File from "./s3-file.d.ts";
7
- import type { AwsError, S3StorageOptions } from "./types.d.ts";
8
- /**
9
- * Amazon S3 storage implementation.
10
- * @example
11
- * ```ts
12
- * const storage = new S3Storage({
13
- * bucket: <YOUR_BUCKET>,
14
- * endpoint: <YOUR_ENDPOINT>,
15
- * region: <YOUR_REGION>,
16
- * credentials: {
17
- * accessKeyId: <YOUR_ACCESS_KEY_ID>,
18
- * secretAccessKey: <YOUR_SECRET_ACCESS_KEY>
19
- * },
20
- * metaStorageConfig: { directory: '/tmp/upload-metafiles' }
21
- * });
22
- * ```
23
- * @remarks
24
- * ## Error Handling
25
- * - S3 API errors are normalized with AWS-specific context
26
- * - Errors include S3 error codes and metadata for debugging
27
- * - Batch operations handle individual failures gracefully
28
- *
29
- * ## Retry Behavior
30
- * - All S3 API calls are wrapped with configurable retry logic via `retryConfig` option
31
- * - Default retryable status codes: 408 (Request Timeout), 429 (Too Many Requests),
32
- * 500 (Internal Server Error), 502 (Bad Gateway), 503 (Service Unavailable), 504 (Gateway Timeout)
33
- * - Retries server-side faults ($fault === "server") automatically
34
- * - Custom `shouldRetry` function can be provided for advanced retry logic
35
- * - Default retry configuration: maxRetries: 3, initialDelay: 1000ms, maxDelay: 30000ms, backoffMultiplier: 2 (exponential backoff)
36
- * - Retry wrapper handles transient network errors and rate limiting
37
- *
38
- * ## Multipart Uploads
39
- * - Large files are automatically split into multipart uploads
40
- * - Maximum 10,000 parts per upload (S3 limitation)
41
- * - Part size is configurable (default: 16MB, minimum: 5MB)
42
- * - Failed multipart uploads are automatically aborted
43
- *
44
- * ## Supported Operations
45
- * - ✅ create, write, delete, get, getStream, list, update, copy, move
46
- * - ✅ Batch operations: deleteBatch, copyBatch, moveBatch (inherited from BaseStorage)
47
- * - ✅ exists: Implemented (checks metadata and S3 object)
48
- * - ❌ getUrl: Not implemented (presigned URLs available via buildPresigned for clientDirectUpload)
49
- * - ❌ getUploadUrl: Not implemented (presigned URLs available via buildPresigned for clientDirectUpload)
50
- */
51
- declare class S3Storage extends S3BaseStorage {
52
- static readonly name: string;
53
- private s3Api;
54
- constructor(config: S3StorageOptions);
55
- /**
56
- * Normalizes AWS S3 errors with S3-specific context.
57
- */
58
- normalizeError(error: AwsError): HttpError;
59
- update({ id }: FileQuery, metadata: Partial<S3File>): Promise<S3File>;
60
- getStream({ id }: FileQuery): Promise<{
61
- headers?: Record<string, string>;
62
- size?: number;
63
- stream: Readable;
64
- }>;
65
- protected getS3Api(): S3ClientAdapter;
66
- protected getFileClass(): new (config: FileInit) => S3File;
67
- protected getAcl(): string | undefined;
68
- protected accessCheck(_maxWaitTime?: number): Promise<void>;
69
- }
70
- export default S3Storage;
@@ -1,118 +0,0 @@
1
- import type { ObjectCannedACL, S3Client, S3ClientConfig } from "@aws-sdk/client-s3";
2
- import type { ResponseMetadata } from "@aws-sdk/types";
3
- import type { LocalMetaStorageOptions } from "../local/local-meta-storage.d.ts";
4
- import type { BaseStorageOptions, MetaStorageOptions } from "../types.d.ts";
5
- export type S3MetaStorageOptions = MetaStorageOptions & S3ClientConfig & {
6
- bucket?: string;
7
- /**
8
- * @internal
9
- */
10
- client?: S3Client;
11
- keyFile?: string;
12
- };
13
- export type S3StorageOptions = BaseStorageOptions & S3ClientConfig & {
14
- /**
15
- * Specifying access rules for uploaded files.
16
- */
17
- acl?: ObjectCannedACL;
18
- /**
19
- * S3 bucket name.
20
- * @default 'node-Upload'
21
- */
22
- bucket?: string;
23
- /**
24
- * Force compatible client upload directly to S3 storage
25
- */
26
- clientDirectUpload?: boolean;
27
- /**
28
- * @deprecated Use standard auth providers
29
- */
30
- keyFile?: string;
31
- /**
32
- * Configure metafiles storage
33
- * @example
34
- * Using local metafiles
35
- * ```ts
36
- * const storage = new S3Storage({
37
- * bucket: 'upload',
38
- * region: 'eu-west-3',
39
- * metaStorageConfig: { directory: '/tmp/upload-metafiles' }
40
- * })
41
- * ```
42
- * Using a separate bucket for metafiles
43
- * ```ts
44
- * const storage = new S3Storage({
45
- * bucket: 'upload',
46
- * region: 'eu-west-3',
47
- * metaStorageConfig: { bucket: 'upload-metafiles' }
48
- * })
49
- * ```
50
- */
51
- metaStorageConfig?: LocalMetaStorageOptions | S3MetaStorageOptions;
52
- /**
53
- * The parts size that the client should use for presigned multipart unloading.
54
- * @default '16MB'
55
- */
56
- partSize?: number | string;
57
- };
58
- /**
59
- * SDK V3
60
- * A structure containing information about a service or networking error.
61
- */
62
- export interface AwsError extends Error {
63
- $fault?: "client" | "server";
64
- $metadata: ResponseMetadata;
65
- $service?: string;
66
- Code?: string;
67
- Type?: string;
68
- }
69
- /**
70
- * SDK V2
71
- * A structure containing information about a service or networking error.
72
- */
73
- export interface AWSErrorV2 extends Error {
74
- /**
75
- * CloudFront request ID associated with the response.
76
- */
77
- cfId: string;
78
- /**
79
- * A unique short code representing the error that was emitted.
80
- */
81
- code: string;
82
- /**
83
- * Second request ID associated with the response from S3.
84
- */
85
- extendedRequestId: string;
86
- /**
87
- * Set when a networking error occurs to easily identify the endpoint of the request.
88
- */
89
- hostname: string;
90
- /**
91
- * A longer human readable error message.
92
- */
93
- message: string;
94
- /**
95
- * Set when a networking error occurs to easily identify the region of the request.
96
- */
97
- region: string;
98
- /**
99
- * The unique request ID associated with the response.
100
- */
101
- requestId: string;
102
- /**
103
- * Whether the error message is retryable.
104
- */
105
- retryable: boolean;
106
- /**
107
- * Amount of time (in seconds) that the request waited before being resent.
108
- */
109
- retryDelay: number;
110
- /**
111
- * In the case of a request that reached the service, this value contains the response status code.
112
- */
113
- statusCode: number;
114
- /**
115
- * The date time object when the error occurred.
116
- */
117
- time: Date;
118
- }
@@ -1,130 +0,0 @@
1
- import { Readable } from "node:stream";
2
- import type { Part, S3ApiOperations } from "../aws/s3-base-storage.d.ts";
3
- import type { AwsLightClientConfig } from "./types.d.ts";
4
- /**
5
- * Adapter that uses aws4fetch to implement S3ApiOperations interface.
6
- */
7
- declare class AwsLightApiAdapter implements S3ApiOperations {
8
- private aws;
9
- private readonly bucket;
10
- private readonly endpoint;
11
- constructor(config: AwsLightClientConfig & {
12
- bucket: string;
13
- });
14
- createMultipartUpload(params: {
15
- ACL?: string;
16
- Bucket: string;
17
- ContentType?: string;
18
- Key: string;
19
- Metadata?: Record<string, string>;
20
- }): Promise<{
21
- UploadId: string;
22
- }>;
23
- uploadPart(params: {
24
- Body: Readable | ReadableStream | Uint8Array;
25
- Bucket: string;
26
- ContentLength?: number;
27
- ContentMD5?: string;
28
- Key: string;
29
- PartNumber: number;
30
- UploadId: string;
31
- }): Promise<{
32
- ETag: string;
33
- }>;
34
- completeMultipartUpload(params: {
35
- Bucket: string;
36
- Key: string;
37
- Parts: {
38
- ETag: string;
39
- PartNumber: number;
40
- }[];
41
- UploadId: string;
42
- }): Promise<{
43
- ETag?: string;
44
- Location: string;
45
- }>;
46
- abortMultipartUpload(params: {
47
- Bucket: string;
48
- Key: string;
49
- UploadId: string;
50
- }): Promise<void>;
51
- listParts(params: {
52
- Bucket: string;
53
- Key: string;
54
- UploadId: string;
55
- }): Promise<{
56
- Parts?: Part[];
57
- }>;
58
- getObject(params: {
59
- Bucket: string;
60
- Key: string;
61
- }): Promise<{
62
- Body?: ReadableStream | Readable;
63
- ContentLength?: number;
64
- ContentType?: string;
65
- ETag?: string;
66
- Expires?: Date;
67
- LastModified?: Date;
68
- Metadata?: Record<string, string>;
69
- }>;
70
- headObject(params: {
71
- Bucket: string;
72
- Key: string;
73
- }): Promise<{
74
- ContentLength?: number;
75
- ContentType?: string;
76
- ETag?: string;
77
- Expires?: Date;
78
- LastModified?: Date;
79
- Metadata?: Record<string, string>;
80
- }>;
81
- deleteObject(params: {
82
- Bucket: string;
83
- Key: string;
84
- }): Promise<void>;
85
- copyObject(params: {
86
- Bucket: string;
87
- CopySource: string;
88
- Key: string;
89
- StorageClass?: string;
90
- }): Promise<void>;
91
- listObjectsV2(params: {
92
- Bucket: string;
93
- ContinuationToken?: string;
94
- MaxKeys?: number;
95
- }): Promise<{
96
- Contents?: {
97
- Key?: string;
98
- LastModified?: Date;
99
- }[];
100
- IsTruncated?: boolean;
101
- NextContinuationToken?: string;
102
- }>;
103
- getPresignedUrl(params: {
104
- Bucket: string;
105
- expiresIn: number;
106
- Key: string;
107
- PartNumber: number;
108
- UploadId: string;
109
- }): Promise<string>;
110
- putObject(params: {
111
- Body?: Uint8Array | ReadableStream;
112
- Bucket: string;
113
- ContentLength?: number;
114
- ContentType?: string;
115
- Key: string;
116
- Metadata?: Record<string, string>;
117
- }): Promise<void>;
118
- checkBucketAccess(_params: {
119
- Bucket: string;
120
- }): Promise<void>;
121
- /**
122
- * Builds S3 API URL.
123
- */
124
- private buildUrl;
125
- /**
126
- * Converts ReadableStream to Readable for Node.js compatibility.
127
- */
128
- private streamToReadable;
129
- }
130
- export default AwsLightApiAdapter;
@@ -1,10 +0,0 @@
1
- import type { Part } from "../aws/s3-base-storage.d.ts";
2
- import { File } from "../utils/index.d.ts";
3
- declare class AwsLightFile extends File {
4
- Parts?: Part[];
5
- UploadId?: string;
6
- uri?: string;
7
- partsUrls?: string[];
8
- partSize?: number;
9
- }
10
- export default AwsLightFile;
@@ -1,19 +0,0 @@
1
- import MetaStorage from "../meta-storage.d.ts";
2
- import type { File } from "../utils/index.d.ts";
3
- import type { AwsLightMetaStorageOptions } from "./types.d.ts";
4
- /**
5
- * AWS Light meta storage implementation using aws4fetch.
6
- * Stores metadata in S3 object metadata headers (x-amz-meta-*).
7
- * Optimized for worker environments (Cloudflare Workers, Web Workers, etc.).
8
- */
9
- declare class AwsLightMetaStorage<T extends File = File> extends MetaStorage<T> {
10
- config: AwsLightMetaStorageOptions;
11
- private readonly adapter;
12
- private readonly bucket;
13
- constructor(config: AwsLightMetaStorageOptions);
14
- get(id: string): Promise<T>;
15
- touch(id: string, file: T): Promise<T>;
16
- delete(id: string): Promise<void>;
17
- save(id: string, file: T): Promise<T>;
18
- }
19
- export default AwsLightMetaStorage;
@@ -1,66 +0,0 @@
1
- import { Readable } from "node:stream";
2
- import type { HttpError } from "../../utils/types.d.ts";
3
- import { S3BaseStorage } from "../aws/s3-base-storage.d.ts";
4
- import type { FileInit, FileQuery } from "../utils/index.d.ts";
5
- import AwsLightApiAdapter from "./aws-light-api-adapter.d.ts";
6
- import AwsLightFile from "./aws-light-file.d.ts";
7
- import type { AwsLightError, AwsLightStorageOptions } from "./types.d.ts";
8
- /**
9
- * AWS Light storage implementation using aws4fetch.
10
- * Optimized for worker environments (Cloudflare Workers, Web Workers, etc.).
11
- * @example
12
- * ```ts
13
- * const storage = new AwsLightStorage({
14
- * bucket: <YOUR_BUCKET>,
15
- * region: <YOUR_REGION>,
16
- * accessKeyId: <YOUR_ACCESS_KEY_ID>,
17
- * secretAccessKey: <YOUR_SECRET_ACCESS_KEY>
18
- * });
19
- * ```
20
- * @remarks
21
- * ## Worker Compatibility
22
- * - Uses aws4fetch for AWS request signing (works in workers)
23
- * - No Node.js-specific dependencies
24
- * - Compatible with Cloudflare Workers, Web Workers, and edge runtimes
25
- *
26
- * ## Error Handling
27
- * - S3 API errors are normalized with AWS-specific context
28
- * - Errors include S3 error codes and status codes for debugging
29
- *
30
- * ## Retry Behavior
31
- * - All S3 API calls are wrapped with configurable retry logic via `retryConfig` option
32
- * - Default retryable status codes: 408, 429, 500, 502, 503, 504
33
- * - Custom `shouldRetry` function can be provided for advanced retry logic
34
- *
35
- * ## Multipart Uploads
36
- * - Large files are automatically split into multipart uploads
37
- * - Maximum 10,000 parts per upload (S3 limitation)
38
- * - Part size is configurable (default: 16MB, minimum: 5MB)
39
- * - Failed multipart uploads are automatically aborted
40
- *
41
- * ## Supported Operations
42
- * - ✅ create, write, delete, get, getStream, list, update, copy, move
43
- * - ✅ Batch operations: deleteBatch, copyBatch, moveBatch (inherited from BaseStorage)
44
- * - ✅ exists: Implemented (checks metadata and S3 object)
45
- * - ⚠️ getUrl/getUploadUrl: Limited presigned URL support (uses aws4fetch signing)
46
- */
47
- declare class AwsLightStorage extends S3BaseStorage {
48
- static readonly name: string;
49
- private s3Api;
50
- constructor(config: AwsLightStorageOptions);
51
- /**
52
- * Normalizes AWS S3 errors with S3-specific context.
53
- */
54
- normalizeError(error: AwsLightError | Error): HttpError;
55
- update({ id }: FileQuery, metadata: Partial<AwsLightFile>): Promise<AwsLightFile>;
56
- getStream({ id }: FileQuery): Promise<{
57
- headers?: Record<string, string>;
58
- size?: number;
59
- stream: Readable;
60
- }>;
61
- protected getS3Api(): AwsLightApiAdapter;
62
- protected getFileClass(): new (config: FileInit) => AwsLightFile;
63
- protected getAcl(): string | undefined;
64
- protected accessCheck(_maxWaitTime?: number): Promise<void>;
65
- }
66
- export default AwsLightStorage;
@@ -1,36 +0,0 @@
1
- import type { BaseStorageOptions, MetaStorageOptions } from "../types.d.ts";
2
- export interface AwsLightClientConfig {
3
- accessKeyId: string;
4
- endpoint?: string;
5
- region: string;
6
- secretAccessKey: string;
7
- service?: string;
8
- sessionToken?: string;
9
- }
10
- export type AwsLightMetaStorageOptions = AwsLightClientConfig & MetaStorageOptions & {
11
- bucket?: string;
12
- };
13
- export type AwsLightStorageOptions = AwsLightClientConfig & BaseStorageOptions & {
14
- /**
15
- * S3 bucket name.
16
- */
17
- bucket?: string;
18
- /**
19
- * Force compatible client upload directly to S3 storage
20
- */
21
- clientDirectUpload?: boolean;
22
- /**
23
- * Configure metafiles storage
24
- */
25
- metaStorageConfig?: AwsLightMetaStorageOptions;
26
- /**
27
- * The parts size that the client should use for presigned multipart unloading.
28
- * @default '16MB'
29
- */
30
- partSize?: number | string;
31
- };
32
- export interface AwsLightError extends Error {
33
- code?: string;
34
- requestId?: string;
35
- statusCode?: number;
36
- }
@@ -1,6 +0,0 @@
1
- import { File } from "../utils/index.d.ts";
2
- declare class AzureFile extends File {
3
- requestId?: string;
4
- uri?: string;
5
- }
6
- export default AzureFile;
@@ -1,15 +0,0 @@
1
- import MetaStorage from "../meta-storage.d.ts";
2
- import type { File } from "../utils/index.d.ts";
3
- import type { AzureMetaStorageOptions } from "./types.d.ts";
4
- declare class AzureMetaStorage<T extends File = File> extends MetaStorage<T> {
5
- config: AzureMetaStorageOptions;
6
- private client;
7
- private containerClient;
8
- constructor(config: AzureMetaStorageOptions);
9
- get(id: string): Promise<T>;
10
- touch(id: string, file: T): Promise<T>;
11
- delete(id: string): Promise<void>;
12
- save(id: string, file: T): Promise<T>;
13
- list(): Promise<T[]>;
14
- }
15
- export default AzureMetaStorage;
@@ -1,69 +0,0 @@
1
- import type MetaStorage from "../meta-storage.d.ts";
2
- import { BaseStorage } from "../storage.d.ts";
3
- import type { FileInit, FilePart, FileQuery, FileReturn } from "../utils/index.d.ts";
4
- import AzureFile from "./azure-file.d.ts";
5
- import type { AzureStorageOptions } from "./types.d.ts";
6
- /**
7
- * Azure Blob Storage implementation.
8
- * @remarks
9
- * ## Supported Operations
10
- * - ✅ create, write, delete, get, list, update, copy, move
11
- * - ✅ Batch operations: deleteBatch, copyBatch, moveBatch (inherited from BaseStorage)
12
- * - ✅ exists: Implemented (checks metadata and Azure blob)
13
- * - ❌ getStream: Not implemented (use get() for file retrieval)
14
- * - ❌ getUrl: Not implemented (Azure Blob URLs not supported)
15
- * - ❌ getUploadUrl: Not implemented (Azure Blob upload URLs handled internally)
16
- */
17
- declare class AzureStorage extends BaseStorage {
18
- static readonly name: string;
19
- checksumTypes: string[];
20
- protected meta: MetaStorage;
21
- private client;
22
- private readonly containerClient;
23
- private readonly root;
24
- private readonly retry;
25
- constructor(config: AzureStorageOptions);
26
- create(config: FileInit): Promise<AzureFile>;
27
- /**
28
- * Deletes an upload and its metadata.
29
- * @param query File query containing the file ID to delete.
30
- * @param query.id File ID to delete.
31
- * @returns Promise resolving to the deleted file object with status: "deleted".
32
- * @throws {UploadError} If the file metadata cannot be found.
33
- */
34
- delete({ id }: FileQuery): Promise<AzureFile>;
35
- /**
36
- * Moves an upload file to a new location.
37
- * @param name Source file name/ID.
38
- * @param destination Destination file name/ID.
39
- * @returns Promise resolving to the moved file object.
40
- * @throws {UploadError} If the source file cannot be found.
41
- */
42
- move(name: string, destination: string): Promise<AzureFile>;
43
- write(part: FilePart | FileQuery | AzureFile): Promise<AzureFile>;
44
- get({ id }: FileQuery): Promise<FileReturn>;
45
- /**
46
- * Checks if a file exists by verifying both metadata and the actual Azure blob.
47
- * Returns true only if both the metadata and the blob exist.
48
- * @param query File query containing the file ID to check.
49
- * @returns Promise resolving to true if both metadata and blob exist, false otherwise.
50
- */
51
- exists({ id }: FileQuery): Promise<boolean>;
52
- /**
53
- * Copies an upload file to a new location.
54
- * @param name Source file name/ID.
55
- * @param destination Destination file name/ID.
56
- * @returns Promise resolving to the copied file object.
57
- * @throws {UploadError} If the source file cannot be found.
58
- */
59
- copy(name: string, destination: string): Promise<AzureFile>;
60
- list(limit?: number): Promise<AzureFile[]>;
61
- /**
62
- * Prefixes the given filePath with the storage root location (assetFolder if configured).
63
- * @param filePath Relative file path to prefix.
64
- * @returns Full path with asset folder prefix if configured, otherwise returns original path.
65
- */
66
- private getFullPath;
67
- private accessCheck;
68
- }
69
- export default AzureStorage;
@@ -1,61 +0,0 @@
1
- import type { BlobServiceClient } from "@azure/storage-blob";
2
- import type { LocalMetaStorageOptions } from "../local/local-meta-storage.d.ts";
3
- import type { BaseStorageOptions, MetaStorageOptions } from "../types.d.ts";
4
- interface ClientConfig {
5
- /**
6
- * Azure account key.
7
- */
8
- accountKey?: string;
9
- /**
10
- * Azure account name.
11
- */
12
- accountName?: string;
13
- /**
14
- * Azure container name.
15
- */
16
- containerName: string;
17
- /**
18
- * Azure endpoint.
19
- */
20
- endpoint?: string;
21
- /**
22
- * Azure root path.
23
- */
24
- root?: string;
25
- }
26
- interface ClientConfig {
27
- connectionString?: string;
28
- /**
29
- * Azure container name.
30
- */
31
- containerName: string;
32
- /**
33
- * Azure root path.
34
- */
35
- root?: string;
36
- }
37
- export interface AzureMetaStorageOptions extends ClientConfig, MetaStorageOptions {
38
- client?: BlobServiceClient;
39
- }
40
- export interface AzureStorageOptions extends BaseStorageOptions, ClientConfig {
41
- /**
42
- * Configure metafiles storage
43
- * @example
44
- * ```ts
45
- * Using local metafiles
46
- * const storage = new AzureStorage({
47
- * bucket: 'upload',
48
- * metaStorageConfig: { directory: '/tmp/upload-metafiles' }
49
- * })
50
- * ```
51
- * Using a separate bucket for metafiles
52
- * ```ts
53
- * const storage = new AzureStorage({
54
- * bucket: 'upload',
55
- * metaStorageConfig: { bucket: 'upload-metafiles' }
56
- * })
57
- * ```
58
- */
59
- metaStorageConfig?: AzureMetaStorageOptions | LocalMetaStorageOptions;
60
- }
61
- export {};
@@ -1,11 +0,0 @@
1
- declare class FetchError extends Error {
2
- code: string;
3
- config: {
4
- uri: string;
5
- };
6
- name: string;
7
- constructor(message: string, code: string, config: {
8
- uri: string;
9
- });
10
- }
11
- export default FetchError;
@@ -1,2 +0,0 @@
1
- declare const GCSConfig: Record<string, string | string[]>;
2
- export default GCSConfig;
@@ -1,6 +0,0 @@
1
- import { File } from "../utils/index.d.ts";
2
- declare class GCSFile extends File {
3
- GCSUploadURI?: string;
4
- uri?: string;
5
- }
6
- export default GCSFile;
@@ -1,27 +0,0 @@
1
- import MetaStorage from "../meta-storage.d.ts";
2
- import type { File } from "../utils/index.d.ts";
3
- import type { GCSMetaStorageOptions } from "./types.d.ts";
4
- declare class GCSMetaStorage<T extends File = File> extends MetaStorage<T> {
5
- readonly config: GCSMetaStorageOptions;
6
- private authClient;
7
- private readonly storageBaseURI;
8
- private readonly uploadBaseURI;
9
- private readonly isCustomEndpoint;
10
- private readonly retryOptions;
11
- private readonly useAuthWithCustomEndpoint;
12
- private readonly userProject;
13
- constructor(config: GCSMetaStorageOptions);
14
- save(id: string, file: T): Promise<T>;
15
- delete(id: string): Promise<void>;
16
- get(id: string): Promise<T>;
17
- touch(id: string, file: T): Promise<T>;
18
- private accessCheck;
19
- /**
20
- * Returns metafile URL path for the given upload ID.
21
- * @param id Upload ID to get metafile path for
22
- * @returns Full URL path to the metafile in GCS
23
- */
24
- private getMetaPath;
25
- private makeRequest;
26
- }
27
- export default GCSMetaStorage;