@based/server 4.0.1 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (438) hide show
  1. package/dist/auth/defaultConfig.d.ts +3 -0
  2. package/dist/auth/defaultConfig.js +12 -0
  3. package/dist/auth/defaultConfig.js.map +1 -0
  4. package/dist/auth/index.d.ts +12 -6
  5. package/dist/auth/index.js +31 -20
  6. package/dist/auth/index.js.map +1 -1
  7. package/dist/auth/parseAuthState.d.ts +2 -1
  8. package/dist/auth/parseAuthState.js +28 -6
  9. package/dist/auth/parseAuthState.js.map +1 -1
  10. package/dist/authorize.d.ts +9 -0
  11. package/dist/authorize.js +59 -0
  12. package/dist/authorize.js.map +1 -0
  13. package/dist/compress.js +3 -0
  14. package/dist/compress.js.map +1 -1
  15. package/dist/createSimpleServer.d.ts +20 -10
  16. package/dist/createSimpleServer.js +64 -53
  17. package/dist/createSimpleServer.js.map +1 -1
  18. package/dist/error/errorTypeHandlers.js +31 -12
  19. package/dist/error/errorTypeHandlers.js.map +1 -1
  20. package/dist/error/index.d.ts +11 -1
  21. package/dist/error/index.js +9 -10
  22. package/dist/error/index.js.map +1 -1
  23. package/dist/error/types.d.ts +41 -45
  24. package/dist/error/types.js +3 -1
  25. package/dist/error/types.js.map +1 -1
  26. package/dist/functionApi/callFunction copy.d.ts +3 -0
  27. package/dist/functionApi/callFunction copy.js +29 -0
  28. package/dist/functionApi/callFunction copy.js.map +1 -0
  29. package/dist/functionApi/callFunction.d.ts +3 -0
  30. package/dist/functionApi/callFunction.js +29 -0
  31. package/dist/functionApi/callFunction.js.map +1 -0
  32. package/dist/functionApi/client/index.d.ts +17 -0
  33. package/dist/functionApi/client/index.js +54 -0
  34. package/dist/functionApi/client/index.js.map +1 -0
  35. package/dist/functionApi/client/query.d.ts +11 -0
  36. package/dist/functionApi/client/query.js +32 -0
  37. package/dist/functionApi/client/query.js.map +1 -0
  38. package/dist/functionApi/get.d.ts +3 -0
  39. package/dist/functionApi/get.js +71 -0
  40. package/dist/functionApi/get.js.map +1 -0
  41. package/dist/functionApi/index.d.ts +5 -0
  42. package/dist/functionApi/index.js +25 -0
  43. package/dist/functionApi/index.js.map +1 -0
  44. package/dist/functionApi/observe.d.ts +4 -0
  45. package/dist/functionApi/observe.js +44 -0
  46. package/dist/functionApi/observe.js.map +1 -0
  47. package/dist/functionApi/stream.d.ts +3 -0
  48. package/dist/functionApi/stream.js +30 -0
  49. package/dist/functionApi/stream.js.map +1 -0
  50. package/dist/functions/index.d.ts +16 -8
  51. package/dist/functions/index.js +39 -10
  52. package/dist/functions/index.js.map +1 -1
  53. package/dist/functions/timeout.d.ts +3 -3
  54. package/dist/functions/timeout.js.map +1 -1
  55. package/dist/functions/types.d.ts +45 -31
  56. package/dist/functions/types.js +40 -12
  57. package/dist/functions/types.js.map +1 -1
  58. package/dist/incoming/http/function.d.ts +3 -4
  59. package/dist/incoming/http/function.js +29 -35
  60. package/dist/incoming/http/function.js.map +1 -1
  61. package/dist/incoming/http/get.d.ts +3 -3
  62. package/dist/incoming/http/get.js +44 -43
  63. package/dist/incoming/http/get.js.map +1 -1
  64. package/dist/incoming/http/index.js +50 -31
  65. package/dist/incoming/http/index.js.map +1 -1
  66. package/dist/incoming/http/parseQuery.d.ts +1 -1
  67. package/dist/incoming/http/parseQuery.js +3 -1
  68. package/dist/incoming/http/parseQuery.js.map +1 -1
  69. package/dist/incoming/http/query.d.ts +4 -0
  70. package/dist/incoming/http/query.js +165 -0
  71. package/dist/incoming/http/query.js.map +1 -0
  72. package/dist/incoming/http/readBody.d.ts +4 -3
  73. package/dist/incoming/http/readBody.js +32 -8
  74. package/dist/incoming/http/readBody.js.map +1 -1
  75. package/dist/incoming/http/streamFunction/DataStream.d.ts +8 -0
  76. package/dist/incoming/http/streamFunction/DataStream.js +42 -3
  77. package/dist/incoming/http/streamFunction/DataStream.js.map +1 -1
  78. package/dist/incoming/http/streamFunction/getExtension.d.ts +1 -1
  79. package/dist/incoming/http/streamFunction/index.d.ts +3 -3
  80. package/dist/incoming/http/streamFunction/index.js +6 -87
  81. package/dist/incoming/http/streamFunction/index.js.map +1 -1
  82. package/dist/incoming/http/streamFunction/multiPart/index.d.ts +4 -0
  83. package/dist/incoming/http/streamFunction/multiPart/index.js +66 -0
  84. package/dist/incoming/http/streamFunction/multiPart/index.js.map +1 -0
  85. package/dist/incoming/http/streamFunction/multiPart/readFormData.d.ts +12 -0
  86. package/dist/incoming/http/streamFunction/{multipartStream.js → multiPart/readFormData.js} +80 -86
  87. package/dist/incoming/http/streamFunction/multiPart/readFormData.js.map +1 -0
  88. package/dist/incoming/http/streamFunction/stream/createStream.d.ts +6 -0
  89. package/dist/incoming/http/streamFunction/{stream.js → stream/createStream.js} +5 -38
  90. package/dist/incoming/http/streamFunction/stream/createStream.js.map +1 -0
  91. package/dist/incoming/http/streamFunction/stream/index.d.ts +4 -0
  92. package/dist/incoming/http/streamFunction/stream/index.js +70 -0
  93. package/dist/incoming/http/streamFunction/stream/index.js.map +1 -0
  94. package/dist/incoming/index.d.ts +1 -1
  95. package/dist/incoming/index.js +13 -11
  96. package/dist/incoming/index.js.map +1 -1
  97. package/dist/incoming/upgrade.js +18 -9
  98. package/dist/incoming/upgrade.js.map +1 -1
  99. package/dist/incoming/ws/auth.d.ts +4 -4
  100. package/dist/incoming/ws/auth.js +37 -19
  101. package/dist/incoming/ws/auth.js.map +1 -1
  102. package/dist/incoming/ws/function.d.ts +2 -3
  103. package/dist/incoming/ws/function.js +21 -73
  104. package/dist/incoming/ws/function.js.map +1 -1
  105. package/dist/incoming/ws/get.d.ts +2 -3
  106. package/dist/incoming/ws/get.js +33 -54
  107. package/dist/incoming/ws/get.js.map +1 -1
  108. package/dist/incoming/ws/index.d.ts +1 -1
  109. package/dist/incoming/ws/index.js +2 -1
  110. package/dist/incoming/ws/index.js.map +1 -1
  111. package/dist/incoming/ws/observable.d.ts +7 -6
  112. package/dist/incoming/ws/observable.js +25 -49
  113. package/dist/incoming/ws/observable.js.map +1 -1
  114. package/dist/incoming/ws/types.d.ts +3 -0
  115. package/dist/{auth → incoming/ws}/types.js +0 -0
  116. package/dist/{auth → incoming/ws}/types.js.map +1 -1
  117. package/dist/index.d.ts +2 -2
  118. package/dist/index.js +2 -2
  119. package/dist/index.js.map +1 -1
  120. package/dist/installFn.d.ts +4 -0
  121. package/dist/installFn.js +94 -0
  122. package/dist/installFn.js.map +1 -0
  123. package/dist/observable/create.d.ts +1 -1
  124. package/dist/observable/create.js +5 -1
  125. package/dist/observable/create.js.map +1 -1
  126. package/dist/observable/destroy.js +1 -1
  127. package/dist/observable/destroy.js.map +1 -1
  128. package/dist/observable/index.d.ts +0 -1
  129. package/dist/observable/index.js +0 -1
  130. package/dist/observable/index.js.map +1 -1
  131. package/dist/observable/send.d.ts +3 -3
  132. package/dist/observable/send.js +2 -8
  133. package/dist/observable/send.js.map +1 -1
  134. package/dist/observable/start/error.d.ts +2 -1
  135. package/dist/observable/start/error.js +13 -11
  136. package/dist/observable/start/error.js.map +1 -1
  137. package/dist/observable/start/index.js +17 -8
  138. package/dist/observable/start/index.js.map +1 -1
  139. package/dist/observable/subscribe.d.ts +3 -3
  140. package/dist/observable/subscribe.js +6 -12
  141. package/dist/observable/subscribe.js.map +1 -1
  142. package/dist/observable/types.d.ts +6 -5
  143. package/dist/observable/unsub.d.ts +1 -1
  144. package/dist/observable/unsub.js.map +1 -1
  145. package/dist/protocol.d.ts +1 -0
  146. package/dist/protocol.js +11 -1
  147. package/dist/protocol.js.map +1 -1
  148. package/dist/security.d.ts +1 -1
  149. package/dist/security.js +1 -1
  150. package/dist/security.js.map +1 -1
  151. package/dist/sendError.d.ts +3 -2
  152. package/dist/sendError.js +30 -16
  153. package/dist/sendError.js.map +1 -1
  154. package/dist/sendHttpResponse.d.ts +3 -2
  155. package/dist/sendHttpResponse.js +62 -10
  156. package/dist/sendHttpResponse.js.map +1 -1
  157. package/dist/server.d.ts +10 -3
  158. package/dist/server.js +16 -4
  159. package/dist/server.js.map +1 -1
  160. package/dist/verifyRoute.d.ts +14 -0
  161. package/dist/verifyRoute.js +99 -0
  162. package/dist/verifyRoute.js.map +1 -0
  163. package/package.json +4 -2
  164. package/dist/BasedServerClient.d.ts +0 -71
  165. package/dist/BasedServerClient.js +0 -390
  166. package/dist/BasedServerClient.js.map +0 -1
  167. package/dist/Client.d.ts +0 -75
  168. package/dist/Client.js +0 -277
  169. package/dist/Client.js.map +0 -1
  170. package/dist/Params.d.ts +0 -20
  171. package/dist/Params.js +0 -48
  172. package/dist/Params.js.map +0 -1
  173. package/dist/api/index.d.ts +0 -7
  174. package/dist/api/index.js +0 -173
  175. package/dist/api/index.js.map +0 -1
  176. package/dist/auth/authorize.d.ts +0 -2
  177. package/dist/auth/authorize.js +0 -8
  178. package/dist/auth/authorize.js.map +0 -1
  179. package/dist/auth/dummyAuth.d.ts +0 -2
  180. package/dist/auth/dummyAuth.js +0 -8
  181. package/dist/auth/dummyAuth.js.map +0 -1
  182. package/dist/auth/types.d.ts +0 -10
  183. package/dist/clientContext.d.ts +0 -0
  184. package/dist/clientContext.js +0 -83
  185. package/dist/clientContext.js.map +0 -1
  186. package/dist/closeListener.d.ts +0 -4
  187. package/dist/closeListener.js +0 -13
  188. package/dist/closeListener.js.map +0 -1
  189. package/dist/context.d.ts +0 -54
  190. package/dist/context.js +0 -18
  191. package/dist/context.js.map +0 -1
  192. package/dist/error.d.ts +0 -66
  193. package/dist/error.js +0 -149
  194. package/dist/error.js.map +0 -1
  195. package/dist/findPrefix.d.ts +0 -3
  196. package/dist/findPrefix.js +0 -20
  197. package/dist/findPrefix.js.map +0 -1
  198. package/dist/functions/workerPool.d.ts +0 -0
  199. package/dist/functions/workerPool.js +0 -5
  200. package/dist/functions/workerPool.js.map +0 -1
  201. package/dist/getFromConfig.d.ts +0 -3
  202. package/dist/getFromConfig.js +0 -50
  203. package/dist/getFromConfig.js.map +0 -1
  204. package/dist/handlers/authorize.d.ts +0 -5
  205. package/dist/handlers/authorize.js +0 -196
  206. package/dist/handlers/authorize.js.map +0 -1
  207. package/dist/handlers/bulkUpdate/index.d.ts +0 -5
  208. package/dist/handlers/bulkUpdate/index.js +0 -26
  209. package/dist/handlers/bulkUpdate/index.js.map +0 -1
  210. package/dist/handlers/configuration/index.d.ts +0 -10
  211. package/dist/handlers/configuration/index.js +0 -74
  212. package/dist/handlers/configuration/index.js.map +0 -1
  213. package/dist/handlers/configuration/observable/index.d.ts +0 -46
  214. package/dist/handlers/configuration/observable/index.js +0 -277
  215. package/dist/handlers/configuration/observable/index.js.map +0 -1
  216. package/dist/handlers/configure/index.d.ts +0 -5
  217. package/dist/handlers/configure/index.js +0 -44
  218. package/dist/handlers/configure/index.js.map +0 -1
  219. package/dist/handlers/copy/index.d.ts +0 -8
  220. package/dist/handlers/copy/index.js +0 -135
  221. package/dist/handlers/copy/index.js.map +0 -1
  222. package/dist/handlers/delete/index.d.ts +0 -5
  223. package/dist/handlers/delete/index.js +0 -34
  224. package/dist/handlers/delete/index.js.map +0 -1
  225. package/dist/handlers/digest/index.d.ts +0 -5
  226. package/dist/handlers/digest/index.js +0 -23
  227. package/dist/handlers/digest/index.js.map +0 -1
  228. package/dist/handlers/functions/call.d.ts +0 -6
  229. package/dist/handlers/functions/call.js +0 -54
  230. package/dist/handlers/functions/call.js.map +0 -1
  231. package/dist/handlers/functions/observable/Observable.d.ts +0 -49
  232. package/dist/handlers/functions/observable/Observable.js +0 -290
  233. package/dist/handlers/functions/observable/Observable.js.map +0 -1
  234. package/dist/handlers/functions/observable/SharedObservable.d.ts +0 -45
  235. package/dist/handlers/functions/observable/SharedObservable.js +0 -291
  236. package/dist/handlers/functions/observable/SharedObservable.js.map +0 -1
  237. package/dist/handlers/functions/observable/index.d.ts +0 -14
  238. package/dist/handlers/functions/observable/index.js +0 -130
  239. package/dist/handlers/functions/observable/index.js.map +0 -1
  240. package/dist/handlers/get/index.d.ts +0 -5
  241. package/dist/handlers/get/index.js +0 -23
  242. package/dist/handlers/get/index.js.map +0 -1
  243. package/dist/handlers/getConfig/index.d.ts +0 -5
  244. package/dist/handlers/getConfig/index.js +0 -38
  245. package/dist/handlers/getConfig/index.js.map +0 -1
  246. package/dist/handlers/handleRequests.d.ts +0 -5
  247. package/dist/handlers/handleRequests.js +0 -78
  248. package/dist/handlers/handleRequests.js.map +0 -1
  249. package/dist/handlers/index.d.ts +0 -4
  250. package/dist/handlers/index.js +0 -49
  251. package/dist/handlers/index.js.map +0 -1
  252. package/dist/handlers/messageParser.d.ts +0 -5
  253. package/dist/handlers/messageParser.js +0 -122
  254. package/dist/handlers/messageParser.js.map +0 -1
  255. package/dist/handlers/removeField/index.d.ts +0 -5
  256. package/dist/handlers/removeField/index.js +0 -42
  257. package/dist/handlers/removeField/index.js.map +0 -1
  258. package/dist/handlers/removeType/index.d.ts +0 -5
  259. package/dist/handlers/removeType/index.js +0 -30
  260. package/dist/handlers/removeType/index.js.map +0 -1
  261. package/dist/handlers/rest/file/DataStream.d.ts +0 -7
  262. package/dist/handlers/rest/file/DataStream.js +0 -17
  263. package/dist/handlers/rest/file/DataStream.js.map +0 -1
  264. package/dist/handlers/rest/file/formStream.d.ts +0 -4
  265. package/dist/handlers/rest/file/formStream.js +0 -188
  266. package/dist/handlers/rest/file/formStream.js.map +0 -1
  267. package/dist/handlers/rest/file/getExtenstion.d.ts +0 -2
  268. package/dist/handlers/rest/file/getExtenstion.js +0 -22
  269. package/dist/handlers/rest/file/getExtenstion.js.map +0 -1
  270. package/dist/handlers/rest/file/index.d.ts +0 -4
  271. package/dist/handlers/rest/file/index.js +0 -53
  272. package/dist/handlers/rest/file/index.js.map +0 -1
  273. package/dist/handlers/rest/file/storeFile.d.ts +0 -6
  274. package/dist/handlers/rest/file/storeFile.js +0 -44
  275. package/dist/handlers/rest/file/storeFile.js.map +0 -1
  276. package/dist/handlers/rest/file/stream.d.ts +0 -5
  277. package/dist/handlers/rest/file/stream.js +0 -104
  278. package/dist/handlers/rest/file/stream.js.map +0 -1
  279. package/dist/handlers/rest/file/types.d.ts +0 -9
  280. package/dist/handlers/rest/file/types.js +0 -3
  281. package/dist/handlers/rest/file/types.js.map +0 -1
  282. package/dist/handlers/rest/getReqMessage.d.ts +0 -3
  283. package/dist/handlers/rest/getReqMessage.js +0 -92
  284. package/dist/handlers/rest/getReqMessage.js.map +0 -1
  285. package/dist/handlers/rest/index.d.ts +0 -4
  286. package/dist/handlers/rest/index.js +0 -121
  287. package/dist/handlers/rest/index.js.map +0 -1
  288. package/dist/handlers/rest/invalidReq.d.ts +0 -4
  289. package/dist/handlers/rest/invalidReq.js +0 -20
  290. package/dist/handlers/rest/invalidReq.js.map +0 -1
  291. package/dist/handlers/rest/parseResponse.d.ts +0 -6
  292. package/dist/handlers/rest/parseResponse.js +0 -230
  293. package/dist/handlers/rest/parseResponse.js.map +0 -1
  294. package/dist/handlers/rest/playground/index.d.ts +0 -5
  295. package/dist/handlers/rest/playground/index.js +0 -308
  296. package/dist/handlers/rest/playground/index.js.map +0 -1
  297. package/dist/handlers/rest/readBody.d.ts +0 -3
  298. package/dist/handlers/rest/readBody.js +0 -45
  299. package/dist/handlers/rest/readBody.js.map +0 -1
  300. package/dist/handlers/set/index.d.ts +0 -5
  301. package/dist/handlers/set/index.js +0 -20
  302. package/dist/handlers/set/index.js.map +0 -1
  303. package/dist/handlers/subscription/index.d.ts +0 -32
  304. package/dist/handlers/subscription/index.js +0 -223
  305. package/dist/handlers/subscription/index.js.map +0 -1
  306. package/dist/handlers/token.d.ts +0 -5
  307. package/dist/handlers/token.js +0 -122
  308. package/dist/handlers/token.js.map +0 -1
  309. package/dist/handlers/track/index.d.ts +0 -7
  310. package/dist/handlers/track/index.js +0 -102
  311. package/dist/handlers/track/index.js.map +0 -1
  312. package/dist/handlers/userAuth/index.d.ts +0 -5
  313. package/dist/handlers/userAuth/index.js +0 -78
  314. package/dist/handlers/userAuth/index.js.map +0 -1
  315. package/dist/incoming/http/authorize.d.ts +0 -4
  316. package/dist/incoming/http/authorize.js +0 -37
  317. package/dist/incoming/http/authorize.js.map +0 -1
  318. package/dist/incoming/http/streamFunction/multipartStream.d.ts +0 -13
  319. package/dist/incoming/http/streamFunction/multipartStream.js.map +0 -1
  320. package/dist/incoming/http/streamFunction/stream.d.ts +0 -6
  321. package/dist/incoming/http/streamFunction/stream.js.map +0 -1
  322. package/dist/network/http/authorize.d.ts +0 -3
  323. package/dist/network/http/authorize.js +0 -28
  324. package/dist/network/http/authorize.js.map +0 -1
  325. package/dist/network/http/compress.d.ts +0 -6
  326. package/dist/network/http/compress.js +0 -56
  327. package/dist/network/http/compress.js.map +0 -1
  328. package/dist/network/http/end.d.ts +0 -4
  329. package/dist/network/http/end.js +0 -19
  330. package/dist/network/http/end.js.map +0 -1
  331. package/dist/network/http/function.d.ts +0 -3
  332. package/dist/network/http/function.js +0 -47
  333. package/dist/network/http/function.js.map +0 -1
  334. package/dist/network/http/get.d.ts +0 -3
  335. package/dist/network/http/get.js +0 -129
  336. package/dist/network/http/get.js.map +0 -1
  337. package/dist/network/http/index.d.ts +0 -3
  338. package/dist/network/http/index.js +0 -122
  339. package/dist/network/http/index.js.map +0 -1
  340. package/dist/network/http/readBody.d.ts +0 -3
  341. package/dist/network/http/readBody.js +0 -112
  342. package/dist/network/http/readBody.js.map +0 -1
  343. package/dist/network/http/send.d.ts +0 -5
  344. package/dist/network/http/send.js +0 -60
  345. package/dist/network/http/send.js.map +0 -1
  346. package/dist/network/http/streamFunction/DataStream.d.ts +0 -7
  347. package/dist/network/http/streamFunction/DataStream.js +0 -19
  348. package/dist/network/http/streamFunction/DataStream.js.map +0 -1
  349. package/dist/network/http/streamFunction/getExtension.d.ts +0 -2
  350. package/dist/network/http/streamFunction/getExtension.js +0 -29
  351. package/dist/network/http/streamFunction/getExtension.js.map +0 -1
  352. package/dist/network/http/streamFunction/index.d.ts +0 -3
  353. package/dist/network/http/streamFunction/index.js +0 -81
  354. package/dist/network/http/streamFunction/index.js.map +0 -1
  355. package/dist/network/http/streamFunction/multipartStream.d.ts +0 -12
  356. package/dist/network/http/streamFunction/multipartStream.js +0 -208
  357. package/dist/network/http/streamFunction/multipartStream.js.map +0 -1
  358. package/dist/network/http/streamFunction/stream.d.ts +0 -5
  359. package/dist/network/http/streamFunction/stream.js +0 -103
  360. package/dist/network/http/streamFunction/stream.js.map +0 -1
  361. package/dist/network/index.d.ts +0 -4
  362. package/dist/network/index.js +0 -84
  363. package/dist/network/index.js.map +0 -1
  364. package/dist/network/message/auth.d.ts +0 -4
  365. package/dist/network/message/auth.js +0 -32
  366. package/dist/network/message/auth.js.map +0 -1
  367. package/dist/network/message/function.d.ts +0 -3
  368. package/dist/network/message/function.js +0 -67
  369. package/dist/network/message/function.js.map +0 -1
  370. package/dist/network/message/get.d.ts +0 -3
  371. package/dist/network/message/get.js +0 -109
  372. package/dist/network/message/get.js.map +0 -1
  373. package/dist/network/message/index.d.ts +0 -3
  374. package/dist/network/message/index.js +0 -62
  375. package/dist/network/message/index.js.map +0 -1
  376. package/dist/network/message/observable.d.ts +0 -5
  377. package/dist/network/message/observable.js +0 -103
  378. package/dist/network/message/observable.js.map +0 -1
  379. package/dist/network/message/send.d.ts +0 -4
  380. package/dist/network/message/send.js +0 -11
  381. package/dist/network/message/send.js.map +0 -1
  382. package/dist/network/upgrade.d.ts +0 -4
  383. package/dist/network/upgrade.js +0 -49
  384. package/dist/network/upgrade.js.map +0 -1
  385. package/dist/network/worker/get.d.ts +0 -0
  386. package/dist/network/worker/get.js +0 -122
  387. package/dist/network/worker/get.js.map +0 -1
  388. package/dist/network/worker/observable.d.ts +0 -0
  389. package/dist/network/worker/observable.js +0 -120
  390. package/dist/network/worker/observable.js.map +0 -1
  391. package/dist/observable/error.d.ts +0 -4
  392. package/dist/observable/error.js +0 -17
  393. package/dist/observable/error.js.map +0 -1
  394. package/dist/observable/verify.d.ts +0 -4
  395. package/dist/observable/verify.js +0 -18
  396. package/dist/observable/verify.js.map +0 -1
  397. package/dist/openListener.d.ts +0 -4
  398. package/dist/openListener.js +0 -13
  399. package/dist/openListener.js.map +0 -1
  400. package/dist/secrets.d.ts +0 -9
  401. package/dist/secrets.js +0 -150
  402. package/dist/secrets.js.map +0 -1
  403. package/dist/security/index.d.ts +0 -3
  404. package/dist/security/index.js +0 -66
  405. package/dist/security/index.js.map +0 -1
  406. package/dist/types.d.ts +0 -129
  407. package/dist/types.js +0 -17
  408. package/dist/types.js.map +0 -1
  409. package/dist/upgradeListener.d.ts +0 -4
  410. package/dist/upgradeListener.js +0 -47
  411. package/dist/upgradeListener.js.map +0 -1
  412. package/dist/worker/authorize.d.ts +0 -5
  413. package/dist/worker/authorize.js +0 -15
  414. package/dist/worker/authorize.js.map +0 -1
  415. package/dist/worker/fnMap.d.ts +0 -2
  416. package/dist/worker/fnMap.js +0 -5
  417. package/dist/worker/fnMap.js.map +0 -1
  418. package/dist/worker/functions.d.ts +0 -3
  419. package/dist/worker/functions.js +0 -8
  420. package/dist/worker/functions.js.map +0 -1
  421. package/dist/worker/http/function.d.ts +0 -4
  422. package/dist/worker/http/function.js +0 -75
  423. package/dist/worker/http/function.js.map +0 -1
  424. package/dist/worker/index.d.ts +0 -1
  425. package/dist/worker/index.js +0 -101
  426. package/dist/worker/index.js.map +0 -1
  427. package/dist/worker/observable.d.ts +0 -15
  428. package/dist/worker/observable.js +0 -110
  429. package/dist/worker/observable.js.map +0 -1
  430. package/dist/worker/ws/function.d.ts +0 -3
  431. package/dist/worker/ws/function.js +0 -42
  432. package/dist/worker/ws/function.js.map +0 -1
  433. package/dist/workers/index.d.ts +0 -0
  434. package/dist/workers/index.js +0 -20
  435. package/dist/workers/index.js.map +0 -1
  436. package/dist/workers/workerCode.d.ts +0 -12
  437. package/dist/workers/workerCode.js +0 -46
  438. package/dist/workers/workerCode.js.map +0 -1
@@ -3,23 +3,45 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.readBody = void 0;
6
+ exports.readBody = exports.parseHttpPayload = void 0;
7
7
  const node_zlib_1 = __importDefault(require("node:zlib"));
8
8
  const error_1 = require("../../error");
9
9
  const sendError_1 = require("../../sendError");
10
- // TODO: might be good to use worker stream as well for this
10
+ const decoder = new TextDecoder('utf-8');
11
11
  const MAX_CHUNK_SIZE = 1024 * 1024;
12
12
  const UNCOMPRESS_OPTS = {
13
13
  // can be endless scince we limit by incoming
14
14
  chunkSize: 1024 * 1024 * 1000,
15
15
  };
16
+ const parseHttpPayload = (server, ctx, data, route) => {
17
+ const contentType = ctx.session.headers['content-type'];
18
+ if (contentType === 'application/json' || !contentType) {
19
+ const str = decoder.decode(data);
20
+ let parsedData;
21
+ try {
22
+ parsedData = data.byteLength ? JSON.parse(str) : undefined;
23
+ return parsedData;
24
+ }
25
+ catch (err) {
26
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.InvalidPayload, { route });
27
+ }
28
+ }
29
+ else if (contentType.startsWith('text') ||
30
+ contentType === 'application/xml') {
31
+ return decoder.decode(data);
32
+ }
33
+ else {
34
+ return data;
35
+ }
36
+ };
37
+ exports.parseHttpPayload = parseHttpPayload;
16
38
  const readBody = (server, ctx, onData, route) => {
17
39
  if (!ctx.session) {
18
40
  return;
19
41
  }
20
42
  const contentLen = ctx.session.headers['content-length'];
21
43
  if (contentLen > route.maxPayloadSize) {
22
- (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, route);
44
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, { route });
23
45
  return;
24
46
  }
25
47
  const contentEncoding = ctx.session.headers['content-encoding'];
@@ -39,7 +61,7 @@ const readBody = (server, ctx, onData, route) => {
39
61
  ctx.session.res.onData((c, isLast) => {
40
62
  size += c.byteLength;
41
63
  if (size > route.maxPayloadSize) {
42
- (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, route);
64
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, { route });
43
65
  uncompressStream.destroy();
44
66
  return;
45
67
  }
@@ -74,11 +96,12 @@ const readBody = (server, ctx, onData, route) => {
74
96
  buf.set(c, i);
75
97
  i += c.byteLength;
76
98
  }
77
- onData(buf);
99
+ // readValue
100
+ onData((0, exports.parseHttpPayload)(server, ctx, buf, route));
78
101
  });
79
102
  }
80
103
  else {
81
- (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.InvalidPayload, route);
104
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.InvalidPayload, { route });
82
105
  }
83
106
  }
84
107
  else {
@@ -88,7 +111,7 @@ const readBody = (server, ctx, onData, route) => {
88
111
  const len = c.byteLength;
89
112
  size += len;
90
113
  if (size > route.maxPayloadSize) {
91
- (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, route);
114
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, { route });
92
115
  return;
93
116
  }
94
117
  if (c.byteLength > MAX_CHUNK_SIZE) {
@@ -98,7 +121,8 @@ const readBody = (server, ctx, onData, route) => {
98
121
  buf.set(new Uint8Array(c), index);
99
122
  index += len;
100
123
  if (isLast) {
101
- onData(buf);
124
+ // readValue
125
+ onData((0, exports.parseHttpPayload)(server, ctx, buf, route));
102
126
  }
103
127
  });
104
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"readBody.js","sourceRoot":"","sources":["../../../src/incoming/http/readBody.ts"],"names":[],"mappings":";;;;;;AACA,0DAA4B;AAE5B,uCAA4C;AAE5C,+CAA2C;AAE3C,4DAA4D;AAE5D,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAA;AAElC,MAAM,eAAe,GAAG;IACtB,6CAA6C;IAC7C,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI;CAC9B,CAAA;AAEM,MAAM,QAAQ,GAAG,CACtB,MAAmB,EACnB,GAAyB,EACzB,MAAkC,EAClC,KAA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E,EAAE;YACnC,MAAM,GAAG,GAAG,CAAC,CAAC,UAAU,CAAA;YAExB,IAAI,IAAI,GAAG,CAAA;YACX,IAAI,IAAI,GAAG,KAAK,CAAC,cAAc,EAAE;gBAC/B,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;gBACjE,OAAM;aACP;YACD,IAAI,CAAC,CAAC,UAAU,GAAG,cAAc,EAAE;gBACjC,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA;gBAC3D,OAAM;aACP;YAED,GAAG,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;YACjC,KAAK,IAAI,GAAG,CAAA;YAEZ,IAAI,MAAM,EAAE;gBACV,YAAY;gBACZ,MAAM,CAAC,IAAA,wBAAgB,EAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;aAClD;QACH,CAAC,CAAC,CAAA;KACH;AACH,CAAC,CAAA;AAlGY,QAAA,QAAQ,YAkGpB"}
@@ -1,7 +1,15 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
2
4
  import { Duplex } from 'stream';
5
+ import util from 'node:util';
3
6
  export declare class DataStream extends Duplex {
7
+ size: number;
8
+ receivedBytes: number;
9
+ progessTimer: NodeJS.Timeout;
10
+ constructor(size: number);
4
11
  _read(): void;
5
12
  _write(chunk: any, encoding: any, callback: any): void;
6
13
  _final(): void;
14
+ [util.inspect.custom](): string;
7
15
  }
@@ -1,19 +1,58 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.DataStream = void 0;
4
7
  const stream_1 = require("stream");
5
- // copy / ;/ or shall we just run stream functions on the main thread
6
- // how to send to worker...
8
+ const node_util_1 = __importDefault(require("node:util"));
7
9
  class DataStream extends stream_1.Duplex {
10
+ constructor(size) {
11
+ super();
12
+ this.size = 0;
13
+ this.receivedBytes = 0;
14
+ this.size = size;
15
+ this.emit('progress', 0);
16
+ }
8
17
  _read() { }
9
- // writableHighWaterMark:
10
18
  _write(chunk, encoding, callback) {
19
+ this.receivedBytes += chunk.byteLength;
20
+ if (this.size && this.size > 20000) {
21
+ if (!this.progessTimer) {
22
+ this.progessTimer = setTimeout(() => {
23
+ const progress = this.receivedBytes / this.size;
24
+ this.emit('progress', progress);
25
+ this.progessTimer = null;
26
+ }, 200);
27
+ }
28
+ }
11
29
  this.push(Buffer.from(chunk, encoding));
12
30
  callback();
13
31
  }
14
32
  _final() {
33
+ if (!this.size) {
34
+ this.size = this.receivedBytes;
35
+ }
36
+ this.receivedBytes = this.size;
37
+ if (this.progessTimer) {
38
+ clearTimeout(this.progessTimer);
39
+ this.progessTimer = null;
40
+ }
41
+ this.emit('progress', 1);
15
42
  this.push(null);
16
43
  }
44
+ [node_util_1.default.inspect.custom]() {
45
+ if (this.size) {
46
+ const rb = this.receivedBytes < 1000
47
+ ? Math.round(this.receivedBytes / 1024) + 'kb'
48
+ : Math.round(this.receivedBytes / 1024 / 1024) + 'mb';
49
+ return `[BasedStream ${~~((this.receivedBytes / this.size) *
50
+ 100)}% ${rb}]`;
51
+ }
52
+ else {
53
+ return `[BasedStream]`;
54
+ }
55
+ }
17
56
  }
18
57
  exports.DataStream = DataStream;
19
58
  //# sourceMappingURL=DataStream.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataStream.js","sourceRoot":"","sources":["../../../../src/incoming/http/streamFunction/DataStream.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAE/B,qEAAqE;AAErE,2BAA2B;AAC3B,MAAa,UAAW,SAAQ,eAAM;IACpC,KAAK,KAAI,CAAC;IAEV,yBAAyB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AAK,EAAE,QAAQ,CAAC,CAAC,CAAA;QACvC,QAAQ,EAAE,CAAA;IACZ,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,aAAa,CAAA;SAC/B;QACD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,IAAI,CAAA;QAC9B,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YAC/B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;SACzB;QACD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAA;QACxB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjB,CAAC;IAED,CAAC,mBAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QACnB,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,MAAM,EAAE,GACN,IAAI,CAAC,aAAa,GAAG,IAAI;gBACvB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,IAAI;gBAC9C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;YAEzD,OAAO,gBAAgB,CAAC,CAAC,CACvB,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC;gBAChC,GAAG,CACJ,KAAK,EAAE,GAAG,CAAA;SACZ;aAAM;YACL,OAAO,eAAe,CAAA;SACvB;IACH,CAAC;CACF;AAxDD,gCAwDC"}
@@ -1,2 +1,2 @@
1
- declare const _default: (mimeType: string) => any;
1
+ declare const _default: (mimeType: string) => string | false;
2
2
  export default _default;
@@ -1,4 +1,4 @@
1
1
  import { BasedServer } from '../../../server';
2
- import { BasedFunctionRoute } from '../../../functions';
3
- import { HttpSession, Context } from '../../../context';
4
- export declare const httpStreamFunction: (server: BasedServer, ctx: Context<HttpSession>, payload: any, route: BasedFunctionRoute) => void;
2
+ import { BasedStreamFunctionRoute } from '../../../functions';
3
+ import { HttpSession, Context } from '@based/functions';
4
+ export declare const httpStreamFunction: (server: BasedServer, ctx: Context<HttpSession>, route: BasedStreamFunctionRoute) => void;
@@ -1,106 +1,25 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.httpStreamFunction = void 0;
7
- const stream_1 = __importDefault(require("./stream"));
8
4
  const sendError_1 = require("../../../sendError");
9
- const functions_1 = require("../../../functions");
10
- const authorize_1 = require("../authorize");
11
5
  const error_1 = require("../../../error");
12
- const multipartStream_1 = __importDefault(require("./multipartStream"));
13
- const sendHttpResponse_1 = require("../../../sendHttpResponse");
14
- const httpStreamFunction = (server, ctx, payload, route) => {
6
+ const multiPart_1 = require("./multiPart");
7
+ const stream_1 = require("./stream");
8
+ const httpStreamFunction = (server, ctx, route) => {
15
9
  if (!ctx.session) {
16
10
  return;
17
11
  }
18
12
  const size = ctx.session.headers['content-length'];
19
13
  if (route.maxPayloadSize > -1 && route.maxPayloadSize < size) {
20
- (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, route);
14
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, { route });
21
15
  return;
22
16
  }
23
17
  const type = ctx.session.headers['content-type'];
24
- // replace this with transder encoding 'chunked'
25
18
  if (type && type.startsWith('multipart/form-data')) {
26
- const files = [];
27
- let thisIsFn;
28
- (0, multipartStream_1.default)(ctx, server, payload, route, (p) => {
29
- return new Promise((resolve) => {
30
- (0, authorize_1.authorizeRequest)(server, ctx, p.payload, route, () => {
31
- if (!thisIsFn) {
32
- files.push({ p, resolve });
33
- }
34
- else {
35
- resolve(thisIsFn(p, ctx));
36
- }
37
- }, () => {
38
- resolve(undefined);
39
- });
40
- });
41
- });
42
- server.functions
43
- .install(route.name)
44
- .then((spec) => {
45
- if (spec && !(0, functions_1.isObservableFunctionSpec)(spec) && spec.stream) {
46
- thisIsFn = spec.function;
47
- if (files.length) {
48
- for (const file of files) {
49
- console.info('File parsed before fn / auth');
50
- file.resolve(thisIsFn(file.p, ctx));
51
- }
52
- }
53
- }
54
- else {
55
- (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, route);
56
- }
57
- })
58
- .catch(() => {
59
- (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, route);
60
- });
19
+ (0, multiPart_1.multiPart)(server, ctx, route);
61
20
  return;
62
21
  }
63
- const stream = (0, stream_1.default)(server, route, ctx, size);
64
- // destroy stream from context
65
- (0, authorize_1.authorizeRequest)(server, ctx, payload, route, (payload) => {
66
- server.functions
67
- .install(route.name)
68
- .then((spec) => {
69
- if (spec && !(0, functions_1.isObservableFunctionSpec)(spec) && spec.stream) {
70
- // const stream = createDataStream(server, route, client, size)
71
- const streamPayload = { payload, stream };
72
- const fn = spec.function;
73
- fn(streamPayload, ctx)
74
- .catch((err) => {
75
- stream.destroy();
76
- (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionError, {
77
- err,
78
- route,
79
- });
80
- })
81
- .then((r) => {
82
- if (stream.readableEnded ||
83
- stream.listenerCount('data') === 0) {
84
- (0, sendHttpResponse_1.sendHttpResponse)(ctx, r);
85
- }
86
- else {
87
- stream.on('end', () => {
88
- (0, sendHttpResponse_1.sendHttpResponse)(ctx, r);
89
- });
90
- }
91
- });
92
- }
93
- else {
94
- (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, route);
95
- }
96
- })
97
- .catch((err) => {
98
- console.error(err);
99
- (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, route);
100
- });
101
- }, () => {
102
- stream.destroy();
103
- });
22
+ (0, stream_1.singleStream)(server, ctx, route, type, size);
104
23
  };
105
24
  exports.httpStreamFunction = httpStreamFunction;
106
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/incoming/http/streamFunction/index.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAuC;AAEvC,kDAA8C;AAC9C,kDAG2B;AAE3B,4CAA+C;AAC/C,0CAA+C;AAC/C,wEAA+C;AAC/C,gEAA4D;AAErD,MAAM,kBAAkB,GAAG,CAChC,MAAmB,EACnB,GAAyB,EACzB,OAAY,EACZ,KAAyB,EACzB,EAAE;IACF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,OAAM;KACP;IAED,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAElD,IAAI,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,cAAc,GAAG,IAAI,EAAE;QAC5D,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,eAAe,EAAE,KAAK,CAAC,CAAA;QAC7D,OAAM;KACP;IAED,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IAEhD,gDAAgD;IAChD,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,EAAE;QAClD,MAAM,KAAK,GAAU,EAAE,CAAA;QACvB,IAAI,QAAkB,CAAA;QAEtB,IAAA,yBAAe,EAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;YACjD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC7B,IAAA,4BAAgB,EACd,MAAM,EACN,GAAG,EACH,CAAC,CAAC,OAAO,EACT,KAAK,EACL,GAAG,EAAE;oBACH,IAAI,CAAC,QAAQ,EAA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CAAA;YAClB,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;QAChE,CAAC,CAAC,CAAA;IACN,CAAC,EACD,GAAG,EAAE;QACH,MAAM,CAAC,OAAO,EAAE,CAAA;IAClB,CAAC,CACF,CAAA;AACH,CAAC,CAAA;AAtHY,QAAA,kBAAkB,sBAsH9B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/incoming/http/streamFunction/index.ts"],"names":[],"mappings":";;;AACA,kDAA8C;AAG9C,0CAA+C;AAC/C,2CAAuC;AACvC,qCAAuC;AAEhC,MAAM,kBAAkB,GAAG,CAChC,MAAmB,EACnB,GAAyB,EACzB,KAA+B,EAC/B,EAAE;IACF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,OAAM;KACP;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAClD,IAAI,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,cAAc,GAAG,IAAI,EAAE;QAC5D,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QACjE,OAAM;KACP;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IAChD,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,EAAE;QAClD,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;QAC7B,OAAM;KACP;IACD,IAAA,qBAAY,EAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAC9C,CAAC,CAAA;AAnBY,QAAA,kBAAkB,sBAmB9B"}
@@ -0,0 +1,4 @@
1
+ import { HttpSession, Context } from '@based/functions';
2
+ import { BasedServer } from '../../../../server';
3
+ import { BasedStreamFunctionRoute } from '../../../../functions';
4
+ export declare const multiPart: (server: BasedServer, ctx: Context<HttpSession>, route: BasedStreamFunctionRoute) => void;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.multiPart = void 0;
7
+ const installFn_1 = require("../../../../installFn");
8
+ const readFormData_1 = __importDefault(require("./readFormData"));
9
+ const error_1 = require("../../../../error");
10
+ const sendHttpResponse_1 = require("../../../../sendHttpResponse");
11
+ const handleFile = async (server, ctx, installedFn, file, route) => {
12
+ try {
13
+ const ok = await server.auth.authorize(server.client, ctx, route.name, file);
14
+ if (!ok) {
15
+ return {
16
+ error: (0, error_1.createErrorData)(error_1.BasedErrorCode.AuthorizeRejectedError, {
17
+ route,
18
+ }),
19
+ };
20
+ }
21
+ }
22
+ catch (err) {
23
+ return {
24
+ error: (0, error_1.createErrorData)(error_1.BasedErrorCode.AuthorizeFunctionError, {
25
+ route,
26
+ err,
27
+ }),
28
+ };
29
+ }
30
+ const spec = await installedFn;
31
+ if (spec === null) {
32
+ return {
33
+ error: (0, error_1.createErrorData)(error_1.BasedErrorCode.FunctionNotFound, {
34
+ route,
35
+ }),
36
+ };
37
+ }
38
+ try {
39
+ const value = await spec.function(server.client, file, ctx);
40
+ return { value };
41
+ }
42
+ catch (err) {
43
+ return {
44
+ error: (0, error_1.createErrorData)(error_1.BasedErrorCode.FunctionError, { err, route }),
45
+ };
46
+ }
47
+ };
48
+ const multiPart = (server, ctx, route) => {
49
+ ctx.session.res.cork(() => {
50
+ ctx.session.res.writeHeader('Access-Control-Allow-Origin', '*');
51
+ ctx.session.res.writeHeader('Access-Control-Allow-Headers', '*');
52
+ ctx.session.corsSend = true;
53
+ });
54
+ const installedFn = (0, installFn_1.installFn)(server, server.client.ctx, route);
55
+ const pendingFiles = [];
56
+ const onFile = (file) => {
57
+ pendingFiles.push(handleFile(server, ctx, installedFn, file, route));
58
+ };
59
+ const ready = async () => {
60
+ const results = await Promise.all(pendingFiles);
61
+ (0, sendHttpResponse_1.sendHttpResponse)(ctx, results);
62
+ };
63
+ (0, readFormData_1.default)(ctx, server, route, onFile, ready);
64
+ };
65
+ exports.multiPart = multiPart;
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/incoming/http/streamFunction/multiPart/index.ts"],"names":[],"mappings":";;;;;;AAMA,qDAAiD;AACjD,kEAAyC;AACzC,6CAI0B;AAC1B,mEAA+D;AAE/D,MAAM,UAAU,GAAG,KAAK,EACtB,MAAmB,EACnB,GAAyB,EACzB,WAAoD,EACpD,IAAmB,EACnB,KAA+B,EAW/B,EAAE;IACF,IAAI;QACF,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAC5E,IAAI,CAAC,EAAE,EAAE;YACP,OAAO;gBACL,KAAK,EAAE,IAAA,uBAAe,EAAC,sBAAc,CAAC,sBAAsB,EAAE;oBAC5D,KAAK;iBACN,CAAC;aACH,CAAA;SACF;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO;YACL,KAAK,EAAE,IAAA,uBAAe,EAAC,sBAAc,CAAC,sBAAsB,EAAE;gBAC5D,KAAK;gBACL,GAAG;aACJ,CAAC;SACH,CAAA;KACF;IAED,MAAM,IAAI,GAAG,MAAM,WAAW,CAAA;IAE9B,IAAI,IAAI,KAAK,IAAI,EAAE;QACjB,OAAO;YACL,KAAK,EAAE,IAAA,uBAAe,EAAC,sBAAc,CAAC,gBAAgB,EAAE;gBACtD,KAAK;aACN,CAAC;SACH,CAAA;KACF;IACD,IAA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AAA;IAED,IAAA,sBAAY,EAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AACjD,CAAC,CAAA;AAzBY,QAAA,SAAS,aAyBrB"}
@@ -0,0 +1,12 @@
1
+ import { HttpSession, Context, StreamPayload } from '@based/functions';
2
+ import { BasedServer } from '../../../../server';
3
+ import { BasedFunctionRoute } from '../../../../functions';
4
+ export declare type FileOptions = {
5
+ name?: string;
6
+ size?: number;
7
+ type: string;
8
+ extension: string;
9
+ payload: any;
10
+ };
11
+ declare const _default: (ctx: Context<HttpSession>, server: BasedServer, route: BasedFunctionRoute, onFile: (payload: StreamPayload) => void, isReady: () => void) => void;
12
+ export default _default;