@uploadista/core 0.0.2

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 (359) hide show
  1. package/.turbo/turbo-build.log +5 -0
  2. package/.turbo/turbo-check.log +231 -0
  3. package/.turbo/turbo-format.log +5 -0
  4. package/LICENSE +21 -0
  5. package/README.md +1120 -0
  6. package/dist/chunk-CUT6urMc.cjs +1 -0
  7. package/dist/debounce-C2SeqcxD.js +2 -0
  8. package/dist/debounce-C2SeqcxD.js.map +1 -0
  9. package/dist/debounce-LZK7yS7Z.cjs +1 -0
  10. package/dist/errors/index.cjs +1 -0
  11. package/dist/errors/index.d.cts +3 -0
  12. package/dist/errors/index.d.ts +3 -0
  13. package/dist/errors/index.d.ts.map +1 -0
  14. package/dist/errors/index.js +2 -0
  15. package/dist/errors/uploadista-error.d.ts +209 -0
  16. package/dist/errors/uploadista-error.d.ts.map +1 -0
  17. package/dist/errors/uploadista-error.js +322 -0
  18. package/dist/errors-8i_aMxOE.js +1 -0
  19. package/dist/errors-CRm1FHHT.cjs +0 -0
  20. package/dist/flow/edge.d.ts +47 -0
  21. package/dist/flow/edge.d.ts.map +1 -0
  22. package/dist/flow/edge.js +40 -0
  23. package/dist/flow/event.d.ts +206 -0
  24. package/dist/flow/event.d.ts.map +1 -0
  25. package/dist/flow/event.js +53 -0
  26. package/dist/flow/flow-server.d.ts +223 -0
  27. package/dist/flow/flow-server.d.ts.map +1 -0
  28. package/dist/flow/flow-server.js +614 -0
  29. package/dist/flow/flow.d.ts +238 -0
  30. package/dist/flow/flow.d.ts.map +1 -0
  31. package/dist/flow/flow.js +629 -0
  32. package/dist/flow/index.cjs +1 -0
  33. package/dist/flow/index.d.cts +6 -0
  34. package/dist/flow/index.d.ts +24 -0
  35. package/dist/flow/index.d.ts.map +1 -0
  36. package/dist/flow/index.js +24 -0
  37. package/dist/flow/node.d.ts +136 -0
  38. package/dist/flow/node.d.ts.map +1 -0
  39. package/dist/flow/node.js +153 -0
  40. package/dist/flow/nodes/index.d.ts +8 -0
  41. package/dist/flow/nodes/index.d.ts.map +1 -0
  42. package/dist/flow/nodes/index.js +7 -0
  43. package/dist/flow/nodes/input-node.d.ts +78 -0
  44. package/dist/flow/nodes/input-node.d.ts.map +1 -0
  45. package/dist/flow/nodes/input-node.js +233 -0
  46. package/dist/flow/nodes/storage-node.d.ts +67 -0
  47. package/dist/flow/nodes/storage-node.d.ts.map +1 -0
  48. package/dist/flow/nodes/storage-node.js +94 -0
  49. package/dist/flow/nodes/streaming-input-node.d.ts +69 -0
  50. package/dist/flow/nodes/streaming-input-node.d.ts.map +1 -0
  51. package/dist/flow/nodes/streaming-input-node.js +156 -0
  52. package/dist/flow/nodes/transform-node.d.ts +85 -0
  53. package/dist/flow/nodes/transform-node.d.ts.map +1 -0
  54. package/dist/flow/nodes/transform-node.js +107 -0
  55. package/dist/flow/parallel-scheduler.d.ts +175 -0
  56. package/dist/flow/parallel-scheduler.d.ts.map +1 -0
  57. package/dist/flow/parallel-scheduler.js +193 -0
  58. package/dist/flow/plugins/credential-provider.d.ts +47 -0
  59. package/dist/flow/plugins/credential-provider.d.ts.map +1 -0
  60. package/dist/flow/plugins/credential-provider.js +24 -0
  61. package/dist/flow/plugins/image-ai-plugin.d.ts +61 -0
  62. package/dist/flow/plugins/image-ai-plugin.d.ts.map +1 -0
  63. package/dist/flow/plugins/image-ai-plugin.js +21 -0
  64. package/dist/flow/plugins/image-plugin.d.ts +52 -0
  65. package/dist/flow/plugins/image-plugin.d.ts.map +1 -0
  66. package/dist/flow/plugins/image-plugin.js +22 -0
  67. package/dist/flow/plugins/types/describe-image-node.d.ts +16 -0
  68. package/dist/flow/plugins/types/describe-image-node.d.ts.map +1 -0
  69. package/dist/flow/plugins/types/describe-image-node.js +9 -0
  70. package/dist/flow/plugins/types/index.d.ts +9 -0
  71. package/dist/flow/plugins/types/index.d.ts.map +1 -0
  72. package/dist/flow/plugins/types/index.js +8 -0
  73. package/dist/flow/plugins/types/optimize-node.d.ts +20 -0
  74. package/dist/flow/plugins/types/optimize-node.d.ts.map +1 -0
  75. package/dist/flow/plugins/types/optimize-node.js +11 -0
  76. package/dist/flow/plugins/types/remove-background-node.d.ts +16 -0
  77. package/dist/flow/plugins/types/remove-background-node.d.ts.map +1 -0
  78. package/dist/flow/plugins/types/remove-background-node.js +9 -0
  79. package/dist/flow/plugins/types/resize-node.d.ts +21 -0
  80. package/dist/flow/plugins/types/resize-node.d.ts.map +1 -0
  81. package/dist/flow/plugins/types/resize-node.js +16 -0
  82. package/dist/flow/plugins/zip-plugin.d.ts +62 -0
  83. package/dist/flow/plugins/zip-plugin.d.ts.map +1 -0
  84. package/dist/flow/plugins/zip-plugin.js +21 -0
  85. package/dist/flow/typed-flow.d.ts +90 -0
  86. package/dist/flow/typed-flow.d.ts.map +1 -0
  87. package/dist/flow/typed-flow.js +59 -0
  88. package/dist/flow/types/flow-file.d.ts +45 -0
  89. package/dist/flow/types/flow-file.d.ts.map +1 -0
  90. package/dist/flow/types/flow-file.js +27 -0
  91. package/dist/flow/types/flow-job.d.ts +118 -0
  92. package/dist/flow/types/flow-job.d.ts.map +1 -0
  93. package/dist/flow/types/flow-job.js +11 -0
  94. package/dist/flow/types/flow-types.d.ts +321 -0
  95. package/dist/flow/types/flow-types.d.ts.map +1 -0
  96. package/dist/flow/types/flow-types.js +52 -0
  97. package/dist/flow/types/index.d.ts +4 -0
  98. package/dist/flow/types/index.d.ts.map +1 -0
  99. package/dist/flow/types/index.js +3 -0
  100. package/dist/flow/types/run-args.d.ts +38 -0
  101. package/dist/flow/types/run-args.d.ts.map +1 -0
  102. package/dist/flow/types/run-args.js +30 -0
  103. package/dist/flow/types/type-validator.d.ts +26 -0
  104. package/dist/flow/types/type-validator.d.ts.map +1 -0
  105. package/dist/flow/types/type-validator.js +134 -0
  106. package/dist/flow/utils/resolve-upload-metadata.d.ts +11 -0
  107. package/dist/flow/utils/resolve-upload-metadata.d.ts.map +1 -0
  108. package/dist/flow/utils/resolve-upload-metadata.js +28 -0
  109. package/dist/flow-2zXnEiWL.cjs +1 -0
  110. package/dist/flow-CRaKy7Vj.js +2 -0
  111. package/dist/flow-CRaKy7Vj.js.map +1 -0
  112. package/dist/generate-id-Dm-Vboxq.d.ts +34 -0
  113. package/dist/generate-id-Dm-Vboxq.d.ts.map +1 -0
  114. package/dist/generate-id-LjJRLD6N.d.cts +34 -0
  115. package/dist/generate-id-LjJRLD6N.d.cts.map +1 -0
  116. package/dist/generate-id-xHp_Z7Cl.cjs +1 -0
  117. package/dist/generate-id-yohS1ZDk.js +2 -0
  118. package/dist/generate-id-yohS1ZDk.js.map +1 -0
  119. package/dist/index-BO8GZlbD.d.cts +1040 -0
  120. package/dist/index-BO8GZlbD.d.cts.map +1 -0
  121. package/dist/index-BoGG5KAY.d.ts +1 -0
  122. package/dist/index-BtBZHVmz.d.cts +1 -0
  123. package/dist/index-D-CoVpkZ.d.ts +1004 -0
  124. package/dist/index-D-CoVpkZ.d.ts.map +1 -0
  125. package/dist/index.cjs +1 -0
  126. package/dist/index.d.cts +6 -0
  127. package/dist/index.d.ts +5 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/index.js +5 -0
  130. package/dist/logger/logger.cjs +1 -0
  131. package/dist/logger/logger.d.cts +8 -0
  132. package/dist/logger/logger.d.cts.map +1 -0
  133. package/dist/logger/logger.d.ts +5 -0
  134. package/dist/logger/logger.d.ts.map +1 -0
  135. package/dist/logger/logger.js +10 -0
  136. package/dist/logger/logger.js.map +1 -0
  137. package/dist/semaphore-0ZwjVpyF.js +2 -0
  138. package/dist/semaphore-0ZwjVpyF.js.map +1 -0
  139. package/dist/semaphore-BHprIjFI.d.cts +37 -0
  140. package/dist/semaphore-BHprIjFI.d.cts.map +1 -0
  141. package/dist/semaphore-DThupBkc.d.ts +37 -0
  142. package/dist/semaphore-DThupBkc.d.ts.map +1 -0
  143. package/dist/semaphore-DVrONiAV.cjs +1 -0
  144. package/dist/stream-limiter-CoWKv39w.js +2 -0
  145. package/dist/stream-limiter-CoWKv39w.js.map +1 -0
  146. package/dist/stream-limiter-JgOwmkMa.cjs +1 -0
  147. package/dist/streams/multi-stream.cjs +1 -0
  148. package/dist/streams/multi-stream.d.cts +91 -0
  149. package/dist/streams/multi-stream.d.cts.map +1 -0
  150. package/dist/streams/multi-stream.d.ts +86 -0
  151. package/dist/streams/multi-stream.d.ts.map +1 -0
  152. package/dist/streams/multi-stream.js +149 -0
  153. package/dist/streams/multi-stream.js.map +1 -0
  154. package/dist/streams/stream-limiter.cjs +1 -0
  155. package/dist/streams/stream-limiter.d.cts +36 -0
  156. package/dist/streams/stream-limiter.d.cts.map +1 -0
  157. package/dist/streams/stream-limiter.d.ts +27 -0
  158. package/dist/streams/stream-limiter.d.ts.map +1 -0
  159. package/dist/streams/stream-limiter.js +49 -0
  160. package/dist/streams/stream-splitter.cjs +1 -0
  161. package/dist/streams/stream-splitter.d.cts +68 -0
  162. package/dist/streams/stream-splitter.d.cts.map +1 -0
  163. package/dist/streams/stream-splitter.d.ts +51 -0
  164. package/dist/streams/stream-splitter.d.ts.map +1 -0
  165. package/dist/streams/stream-splitter.js +175 -0
  166. package/dist/streams/stream-splitter.js.map +1 -0
  167. package/dist/types/data-store-registry.d.ts +13 -0
  168. package/dist/types/data-store-registry.d.ts.map +1 -0
  169. package/dist/types/data-store-registry.js +4 -0
  170. package/dist/types/data-store.d.ts +316 -0
  171. package/dist/types/data-store.d.ts.map +1 -0
  172. package/dist/types/data-store.js +157 -0
  173. package/dist/types/event-broadcaster.d.ts +28 -0
  174. package/dist/types/event-broadcaster.d.ts.map +1 -0
  175. package/dist/types/event-broadcaster.js +6 -0
  176. package/dist/types/event-emitter.d.ts +378 -0
  177. package/dist/types/event-emitter.d.ts.map +1 -0
  178. package/dist/types/event-emitter.js +223 -0
  179. package/dist/types/index.cjs +1 -0
  180. package/dist/types/index.d.cts +6 -0
  181. package/dist/types/index.d.ts +10 -0
  182. package/dist/types/index.d.ts.map +1 -0
  183. package/dist/types/index.js +9 -0
  184. package/dist/types/input-file.d.ts +104 -0
  185. package/dist/types/input-file.d.ts.map +1 -0
  186. package/dist/types/input-file.js +27 -0
  187. package/dist/types/kv-store.d.ts +281 -0
  188. package/dist/types/kv-store.d.ts.map +1 -0
  189. package/dist/types/kv-store.js +234 -0
  190. package/dist/types/middleware.d.ts +17 -0
  191. package/dist/types/middleware.d.ts.map +1 -0
  192. package/dist/types/middleware.js +21 -0
  193. package/dist/types/upload-event.d.ts +105 -0
  194. package/dist/types/upload-event.d.ts.map +1 -0
  195. package/dist/types/upload-event.js +71 -0
  196. package/dist/types/upload-file.d.ts +136 -0
  197. package/dist/types/upload-file.d.ts.map +1 -0
  198. package/dist/types/upload-file.js +34 -0
  199. package/dist/types/websocket.d.ts +144 -0
  200. package/dist/types/websocket.d.ts.map +1 -0
  201. package/dist/types/websocket.js +40 -0
  202. package/dist/types-BT-cvi7T.cjs +1 -0
  203. package/dist/types-DhU2j-XF.js +2 -0
  204. package/dist/types-DhU2j-XF.js.map +1 -0
  205. package/dist/upload/convert-to-stream.d.ts +38 -0
  206. package/dist/upload/convert-to-stream.d.ts.map +1 -0
  207. package/dist/upload/convert-to-stream.js +43 -0
  208. package/dist/upload/convert-upload-to-flow-file.d.ts +14 -0
  209. package/dist/upload/convert-upload-to-flow-file.d.ts.map +1 -0
  210. package/dist/upload/convert-upload-to-flow-file.js +21 -0
  211. package/dist/upload/create-upload.d.ts +68 -0
  212. package/dist/upload/create-upload.d.ts.map +1 -0
  213. package/dist/upload/create-upload.js +157 -0
  214. package/dist/upload/index.cjs +1 -0
  215. package/dist/upload/index.d.cts +6 -0
  216. package/dist/upload/index.d.ts +4 -0
  217. package/dist/upload/index.d.ts.map +1 -0
  218. package/dist/upload/index.js +3 -0
  219. package/dist/upload/mime.d.ts +24 -0
  220. package/dist/upload/mime.d.ts.map +1 -0
  221. package/dist/upload/mime.js +351 -0
  222. package/dist/upload/upload-chunk.d.ts +58 -0
  223. package/dist/upload/upload-chunk.d.ts.map +1 -0
  224. package/dist/upload/upload-chunk.js +277 -0
  225. package/dist/upload/upload-server.d.ts +221 -0
  226. package/dist/upload/upload-server.d.ts.map +1 -0
  227. package/dist/upload/upload-server.js +181 -0
  228. package/dist/upload/upload-strategy-negotiator.d.ts +148 -0
  229. package/dist/upload/upload-strategy-negotiator.d.ts.map +1 -0
  230. package/dist/upload/upload-strategy-negotiator.js +217 -0
  231. package/dist/upload/upload-url.d.ts +68 -0
  232. package/dist/upload/upload-url.d.ts.map +1 -0
  233. package/dist/upload/upload-url.js +142 -0
  234. package/dist/upload/write-to-store.d.ts +77 -0
  235. package/dist/upload/write-to-store.d.ts.map +1 -0
  236. package/dist/upload/write-to-store.js +147 -0
  237. package/dist/upload-DLuICjpP.cjs +1 -0
  238. package/dist/upload-DaXO34dE.js +2 -0
  239. package/dist/upload-DaXO34dE.js.map +1 -0
  240. package/dist/uploadista-error-BB-Wdiz9.cjs +22 -0
  241. package/dist/uploadista-error-BVsVxqvz.js +23 -0
  242. package/dist/uploadista-error-BVsVxqvz.js.map +1 -0
  243. package/dist/uploadista-error-CwxYs4EB.d.ts +52 -0
  244. package/dist/uploadista-error-CwxYs4EB.d.ts.map +1 -0
  245. package/dist/uploadista-error-kKlhLRhY.d.cts +52 -0
  246. package/dist/uploadista-error-kKlhLRhY.d.cts.map +1 -0
  247. package/dist/utils/checksum.d.ts +22 -0
  248. package/dist/utils/checksum.d.ts.map +1 -0
  249. package/dist/utils/checksum.js +49 -0
  250. package/dist/utils/debounce.cjs +1 -0
  251. package/dist/utils/debounce.d.cts +38 -0
  252. package/dist/utils/debounce.d.cts.map +1 -0
  253. package/dist/utils/debounce.d.ts +36 -0
  254. package/dist/utils/debounce.d.ts.map +1 -0
  255. package/dist/utils/debounce.js +73 -0
  256. package/dist/utils/generate-id.cjs +1 -0
  257. package/dist/utils/generate-id.d.cts +2 -0
  258. package/dist/utils/generate-id.d.ts +32 -0
  259. package/dist/utils/generate-id.d.ts.map +1 -0
  260. package/dist/utils/generate-id.js +23 -0
  261. package/dist/utils/md5.cjs +1 -0
  262. package/dist/utils/md5.d.cts +73 -0
  263. package/dist/utils/md5.d.cts.map +1 -0
  264. package/dist/utils/md5.d.ts +71 -0
  265. package/dist/utils/md5.d.ts.map +1 -0
  266. package/dist/utils/md5.js +417 -0
  267. package/dist/utils/md5.js.map +1 -0
  268. package/dist/utils/once.cjs +1 -0
  269. package/dist/utils/once.d.cts +25 -0
  270. package/dist/utils/once.d.cts.map +1 -0
  271. package/dist/utils/once.d.ts +21 -0
  272. package/dist/utils/once.d.ts.map +1 -0
  273. package/dist/utils/once.js +54 -0
  274. package/dist/utils/once.js.map +1 -0
  275. package/dist/utils/semaphore.cjs +1 -0
  276. package/dist/utils/semaphore.d.cts +3 -0
  277. package/dist/utils/semaphore.d.ts +78 -0
  278. package/dist/utils/semaphore.d.ts.map +1 -0
  279. package/dist/utils/semaphore.js +134 -0
  280. package/dist/utils/throttle.cjs +1 -0
  281. package/dist/utils/throttle.d.cts +24 -0
  282. package/dist/utils/throttle.d.cts.map +1 -0
  283. package/dist/utils/throttle.d.ts +18 -0
  284. package/dist/utils/throttle.d.ts.map +1 -0
  285. package/dist/utils/throttle.js +20 -0
  286. package/dist/utils/throttle.js.map +1 -0
  287. package/docs/PARALLEL_EXECUTION.md +206 -0
  288. package/docs/PARALLEL_EXECUTION_QUICKSTART.md +142 -0
  289. package/docs/PARALLEL_EXECUTION_REFACTOR.md +184 -0
  290. package/package.json +80 -0
  291. package/src/errors/__tests__/uploadista-error.test.ts +251 -0
  292. package/src/errors/index.ts +2 -0
  293. package/src/errors/uploadista-error.ts +394 -0
  294. package/src/flow/README.md +352 -0
  295. package/src/flow/edge.test.ts +146 -0
  296. package/src/flow/edge.ts +60 -0
  297. package/src/flow/event.ts +229 -0
  298. package/src/flow/flow-server.ts +1089 -0
  299. package/src/flow/flow.ts +1050 -0
  300. package/src/flow/index.ts +28 -0
  301. package/src/flow/node.ts +249 -0
  302. package/src/flow/nodes/index.ts +8 -0
  303. package/src/flow/nodes/input-node.ts +296 -0
  304. package/src/flow/nodes/storage-node.ts +128 -0
  305. package/src/flow/nodes/transform-node.ts +154 -0
  306. package/src/flow/parallel-scheduler.ts +259 -0
  307. package/src/flow/plugins/credential-provider.ts +48 -0
  308. package/src/flow/plugins/image-ai-plugin.ts +66 -0
  309. package/src/flow/plugins/image-plugin.ts +60 -0
  310. package/src/flow/plugins/types/describe-image-node.ts +16 -0
  311. package/src/flow/plugins/types/index.ts +9 -0
  312. package/src/flow/plugins/types/optimize-node.ts +18 -0
  313. package/src/flow/plugins/types/remove-background-node.ts +18 -0
  314. package/src/flow/plugins/types/resize-node.ts +26 -0
  315. package/src/flow/plugins/zip-plugin.ts +69 -0
  316. package/src/flow/typed-flow.ts +279 -0
  317. package/src/flow/types/flow-file.ts +51 -0
  318. package/src/flow/types/flow-job.ts +138 -0
  319. package/src/flow/types/flow-types.ts +353 -0
  320. package/src/flow/types/index.ts +6 -0
  321. package/src/flow/types/run-args.ts +40 -0
  322. package/src/flow/types/type-validator.ts +204 -0
  323. package/src/flow/utils/resolve-upload-metadata.ts +48 -0
  324. package/src/index.ts +5 -0
  325. package/src/logger/logger.ts +14 -0
  326. package/src/streams/stream-limiter.test.ts +150 -0
  327. package/src/streams/stream-limiter.ts +75 -0
  328. package/src/types/data-store.ts +427 -0
  329. package/src/types/event-broadcaster.ts +39 -0
  330. package/src/types/event-emitter.ts +349 -0
  331. package/src/types/index.ts +9 -0
  332. package/src/types/input-file.ts +107 -0
  333. package/src/types/kv-store.ts +375 -0
  334. package/src/types/middleware.ts +54 -0
  335. package/src/types/upload-event.ts +75 -0
  336. package/src/types/upload-file.ts +139 -0
  337. package/src/types/websocket.ts +65 -0
  338. package/src/upload/convert-to-stream.ts +48 -0
  339. package/src/upload/create-upload.ts +214 -0
  340. package/src/upload/index.ts +3 -0
  341. package/src/upload/mime.ts +436 -0
  342. package/src/upload/upload-chunk.ts +364 -0
  343. package/src/upload/upload-server.ts +390 -0
  344. package/src/upload/upload-strategy-negotiator.ts +316 -0
  345. package/src/upload/upload-url.ts +173 -0
  346. package/src/upload/write-to-store.ts +211 -0
  347. package/src/utils/checksum.ts +61 -0
  348. package/src/utils/debounce.test.ts +126 -0
  349. package/src/utils/debounce.ts +89 -0
  350. package/src/utils/generate-id.ts +35 -0
  351. package/src/utils/md5.ts +475 -0
  352. package/src/utils/once.test.ts +83 -0
  353. package/src/utils/once.ts +63 -0
  354. package/src/utils/throttle.test.ts +101 -0
  355. package/src/utils/throttle.ts +29 -0
  356. package/tsconfig.json +20 -0
  357. package/tsconfig.tsbuildinfo +1 -0
  358. package/tsdown.config.ts +25 -0
  359. package/vitest.config.ts +15 -0
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));Object.defineProperty(exports,`__toESM`,{enumerable:!0,get:function(){return s}});
@@ -0,0 +1,2 @@
1
+ const e={leading:!1,trailing:!0};function t(t,n,r={}){let i={...e,...r},a;return function(...e){i.leading&&!a?(console.log(`leading`),t.apply(this,e),a=setTimeout(()=>{a=void 0},n)):(clearTimeout(a),a=setTimeout(()=>{i.trailing?(t.apply(this,e),i.leading&&setTimeout(()=>{a=void 0},n)):a=void 0},n))}}export{t as debounce};
2
+ //# sourceMappingURL=debounce-C2SeqcxD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce-C2SeqcxD.js","names":["defaultDebounceOptions: DebounceOptions","timer: ReturnType<typeof setTimeout> | undefined"],"sources":["../src/utils/debounce.ts"],"sourcesContent":["type DebounceOptions = {\n // Whether the first call to the debounced function is run immediately.\n leading?: boolean;\n\n // Whether the last call to the debounced function is run after delay\n // milliseconds have elapsed since the last call.\n trailing?: boolean;\n};\n\nconst defaultDebounceOptions: DebounceOptions = {\n leading: false,\n trailing: true,\n};\n\n/**\n * Returns `fn` wrapped by a function that delays invoking `fn` for `delay`\n * milliseconds since the last call. Set `options.leading` to invoke `fn` on\n * the leading edge of the delay, and/or set `options.trailing` to invoke `fn`\n * on the trailing edge of the delay (true by default).\n *\n * Example for `debounce(fn, 30, {leading: true, trailing: true})`,\n * where `fn` is called twice, with the second call made 20 ms after the first:\n *\n * Time: 0 20 50 (ms)\n * Timeline: |----------------------------------------------------------------|\n * ^ ^ ^\n * | | |\n * | First call. | Second call 20ms after the | End of delay.\n * | (instant leading | first. | (trailing edge\n * | edge call) | | call)\n * |-----------------------------|\n * | 30 ms delay for debounce. |\n *\n *\n * Note that if both `options.leading` and `options.trailing` are true, `fn`\n * will only be invoked on the trailing edge if the debounced function is called\n * more than once during the delay.\n *\n * @param fn - Function to debounce.\n * @param delay - Milliseconds to delay calling `fn` since the last call.\n * @param debounceOptions - See `DebounceOptions` and `defaultDebounceOptions`.\n * @returns A debounced `fn`.\n */\nexport function debounce<T, A extends unknown[]>(\n fn: (this: T, ...args: A) => void,\n delay: number,\n debounceOptions: DebounceOptions = {},\n): (this: T, ...args: A) => void {\n const options = { ...defaultDebounceOptions, ...debounceOptions };\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n return function (this: T, ...args: A): void {\n if (options.leading && !timer) {\n // Leading edge.\n // Call fn on the leading edge, when debouncing hasn't started yet.\n console.log(\"leading\");\n fn.apply(this, args);\n\n // Debounce the next call.\n timer = setTimeout(() => {\n timer = undefined;\n }, delay);\n } else {\n // Trailing edge.\n // Postpone calling fn until the delay has elapsed since the last call.\n // Each call clears any previously delayed call and resets the delay, so\n // the postponed call will always be the last one.\n clearTimeout(timer);\n timer = setTimeout(() => {\n if (options.trailing) {\n // Call fn on the trailing edge.\n fn.apply(this, args);\n\n if (options.leading) {\n // Debounce next leading call since a trailing call was just made.\n setTimeout(() => {\n timer = undefined;\n }, delay);\n }\n } else {\n // No trailing call. Since the delay has elapsed since the last call,\n // immediately reset the debouncing delay.\n timer = undefined;\n }\n }, delay);\n }\n };\n}\n"],"mappings":"AASA,MAAMA,EAA0C,CAC9C,QAAS,GACT,SAAU,GACX,CA+BD,SAAgB,EACd,EACA,EACA,EAAmC,EAAE,CACN,CAC/B,IAAM,EAAU,CAAE,GAAG,EAAwB,GAAG,EAAiB,CAE7DC,EAEJ,OAAO,SAAmB,GAAG,EAAe,CACtC,EAAQ,SAAW,CAAC,GAGtB,QAAQ,IAAI,UAAU,CACtB,EAAG,MAAM,KAAM,EAAK,CAGpB,EAAQ,eAAiB,CACvB,EAAQ,IAAA,IACP,EAAM,GAMT,aAAa,EAAM,CACnB,EAAQ,eAAiB,CACnB,EAAQ,UAEV,EAAG,MAAM,KAAM,EAAK,CAEhB,EAAQ,SAEV,eAAiB,CACf,EAAQ,IAAA,IACP,EAAM,EAKX,EAAQ,IAAA,IAET,EAAM"}
@@ -0,0 +1 @@
1
+ const e={leading:!1,trailing:!0};function t(t,n,r={}){let i={...e,...r},a;return function(...e){i.leading&&!a?(console.log(`leading`),t.apply(this,e),a=setTimeout(()=>{a=void 0},n)):(clearTimeout(a),a=setTimeout(()=>{i.trailing?(t.apply(this,e),i.leading&&setTimeout(()=>{a=void 0},n)):a=void 0},n))}}Object.defineProperty(exports,`debounce`,{enumerable:!0,get:function(){return t}});
@@ -0,0 +1 @@
1
+ const e=require(`../uploadista-error-BB-Wdiz9.cjs`);require(`../errors-CRm1FHHT.cjs`),exports.ERRORS=e.ERROR_CATALOG,exports.ERROR_CATALOG=e.ERROR_CATALOG,exports.UploadistaError=e.UploadistaError,exports.httpFailureEffect=e.httpFailureEffect,exports.isUploadistaError=e.isUploadistaError;
@@ -0,0 +1,3 @@
1
+ import { ERROR_CATALOG, UploadistaError, UploadistaErrorCode, httpFailureEffect, isUploadistaError } from "../uploadista-error-kKlhLRhY.cjs";
2
+ import "../index-BtBZHVmz.cjs";
3
+ export { ERROR_CATALOG as ERRORS, ERROR_CATALOG, UploadistaError, UploadistaErrorCode, httpFailureEffect, isUploadistaError };
@@ -0,0 +1,3 @@
1
+ export * from "./uploadista-error.js";
2
+ export { ERROR_CATALOG as ERRORS } from "./uploadista-error.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./uploadista-error.js";
2
+ export { ERROR_CATALOG as ERRORS } from "./uploadista-error.js";
@@ -0,0 +1,209 @@
1
+ import { Effect } from "effect";
2
+ /**
3
+ * Union type of all possible error codes in the Uploadista system.
4
+ *
5
+ * Each error code corresponds to a specific error condition with predefined
6
+ * HTTP status codes and messages in the ERROR_CATALOG.
7
+ */
8
+ export 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" | "FILE_READ_ERROR" | "FLOW_JOB_NOT_FOUND" | "FLOW_JOB_ERROR" | "DATASTORE_NOT_FOUND" | "FILE_NOT_FOUND" | "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";
9
+ /**
10
+ * Catalog of all predefined errors in the Uploadista system.
11
+ *
12
+ * Maps error codes to their HTTP status codes and default error messages.
13
+ * This centralized catalog ensures consistent error handling across all
14
+ * Uploadista packages and adapters.
15
+ *
16
+ * Each error entry contains:
17
+ * - `status`: HTTP status code (400-500 range)
18
+ * - `body`: Human-readable error message
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Access a specific error definition
23
+ * const fileNotFound = ERROR_CATALOG.FILE_NOT_FOUND;
24
+ * console.log(fileNotFound.status); // 404
25
+ * console.log(fileNotFound.body); // "The file for this url was not found\n"
26
+ *
27
+ * // Use with UploadistaError
28
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
29
+ * ```
30
+ */
31
+ export declare const ERROR_CATALOG: Readonly<Record<UploadistaErrorCode, {
32
+ status: number;
33
+ body: string;
34
+ }>>;
35
+ declare const UploadistaError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
36
+ readonly _tag: "UploadistaError";
37
+ } & Readonly<A>;
38
+ /**
39
+ * Standard error class for all Uploadista operations.
40
+ *
41
+ * UploadistaError provides a consistent error handling approach across the entire
42
+ * Uploadista ecosystem. Each error has:
43
+ * - A typed error code from the ERROR_CATALOG
44
+ * - An HTTP-compatible status code
45
+ * - A human-readable error message (body)
46
+ * - Optional additional details and cause information
47
+ *
48
+ * This class integrates with Effect-TS for functional error handling and can be
49
+ * easily converted to an Effect that fails.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Create from error code
54
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
55
+ *
56
+ * // Create with custom details
57
+ * const customError = UploadistaError.fromCode("FLOW_NODE_ERROR", {
58
+ * body: "Failed to process image",
59
+ * cause: originalError,
60
+ * details: { nodeId: "resize-1", fileId: "abc123" }
61
+ * });
62
+ *
63
+ * // Use with Effect
64
+ * const effect = customError.toEffect<void>();
65
+ *
66
+ * // In an Effect pipeline
67
+ * return Effect.gen(function* () {
68
+ * const file = yield* getFile(id);
69
+ * if (!file) {
70
+ * return yield* UploadistaError.fromCode("FILE_NOT_FOUND").toEffect();
71
+ * }
72
+ * return file;
73
+ * });
74
+ * ```
75
+ */
76
+ export declare class UploadistaError extends UploadistaError_base {
77
+ readonly code: string;
78
+ readonly status: number;
79
+ readonly status_code: number;
80
+ readonly body: string;
81
+ readonly details?: unknown;
82
+ constructor({ code, status, body, cause, details, }: {
83
+ code: UploadistaErrorCode | string;
84
+ status: number;
85
+ body: string;
86
+ cause?: unknown;
87
+ details?: unknown;
88
+ });
89
+ /**
90
+ * Creates an UploadistaError from a predefined error code.
91
+ *
92
+ * This is the primary way to create errors in the Uploadista system. Each error code
93
+ * has a default status and message defined in ERROR_CATALOG, but these can be overridden
94
+ * for specific use cases.
95
+ *
96
+ * @param code - One of the predefined error codes from UploadistaErrorCode
97
+ * @param overrides - Optional overrides for the default error properties
98
+ * @param overrides.status - Custom HTTP status code (overrides the default)
99
+ * @param overrides.body - Custom error message (overrides the default)
100
+ * @param overrides.details - Additional structured data about the error
101
+ * @param overrides.cause - The underlying error that caused this error (for error chaining)
102
+ *
103
+ * @returns A new UploadistaError instance
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * // Use default error
108
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
109
+ *
110
+ * // Override message
111
+ * const customError = UploadistaError.fromCode("FILE_NOT_FOUND", {
112
+ * body: `File with ID ${fileId} was not found in storage`
113
+ * });
114
+ *
115
+ * // Include cause and details
116
+ * const detailedError = UploadistaError.fromCode("DATASTORE_NOT_FOUND", {
117
+ * cause: storageException,
118
+ * details: { storageId: "s3-prod", region: "us-east-1" }
119
+ * });
120
+ * ```
121
+ */
122
+ static fromCode(code: UploadistaErrorCode, overrides?: Partial<Pick<UploadistaError, "status" | "body">> & {
123
+ details?: unknown;
124
+ cause?: unknown;
125
+ }): UploadistaError;
126
+ /**
127
+ * Converts this error to an Effect that immediately fails.
128
+ *
129
+ * This method integrates UploadistaError with Effect-TS's error handling system,
130
+ * allowing errors to be used in Effect pipelines with proper type checking.
131
+ *
132
+ * @template T - The success type of the Effect (defaults to never since it always fails)
133
+ * @returns An Effect that fails with this UploadistaError
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
138
+ *
139
+ * // Use in an Effect pipeline
140
+ * return Effect.gen(function* () {
141
+ * const file = yield* kvStore.get(fileId);
142
+ * if (!file) {
143
+ * return yield* error.toEffect();
144
+ * }
145
+ * return file;
146
+ * });
147
+ * ```
148
+ */
149
+ toEffect<T = never>(): Effect.Effect<T, UploadistaError>;
150
+ }
151
+ /**
152
+ * Type guard to check if an unknown value is an UploadistaError.
153
+ *
154
+ * Useful for error handling when catching errors that might be from
155
+ * different sources or libraries.
156
+ *
157
+ * @param error - The value to check
158
+ * @returns True if the value is an UploadistaError instance
159
+ *
160
+ * @example
161
+ * ```typescript
162
+ * try {
163
+ * await someOperation();
164
+ * } catch (error) {
165
+ * if (isUploadistaError(error)) {
166
+ * console.log(`Uploadista error: ${error.code} (${error.status})`);
167
+ * console.log(error.body);
168
+ * } else {
169
+ * console.error("Unknown error:", error);
170
+ * }
171
+ * }
172
+ * ```
173
+ */
174
+ export declare function isUploadistaError(error: unknown): error is UploadistaError;
175
+ /**
176
+ * Creates an Effect that immediately fails with an UploadistaError.
177
+ *
178
+ * This is a convenience function that combines error creation with Effect conversion.
179
+ * It's equivalent to calling `UploadistaError.fromCode(code, overrides).toEffect()`.
180
+ *
181
+ * @param code - One of the predefined error codes from UploadistaErrorCode
182
+ * @param overrides - Optional overrides for the default error properties
183
+ * @param overrides.status - Custom HTTP status code
184
+ * @param overrides.body - Custom error message
185
+ * @param overrides.details - Additional structured data about the error
186
+ * @param overrides.cause - The underlying error that caused this error
187
+ *
188
+ * @returns An Effect that immediately fails with the created UploadistaError
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * // In an Effect pipeline
193
+ * return Effect.gen(function* () {
194
+ * const file = yield* kvStore.get(fileId);
195
+ * if (!file) {
196
+ * return yield* httpFailure("FILE_NOT_FOUND", {
197
+ * details: { fileId }
198
+ * });
199
+ * }
200
+ * return file;
201
+ * });
202
+ * ```
203
+ */
204
+ export declare function httpFailure(code: UploadistaErrorCode, overrides?: Partial<Pick<UploadistaError, "status" | "body">> & {
205
+ details?: unknown;
206
+ cause?: unknown;
207
+ }): Effect.Effect<never, UploadistaError>;
208
+ export {};
209
+ //# sourceMappingURL=uploadista-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploadista-error.d.ts","sourceRoot":"","sources":["../../src/errors/uploadista-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAC3B,gBAAgB,GAChB,SAAS,GACT,qBAAqB,GACrB,kBAAkB,GAClB,sBAAsB,GACtB,sBAAsB,GACtB,kBAAkB,GAClB,qBAAqB,GACrB,iBAAiB,GACjB,qBAAqB,GACrB,gBAAgB,GAChB,iBAAiB,GACjB,oBAAoB,GACpB,gBAAgB,GAChB,qBAAqB,GACrB,gBAAgB,GAChB,gBAAgB,GAChB,uBAAuB,GACvB,mBAAmB,GACnB,uBAAuB,GACvB,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,wBAAwB,GACxB,eAAe,GACf,kBAAkB,GAClB,qBAAqB,GACrB,8BAA8B,GAC9B,6BAA6B,GAC7B,mBAAmB,GACnB,mBAAmB,GACnB,gCAAgC,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAClC,MAAM,CAAC,mBAAmB,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAmHrD,CAAC;;;;AAEX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,qBAAa,eAAgB,SAAQ,oBAAmC;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;gBAEf,EACV,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,OAAO,GACR,EAAE;QACD,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAAC;QACnC,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB;IAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,MAAM,CAAC,QAAQ,CACb,IAAI,EAAE,mBAAmB,EACzB,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC,GAAG;QAC9D,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GACA,eAAe;IAWlB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,CAAC,GAAG,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,eAAe,CAAC;CAGzD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,mBAAmB,EACzB,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC,GAAG;IAC9D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GACA,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,eAAe,CAAC,CAEvC"}
@@ -0,0 +1,322 @@
1
+ import { Data, Effect } from "effect";
2
+ /**
3
+ * Catalog of all predefined errors in the Uploadista system.
4
+ *
5
+ * Maps error codes to their HTTP status codes and default error messages.
6
+ * This centralized catalog ensures consistent error handling across all
7
+ * Uploadista packages and adapters.
8
+ *
9
+ * Each error entry contains:
10
+ * - `status`: HTTP status code (400-500 range)
11
+ * - `body`: Human-readable error message
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Access a specific error definition
16
+ * const fileNotFound = ERROR_CATALOG.FILE_NOT_FOUND;
17
+ * console.log(fileNotFound.status); // 404
18
+ * console.log(fileNotFound.body); // "The file for this url was not found\n"
19
+ *
20
+ * // Use with UploadistaError
21
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
22
+ * ```
23
+ */
24
+ export const ERROR_CATALOG = {
25
+ MISSING_OFFSET: { status: 403, body: "Upload-Offset header required\n" },
26
+ ABORTED: { status: 400, body: "Request aborted due to lock acquired" },
27
+ INVALID_TERMINATION: {
28
+ status: 400,
29
+ body: "Cannot terminate an already completed upload",
30
+ },
31
+ ERR_LOCK_TIMEOUT: {
32
+ status: 500,
33
+ body: "failed to acquire lock before timeout",
34
+ },
35
+ INVALID_CONTENT_TYPE: {
36
+ status: 403,
37
+ body: "Content-Type header required\n",
38
+ },
39
+ DATASTORE_NOT_FOUND: {
40
+ status: 500,
41
+ body: "The datastore was not found\n",
42
+ },
43
+ UPLOAD_ID_NOT_FOUND: {
44
+ status: 500,
45
+ body: "The upload id was not found\n",
46
+ },
47
+ FILE_NOT_FOUND: {
48
+ status: 404,
49
+ body: "The file for this url was not found\n",
50
+ },
51
+ FLOW_NOT_AUTHORIZED: {
52
+ status: 401,
53
+ body: "The flow is not authorized\n",
54
+ },
55
+ FLOW_NOT_FOUND: {
56
+ status: 404,
57
+ body: "The flow was not found\n",
58
+ },
59
+ FLOW_STRUCTURE_ERROR: {
60
+ status: 500,
61
+ body: "The flow structure is invalid\n",
62
+ },
63
+ FLOW_CYCLE_ERROR: {
64
+ status: 500,
65
+ body: "The flow contains a cycle\n",
66
+ },
67
+ FLOW_NODE_NOT_FOUND: {
68
+ status: 500,
69
+ body: "The flow node was not found\n",
70
+ },
71
+ FLOW_NODE_ERROR: {
72
+ status: 500,
73
+ body: "The flow node failed\n",
74
+ },
75
+ FLOW_JOB_NOT_FOUND: {
76
+ status: 404,
77
+ body: "The flow job was not found\n",
78
+ },
79
+ FLOW_JOB_ERROR: {
80
+ status: 500,
81
+ body: "The flow job failed\n",
82
+ },
83
+ FLOW_INPUT_VALIDATION_ERROR: {
84
+ status: 500,
85
+ body: "The flow input validation failed\n",
86
+ },
87
+ FLOW_OUTPUT_VALIDATION_ERROR: {
88
+ status: 500,
89
+ body: "The flow output validation failed\n",
90
+ },
91
+ INVALID_OFFSET: { status: 409, body: "Upload-Offset conflict\n" },
92
+ FILE_NO_LONGER_EXISTS: {
93
+ status: 410,
94
+ body: "The file for this url no longer exists\n",
95
+ },
96
+ FILE_READ_ERROR: {
97
+ status: 500,
98
+ body: "Something went wrong reading the file\n",
99
+ },
100
+ ERR_SIZE_EXCEEDED: { status: 413, body: "upload's size exceeded\n" },
101
+ ERR_MAX_SIZE_EXCEEDED: { status: 413, body: "Maximum size exceeded\n" },
102
+ INVALID_LENGTH: {
103
+ status: 400,
104
+ body: "Upload-Length or Upload-Defer-Length header required\n",
105
+ },
106
+ INVALID_METADATA: {
107
+ status: 400,
108
+ 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",
109
+ },
110
+ VALIDATION_ERROR: {
111
+ status: 400,
112
+ body: "Validation failed\n",
113
+ },
114
+ STORAGE_NOT_AUTHORIZED: {
115
+ status: 401,
116
+ body: "The storage is not authorized\n",
117
+ },
118
+ UNKNOWN_ERROR: {
119
+ status: 500,
120
+ body: "Something went wrong with that request\n",
121
+ },
122
+ FILE_WRITE_ERROR: {
123
+ status: 500,
124
+ body: "Something went wrong receiving the file\n",
125
+ },
126
+ CHECKSUM_MISMATCH: {
127
+ status: 400,
128
+ body: "The file checksum does not match the provided checksum\n",
129
+ },
130
+ MIMETYPE_MISMATCH: {
131
+ status: 400,
132
+ body: "The file MIME type does not match the declared type\n",
133
+ },
134
+ UNSUPPORTED_CHECKSUM_ALGORITHM: {
135
+ status: 400,
136
+ body: "The specified checksum algorithm is not supported\n",
137
+ },
138
+ };
139
+ /**
140
+ * Standard error class for all Uploadista operations.
141
+ *
142
+ * UploadistaError provides a consistent error handling approach across the entire
143
+ * Uploadista ecosystem. Each error has:
144
+ * - A typed error code from the ERROR_CATALOG
145
+ * - An HTTP-compatible status code
146
+ * - A human-readable error message (body)
147
+ * - Optional additional details and cause information
148
+ *
149
+ * This class integrates with Effect-TS for functional error handling and can be
150
+ * easily converted to an Effect that fails.
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * // Create from error code
155
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
156
+ *
157
+ * // Create with custom details
158
+ * const customError = UploadistaError.fromCode("FLOW_NODE_ERROR", {
159
+ * body: "Failed to process image",
160
+ * cause: originalError,
161
+ * details: { nodeId: "resize-1", fileId: "abc123" }
162
+ * });
163
+ *
164
+ * // Use with Effect
165
+ * const effect = customError.toEffect<void>();
166
+ *
167
+ * // In an Effect pipeline
168
+ * return Effect.gen(function* () {
169
+ * const file = yield* getFile(id);
170
+ * if (!file) {
171
+ * return yield* UploadistaError.fromCode("FILE_NOT_FOUND").toEffect();
172
+ * }
173
+ * return file;
174
+ * });
175
+ * ```
176
+ */
177
+ export class UploadistaError extends Data.TaggedError("UploadistaError") {
178
+ code;
179
+ status;
180
+ // Keep legacy property names for backward compatibility
181
+ status_code;
182
+ body;
183
+ details;
184
+ constructor({ code, status, body, cause, details, }) {
185
+ super();
186
+ this.name = "UploadistaError";
187
+ this.code = code;
188
+ this.status = status;
189
+ this.status_code = status; // legacy alias
190
+ this.body = body;
191
+ this.details = details;
192
+ if (cause)
193
+ this.cause = cause;
194
+ }
195
+ /**
196
+ * Creates an UploadistaError from a predefined error code.
197
+ *
198
+ * This is the primary way to create errors in the Uploadista system. Each error code
199
+ * has a default status and message defined in ERROR_CATALOG, but these can be overridden
200
+ * for specific use cases.
201
+ *
202
+ * @param code - One of the predefined error codes from UploadistaErrorCode
203
+ * @param overrides - Optional overrides for the default error properties
204
+ * @param overrides.status - Custom HTTP status code (overrides the default)
205
+ * @param overrides.body - Custom error message (overrides the default)
206
+ * @param overrides.details - Additional structured data about the error
207
+ * @param overrides.cause - The underlying error that caused this error (for error chaining)
208
+ *
209
+ * @returns A new UploadistaError instance
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * // Use default error
214
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
215
+ *
216
+ * // Override message
217
+ * const customError = UploadistaError.fromCode("FILE_NOT_FOUND", {
218
+ * body: `File with ID ${fileId} was not found in storage`
219
+ * });
220
+ *
221
+ * // Include cause and details
222
+ * const detailedError = UploadistaError.fromCode("DATASTORE_NOT_FOUND", {
223
+ * cause: storageException,
224
+ * details: { storageId: "s3-prod", region: "us-east-1" }
225
+ * });
226
+ * ```
227
+ */
228
+ static fromCode(code, overrides) {
229
+ const base = ERROR_CATALOG[code];
230
+ return new UploadistaError({
231
+ code,
232
+ status: overrides?.status ?? base.status,
233
+ body: overrides?.body ?? base.body,
234
+ details: overrides?.details,
235
+ cause: overrides?.cause,
236
+ });
237
+ }
238
+ /**
239
+ * Converts this error to an Effect that immediately fails.
240
+ *
241
+ * This method integrates UploadistaError with Effect-TS's error handling system,
242
+ * allowing errors to be used in Effect pipelines with proper type checking.
243
+ *
244
+ * @template T - The success type of the Effect (defaults to never since it always fails)
245
+ * @returns An Effect that fails with this UploadistaError
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
250
+ *
251
+ * // Use in an Effect pipeline
252
+ * return Effect.gen(function* () {
253
+ * const file = yield* kvStore.get(fileId);
254
+ * if (!file) {
255
+ * return yield* error.toEffect();
256
+ * }
257
+ * return file;
258
+ * });
259
+ * ```
260
+ */
261
+ toEffect() {
262
+ return Effect.fail(this);
263
+ }
264
+ }
265
+ /**
266
+ * Type guard to check if an unknown value is an UploadistaError.
267
+ *
268
+ * Useful for error handling when catching errors that might be from
269
+ * different sources or libraries.
270
+ *
271
+ * @param error - The value to check
272
+ * @returns True if the value is an UploadistaError instance
273
+ *
274
+ * @example
275
+ * ```typescript
276
+ * try {
277
+ * await someOperation();
278
+ * } catch (error) {
279
+ * if (isUploadistaError(error)) {
280
+ * console.log(`Uploadista error: ${error.code} (${error.status})`);
281
+ * console.log(error.body);
282
+ * } else {
283
+ * console.error("Unknown error:", error);
284
+ * }
285
+ * }
286
+ * ```
287
+ */
288
+ export function isUploadistaError(error) {
289
+ return error instanceof UploadistaError;
290
+ }
291
+ /**
292
+ * Creates an Effect that immediately fails with an UploadistaError.
293
+ *
294
+ * This is a convenience function that combines error creation with Effect conversion.
295
+ * It's equivalent to calling `UploadistaError.fromCode(code, overrides).toEffect()`.
296
+ *
297
+ * @param code - One of the predefined error codes from UploadistaErrorCode
298
+ * @param overrides - Optional overrides for the default error properties
299
+ * @param overrides.status - Custom HTTP status code
300
+ * @param overrides.body - Custom error message
301
+ * @param overrides.details - Additional structured data about the error
302
+ * @param overrides.cause - The underlying error that caused this error
303
+ *
304
+ * @returns An Effect that immediately fails with the created UploadistaError
305
+ *
306
+ * @example
307
+ * ```typescript
308
+ * // In an Effect pipeline
309
+ * return Effect.gen(function* () {
310
+ * const file = yield* kvStore.get(fileId);
311
+ * if (!file) {
312
+ * return yield* httpFailure("FILE_NOT_FOUND", {
313
+ * details: { fileId }
314
+ * });
315
+ * }
316
+ * return file;
317
+ * });
318
+ * ```
319
+ */
320
+ export function httpFailure(code, overrides) {
321
+ return UploadistaError.fromCode(code, overrides).toEffect();
322
+ }
@@ -0,0 +1 @@
1
+ export{};
File without changes
@@ -0,0 +1,47 @@
1
+ import type { FlowEdge as EnhancedFlowEdge } from "./types/flow-types";
2
+ /**
3
+ * Represents a connection between two nodes in a flow, defining the data flow direction.
4
+ *
5
+ * Edges connect the output of a source node to the input of a target node,
6
+ * enabling data to flow through the processing pipeline in a directed acyclic graph (DAG).
7
+ */
8
+ export type FlowEdge = EnhancedFlowEdge;
9
+ /**
10
+ * Creates a flow edge connecting two nodes in a processing pipeline.
11
+ *
12
+ * Edges define how data flows between nodes. The data output from the source node
13
+ * becomes the input for the target node. For nodes with multiple inputs/outputs,
14
+ * ports can be specified to route data to specific connections.
15
+ *
16
+ * @param config - Edge configuration
17
+ * @param config.source - ID of the source node (data originates here)
18
+ * @param config.target - ID of the target node (data flows to here)
19
+ * @param config.sourcePort - Optional port name on the source node for multi-output nodes
20
+ * @param config.targetPort - Optional port name on the target node for multi-input nodes
21
+ *
22
+ * @returns A FlowEdge object representing the connection
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // Simple edge connecting two nodes
27
+ * const edge = createFlowEdge({
28
+ * source: "input-1",
29
+ * target: "process-1"
30
+ * });
31
+ *
32
+ * // Edge with ports for multi-input/output nodes
33
+ * const portEdge = createFlowEdge({
34
+ * source: "multiplex-1",
35
+ * target: "merge-1",
36
+ * sourcePort: "out-a",
37
+ * targetPort: "in-1"
38
+ * });
39
+ * ```
40
+ */
41
+ export declare function createFlowEdge({ source, target, sourcePort, targetPort, }: {
42
+ source: string;
43
+ target: string;
44
+ sourcePort?: string;
45
+ targetPort?: string;
46
+ }): FlowEdge;
47
+ //# sourceMappingURL=edge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/flow/edge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,MAAM,EACN,UAAU,EACV,UAAU,GACX,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,QAAQ,CAOX"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Creates a flow edge connecting two nodes in a processing pipeline.
3
+ *
4
+ * Edges define how data flows between nodes. The data output from the source node
5
+ * becomes the input for the target node. For nodes with multiple inputs/outputs,
6
+ * ports can be specified to route data to specific connections.
7
+ *
8
+ * @param config - Edge configuration
9
+ * @param config.source - ID of the source node (data originates here)
10
+ * @param config.target - ID of the target node (data flows to here)
11
+ * @param config.sourcePort - Optional port name on the source node for multi-output nodes
12
+ * @param config.targetPort - Optional port name on the target node for multi-input nodes
13
+ *
14
+ * @returns A FlowEdge object representing the connection
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // Simple edge connecting two nodes
19
+ * const edge = createFlowEdge({
20
+ * source: "input-1",
21
+ * target: "process-1"
22
+ * });
23
+ *
24
+ * // Edge with ports for multi-input/output nodes
25
+ * const portEdge = createFlowEdge({
26
+ * source: "multiplex-1",
27
+ * target: "merge-1",
28
+ * sourcePort: "out-a",
29
+ * targetPort: "in-1"
30
+ * });
31
+ * ```
32
+ */
33
+ export function createFlowEdge({ source, target, sourcePort, targetPort, }) {
34
+ return {
35
+ source,
36
+ target,
37
+ sourcePort,
38
+ targetPort,
39
+ };
40
+ }