@uploadista/core 0.0.2 → 0.0.4

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 (331) hide show
  1. package/README.md +6 -20
  2. package/dist/checksum-C5qE-5eg.js +2 -0
  3. package/dist/checksum-C5qE-5eg.js.map +1 -0
  4. package/dist/checksum-wSBuXX84.cjs +1 -0
  5. package/dist/errors/index.cjs +1 -1
  6. package/dist/errors/index.d.cts +2 -2
  7. package/dist/errors/index.d.ts +3 -3
  8. package/dist/errors/index.js +1 -2
  9. package/dist/flow/index.cjs +1 -1
  10. package/dist/flow/index.d.cts +5 -5
  11. package/dist/flow/index.d.ts +6 -24
  12. package/dist/flow/index.js +1 -24
  13. package/dist/flow-B0mMJM5Y.js +2 -0
  14. package/dist/flow-B0mMJM5Y.js.map +1 -0
  15. package/dist/flow-s5bgJsdb.cjs +1 -0
  16. package/dist/index-B46hb7yB.d.cts +36 -0
  17. package/dist/index-B46hb7yB.d.cts.map +1 -0
  18. package/dist/index-BnGZO47X.d.ts +3952 -0
  19. package/dist/index-BnGZO47X.d.ts.map +1 -0
  20. package/dist/{streams/stream-limiter.d.cts → index-C1mxuUxK.d.ts} +3 -3
  21. package/dist/index-C1mxuUxK.d.ts.map +1 -0
  22. package/dist/index-DM69UMgG.d.cts +4132 -0
  23. package/dist/index-DM69UMgG.d.cts.map +1 -0
  24. package/dist/index-DMJv8Tvo.d.ts +168 -0
  25. package/dist/index-DMJv8Tvo.d.ts.map +1 -0
  26. package/dist/index-GLPiXqj4.d.cts +168 -0
  27. package/dist/index-GLPiXqj4.d.cts.map +1 -0
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.d.cts +5 -5
  30. package/dist/index.d.ts +6 -5
  31. package/dist/index.js +1 -5
  32. package/dist/stream-limiter-CTuiXkcq.js +2 -0
  33. package/dist/{stream-limiter-CoWKv39w.js.map → stream-limiter-CTuiXkcq.js.map} +1 -1
  34. package/dist/stream-limiter-DYGG4t9f.cjs +1 -0
  35. package/dist/streams/index.cjs +1 -0
  36. package/dist/streams/index.d.cts +3 -0
  37. package/dist/streams/index.d.ts +3 -0
  38. package/dist/streams/index.js +1 -0
  39. package/dist/streams-BiD_pOPH.cjs +0 -0
  40. package/dist/streams-Bs3GDNKJ.js +1 -0
  41. package/dist/types/index.cjs +1 -1
  42. package/dist/types/index.d.cts +5 -5
  43. package/dist/types/index.d.ts +6 -10
  44. package/dist/types/index.js +1 -9
  45. package/dist/types-Dj9g8ocl.cjs +1 -0
  46. package/dist/types-m26wrG-Z.js +2 -0
  47. package/dist/types-m26wrG-Z.js.map +1 -0
  48. package/dist/upload/index.cjs +1 -1
  49. package/dist/upload/index.d.cts +5 -5
  50. package/dist/upload/index.d.ts +6 -4
  51. package/dist/upload/index.js +1 -3
  52. package/dist/upload-BzU7ifyH.js +2 -0
  53. package/dist/upload-BzU7ifyH.js.map +1 -0
  54. package/dist/upload-DvLp6TXO.cjs +1 -0
  55. package/dist/uploadista-error-CAtkQiAv.d.cts +221 -0
  56. package/dist/uploadista-error-CAtkQiAv.d.cts.map +1 -0
  57. package/dist/{uploadista-error-BVsVxqvz.js → uploadista-error-CjfcFnVa.js} +9 -2
  58. package/dist/uploadista-error-CjfcFnVa.js.map +1 -0
  59. package/dist/uploadista-error-D9SONF9K.d.ts +221 -0
  60. package/dist/uploadista-error-D9SONF9K.d.ts.map +1 -0
  61. package/dist/{uploadista-error-BB-Wdiz9.cjs → uploadista-error-DdTP-Rjx.cjs} +9 -2
  62. package/dist/utils/index.cjs +1 -0
  63. package/dist/utils/index.d.cts +3 -0
  64. package/dist/utils/index.d.ts +3 -0
  65. package/dist/utils/index.js +1 -0
  66. package/dist/utils-BILytQlb.js +2 -0
  67. package/dist/utils-BILytQlb.js.map +1 -0
  68. package/dist/utils-BLsIUd8c.cjs +1 -0
  69. package/package.json +13 -17
  70. package/src/index.ts +2 -0
  71. package/src/streams/index.ts +1 -0
  72. package/src/utils/index.ts +5 -0
  73. package/tsdown.config.ts +2 -10
  74. package/.turbo/turbo-build.log +0 -5
  75. package/.turbo/turbo-check.log +0 -231
  76. package/.turbo/turbo-format.log +0 -5
  77. package/dist/chunk-CUT6urMc.cjs +0 -1
  78. package/dist/debounce-C2SeqcxD.js +0 -2
  79. package/dist/debounce-C2SeqcxD.js.map +0 -1
  80. package/dist/debounce-LZK7yS7Z.cjs +0 -1
  81. package/dist/errors/index.d.ts.map +0 -1
  82. package/dist/errors/uploadista-error.d.ts +0 -209
  83. package/dist/errors/uploadista-error.d.ts.map +0 -1
  84. package/dist/errors/uploadista-error.js +0 -322
  85. package/dist/flow/edge.d.ts +0 -47
  86. package/dist/flow/edge.d.ts.map +0 -1
  87. package/dist/flow/edge.js +0 -40
  88. package/dist/flow/event.d.ts +0 -206
  89. package/dist/flow/event.d.ts.map +0 -1
  90. package/dist/flow/event.js +0 -53
  91. package/dist/flow/flow-server.d.ts +0 -223
  92. package/dist/flow/flow-server.d.ts.map +0 -1
  93. package/dist/flow/flow-server.js +0 -614
  94. package/dist/flow/flow.d.ts +0 -238
  95. package/dist/flow/flow.d.ts.map +0 -1
  96. package/dist/flow/flow.js +0 -629
  97. package/dist/flow/index.d.ts.map +0 -1
  98. package/dist/flow/node.d.ts +0 -136
  99. package/dist/flow/node.d.ts.map +0 -1
  100. package/dist/flow/node.js +0 -153
  101. package/dist/flow/nodes/index.d.ts +0 -8
  102. package/dist/flow/nodes/index.d.ts.map +0 -1
  103. package/dist/flow/nodes/index.js +0 -7
  104. package/dist/flow/nodes/input-node.d.ts +0 -78
  105. package/dist/flow/nodes/input-node.d.ts.map +0 -1
  106. package/dist/flow/nodes/input-node.js +0 -233
  107. package/dist/flow/nodes/storage-node.d.ts +0 -67
  108. package/dist/flow/nodes/storage-node.d.ts.map +0 -1
  109. package/dist/flow/nodes/storage-node.js +0 -94
  110. package/dist/flow/nodes/streaming-input-node.d.ts +0 -69
  111. package/dist/flow/nodes/streaming-input-node.d.ts.map +0 -1
  112. package/dist/flow/nodes/streaming-input-node.js +0 -156
  113. package/dist/flow/nodes/transform-node.d.ts +0 -85
  114. package/dist/flow/nodes/transform-node.d.ts.map +0 -1
  115. package/dist/flow/nodes/transform-node.js +0 -107
  116. package/dist/flow/parallel-scheduler.d.ts +0 -175
  117. package/dist/flow/parallel-scheduler.d.ts.map +0 -1
  118. package/dist/flow/parallel-scheduler.js +0 -193
  119. package/dist/flow/plugins/credential-provider.d.ts +0 -47
  120. package/dist/flow/plugins/credential-provider.d.ts.map +0 -1
  121. package/dist/flow/plugins/credential-provider.js +0 -24
  122. package/dist/flow/plugins/image-ai-plugin.d.ts +0 -61
  123. package/dist/flow/plugins/image-ai-plugin.d.ts.map +0 -1
  124. package/dist/flow/plugins/image-ai-plugin.js +0 -21
  125. package/dist/flow/plugins/image-plugin.d.ts +0 -52
  126. package/dist/flow/plugins/image-plugin.d.ts.map +0 -1
  127. package/dist/flow/plugins/image-plugin.js +0 -22
  128. package/dist/flow/plugins/types/describe-image-node.d.ts +0 -16
  129. package/dist/flow/plugins/types/describe-image-node.d.ts.map +0 -1
  130. package/dist/flow/plugins/types/describe-image-node.js +0 -9
  131. package/dist/flow/plugins/types/index.d.ts +0 -9
  132. package/dist/flow/plugins/types/index.d.ts.map +0 -1
  133. package/dist/flow/plugins/types/index.js +0 -8
  134. package/dist/flow/plugins/types/optimize-node.d.ts +0 -20
  135. package/dist/flow/plugins/types/optimize-node.d.ts.map +0 -1
  136. package/dist/flow/plugins/types/optimize-node.js +0 -11
  137. package/dist/flow/plugins/types/remove-background-node.d.ts +0 -16
  138. package/dist/flow/plugins/types/remove-background-node.d.ts.map +0 -1
  139. package/dist/flow/plugins/types/remove-background-node.js +0 -9
  140. package/dist/flow/plugins/types/resize-node.d.ts +0 -21
  141. package/dist/flow/plugins/types/resize-node.d.ts.map +0 -1
  142. package/dist/flow/plugins/types/resize-node.js +0 -16
  143. package/dist/flow/plugins/zip-plugin.d.ts +0 -62
  144. package/dist/flow/plugins/zip-plugin.d.ts.map +0 -1
  145. package/dist/flow/plugins/zip-plugin.js +0 -21
  146. package/dist/flow/typed-flow.d.ts +0 -90
  147. package/dist/flow/typed-flow.d.ts.map +0 -1
  148. package/dist/flow/typed-flow.js +0 -59
  149. package/dist/flow/types/flow-file.d.ts +0 -45
  150. package/dist/flow/types/flow-file.d.ts.map +0 -1
  151. package/dist/flow/types/flow-file.js +0 -27
  152. package/dist/flow/types/flow-job.d.ts +0 -118
  153. package/dist/flow/types/flow-job.d.ts.map +0 -1
  154. package/dist/flow/types/flow-job.js +0 -11
  155. package/dist/flow/types/flow-types.d.ts +0 -321
  156. package/dist/flow/types/flow-types.d.ts.map +0 -1
  157. package/dist/flow/types/flow-types.js +0 -52
  158. package/dist/flow/types/index.d.ts +0 -4
  159. package/dist/flow/types/index.d.ts.map +0 -1
  160. package/dist/flow/types/index.js +0 -3
  161. package/dist/flow/types/run-args.d.ts +0 -38
  162. package/dist/flow/types/run-args.d.ts.map +0 -1
  163. package/dist/flow/types/run-args.js +0 -30
  164. package/dist/flow/types/type-validator.d.ts +0 -26
  165. package/dist/flow/types/type-validator.d.ts.map +0 -1
  166. package/dist/flow/types/type-validator.js +0 -134
  167. package/dist/flow/utils/resolve-upload-metadata.d.ts +0 -11
  168. package/dist/flow/utils/resolve-upload-metadata.d.ts.map +0 -1
  169. package/dist/flow/utils/resolve-upload-metadata.js +0 -28
  170. package/dist/flow-2zXnEiWL.cjs +0 -1
  171. package/dist/flow-CRaKy7Vj.js +0 -2
  172. package/dist/flow-CRaKy7Vj.js.map +0 -1
  173. package/dist/generate-id-Dm-Vboxq.d.ts +0 -34
  174. package/dist/generate-id-Dm-Vboxq.d.ts.map +0 -1
  175. package/dist/generate-id-LjJRLD6N.d.cts +0 -34
  176. package/dist/generate-id-LjJRLD6N.d.cts.map +0 -1
  177. package/dist/generate-id-xHp_Z7Cl.cjs +0 -1
  178. package/dist/generate-id-yohS1ZDk.js +0 -2
  179. package/dist/generate-id-yohS1ZDk.js.map +0 -1
  180. package/dist/index-BO8GZlbD.d.cts +0 -1040
  181. package/dist/index-BO8GZlbD.d.cts.map +0 -1
  182. package/dist/index-D-CoVpkZ.d.ts +0 -1004
  183. package/dist/index-D-CoVpkZ.d.ts.map +0 -1
  184. package/dist/index.d.ts.map +0 -1
  185. package/dist/logger/logger.cjs +0 -1
  186. package/dist/logger/logger.d.cts +0 -8
  187. package/dist/logger/logger.d.cts.map +0 -1
  188. package/dist/logger/logger.d.ts +0 -5
  189. package/dist/logger/logger.d.ts.map +0 -1
  190. package/dist/logger/logger.js +0 -10
  191. package/dist/logger/logger.js.map +0 -1
  192. package/dist/semaphore-0ZwjVpyF.js +0 -2
  193. package/dist/semaphore-0ZwjVpyF.js.map +0 -1
  194. package/dist/semaphore-BHprIjFI.d.cts +0 -37
  195. package/dist/semaphore-BHprIjFI.d.cts.map +0 -1
  196. package/dist/semaphore-DThupBkc.d.ts +0 -37
  197. package/dist/semaphore-DThupBkc.d.ts.map +0 -1
  198. package/dist/semaphore-DVrONiAV.cjs +0 -1
  199. package/dist/stream-limiter-CoWKv39w.js +0 -2
  200. package/dist/stream-limiter-JgOwmkMa.cjs +0 -1
  201. package/dist/streams/multi-stream.cjs +0 -1
  202. package/dist/streams/multi-stream.d.cts +0 -91
  203. package/dist/streams/multi-stream.d.cts.map +0 -1
  204. package/dist/streams/multi-stream.d.ts +0 -86
  205. package/dist/streams/multi-stream.d.ts.map +0 -1
  206. package/dist/streams/multi-stream.js +0 -149
  207. package/dist/streams/multi-stream.js.map +0 -1
  208. package/dist/streams/stream-limiter.cjs +0 -1
  209. package/dist/streams/stream-limiter.d.cts.map +0 -1
  210. package/dist/streams/stream-limiter.d.ts +0 -27
  211. package/dist/streams/stream-limiter.d.ts.map +0 -1
  212. package/dist/streams/stream-limiter.js +0 -49
  213. package/dist/streams/stream-splitter.cjs +0 -1
  214. package/dist/streams/stream-splitter.d.cts +0 -68
  215. package/dist/streams/stream-splitter.d.cts.map +0 -1
  216. package/dist/streams/stream-splitter.d.ts +0 -51
  217. package/dist/streams/stream-splitter.d.ts.map +0 -1
  218. package/dist/streams/stream-splitter.js +0 -175
  219. package/dist/streams/stream-splitter.js.map +0 -1
  220. package/dist/types/data-store-registry.d.ts +0 -13
  221. package/dist/types/data-store-registry.d.ts.map +0 -1
  222. package/dist/types/data-store-registry.js +0 -4
  223. package/dist/types/data-store.d.ts +0 -316
  224. package/dist/types/data-store.d.ts.map +0 -1
  225. package/dist/types/data-store.js +0 -157
  226. package/dist/types/event-broadcaster.d.ts +0 -28
  227. package/dist/types/event-broadcaster.d.ts.map +0 -1
  228. package/dist/types/event-broadcaster.js +0 -6
  229. package/dist/types/event-emitter.d.ts +0 -378
  230. package/dist/types/event-emitter.d.ts.map +0 -1
  231. package/dist/types/event-emitter.js +0 -223
  232. package/dist/types/index.d.ts.map +0 -1
  233. package/dist/types/input-file.d.ts +0 -104
  234. package/dist/types/input-file.d.ts.map +0 -1
  235. package/dist/types/input-file.js +0 -27
  236. package/dist/types/kv-store.d.ts +0 -281
  237. package/dist/types/kv-store.d.ts.map +0 -1
  238. package/dist/types/kv-store.js +0 -234
  239. package/dist/types/middleware.d.ts +0 -17
  240. package/dist/types/middleware.d.ts.map +0 -1
  241. package/dist/types/middleware.js +0 -21
  242. package/dist/types/upload-event.d.ts +0 -105
  243. package/dist/types/upload-event.d.ts.map +0 -1
  244. package/dist/types/upload-event.js +0 -71
  245. package/dist/types/upload-file.d.ts +0 -136
  246. package/dist/types/upload-file.d.ts.map +0 -1
  247. package/dist/types/upload-file.js +0 -34
  248. package/dist/types/websocket.d.ts +0 -144
  249. package/dist/types/websocket.d.ts.map +0 -1
  250. package/dist/types/websocket.js +0 -40
  251. package/dist/types-BT-cvi7T.cjs +0 -1
  252. package/dist/types-DhU2j-XF.js +0 -2
  253. package/dist/types-DhU2j-XF.js.map +0 -1
  254. package/dist/upload/convert-to-stream.d.ts +0 -38
  255. package/dist/upload/convert-to-stream.d.ts.map +0 -1
  256. package/dist/upload/convert-to-stream.js +0 -43
  257. package/dist/upload/convert-upload-to-flow-file.d.ts +0 -14
  258. package/dist/upload/convert-upload-to-flow-file.d.ts.map +0 -1
  259. package/dist/upload/convert-upload-to-flow-file.js +0 -21
  260. package/dist/upload/create-upload.d.ts +0 -68
  261. package/dist/upload/create-upload.d.ts.map +0 -1
  262. package/dist/upload/create-upload.js +0 -157
  263. package/dist/upload/index.d.ts.map +0 -1
  264. package/dist/upload/mime.d.ts +0 -24
  265. package/dist/upload/mime.d.ts.map +0 -1
  266. package/dist/upload/mime.js +0 -351
  267. package/dist/upload/upload-chunk.d.ts +0 -58
  268. package/dist/upload/upload-chunk.d.ts.map +0 -1
  269. package/dist/upload/upload-chunk.js +0 -277
  270. package/dist/upload/upload-server.d.ts +0 -221
  271. package/dist/upload/upload-server.d.ts.map +0 -1
  272. package/dist/upload/upload-server.js +0 -181
  273. package/dist/upload/upload-strategy-negotiator.d.ts +0 -148
  274. package/dist/upload/upload-strategy-negotiator.d.ts.map +0 -1
  275. package/dist/upload/upload-strategy-negotiator.js +0 -217
  276. package/dist/upload/upload-url.d.ts +0 -68
  277. package/dist/upload/upload-url.d.ts.map +0 -1
  278. package/dist/upload/upload-url.js +0 -142
  279. package/dist/upload/write-to-store.d.ts +0 -77
  280. package/dist/upload/write-to-store.d.ts.map +0 -1
  281. package/dist/upload/write-to-store.js +0 -147
  282. package/dist/upload-DLuICjpP.cjs +0 -1
  283. package/dist/upload-DaXO34dE.js +0 -2
  284. package/dist/upload-DaXO34dE.js.map +0 -1
  285. package/dist/uploadista-error-BVsVxqvz.js.map +0 -1
  286. package/dist/uploadista-error-CwxYs4EB.d.ts +0 -52
  287. package/dist/uploadista-error-CwxYs4EB.d.ts.map +0 -1
  288. package/dist/uploadista-error-kKlhLRhY.d.cts +0 -52
  289. package/dist/uploadista-error-kKlhLRhY.d.cts.map +0 -1
  290. package/dist/utils/checksum.d.ts +0 -22
  291. package/dist/utils/checksum.d.ts.map +0 -1
  292. package/dist/utils/checksum.js +0 -49
  293. package/dist/utils/debounce.cjs +0 -1
  294. package/dist/utils/debounce.d.cts +0 -38
  295. package/dist/utils/debounce.d.cts.map +0 -1
  296. package/dist/utils/debounce.d.ts +0 -36
  297. package/dist/utils/debounce.d.ts.map +0 -1
  298. package/dist/utils/debounce.js +0 -73
  299. package/dist/utils/generate-id.cjs +0 -1
  300. package/dist/utils/generate-id.d.cts +0 -2
  301. package/dist/utils/generate-id.d.ts +0 -32
  302. package/dist/utils/generate-id.d.ts.map +0 -1
  303. package/dist/utils/generate-id.js +0 -23
  304. package/dist/utils/md5.cjs +0 -1
  305. package/dist/utils/md5.d.cts +0 -73
  306. package/dist/utils/md5.d.cts.map +0 -1
  307. package/dist/utils/md5.d.ts +0 -71
  308. package/dist/utils/md5.d.ts.map +0 -1
  309. package/dist/utils/md5.js +0 -417
  310. package/dist/utils/md5.js.map +0 -1
  311. package/dist/utils/once.cjs +0 -1
  312. package/dist/utils/once.d.cts +0 -25
  313. package/dist/utils/once.d.cts.map +0 -1
  314. package/dist/utils/once.d.ts +0 -21
  315. package/dist/utils/once.d.ts.map +0 -1
  316. package/dist/utils/once.js +0 -54
  317. package/dist/utils/once.js.map +0 -1
  318. package/dist/utils/semaphore.cjs +0 -1
  319. package/dist/utils/semaphore.d.cts +0 -3
  320. package/dist/utils/semaphore.d.ts +0 -78
  321. package/dist/utils/semaphore.d.ts.map +0 -1
  322. package/dist/utils/semaphore.js +0 -134
  323. package/dist/utils/throttle.cjs +0 -1
  324. package/dist/utils/throttle.d.cts +0 -24
  325. package/dist/utils/throttle.d.cts.map +0 -1
  326. package/dist/utils/throttle.d.ts +0 -18
  327. package/dist/utils/throttle.d.ts.map +0 -1
  328. package/dist/utils/throttle.js +0 -20
  329. package/dist/utils/throttle.js.map +0 -1
  330. package/src/logger/logger.ts +0 -14
  331. /package/dist/{errors-CRm1FHHT.cjs → errors-D-K-vxsP.cjs} +0 -0
@@ -0,0 +1 @@
1
+ const e=require(`./uploadista-error-DdTP-Rjx.cjs`),t=require(`./types-Dj9g8ocl.cjs`),n=require(`./checksum-wSBuXX84.cjs`),r=require(`./stream-limiter-DYGG4t9f.cjs`);let i=require(`effect`);i=e.a(i);function a(e,t,n=0){return e.length<n+t.length?!1:t.every((t,r)=>e[n+r]===t)}function o(e,t,n=0){if(e.length<n+t.length)return!1;for(let r=0;r<t.length;r++)if(e[n+r]!==t.charCodeAt(r))return!1;return!0}const s=(e,t)=>{if(e.length===0)return`application/octet-stream`;if(a(e,[137,80,78,71,13,10,26,10]))return`image/png`;if(a(e,[255,216,255]))return`image/jpeg`;if(o(e,`GIF87a`)||o(e,`GIF89a`))return`image/gif`;if(a(e,[82,73,70,70])&&e.length>=12&&o(e,`WEBP`,8))return`image/webp`;if(e.length>=12&&a(e,[0,0,0],0)&&o(e,`ftyp`,4)&&(o(e,`avif`,8)||o(e,`avis`,8)))return`image/avif`;if(e.length>=12&&o(e,`ftyp`,4)&&(o(e,`heic`,8)||o(e,`heif`,8)||o(e,`mif1`,8)))return`image/heic`;if(a(e,[66,77]))return`image/bmp`;if(a(e,[73,73,42,0])||a(e,[77,77,0,42]))return`image/tiff`;if(a(e,[0,0,1,0]))return`image/x-icon`;if(e.length>=5){let t=new TextDecoder(`utf-8`,{fatal:!1}).decode(e.slice(0,Math.min(1024,e.length)));if(t.includes(`<svg`)||t.includes(`<?xml`)&&t.includes(`<svg`))return`image/svg+xml`}if(e.length>=12&&o(e,`ftyp`,4)){let t=new TextDecoder().decode(e.slice(8,12));if(t.startsWith(`mp4`)||t.startsWith(`M4`)||t.startsWith(`isom`))return`video/mp4`}if(a(e,[26,69,223,163]))return`video/webm`;if(a(e,[82,73,70,70])&&e.length>=12&&o(e,`AVI `,8))return`video/x-msvideo`;if(e.length>=8&&(o(e,`moov`,4)||o(e,`mdat`,4)||o(e,`free`,4)))return`video/quicktime`;if(a(e,[26,69,223,163])&&e.length>=100&&new TextDecoder(`utf-8`,{fatal:!1}).decode(e.slice(0,100)).includes(`matroska`))return`video/x-matroska`;if(a(e,[255,251])||a(e,[255,243])||a(e,[255,242])||o(e,`ID3`))return`audio/mpeg`;if(a(e,[82,73,70,70])&&e.length>=12&&o(e,`WAVE`,8))return`audio/wav`;if(o(e,`fLaC`))return`audio/flac`;if(o(e,`OggS`))return`audio/ogg`;if(e.length>=12&&o(e,`ftyp`,4)&&o(e,`M4A`,8))return`audio/mp4`;if(o(e,`%PDF`))return`application/pdf`;if(a(e,[80,75,3,4])||a(e,[80,75,5,6])||a(e,[80,75,7,8])){if(e.length>=1024){let t=new TextDecoder(`utf-8`,{fatal:!1}).decode(e);if(t.includes(`word/`))return`application/vnd.openxmlformats-officedocument.wordprocessingml.document`;if(t.includes(`xl/`))return`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`;if(t.includes(`ppt/`))return`application/vnd.openxmlformats-officedocument.presentationml.presentation`}return`application/zip`}if(a(e,[82,97,114,33,26,7]))return`application/x-rar-compressed`;if(a(e,[55,122,188,175,39,28]))return`application/x-7z-compressed`;if(a(e,[31,139]))return`application/gzip`;if(e.length>=262&&o(e,`ustar`,257))return`application/x-tar`;if(o(e,`wOFF`))return`font/woff`;if(o(e,`wOF2`))return`font/woff2`;if(a(e,[0,1,0,0,0]))return`font/ttf`;if(o(e,`OTTO`))return`font/otf`;if(e.length>=1){let t=e[0];if(t===123||t===91)try{let t=new TextDecoder(`utf-8`).decode(e.slice(0,Math.min(1024,e.length)));return JSON.parse(t.trim()),`application/json`}catch{}}if(t)switch(t.split(`.`).pop()?.toLowerCase()){case`jpg`:case`jpeg`:return`image/jpeg`;case`png`:return`image/png`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;case`avif`:return`image/avif`;case`heic`:case`heif`:return`image/heic`;case`bmp`:return`image/bmp`;case`tiff`:case`tif`:return`image/tiff`;case`ico`:return`image/x-icon`;case`svg`:return`image/svg+xml`;case`mp4`:case`m4v`:return`video/mp4`;case`webm`:return`video/webm`;case`avi`:return`video/x-msvideo`;case`mov`:return`video/quicktime`;case`mkv`:return`video/x-matroska`;case`mp3`:return`audio/mpeg`;case`wav`:return`audio/wav`;case`flac`:return`audio/flac`;case`ogg`:return`audio/ogg`;case`m4a`:return`audio/mp4`;case`pdf`:return`application/pdf`;case`docx`:return`application/vnd.openxmlformats-officedocument.wordprocessingml.document`;case`xlsx`:return`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`;case`pptx`:return`application/vnd.openxmlformats-officedocument.presentationml.presentation`;case`zip`:return`application/zip`;case`rar`:return`application/x-rar-compressed`;case`7z`:return`application/x-7z-compressed`;case`gz`:case`gzip`:return`application/gzip`;case`tar`:return`application/x-tar`;case`woff`:return`font/woff`;case`woff2`:return`font/woff2`;case`ttf`:return`font/ttf`;case`otf`:return`font/otf`;case`txt`:return`text/plain`;case`json`:return`application/json`;case`xml`:return`application/xml`;case`html`:case`htm`:return`text/html`;case`css`:return`text/css`;case`js`:return`application/javascript`;case`csv`:return`text/csv`;default:return`application/octet-stream`}return`application/octet-stream`};function c(e,t){return e===t?!0:e.split(`/`)[0]===t.split(`/`)[0]}const l=(e,n,{dataStoreService:r,kvStore:a,eventEmitter:o,generateId:s})=>i.Effect.gen(function*(){let i=yield*r.getDataStore(e.storageId,n),c=yield*s.generateId(),{size:l,type:u,fileName:d,lastModified:f,metadata:p,flow:m}=e,h={};if(p)try{h=JSON.parse(p)}catch{h={}}let g={...h,type:u,fileName:d??``};f&&(g.lastModified=f.toString());let _={id:c,size:l,metadata:g,offset:0,creationDate:new Date().toISOString(),storage:{id:e.storageId,type:u,path:``,bucket:i.bucket},flow:m},v=yield*i.create(_);return yield*a.set(c,v),yield*o.emit(c,{type:t.n.UPLOAD_STARTED,data:v,flow:v.flow}),v}).pipe(i.Effect.withSpan(`upload-create`,{attributes:{"upload.file_name":e.fileName??`unknown`,"upload.file_size":e.size?.toString()??`0`,"upload.storage_id":e.storageId,"upload.mime_type":e.type,"upload.has_flow":e.flow?`true`:`false`}}),i.Effect.tap(e=>i.Effect.gen(function*(){if(yield*i.Metric.increment(i.Metric.counter(`upload_created_total`,{description:`Total number of uploads created`})),e.size){let t=i.Metric.histogram(`upload_file_size_bytes`,i.MetricBoundaries.exponential({start:1024,factor:2,count:25}));yield*i.Metric.update(t,e.size)}let t=i.Metric.gauge(`active_uploads`);yield*i.Metric.increment(t)})),i.Effect.tap(t=>i.Effect.logInfo(`Upload created`).pipe(i.Effect.annotateLogs({"upload.id":t.id,"upload.file_name":e.fileName??`unknown`,"upload.file_size":e.size?.toString()??`0`,"upload.storage_id":e.storageId}))),i.Effect.tapError(t=>i.Effect.gen(function*(){yield*i.Effect.logError(`Upload creation failed`).pipe(i.Effect.annotateLogs({"upload.file_name":e.fileName??`unknown`,"upload.storage_id":e.storageId,error:String(t)})),yield*i.Metric.increment(i.Metric.counter(`upload_failed_total`,{description:`Total number of uploads that failed`}))})));function u(t){return i.Stream.fromReadableStream(()=>t,t=>new e.n({code:`UNKNOWN_ERROR`,status:500,body:String(t)}))}function d({data:n,upload:a,dataStore:o,maxFileSize:s,controller:c,eventEmitter:l,uploadProgressInterval:d=200}){return i.Effect.gen(function*(){let f=u(n);if(c.signal.aborted)return yield*i.Effect.fail(e.n.fromCode(`ABORTED`));let p=new AbortController,{signal:m}=p,h=()=>{p.abort()};return c.signal.addEventListener(`abort`,h,{once:!0}),yield*i.Effect.acquireUseRelease(i.Effect.sync(()=>({signal:m,onAbort:h})),({signal:n})=>i.Effect.gen(function*(){let e=yield*i.Ref.make(0),n=r.t.limit({maxSize:s})(f);return yield*o.write({stream:n,file_id:a.id,offset:a.offset},{onProgress:n=>{let r=Date.now();i.Ref.get(e).pipe(i.Effect.flatMap(o=>r-o>=d?i.Effect.gen(function*(){yield*i.Ref.set(e,r),yield*l.emit(a.id,{type:t.n.UPLOAD_PROGRESS,data:{id:a.id,progress:n,total:a.size??0},flow:a.flow})}):i.Effect.void),i.Effect.runPromise).catch(()=>{})}})}).pipe(i.Effect.catchAll(t=>t instanceof Error&&t.name===`AbortError`?i.Effect.fail(e.n.fromCode(`ABORTED`)):t instanceof e.n?i.Effect.fail(t):i.Effect.fail(e.n.fromCode(`FILE_WRITE_ERROR`,{cause:t})))),({onAbort:e})=>i.Effect.sync(()=>{c.signal.removeEventListener(`abort`,e)}))}).pipe(i.Effect.withSpan(`upload-write-to-store`,{attributes:{"upload.id":a.id,"upload.offset":a.offset.toString(),"upload.max_file_size":s.toString(),"upload.file_size":a.size?.toString()??`0`}}),i.Effect.tap(e=>i.Effect.logDebug(`Data written to store`).pipe(i.Effect.annotateLogs({"upload.id":a.id,"write.offset":e.toString(),"write.bytes_written":(e-a.offset).toString()}))),i.Effect.tapError(t=>i.Effect.logError(`Failed to write to store`).pipe(i.Effect.annotateLogs({"upload.id":a.id,"upload.offset":a.offset.toString(),error:t instanceof e.n?t.code:String(t)}))))}const f=(e,n,r,{dataStoreService:a,kvStore:o,eventEmitter:s})=>i.Effect.gen(function*(){let i=yield*o.get(e),c=yield*a.getDataStore(i.storage.id,n);return i.offset=yield*d({dataStore:c,data:r,upload:i,maxFileSize:1e8,controller:new AbortController,uploadProgressInterval:200,eventEmitter:s}),yield*o.set(e,i),yield*s.emit(i.id,{type:t.n.UPLOAD_PROGRESS,data:{id:i.id,progress:i.offset,total:i.size??0},flow:i.flow}),i.size&&i.offset===i.size&&(yield*p({file:i,dataStore:c,eventEmitter:s})),i}).pipe(i.Effect.withSpan(`upload-chunk`,{attributes:{"upload.id":e,"chunk.upload_id":e}}),i.Effect.tap(e=>i.Effect.gen(function*(){yield*i.Metric.increment(i.Metric.counter(`chunk_uploaded_total`,{description:`Total number of chunks uploaded`}));let t=e.offset,n=i.Metric.histogram(`chunk_size_bytes`,i.MetricBoundaries.linear({start:262144,width:262144,count:20}));if(yield*i.Metric.update(n,t),e.size&&e.size>0){let e=t,n=i.Metric.gauge(`upload_throughput_bytes_per_second`);yield*i.Metric.set(n,e)}})),i.Effect.tap(e=>i.Effect.logDebug(`Chunk uploaded`).pipe(i.Effect.annotateLogs({"upload.id":e.id,"chunk.size":e.offset.toString(),"chunk.progress":e.size&&e.size>0?(e.offset/e.size*100).toFixed(2):`0`,"upload.total_size":e.size?.toString()??`0`}))),i.Effect.tapError(t=>i.Effect.logError(`Chunk upload failed`).pipe(i.Effect.annotateLogs({"upload.id":e,error:String(t)})))),p=({file:r,dataStore:a,eventEmitter:o})=>i.Effect.gen(function*(){let i=a.getCapabilities();if(i.maxValidationSize&&r.size&&r.size>i.maxValidationSize){yield*o.emit(r.id,{type:t.n.UPLOAD_VALIDATION_WARNING,data:{id:r.id,message:`File size (${r.size} bytes) exceeds max validation size (${i.maxValidationSize} bytes). Validation skipped.`},flow:r.flow});return}let l=yield*a.read(r.id);if(r.checksum&&r.checksumAlgorithm){let i=yield*n.t(l,r.checksumAlgorithm);if(i!==r.checksum)return yield*o.emit(r.id,{type:t.n.UPLOAD_VALIDATION_FAILED,data:{id:r.id,reason:`checksum_mismatch`,expected:r.checksum,actual:i},flow:r.flow}),yield*a.remove(r.id),yield*e.n.fromCode(`CHECKSUM_MISMATCH`,{body:`Checksum validation failed. Expected: ${r.checksum}, Got: ${i}`,details:{uploadId:r.id,expected:r.checksum,actual:i,algorithm:r.checksumAlgorithm}}).toEffect();yield*o.emit(r.id,{type:t.n.UPLOAD_VALIDATION_SUCCESS,data:{id:r.id,validationType:`checksum`,algorithm:r.checksumAlgorithm},flow:r.flow})}if(i.requiresMimeTypeValidation){let n=s(l),i=r.metadata?.type;if(i&&!c(i,n))return yield*o.emit(r.id,{type:t.n.UPLOAD_VALIDATION_FAILED,data:{id:r.id,reason:`mimetype_mismatch`,expected:i,actual:n},flow:r.flow}),yield*a.remove(r.id),yield*e.n.fromCode(`MIMETYPE_MISMATCH`,{body:`MIME type validation failed. Expected: ${i}, Detected: ${n}`,details:{uploadId:r.id,expected:i,actual:n}}).toEffect();yield*o.emit(r.id,{type:t.n.UPLOAD_VALIDATION_SUCCESS,data:{id:r.id,validationType:`mimetype`},flow:r.flow})}}).pipe(i.Effect.withSpan(`validate-upload`,{attributes:{"upload.id":r.id,"validation.checksum_provided":r.checksum?`true`:`false`,"validation.mime_required":a.getCapabilities().requiresMimeTypeValidation?`true`:`false`}})),m=t=>i.Effect.tryPromise({try:async()=>await fetch(t),catch:t=>e.n.fromCode(`UNKNOWN_ERROR`,{cause:t})}).pipe(i.Effect.withSpan(`upload-fetch-url`,{attributes:{"upload.url":t,"upload.operation":`fetch`}}),i.Effect.tap(e=>i.Effect.gen(function*(){yield*i.Metric.increment(i.Metric.counter(`upload_from_url_total`,{description:`Total number of URL-based uploads`})),e.ok&&(yield*i.Metric.increment(i.Metric.counter(`upload_from_url_success_total`,{description:`Total number of successful URL-based uploads`})))})),i.Effect.tap(e=>i.Effect.logInfo(`URL fetch completed`).pipe(i.Effect.annotateLogs({"upload.url":t,"response.status":e.status.toString(),"response.ok":e.ok.toString(),"response.content_length":e.headers.get(`content-length`)??`unknown`}))),i.Effect.tapError(e=>i.Effect.gen(function*(){yield*i.Metric.increment(i.Metric.counter(`upload_from_url_failed_total`,{description:`Total number of failed URL-based uploads`})),yield*i.Effect.logError(`URL fetch failed`).pipe(i.Effect.annotateLogs({"upload.url":t,error:String(e)}))}))),h=t=>i.Effect.tryPromise({try:async()=>await t.arrayBuffer(),catch:t=>e.n.fromCode(`UNKNOWN_ERROR`,{cause:t})}).pipe(i.Effect.withSpan(`upload-convert-to-buffer`,{attributes:{"upload.operation":`arrayBuffer`}}),i.Effect.tap(e=>i.Effect.logDebug(`Response converted to array buffer`).pipe(i.Effect.annotateLogs({"buffer.size":e.byteLength.toString()}))),i.Effect.tapError(e=>i.Effect.logError(`Failed to convert response to array buffer`).pipe(i.Effect.annotateLogs({error:String(e)}))));var g=class extends i.Context.Tag(`UploadServer`)(){};function _(){return i.Effect.gen(function*(){let e=yield*t.u,r=yield*t.v,a=yield*n.r,o=yield*t.T;return{upload:(t,n,s)=>i.Effect.gen(function*(){return yield*f((yield*l(t,n,{dataStoreService:o,kvStore:e,eventEmitter:r,generateId:a})).id,n,s,{dataStoreService:o,kvStore:e,eventEmitter:r})}),uploadFromUrl:(t,n,s)=>i.Effect.gen(function*(){let i=yield*h(yield*m(s)),c=new ReadableStream({start(e){e.enqueue(new Uint8Array(i)),e.close()}});return yield*f((yield*l({...t,size:i.byteLength},n,{dataStoreService:o,kvStore:e,eventEmitter:r,generateId:a})).id,n,c,{dataStoreService:o,kvStore:e,eventEmitter:r})}),createUpload:(t,n)=>i.Effect.gen(function*(){return yield*l(t,n,{dataStoreService:o,kvStore:e,eventEmitter:r,generateId:a})}),uploadChunk:(t,n,a)=>i.Effect.gen(function*(){return yield*f(t,n,a,{dataStoreService:o,kvStore:e,eventEmitter:r})}),getUpload:t=>i.Effect.gen(function*(){return yield*e.get(t)}),read:(t,n)=>i.Effect.gen(function*(){let r=yield*e.get(t);return yield*(yield*o.getDataStore(r.storage.id,n)).read(t)}),delete:(t,n)=>i.Effect.gen(function*(){let r=yield*e.get(t);yield*(yield*o.getDataStore(r.storage.id,n)).remove(t),yield*e.delete(t)}),getCapabilities:(e,t)=>i.Effect.gen(function*(){return(yield*o.getDataStore(e,t)).getCapabilities()}),subscribeToUploadEvents:(e,t)=>i.Effect.gen(function*(){yield*r.subscribe(e,t)}),unsubscribeFromUploadEvents:e=>i.Effect.gen(function*(){yield*r.unsubscribe(e)})}})}const v=i.Layer.effect(g,_());var y=class{constructor(e,t){this.capabilities=e,this.validateUploadStrategy=t}negotiateStrategy(e){let t=[],n=[],r=`single`,i=e.preferredChunkSize??this.capabilities.optimalChunkSize??1024*1024,a=e.parallelUploads??1;if(e.preferredStrategy&&(this.validateUploadStrategy(e.preferredStrategy)?(r=e.preferredStrategy,t.push(`Using preferred strategy: ${r}`)):n.push(`Preferred strategy '${e.preferredStrategy}' not supported by data store, falling back`)),(!e.preferredStrategy||!this.validateUploadStrategy(e.preferredStrategy))&&(this.capabilities.supportsParallelUploads&&e.fileSize>(e.minChunkSizeForParallel??10*1024*1024)?(r=`parallel`,t.push(`Selected parallel upload for large file (${e.fileSize} bytes)`)):(r=`single`,t.push(this.capabilities.supportsParallelUploads?`Selected single upload for small file (${e.fileSize} bytes)`:`Selected single upload (parallel not supported by data store)`))),this.capabilities.minChunkSize&&i<this.capabilities.minChunkSize&&(n.push(`Chunk size ${i} below minimum ${this.capabilities.minChunkSize}, adjusting`),i=this.capabilities.minChunkSize),this.capabilities.maxChunkSize&&i>this.capabilities.maxChunkSize&&(n.push(`Chunk size ${i} above maximum ${this.capabilities.maxChunkSize}, adjusting`),i=this.capabilities.maxChunkSize),r===`parallel`&&(this.capabilities.maxConcurrentUploads&&a>this.capabilities.maxConcurrentUploads&&(n.push(`Parallel uploads ${a} exceeds maximum ${this.capabilities.maxConcurrentUploads}, adjusting`),a=this.capabilities.maxConcurrentUploads),this.capabilities.maxParts)){let t=Math.ceil(e.fileSize/i);if(t>this.capabilities.maxParts){let r=Math.ceil(e.fileSize/this.capabilities.maxParts);n.push(`Estimated parts ${t} exceeds maximum ${this.capabilities.maxParts}, increasing chunk size`),i=Math.max(i,r)}}return this.validateUploadStrategy(r)||(n.push(`Final strategy validation failed, falling back to single upload`),r=`single`,a=1),t.push(`Data store capabilities: parallel=${this.capabilities.supportsParallelUploads}, concatenation=${this.capabilities.supportsConcatenation}, resumable=${this.capabilities.supportsResumableUploads}`),{strategy:r,chunkSize:i,parallelUploads:r===`parallel`?a:1,reasoning:t,warnings:n}}getDataStoreCapabilities(){return this.capabilities}validateConfiguration(e){let t=[];return e.preferredStrategy&&!this.validateUploadStrategy(e.preferredStrategy)&&t.push(`Preferred strategy '${e.preferredStrategy}' not supported by data store`),e.preferredChunkSize&&(this.capabilities.minChunkSize&&e.preferredChunkSize<this.capabilities.minChunkSize&&t.push(`Chunk size ${e.preferredChunkSize} below data store minimum ${this.capabilities.minChunkSize}`),this.capabilities.maxChunkSize&&e.preferredChunkSize>this.capabilities.maxChunkSize&&t.push(`Chunk size ${e.preferredChunkSize} above data store maximum ${this.capabilities.maxChunkSize}`)),e.parallelUploads&&this.capabilities.maxConcurrentUploads&&e.parallelUploads>this.capabilities.maxConcurrentUploads&&t.push(`Parallel uploads ${e.parallelUploads} exceeds data store maximum ${this.capabilities.maxConcurrentUploads}`),{valid:t.length===0,errors:t}}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return y}});
@@ -0,0 +1,221 @@
1
+ import * as effect_Types0 from "effect/Types";
2
+ import * as effect_Cause0 from "effect/Cause";
3
+ import { Effect } from "effect";
4
+
5
+ //#region src/errors/uploadista-error.d.ts
6
+
7
+ /**
8
+ * Union type of all possible error codes in the Uploadista system.
9
+ *
10
+ * Each error code corresponds to a specific error condition with predefined
11
+ * HTTP status codes and messages in the ERROR_CATALOG.
12
+ */
13
+ 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";
14
+ /**
15
+ * Catalog of all predefined errors in the Uploadista system.
16
+ *
17
+ * Maps error codes to their HTTP status codes and default error messages.
18
+ * This centralized catalog ensures consistent error handling across all
19
+ * Uploadista packages and adapters.
20
+ *
21
+ * Each error entry contains:
22
+ * - `status`: HTTP status code (400-500 range)
23
+ * - `body`: Human-readable error message
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * // Access a specific error definition
28
+ * const fileNotFound = ERROR_CATALOG.FILE_NOT_FOUND;
29
+ * console.log(fileNotFound.status); // 404
30
+ * console.log(fileNotFound.body); // "The file for this url was not found\n"
31
+ *
32
+ * // Use with UploadistaError
33
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
34
+ * ```
35
+ */
36
+ declare const ERROR_CATALOG: Readonly<Record<UploadistaErrorCode, {
37
+ status: number;
38
+ body: string;
39
+ }>>;
40
+ declare const UploadistaError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause0.YieldableError & {
41
+ readonly _tag: "UploadistaError";
42
+ } & Readonly<A>;
43
+ /**
44
+ * Standard error class for all Uploadista operations.
45
+ *
46
+ * UploadistaError provides a consistent error handling approach across the entire
47
+ * Uploadista ecosystem. Each error has:
48
+ * - A typed error code from the ERROR_CATALOG
49
+ * - An HTTP-compatible status code
50
+ * - A human-readable error message (body)
51
+ * - Optional additional details and cause information
52
+ *
53
+ * This class integrates with Effect-TS for functional error handling and can be
54
+ * easily converted to an Effect that fails.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * // Create from error code
59
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
60
+ *
61
+ * // Create with custom details
62
+ * const customError = UploadistaError.fromCode("FLOW_NODE_ERROR", {
63
+ * body: "Failed to process image",
64
+ * cause: originalError,
65
+ * details: { nodeId: "resize-1", fileId: "abc123" }
66
+ * });
67
+ *
68
+ * // Use with Effect
69
+ * const effect = customError.toEffect<void>();
70
+ *
71
+ * // In an Effect pipeline
72
+ * return Effect.gen(function* () {
73
+ * const file = yield* getFile(id);
74
+ * if (!file) {
75
+ * return yield* UploadistaError.fromCode("FILE_NOT_FOUND").toEffect();
76
+ * }
77
+ * return file;
78
+ * });
79
+ * ```
80
+ */
81
+ declare class UploadistaError extends UploadistaError_base {
82
+ readonly code: string;
83
+ readonly status: number;
84
+ readonly status_code: number;
85
+ readonly body: string;
86
+ readonly details?: unknown;
87
+ constructor({
88
+ code,
89
+ status,
90
+ body,
91
+ cause,
92
+ details
93
+ }: {
94
+ code: UploadistaErrorCode | string;
95
+ status: number;
96
+ body: string;
97
+ cause?: unknown;
98
+ details?: unknown;
99
+ });
100
+ /**
101
+ * Creates an UploadistaError from a predefined error code.
102
+ *
103
+ * This is the primary way to create errors in the Uploadista system. Each error code
104
+ * has a default status and message defined in ERROR_CATALOG, but these can be overridden
105
+ * for specific use cases.
106
+ *
107
+ * @param code - One of the predefined error codes from UploadistaErrorCode
108
+ * @param overrides - Optional overrides for the default error properties
109
+ * @param overrides.status - Custom HTTP status code (overrides the default)
110
+ * @param overrides.body - Custom error message (overrides the default)
111
+ * @param overrides.details - Additional structured data about the error
112
+ * @param overrides.cause - The underlying error that caused this error (for error chaining)
113
+ *
114
+ * @returns A new UploadistaError instance
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * // Use default error
119
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
120
+ *
121
+ * // Override message
122
+ * const customError = UploadistaError.fromCode("FILE_NOT_FOUND", {
123
+ * body: `File with ID ${fileId} was not found in storage`
124
+ * });
125
+ *
126
+ * // Include cause and details
127
+ * const detailedError = UploadistaError.fromCode("DATASTORE_NOT_FOUND", {
128
+ * cause: storageException,
129
+ * details: { storageId: "s3-prod", region: "us-east-1" }
130
+ * });
131
+ * ```
132
+ */
133
+ static fromCode(code: UploadistaErrorCode, overrides?: Partial<Pick<UploadistaError, "status" | "body">> & {
134
+ details?: unknown;
135
+ cause?: unknown;
136
+ }): UploadistaError;
137
+ /**
138
+ * Converts this error to an Effect that immediately fails.
139
+ *
140
+ * This method integrates UploadistaError with Effect-TS's error handling system,
141
+ * allowing errors to be used in Effect pipelines with proper type checking.
142
+ *
143
+ * @template T - The success type of the Effect (defaults to never since it always fails)
144
+ * @returns An Effect that fails with this UploadistaError
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
149
+ *
150
+ * // Use in an Effect pipeline
151
+ * return Effect.gen(function* () {
152
+ * const file = yield* kvStore.get(fileId);
153
+ * if (!file) {
154
+ * return yield* error.toEffect();
155
+ * }
156
+ * return file;
157
+ * });
158
+ * ```
159
+ */
160
+ toEffect<T = never>(): Effect.Effect<T, UploadistaError>;
161
+ }
162
+ /**
163
+ * Type guard to check if an unknown value is an UploadistaError.
164
+ *
165
+ * Useful for error handling when catching errors that might be from
166
+ * different sources or libraries.
167
+ *
168
+ * @param error - The value to check
169
+ * @returns True if the value is an UploadistaError instance
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * try {
174
+ * await someOperation();
175
+ * } catch (error) {
176
+ * if (isUploadistaError(error)) {
177
+ * console.log(`Uploadista error: ${error.code} (${error.status})`);
178
+ * console.log(error.body);
179
+ * } else {
180
+ * console.error("Unknown error:", error);
181
+ * }
182
+ * }
183
+ * ```
184
+ */
185
+ declare function isUploadistaError(error: unknown): error is UploadistaError;
186
+ /**
187
+ * Creates an Effect that immediately fails with an UploadistaError.
188
+ *
189
+ * This is a convenience function that combines error creation with Effect conversion.
190
+ * It's equivalent to calling `UploadistaError.fromCode(code, overrides).toEffect()`.
191
+ *
192
+ * @param code - One of the predefined error codes from UploadistaErrorCode
193
+ * @param overrides - Optional overrides for the default error properties
194
+ * @param overrides.status - Custom HTTP status code
195
+ * @param overrides.body - Custom error message
196
+ * @param overrides.details - Additional structured data about the error
197
+ * @param overrides.cause - The underlying error that caused this error
198
+ *
199
+ * @returns An Effect that immediately fails with the created UploadistaError
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * // In an Effect pipeline
204
+ * return Effect.gen(function* () {
205
+ * const file = yield* kvStore.get(fileId);
206
+ * if (!file) {
207
+ * return yield* httpFailure("FILE_NOT_FOUND", {
208
+ * details: { fileId }
209
+ * });
210
+ * }
211
+ * return file;
212
+ * });
213
+ * ```
214
+ */
215
+ declare function httpFailure(code: UploadistaErrorCode, overrides?: Partial<Pick<UploadistaError, "status" | "body">> & {
216
+ details?: unknown;
217
+ cause?: unknown;
218
+ }): Effect.Effect<never, UploadistaError>;
219
+ //#endregion
220
+ export { isUploadistaError as a, httpFailure as i, UploadistaError as n, UploadistaErrorCode as r, ERROR_CATALOG as t };
221
+ //# sourceMappingURL=uploadista-error-CAtkQiAv.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploadista-error-CAtkQiAv.d.cts","names":[],"sources":["../src/errors/uploadista-error.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAQA;AAwDA;AACS,KAzDG,mBAAA,GAyDH,gBAAA,GAAA,SAAA,GAAA,qBAAA,GAAA,kBAAA,GAAA,sBAAA,GAAA,sBAAA,GAAA,kBAAA,GAAA,qBAAA,GAAA,iBAAA,GAAA,qBAAA,GAAA,gBAAA,GAAA,iBAAA,GAAA,oBAAA,GAAA,gBAAA,GAAA,qBAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,uBAAA,GAAA,mBAAA,GAAA,uBAAA,GAAA,gBAAA,GAAA,kBAAA,GAAA,kBAAA,GAAA,wBAAA,GAAA,eAAA,GAAA,kBAAA,GAAA,qBAAA,GAAA,8BAAA,GAAA,6BAAA,GAAA,mBAAA,GAAA,mBAAA,GAAA,gCAAA;;;;AAmHE;;;;;;;;;;;;;AAwCX;;;;;;AAeU,cA3KG,aA2KH,EA3KkB,QA2KlB,CA1KR,MA0KQ,CA1KD,mBA0KC,EAAA;EAkDA,MAAA,EAAA,MAAA;EACmB,IAAA,EAAA,MAAA;CAAL,CAAA,CAAA;cA1Gb,oBA0GK,EAAA,IAAA,CAAA,gBAAA,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,IAAA,sBAAA,EAAA,EAAA,CAAA,CAAA,CAAA,SAAA,IAAA,GAAA,IAAA,GAAA,iBAAA,OAAA,KAAA,SAAA,MAAA,GAAA,KAAA,IAAA,IAAA,EAAA,CAAA,EAAA,EAAA,kCAAA;EAIX,SAAA,IAAA,EAAA,iBAAA;CAkCkC,WAAA,EAAA,CAAA;;;;;AA4BvC;AAiCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cArKa,eAAA,SAAwB,oBAAA;;;;;;;;;;;;;UAe3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkDA,iCACM,QAAQ,KAAK;;;MAIxB;;;;;;;;;;;;;;;;;;;;;;;;yBAkCoB,MAAA,CAAO,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;iBA4B1B,iBAAA,2BAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiC5C,WAAA,OACR,iCACM,QAAQ,KAAK;;;IAIxB,MAAA,CAAO,cAAc"}
@@ -3,6 +3,8 @@ import{Data as e,Effect as t}from"effect";const n={MISSING_OFFSET:{status:403,bo
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
5
5
  `},FILE_NOT_FOUND:{status:404,body:`The file for this url was not found
6
+ `},FLOW_NOT_AUTHORIZED:{status:401,body:`The flow is not authorized
7
+ `},FLOW_NOT_FOUND:{status:404,body:`The flow was not found
6
8
  `},FLOW_STRUCTURE_ERROR:{status:500,body:`The flow structure is invalid
7
9
  `},FLOW_CYCLE_ERROR:{status:500,body:`The flow contains a cycle
8
10
  `},FLOW_NODE_NOT_FOUND:{status:500,body:`The flow node was not found
@@ -13,11 +15,16 @@ import{Data as e,Effect as t}from"effect";const n={MISSING_OFFSET:{status:403,bo
13
15
  `},FLOW_OUTPUT_VALIDATION_ERROR:{status:500,body:`The flow output validation failed
14
16
  `},INVALID_OFFSET:{status:409,body:`Upload-Offset conflict
15
17
  `},FILE_NO_LONGER_EXISTS:{status:410,body:`The file for this url no longer exists
18
+ `},FILE_READ_ERROR:{status:500,body:`Something went wrong reading the file
16
19
  `},ERR_SIZE_EXCEEDED:{status:413,body:`upload's size exceeded
17
20
  `},ERR_MAX_SIZE_EXCEEDED:{status:413,body:`Maximum size exceeded
18
21
  `},INVALID_LENGTH:{status:400,body:`Upload-Length or Upload-Defer-Length header required
19
22
  `},INVALID_METADATA:{status:400,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`},VALIDATION_ERROR:{status:400,body:`Validation failed
23
+ `},STORAGE_NOT_AUTHORIZED:{status:401,body:`The storage is not authorized
20
24
  `},UNKNOWN_ERROR:{status:500,body:`Something went wrong with that request
21
25
  `},FILE_WRITE_ERROR:{status:500,body:`Something went wrong receiving the file
22
- `}};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.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{n as ERROR_CATALOG,r as UploadistaError,a as httpFailureEffect,i as isUploadistaError};
23
- //# sourceMappingURL=uploadista-error-BVsVxqvz.js.map
26
+ `},CHECKSUM_MISMATCH:{status:400,body:`The file checksum does not match the provided checksum
27
+ `},MIMETYPE_MISMATCH:{status:400,body:`The file MIME type does not match the declared type
28
+ `},UNSUPPORTED_CHECKSUM_ALGORITHM:{status:400,body:`The specified checksum algorithm is not supported
29
+ `}};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.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};
30
+ //# sourceMappingURL=uploadista-error-CjfcFnVa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploadista-error-CjfcFnVa.js","names":["ERROR_CATALOG: Readonly<\n Record<UploadistaErrorCode, { status: number; body: string }>\n>"],"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 | \"FILE_READ_ERROR\"\n | \"FLOW_JOB_NOT_FOUND\"\n | \"FLOW_JOB_ERROR\"\n | \"DATASTORE_NOT_FOUND\"\n | \"FILE_NOT_FOUND\"\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\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 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_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} 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 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":"0CAgEA,MAAaA,EAET,CACF,eAAgB,CAAE,OAAQ,IAAK,KAAM;EAAmC,CACxE,QAAS,CAAE,OAAQ,IAAK,KAAM,uCAAwC,CACtE,oBAAqB,CACnB,OAAQ,IACR,KAAM,+CACP,CACD,iBAAkB,CAChB,OAAQ,IACR,KAAM,wCACP,CACD,qBAAsB,CACpB,OAAQ,IACR,KAAM;EACP,CACD,oBAAqB,CACnB,OAAQ,IACR,KAAM;EACP,CACD,oBAAqB,CACnB,OAAQ,IACR,KAAM;EACP,CACD,eAAgB,CACd,OAAQ,IACR,KAAM;EACP,CACD,oBAAqB,CACnB,OAAQ,IACR,KAAM;EACP,CACD,eAAgB,CACd,OAAQ,IACR,KAAM;EACP,CACD,qBAAsB,CACpB,OAAQ,IACR,KAAM;EACP,CACD,iBAAkB,CAChB,OAAQ,IACR,KAAM;EACP,CACD,oBAAqB,CACnB,OAAQ,IACR,KAAM;EACP,CACD,gBAAiB,CACf,OAAQ,IACR,KAAM;EACP,CACD,mBAAoB,CAClB,OAAQ,IACR,KAAM;EACP,CACD,eAAgB,CACd,OAAQ,IACR,KAAM;EACP,CACD,4BAA6B,CAC3B,OAAQ,IACR,KAAM;EACP,CACD,6BAA8B,CAC5B,OAAQ,IACR,KAAM;EACP,CACD,eAAgB,CAAE,OAAQ,IAAK,KAAM;EAA4B,CACjE,sBAAuB,CACrB,OAAQ,IACR,KAAM;EACP,CACD,gBAAiB,CACf,OAAQ,IACR,KAAM;EACP,CACD,kBAAmB,CAAE,OAAQ,IAAK,KAAM;EAA4B,CACpE,sBAAuB,CAAE,OAAQ,IAAK,KAAM;EAA2B,CACvE,eAAgB,CACd,OAAQ,IACR,KAAM;EACP,CACD,iBAAkB,CAChB,OAAQ,IACR,KAAM,8SACP,CACD,iBAAkB,CAChB,OAAQ,IACR,KAAM;EACP,CACD,uBAAwB,CACtB,OAAQ,IACR,KAAM;EACP,CACD,cAAe,CACb,OAAQ,IACR,KAAM;EACP,CACD,iBAAkB,CAChB,OAAQ,IACR,KAAM;EACP,CACD,kBAAmB,CACjB,OAAQ,IACR,KAAM;EACP,CACD,kBAAmB,CACjB,OAAQ,IACR,KAAM;EACP,CACD,+BAAgC,CAC9B,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,EACZ,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"}
@@ -0,0 +1,221 @@
1
+ import { Effect } from "effect";
2
+ import * as effect_Types0 from "effect/Types";
3
+ import * as effect_Cause0 from "effect/Cause";
4
+
5
+ //#region src/errors/uploadista-error.d.ts
6
+
7
+ /**
8
+ * Union type of all possible error codes in the Uploadista system.
9
+ *
10
+ * Each error code corresponds to a specific error condition with predefined
11
+ * HTTP status codes and messages in the ERROR_CATALOG.
12
+ */
13
+ 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";
14
+ /**
15
+ * Catalog of all predefined errors in the Uploadista system.
16
+ *
17
+ * Maps error codes to their HTTP status codes and default error messages.
18
+ * This centralized catalog ensures consistent error handling across all
19
+ * Uploadista packages and adapters.
20
+ *
21
+ * Each error entry contains:
22
+ * - `status`: HTTP status code (400-500 range)
23
+ * - `body`: Human-readable error message
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * // Access a specific error definition
28
+ * const fileNotFound = ERROR_CATALOG.FILE_NOT_FOUND;
29
+ * console.log(fileNotFound.status); // 404
30
+ * console.log(fileNotFound.body); // "The file for this url was not found\n"
31
+ *
32
+ * // Use with UploadistaError
33
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
34
+ * ```
35
+ */
36
+ declare const ERROR_CATALOG: Readonly<Record<UploadistaErrorCode, {
37
+ status: number;
38
+ body: string;
39
+ }>>;
40
+ declare const UploadistaError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause0.YieldableError & {
41
+ readonly _tag: "UploadistaError";
42
+ } & Readonly<A>;
43
+ /**
44
+ * Standard error class for all Uploadista operations.
45
+ *
46
+ * UploadistaError provides a consistent error handling approach across the entire
47
+ * Uploadista ecosystem. Each error has:
48
+ * - A typed error code from the ERROR_CATALOG
49
+ * - An HTTP-compatible status code
50
+ * - A human-readable error message (body)
51
+ * - Optional additional details and cause information
52
+ *
53
+ * This class integrates with Effect-TS for functional error handling and can be
54
+ * easily converted to an Effect that fails.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * // Create from error code
59
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
60
+ *
61
+ * // Create with custom details
62
+ * const customError = UploadistaError.fromCode("FLOW_NODE_ERROR", {
63
+ * body: "Failed to process image",
64
+ * cause: originalError,
65
+ * details: { nodeId: "resize-1", fileId: "abc123" }
66
+ * });
67
+ *
68
+ * // Use with Effect
69
+ * const effect = customError.toEffect<void>();
70
+ *
71
+ * // In an Effect pipeline
72
+ * return Effect.gen(function* () {
73
+ * const file = yield* getFile(id);
74
+ * if (!file) {
75
+ * return yield* UploadistaError.fromCode("FILE_NOT_FOUND").toEffect();
76
+ * }
77
+ * return file;
78
+ * });
79
+ * ```
80
+ */
81
+ declare class UploadistaError extends UploadistaError_base {
82
+ readonly code: string;
83
+ readonly status: number;
84
+ readonly status_code: number;
85
+ readonly body: string;
86
+ readonly details?: unknown;
87
+ constructor({
88
+ code,
89
+ status,
90
+ body,
91
+ cause,
92
+ details
93
+ }: {
94
+ code: UploadistaErrorCode | string;
95
+ status: number;
96
+ body: string;
97
+ cause?: unknown;
98
+ details?: unknown;
99
+ });
100
+ /**
101
+ * Creates an UploadistaError from a predefined error code.
102
+ *
103
+ * This is the primary way to create errors in the Uploadista system. Each error code
104
+ * has a default status and message defined in ERROR_CATALOG, but these can be overridden
105
+ * for specific use cases.
106
+ *
107
+ * @param code - One of the predefined error codes from UploadistaErrorCode
108
+ * @param overrides - Optional overrides for the default error properties
109
+ * @param overrides.status - Custom HTTP status code (overrides the default)
110
+ * @param overrides.body - Custom error message (overrides the default)
111
+ * @param overrides.details - Additional structured data about the error
112
+ * @param overrides.cause - The underlying error that caused this error (for error chaining)
113
+ *
114
+ * @returns A new UploadistaError instance
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * // Use default error
119
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
120
+ *
121
+ * // Override message
122
+ * const customError = UploadistaError.fromCode("FILE_NOT_FOUND", {
123
+ * body: `File with ID ${fileId} was not found in storage`
124
+ * });
125
+ *
126
+ * // Include cause and details
127
+ * const detailedError = UploadistaError.fromCode("DATASTORE_NOT_FOUND", {
128
+ * cause: storageException,
129
+ * details: { storageId: "s3-prod", region: "us-east-1" }
130
+ * });
131
+ * ```
132
+ */
133
+ static fromCode(code: UploadistaErrorCode, overrides?: Partial<Pick<UploadistaError, "status" | "body">> & {
134
+ details?: unknown;
135
+ cause?: unknown;
136
+ }): UploadistaError;
137
+ /**
138
+ * Converts this error to an Effect that immediately fails.
139
+ *
140
+ * This method integrates UploadistaError with Effect-TS's error handling system,
141
+ * allowing errors to be used in Effect pipelines with proper type checking.
142
+ *
143
+ * @template T - The success type of the Effect (defaults to never since it always fails)
144
+ * @returns An Effect that fails with this UploadistaError
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const error = UploadistaError.fromCode("FILE_NOT_FOUND");
149
+ *
150
+ * // Use in an Effect pipeline
151
+ * return Effect.gen(function* () {
152
+ * const file = yield* kvStore.get(fileId);
153
+ * if (!file) {
154
+ * return yield* error.toEffect();
155
+ * }
156
+ * return file;
157
+ * });
158
+ * ```
159
+ */
160
+ toEffect<T = never>(): Effect.Effect<T, UploadistaError>;
161
+ }
162
+ /**
163
+ * Type guard to check if an unknown value is an UploadistaError.
164
+ *
165
+ * Useful for error handling when catching errors that might be from
166
+ * different sources or libraries.
167
+ *
168
+ * @param error - The value to check
169
+ * @returns True if the value is an UploadistaError instance
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * try {
174
+ * await someOperation();
175
+ * } catch (error) {
176
+ * if (isUploadistaError(error)) {
177
+ * console.log(`Uploadista error: ${error.code} (${error.status})`);
178
+ * console.log(error.body);
179
+ * } else {
180
+ * console.error("Unknown error:", error);
181
+ * }
182
+ * }
183
+ * ```
184
+ */
185
+ declare function isUploadistaError(error: unknown): error is UploadistaError;
186
+ /**
187
+ * Creates an Effect that immediately fails with an UploadistaError.
188
+ *
189
+ * This is a convenience function that combines error creation with Effect conversion.
190
+ * It's equivalent to calling `UploadistaError.fromCode(code, overrides).toEffect()`.
191
+ *
192
+ * @param code - One of the predefined error codes from UploadistaErrorCode
193
+ * @param overrides - Optional overrides for the default error properties
194
+ * @param overrides.status - Custom HTTP status code
195
+ * @param overrides.body - Custom error message
196
+ * @param overrides.details - Additional structured data about the error
197
+ * @param overrides.cause - The underlying error that caused this error
198
+ *
199
+ * @returns An Effect that immediately fails with the created UploadistaError
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * // In an Effect pipeline
204
+ * return Effect.gen(function* () {
205
+ * const file = yield* kvStore.get(fileId);
206
+ * if (!file) {
207
+ * return yield* httpFailure("FILE_NOT_FOUND", {
208
+ * details: { fileId }
209
+ * });
210
+ * }
211
+ * return file;
212
+ * });
213
+ * ```
214
+ */
215
+ declare function httpFailure(code: UploadistaErrorCode, overrides?: Partial<Pick<UploadistaError, "status" | "body">> & {
216
+ details?: unknown;
217
+ cause?: unknown;
218
+ }): Effect.Effect<never, UploadistaError>;
219
+ //#endregion
220
+ export { isUploadistaError as a, httpFailure as i, UploadistaError as n, UploadistaErrorCode as r, ERROR_CATALOG as t };
221
+ //# sourceMappingURL=uploadista-error-D9SONF9K.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploadista-error-D9SONF9K.d.ts","names":[],"sources":["../src/errors/uploadista-error.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAQA;AAwDA;AACS,KAzDG,mBAAA,GAyDH,gBAAA,GAAA,SAAA,GAAA,qBAAA,GAAA,kBAAA,GAAA,sBAAA,GAAA,sBAAA,GAAA,kBAAA,GAAA,qBAAA,GAAA,iBAAA,GAAA,qBAAA,GAAA,gBAAA,GAAA,iBAAA,GAAA,oBAAA,GAAA,gBAAA,GAAA,qBAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,uBAAA,GAAA,mBAAA,GAAA,uBAAA,GAAA,gBAAA,GAAA,kBAAA,GAAA,kBAAA,GAAA,wBAAA,GAAA,eAAA,GAAA,kBAAA,GAAA,qBAAA,GAAA,8BAAA,GAAA,6BAAA,GAAA,mBAAA,GAAA,mBAAA,GAAA,gCAAA;;;;AAmHE;;;;;;;;;;;;;AAwCX;;;;;;AAeU,cA3KG,aA2KH,EA3KkB,QA2KlB,CA1KR,MA0KQ,CA1KD,mBA0KC,EAAA;EAkDA,MAAA,EAAA,MAAA;EACmB,IAAA,EAAA,MAAA;CAAL,CAAA,CAAA;cA1Gb,oBA0GK,EAAA,IAAA,CAAA,gBAAA,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,IAAA,sBAAA,EAAA,EAAA,CAAA,CAAA,CAAA,SAAA,IAAA,GAAA,IAAA,GAAA,iBAAA,OAAA,KAAA,SAAA,MAAA,GAAA,KAAA,IAAA,IAAA,EAAA,CAAA,EAAA,EAAA,kCAAA;EAIX,SAAA,IAAA,EAAA,iBAAA;CAkCkC,WAAA,EAAA,CAAA;;;;;AA4BvC;AAiCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cArKa,eAAA,SAAwB,oBAAA;;;;;;;;;;;;;UAe3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkDA,iCACM,QAAQ,KAAK;;;MAIxB;;;;;;;;;;;;;;;;;;;;;;;;yBAkCoB,MAAA,CAAO,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;iBA4B1B,iBAAA,2BAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiC5C,WAAA,OACR,iCACM,QAAQ,KAAK;;;IAIxB,MAAA,CAAO,cAAc"}
@@ -1,8 +1,10 @@
1
- const e=require(`./chunk-CUT6urMc.cjs`);let t=require(`effect`);t=e.__toESM(t);const n={MISSING_OFFSET:{status:403,body:`Upload-Offset header required
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));let c=require(`effect`);c=s(c);const l={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
5
5
  `},FILE_NOT_FOUND:{status:404,body:`The file for this url was not found
6
+ `},FLOW_NOT_AUTHORIZED:{status:401,body:`The flow is not authorized
7
+ `},FLOW_NOT_FOUND:{status:404,body:`The flow was not found
6
8
  `},FLOW_STRUCTURE_ERROR:{status:500,body:`The flow structure is invalid
7
9
  `},FLOW_CYCLE_ERROR:{status:500,body:`The flow contains a cycle
8
10
  `},FLOW_NODE_NOT_FOUND:{status:500,body:`The flow node was not found
@@ -13,10 +15,15 @@ const e=require(`./chunk-CUT6urMc.cjs`);let t=require(`effect`);t=e.__toESM(t);c
13
15
  `},FLOW_OUTPUT_VALIDATION_ERROR:{status:500,body:`The flow output validation failed
14
16
  `},INVALID_OFFSET:{status:409,body:`Upload-Offset conflict
15
17
  `},FILE_NO_LONGER_EXISTS:{status:410,body:`The file for this url no longer exists
18
+ `},FILE_READ_ERROR:{status:500,body:`Something went wrong reading the file
16
19
  `},ERR_SIZE_EXCEEDED:{status:413,body:`upload's size exceeded
17
20
  `},ERR_MAX_SIZE_EXCEEDED:{status:413,body:`Maximum size exceeded
18
21
  `},INVALID_LENGTH:{status:400,body:`Upload-Length or Upload-Defer-Length header required
19
22
  `},INVALID_METADATA:{status:400,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`},VALIDATION_ERROR:{status:400,body:`Validation failed
23
+ `},STORAGE_NOT_AUTHORIZED:{status:401,body:`The storage is not authorized
20
24
  `},UNKNOWN_ERROR:{status:500,body:`Something went wrong with that request
21
25
  `},FILE_WRITE_ERROR:{status:500,body:`Something went wrong receiving the file
22
- `}};var r=class e extends t.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.details=i,r&&(this.cause=r)}static fromCode(t,r){let i=n[t];return new e({code:t,status:r?.status??i.status,body:r?.body??i.body,details:r?.details,cause:r?.cause})}toEffect(){return t.Effect.fail(this)}};function i(e){return e instanceof r}function a(e,t){return r.fromCode(e,t).toEffect()}Object.defineProperty(exports,`ERROR_CATALOG`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`UploadistaError`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`httpFailureEffect`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`isUploadistaError`,{enumerable:!0,get:function(){return i}});
26
+ `},CHECKSUM_MISMATCH:{status:400,body:`The file checksum does not match the provided checksum
27
+ `},MIMETYPE_MISMATCH:{status:400,body:`The file MIME type does not match the declared type
28
+ `},UNSUPPORTED_CHECKSUM_ALGORITHM:{status:400,body:`The specified checksum algorithm is not supported
29
+ `}};var u=class e extends c.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.details=i,r&&(this.cause=r)}static fromCode(t,n){let r=l[t];return new e({code:t,status:n?.status??r.status,body:n?.body??r.body,details:n?.details,cause:n?.cause})}toEffect(){return c.Effect.fail(this)}};function d(e){return e instanceof u}function f(e,t){return u.fromCode(e,t).toEffect()}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return l}});
@@ -0,0 +1 @@
1
+ require(`../uploadista-error-DdTP-Rjx.cjs`);const e=require(`../checksum-wSBuXX84.cjs`),t=require(`../utils-BLsIUd8c.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;
@@ -0,0 +1,3 @@
1
+ import "../uploadista-error-CAtkQiAv.cjs";
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 "../index-GLPiXqj4.cjs";
3
+ export { ChecksumAlgorithm, GenerateId, GenerateIdLive, GenerateIdRandom, GenerateIdService, GenerateIdShape, GenerateIdTimestamp, Md5, OnceEffect, ThrottleEffect, computeChecksum, isSupportedAlgorithm, once, throttle };
@@ -0,0 +1,3 @@
1
+ import "../uploadista-error-D9SONF9K.js";
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 "../index-DMJv8Tvo.js";
3
+ export { ChecksumAlgorithm, GenerateId, GenerateIdLive, GenerateIdRandom, GenerateIdService, GenerateIdShape, GenerateIdTimestamp, Md5, OnceEffect, ThrottleEffect, computeChecksum, isSupportedAlgorithm, once, throttle };
@@ -0,0 +1 @@
1
+ import"../uploadista-error-CjfcFnVa.js";import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"../checksum-C5qE-5eg.js";import{a as s,i as c,n as l,r as u,t as d}from"../utils-BILytQlb.js";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};
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./uploadista-error-CjfcFnVa.js";import{Effect as t}from"effect";var n=class e{static hashStr(t,n=!1){return e.onePassHasher.start().appendStr(t).end(n)}static hashAsciiStr(t,n=!1){return e.onePassHasher.start().appendAsciiStr(t).end(n)}static stateIdentity=new Int32Array([1732584193,-271733879,-1732584194,271733878]);static buffer32Identity=new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);static hexChars=`0123456789abcdef`;static hexOut=[];static onePassHasher=new e;static _hex(t){let n=e.hexChars,r=e.hexOut,i,a,o,s;for(s=0;s<4;s+=1)for(a=s*8,i=t[s]??0,o=0;o<8;o+=2)r[a+1+o]=n.charAt(i&15),i>>>=4,r[a+0+o]=n.charAt(i&15),i>>>=4;return r.join(``)}static _md5cycle(e,t){let n=e[0]??0,r=e[1]??0,i=e[2]??0,a=e[3]??0;n+=(r&i|~r&a)+(t[0]??0)-680876936|0,n=(n<<7|n>>>25)+r|0,a+=(n&r|~n&i)+(t[1]??0)-389564586|0,a=(a<<12|a>>>20)+n|0,i+=(a&n|~a&r)+(t[2]??0)+606105819|0,i=(i<<17|i>>>15)+a|0,r+=(i&a|~i&n)+(t[3]??0)-1044525330|0,r=(r<<22|r>>>10)+i|0,n+=(r&i|~r&a)+(t[4]??0)-176418897|0,n=(n<<7|n>>>25)+r|0,a+=(n&r|~n&i)+(t[5]??0)+1200080426|0,a=(a<<12|a>>>20)+n|0,i+=(a&n|~a&r)+(t[6]??0)-1473231341|0,i=(i<<17|i>>>15)+a|0,r+=(i&a|~i&n)+(t[7]??0)-45705983|0,r=(r<<22|r>>>10)+i|0,n+=(r&i|~r&a)+(t[8]??0)+1770035416|0,n=(n<<7|n>>>25)+r|0,a+=(n&r|~n&i)+(t[9]??0)-1958414417|0,a=(a<<12|a>>>20)+n|0,i+=(a&n|~a&r)+(t[10]??0)-42063|0,i=(i<<17|i>>>15)+a|0,r+=(i&a|~i&n)+(t[11]??0)-1990404162|0,r=(r<<22|r>>>10)+i|0,n+=(r&i|~r&a)+(t[12]??0)+1804603682|0,n=(n<<7|n>>>25)+r|0,a+=(n&r|~n&i)+(t[13]??0)-40341101|0,a=(a<<12|a>>>20)+n|0,i+=(a&n|~a&r)+(t[14]??0)-1502002290|0,i=(i<<17|i>>>15)+a|0,r+=(i&a|~i&n)+(t[15]??0)+1236535329|0,r=(r<<22|r>>>10)+i|0,n+=(r&a|i&~a)+(t[1]??0)-165796510|0,n=(n<<5|n>>>27)+r|0,a+=(n&i|r&~i)+(t[6]??0)-1069501632|0,a=(a<<9|a>>>23)+n|0,i+=(a&r|n&~r)+(t[11]??0)+643717713|0,i=(i<<14|i>>>18)+a|0,r+=(i&n|a&~n)+(t[0]??0)-373897302|0,r=(r<<20|r>>>12)+i|0,n+=(r&a|i&~a)+(t[5]??0)-701558691|0,n=(n<<5|n>>>27)+r|0,a+=(n&i|r&~i)+(t[10]??0)+38016083|0,a=(a<<9|a>>>23)+n|0,i+=(a&r|n&~r)+(t[15]??0)-660478335|0,i=(i<<14|i>>>18)+a|0,r+=(i&n|a&~n)+(t[4]??0)-405537848|0,r=(r<<20|r>>>12)+i|0,n+=(r&a|i&~a)+(t[9]??0)+568446438|0,n=(n<<5|n>>>27)+r|0,a+=(n&i|r&~i)+(t[14]??0)-1019803690|0,a=(a<<9|a>>>23)+n|0,i+=(a&r|n&~r)+(t[3]??0)-187363961|0,i=(i<<14|i>>>18)+a|0,r+=(i&n|a&~n)+(t[8]??0)+1163531501|0,r=(r<<20|r>>>12)+i|0,n+=(r&a|i&~a)+(t[13]??0)-1444681467|0,n=(n<<5|n>>>27)+r|0,a+=(n&i|r&~i)+(t[2]??0)-51403784|0,a=(a<<9|a>>>23)+n|0,i+=(a&r|n&~r)+(t[7]??0)+1735328473|0,i=(i<<14|i>>>18)+a|0,r+=(i&n|a&~n)+(t[12]??0)-1926607734|0,r=(r<<20|r>>>12)+i|0,n+=(r^i^a)+(t[5]??0)-378558|0,n=(n<<4|n>>>28)+r|0,a+=(n^r^i)+(t[8]??0)-2022574463|0,a=(a<<11|a>>>21)+n|0,i+=(a^n^r)+(t[11]??0)+1839030562|0,i=(i<<16|i>>>16)+a|0,r+=(i^a^n)+(t[14]??0)-35309556|0,r=(r<<23|r>>>9)+i|0,n+=(r^i^a)+(t[1]??0)-1530992060|0,n=(n<<4|n>>>28)+r|0,a+=(n^r^i)+(t[4]??0)+1272893353|0,a=(a<<11|a>>>21)+n|0,i+=(a^n^r)+(t[7]??0)-155497632|0,i=(i<<16|i>>>16)+a|0,r+=(i^a^n)+(t[10]??0)-1094730640|0,r=(r<<23|r>>>9)+i|0,n+=(r^i^a)+(t[13]??0)+681279174|0,n=(n<<4|n>>>28)+r|0,a+=(n^r^i)+(t[0]??0)-358537222|0,a=(a<<11|a>>>21)+n|0,i+=(a^n^r)+(t[3]??0)-722521979|0,i=(i<<16|i>>>16)+a|0,r+=(i^a^n)+(t[6]??0)+76029189|0,r=(r<<23|r>>>9)+i|0,n+=(r^i^a)+(t[9]??0)-640364487|0,n=(n<<4|n>>>28)+r|0,a+=(n^r^i)+(t[12]??0)-421815835|0,a=(a<<11|a>>>21)+n|0,i+=(a^n^r)+(t[15]??0)+530742520|0,i=(i<<16|i>>>16)+a|0,r+=(i^a^n)+(t[2]??0)-995338651|0,r=(r<<23|r>>>9)+i|0,n+=(i^(r|~a))+(t[0]??0)-198630844|0,n=(n<<6|n>>>26)+r|0,a+=(r^(n|~i))+(t[7]??0)+1126891415|0,a=(a<<10|a>>>22)+n|0,i+=(n^(a|~r))+(t[14]??0)-1416354905|0,i=(i<<15|i>>>17)+a|0,r+=(a^(i|~n))+(t[5]??0)-57434055|0,r=(r<<21|r>>>11)+i|0,n+=(i^(r|~a))+(t[12]??0)+1700485571|0,n=(n<<6|n>>>26)+r|0,a+=(r^(n|~i))+(t[3]??0)-1894986606|0,a=(a<<10|a>>>22)+n|0,i+=(n^(a|~r))+(t[10]??0)-1051523|0,i=(i<<15|i>>>17)+a|0,r+=(a^(i|~n))+(t[1]??0)-2054922799|0,r=(r<<21|r>>>11)+i|0,n+=(i^(r|~a))+(t[8]??0)+1873313359|0,n=(n<<6|n>>>26)+r|0,a+=(r^(n|~i))+(t[15]??0)-30611744|0,a=(a<<10|a>>>22)+n|0,i+=(n^(a|~r))+(t[6]??0)-1560198380|0,i=(i<<15|i>>>17)+a|0,r+=(a^(i|~n))+(t[13]??0)+1309151649|0,r=(r<<21|r>>>11)+i|0,n+=(i^(r|~a))+(t[4]??0)-145523070|0,n=(n<<6|n>>>26)+r|0,a+=(r^(n|~i))+(t[11]??0)-1120210379|0,a=(a<<10|a>>>22)+n|0,i+=(n^(a|~r))+(t[2]??0)+718787259|0,i=(i<<15|i>>>17)+a|0,r+=(a^(i|~n))+(t[9]??0)-343485551|0,r=(r<<21|r>>>11)+i|0,e[0]=n+(e[0]??0)|0,e[1]=r+(e[1]??0)|0,e[2]=i+(e[2]??0)|0,e[3]=a+(e[3]??0)|0}_dataLength=0;_bufferLength=0;_state=new Int32Array(4);_buffer=new ArrayBuffer(68);_buffer8;_buffer32;constructor(){this._buffer8=new Uint8Array(this._buffer,0,68),this._buffer32=new Uint32Array(this._buffer,0,17),this.start()}start(){return this._dataLength=0,this._bufferLength=0,this._state.set(e.stateIdentity),this}appendStr(t){let n=this._buffer8,r=this._buffer32,i=this._bufferLength,a,o;for(o=0;o<t.length;o+=1){if(a=t.charCodeAt(o),a<128)n[i++]=a;else if(a<2048)n[i++]=(a>>>6)+192,n[i++]=a&63|128;else if(a<55296||a>56319)n[i++]=(a>>>12)+224,n[i++]=a>>>6&63|128,n[i++]=a&63|128;else{if(a=(a-55296)*1024+(t.charCodeAt(++o)-56320)+65536,a>1114111)throw Error(`Unicode standard supports code points up to U+10FFFF`);n[i++]=(a>>>18)+240,n[i++]=a>>>12&63|128,n[i++]=a>>>6&63|128,n[i++]=a&63|128}i>=64&&(this._dataLength+=64,e._md5cycle(this._state,r),i-=64,r[0]=r[16]??0)}return this._bufferLength=i,this}appendAsciiStr(t){let n=this._buffer8,r=this._buffer32,i=this._bufferLength,a,o=0;for(;;){for(a=Math.min(t.length-o,64-i);a--;)n[i++]=t.charCodeAt(o++);if(i<64)break;this._dataLength+=64,e._md5cycle(this._state,r),i=0}return this._bufferLength=i,this}appendByteArray(t){let n=this._buffer8,r=this._buffer32,i=this._bufferLength,a,o=0;for(;;){for(a=Math.min(t.length-o,64-i);a--;)n[i++]=t[o++]??0;if(i<64)break;this._dataLength+=64,e._md5cycle(this._state,r),i=0}return this._bufferLength=i,this}getState(){let e=this._state;return{buffer:String.fromCharCode.apply(null,Array.from(this._buffer8)),buflen:this._bufferLength,length:this._dataLength,state:[e[0]??0,e[1]??0,e[2]??0,e[3]??0]}}setState(e){let t=e.buffer,n=e.state,r=this._state,i;for(this._dataLength=e.length,this._bufferLength=e.buflen,r[0]=n[0]??0,r[1]=n[1]??0,r[2]=n[2]??0,r[3]=n[3]??0,i=0;i<t.length;i+=1)this._buffer8[i]=t.charCodeAt(i)}end(t=!1){let n=this._bufferLength,r=this._buffer8,i=this._buffer32,a=(n>>2)+1;this._dataLength+=n;let o=this._dataLength*8;if(r[n]=128,r[n+1]=r[n+2]=r[n+3]=0,i.set(e.buffer32Identity.subarray(a),a),n>55&&(e._md5cycle(this._state,i),i.set(e.buffer32Identity)),o<=4294967295)i[14]=o;else{let e=o.toString(16).match(/(.*?)(.{0,8})$/);if(e===null)return;let t=Number.parseInt(e[2]??``,16),n=Number.parseInt(e[1]??``,16)||0;i[14]=t,i[15]=n}return e._md5cycle(this._state,i),t?this._state:e._hex(this._state)}};if(n.hashStr(`hello`)!==`5d41402abc4b2a76b9719d911017c592`)throw Error(`Md5 self test failed.`);function r(e){let t=!1,n;return function(...r){if(t){if(n)return n;throw Error(`Function called more than once`)}return t=!0,n=e.apply(this,r),n}}const i={make:n=>{let r,i=!1;return t.gen(function*(){if(i){if(r!==void 0)return r;yield*new e({code:`UNKNOWN_ERROR`,status:500,body:`Effect called more than once with undefined result`}).toEffect()}return i=!0,r=yield*n,r})},legacy:r},a={leading:!1,trailing:!0};function o(e,t,n={}){let r={...a,...n},i;return function(...n){r.leading&&!i?(console.log(`leading`),e.apply(this,n),i=setTimeout(()=>{i=void 0},t)):(clearTimeout(i),i=setTimeout(()=>{r.trailing?(e.apply(this,n),r.leading&&setTimeout(()=>{i=void 0},t)):i=void 0},t))}}function s(e,t,{leading:n=!0,trailing:r=!0}={}){return o(e,t,{leading:n,trailing:r})}const c={legacy:s};export{n as a,r as i,s as n,i as r,c as t};
2
+ //# sourceMappingURL=utils-BILytQlb.js.map