@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.
- package/CHANGELOG.md +11 -0
- package/LICENSE.md +1094 -382
- package/dist/adapter/nuxt/module.d.ts +41 -34
- package/dist/handler/http/fetch/index.d.ts +297 -4
- package/dist/handler/http/hono/index.d.ts +1474 -58
- package/dist/handler/http/nextjs/index.d.ts +66 -58
- package/dist/handler/http/node/index.d.ts +361 -4
- package/dist/handler/http/solid-start/index.d.ts +66 -57
- package/dist/index.d.ts +376 -17
- package/dist/openapi/index.d.ts +24 -5
- package/dist/packem_shared/{GCSMetaStorage-BkUIdJ5m.js → GCSMetaStorage-CNXq7vGd.js} +1 -1
- package/dist/packem_shared/{GCStorage-BnsSAjdW.js → GCStorage-CdnSuQwa.js} +1 -1
- package/dist/packem_shared/S3Client.d-CZ62Jztg.d.ts +20357 -0
- package/dist/packem_shared/disk-storage-with-checksum.d-hEoe2ugb.d.ts +148 -0
- package/dist/packem_shared/{gcs-meta-storage-DBeGn2ix.js → gcs-meta-storage-B5AVt1aS.js} +1 -1
- package/dist/packem_shared/local-meta-storage.d-Dop9RP9k.d.ts +20 -0
- package/dist/packem_shared/media-transformer.d-DeHZkBVx.d.ts +331 -0
- package/dist/packem_shared/s3-base-storage.d-CczjSe98.d.ts +251 -0
- package/dist/packem_shared/storage.d-BOMUJD96.d.ts +939 -0
- package/dist/packem_shared/tus-base.d-BftIixIA.d.ts +99 -0
- package/dist/packem_shared/types.d-BPd_JkW1.d.ts +708 -0
- package/dist/packem_shared/types.d-D-mlfmef.d.ts +49 -0
- package/dist/storage/aws/clients/index.d.ts +166 -6
- package/dist/storage/aws/index.d.ts +320 -4
- package/dist/storage/aws-light/index.d.ts +252 -4
- package/dist/storage/azure/index.d.ts +10422 -4
- package/dist/storage/gcs/index.d.ts +4107 -5
- package/dist/storage/gcs/index.js +2 -2
- package/dist/storage/local/index.d.ts +7 -4
- package/dist/storage/netlify-blob/index.d.ts +142 -4
- package/dist/storage/vercel-blob/index.d.ts +129 -4
- package/dist/transformer/audio-transformer.d.ts +127 -125
- package/dist/transformer/image-transformer.d.ts +569 -568
- package/dist/transformer/index.d.ts +62 -5
- package/dist/transformer/video-transformer.d.ts +144 -142
- package/package.json +37 -37
- package/dist/handler/base/base-handler-core.d.ts +0 -91
- package/dist/handler/base/base-handler-fetch.d.ts +0 -76
- package/dist/handler/base/base-handler-node.d.ts +0 -137
- package/dist/handler/multipart/multipart-base.d.ts +0 -84
- package/dist/handler/multipart/multipart-fetch.d.ts +0 -64
- package/dist/handler/multipart/multipart.d.ts +0 -49
- package/dist/handler/rest/rest-base.d.ts +0 -106
- package/dist/handler/rest/rest-fetch.d.ts +0 -88
- package/dist/handler/rest/rest.d.ts +0 -93
- package/dist/handler/tus/tus-base.d.ts +0 -152
- package/dist/handler/tus/tus-fetch.d.ts +0 -72
- package/dist/handler/tus/tus.d.ts +0 -78
- package/dist/handler/types.d.ts +0 -53
- package/dist/handler/utils/request-parser.d.ts +0 -72
- package/dist/handler/utils/response-builder.d.ts +0 -83
- package/dist/handler/utils/storage-utils.d.ts +0 -10
- package/dist/handler/utils/stream-utils.d.ts +0 -29
- package/dist/handler/utils/upload-handlers.d.ts +0 -76
- package/dist/metrics/index.d.ts +0 -2
- package/dist/metrics/no-op-metrics.d.ts +0 -15
- package/dist/metrics/opentelemetry-metrics.d.ts +0 -55
- package/dist/openapi/rest.d.ts +0 -7
- package/dist/openapi/shared.d.ts +0 -13
- package/dist/openapi/transform.d.ts +0 -3
- package/dist/openapi/tus.d.ts +0 -7
- package/dist/openapi/xhr.d.ts +0 -7
- package/dist/storage/aws/clients/backblaze.d.ts +0 -12
- package/dist/storage/aws/clients/cloudflare.d.ts +0 -13
- package/dist/storage/aws/clients/digital-ocean.d.ts +0 -12
- package/dist/storage/aws/clients/minio.d.ts +0 -13
- package/dist/storage/aws/clients/tigris.d.ts +0 -12
- package/dist/storage/aws/clients/types.d.ts +0 -95
- package/dist/storage/aws/clients/wasabi.d.ts +0 -12
- package/dist/storage/aws/s3-base-storage.d.ts +0 -248
- package/dist/storage/aws/s3-client-adapter.d.ts +0 -110
- package/dist/storage/aws/s3-file.d.ts +0 -10
- package/dist/storage/aws/s3-meta-storage.d.ts +0 -15
- package/dist/storage/aws/s3-storage.d.ts +0 -70
- package/dist/storage/aws/types.d.ts +0 -118
- package/dist/storage/aws-light/aws-light-api-adapter.d.ts +0 -130
- package/dist/storage/aws-light/aws-light-file.d.ts +0 -10
- package/dist/storage/aws-light/aws-light-meta-storage.d.ts +0 -19
- package/dist/storage/aws-light/aws-light-storage.d.ts +0 -66
- package/dist/storage/aws-light/types.d.ts +0 -36
- package/dist/storage/azure/azure-file.d.ts +0 -6
- package/dist/storage/azure/azure-meta-storage.d.ts +0 -15
- package/dist/storage/azure/azure-storage.d.ts +0 -69
- package/dist/storage/azure/types.d.ts +0 -61
- package/dist/storage/gcs/fetch-error.d.ts +0 -11
- package/dist/storage/gcs/gcs-config.d.ts +0 -2
- package/dist/storage/gcs/gcs-file.d.ts +0 -6
- package/dist/storage/gcs/gcs-meta-storage.d.ts +0 -27
- package/dist/storage/gcs/gcs-storage.d.ts +0 -91
- package/dist/storage/gcs/types.d.ts +0 -54
- package/dist/storage/gcs/utils.d.ts +0 -7
- package/dist/storage/local/disk-storage-with-checksum.d.ts +0 -15
- package/dist/storage/local/disk-storage.d.ts +0 -135
- package/dist/storage/local/local-meta-storage.d.ts +0 -27
- package/dist/storage/meta-storage-options.d.ts +0 -11
- package/dist/storage/meta-storage.d.ts +0 -30
- package/dist/storage/netlify-blob/netlify-blob-file.d.ts +0 -12
- package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +0 -6
- package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +0 -93
- package/dist/storage/netlify-blob/types.d.ts +0 -29
- package/dist/storage/storage.d.ts +0 -353
- package/dist/storage/types.d.ts +0 -217
- package/dist/storage/utils/file/file.d.ts +0 -25
- package/dist/storage/utils/file/get-file-status.d.ts +0 -9
- package/dist/storage/utils/file/has-content.d.ts +0 -9
- package/dist/storage/utils/file/index.d.ts +0 -10
- package/dist/storage/utils/file/is-expired.d.ts +0 -8
- package/dist/storage/utils/file/metadata.d.ts +0 -18
- package/dist/storage/utils/file/part-match.d.ts +0 -11
- package/dist/storage/utils/file/types.d.ts +0 -37
- package/dist/storage/utils/file/update-metadata.d.ts +0 -10
- package/dist/storage/utils/file/update-size.d.ts +0 -10
- package/dist/storage/vercel-blob/types.d.ts +0 -31
- package/dist/storage/vercel-blob/vercel-blob-file.d.ts +0 -16
- package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +0 -6
- package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +0 -76
- package/dist/transformer/base-transformer.d.ts +0 -63
- package/dist/transformer/media-transformer.d.ts +0 -332
- package/dist/transformer/transformer-config.d.ts +0 -16
- package/dist/transformer/types.d.ts +0 -639
- package/dist/transformer/utils.d.ts +0 -33
- package/dist/transformer/validation-error.d.ts +0 -23
- package/dist/utils/cache.d.ts +0 -32
- package/dist/utils/chunked-upload.d.ts +0 -65
- package/dist/utils/detect-file-type.d.ts +0 -28
- package/dist/utils/errors.d.ts +0 -74
- package/dist/utils/file-path-url-matcher.d.ts +0 -18
- package/dist/utils/headers.d.ts +0 -111
- package/dist/utils/http.d.ts +0 -92
- package/dist/utils/locker.d.ts +0 -26
- package/dist/utils/pipes/stream-checksum.d.ts +0 -47
- package/dist/utils/pipes/stream-length.d.ts +0 -22
- package/dist/utils/primitives/get-last-one.d.ts +0 -3
- package/dist/utils/primitives/is-record.d.ts +0 -2
- package/dist/utils/primitives/map-values.d.ts +0 -9
- package/dist/utils/primitives/pick.d.ts +0 -2
- package/dist/utils/primitives/to-milliseconds.d.ts +0 -12
- package/dist/utils/primitives/to-seconds.d.ts +0 -12
- package/dist/utils/range-checksum.d.ts +0 -33
- package/dist/utils/range-hasher.d.ts +0 -46
- package/dist/utils/retry.d.ts +0 -64
- package/dist/utils/types.d.ts +0 -108
- package/dist/utils/validation-error.d.ts +0 -22
- package/dist/utils/validator.d.ts +0 -36
|
@@ -1,4 +1,252 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { P as Part, S as S3ApiOperations, a as S3BaseStorage } from "../../packem_shared/s3-base-storage.d-CczjSe98.js";
|
|
2
|
+
import { F as File, m as MetaStorageOptions, k as BaseStorageOptions, M as MetaStorage, H as HttpError, e as FileQuery, b as FileInit } from "../../packem_shared/storage.d-BOMUJD96.js";
|
|
3
|
+
import { Readable } from 'node:stream';
|
|
4
|
+
import 'node:crypto';
|
|
5
|
+
import 'node:http';
|
|
6
|
+
import 'lru-cache';
|
|
7
|
+
declare class AwsLightFile extends File {
|
|
8
|
+
Parts?: Part[];
|
|
9
|
+
UploadId?: string;
|
|
10
|
+
uri?: string;
|
|
11
|
+
partsUrls?: string[];
|
|
12
|
+
partSize?: number;
|
|
13
|
+
}
|
|
14
|
+
interface AwsLightClientConfig {
|
|
15
|
+
accessKeyId: string;
|
|
16
|
+
endpoint?: string;
|
|
17
|
+
region: string;
|
|
18
|
+
secretAccessKey: string;
|
|
19
|
+
service?: string;
|
|
20
|
+
sessionToken?: string;
|
|
21
|
+
}
|
|
22
|
+
type AwsLightMetaStorageOptions = AwsLightClientConfig & MetaStorageOptions & {
|
|
23
|
+
bucket?: string;
|
|
24
|
+
};
|
|
25
|
+
type AwsLightStorageOptions = AwsLightClientConfig & BaseStorageOptions & {
|
|
26
|
+
/**
|
|
27
|
+
* S3 bucket name.
|
|
28
|
+
*/
|
|
29
|
+
bucket?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Force compatible client upload directly to S3 storage
|
|
32
|
+
*/
|
|
33
|
+
clientDirectUpload?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Configure metafiles storage
|
|
36
|
+
*/
|
|
37
|
+
metaStorageConfig?: AwsLightMetaStorageOptions;
|
|
38
|
+
/**
|
|
39
|
+
* The parts size that the client should use for presigned multipart unloading.
|
|
40
|
+
* @default '16MB'
|
|
41
|
+
*/
|
|
42
|
+
partSize?: number | string;
|
|
43
|
+
};
|
|
44
|
+
interface AwsLightError extends Error {
|
|
45
|
+
code?: string;
|
|
46
|
+
requestId?: string;
|
|
47
|
+
statusCode?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* AWS Light meta storage implementation using aws4fetch.
|
|
51
|
+
* Stores metadata in S3 object metadata headers (x-amz-meta-*).
|
|
52
|
+
* Optimized for worker environments (Cloudflare Workers, Web Workers, etc.).
|
|
53
|
+
*/
|
|
54
|
+
declare class AwsLightMetaStorage<T extends File = File> extends MetaStorage<T> {
|
|
55
|
+
config: AwsLightMetaStorageOptions;
|
|
56
|
+
private readonly adapter;
|
|
57
|
+
private readonly bucket;
|
|
58
|
+
constructor(config: AwsLightMetaStorageOptions);
|
|
59
|
+
override get(id: string): Promise<T>;
|
|
60
|
+
override touch(id: string, file: T): Promise<T>;
|
|
61
|
+
override delete(id: string): Promise<void>;
|
|
62
|
+
override save(id: string, file: T): Promise<T>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Adapter that uses aws4fetch to implement S3ApiOperations interface.
|
|
66
|
+
*/
|
|
67
|
+
declare class AwsLightApiAdapter implements S3ApiOperations {
|
|
68
|
+
private aws;
|
|
69
|
+
private readonly bucket;
|
|
70
|
+
private readonly endpoint;
|
|
71
|
+
constructor(config: AwsLightClientConfig & {
|
|
72
|
+
bucket: string;
|
|
73
|
+
});
|
|
74
|
+
createMultipartUpload(params: {
|
|
75
|
+
ACL?: string;
|
|
76
|
+
Bucket: string;
|
|
77
|
+
ContentType?: string;
|
|
78
|
+
Key: string;
|
|
79
|
+
Metadata?: Record<string, string>;
|
|
80
|
+
}): Promise<{
|
|
81
|
+
UploadId: string;
|
|
82
|
+
}>;
|
|
83
|
+
uploadPart(params: {
|
|
84
|
+
Body: Readable | ReadableStream | Uint8Array;
|
|
85
|
+
Bucket: string;
|
|
86
|
+
ContentLength?: number;
|
|
87
|
+
ContentMD5?: string;
|
|
88
|
+
Key: string;
|
|
89
|
+
PartNumber: number;
|
|
90
|
+
UploadId: string;
|
|
91
|
+
}): Promise<{
|
|
92
|
+
ETag: string;
|
|
93
|
+
}>;
|
|
94
|
+
completeMultipartUpload(params: {
|
|
95
|
+
Bucket: string;
|
|
96
|
+
Key: string;
|
|
97
|
+
Parts: {
|
|
98
|
+
ETag: string;
|
|
99
|
+
PartNumber: number;
|
|
100
|
+
}[];
|
|
101
|
+
UploadId: string;
|
|
102
|
+
}): Promise<{
|
|
103
|
+
ETag?: string;
|
|
104
|
+
Location: string;
|
|
105
|
+
}>;
|
|
106
|
+
abortMultipartUpload(params: {
|
|
107
|
+
Bucket: string;
|
|
108
|
+
Key: string;
|
|
109
|
+
UploadId: string;
|
|
110
|
+
}): Promise<void>;
|
|
111
|
+
listParts(params: {
|
|
112
|
+
Bucket: string;
|
|
113
|
+
Key: string;
|
|
114
|
+
UploadId: string;
|
|
115
|
+
}): Promise<{
|
|
116
|
+
Parts?: Part[];
|
|
117
|
+
}>;
|
|
118
|
+
getObject(params: {
|
|
119
|
+
Bucket: string;
|
|
120
|
+
Key: string;
|
|
121
|
+
}): Promise<{
|
|
122
|
+
Body?: ReadableStream | Readable;
|
|
123
|
+
ContentLength?: number;
|
|
124
|
+
ContentType?: string;
|
|
125
|
+
ETag?: string;
|
|
126
|
+
Expires?: Date;
|
|
127
|
+
LastModified?: Date;
|
|
128
|
+
Metadata?: Record<string, string>;
|
|
129
|
+
}>;
|
|
130
|
+
headObject(params: {
|
|
131
|
+
Bucket: string;
|
|
132
|
+
Key: string;
|
|
133
|
+
}): Promise<{
|
|
134
|
+
ContentLength?: number;
|
|
135
|
+
ContentType?: string;
|
|
136
|
+
ETag?: string;
|
|
137
|
+
Expires?: Date;
|
|
138
|
+
LastModified?: Date;
|
|
139
|
+
Metadata?: Record<string, string>;
|
|
140
|
+
}>;
|
|
141
|
+
deleteObject(params: {
|
|
142
|
+
Bucket: string;
|
|
143
|
+
Key: string;
|
|
144
|
+
}): Promise<void>;
|
|
145
|
+
copyObject(params: {
|
|
146
|
+
Bucket: string;
|
|
147
|
+
CopySource: string;
|
|
148
|
+
Key: string;
|
|
149
|
+
StorageClass?: string;
|
|
150
|
+
}): Promise<void>;
|
|
151
|
+
listObjectsV2(params: {
|
|
152
|
+
Bucket: string;
|
|
153
|
+
ContinuationToken?: string;
|
|
154
|
+
MaxKeys?: number;
|
|
155
|
+
}): Promise<{
|
|
156
|
+
Contents?: {
|
|
157
|
+
Key?: string;
|
|
158
|
+
LastModified?: Date;
|
|
159
|
+
}[];
|
|
160
|
+
IsTruncated?: boolean;
|
|
161
|
+
NextContinuationToken?: string;
|
|
162
|
+
}>;
|
|
163
|
+
getPresignedUrl(params: {
|
|
164
|
+
Bucket: string;
|
|
165
|
+
expiresIn: number;
|
|
166
|
+
Key: string;
|
|
167
|
+
PartNumber: number;
|
|
168
|
+
UploadId: string;
|
|
169
|
+
}): Promise<string>;
|
|
170
|
+
putObject(params: {
|
|
171
|
+
Body?: Uint8Array | ReadableStream;
|
|
172
|
+
Bucket: string;
|
|
173
|
+
ContentLength?: number;
|
|
174
|
+
ContentType?: string;
|
|
175
|
+
Key: string;
|
|
176
|
+
Metadata?: Record<string, string>;
|
|
177
|
+
}): Promise<void>;
|
|
178
|
+
checkBucketAccess(_params: {
|
|
179
|
+
Bucket: string;
|
|
180
|
+
}): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Builds S3 API URL.
|
|
183
|
+
*/
|
|
184
|
+
private buildUrl;
|
|
185
|
+
/**
|
|
186
|
+
* Converts ReadableStream to Readable for Node.js compatibility.
|
|
187
|
+
*/
|
|
188
|
+
private streamToReadable;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* AWS Light storage implementation using aws4fetch.
|
|
192
|
+
* Optimized for worker environments (Cloudflare Workers, Web Workers, etc.).
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const storage = new AwsLightStorage({
|
|
196
|
+
* bucket: <YOUR_BUCKET>,
|
|
197
|
+
* region: <YOUR_REGION>,
|
|
198
|
+
* accessKeyId: <YOUR_ACCESS_KEY_ID>,
|
|
199
|
+
* secretAccessKey: <YOUR_SECRET_ACCESS_KEY>
|
|
200
|
+
* });
|
|
201
|
+
* ```
|
|
202
|
+
* @remarks
|
|
203
|
+
* ## Worker Compatibility
|
|
204
|
+
* - Uses aws4fetch for AWS request signing (works in workers)
|
|
205
|
+
* - No Node.js-specific dependencies
|
|
206
|
+
* - Compatible with Cloudflare Workers, Web Workers, and edge runtimes
|
|
207
|
+
*
|
|
208
|
+
* ## Error Handling
|
|
209
|
+
* - S3 API errors are normalized with AWS-specific context
|
|
210
|
+
* - Errors include S3 error codes and status codes for debugging
|
|
211
|
+
*
|
|
212
|
+
* ## Retry Behavior
|
|
213
|
+
* - All S3 API calls are wrapped with configurable retry logic via `retryConfig` option
|
|
214
|
+
* - Default retryable status codes: 408, 429, 500, 502, 503, 504
|
|
215
|
+
* - Custom `shouldRetry` function can be provided for advanced retry logic
|
|
216
|
+
*
|
|
217
|
+
* ## Multipart Uploads
|
|
218
|
+
* - Large files are automatically split into multipart uploads
|
|
219
|
+
* - Maximum 10,000 parts per upload (S3 limitation)
|
|
220
|
+
* - Part size is configurable (default: 16MB, minimum: 5MB)
|
|
221
|
+
* - Failed multipart uploads are automatically aborted
|
|
222
|
+
*
|
|
223
|
+
* ## Supported Operations
|
|
224
|
+
* - ✅ create, write, delete, get, getStream, list, update, copy, move
|
|
225
|
+
* - ✅ Batch operations: deleteBatch, copyBatch, moveBatch (inherited from BaseStorage)
|
|
226
|
+
* - ✅ exists: Implemented (checks metadata and S3 object)
|
|
227
|
+
* - ⚠️ getUrl/getUploadUrl: Limited presigned URL support (uses aws4fetch signing)
|
|
228
|
+
*/
|
|
229
|
+
declare class AwsLightStorage extends S3BaseStorage {
|
|
230
|
+
static override readonly name: string;
|
|
231
|
+
private s3Api;
|
|
232
|
+
constructor(config: AwsLightStorageOptions);
|
|
233
|
+
/**
|
|
234
|
+
* Normalizes AWS S3 errors with S3-specific context.
|
|
235
|
+
*/
|
|
236
|
+
override normalizeError(error: AwsLightError | Error): HttpError;
|
|
237
|
+
override update({
|
|
238
|
+
id
|
|
239
|
+
}: FileQuery, metadata: Partial<AwsLightFile>): Promise<AwsLightFile>;
|
|
240
|
+
override getStream({
|
|
241
|
+
id
|
|
242
|
+
}: FileQuery): Promise<{
|
|
243
|
+
headers?: Record<string, string>;
|
|
244
|
+
size?: number;
|
|
245
|
+
stream: Readable;
|
|
246
|
+
}>;
|
|
247
|
+
protected getS3Api(): AwsLightApiAdapter;
|
|
248
|
+
protected getFileClass(): new (config: FileInit) => AwsLightFile;
|
|
249
|
+
protected getAcl(): string | undefined;
|
|
250
|
+
protected accessCheck(_maxWaitTime?: number): Promise<void>;
|
|
251
|
+
}
|
|
252
|
+
export { type AwsLightClientConfig, type AwsLightError, AwsLightFile, AwsLightMetaStorage, type AwsLightMetaStorageOptions, AwsLightStorage, type AwsLightStorageOptions };
|