@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,64 +0,0 @@
1
- /**
2
- * Retry configuration options for storage operations
3
- */
4
- export interface RetryConfig {
5
- /**
6
- * Multiplier for exponential backoff (e.g., 2 means delays double each retry)
7
- * @default 2
8
- */
9
- backoffMultiplier?: number;
10
- /**
11
- * Custom function to calculate delay for a specific retry attempt
12
- * @param attempt The current retry attempt (0-indexed)
13
- * @param error The error that occurred
14
- * @returns Delay in milliseconds, or undefined to use default exponential backoff
15
- */
16
- calculateDelay?: (attempt: number, error: unknown) => number | undefined;
17
- /**
18
- * Initial delay in milliseconds before first retry
19
- * @default 1000
20
- */
21
- initialDelay?: number;
22
- /**
23
- * Maximum delay in milliseconds between retries
24
- * @default 30000
25
- */
26
- maxDelay?: number;
27
- /**
28
- * Maximum number of retry attempts
29
- * @default 3
30
- */
31
- maxRetries?: number;
32
- /**
33
- * HTTP status codes that should trigger a retry
34
- * @default [408, 429, 500, 502, 503, 504]
35
- */
36
- retryableStatusCodes?: number[];
37
- /**
38
- * Custom function to determine if an error should be retried
39
- * @param error The error that occurred
40
- * @returns true if the error should be retried, false otherwise
41
- */
42
- shouldRetry?: (error: unknown) => boolean;
43
- }
44
- /**
45
- * Determines if an error is retryable based on common patterns
46
- * @param error The error to check
47
- * @param retryableStatusCodes HTTP status codes that should trigger retry
48
- * @returns true if the error is retryable
49
- */
50
- export declare const isRetryableError: (error: unknown, retryableStatusCodes?: number[]) => boolean;
51
- /**
52
- * Retry an async operation with exponential backoff
53
- * @param fn The async function to retry
54
- * @param config Retry configuration
55
- * @returns The result of the function
56
- * @throws The last error if all retries are exhausted
57
- */
58
- export declare const retry: <T>(function_: () => Promise<T>, config?: RetryConfig) => Promise<T>;
59
- /**
60
- * Create a retry wrapper function with pre-configured settings.
61
- * @param config Retry configuration
62
- * @returns A function that wraps async operations with retry logic
63
- */
64
- export declare const createRetryWrapper: (config?: RetryConfig) => <T>(function_: () => Promise<T>) => Promise<T>;
@@ -1,108 +0,0 @@
1
- import type { BinaryToTextEncoding, Hash } from "node:crypto";
2
- import type { IncomingMessage } from "node:http";
3
- import type { Transform } from "node:stream";
4
- import type { LRUCache as Cache } from "lru-cache";
5
- /**
6
- * Transform that computes a rolling checksum for a stream while passing
7
- * data through unchanged.
8
- */
9
- export interface RangeChecksum extends Transform {
10
- /** Return the current digest in the selected encoding. */
11
- digest: (encoding: BinaryToTextEncoding) => string;
12
- hash: Hash;
13
- path: string;
14
- reset: () => void;
15
- }
16
- /**
17
- * LRU-backed map of rolling hashers keyed by file path. Used to compute
18
- * hex/base64 digests and resume hashing from an offset.
19
- */
20
- export interface RangeHasher extends Cache<string, Hash> {
21
- algorithm: "md5" | "sha1";
22
- base64: (path: string) => string;
23
- digester: (path: string) => RangeChecksum;
24
- hex: (path: string) => string;
25
- init: (path: string, start: number) => Promise<Hash>;
26
- updateFromFs: (path: string, start: number, initial?: Hash) => Promise<Hash>;
27
- }
28
- /**
29
- * Normalized HTTP error payload returned by handlers and storage backends.
30
- */
31
- export interface HttpErrorBody {
32
- code: string;
33
- detail?: Record<string, unknown> | string;
34
- message: string;
35
- name?: string;
36
- retryable?: boolean;
37
- UploadErrorCode?: string;
38
- }
39
- /**
40
- * Rich HTTP error including status code and optional headers/body.
41
- */
42
- export interface HttpError<T = HttpErrorBody> extends UploadResponse<T> {
43
- statusCode: number;
44
- }
45
- /**
46
- * Node.js IncomingMessage with an optional parsed body attached.
47
- */
48
- export interface IncomingMessageWithBody<T = unknown> extends IncomingMessage {
49
- _body?: boolean;
50
- body?: T;
51
- }
52
- export type Header = string[] | number | string;
53
- export type Headers = Record<string, Header>;
54
- export type ResponseBody = Record<string, unknown> | string | Buffer | Uint8Array;
55
- export type ResponseBodyType = "json" | "text";
56
- /**
57
- * Tuple form for quick response definitions: [status, body, headers].
58
- */
59
- export type ResponseTuple<T = ResponseBody> = [statusCode: number, body?: T, headers?: Headers];
60
- /**
61
- * Structured response used across handlers and storage operations.
62
- */
63
- export interface UploadResponse<T = ResponseBody> extends Record<string, unknown> {
64
- body?: T;
65
- headers?: Headers;
66
- statusCode?: number;
67
- }
68
- /**
69
- * Declarative validator configuration for a single rule.
70
- */
71
- export interface ValidatorConfig<T> {
72
- isValid?: (t: T) => Promise<boolean> | boolean;
73
- response?: HttpError | ResponseTuple;
74
- value?: unknown;
75
- }
76
- /** Map of rule-name -> validator configuration. */
77
- export type Validation<T> = Record<string, ValidatorConfig<T>>;
78
- /** Narrowed error response shape for validation failures. */
79
- export interface ValidationError extends HttpError {
80
- code: string;
81
- }
82
- /**
83
- * Metrics interface for observability.
84
- * Provides counters, timers, and gauges for tracking storage operations.
85
- */
86
- export interface Metrics {
87
- /**
88
- * Set a gauge metric value.
89
- * @param name Metric name (e.g., "storage.files.size")
90
- * @param value Gauge value
91
- * @param attributes Optional attributes/labels
92
- */
93
- gauge: (name: string, value: number, attributes?: Record<string, string | number>) => void;
94
- /**
95
- * Increment a counter metric.
96
- * @param name Metric name (e.g., "storage.operations.create.count")
97
- * @param value Increment value (default: 1)
98
- * @param attributes Optional attributes/labels (e.g., { storage: "s3", operation: "create" })
99
- */
100
- increment: (name: string, value?: number, attributes?: Record<string, string | number>) => void;
101
- /**
102
- * Record a duration/timing metric in milliseconds.
103
- * @param name Metric name (e.g., "storage.operations.write.duration")
104
- * @param duration Duration in milliseconds
105
- * @param attributes Optional attributes/labels
106
- */
107
- timing: (name: string, duration: number, attributes?: Record<string, string | number>) => void;
108
- }
@@ -1,22 +0,0 @@
1
- import type { Headers, HttpErrorBody, ValidationError as IValidationError } from "./types.d.ts";
2
- /**
3
- * Error class for validation failures with detailed error information.
4
- * Implements the ValidationError interface for consistent error handling.
5
- */
6
- declare class ValidationError extends Error implements IValidationError {
7
- readonly code: string;
8
- readonly statusCode: number;
9
- readonly body: HttpErrorBody;
10
- readonly headers: Headers;
11
- readonly name: string;
12
- [key: string]: unknown;
13
- /**
14
- * Creates a new ValidationError instance.
15
- * @param code Machine-readable error code
16
- * @param statusCode HTTP status code for the error
17
- * @param body Error response body (string or structured object)
18
- * @param headers HTTP headers to include in error response
19
- */
20
- constructor(code: string, statusCode: number, body: HttpErrorBody, headers: Headers);
21
- }
22
- export default ValidationError;
@@ -1,36 +0,0 @@
1
- import type { Validation } from "./types.d.ts";
2
- import ValidationError from "./validation-error.d.ts";
3
- /**
4
- * Configurable validation system for file upload constraints.
5
- * Supports multiple validation rules with custom error responses.
6
- * @template T - The type being validated
7
- */
8
- export declare class Validator<T> {
9
- private prefix;
10
- private validators;
11
- /**
12
- * Creates a new Validator instance.
13
- * @param prefix Prefix for generated error codes (default: "ValidationError")
14
- */
15
- constructor(prefix?: string);
16
- /**
17
- * Adds validation rules to the validator.
18
- * Each rule must include an `isValid` function.
19
- * @param config Validation configuration object
20
- * @throws TypeError if any validator is missing the isValid function
21
- */
22
- add(config: Validation<T>): void;
23
- /**
24
- * Verifies an object against all configured validation rules.
25
- * Throws ValidationError on first validation failure.
26
- * @param t Object to validate
27
- * @throws ValidationError if validation fails
28
- */
29
- verify(t: T): Promise<never | void>;
30
- }
31
- /**
32
- * Type guard to check if an error is a ValidationError instance.
33
- * @param error Error to check
34
- * @returns True if the error is a ValidationError
35
- */
36
- export declare const isValidationError: (error: unknown) => error is ValidationError;