@uploadista/core 0.2.0 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/{checksum-BjP9nb5b.mjs → checksum-BRjFmTRk.mjs} +2 -2
  2. package/dist/{checksum-BjP9nb5b.mjs.map → checksum-BRjFmTRk.mjs.map} +1 -1
  3. package/dist/{checksum-B7RDiO7V.cjs → checksum-BrjQ8GJL.cjs} +1 -1
  4. package/dist/errors/index.cjs +1 -1
  5. package/dist/errors/index.d.cts +1 -1
  6. package/dist/errors/index.d.mts +1 -1
  7. package/dist/errors/index.mjs +1 -1
  8. package/dist/flow/index.cjs +1 -1
  9. package/dist/flow/index.d.cts +3 -2
  10. package/dist/flow/index.d.mts +8 -5
  11. package/dist/flow/index.mjs +1 -1
  12. package/dist/generate-id-BAMRQzMr.d.cts +34 -0
  13. package/dist/generate-id-BAMRQzMr.d.cts.map +1 -0
  14. package/dist/generate-id-DuZwLm4m.d.mts +34 -0
  15. package/dist/generate-id-DuZwLm4m.d.mts.map +1 -0
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.d.cts +8 -5
  18. package/dist/index.d.mts +8 -5
  19. package/dist/index.mjs +1 -1
  20. package/dist/middleware-BghazxzH.d.cts +4129 -0
  21. package/dist/middleware-BghazxzH.d.cts.map +1 -0
  22. package/dist/middleware-CYizzAhP.d.mts +4129 -0
  23. package/dist/middleware-CYizzAhP.d.mts.map +1 -0
  24. package/dist/resolve-upload-metadata-CYl2PHIs.d.mts +4542 -0
  25. package/dist/resolve-upload-metadata-CYl2PHIs.d.mts.map +1 -0
  26. package/dist/resolve-upload-metadata-D0qFuyWc.d.cts +4542 -0
  27. package/dist/resolve-upload-metadata-D0qFuyWc.d.cts.map +1 -0
  28. package/dist/run-args-CM14Vtzu.cjs +1 -0
  29. package/dist/run-args-DSKHoSWs.mjs +2 -0
  30. package/dist/run-args-DSKHoSWs.mjs.map +1 -0
  31. package/dist/{stream-limiter-BCFULdAM.d.cts → stream-limiter-7wkBVLWT.d.mts} +2 -2
  32. package/dist/{stream-limiter-BCFULdAM.d.cts.map → stream-limiter-7wkBVLWT.d.mts.map} +1 -1
  33. package/dist/{stream-limiter-DZ22uIqf.cjs → stream-limiter-B-Y0DTgA.cjs} +1 -1
  34. package/dist/{stream-limiter-CTJPEJqE.mjs → stream-limiter-CvDuNIyd.mjs} +2 -2
  35. package/dist/{stream-limiter-CTJPEJqE.mjs.map → stream-limiter-CvDuNIyd.mjs.map} +1 -1
  36. package/dist/{stream-limiter-Bi7OTbRp.d.mts → stream-limiter-D1KC-6pK.d.cts} +2 -2
  37. package/dist/{stream-limiter-Bi7OTbRp.d.mts.map → stream-limiter-D1KC-6pK.d.cts.map} +1 -1
  38. package/dist/streams/index.cjs +1 -1
  39. package/dist/streams/index.d.cts +1 -1
  40. package/dist/streams/index.d.mts +2 -2
  41. package/dist/streams/index.mjs +1 -1
  42. package/dist/testing/index.cjs +1 -1
  43. package/dist/testing/index.d.cts +2 -1
  44. package/dist/testing/index.d.cts.map +1 -1
  45. package/dist/testing/index.d.mts +7 -4
  46. package/dist/testing/index.d.mts.map +1 -1
  47. package/dist/testing/index.mjs +1 -1
  48. package/dist/{throttle-Da0OA8JT.d.cts → throttle-3FRcr7MU.d.mts} +4 -34
  49. package/dist/throttle-3FRcr7MU.d.mts.map +1 -0
  50. package/dist/{throttle-ibiT6E4U.d.mts → throttle-BlH27EGu.d.cts} +4 -34
  51. package/dist/throttle-BlH27EGu.d.cts.map +1 -0
  52. package/dist/{throttle-KnkRgZPi.cjs → throttle-Dp59f37i.cjs} +1 -1
  53. package/dist/{throttle-CnDa3v1k.mjs → throttle-TFY-V41R.mjs} +2 -2
  54. package/dist/{throttle-CnDa3v1k.mjs.map → throttle-TFY-V41R.mjs.map} +1 -1
  55. package/dist/types/index.cjs +1 -1
  56. package/dist/types/index.d.cts +2 -2
  57. package/dist/types/index.d.mts +3 -5
  58. package/dist/types/index.mjs +1 -1
  59. package/dist/upload/index.cjs +1 -1
  60. package/dist/upload/index.d.cts +1 -1
  61. package/dist/upload/index.d.mts +4 -4
  62. package/dist/upload/index.mjs +1 -1
  63. package/dist/upload-strategy-negotiator-0-dpNIce.d.cts +455 -0
  64. package/dist/upload-strategy-negotiator-0-dpNIce.d.cts.map +1 -0
  65. package/dist/upload-strategy-negotiator-BR_o1Ez8.cjs +1 -0
  66. package/dist/upload-strategy-negotiator-C9MeoOnW.mjs +2 -0
  67. package/dist/upload-strategy-negotiator-C9MeoOnW.mjs.map +1 -0
  68. package/dist/upload-strategy-negotiator-CEnlfVgJ.d.mts +455 -0
  69. package/dist/upload-strategy-negotiator-CEnlfVgJ.d.mts.map +1 -0
  70. package/dist/{uploadista-error-B-geDgi8.cjs → uploadista-error-CZx1JU_L.cjs} +3 -1
  71. package/dist/{uploadista-error-Fsfvr2Bb.mjs → uploadista-error-DQ7V1FlX.mjs} +3 -1
  72. package/dist/uploadista-error-DQ7V1FlX.mjs.map +1 -0
  73. package/dist/{uploadista-error-BragVhIs.d.mts → uploadista-error-LtiZn-R_.d.mts} +2 -2
  74. package/dist/{uploadista-error-BragVhIs.d.mts.map → uploadista-error-LtiZn-R_.d.mts.map} +1 -1
  75. package/dist/{uploadista-error-Cj_pAFck.d.cts → uploadista-error-eZtG4iyf.d.cts} +2 -2
  76. package/dist/{uploadista-error-Cj_pAFck.d.cts.map → uploadista-error-eZtG4iyf.d.cts.map} +1 -1
  77. package/dist/utils/index.cjs +1 -1
  78. package/dist/utils/index.d.cts +2 -1
  79. package/dist/utils/index.d.mts +3 -2
  80. package/dist/utils/index.mjs +1 -1
  81. package/dist/websocket-Br0ijEZA.cjs +1 -0
  82. package/dist/websocket-DftnHFfN.mjs +2 -0
  83. package/dist/websocket-DftnHFfN.mjs.map +1 -0
  84. package/package.json +3 -3
  85. package/src/errors/uploadista-error.ts +11 -1
  86. package/src/flow/README.md +115 -0
  87. package/src/flow/flow-engine.ts +36 -2
  88. package/src/flow/flow-queue-store.ts +155 -0
  89. package/src/flow/flow-queue.ts +640 -0
  90. package/src/flow/index.ts +4 -0
  91. package/src/flow/types/flow-queue-item.ts +154 -0
  92. package/src/types/data-store.ts +3 -3
  93. package/src/types/kv-store.ts +31 -1
  94. package/src/upload/write-to-store.ts +24 -29
  95. package/tests/flow-queue-store.test.ts +150 -0
  96. package/tests/flow-queue.test.ts +308 -0
  97. package/dist/resolve-upload-metadata-BUVl1LoS.d.cts +0 -8723
  98. package/dist/resolve-upload-metadata-BUVl1LoS.d.cts.map +0 -1
  99. package/dist/resolve-upload-metadata-MPDmDfOZ.d.mts +0 -8723
  100. package/dist/resolve-upload-metadata-MPDmDfOZ.d.mts.map +0 -1
  101. package/dist/run-args-WD1otVrz.mjs +0 -2
  102. package/dist/run-args-WD1otVrz.mjs.map +0 -1
  103. package/dist/run-args-g74p8pEZ.cjs +0 -1
  104. package/dist/throttle-Da0OA8JT.d.cts.map +0 -1
  105. package/dist/throttle-ibiT6E4U.d.mts.map +0 -1
  106. package/dist/upload-strategy-negotiator-BuxPf1sa.mjs +0 -2
  107. package/dist/upload-strategy-negotiator-BuxPf1sa.mjs.map +0 -1
  108. package/dist/upload-strategy-negotiator-DfiQ0Fy0.cjs +0 -1
  109. package/dist/uploadista-error-Fsfvr2Bb.mjs.map +0 -1
  110. package/dist/websocket-Avz4T8YB.cjs +0 -1
  111. package/dist/websocket-CdgVhVJs.mjs +0 -2
  112. package/dist/websocket-CdgVhVJs.mjs.map +0 -1
@@ -0,0 +1,455 @@
1
+ import { n as UploadistaError } from "./uploadista-error-LtiZn-R_.mjs";
2
+ import { B as DataStoreCapabilities, G as StreamingConfig, O as WebSocketConnection, Y as UploadStrategy, at as UploadFileKVStore, j as UploadEvent, jn as UploadFile, o as InputFile, q as UploadFileDataStores, rt as KvStore, t as Middleware, w as UploadEventEmitter, x as EventEmitter, z as DataStore } from "./middleware-CYizzAhP.mjs";
3
+ import { a as GenerateIdShape, t as GenerateId } from "./generate-id-DuZwLm4m.mjs";
4
+ import { Context, Effect, Layer, Stream } from "effect";
5
+
6
+ //#region src/upload/mime.d.ts
7
+ /**
8
+ * Detect MIME type from buffer using magic bytes (file signatures).
9
+ * Supports a wide range of common file types including images, videos, audio, documents, and archives.
10
+ *
11
+ * @param buffer - File content as Uint8Array
12
+ * @param filename - Optional filename for extension-based fallback
13
+ * @returns Detected MIME type or "application/octet-stream" if unknown
14
+ */
15
+ declare const detectMimeType: (buffer: Uint8Array, filename?: string) => string;
16
+ /**
17
+ * Compare two MIME types with lenient matching.
18
+ * Matches on major type (e.g., "image/*") to allow for minor variations.
19
+ *
20
+ * @param declared - MIME type provided by client
21
+ * @param detected - MIME type detected from file content
22
+ * @returns true if MIME types are compatible
23
+ *
24
+ * @example
25
+ * compareMimeTypes("image/png", "image/apng") // true
26
+ * compareMimeTypes("image/jpeg", "image/png") // true (both images)
27
+ * compareMimeTypes("image/png", "application/pdf") // false
28
+ */
29
+ declare function compareMimeTypes(declared: string, detected: string): boolean;
30
+ //#endregion
31
+ //#region src/upload/upload-engine.d.ts
32
+ /**
33
+ * Legacy configuration options for UploadEngine.
34
+ *
35
+ * @deprecated Use Effect Layers instead of this configuration object.
36
+ * This type is kept for backward compatibility.
37
+ *
38
+ * @property dataStore - DataStore instance or factory function
39
+ * @property kvStore - KV store for upload metadata
40
+ * @property eventEmitter - Event emitter for upload progress
41
+ * @property generateId - Optional ID generator (defaults to UUID)
42
+ * @property middlewares - Optional request middlewares
43
+ * @property withTracing - Enable Effect tracing for debugging
44
+ */
45
+ type UploadEngineOptions = {
46
+ dataStore: ((storageId: string) => Promise<DataStore<UploadFile>>) | DataStore<UploadFile>;
47
+ kvStore: KvStore<UploadFile>;
48
+ eventEmitter: EventEmitter<UploadEvent>;
49
+ generateId?: GenerateIdShape;
50
+ middlewares?: Middleware[];
51
+ withTracing?: boolean;
52
+ };
53
+ /**
54
+ * UploadEngine service interface.
55
+ *
56
+ * This is the core upload handling service that provides all file upload operations.
57
+ * It manages upload lifecycle, resumable uploads, progress tracking, and storage integration.
58
+ *
59
+ * All operations return Effect types for composable, type-safe error handling.
60
+ *
61
+ * @property createUpload - Initiates a new upload and returns metadata
62
+ * @property uploadChunk - Uploads a chunk of data for an existing upload
63
+ * @property getCapabilities - Returns storage backend capabilities
64
+ * @property upload - Complete upload in one operation (create + upload data)
65
+ * @property uploadFromUrl - Uploads a file from a remote URL
66
+ * @property getUpload - Retrieves upload metadata by ID
67
+ * @property read - Reads the complete uploaded file data
68
+ * @property delete - Deletes an upload and its data
69
+ * @property subscribeToUploadEvents - Subscribes WebSocket to upload progress events
70
+ * @property unsubscribeFromUploadEvents - Unsubscribes from upload events
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * // Basic upload flow
75
+ * const program = Effect.gen(function* () {
76
+ * const server = yield* UploadEngine;
77
+ *
78
+ * // 1. Create upload
79
+ * const inputFile: InputFile = {
80
+ * storageId: "s3-production",
81
+ * size: 1024000,
82
+ * type: "image/jpeg",
83
+ * fileName: "photo.jpg"
84
+ * };
85
+ * const upload = yield* server.createUpload(inputFile, "client123");
86
+ *
87
+ * // 2. Upload chunks
88
+ * const chunk = new ReadableStream(...);
89
+ * const updated = yield* server.uploadChunk(upload.id, "client123", chunk);
90
+ *
91
+ * // 3. Read the uploaded file
92
+ * const data = yield* server.read(upload.id, "client123");
93
+ *
94
+ * return upload;
95
+ * });
96
+ *
97
+ * // Upload with WebSocket progress tracking
98
+ * const uploadWithProgress = Effect.gen(function* () {
99
+ * const server = yield* UploadEngine;
100
+ *
101
+ * // Subscribe to progress events
102
+ * yield* server.subscribeToUploadEvents(uploadId, websocket);
103
+ *
104
+ * // Upload (events will be emitted automatically)
105
+ * const result = yield* server.upload(inputFile, clientId, stream);
106
+ *
107
+ * // Unsubscribe when done
108
+ * yield* server.unsubscribeFromUploadEvents(uploadId);
109
+ *
110
+ * return result;
111
+ * });
112
+ *
113
+ * // Upload from URL
114
+ * const urlUpload = Effect.gen(function* () {
115
+ * const server = yield* UploadEngine;
116
+ *
117
+ * const inputFile: InputFile = {
118
+ * storageId: "s3-production",
119
+ * size: 0, // Unknown initially
120
+ * type: "image/png",
121
+ * fileName: "remote-image.png"
122
+ * };
123
+ *
124
+ * const upload = yield* server.uploadFromUrl(
125
+ * inputFile,
126
+ * "client123",
127
+ * "https://example.com/image.png"
128
+ * );
129
+ *
130
+ * return upload;
131
+ * });
132
+ * ```
133
+ */
134
+ type UploadEngineShape = {
135
+ createUpload: (inputFile: InputFile, clientId: string | null) => Effect.Effect<UploadFile, UploadistaError>;
136
+ uploadChunk: (uploadId: string, clientId: string | null, chunk: ReadableStream) => Effect.Effect<UploadFile, UploadistaError>;
137
+ getCapabilities: (storageId: string, clientId: string | null) => Effect.Effect<DataStoreCapabilities, UploadistaError>;
138
+ upload: (file: InputFile, clientId: string | null, stream: ReadableStream) => Effect.Effect<UploadFile, UploadistaError>;
139
+ uploadFromUrl: (inputFile: InputFile, clientId: string | null, url: string) => Effect.Effect<UploadFile, UploadistaError>;
140
+ getUpload: (uploadId: string) => Effect.Effect<UploadFile, UploadistaError>;
141
+ /**
142
+ * Reads the complete uploaded file data as bytes (buffered mode).
143
+ * For large files, consider using readStream() for memory efficiency.
144
+ */
145
+ read: (uploadId: string, clientId: string | null) => Effect.Effect<Uint8Array, UploadistaError>;
146
+ /**
147
+ * Reads file content as a stream of chunks for memory-efficient processing.
148
+ * Falls back to buffered read if the underlying DataStore doesn't support streaming.
149
+ *
150
+ * @param uploadId - The unique identifier of the upload to read
151
+ * @param clientId - Client identifier for multi-tenant routing
152
+ * @param config - Optional streaming configuration (chunk size)
153
+ * @returns An Effect that resolves to a Stream of byte chunks
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const server = yield* UploadEngine;
158
+ * const stream = yield* server.readStream(uploadId, clientId, { chunkSize: 65536 });
159
+ * // Process stream chunk by chunk with bounded memory
160
+ * yield* Stream.runForEach(stream, (chunk) => processChunk(chunk));
161
+ * ```
162
+ */
163
+ readStream: (uploadId: string, clientId: string | null, config?: StreamingConfig) => Effect.Effect<Stream.Stream<Uint8Array, UploadistaError>, UploadistaError>;
164
+ /**
165
+ * Uploads file content from a stream with unknown final size.
166
+ * Creates upload with deferred length, streams content to storage,
167
+ * and updates the upload record with final size when complete.
168
+ *
169
+ * Falls back to buffered upload if the underlying DataStore
170
+ * doesn't support streaming writes.
171
+ *
172
+ * @param file - Input file configuration (size is optional)
173
+ * @param clientId - Client identifier for multi-tenant routing
174
+ * @param stream - Effect Stream of byte chunks to upload
175
+ * @returns The completed UploadFile with final size
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * const server = yield* UploadEngine;
180
+ * const result = yield* server.uploadStream(
181
+ * {
182
+ * storageId: "s3-production",
183
+ * type: "image/webp",
184
+ * uploadLengthDeferred: true,
185
+ * fileName: "optimized.webp",
186
+ * },
187
+ * clientId,
188
+ * transformedStream,
189
+ * );
190
+ * console.log(`Uploaded ${result.size} bytes`);
191
+ * ```
192
+ */
193
+ uploadStream: (file: Omit<InputFile, "size"> & {
194
+ size?: number;
195
+ sizeHint?: number;
196
+ }, clientId: string | null, stream: Stream.Stream<Uint8Array, UploadistaError>) => Effect.Effect<UploadFile, UploadistaError>;
197
+ delete: (uploadId: string, clientId: string | null) => Effect.Effect<void, UploadistaError>;
198
+ subscribeToUploadEvents: (uploadId: string, connection: WebSocketConnection) => Effect.Effect<void, UploadistaError>;
199
+ unsubscribeFromUploadEvents: (uploadId: string) => Effect.Effect<void, UploadistaError>;
200
+ };
201
+ declare const UploadEngine_base: Context.TagClass<UploadEngine, "UploadEngine", UploadEngineShape>;
202
+ /**
203
+ * Effect-TS context tag for the UploadEngine service.
204
+ *
205
+ * Use this tag to access the UploadEngine in an Effect context.
206
+ * The server must be provided via a Layer or dependency injection.
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * // Access UploadEngine in an Effect
211
+ * const uploadEffect = Effect.gen(function* () {
212
+ * const server = yield* UploadEngine;
213
+ * const upload = yield* server.createUpload(inputFile, clientId);
214
+ * return upload;
215
+ * });
216
+ *
217
+ * // Provide UploadEngine layer
218
+ * const program = uploadEffect.pipe(
219
+ * Effect.provide(uploadEngine),
220
+ * Effect.provide(uploadFileKvStore),
221
+ * Effect.provide(dataStoreLayer),
222
+ * Effect.provide(eventEmitterLayer)
223
+ * );
224
+ * ```
225
+ */
226
+ declare class UploadEngine extends UploadEngine_base {}
227
+ /**
228
+ * Creates the UploadEngine implementation.
229
+ *
230
+ * This function constructs the UploadEngine service by composing all required
231
+ * dependencies (KV store, data stores, event emitter, ID generator). It implements
232
+ * all upload operations defined in UploadEngineShape.
233
+ *
234
+ * The server automatically handles:
235
+ * - Upload lifecycle management (create, resume, complete)
236
+ * - Progress tracking and event emission
237
+ * - Storage backend routing based on storageId
238
+ * - Error handling with proper UploadistaError types
239
+ *
240
+ * @returns An Effect that yields the UploadEngineShape implementation
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * // Create a custom UploadEngine layer
245
+ * const myUploadEngine = Layer.effect(
246
+ * UploadEngine,
247
+ * createUploadEngine()
248
+ * );
249
+ *
250
+ * // Use in a program
251
+ * const program = Effect.gen(function* () {
252
+ * const server = yield* UploadEngine;
253
+ * // Use server operations...
254
+ * }).pipe(Effect.provide(myUploadEngine));
255
+ * ```
256
+ */
257
+ declare function createUploadEngine(): Effect.Effect<{
258
+ upload: (inputFile: InputFile, clientId: string | null, stream: ReadableStream) => Effect.Effect<UploadFile, UploadistaError, never>;
259
+ uploadFromUrl: (inputFile: InputFile, clientId: string | null, url: string) => Effect.Effect<UploadFile, UploadistaError, never>;
260
+ createUpload: (inputFile: InputFile, clientId: string | null) => Effect.Effect<UploadFile, UploadistaError, never>;
261
+ uploadChunk: (uploadId: string, clientId: string | null, chunk: ReadableStream) => Effect.Effect<UploadFile, UploadistaError, never>;
262
+ getUpload: (uploadId: string) => Effect.Effect<UploadFile, UploadistaError, never>;
263
+ read: (uploadId: string, clientId: string | null) => Effect.Effect<Uint8Array<ArrayBufferLike>, UploadistaError, never>;
264
+ readStream: (uploadId: string, clientId: string | null, config?: StreamingConfig) => Effect.Effect<Stream.Stream<Uint8Array<ArrayBufferLike>, UploadistaError, never>, UploadistaError, never>;
265
+ uploadStream: (file: Omit<InputFile, "size"> & {
266
+ size?: number;
267
+ sizeHint?: number;
268
+ }, clientId: string | null, stream: Stream.Stream<Uint8Array, UploadistaError>) => Effect.Effect<UploadFile, UploadistaError, never>;
269
+ delete: (uploadId: string, clientId: string | null) => Effect.Effect<void, UploadistaError, never>;
270
+ getCapabilities: (storageId: string, clientId: string | null) => Effect.Effect<DataStoreCapabilities, UploadistaError, never>;
271
+ subscribeToUploadEvents: (uploadId: string, connection: WebSocketConnection) => Effect.Effect<void, UploadistaError, never>;
272
+ unsubscribeFromUploadEvents: (uploadId: string) => Effect.Effect<void, UploadistaError, never>;
273
+ }, never, UploadFileDataStores | UploadFileKVStore | UploadEventEmitter | GenerateId>;
274
+ /**
275
+ * Pre-built UploadEngine Effect Layer.
276
+ *
277
+ * This layer provides a ready-to-use UploadEngine implementation that can be
278
+ * composed with other layers to build a complete upload system.
279
+ *
280
+ * Required dependencies:
281
+ * - UploadFileKVStore: For storing upload metadata
282
+ * - UploadFileDataStores: For routing to storage backends
283
+ * - UploadEventEmitter: For progress events
284
+ * - GenerateId: For creating upload IDs
285
+ *
286
+ * @example
287
+ * ```typescript
288
+ * // Compose a complete upload system
289
+ * const fullUploadSystem = Layer.mergeAll(
290
+ * uploadEngine,
291
+ * uploadFileKvStore,
292
+ * dataStoreLayer,
293
+ * uploadEventEmitter,
294
+ * generateIdLayer
295
+ * );
296
+ *
297
+ * // Use in application
298
+ * const app = Effect.gen(function* () {
299
+ * const server = yield* UploadEngine;
300
+ * // Perform uploads...
301
+ * }).pipe(Effect.provide(fullUploadSystem));
302
+ * ```
303
+ */
304
+ declare const uploadEngine: Layer.Layer<UploadEngine, never, UploadFileDataStores | UploadFileKVStore | UploadEventEmitter | GenerateId>;
305
+ //#endregion
306
+ //#region src/upload/upload-strategy-negotiator.d.ts
307
+ /**
308
+ * Configuration options for upload strategy negotiation.
309
+ *
310
+ * @property fileSize - Size of the file to be uploaded in bytes
311
+ * @property preferredStrategy - Preferred upload strategy (single, parallel, resumable)
312
+ * @property preferredChunkSize - Preferred chunk size in bytes
313
+ * @property parallelUploads - Number of parallel upload connections
314
+ * @property minChunkSizeForParallel - Minimum file size to consider parallel uploads
315
+ */
316
+ type UploadStrategyOptions = {
317
+ fileSize: number;
318
+ preferredStrategy?: UploadStrategy;
319
+ preferredChunkSize?: number;
320
+ parallelUploads?: number;
321
+ minChunkSizeForParallel?: number;
322
+ };
323
+ /**
324
+ * Result of upload strategy negotiation.
325
+ *
326
+ * @property strategy - The negotiated upload strategy
327
+ * @property chunkSize - The negotiated chunk size in bytes
328
+ * @property parallelUploads - The negotiated number of parallel uploads
329
+ * @property reasoning - Array of reasoning strings explaining the decisions
330
+ * @property warnings - Array of warning messages about adjustments made
331
+ */
332
+ type NegotiatedStrategy = {
333
+ strategy: UploadStrategy;
334
+ chunkSize: number;
335
+ parallelUploads: number;
336
+ reasoning: string[];
337
+ warnings: string[];
338
+ };
339
+ /**
340
+ * Negotiates the optimal upload strategy based on data store capabilities and file characteristics.
341
+ *
342
+ * This class analyzes data store capabilities, file size, and user preferences to determine
343
+ * the best upload strategy (single, parallel, resumable) and optimal parameters like chunk size
344
+ * and parallel connection count.
345
+ *
346
+ * The negotiator considers:
347
+ * - Data store capabilities (parallel uploads, resumable uploads, concatenation)
348
+ * - File size and chunk size constraints
349
+ * - User preferences and requirements
350
+ * - Performance optimization opportunities
351
+ *
352
+ * @example
353
+ * ```typescript
354
+ * // Create negotiator for S3 data store
355
+ * const negotiator = new UploadStrategyNegotiator(
356
+ * s3Capabilities,
357
+ * (strategy) => s3Capabilities.supportsStrategy(strategy)
358
+ * );
359
+ *
360
+ * // Negotiate strategy for large file
361
+ * const result = negotiator.negotiateStrategy({
362
+ * fileSize: 100_000_000, // 100MB
363
+ * preferredStrategy: "parallel",
364
+ * preferredChunkSize: 5_000_000, // 5MB chunks
365
+ * parallelUploads: 4
366
+ * });
367
+ *
368
+ * console.log(result.strategy); // "parallel"
369
+ * console.log(result.chunkSize); // 5_000_000
370
+ * console.log(result.reasoning); // ["Using preferred strategy: parallel", ...]
371
+ * ```
372
+ */
373
+ declare class UploadStrategyNegotiator {
374
+ private capabilities;
375
+ private validateUploadStrategy;
376
+ /**
377
+ * Creates a new upload strategy negotiator.
378
+ *
379
+ * @param capabilities - Data store capabilities and constraints
380
+ * @param validateUploadStrategy - Function to validate if a strategy is supported
381
+ */
382
+ constructor(capabilities: DataStoreCapabilities, validateUploadStrategy: (strategy: UploadStrategy) => boolean);
383
+ /**
384
+ * Negotiates the optimal upload strategy based on options and data store capabilities.
385
+ *
386
+ * This method analyzes the provided options and data store capabilities to determine
387
+ * the best upload strategy, chunk size, and parallel upload settings. It considers
388
+ * user preferences, file size, and data store constraints to make optimal decisions.
389
+ *
390
+ * The negotiation process:
391
+ * 1. Validates preferred strategy against data store capabilities
392
+ * 2. Automatically selects strategy based on file size and capabilities
393
+ * 3. Adjusts chunk size to fit within data store constraints
394
+ * 4. Validates parallel upload settings
395
+ * 5. Ensures final strategy is supported by the data store
396
+ *
397
+ * @param options - Upload strategy options including file size and preferences
398
+ * @returns Negotiated strategy with reasoning and warnings
399
+ *
400
+ * @example
401
+ * ```typescript
402
+ * const result = negotiator.negotiateStrategy({
403
+ * fileSize: 50_000_000, // 50MB
404
+ * preferredStrategy: "parallel",
405
+ * preferredChunkSize: 5_000_000, // 5MB
406
+ * parallelUploads: 3
407
+ * });
408
+ *
409
+ * console.log(result.strategy); // "parallel"
410
+ * console.log(result.chunkSize); // 5_000_000
411
+ * console.log(result.parallelUploads); // 3
412
+ * console.log(result.reasoning); // ["Using preferred strategy: parallel", ...]
413
+ * console.log(result.warnings); // [] (no warnings)
414
+ * ```
415
+ */
416
+ negotiateStrategy(options: UploadStrategyOptions): NegotiatedStrategy;
417
+ /**
418
+ * Gets the data store capabilities used by this negotiator.
419
+ *
420
+ * @returns The data store capabilities and constraints
421
+ */
422
+ getDataStoreCapabilities(): DataStoreCapabilities;
423
+ /**
424
+ * Validates upload strategy configuration against data store capabilities.
425
+ *
426
+ * This method checks if the provided configuration is valid for the current
427
+ * data store capabilities without performing the actual negotiation. It's
428
+ * useful for pre-validation before attempting to negotiate a strategy.
429
+ *
430
+ * @param options - Upload strategy options to validate
431
+ * @returns Validation result with validity flag and error messages
432
+ *
433
+ * @example
434
+ * ```typescript
435
+ * const validation = negotiator.validateConfiguration({
436
+ * fileSize: 10_000_000,
437
+ * preferredStrategy: "parallel",
438
+ * preferredChunkSize: 1_000_000,
439
+ * parallelUploads: 5
440
+ * });
441
+ *
442
+ * if (!validation.valid) {
443
+ * console.log("Configuration errors:", validation.errors);
444
+ * // Handle validation errors
445
+ * }
446
+ * ```
447
+ */
448
+ validateConfiguration(options: UploadStrategyOptions): {
449
+ valid: boolean;
450
+ errors: string[];
451
+ };
452
+ }
453
+ //#endregion
454
+ export { UploadEngineOptions as a, uploadEngine as c, UploadEngine as i, compareMimeTypes as l, UploadStrategyNegotiator as n, UploadEngineShape as o, UploadStrategyOptions as r, createUploadEngine as s, NegotiatedStrategy as t, detectMimeType as u };
455
+ //# sourceMappingURL=upload-strategy-negotiator-CEnlfVgJ.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-strategy-negotiator-CEnlfVgJ.d.mts","names":[],"sources":["../src/upload/mime.ts","../src/upload/upload-engine.ts","../src/upload/upload-strategy-negotiator.ts"],"mappings":";;;;;;;;;;;;AA+BA;;cAAa,cAAA,GACX,MAAA,EAAQ,UAAA,EACR,QAAA;;;;;;;AAqYF;;;;;;;iBAAgB,gBAAA,CAAiB,QAAA,UAAkB,QAAA;;;;AAvYnD;;;;;;;;;AAuYA;;;KChYY,mBAAA;EACV,SAAA,IACM,SAAA,aAAsB,OAAA,CAAQ,SAAA,CAAU,UAAA,MAC1C,SAAA,CAAU,UAAA;EACd,OAAA,EA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AAgB,MAAA,CAAA,MAAA,CAAA,UAAA,EAAA,eAAA;6BA4I3B,QAAA,oBAAyB,MAAA,CAAA,MAAA,OAAA,eAAA;uCAWf,QAAA,oBAAyB,MAAA,CAAA,MAAA,CAAA,qBAAA,EAAA,eAAA;8CAS1C,UAAA,EACJ,mBAAA,KAAmB,MAAA,CAAA,MAAA,OAAA,eAAA;qDAKa,MAAA,CAAA,MAAA,OAAA,eAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsCvC,YAAA,EAAY,KAAA,CAAA,KAAA,CAAA,YAAA,SAAA,oBAAA,GAAA,iBAAA,GAAA,kBAAA,GAAA,UAAA;;;;;;;;ADnlBzB;;;;KEpBY,qBAAA;EACV,QAAA;EACA,iBAAA,GAAoB,cAAA;EACpB,kBAAA;EACA,eAAA;EACA,uBAAA;AAAA;;;;;;;ADsBF;;;KCVY,kBAAA;EACV,QAAA,EAAU,cAAA;EACV,SAAA;EACA,eAAA;EACA,SAAA;EACA,QAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;ADiGF;;;;;;;;cC5Da,wBAAA;EAAA,QAQD,YAAA;EAAA,QACA,sBAAA;EDgES;;;;;;cCjET,YAAA,EAAc,qBAAA,EACd,sBAAA,GAAyB,QAAA,EAAU,cAAA;EDqExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ECjCL,iBAAA,CAAkB,OAAA,EAAS,qBAAA,GAAwB,kBAAA;EDgBnD;;;;;EC0GA,wBAAA,CAAA,GAA4B,qBAAA;EDvGT;;;;;;;;;;;;;;;;;;;;;;;;;ECoInB,qBAAA,CAAsB,OAAA,EAAS,qBAAA;IAC7B,KAAA;IACA,MAAA;EAAA;AAAA"}
@@ -1,4 +1,4 @@
1
- require(`./websocket-Avz4T8YB.cjs`);let e=require(`effect`);const t={MISSING_OFFSET:{status:403,body:`Upload-Offset header required
1
+ require(`./websocket-Br0ijEZA.cjs`);let e=require(`effect`);const t={MISSING_OFFSET:{status:403,body:`Upload-Offset header required
2
2
  `},ABORTED:{status:400,body:`Request aborted due to lock acquired`},INVALID_TERMINATION:{status:400,body:`Cannot terminate an already completed upload`},ERR_LOCK_TIMEOUT:{status:500,body:`failed to acquire lock before timeout`},INVALID_CONTENT_TYPE:{status:403,body:`Content-Type header required
3
3
  `},DATASTORE_NOT_FOUND:{status:500,body:`The datastore was not found
4
4
  `},UPLOAD_ID_NOT_FOUND:{status:500,body:`The upload id was not found
@@ -52,4 +52,6 @@ require(`./websocket-Avz4T8YB.cjs`);let e=require(`effect`);const t={MISSING_OFF
52
52
  `},PDF_CORRUPTED:{status:400,body:`The PDF file is corrupted or malformed
53
53
  `},PAGE_RANGE_INVALID:{status:400,body:`The specified page range is invalid
54
54
  `},CIRCUIT_BREAKER_OPEN:{status:503,body:`Circuit breaker is open - service temporarily unavailable
55
+ `},QUEUE_ITEM_NOT_FOUND:{status:404,body:`The queue item was not found
56
+ `},QUEUE_ITEM_ALREADY_RUNNING:{status:409,body:`Cannot cancel a queue item that is already running
55
57
  `}};var n=class n extends e.Data.TaggedError(`UploadistaError`){code;status;status_code;body;details;constructor({code:e,status:t,body:n,cause:r,details:i}){super(),this.name=`UploadistaError`,this.code=e,this.status=t,this.status_code=t,this.body=n,this.message=n,this.details=i,r&&(this.cause=r)}static fromCode(e,r){let i=t[e];return new n({code:e,status:r?.status??i.status,body:r?.body??i.body,details:r?.details,cause:r?.cause})}toEffect(){return e.Effect.fail(this)}};function r(e){return e instanceof n}function i(e,t){return n.fromCode(e,t).toEffect()}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
@@ -52,5 +52,7 @@ import{Data as e,Effect as t}from"effect";const n={MISSING_OFFSET:{status:403,bo
52
52
  `},PDF_CORRUPTED:{status:400,body:`The PDF file is corrupted or malformed
53
53
  `},PAGE_RANGE_INVALID:{status:400,body:`The specified page range is invalid
54
54
  `},CIRCUIT_BREAKER_OPEN:{status:503,body:`Circuit breaker is open - service temporarily unavailable
55
+ `},QUEUE_ITEM_NOT_FOUND:{status:404,body:`The queue item was not found
56
+ `},QUEUE_ITEM_ALREADY_RUNNING:{status:409,body:`Cannot cancel a queue item that is already running
55
57
  `}};var r=class r extends e.TaggedError(`UploadistaError`){code;status;status_code;body;details;constructor({code:e,status:t,body:n,cause:r,details:i}){super(),this.name=`UploadistaError`,this.code=e,this.status=t,this.status_code=t,this.body=n,this.message=n,this.details=i,r&&(this.cause=r)}static fromCode(e,t){let i=n[e];return new r({code:e,status:t?.status??i.status,body:t?.body??i.body,details:t?.details,cause:t?.cause})}toEffect(){return t.fail(this)}};function i(e){return e instanceof r}function a(e,t){return r.fromCode(e,t).toEffect()}export{i,r as n,a as r,n as t};
56
- //# sourceMappingURL=uploadista-error-Fsfvr2Bb.mjs.map
58
+ //# sourceMappingURL=uploadista-error-DQ7V1FlX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploadista-error-DQ7V1FlX.mjs","names":[],"sources":["../src/errors/uploadista-error.ts"],"sourcesContent":["import { Data, Effect } from \"effect\";\n\n/**\n * Union type of all possible error codes in the Uploadista system.\n *\n * Each error code corresponds to a specific error condition with predefined\n * HTTP status codes and messages in the ERROR_CATALOG.\n */\nexport type UploadistaErrorCode =\n | \"MISSING_OFFSET\"\n | \"ABORTED\"\n | \"INVALID_TERMINATION\"\n | \"ERR_LOCK_TIMEOUT\"\n | \"INVALID_CONTENT_TYPE\"\n | \"FLOW_STRUCTURE_ERROR\"\n | \"FLOW_CYCLE_ERROR\"\n | \"FLOW_NODE_NOT_FOUND\"\n | \"FLOW_NODE_ERROR\"\n | \"FLOW_NOT_AUTHORIZED\"\n | \"FLOW_NOT_FOUND\"\n | \"FLOW_PAUSED\"\n | \"FLOW_CANCELLED\"\n | \"FILE_READ_ERROR\"\n | \"FLOW_JOB_NOT_FOUND\"\n | \"FLOW_JOB_ERROR\"\n | \"DATASTORE_NOT_FOUND\"\n | \"FILE_NOT_FOUND\"\n | \"UPLOAD_CANCELLED\"\n | \"INVALID_OFFSET\"\n | \"FILE_NO_LONGER_EXISTS\"\n | \"ERR_SIZE_EXCEEDED\"\n | \"ERR_MAX_SIZE_EXCEEDED\"\n | \"INVALID_LENGTH\"\n | \"INVALID_METADATA\"\n | \"VALIDATION_ERROR\"\n | \"STORAGE_NOT_AUTHORIZED\"\n | \"UNKNOWN_ERROR\"\n | \"FILE_WRITE_ERROR\"\n | \"UPLOAD_ID_NOT_FOUND\"\n | \"FLOW_OUTPUT_VALIDATION_ERROR\"\n | \"FLOW_INPUT_VALIDATION_ERROR\"\n | \"CHECKSUM_MISMATCH\"\n | \"MIMETYPE_MISMATCH\"\n | \"UNSUPPORTED_CHECKSUM_ALGORITHM\"\n | \"VIDEO_PROCESSING_FAILED\"\n | \"INVALID_VIDEO_FORMAT\"\n | \"CODEC_NOT_SUPPORTED\"\n | \"VIDEO_METADATA_EXTRACTION_FAILED\"\n | \"FFMPEG_NOT_INSTALLED\"\n | \"INVALID_NODE_TYPE\"\n | \"TYPE_CATEGORY_MISMATCH\"\n | \"INVALID_INPUT_TYPE\"\n | \"INVALID_OUTPUT_TYPE\"\n | \"OUTPUT_NOT_FOUND\"\n | \"MULTIPLE_OUTPUTS_FOUND\"\n | \"VIRUS_SCAN_FAILED\"\n | \"VIRUS_DETECTED\"\n | \"CLAMAV_NOT_INSTALLED\"\n | \"VIRUS_DEFINITIONS_OUTDATED\"\n | \"SCAN_TIMEOUT\"\n | \"DOCUMENT_PROCESSING_FAILED\"\n | \"INVALID_DOCUMENT_FORMAT\"\n | \"OCR_FAILED\"\n | \"PDF_ENCRYPTED\"\n | \"PDF_CORRUPTED\"\n | \"PAGE_RANGE_INVALID\"\n | \"CIRCUIT_BREAKER_OPEN\"\n | \"QUEUE_ITEM_NOT_FOUND\"\n | \"QUEUE_ITEM_ALREADY_RUNNING\";\n\n/**\n * Catalog of all predefined errors in the Uploadista system.\n *\n * Maps error codes to their HTTP status codes and default error messages.\n * This centralized catalog ensures consistent error handling across all\n * Uploadista packages and adapters.\n *\n * Each error entry contains:\n * - `status`: HTTP status code (400-500 range)\n * - `body`: Human-readable error message\n *\n * @example\n * ```typescript\n * // Access a specific error definition\n * const fileNotFound = ERROR_CATALOG.FILE_NOT_FOUND;\n * console.log(fileNotFound.status); // 404\n * console.log(fileNotFound.body); // \"The file for this url was not found\\n\"\n *\n * // Use with UploadistaError\n * const error = UploadistaError.fromCode(\"FILE_NOT_FOUND\");\n * ```\n */\nexport const ERROR_CATALOG: Readonly<\n Record<UploadistaErrorCode, { status: number; body: string }>\n> = {\n MISSING_OFFSET: { status: 403, body: \"Upload-Offset header required\\n\" },\n ABORTED: { status: 400, body: \"Request aborted due to lock acquired\" },\n INVALID_TERMINATION: {\n status: 400,\n body: \"Cannot terminate an already completed upload\",\n },\n ERR_LOCK_TIMEOUT: {\n status: 500,\n body: \"failed to acquire lock before timeout\",\n },\n INVALID_CONTENT_TYPE: {\n status: 403,\n body: \"Content-Type header required\\n\",\n },\n DATASTORE_NOT_FOUND: {\n status: 500,\n body: \"The datastore was not found\\n\",\n },\n UPLOAD_ID_NOT_FOUND: {\n status: 500,\n body: \"The upload id was not found\\n\",\n },\n FILE_NOT_FOUND: {\n status: 404,\n body: \"The file for this url was not found\\n\",\n },\n UPLOAD_CANCELLED: {\n status: 410,\n body: \"The upload was cancelled\\n\",\n },\n FLOW_NOT_AUTHORIZED: {\n status: 401,\n body: \"The flow is not authorized\\n\",\n },\n FLOW_NOT_FOUND: {\n status: 404,\n body: \"The flow was not found\\n\",\n },\n FLOW_PAUSED: {\n status: 409,\n body: \"The flow execution was paused by user\\n\",\n },\n FLOW_CANCELLED: {\n status: 409,\n body: \"The flow execution was cancelled by user\\n\",\n },\n FLOW_STRUCTURE_ERROR: {\n status: 500,\n body: \"The flow structure is invalid\\n\",\n },\n FLOW_CYCLE_ERROR: {\n status: 500,\n body: \"The flow contains a cycle\\n\",\n },\n FLOW_NODE_NOT_FOUND: {\n status: 500,\n body: \"The flow node was not found\\n\",\n },\n FLOW_NODE_ERROR: {\n status: 500,\n body: \"The flow node failed\\n\",\n },\n FLOW_JOB_NOT_FOUND: {\n status: 404,\n body: \"The flow job was not found\\n\",\n },\n FLOW_JOB_ERROR: {\n status: 500,\n body: \"The flow job failed\\n\",\n },\n FLOW_INPUT_VALIDATION_ERROR: {\n status: 500,\n body: \"The flow input validation failed\\n\",\n },\n FLOW_OUTPUT_VALIDATION_ERROR: {\n status: 500,\n body: \"The flow output validation failed\\n\",\n },\n INVALID_OFFSET: { status: 409, body: \"Upload-Offset conflict\\n\" },\n FILE_NO_LONGER_EXISTS: {\n status: 410,\n body: \"The file for this url no longer exists\\n\",\n },\n FILE_READ_ERROR: {\n status: 500,\n body: \"Something went wrong reading the file\\n\",\n },\n ERR_SIZE_EXCEEDED: { status: 413, body: \"upload's size exceeded\\n\" },\n ERR_MAX_SIZE_EXCEEDED: { status: 413, body: \"Maximum size exceeded\\n\" },\n INVALID_LENGTH: {\n status: 400,\n body: \"Upload-Length or Upload-Defer-Length header required\\n\",\n },\n INVALID_METADATA: {\n status: 400,\n body: \"Upload-Metadata is invalid. It MUST consist of one or more comma-separated key-value pairs. The key and value MUST be separated by a space. The key MUST NOT contain spaces and commas and MUST NOT be empty. The key SHOULD be ASCII encoded and the value MUST be Base64 encoded. All keys MUST be unique\",\n },\n VALIDATION_ERROR: {\n status: 400,\n body: \"Validation failed\\n\",\n },\n STORAGE_NOT_AUTHORIZED: {\n status: 401,\n body: \"The storage is not authorized\\n\",\n },\n UNKNOWN_ERROR: {\n status: 500,\n body: \"Something went wrong with that request\\n\",\n },\n FILE_WRITE_ERROR: {\n status: 500,\n body: \"Something went wrong receiving the file\\n\",\n },\n CHECKSUM_MISMATCH: {\n status: 400,\n body: \"The file checksum does not match the provided checksum\\n\",\n },\n MIMETYPE_MISMATCH: {\n status: 400,\n body: \"The file MIME type does not match the declared type\\n\",\n },\n UNSUPPORTED_CHECKSUM_ALGORITHM: {\n status: 400,\n body: \"The specified checksum algorithm is not supported\\n\",\n },\n VIDEO_PROCESSING_FAILED: {\n status: 500,\n body: \"Video processing operation failed\\n\",\n },\n INVALID_VIDEO_FORMAT: {\n status: 400,\n body: \"The video format is not supported\\n\",\n },\n CODEC_NOT_SUPPORTED: {\n status: 400,\n body: \"The specified video codec is not supported\\n\",\n },\n VIDEO_METADATA_EXTRACTION_FAILED: {\n status: 500,\n body: \"Failed to extract video metadata\\n\",\n },\n FFMPEG_NOT_INSTALLED: {\n status: 500,\n body: \"FFmpeg is not installed or not available in PATH\\n\",\n },\n INVALID_NODE_TYPE: {\n status: 500,\n body: \"The specified node type is not registered\\n\",\n },\n TYPE_CATEGORY_MISMATCH: {\n status: 500,\n body: \"Node type category does not match the node configuration\\n\",\n },\n INVALID_INPUT_TYPE: {\n status: 500,\n body: \"The input type is not registered\\n\",\n },\n INVALID_OUTPUT_TYPE: {\n status: 500,\n body: \"The output type is not registered\\n\",\n },\n OUTPUT_NOT_FOUND: {\n status: 404,\n body: \"No output of the specified type was found\\n\",\n },\n MULTIPLE_OUTPUTS_FOUND: {\n status: 409,\n body: \"Multiple outputs of the specified type found, expected single output\\n\",\n },\n VIRUS_SCAN_FAILED: {\n status: 500,\n body: \"Virus scanning operation failed\\n\",\n },\n VIRUS_DETECTED: {\n status: 400,\n body: \"Virus or malware detected in file\\n\",\n },\n CLAMAV_NOT_INSTALLED: {\n status: 500,\n body: \"ClamAV is not installed or not available\\n\",\n },\n VIRUS_DEFINITIONS_OUTDATED: {\n status: 500,\n body: \"Virus definitions are outdated and should be updated\\n\",\n },\n SCAN_TIMEOUT: {\n status: 500,\n body: \"Virus scan exceeded timeout limit\\n\",\n },\n DOCUMENT_PROCESSING_FAILED: {\n status: 500,\n body: \"Document processing operation failed\\n\",\n },\n INVALID_DOCUMENT_FORMAT: {\n status: 400,\n body: \"The document format is not supported\\n\",\n },\n OCR_FAILED: {\n status: 500,\n body: \"OCR operation failed\\n\",\n },\n PDF_ENCRYPTED: {\n status: 400,\n body: \"The PDF is password-protected and cannot be processed\\n\",\n },\n PDF_CORRUPTED: {\n status: 400,\n body: \"The PDF file is corrupted or malformed\\n\",\n },\n PAGE_RANGE_INVALID: {\n status: 400,\n body: \"The specified page range is invalid\\n\",\n },\n CIRCUIT_BREAKER_OPEN: {\n status: 503,\n body: \"Circuit breaker is open - service temporarily unavailable\\n\",\n },\n QUEUE_ITEM_NOT_FOUND: {\n status: 404,\n body: \"The queue item was not found\\n\",\n },\n QUEUE_ITEM_ALREADY_RUNNING: {\n status: 409,\n body: \"Cannot cancel a queue item that is already running\\n\",\n },\n} as const;\n\n/**\n * Standard error class for all Uploadista operations.\n *\n * UploadistaError provides a consistent error handling approach across the entire\n * Uploadista ecosystem. Each error has:\n * - A typed error code from the ERROR_CATALOG\n * - An HTTP-compatible status code\n * - A human-readable error message (body)\n * - Optional additional details and cause information\n *\n * This class integrates with Effect-TS for functional error handling and can be\n * easily converted to an Effect that fails.\n *\n * @example\n * ```typescript\n * // Create from error code\n * const error = UploadistaError.fromCode(\"FILE_NOT_FOUND\");\n *\n * // Create with custom details\n * const customError = UploadistaError.fromCode(\"FLOW_NODE_ERROR\", {\n * body: \"Failed to process image\",\n * cause: originalError,\n * details: { nodeId: \"resize-1\", fileId: \"abc123\" }\n * });\n *\n * // Use with Effect\n * const effect = customError.toEffect<void>();\n *\n * // In an Effect pipeline\n * return Effect.gen(function* () {\n * const file = yield* getFile(id);\n * if (!file) {\n * return yield* UploadistaError.fromCode(\"FILE_NOT_FOUND\").toEffect();\n * }\n * return file;\n * });\n * ```\n */\nexport class UploadistaError extends Data.TaggedError(\"UploadistaError\") {\n readonly code: string;\n readonly status: number;\n // Keep legacy property names for backward compatibility\n readonly status_code: number;\n readonly body: string;\n readonly details?: unknown;\n\n constructor({\n code,\n status,\n body,\n cause,\n details,\n }: {\n code: UploadistaErrorCode | string;\n status: number;\n body: string;\n cause?: unknown;\n details?: unknown;\n }) {\n super();\n this.name = \"UploadistaError\";\n this.code = code;\n this.status = status;\n this.status_code = status; // legacy alias\n this.body = body;\n // Set message property from body so it's serializable to JSON\n (this as unknown as { message: string }).message = body;\n this.details = details;\n if (cause) (this as unknown as { cause?: unknown }).cause = cause;\n }\n\n /**\n * Creates an UploadistaError from a predefined error code.\n *\n * This is the primary way to create errors in the Uploadista system. Each error code\n * has a default status and message defined in ERROR_CATALOG, but these can be overridden\n * for specific use cases.\n *\n * @param code - One of the predefined error codes from UploadistaErrorCode\n * @param overrides - Optional overrides for the default error properties\n * @param overrides.status - Custom HTTP status code (overrides the default)\n * @param overrides.body - Custom error message (overrides the default)\n * @param overrides.details - Additional structured data about the error\n * @param overrides.cause - The underlying error that caused this error (for error chaining)\n *\n * @returns A new UploadistaError instance\n *\n * @example\n * ```typescript\n * // Use default error\n * const error = UploadistaError.fromCode(\"FILE_NOT_FOUND\");\n *\n * // Override message\n * const customError = UploadistaError.fromCode(\"FILE_NOT_FOUND\", {\n * body: `File with ID ${fileId} was not found in storage`\n * });\n *\n * // Include cause and details\n * const detailedError = UploadistaError.fromCode(\"DATASTORE_NOT_FOUND\", {\n * cause: storageException,\n * details: { storageId: \"s3-prod\", region: \"us-east-1\" }\n * });\n * ```\n */\n static fromCode(\n code: UploadistaErrorCode,\n overrides?: Partial<Pick<UploadistaError, \"status\" | \"body\">> & {\n details?: unknown;\n cause?: unknown;\n },\n ): UploadistaError {\n const base = ERROR_CATALOG[code];\n return new UploadistaError({\n code,\n status: overrides?.status ?? base.status,\n body: overrides?.body ?? base.body,\n details: overrides?.details,\n cause: overrides?.cause,\n });\n }\n\n /**\n * Converts this error to an Effect that immediately fails.\n *\n * This method integrates UploadistaError with Effect-TS's error handling system,\n * allowing errors to be used in Effect pipelines with proper type checking.\n *\n * @template T - The success type of the Effect (defaults to never since it always fails)\n * @returns An Effect that fails with this UploadistaError\n *\n * @example\n * ```typescript\n * const error = UploadistaError.fromCode(\"FILE_NOT_FOUND\");\n *\n * // Use in an Effect pipeline\n * return Effect.gen(function* () {\n * const file = yield* kvStore.get(fileId);\n * if (!file) {\n * return yield* error.toEffect();\n * }\n * return file;\n * });\n * ```\n */\n toEffect<T = never>(): Effect.Effect<T, UploadistaError> {\n return Effect.fail(this);\n }\n}\n\n/**\n * Type guard to check if an unknown value is an UploadistaError.\n *\n * Useful for error handling when catching errors that might be from\n * different sources or libraries.\n *\n * @param error - The value to check\n * @returns True if the value is an UploadistaError instance\n *\n * @example\n * ```typescript\n * try {\n * await someOperation();\n * } catch (error) {\n * if (isUploadistaError(error)) {\n * console.log(`Uploadista error: ${error.code} (${error.status})`);\n * console.log(error.body);\n * } else {\n * console.error(\"Unknown error:\", error);\n * }\n * }\n * ```\n */\nexport function isUploadistaError(error: unknown): error is UploadistaError {\n return error instanceof UploadistaError;\n}\n\n/**\n * Creates an Effect that immediately fails with an UploadistaError.\n *\n * This is a convenience function that combines error creation with Effect conversion.\n * It's equivalent to calling `UploadistaError.fromCode(code, overrides).toEffect()`.\n *\n * @param code - One of the predefined error codes from UploadistaErrorCode\n * @param overrides - Optional overrides for the default error properties\n * @param overrides.status - Custom HTTP status code\n * @param overrides.body - Custom error message\n * @param overrides.details - Additional structured data about the error\n * @param overrides.cause - The underlying error that caused this error\n *\n * @returns An Effect that immediately fails with the created UploadistaError\n *\n * @example\n * ```typescript\n * // In an Effect pipeline\n * return Effect.gen(function* () {\n * const file = yield* kvStore.get(fileId);\n * if (!file) {\n * return yield* httpFailure(\"FILE_NOT_FOUND\", {\n * details: { fileId }\n * });\n * }\n * return file;\n * });\n * ```\n */\nexport function httpFailure(\n code: UploadistaErrorCode,\n overrides?: Partial<Pick<UploadistaError, \"status\" | \"body\">> & {\n details?: unknown;\n cause?: unknown;\n },\n): Effect.Effect<never, UploadistaError> {\n return UploadistaError.fromCode(code, overrides).toEffect();\n}\n"],"mappings":"0CA4FA,MAAa,EAET,CACF,eAAgB,C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CACD,2BAA4B,CAC1B,OAAQ,IACR,KAAM;EACP,CACF,CAwCD,IAAa,EAAb,MAAa,UAAwB,EAAK,YAAY,kBAAkB,AAAC,CACvE,KACA,OAEA,YACA,KACA,QAEA,YAAY,CACV,OACA,SACA,OACA,QACA,WAOC,CACD,OAAO,CACP,KAAK,KAAO,kBACZ,KAAK,KAAO,EACZ,KAAK,OAAS,EACd,KAAK,YAAc,EACnB,KAAK,KAAO,EAEX,KAAwC,QAAU,EACnD,KAAK,QAAU,EACX,IAAQ,KAAwC,MAAQ,GAoC9D,OAAO,SACL,EACA,EAIiB,CACjB,IAAM,EAAO,EAAc,GAC3B,OAAO,IAAI,EAAgB,CACzB,OACA,OAAQ,GAAW,QAAU,EAAK,OAClC,KAAM,GAAW,MAAQ,EAAK,KAC9B,QAAS,GAAW,QACpB,MAAO,GAAW,MACnB,CAAC,CA0BJ,UAAyD,CACvD,OAAO,EAAO,KAAK,KAAK,GA2B5B,SAAgB,EAAkB,EAA0C,CAC1E,OAAO,aAAiB,EAgC1B,SAAgB,EACd,EACA,EAIuC,CACvC,OAAO,EAAgB,SAAS,EAAM,EAAU,CAAC,UAAU"}
@@ -9,7 +9,7 @@ import * as effect_Cause0 from "effect/Cause";
9
9
  * Each error code corresponds to a specific error condition with predefined
10
10
  * HTTP status codes and messages in the ERROR_CATALOG.
11
11
  */
12
- type UploadistaErrorCode = "MISSING_OFFSET" | "ABORTED" | "INVALID_TERMINATION" | "ERR_LOCK_TIMEOUT" | "INVALID_CONTENT_TYPE" | "FLOW_STRUCTURE_ERROR" | "FLOW_CYCLE_ERROR" | "FLOW_NODE_NOT_FOUND" | "FLOW_NODE_ERROR" | "FLOW_NOT_AUTHORIZED" | "FLOW_NOT_FOUND" | "FLOW_PAUSED" | "FLOW_CANCELLED" | "FILE_READ_ERROR" | "FLOW_JOB_NOT_FOUND" | "FLOW_JOB_ERROR" | "DATASTORE_NOT_FOUND" | "FILE_NOT_FOUND" | "UPLOAD_CANCELLED" | "INVALID_OFFSET" | "FILE_NO_LONGER_EXISTS" | "ERR_SIZE_EXCEEDED" | "ERR_MAX_SIZE_EXCEEDED" | "INVALID_LENGTH" | "INVALID_METADATA" | "VALIDATION_ERROR" | "STORAGE_NOT_AUTHORIZED" | "UNKNOWN_ERROR" | "FILE_WRITE_ERROR" | "UPLOAD_ID_NOT_FOUND" | "FLOW_OUTPUT_VALIDATION_ERROR" | "FLOW_INPUT_VALIDATION_ERROR" | "CHECKSUM_MISMATCH" | "MIMETYPE_MISMATCH" | "UNSUPPORTED_CHECKSUM_ALGORITHM" | "VIDEO_PROCESSING_FAILED" | "INVALID_VIDEO_FORMAT" | "CODEC_NOT_SUPPORTED" | "VIDEO_METADATA_EXTRACTION_FAILED" | "FFMPEG_NOT_INSTALLED" | "INVALID_NODE_TYPE" | "TYPE_CATEGORY_MISMATCH" | "INVALID_INPUT_TYPE" | "INVALID_OUTPUT_TYPE" | "OUTPUT_NOT_FOUND" | "MULTIPLE_OUTPUTS_FOUND" | "VIRUS_SCAN_FAILED" | "VIRUS_DETECTED" | "CLAMAV_NOT_INSTALLED" | "VIRUS_DEFINITIONS_OUTDATED" | "SCAN_TIMEOUT" | "DOCUMENT_PROCESSING_FAILED" | "INVALID_DOCUMENT_FORMAT" | "OCR_FAILED" | "PDF_ENCRYPTED" | "PDF_CORRUPTED" | "PAGE_RANGE_INVALID" | "CIRCUIT_BREAKER_OPEN";
12
+ type UploadistaErrorCode = "MISSING_OFFSET" | "ABORTED" | "INVALID_TERMINATION" | "ERR_LOCK_TIMEOUT" | "INVALID_CONTENT_TYPE" | "FLOW_STRUCTURE_ERROR" | "FLOW_CYCLE_ERROR" | "FLOW_NODE_NOT_FOUND" | "FLOW_NODE_ERROR" | "FLOW_NOT_AUTHORIZED" | "FLOW_NOT_FOUND" | "FLOW_PAUSED" | "FLOW_CANCELLED" | "FILE_READ_ERROR" | "FLOW_JOB_NOT_FOUND" | "FLOW_JOB_ERROR" | "DATASTORE_NOT_FOUND" | "FILE_NOT_FOUND" | "UPLOAD_CANCELLED" | "INVALID_OFFSET" | "FILE_NO_LONGER_EXISTS" | "ERR_SIZE_EXCEEDED" | "ERR_MAX_SIZE_EXCEEDED" | "INVALID_LENGTH" | "INVALID_METADATA" | "VALIDATION_ERROR" | "STORAGE_NOT_AUTHORIZED" | "UNKNOWN_ERROR" | "FILE_WRITE_ERROR" | "UPLOAD_ID_NOT_FOUND" | "FLOW_OUTPUT_VALIDATION_ERROR" | "FLOW_INPUT_VALIDATION_ERROR" | "CHECKSUM_MISMATCH" | "MIMETYPE_MISMATCH" | "UNSUPPORTED_CHECKSUM_ALGORITHM" | "VIDEO_PROCESSING_FAILED" | "INVALID_VIDEO_FORMAT" | "CODEC_NOT_SUPPORTED" | "VIDEO_METADATA_EXTRACTION_FAILED" | "FFMPEG_NOT_INSTALLED" | "INVALID_NODE_TYPE" | "TYPE_CATEGORY_MISMATCH" | "INVALID_INPUT_TYPE" | "INVALID_OUTPUT_TYPE" | "OUTPUT_NOT_FOUND" | "MULTIPLE_OUTPUTS_FOUND" | "VIRUS_SCAN_FAILED" | "VIRUS_DETECTED" | "CLAMAV_NOT_INSTALLED" | "VIRUS_DEFINITIONS_OUTDATED" | "SCAN_TIMEOUT" | "DOCUMENT_PROCESSING_FAILED" | "INVALID_DOCUMENT_FORMAT" | "OCR_FAILED" | "PDF_ENCRYPTED" | "PDF_CORRUPTED" | "PAGE_RANGE_INVALID" | "CIRCUIT_BREAKER_OPEN" | "QUEUE_ITEM_NOT_FOUND" | "QUEUE_ITEM_ALREADY_RUNNING";
13
13
  /**
14
14
  * Catalog of all predefined errors in the Uploadista system.
15
15
  *
@@ -217,4 +217,4 @@ declare function httpFailure(code: UploadistaErrorCode, overrides?: Partial<Pick
217
217
  }): Effect.Effect<never, UploadistaError>;
218
218
  //#endregion
219
219
  export { isUploadistaError as a, httpFailure as i, UploadistaError as n, UploadistaErrorCode as r, ERROR_CATALOG as t };
220
- //# sourceMappingURL=uploadista-error-BragVhIs.d.mts.map
220
+ //# sourceMappingURL=uploadista-error-LtiZn-R_.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadista-error-BragVhIs.d.mts","names":[],"sources":["../src/errors/uploadista-error.ts"],"mappings":";;;;;;;;;AAQA;;KAAY,mBAAA;;;AAkFZ;;;;;;;;;;;;;;;AA4NW;;;;;cA5NE,aAAA,EAAe,QAAA,CAC1B,MAAA,CAAO,mBAAA;EAAuB,MAAA;EAAgB,IAAA;AAAA;AAAA,cA2NrC,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwCX;;;;;;;;;;;;;;;;;cAAa,eAAA,SAAwB,oBAAA;EAAA,SAC1B,IAAA;EAAA,SACA,MAAA;EAAA,SAEA,WAAA;EAAA,SACA,IAAA;EAAA,SACA,OAAA;;IAGP,IAAA;IACA,MAAA;IACA,IAAA;IACA,KAAA;IACA;EAAA;IAEA,IAAA,EAAM,mBAAA;IACN,MAAA;IACA,IAAA;IACA,KAAA;IACA,OAAA;EAAA;EATA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4HJ;;EA5HI,OAwDK,QAAA,CACL,IAAA,EAAM,mBAAA,EACN,SAAA,GAAY,OAAA,CAAQ,IAAA,CAAK,eAAA;IACvB,OAAA;IACA,KAAA;EAAA,IAED,eAAA;EA8DuD;;;AAiC5D;;;;;;;;;;;;;;;;;;;;EA7DE,QAAA,WAAA,CAAA,GAAuB,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,eAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;iBA4B1B,iBAAA,CAAkB,KAAA,YAAiB,KAAA,IAAS,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiC5C,WAAA,CACd,IAAA,EAAM,mBAAA,EACN,SAAA,GAAY,OAAA,CAAQ,IAAA,CAAK,eAAA;EACvB,OAAA;EACA,KAAA;AAAA,IAED,MAAA,CAAO,MAAA,QAAc,eAAA"}
1
+ {"version":3,"file":"uploadista-error-LtiZn-R_.d.mts","names":[],"sources":["../src/errors/uploadista-error.ts"],"mappings":";;;;;;;;;AAQA;;KAAY,mBAAA;;;AAoFZ;;;;;;;;;;;;;;;AAoOW;;;;;cApOE,aAAA,EAAe,QAAA,CAC1B,MAAA,CAAO,mBAAA;EAAuB,MAAA;EAAgB,IAAA;AAAA;AAAA,cAmOrC,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwCX;;;;;;;;;;;;;;;;;cAAa,eAAA,SAAwB,oBAAA;EAAA,SAC1B,IAAA;EAAA,SACA,MAAA;EAAA,SAEA,WAAA;EAAA,SACA,IAAA;EAAA,SACA,OAAA;;IAGP,IAAA;IACA,MAAA;IACA,IAAA;IACA,KAAA;IACA;EAAA;IAEA,IAAA,EAAM,mBAAA;IACN,MAAA;IACA,IAAA;IACA,KAAA;IACA,OAAA;EAAA;EATA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4HJ;;EA5HI,OAwDK,QAAA,CACL,IAAA,EAAM,mBAAA,EACN,SAAA,GAAY,OAAA,CAAQ,IAAA,CAAK,eAAA;IACvB,OAAA;IACA,KAAA;EAAA,IAED,eAAA;EA8DuD;;;AAiC5D;;;;;;;;;;;;;;;;;;;;EA7DE,QAAA,WAAA,CAAA,GAAuB,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,eAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;iBA4B1B,iBAAA,CAAkB,KAAA,YAAiB,KAAA,IAAS,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiC5C,WAAA,CACd,IAAA,EAAM,mBAAA,EACN,SAAA,GAAY,OAAA,CAAQ,IAAA,CAAK,eAAA;EACvB,OAAA;EACA,KAAA;AAAA,IAED,MAAA,CAAO,MAAA,QAAc,eAAA"}
@@ -9,7 +9,7 @@ import { Effect } from "effect";
9
9
  * Each error code corresponds to a specific error condition with predefined
10
10
  * HTTP status codes and messages in the ERROR_CATALOG.
11
11
  */
12
- type UploadistaErrorCode = "MISSING_OFFSET" | "ABORTED" | "INVALID_TERMINATION" | "ERR_LOCK_TIMEOUT" | "INVALID_CONTENT_TYPE" | "FLOW_STRUCTURE_ERROR" | "FLOW_CYCLE_ERROR" | "FLOW_NODE_NOT_FOUND" | "FLOW_NODE_ERROR" | "FLOW_NOT_AUTHORIZED" | "FLOW_NOT_FOUND" | "FLOW_PAUSED" | "FLOW_CANCELLED" | "FILE_READ_ERROR" | "FLOW_JOB_NOT_FOUND" | "FLOW_JOB_ERROR" | "DATASTORE_NOT_FOUND" | "FILE_NOT_FOUND" | "UPLOAD_CANCELLED" | "INVALID_OFFSET" | "FILE_NO_LONGER_EXISTS" | "ERR_SIZE_EXCEEDED" | "ERR_MAX_SIZE_EXCEEDED" | "INVALID_LENGTH" | "INVALID_METADATA" | "VALIDATION_ERROR" | "STORAGE_NOT_AUTHORIZED" | "UNKNOWN_ERROR" | "FILE_WRITE_ERROR" | "UPLOAD_ID_NOT_FOUND" | "FLOW_OUTPUT_VALIDATION_ERROR" | "FLOW_INPUT_VALIDATION_ERROR" | "CHECKSUM_MISMATCH" | "MIMETYPE_MISMATCH" | "UNSUPPORTED_CHECKSUM_ALGORITHM" | "VIDEO_PROCESSING_FAILED" | "INVALID_VIDEO_FORMAT" | "CODEC_NOT_SUPPORTED" | "VIDEO_METADATA_EXTRACTION_FAILED" | "FFMPEG_NOT_INSTALLED" | "INVALID_NODE_TYPE" | "TYPE_CATEGORY_MISMATCH" | "INVALID_INPUT_TYPE" | "INVALID_OUTPUT_TYPE" | "OUTPUT_NOT_FOUND" | "MULTIPLE_OUTPUTS_FOUND" | "VIRUS_SCAN_FAILED" | "VIRUS_DETECTED" | "CLAMAV_NOT_INSTALLED" | "VIRUS_DEFINITIONS_OUTDATED" | "SCAN_TIMEOUT" | "DOCUMENT_PROCESSING_FAILED" | "INVALID_DOCUMENT_FORMAT" | "OCR_FAILED" | "PDF_ENCRYPTED" | "PDF_CORRUPTED" | "PAGE_RANGE_INVALID" | "CIRCUIT_BREAKER_OPEN";
12
+ type UploadistaErrorCode = "MISSING_OFFSET" | "ABORTED" | "INVALID_TERMINATION" | "ERR_LOCK_TIMEOUT" | "INVALID_CONTENT_TYPE" | "FLOW_STRUCTURE_ERROR" | "FLOW_CYCLE_ERROR" | "FLOW_NODE_NOT_FOUND" | "FLOW_NODE_ERROR" | "FLOW_NOT_AUTHORIZED" | "FLOW_NOT_FOUND" | "FLOW_PAUSED" | "FLOW_CANCELLED" | "FILE_READ_ERROR" | "FLOW_JOB_NOT_FOUND" | "FLOW_JOB_ERROR" | "DATASTORE_NOT_FOUND" | "FILE_NOT_FOUND" | "UPLOAD_CANCELLED" | "INVALID_OFFSET" | "FILE_NO_LONGER_EXISTS" | "ERR_SIZE_EXCEEDED" | "ERR_MAX_SIZE_EXCEEDED" | "INVALID_LENGTH" | "INVALID_METADATA" | "VALIDATION_ERROR" | "STORAGE_NOT_AUTHORIZED" | "UNKNOWN_ERROR" | "FILE_WRITE_ERROR" | "UPLOAD_ID_NOT_FOUND" | "FLOW_OUTPUT_VALIDATION_ERROR" | "FLOW_INPUT_VALIDATION_ERROR" | "CHECKSUM_MISMATCH" | "MIMETYPE_MISMATCH" | "UNSUPPORTED_CHECKSUM_ALGORITHM" | "VIDEO_PROCESSING_FAILED" | "INVALID_VIDEO_FORMAT" | "CODEC_NOT_SUPPORTED" | "VIDEO_METADATA_EXTRACTION_FAILED" | "FFMPEG_NOT_INSTALLED" | "INVALID_NODE_TYPE" | "TYPE_CATEGORY_MISMATCH" | "INVALID_INPUT_TYPE" | "INVALID_OUTPUT_TYPE" | "OUTPUT_NOT_FOUND" | "MULTIPLE_OUTPUTS_FOUND" | "VIRUS_SCAN_FAILED" | "VIRUS_DETECTED" | "CLAMAV_NOT_INSTALLED" | "VIRUS_DEFINITIONS_OUTDATED" | "SCAN_TIMEOUT" | "DOCUMENT_PROCESSING_FAILED" | "INVALID_DOCUMENT_FORMAT" | "OCR_FAILED" | "PDF_ENCRYPTED" | "PDF_CORRUPTED" | "PAGE_RANGE_INVALID" | "CIRCUIT_BREAKER_OPEN" | "QUEUE_ITEM_NOT_FOUND" | "QUEUE_ITEM_ALREADY_RUNNING";
13
13
  /**
14
14
  * Catalog of all predefined errors in the Uploadista system.
15
15
  *
@@ -217,4 +217,4 @@ declare function httpFailure(code: UploadistaErrorCode, overrides?: Partial<Pick
217
217
  }): Effect.Effect<never, UploadistaError>;
218
218
  //#endregion
219
219
  export { isUploadistaError as a, httpFailure as i, UploadistaError as n, UploadistaErrorCode as r, ERROR_CATALOG as t };
220
- //# sourceMappingURL=uploadista-error-Cj_pAFck.d.cts.map
220
+ //# sourceMappingURL=uploadista-error-eZtG4iyf.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadista-error-Cj_pAFck.d.cts","names":[],"sources":["../src/errors/uploadista-error.ts"],"mappings":";;;;;;;;;AAQA;;KAAY,mBAAA;;;AAkFZ;;;;;;;;;;;;;;;AA4NW;;;;;cA5NE,aAAA,EAAe,QAAA,CAC1B,MAAA,CAAO,mBAAA;EAAuB,MAAA;EAAgB,IAAA;AAAA;AAAA,cA2NrC,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwCX;;;;;;;;;;;;;;;;;cAAa,eAAA,SAAwB,oBAAA;EAAA,SAC1B,IAAA;EAAA,SACA,MAAA;EAAA,SAEA,WAAA;EAAA,SACA,IAAA;EAAA,SACA,OAAA;;IAGP,IAAA;IACA,MAAA;IACA,IAAA;IACA,KAAA;IACA;EAAA;IAEA,IAAA,EAAM,mBAAA;IACN,MAAA;IACA,IAAA;IACA,KAAA;IACA,OAAA;EAAA;EATA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4HJ;;EA5HI,OAwDK,QAAA,CACL,IAAA,EAAM,mBAAA,EACN,SAAA,GAAY,OAAA,CAAQ,IAAA,CAAK,eAAA;IACvB,OAAA;IACA,KAAA;EAAA,IAED,eAAA;EA8DuD;;;AAiC5D;;;;;;;;;;;;;;;;;;;;EA7DE,QAAA,WAAA,CA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AA,CAAkB,KAAA,YAAiB,KAAA,IAAS,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiC5C,WAAA,CACd,IAAA,EAAM,mBAAA,EACN,SAAA,GAAY,OAAA,CAAQ,IAAA,CAAK,eAAA;EACvB,OAAA;EACA,KAAA;AAAA,IAED,MAAA,CAAO,MAAA,QAAc,eAAA"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../uploadista-error-B-geDgi8.cjs`);const e=require(`../checksum-B7RDiO7V.cjs`),t=require(`../throttle-KnkRgZPi.cjs`);exports.GenerateId=e.r,exports.GenerateIdLive=e.i,exports.GenerateIdRandom=e.a,exports.GenerateIdService=e.o,exports.GenerateIdTimestamp=e.s,exports.Md5=t.a,exports.OnceEffect=t.r,exports.ThrottleEffect=t.t,exports.computeChecksum=e.t,exports.isSupportedAlgorithm=e.n,exports.once=t.i,exports.throttle=t.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../uploadista-error-CZx1JU_L.cjs`);const e=require(`../checksum-BrjQ8GJL.cjs`),t=require(`../throttle-Dp59f37i.cjs`);exports.GenerateId=e.r,exports.GenerateIdLive=e.i,exports.GenerateIdRandom=e.a,exports.GenerateIdService=e.o,exports.GenerateIdTimestamp=e.s,exports.Md5=t.a,exports.OnceEffect=t.r,exports.ThrottleEffect=t.t,exports.computeChecksum=e.t,exports.isSupportedAlgorithm=e.n,exports.once=t.i,exports.throttle=t.n;
@@ -1,2 +1,3 @@
1
- import { a as Md5, c as isSupportedAlgorithm, d as GenerateIdRandom, f as GenerateIdService, i as once, l as GenerateId, m as GenerateIdTimestamp, n as throttle, o as ChecksumAlgorithm, p as GenerateIdShape, r as OnceEffect, s as computeChecksum, t as ThrottleEffect, u as GenerateIdLive } from "../throttle-Da0OA8JT.cjs";
1
+ import { a as GenerateIdShape, i as GenerateIdService, n as GenerateIdLive, o as GenerateIdTimestamp, r as GenerateIdRandom, t as GenerateId } from "../generate-id-BAMRQzMr.cjs";
2
+ import { a as Md5, c as isSupportedAlgorithm, i as once, n as throttle, o as ChecksumAlgorithm, r as OnceEffect, s as computeChecksum, t as ThrottleEffect } from "../throttle-BlH27EGu.cjs";
2
3
  export { ChecksumAlgorithm, GenerateId, GenerateIdLive, GenerateIdRandom, GenerateIdService, GenerateIdShape, GenerateIdTimestamp, Md5, OnceEffect, ThrottleEffect, computeChecksum, isSupportedAlgorithm, once, throttle };
@@ -1,3 +1,4 @@
1
- import "../uploadista-error-BragVhIs.mjs";
2
- import { a as Md5, c as isSupportedAlgorithm, d as GenerateIdRandom, f as GenerateIdService, i as once, l as GenerateId, m as GenerateIdTimestamp, n as throttle, o as ChecksumAlgorithm, p as GenerateIdShape, r as OnceEffect, s as computeChecksum, t as ThrottleEffect, u as GenerateIdLive } from "../throttle-ibiT6E4U.mjs";
1
+ import "../uploadista-error-LtiZn-R_.mjs";
2
+ import { a as GenerateIdShape, i as GenerateIdService, n as GenerateIdLive, o as GenerateIdTimestamp, r as GenerateIdRandom, t as GenerateId } from "../generate-id-DuZwLm4m.mjs";
3
+ import { a as Md5, c as isSupportedAlgorithm, i as once, n as throttle, o as ChecksumAlgorithm, r as OnceEffect, s as computeChecksum, t as ThrottleEffect } from "../throttle-3FRcr7MU.mjs";
3
4
  export { ChecksumAlgorithm, GenerateId, GenerateIdLive, GenerateIdRandom, GenerateIdService, GenerateIdShape, GenerateIdTimestamp, Md5, OnceEffect, ThrottleEffect, computeChecksum, isSupportedAlgorithm, once, throttle };
@@ -1 +1 @@
1
- import"../uploadista-error-Fsfvr2Bb.mjs";import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"../checksum-BjP9nb5b.mjs";import{a as s,i as c,n as l,r as u,t as d}from"../throttle-CnDa3v1k.mjs";export{i as GenerateId,t as GenerateIdLive,e as GenerateIdRandom,r as GenerateIdService,a as GenerateIdTimestamp,s as Md5,u as OnceEffect,d as ThrottleEffect,o as computeChecksum,n as isSupportedAlgorithm,c as once,l as throttle};
1
+ import"../uploadista-error-DQ7V1FlX.mjs";import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"../checksum-BRjFmTRk.mjs";import{a as s,i as c,n as l,r as u,t as d}from"../throttle-TFY-V41R.mjs";export{i as GenerateId,t as GenerateIdLive,e as GenerateIdRandom,r as GenerateIdService,a as GenerateIdTimestamp,s as Md5,u as OnceEffect,d as ThrottleEffect,o as computeChecksum,n as isSupportedAlgorithm,c as once,l as throttle};