@based/server 3.4.5 → 4.0.0

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 (396) hide show
  1. package/dist/api/index.d.ts +7 -0
  2. package/dist/api/index.js +173 -0
  3. package/dist/api/index.js.map +1 -0
  4. package/dist/auth/dummyAuth.d.ts +1 -1
  5. package/dist/auth/dummyAuth.js +3 -2
  6. package/dist/auth/dummyAuth.js.map +1 -1
  7. package/dist/auth/index.d.ts +8 -4
  8. package/dist/auth/index.js +28 -23
  9. package/dist/auth/index.js.map +1 -1
  10. package/dist/auth/parseAuthState.d.ts +2 -0
  11. package/dist/auth/parseAuthState.js +16 -0
  12. package/dist/auth/parseAuthState.js.map +1 -0
  13. package/dist/auth/types.d.ts +10 -0
  14. package/dist/{handlers/rest/file → auth}/types.js +0 -0
  15. package/dist/auth/types.js.map +1 -0
  16. package/dist/compress.d.ts +5 -0
  17. package/dist/{network/http/compress.js → compress.js} +2 -6
  18. package/dist/compress.js.map +1 -0
  19. package/dist/context.d.ts +54 -0
  20. package/dist/context.js +18 -0
  21. package/dist/context.js.map +1 -0
  22. package/dist/error/errorTypeHandlers.d.ts +6 -0
  23. package/dist/error/errorTypeHandlers.js +130 -0
  24. package/dist/error/errorTypeHandlers.js.map +1 -0
  25. package/dist/error/index.d.ts +5 -0
  26. package/dist/error/index.js +61 -0
  27. package/dist/error/index.js.map +1 -0
  28. package/dist/error/types.d.ts +105 -0
  29. package/dist/error/types.js +30 -0
  30. package/dist/error/types.js.map +1 -0
  31. package/dist/functions/index.d.ts +10 -24
  32. package/dist/functions/index.js +98 -287
  33. package/dist/functions/index.js.map +1 -1
  34. package/dist/functions/timeout.d.ts +1 -1
  35. package/dist/functions/types.d.ts +69 -0
  36. package/dist/functions/types.js +15 -0
  37. package/dist/functions/types.js.map +1 -0
  38. package/dist/incoming/http/authorize.d.ts +4 -0
  39. package/dist/incoming/http/authorize.js +37 -0
  40. package/dist/incoming/http/authorize.js.map +1 -0
  41. package/dist/incoming/http/function.d.ts +4 -0
  42. package/dist/{network → incoming}/http/function.js +13 -13
  43. package/dist/incoming/http/function.js.map +1 -0
  44. package/dist/incoming/http/get.d.ts +4 -0
  45. package/dist/incoming/http/get.js +155 -0
  46. package/dist/incoming/http/get.js.map +1 -0
  47. package/dist/{network → incoming}/http/index.d.ts +0 -0
  48. package/dist/incoming/http/index.js +134 -0
  49. package/dist/incoming/http/index.js.map +1 -0
  50. package/dist/incoming/http/parseQuery.d.ts +4 -0
  51. package/dist/incoming/http/parseQuery.js +25 -0
  52. package/dist/incoming/http/parseQuery.js.map +1 -0
  53. package/dist/incoming/http/readBody.d.ts +4 -0
  54. package/dist/{network → incoming}/http/readBody.js +27 -32
  55. package/dist/incoming/http/readBody.js.map +1 -0
  56. package/dist/{handlers/rest/file → incoming/http/streamFunction}/DataStream.d.ts +0 -0
  57. package/dist/{network → incoming}/http/streamFunction/DataStream.js +0 -0
  58. package/dist/incoming/http/streamFunction/DataStream.js.map +1 -0
  59. package/dist/{network → incoming}/http/streamFunction/getExtension.d.ts +0 -0
  60. package/dist/{network → incoming}/http/streamFunction/getExtension.js +0 -0
  61. package/dist/incoming/http/streamFunction/getExtension.js.map +1 -0
  62. package/dist/incoming/http/streamFunction/index.d.ts +4 -0
  63. package/dist/incoming/http/streamFunction/index.js +106 -0
  64. package/dist/incoming/http/streamFunction/index.js.map +1 -0
  65. package/dist/incoming/http/streamFunction/multipartStream.d.ts +13 -0
  66. package/dist/{network → incoming}/http/streamFunction/multipartStream.js +12 -12
  67. package/dist/incoming/http/streamFunction/multipartStream.js.map +1 -0
  68. package/dist/{network → incoming}/http/streamFunction/stream.d.ts +3 -2
  69. package/dist/{network → incoming}/http/streamFunction/stream.js +16 -11
  70. package/dist/incoming/http/streamFunction/stream.js.map +1 -0
  71. package/dist/incoming/index.d.ts +3 -0
  72. package/dist/{network → incoming}/index.js +28 -28
  73. package/dist/incoming/index.js.map +1 -0
  74. package/dist/incoming/upgrade.d.ts +4 -0
  75. package/dist/{network → incoming}/upgrade.js +24 -9
  76. package/dist/incoming/upgrade.js.map +1 -0
  77. package/dist/incoming/ws/auth.d.ts +5 -0
  78. package/dist/incoming/ws/auth.js +40 -0
  79. package/dist/incoming/ws/auth.js.map +1 -0
  80. package/dist/incoming/ws/function.d.ts +3 -0
  81. package/dist/incoming/ws/function.js +107 -0
  82. package/dist/incoming/ws/function.js.map +1 -0
  83. package/dist/incoming/ws/get.d.ts +3 -0
  84. package/dist/incoming/ws/get.js +136 -0
  85. package/dist/incoming/ws/get.js.map +1 -0
  86. package/dist/incoming/ws/index.d.ts +3 -0
  87. package/dist/{network/message → incoming/ws}/index.js +17 -18
  88. package/dist/incoming/ws/index.js.map +1 -0
  89. package/dist/incoming/ws/observable.d.ts +6 -0
  90. package/dist/incoming/ws/observable.js +112 -0
  91. package/dist/incoming/ws/observable.js.map +1 -0
  92. package/dist/index.d.ts +10 -35
  93. package/dist/index.js +17 -196
  94. package/dist/index.js.map +1 -1
  95. package/dist/ip.d.ts +2 -0
  96. package/dist/ip.js +8 -0
  97. package/dist/ip.js.map +1 -0
  98. package/dist/observable/create.d.ts +3 -0
  99. package/dist/observable/create.js +30 -0
  100. package/dist/observable/create.js.map +1 -0
  101. package/dist/observable/destroy.d.ts +2 -0
  102. package/dist/observable/destroy.js +51 -0
  103. package/dist/observable/destroy.js.map +1 -0
  104. package/dist/observable/error.d.ts +4 -0
  105. package/dist/observable/error.js +17 -0
  106. package/dist/observable/error.js.map +1 -0
  107. package/dist/observable/extendCache.d.ts +2 -0
  108. package/dist/observable/extendCache.js +11 -0
  109. package/dist/observable/extendCache.js.map +1 -0
  110. package/dist/observable/genObservableId.d.ts +1 -0
  111. package/dist/observable/genObservableId.js +9 -0
  112. package/dist/observable/genObservableId.js.map +1 -0
  113. package/dist/observable/get.d.ts +4 -0
  114. package/dist/observable/get.js +15 -0
  115. package/dist/observable/get.js.map +1 -0
  116. package/dist/observable/index.d.ts +11 -8
  117. package/dist/observable/index.js +25 -151
  118. package/dist/observable/index.js.map +1 -1
  119. package/dist/observable/send.d.ts +6 -0
  120. package/dist/observable/send.js +32 -0
  121. package/dist/observable/send.js.map +1 -0
  122. package/dist/observable/start/error.d.ts +3 -0
  123. package/dist/observable/start/error.js +36 -0
  124. package/dist/observable/start/error.js.map +1 -0
  125. package/dist/observable/start/index.d.ts +2 -0
  126. package/dist/observable/start/index.js +46 -0
  127. package/dist/observable/start/index.js.map +1 -0
  128. package/dist/observable/start/update.d.ts +6 -0
  129. package/dist/observable/start/update.js +104 -0
  130. package/dist/observable/start/update.js.map +1 -0
  131. package/dist/observable/subscribe.d.ts +7 -0
  132. package/dist/observable/subscribe.js +54 -0
  133. package/dist/observable/subscribe.js.map +1 -0
  134. package/dist/observable/types.d.ts +26 -0
  135. package/dist/observable/types.js +3 -0
  136. package/dist/observable/types.js.map +1 -0
  137. package/dist/observable/unsub.d.ts +6 -0
  138. package/dist/observable/unsub.js +43 -0
  139. package/dist/observable/unsub.js.map +1 -0
  140. package/dist/observable/verify.d.ts +4 -0
  141. package/dist/observable/verify.js +18 -0
  142. package/dist/observable/verify.js.map +1 -0
  143. package/dist/protocol.d.ts +2 -0
  144. package/dist/protocol.js +32 -11
  145. package/dist/protocol.js.map +1 -1
  146. package/dist/security.d.ts +6 -0
  147. package/dist/security.js +95 -0
  148. package/dist/security.js.map +1 -0
  149. package/dist/sendError.d.ts +5 -0
  150. package/dist/sendError.js +42 -0
  151. package/dist/sendError.js.map +1 -0
  152. package/dist/sendHttpResponse.d.ts +4 -0
  153. package/dist/sendHttpResponse.js +53 -0
  154. package/dist/sendHttpResponse.js.map +1 -0
  155. package/dist/server.d.ts +42 -8
  156. package/dist/server.js +26 -12
  157. package/dist/server.js.map +1 -1
  158. package/package.json +16 -14
  159. package/.turbo/turbo-build.log +0 -4
  160. package/dist/BasedServerClient.d.ts +0 -71
  161. package/dist/BasedServerClient.js +0 -390
  162. package/dist/BasedServerClient.js.map +0 -1
  163. package/dist/Client.d.ts +0 -75
  164. package/dist/Client.js +0 -277
  165. package/dist/Client.js.map +0 -1
  166. package/dist/Params.d.ts +0 -20
  167. package/dist/Params.js +0 -48
  168. package/dist/Params.js.map +0 -1
  169. package/dist/auth/authorize.d.ts +0 -2
  170. package/dist/auth/authorize.js +0 -8
  171. package/dist/auth/authorize.js.map +0 -1
  172. package/dist/clientContext.d.ts +0 -0
  173. package/dist/clientContext.js +0 -83
  174. package/dist/clientContext.js.map +0 -1
  175. package/dist/closeListener.d.ts +0 -4
  176. package/dist/closeListener.js +0 -13
  177. package/dist/closeListener.js.map +0 -1
  178. package/dist/error.d.ts +0 -66
  179. package/dist/error.js +0 -149
  180. package/dist/error.js.map +0 -1
  181. package/dist/findPrefix.d.ts +0 -3
  182. package/dist/findPrefix.js +0 -20
  183. package/dist/findPrefix.js.map +0 -1
  184. package/dist/functions/workerPool.d.ts +0 -0
  185. package/dist/functions/workerPool.js +0 -5
  186. package/dist/functions/workerPool.js.map +0 -1
  187. package/dist/getFromConfig.d.ts +0 -3
  188. package/dist/getFromConfig.js +0 -50
  189. package/dist/getFromConfig.js.map +0 -1
  190. package/dist/handlers/authorize.d.ts +0 -5
  191. package/dist/handlers/authorize.js +0 -196
  192. package/dist/handlers/authorize.js.map +0 -1
  193. package/dist/handlers/bulkUpdate/index.d.ts +0 -5
  194. package/dist/handlers/bulkUpdate/index.js +0 -26
  195. package/dist/handlers/bulkUpdate/index.js.map +0 -1
  196. package/dist/handlers/configuration/index.d.ts +0 -10
  197. package/dist/handlers/configuration/index.js +0 -74
  198. package/dist/handlers/configuration/index.js.map +0 -1
  199. package/dist/handlers/configuration/observable/index.d.ts +0 -46
  200. package/dist/handlers/configuration/observable/index.js +0 -277
  201. package/dist/handlers/configuration/observable/index.js.map +0 -1
  202. package/dist/handlers/configure/index.d.ts +0 -5
  203. package/dist/handlers/configure/index.js +0 -44
  204. package/dist/handlers/configure/index.js.map +0 -1
  205. package/dist/handlers/copy/index.d.ts +0 -8
  206. package/dist/handlers/copy/index.js +0 -135
  207. package/dist/handlers/copy/index.js.map +0 -1
  208. package/dist/handlers/delete/index.d.ts +0 -5
  209. package/dist/handlers/delete/index.js +0 -34
  210. package/dist/handlers/delete/index.js.map +0 -1
  211. package/dist/handlers/digest/index.d.ts +0 -5
  212. package/dist/handlers/digest/index.js +0 -23
  213. package/dist/handlers/digest/index.js.map +0 -1
  214. package/dist/handlers/functions/call.d.ts +0 -6
  215. package/dist/handlers/functions/call.js +0 -54
  216. package/dist/handlers/functions/call.js.map +0 -1
  217. package/dist/handlers/functions/observable/Observable.d.ts +0 -49
  218. package/dist/handlers/functions/observable/Observable.js +0 -290
  219. package/dist/handlers/functions/observable/Observable.js.map +0 -1
  220. package/dist/handlers/functions/observable/SharedObservable.d.ts +0 -45
  221. package/dist/handlers/functions/observable/SharedObservable.js +0 -291
  222. package/dist/handlers/functions/observable/SharedObservable.js.map +0 -1
  223. package/dist/handlers/functions/observable/index.d.ts +0 -14
  224. package/dist/handlers/functions/observable/index.js +0 -130
  225. package/dist/handlers/functions/observable/index.js.map +0 -1
  226. package/dist/handlers/get/index.d.ts +0 -5
  227. package/dist/handlers/get/index.js +0 -23
  228. package/dist/handlers/get/index.js.map +0 -1
  229. package/dist/handlers/getConfig/index.d.ts +0 -5
  230. package/dist/handlers/getConfig/index.js +0 -38
  231. package/dist/handlers/getConfig/index.js.map +0 -1
  232. package/dist/handlers/handleRequests.d.ts +0 -5
  233. package/dist/handlers/handleRequests.js +0 -78
  234. package/dist/handlers/handleRequests.js.map +0 -1
  235. package/dist/handlers/index.d.ts +0 -4
  236. package/dist/handlers/index.js +0 -49
  237. package/dist/handlers/index.js.map +0 -1
  238. package/dist/handlers/messageParser.d.ts +0 -5
  239. package/dist/handlers/messageParser.js +0 -122
  240. package/dist/handlers/messageParser.js.map +0 -1
  241. package/dist/handlers/removeField/index.d.ts +0 -5
  242. package/dist/handlers/removeField/index.js +0 -42
  243. package/dist/handlers/removeField/index.js.map +0 -1
  244. package/dist/handlers/removeType/index.d.ts +0 -5
  245. package/dist/handlers/removeType/index.js +0 -30
  246. package/dist/handlers/removeType/index.js.map +0 -1
  247. package/dist/handlers/rest/file/DataStream.js +0 -17
  248. package/dist/handlers/rest/file/DataStream.js.map +0 -1
  249. package/dist/handlers/rest/file/formStream.d.ts +0 -4
  250. package/dist/handlers/rest/file/formStream.js +0 -188
  251. package/dist/handlers/rest/file/formStream.js.map +0 -1
  252. package/dist/handlers/rest/file/getExtenstion.d.ts +0 -2
  253. package/dist/handlers/rest/file/getExtenstion.js +0 -22
  254. package/dist/handlers/rest/file/getExtenstion.js.map +0 -1
  255. package/dist/handlers/rest/file/index.d.ts +0 -4
  256. package/dist/handlers/rest/file/index.js +0 -53
  257. package/dist/handlers/rest/file/index.js.map +0 -1
  258. package/dist/handlers/rest/file/storeFile.d.ts +0 -6
  259. package/dist/handlers/rest/file/storeFile.js +0 -44
  260. package/dist/handlers/rest/file/storeFile.js.map +0 -1
  261. package/dist/handlers/rest/file/stream.d.ts +0 -5
  262. package/dist/handlers/rest/file/stream.js +0 -105
  263. package/dist/handlers/rest/file/stream.js.map +0 -1
  264. package/dist/handlers/rest/file/types.d.ts +0 -9
  265. package/dist/handlers/rest/file/types.js.map +0 -1
  266. package/dist/handlers/rest/getReqMessage.d.ts +0 -3
  267. package/dist/handlers/rest/getReqMessage.js +0 -92
  268. package/dist/handlers/rest/getReqMessage.js.map +0 -1
  269. package/dist/handlers/rest/index.d.ts +0 -4
  270. package/dist/handlers/rest/index.js +0 -121
  271. package/dist/handlers/rest/index.js.map +0 -1
  272. package/dist/handlers/rest/invalidReq.d.ts +0 -4
  273. package/dist/handlers/rest/invalidReq.js +0 -20
  274. package/dist/handlers/rest/invalidReq.js.map +0 -1
  275. package/dist/handlers/rest/parseResponse.d.ts +0 -6
  276. package/dist/handlers/rest/parseResponse.js +0 -230
  277. package/dist/handlers/rest/parseResponse.js.map +0 -1
  278. package/dist/handlers/rest/playground/index.d.ts +0 -5
  279. package/dist/handlers/rest/playground/index.js +0 -308
  280. package/dist/handlers/rest/playground/index.js.map +0 -1
  281. package/dist/handlers/rest/readBody.d.ts +0 -3
  282. package/dist/handlers/rest/readBody.js +0 -45
  283. package/dist/handlers/rest/readBody.js.map +0 -1
  284. package/dist/handlers/set/index.d.ts +0 -5
  285. package/dist/handlers/set/index.js +0 -20
  286. package/dist/handlers/set/index.js.map +0 -1
  287. package/dist/handlers/subscription/index.d.ts +0 -32
  288. package/dist/handlers/subscription/index.js +0 -223
  289. package/dist/handlers/subscription/index.js.map +0 -1
  290. package/dist/handlers/token.d.ts +0 -5
  291. package/dist/handlers/token.js +0 -122
  292. package/dist/handlers/token.js.map +0 -1
  293. package/dist/handlers/track/index.d.ts +0 -7
  294. package/dist/handlers/track/index.js +0 -102
  295. package/dist/handlers/track/index.js.map +0 -1
  296. package/dist/handlers/userAuth/index.d.ts +0 -5
  297. package/dist/handlers/userAuth/index.js +0 -78
  298. package/dist/handlers/userAuth/index.js.map +0 -1
  299. package/dist/network/http/authorize.d.ts +0 -3
  300. package/dist/network/http/authorize.js +0 -28
  301. package/dist/network/http/authorize.js.map +0 -1
  302. package/dist/network/http/compress.d.ts +0 -6
  303. package/dist/network/http/compress.js.map +0 -1
  304. package/dist/network/http/end.d.ts +0 -4
  305. package/dist/network/http/end.js +0 -19
  306. package/dist/network/http/end.js.map +0 -1
  307. package/dist/network/http/function.d.ts +0 -3
  308. package/dist/network/http/function.js.map +0 -1
  309. package/dist/network/http/get.d.ts +0 -3
  310. package/dist/network/http/get.js +0 -129
  311. package/dist/network/http/get.js.map +0 -1
  312. package/dist/network/http/index.js +0 -122
  313. package/dist/network/http/index.js.map +0 -1
  314. package/dist/network/http/readBody.d.ts +0 -3
  315. package/dist/network/http/readBody.js.map +0 -1
  316. package/dist/network/http/send.d.ts +0 -5
  317. package/dist/network/http/send.js +0 -60
  318. package/dist/network/http/send.js.map +0 -1
  319. package/dist/network/http/streamFunction/DataStream.d.ts +0 -7
  320. package/dist/network/http/streamFunction/DataStream.js.map +0 -1
  321. package/dist/network/http/streamFunction/getExtension.js.map +0 -1
  322. package/dist/network/http/streamFunction/index.d.ts +0 -3
  323. package/dist/network/http/streamFunction/index.js +0 -81
  324. package/dist/network/http/streamFunction/index.js.map +0 -1
  325. package/dist/network/http/streamFunction/multipartStream.d.ts +0 -12
  326. package/dist/network/http/streamFunction/multipartStream.js.map +0 -1
  327. package/dist/network/http/streamFunction/stream.js.map +0 -1
  328. package/dist/network/index.d.ts +0 -4
  329. package/dist/network/index.js.map +0 -1
  330. package/dist/network/message/auth.d.ts +0 -4
  331. package/dist/network/message/auth.js +0 -32
  332. package/dist/network/message/auth.js.map +0 -1
  333. package/dist/network/message/function.d.ts +0 -3
  334. package/dist/network/message/function.js +0 -67
  335. package/dist/network/message/function.js.map +0 -1
  336. package/dist/network/message/get.d.ts +0 -3
  337. package/dist/network/message/get.js +0 -109
  338. package/dist/network/message/get.js.map +0 -1
  339. package/dist/network/message/index.d.ts +0 -3
  340. package/dist/network/message/index.js.map +0 -1
  341. package/dist/network/message/observable.d.ts +0 -5
  342. package/dist/network/message/observable.js +0 -103
  343. package/dist/network/message/observable.js.map +0 -1
  344. package/dist/network/message/send.d.ts +0 -4
  345. package/dist/network/message/send.js +0 -11
  346. package/dist/network/message/send.js.map +0 -1
  347. package/dist/network/upgrade.d.ts +0 -4
  348. package/dist/network/upgrade.js.map +0 -1
  349. package/dist/network/worker/get.d.ts +0 -0
  350. package/dist/network/worker/get.js +0 -122
  351. package/dist/network/worker/get.js.map +0 -1
  352. package/dist/network/worker/observable.d.ts +0 -0
  353. package/dist/network/worker/observable.js +0 -120
  354. package/dist/network/worker/observable.js.map +0 -1
  355. package/dist/openListener.d.ts +0 -4
  356. package/dist/openListener.js +0 -13
  357. package/dist/openListener.js.map +0 -1
  358. package/dist/secrets.d.ts +0 -9
  359. package/dist/secrets.js +0 -150
  360. package/dist/secrets.js.map +0 -1
  361. package/dist/security/index.d.ts +0 -2
  362. package/dist/security/index.js +0 -57
  363. package/dist/security/index.js.map +0 -1
  364. package/dist/types.d.ts +0 -129
  365. package/dist/types.js +0 -17
  366. package/dist/types.js.map +0 -1
  367. package/dist/upgradeListener.d.ts +0 -4
  368. package/dist/upgradeListener.js +0 -47
  369. package/dist/upgradeListener.js.map +0 -1
  370. package/dist/worker/authorize.d.ts +0 -5
  371. package/dist/worker/authorize.js +0 -15
  372. package/dist/worker/authorize.js.map +0 -1
  373. package/dist/worker/fnMap.d.ts +0 -2
  374. package/dist/worker/fnMap.js +0 -5
  375. package/dist/worker/fnMap.js.map +0 -1
  376. package/dist/worker/functions.d.ts +0 -3
  377. package/dist/worker/functions.js +0 -8
  378. package/dist/worker/functions.js.map +0 -1
  379. package/dist/worker/http/function.d.ts +0 -4
  380. package/dist/worker/http/function.js +0 -75
  381. package/dist/worker/http/function.js.map +0 -1
  382. package/dist/worker/index.d.ts +0 -1
  383. package/dist/worker/index.js +0 -101
  384. package/dist/worker/index.js.map +0 -1
  385. package/dist/worker/observable.d.ts +0 -15
  386. package/dist/worker/observable.js +0 -110
  387. package/dist/worker/observable.js.map +0 -1
  388. package/dist/worker/ws/function.d.ts +0 -3
  389. package/dist/worker/ws/function.js +0 -42
  390. package/dist/worker/ws/function.js.map +0 -1
  391. package/dist/workers/index.d.ts +0 -0
  392. package/dist/workers/index.js +0 -20
  393. package/dist/workers/index.js.map +0 -1
  394. package/dist/workers/workerCode.d.ts +0 -12
  395. package/dist/workers/workerCode.js +0 -46
  396. package/dist/workers/workerCode.js.map +0 -1
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createError = void 0;
18
+ const types_1 = require("./types");
19
+ const errorTypeHandlers_1 = require("./errorTypeHandlers");
20
+ __exportStar(require("./types"), exports);
21
+ const isBasedFunctionRoute = (route) => {
22
+ if (route && typeof route === 'object' && 'name' in route) {
23
+ return true;
24
+ }
25
+ return false;
26
+ };
27
+ function createError(server, context, code, payload) {
28
+ const type = errorTypeHandlers_1.errorTypeHandlers[code];
29
+ const route = !payload
30
+ ? types_1.EMPTY_ROUTE
31
+ : isBasedFunctionRoute(payload)
32
+ ? payload
33
+ : 'route' in payload
34
+ ? payload.route
35
+ : types_1.EMPTY_ROUTE;
36
+ const errorData = {
37
+ code,
38
+ statusCode: type.statusCode,
39
+ statusMessage: type.statusMessage,
40
+ message: type.message(payload),
41
+ route: {
42
+ name: route.name,
43
+ path: route.path,
44
+ },
45
+ };
46
+ if ('requestId' in payload) {
47
+ errorData.requestId = payload.requestId;
48
+ }
49
+ if ('observableId' in payload) {
50
+ errorData.observableId = payload.observableId;
51
+ }
52
+ if ('err' in payload) {
53
+ server.emit('error', context, errorData, payload.err);
54
+ }
55
+ else {
56
+ server.emit('error', context, errorData);
57
+ }
58
+ return errorData;
59
+ }
60
+ exports.createError = createError;
61
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGA,mCAKgB;AAEhB,2DAAuD;AACvD,0CAAuB;AAEvB,MAAM,oBAAoB,GAAG,CAAC,KAAU,EAA+B,EAAE;IACvE,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,EAAE;QACzD,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,SAAgB,WAAW,CACzB,MAAmB,EACnB,OAAgB,EAChB,IAAO,EACP,OAAwB;IAExB,MAAM,IAAI,GAAG,qCAAiB,CAAC,IAAI,CAAC,CAAA;IAEpC,MAAM,KAAK,GAAG,CAAC,OAAO;QACpB,CAAC,CAAC,mBAAW;QACb,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC;YAC/B,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,OAAO,IAAI,OAAO;gBACpB,CAAC,CAAC,OAAO,CAAC,KAAK;gBACf,CAAC,CAAC,mBAAW,CAAA;IAEf,MAAM,SAAS,GAAsB;QACnC,IAAI;QACJ,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAC9B,KAAK,EAAE;YACL,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB;KACF,CAAA;IAED,IAAI,WAAW,IAAI,OAAO,EAAE;QAC1B,SAAS,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;KACxC;IAED,IAAI,cAAc,IAAI,OAAO,EAAE;QAC7B,SAAS,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;KAC9C;IAED,IAAI,KAAK,IAAI,OAAO,EAAE;QACpB,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;KACtD;SAAM;QACL,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;KACzC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC;AA1CD,kCA0CC"}
@@ -0,0 +1,105 @@
1
+ import { BasedFunctionRoute } from '../functions';
2
+ export declare const EMPTY_ROUTE: {
3
+ name: string;
4
+ path: string;
5
+ };
6
+ export declare enum BasedErrorCode {
7
+ FunctionError = 50001,
8
+ AuthorizeFunctionError = 50002,
9
+ NoOservableCacheAvailable = 50003,
10
+ ObservableFunctionError = 50004,
11
+ ObserveCallbackError = 50005,
12
+ FunctionNotFound = 40401,
13
+ FunctionIsNotObservable = 40402,
14
+ FunctionIsObservable = 40403,
15
+ FunctionIsStream = 40404,
16
+ CannotStreamToObservableFunction = 40402,
17
+ AuthorizeRejectedError = 40301,
18
+ InvalidPayload = 40001,
19
+ PayloadTooLarge = 40002,
20
+ ChunkTooLarge = 40003,
21
+ UnsupportedContentEncoding = 40004,
22
+ NoBinaryProtocol = 40005,
23
+ LengthRequired = 41101,
24
+ MethodNotAllowed = 40501,
25
+ RateLimit = 40029
26
+ }
27
+ export declare type BasedError<T extends BasedErrorCode = BasedErrorCode> = Error & {
28
+ code: T;
29
+ };
30
+ declare type FunctionErrorProps = {
31
+ err: Error;
32
+ requestId?: number;
33
+ route: BasedFunctionRoute;
34
+ };
35
+ declare type ObservableFunctionErrorProps = {
36
+ observableId: number;
37
+ err: Error;
38
+ route: BasedFunctionRoute;
39
+ };
40
+ export declare type ErrorPayload = {
41
+ [BasedErrorCode.RateLimit]: {};
42
+ [BasedErrorCode.NoBinaryProtocol]: {
43
+ buffer: ArrayBuffer;
44
+ };
45
+ [BasedErrorCode.FunctionError]: FunctionErrorProps;
46
+ [BasedErrorCode.ObservableFunctionError]: ObservableFunctionErrorProps;
47
+ [BasedErrorCode.AuthorizeFunctionError]: FunctionErrorProps | ObservableFunctionErrorProps;
48
+ [BasedErrorCode.AuthorizeRejectedError]: {
49
+ observableId: number;
50
+ route: BasedFunctionRoute;
51
+ } | {
52
+ requestId?: number;
53
+ route: BasedFunctionRoute;
54
+ };
55
+ [BasedErrorCode.ObserveCallbackError]: {
56
+ err: Error;
57
+ observableId: number;
58
+ route?: BasedFunctionRoute;
59
+ };
60
+ [BasedErrorCode.NoOservableCacheAvailable]: {
61
+ observableId: number;
62
+ route: BasedFunctionRoute;
63
+ };
64
+ [BasedErrorCode.FunctionIsStream]: BasedFunctionRoute & {
65
+ requestId?: number;
66
+ };
67
+ [BasedErrorCode.FunctionNotFound]: BasedFunctionRoute & {
68
+ requestId?: number;
69
+ };
70
+ [BasedErrorCode.FunctionIsNotObservable]: BasedFunctionRoute & {
71
+ requestId?: number;
72
+ };
73
+ [BasedErrorCode.FunctionIsObservable]: BasedFunctionRoute & {
74
+ requestId?: number;
75
+ };
76
+ [BasedErrorCode.CannotStreamToObservableFunction]: BasedFunctionRoute & {
77
+ requestId?: number;
78
+ };
79
+ [BasedErrorCode.InvalidPayload]: BasedFunctionRoute & {
80
+ requestId?: number;
81
+ };
82
+ [BasedErrorCode.PayloadTooLarge]: BasedFunctionRoute & {
83
+ requestId?: number;
84
+ };
85
+ [BasedErrorCode.ChunkTooLarge]: BasedFunctionRoute;
86
+ [BasedErrorCode.UnsupportedContentEncoding]: BasedFunctionRoute;
87
+ [BasedErrorCode.LengthRequired]: BasedFunctionRoute;
88
+ [BasedErrorCode.MethodNotAllowed]: BasedFunctionRoute;
89
+ };
90
+ export declare type ErrorHandler<T extends BasedErrorCode> = {
91
+ statusCode: number;
92
+ statusMessage: string;
93
+ message: (payload: ErrorPayload[T]) => string;
94
+ };
95
+ export declare type BasedErrorData<T extends BasedErrorCode = BasedErrorCode> = {
96
+ route: BasedFunctionRoute;
97
+ message: string;
98
+ code: T;
99
+ statusCode: number;
100
+ statusMessage: string;
101
+ requestId?: number;
102
+ observableId?: number;
103
+ err?: BasedError<T>;
104
+ };
105
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BasedErrorCode = exports.EMPTY_ROUTE = void 0;
4
+ exports.EMPTY_ROUTE = {
5
+ name: 'no-route',
6
+ path: '',
7
+ };
8
+ var BasedErrorCode;
9
+ (function (BasedErrorCode) {
10
+ BasedErrorCode[BasedErrorCode["FunctionError"] = 50001] = "FunctionError";
11
+ BasedErrorCode[BasedErrorCode["AuthorizeFunctionError"] = 50002] = "AuthorizeFunctionError";
12
+ BasedErrorCode[BasedErrorCode["NoOservableCacheAvailable"] = 50003] = "NoOservableCacheAvailable";
13
+ BasedErrorCode[BasedErrorCode["ObservableFunctionError"] = 50004] = "ObservableFunctionError";
14
+ BasedErrorCode[BasedErrorCode["ObserveCallbackError"] = 50005] = "ObserveCallbackError";
15
+ BasedErrorCode[BasedErrorCode["FunctionNotFound"] = 40401] = "FunctionNotFound";
16
+ BasedErrorCode[BasedErrorCode["FunctionIsNotObservable"] = 40402] = "FunctionIsNotObservable";
17
+ BasedErrorCode[BasedErrorCode["FunctionIsObservable"] = 40403] = "FunctionIsObservable";
18
+ BasedErrorCode[BasedErrorCode["FunctionIsStream"] = 40404] = "FunctionIsStream";
19
+ BasedErrorCode[BasedErrorCode["CannotStreamToObservableFunction"] = 40402] = "CannotStreamToObservableFunction";
20
+ BasedErrorCode[BasedErrorCode["AuthorizeRejectedError"] = 40301] = "AuthorizeRejectedError";
21
+ BasedErrorCode[BasedErrorCode["InvalidPayload"] = 40001] = "InvalidPayload";
22
+ BasedErrorCode[BasedErrorCode["PayloadTooLarge"] = 40002] = "PayloadTooLarge";
23
+ BasedErrorCode[BasedErrorCode["ChunkTooLarge"] = 40003] = "ChunkTooLarge";
24
+ BasedErrorCode[BasedErrorCode["UnsupportedContentEncoding"] = 40004] = "UnsupportedContentEncoding";
25
+ BasedErrorCode[BasedErrorCode["NoBinaryProtocol"] = 40005] = "NoBinaryProtocol";
26
+ BasedErrorCode[BasedErrorCode["LengthRequired"] = 41101] = "LengthRequired";
27
+ BasedErrorCode[BasedErrorCode["MethodNotAllowed"] = 40501] = "MethodNotAllowed";
28
+ BasedErrorCode[BasedErrorCode["RateLimit"] = 40029] = "RateLimit";
29
+ })(BasedErrorCode = exports.BasedErrorCode || (exports.BasedErrorCode = {}));
30
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/error/types.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,EAAE;CACT,CAAA;AAED,IAAY,cAoBX;AApBD,WAAY,cAAc;IACxB,yEAAqB,CAAA;IACrB,2FAA8B,CAAA;IAC9B,iGAAiC,CAAA;IACjC,6FAA+B,CAAA;IAC/B,uFAA4B,CAAA;IAC5B,+EAAwB,CAAA;IACxB,6FAA+B,CAAA;IAC/B,uFAA4B,CAAA;IAC5B,+EAAwB,CAAA;IACxB,+GAAwC,CAAA;IACxC,2FAA8B,CAAA;IAC9B,2EAAsB,CAAA;IACtB,6EAAuB,CAAA;IACvB,yEAAqB,CAAA;IACrB,mGAAkC,CAAA;IAClC,+EAAwB,CAAA;IACxB,2EAAsB,CAAA;IACtB,+EAAwB,CAAA;IACxB,iEAAiB,CAAA;AACnB,CAAC,EApBW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAoBzB"}
@@ -1,38 +1,29 @@
1
1
  /// <reference types="node" />
2
2
  import type { BasedServer } from '../server';
3
- import { BasedFunctionRoute, BasedFunctionSpec, BasedObservableFunctionSpec, FunctionConfig, isObservableFunctionSpec } from '../types';
4
- import { Worker } from 'node:worker_threads';
5
- declare type BasedWorker = {
6
- worker: Worker;
7
- name?: string;
8
- index: number;
9
- activeObservables: number;
10
- activeFunctions: number;
11
- };
12
- export { isObservableFunctionSpec };
3
+ import { BasedFunctionRoute, BasedFunctionSpec, BasedObservableFunctionSpec, FunctionConfig } from './types';
4
+ export * from './types';
13
5
  export declare class BasedFunctions {
14
6
  server: BasedServer;
7
+ reqId: number;
15
8
  config: FunctionConfig;
16
9
  unregisterTimeout: NodeJS.Timeout;
17
- workers: BasedWorker[];
18
- workerResponseListeners: Map<number, (err: Error, p: any) => void>;
10
+ installsInProgress: {
11
+ [name: string]: Promise<any>;
12
+ };
19
13
  paths: {
20
14
  [path: string]: string;
21
15
  };
22
- observables: {
23
- [name: string]: BasedObservableFunctionSpec;
24
- };
25
- functions: {
26
- [name: string]: BasedFunctionSpec;
16
+ specs: {
17
+ [name: string]: BasedFunctionSpec | BasedObservableFunctionSpec;
27
18
  };
28
19
  beingUninstalled: {
29
20
  [name: string]: boolean;
30
21
  };
31
- lowestWorker: BasedWorker;
32
22
  constructor(server: BasedServer, config?: FunctionConfig);
33
- workerSortLoop(): void;
34
23
  uninstallLoop(): void;
35
24
  updateConfig(config: FunctionConfig): void;
25
+ updateFunction(spec: BasedObservableFunctionSpec | BasedFunctionSpec): Promise<void>;
26
+ private installGaurdedFromConfig;
36
27
  install(name: string): Promise<BasedObservableFunctionSpec | BasedFunctionSpec | false>;
37
28
  getNameFromPath(path: string): string;
38
29
  route(name?: string, path?: string): BasedFunctionRoute | false;
@@ -40,9 +31,4 @@ export declare class BasedFunctions {
40
31
  update(spec: BasedObservableFunctionSpec | BasedFunctionSpec): boolean;
41
32
  remove(name: string): boolean;
42
33
  uninstall(name: string, spec?: BasedObservableFunctionSpec | BasedFunctionSpec | false): Promise<boolean>;
43
- runObservableFunction(spec: BasedFunctionSpec, id: number, error: (err: Error) => void, update: (encodedDiffData: Uint8Array, encodedData: Uint8Array, checksum: number, isDeflate: boolean) => void, payload?: any): () => void;
44
- runFunction(type: 0 | 3 | 4, spec: BasedFunctionSpec, context: {
45
- [key: string]: any;
46
- }, // make this specific
47
- payload?: Uint8Array): Promise<Uint8Array>;
48
34
  }