@vandenberghinc/volt 1.1.26 → 1.1.28

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 (502) hide show
  1. package/backend/dist/cjs/{blacklist.d.ts → backend/src/blacklist.d.ts} +5 -3
  2. package/backend/dist/cjs/{blacklist.js → backend/src/blacklist.js} +8 -5
  3. package/backend/dist/cjs/{cli.js → backend/src/cli.js} +29 -47
  4. package/backend/dist/cjs/backend/src/database/collection.d.ts +1543 -0
  5. package/backend/dist/cjs/backend/src/database/collection.js +3042 -0
  6. package/backend/dist/cjs/backend/src/database/database.d.ts +66 -0
  7. package/backend/dist/cjs/{database → backend/src/database}/database.js +48 -43
  8. package/backend/dist/cjs/backend/src/database/filters/filters.d.ts +6 -0
  9. package/backend/dist/cjs/backend/src/database/filters/filters.js +15 -0
  10. package/backend/dist/cjs/backend/src/database/filters/strict_filter.d.ts +223 -0
  11. package/backend/dist/cjs/backend/src/database/filters/strict_filter.js +15 -0
  12. package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.js +443 -0
  13. package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.js +15 -0
  14. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
  15. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.js +15 -0
  16. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
  17. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.js +15 -0
  18. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
  19. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.js +15 -0
  20. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
  21. package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.js +15 -0
  22. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.d.ts +165 -0
  23. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.js +15 -0
  24. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
  25. package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.js +355 -0
  26. package/backend/dist/cjs/backend/src/database/flatten.d.ts +75 -0
  27. package/backend/dist/cjs/{logger.js → backend/src/database/flatten.js} +18 -7
  28. package/backend/dist/cjs/backend/src/database/flatten_test.js +175 -0
  29. package/backend/dist/cjs/backend/src/database/quota/quota.d.ts +461 -0
  30. package/backend/dist/cjs/backend/src/database/quota/quota.js +1014 -0
  31. package/backend/dist/cjs/backend/src/database/quota/quota_v1.d.ts +534 -0
  32. package/backend/dist/cjs/backend/src/database/quota/quota_v1.js +1087 -0
  33. package/backend/dist/cjs/backend/src/database/quota/safe_int.d.ts +293 -0
  34. package/backend/dist/cjs/backend/src/database/quota/safe_int.js +573 -0
  35. package/backend/dist/{esm → cjs/backend/src}/endpoint.d.ts +69 -46
  36. package/backend/dist/cjs/{endpoint.js → backend/src/endpoint.js} +87 -101
  37. package/backend/dist/cjs/backend/src/errors/index.d.ts +7 -0
  38. package/backend/dist/cjs/backend/src/errors/index.js +25 -0
  39. package/backend/dist/{esm/utils.d.ts → cjs/backend/src/errors/internal_external.d.ts} +14 -22
  40. package/backend/dist/cjs/backend/src/errors/internal_external.js +85 -0
  41. package/backend/dist/cjs/backend/src/errors/invalid_usage_error.d.ts +38 -0
  42. package/backend/dist/cjs/{mutex.js → backend/src/errors/invalid_usage_error.js} +20 -37
  43. package/backend/dist/cjs/backend/src/errors/system_error.d.ts +230 -0
  44. package/backend/dist/cjs/backend/src/errors/system_error.js +393 -0
  45. package/backend/dist/cjs/backend/src/events.d.ts +54 -0
  46. package/backend/dist/cjs/backend/src/events.js +15 -0
  47. package/backend/dist/cjs/{frontend.js → backend/src/frontend.js} +1 -1
  48. package/backend/dist/cjs/{image_endpoint.d.ts → backend/src/image_endpoint.d.ts} +16 -1
  49. package/backend/dist/cjs/{image_endpoint.js → backend/src/image_endpoint.js} +3 -5
  50. package/backend/dist/cjs/backend/src/logger.d.ts +5 -0
  51. package/backend/dist/cjs/backend/src/logger.js +15 -0
  52. package/backend/dist/cjs/backend/src/meta.d.ts +64 -0
  53. package/backend/dist/cjs/{meta.js → backend/src/meta.js} +9 -12
  54. package/backend/dist/cjs/backend/src/payments/paddle.d.ts +326 -0
  55. package/backend/dist/cjs/{payments → backend/src/payments}/paddle.js +377 -327
  56. package/backend/dist/cjs/backend/src/plugins/browser.d.ts +1 -0
  57. package/backend/dist/cjs/backend/src/plugins/browser.js +15 -0
  58. package/backend/dist/cjs/backend/src/plugins/mail/mail.d.ts +248 -0
  59. package/backend/dist/cjs/backend/src/plugins/mail/mail.js +379 -0
  60. package/backend/dist/{esm → cjs/backend/src}/plugins/mail/ui.d.ts +23 -0
  61. package/backend/dist/cjs/backend/src/plugins/pdf.d.ts +1 -0
  62. package/backend/dist/cjs/backend/src/rate_limit.d.ts +145 -0
  63. package/backend/dist/cjs/backend/src/rate_limit.js +549 -0
  64. package/backend/dist/cjs/{route.d.ts → backend/src/route.d.ts} +3 -10
  65. package/backend/dist/cjs/{route.js → backend/src/route.js} +23 -21
  66. package/backend/dist/cjs/backend/src/server.d.ts +485 -0
  67. package/backend/dist/cjs/{server.js → backend/src/server.js} +688 -873
  68. package/backend/dist/cjs/backend/src/splash_screen.d.ts +80 -0
  69. package/backend/dist/cjs/{splash_screen.js → backend/src/splash_screen.js} +24 -3
  70. package/backend/dist/cjs/backend/src/status.d.ts +74 -0
  71. package/backend/dist/cjs/{status.js → backend/src/status.js} +64 -64
  72. package/backend/dist/cjs/backend/src/stream.d.ts +376 -0
  73. package/backend/dist/cjs/{stream.js → backend/src/stream.js} +299 -276
  74. package/backend/dist/cjs/backend/src/users.d.ts +807 -0
  75. package/backend/dist/cjs/backend/src/users.js +1971 -0
  76. package/backend/dist/cjs/backend/src/utils.d.ts +16 -0
  77. package/backend/dist/cjs/{utils.js → backend/src/utils.js} +14 -77
  78. package/backend/dist/{esm → cjs/backend/src}/view.d.ts +33 -11
  79. package/backend/dist/cjs/backend/src/view.js +508 -0
  80. package/backend/dist/{esm → cjs/backend/src}/volt.d.ts +10 -1
  81. package/backend/dist/cjs/{volt.js → backend/src/volt.js} +8 -5
  82. package/backend/dist/cjs/frontend/src/modules/request.d.ts +70 -0
  83. package/backend/dist/cjs/frontend/src/modules/request.js +99 -0
  84. package/backend/dist/esm/{blacklist.d.ts → backend/src/blacklist.d.ts} +5 -3
  85. package/backend/dist/esm/{blacklist.js → backend/src/blacklist.js} +9 -6
  86. package/backend/dist/esm/{cli.js → backend/src/cli.js} +43 -60
  87. package/backend/dist/esm/backend/src/database/collection.d.ts +1543 -0
  88. package/backend/dist/esm/backend/src/database/collection.js +3510 -0
  89. package/backend/dist/esm/backend/src/database/database.d.ts +66 -0
  90. package/backend/dist/esm/{database → backend/src/database}/database.js +62 -103
  91. package/backend/dist/esm/backend/src/database/document.d.ts +1 -0
  92. package/backend/dist/esm/backend/src/database/document.js +558 -0
  93. package/backend/dist/esm/backend/src/database/filters/filters.d.ts +6 -0
  94. package/backend/dist/esm/backend/src/database/filters/filters.js +1 -0
  95. package/backend/dist/esm/backend/src/database/filters/strict_filter.d.ts +223 -0
  96. package/backend/dist/esm/backend/src/database/filters/strict_filter.js +3 -0
  97. package/backend/dist/esm/backend/src/database/filters/strict_filter_test.d.ts +1 -0
  98. package/backend/dist/esm/backend/src/database/filters/strict_filter_test.js +505 -0
  99. package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.d.ts +1 -0
  100. package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.js +712 -0
  101. package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
  102. package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.js +5 -0
  103. package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
  104. package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.js +44 -0
  105. package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
  106. package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.js +5 -0
  107. package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
  108. package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.js +1 -0
  109. package/backend/dist/esm/backend/src/database/filters/strict_update_filter.d.ts +165 -0
  110. package/backend/dist/esm/backend/src/database/filters/strict_update_filter.js +5 -0
  111. package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
  112. package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.js +405 -0
  113. package/backend/dist/esm/backend/src/database/flatten.d.ts +75 -0
  114. package/backend/dist/esm/backend/src/database/flatten.js +22 -0
  115. package/backend/dist/esm/backend/src/database/flatten_test.d.ts +1 -0
  116. package/backend/dist/esm/backend/src/database/flatten_test.js +174 -0
  117. package/backend/dist/esm/backend/src/database/quota/quota.d.ts +461 -0
  118. package/backend/dist/esm/backend/src/database/quota/quota.js +1118 -0
  119. package/backend/dist/esm/backend/src/database/quota/quota_v1.d.ts +534 -0
  120. package/backend/dist/esm/backend/src/database/quota/quota_v1.js +1242 -0
  121. package/backend/dist/esm/backend/src/database/quota/safe_int.d.ts +293 -0
  122. package/backend/dist/esm/backend/src/database/quota/safe_int.js +602 -0
  123. package/backend/dist/{cjs → esm/backend/src}/endpoint.d.ts +69 -46
  124. package/backend/dist/esm/{endpoint.js → backend/src/endpoint.js} +136 -127
  125. package/backend/dist/esm/backend/src/errors/index.d.ts +7 -0
  126. package/backend/dist/esm/backend/src/errors/index.js +7 -0
  127. package/backend/dist/{cjs/utils.d.ts → esm/backend/src/errors/internal_external.d.ts} +14 -22
  128. package/backend/dist/esm/backend/src/errors/internal_external.js +70 -0
  129. package/backend/dist/esm/backend/src/errors/invalid_usage_error.d.ts +38 -0
  130. package/backend/dist/esm/backend/src/errors/invalid_usage_error.js +30 -0
  131. package/backend/dist/esm/backend/src/errors/system_error.d.ts +230 -0
  132. package/backend/dist/esm/backend/src/errors/system_error.js +402 -0
  133. package/backend/dist/esm/backend/src/events.d.ts +54 -0
  134. package/backend/dist/esm/backend/src/events.js +5 -0
  135. package/backend/dist/esm/{frontend.js → backend/src/frontend.js} +1 -1
  136. package/backend/dist/esm/{image_endpoint.d.ts → backend/src/image_endpoint.d.ts} +16 -1
  137. package/backend/dist/esm/{image_endpoint.js → backend/src/image_endpoint.js} +16 -20
  138. package/backend/dist/esm/backend/src/logger.d.ts +5 -0
  139. package/backend/dist/esm/backend/src/logger.js +8 -0
  140. package/backend/dist/esm/backend/src/meta.d.ts +64 -0
  141. package/backend/dist/esm/{meta.js → backend/src/meta.js} +15 -54
  142. package/backend/dist/esm/backend/src/payments/paddle.d.ts +326 -0
  143. package/backend/dist/esm/{payments → backend/src/payments}/paddle.js +417 -452
  144. package/backend/dist/esm/backend/src/plugins/browser.d.ts +1 -0
  145. package/backend/dist/esm/backend/src/plugins/browser.js +170 -0
  146. package/backend/dist/esm/backend/src/plugins/mail/mail.d.ts +248 -0
  147. package/backend/dist/esm/backend/src/plugins/mail/mail.js +389 -0
  148. package/backend/dist/{cjs → esm/backend/src}/plugins/mail/ui.d.ts +23 -0
  149. package/backend/dist/esm/{plugins → backend/src/plugins}/mail/ui.js +3 -6
  150. package/backend/dist/esm/backend/src/plugins/pdf.d.ts +1 -0
  151. package/backend/dist/esm/{plugins → backend/src/plugins}/pdf.js +3 -3
  152. package/backend/dist/esm/backend/src/rate_limit.d.ts +145 -0
  153. package/backend/dist/esm/backend/src/rate_limit.js +667 -0
  154. package/backend/dist/esm/{route.d.ts → backend/src/route.d.ts} +3 -10
  155. package/backend/dist/esm/{route.js → backend/src/route.js} +26 -21
  156. package/backend/dist/esm/backend/src/server.d.ts +485 -0
  157. package/backend/dist/esm/{server.js → backend/src/server.js} +891 -1441
  158. package/backend/dist/esm/backend/src/splash_screen.d.ts +80 -0
  159. package/backend/dist/esm/{splash_screen.js → backend/src/splash_screen.js} +42 -55
  160. package/backend/dist/esm/backend/src/status.d.ts +74 -0
  161. package/backend/dist/esm/backend/src/status.js +199 -0
  162. package/backend/dist/esm/backend/src/stream.d.ts +376 -0
  163. package/backend/dist/esm/{stream.js → backend/src/stream.js} +327 -292
  164. package/backend/dist/esm/backend/src/users.d.ts +809 -0
  165. package/backend/dist/esm/backend/src/users.js +2140 -0
  166. package/backend/dist/esm/backend/src/utils.d.ts +16 -0
  167. package/backend/dist/esm/{utils.js → backend/src/utils.js} +20 -81
  168. package/backend/dist/{cjs → esm/backend/src}/view.d.ts +33 -11
  169. package/backend/dist/esm/{view.js → backend/src/view.js} +266 -86
  170. package/backend/dist/{cjs → esm/backend/src}/volt.d.ts +10 -1
  171. package/backend/dist/esm/{volt.js → backend/src/volt.js} +7 -4
  172. package/backend/dist/esm/frontend/src/modules/request.d.ts +70 -0
  173. package/backend/dist/esm/frontend/src/modules/request.js +117 -0
  174. package/frontend/dist/backend/src/database/collection.d.ts +1543 -0
  175. package/frontend/dist/backend/src/database/collection.js +3510 -0
  176. package/frontend/dist/backend/src/database/database.d.ts +66 -0
  177. package/frontend/dist/backend/src/database/database.js +196 -0
  178. package/frontend/dist/backend/src/database/filters/filters.d.ts +6 -0
  179. package/frontend/dist/backend/src/database/filters/filters.js +1 -0
  180. package/frontend/dist/backend/src/database/filters/strict_filter.d.ts +223 -0
  181. package/frontend/dist/backend/src/database/filters/strict_filter.js +3 -0
  182. package/frontend/dist/backend/src/database/filters/strict_update_filter.d.ts +165 -0
  183. package/frontend/dist/backend/src/database/filters/strict_update_filter.js +5 -0
  184. package/frontend/dist/backend/src/database/flatten.d.ts +75 -0
  185. package/frontend/dist/backend/src/database/flatten.js +22 -0
  186. package/frontend/dist/backend/src/endpoint.d.ts +204 -0
  187. package/frontend/dist/backend/src/endpoint.js +570 -0
  188. package/frontend/dist/backend/src/errors/index.d.ts +7 -0
  189. package/frontend/dist/backend/src/errors/index.js +7 -0
  190. package/frontend/dist/backend/src/errors/internal_external.d.ts +38 -0
  191. package/frontend/dist/backend/src/errors/internal_external.js +70 -0
  192. package/frontend/dist/backend/src/errors/invalid_usage_error.d.ts +38 -0
  193. package/frontend/dist/backend/src/errors/invalid_usage_error.js +30 -0
  194. package/frontend/dist/backend/src/errors/system_error.d.ts +230 -0
  195. package/frontend/dist/backend/src/errors/system_error.js +402 -0
  196. package/frontend/dist/backend/src/events.d.ts +54 -0
  197. package/frontend/dist/backend/src/events.js +5 -0
  198. package/frontend/dist/backend/src/frontend.d.ts +11 -0
  199. package/frontend/dist/backend/src/frontend.js +12 -0
  200. package/frontend/dist/backend/src/image_endpoint.d.ts +39 -0
  201. package/frontend/dist/backend/src/image_endpoint.js +202 -0
  202. package/frontend/dist/backend/src/meta.d.ts +64 -0
  203. package/frontend/dist/backend/src/meta.js +110 -0
  204. package/frontend/dist/backend/src/payments/paddle.d.ts +326 -0
  205. package/frontend/dist/backend/src/payments/paddle.js +2256 -0
  206. package/frontend/dist/backend/src/plugins/mail/mail.d.ts +248 -0
  207. package/frontend/dist/backend/src/plugins/mail/mail.js +389 -0
  208. package/{backend/dist/esm/plugins/mail.d.ts → frontend/dist/backend/src/plugins/mail/ui.d.ts} +23 -0
  209. package/{backend/dist/esm/plugins/mail.js → frontend/dist/backend/src/plugins/mail/ui.js} +3 -6
  210. package/frontend/dist/backend/src/rate_limit.d.ts +145 -0
  211. package/frontend/dist/backend/src/rate_limit.js +673 -0
  212. package/frontend/dist/backend/src/route.d.ts +35 -0
  213. package/frontend/dist/backend/src/route.js +212 -0
  214. package/frontend/dist/backend/src/server.d.ts +485 -0
  215. package/frontend/dist/backend/src/server.js +2670 -0
  216. package/frontend/dist/backend/src/splash_screen.d.ts +80 -0
  217. package/frontend/dist/backend/src/splash_screen.js +135 -0
  218. package/frontend/dist/backend/src/status.d.ts +74 -0
  219. package/frontend/dist/backend/src/status.js +199 -0
  220. package/frontend/dist/backend/src/stream.d.ts +376 -0
  221. package/frontend/dist/backend/src/stream.js +1007 -0
  222. package/frontend/dist/backend/src/users.d.ts +807 -0
  223. package/frontend/dist/backend/src/users.js +2118 -0
  224. package/frontend/dist/backend/src/utils.d.ts +16 -0
  225. package/frontend/dist/backend/src/utils.js +241 -0
  226. package/frontend/dist/backend/src/view.d.ts +162 -0
  227. package/frontend/dist/backend/src/view.js +720 -0
  228. package/frontend/dist/frontend/src/elements/base.d.ts +4414 -0
  229. package/frontend/dist/{elements → frontend/src/elements}/base.js +3624 -260
  230. package/frontend/dist/frontend/src/elements/module.d.ts +95 -0
  231. package/frontend/dist/{elements → frontend/src/elements}/module.js +53 -52
  232. package/frontend/dist/frontend/src/elements/types.d.ts +52 -0
  233. package/frontend/dist/frontend/src/elements/types.js +5 -0
  234. package/frontend/dist/frontend/src/modules/attachment.d.ts +126 -0
  235. package/frontend/dist/frontend/src/modules/attachment.js +306 -0
  236. package/frontend/dist/frontend/src/modules/auth.d.ts +44 -0
  237. package/frontend/dist/frontend/src/modules/auth.js +80 -0
  238. package/frontend/dist/{modules → frontend/src/modules}/color.js +2 -2
  239. package/frontend/dist/frontend/src/modules/compression.d.ts +39 -0
  240. package/frontend/dist/frontend/src/modules/compression.js +102 -0
  241. package/frontend/dist/frontend/src/modules/cookies.d.ts +44 -0
  242. package/frontend/dist/frontend/src/modules/cookies.js +143 -0
  243. package/frontend/dist/frontend/src/modules/events.d.ts +31 -0
  244. package/frontend/dist/frontend/src/modules/events.js +74 -0
  245. package/frontend/dist/frontend/src/modules/google.d.ts +23 -0
  246. package/frontend/dist/frontend/src/modules/google.js +52 -0
  247. package/frontend/dist/frontend/src/modules/meta.d.ts +14 -0
  248. package/frontend/dist/{modules → frontend/src/modules}/meta.js +9 -7
  249. package/frontend/dist/{modules → frontend/src/modules}/paddle.d.ts +37 -134
  250. package/frontend/dist/{modules → frontend/src/modules}/paddle.js +620 -568
  251. package/frontend/dist/frontend/src/modules/request.d.ts +70 -0
  252. package/frontend/dist/frontend/src/modules/request.js +117 -0
  253. package/frontend/dist/frontend/src/modules/settings.d.ts +3 -0
  254. package/frontend/dist/frontend/src/modules/settings.js +5 -0
  255. package/frontend/dist/frontend/src/modules/statics.d.ts +21 -0
  256. package/frontend/dist/{modules → frontend/src/modules}/statics.js +15 -18
  257. package/frontend/dist/frontend/src/modules/support.d.ts +30 -0
  258. package/frontend/dist/frontend/src/modules/support.js +53 -0
  259. package/frontend/dist/{modules → frontend/src/modules}/theme.d.ts +67 -0
  260. package/frontend/dist/{modules → frontend/src/modules}/theme.js +68 -38
  261. package/frontend/dist/frontend/src/modules/themes.d.ts +12 -0
  262. package/frontend/dist/frontend/src/modules/themes.js +22 -0
  263. package/frontend/dist/frontend/src/modules/user.d.ts +164 -0
  264. package/frontend/dist/frontend/src/modules/user.js +268 -0
  265. package/frontend/dist/frontend/src/modules/utils.d.ts +176 -0
  266. package/frontend/dist/frontend/src/modules/utils.js +569 -0
  267. package/frontend/dist/frontend/src/types/gradient.d.ts +29 -0
  268. package/frontend/dist/{types → frontend/src/types}/gradient.js +14 -18
  269. package/frontend/dist/frontend/src/ui/border_button.d.ts +94 -0
  270. package/frontend/dist/{ui → frontend/src/ui}/border_button.js +7 -13
  271. package/frontend/dist/frontend/src/ui/button.d.ts +28 -0
  272. package/frontend/dist/{ui → frontend/src/ui}/button.js +21 -12
  273. package/frontend/dist/frontend/src/ui/canvas.d.ts +138 -0
  274. package/frontend/dist/{ui → frontend/src/ui}/canvas.js +88 -55
  275. package/frontend/dist/frontend/src/ui/checkbox.d.ts +74 -0
  276. package/frontend/dist/{ui → frontend/src/ui}/checkbox.js +80 -41
  277. package/frontend/dist/{ui → frontend/src/ui}/code.d.ts +73 -6
  278. package/frontend/dist/{ui → frontend/src/ui}/code.js +55 -52
  279. package/frontend/dist/{ui → frontend/src/ui}/context_menu.d.ts +4 -0
  280. package/frontend/dist/{ui → frontend/src/ui}/context_menu.js +12 -17
  281. package/frontend/dist/{ui → frontend/src/ui}/css.d.ts +4 -0
  282. package/frontend/dist/{ui → frontend/src/ui}/css.js +3 -3
  283. package/frontend/dist/{ui → frontend/src/ui}/divider.d.ts +4 -0
  284. package/frontend/dist/{ui → frontend/src/ui}/divider.js +3 -3
  285. package/frontend/dist/{ui → frontend/src/ui}/dropdown.d.ts +57 -2
  286. package/frontend/dist/{ui → frontend/src/ui}/dropdown.js +87 -94
  287. package/frontend/dist/{ui → frontend/src/ui}/for_each.d.ts +4 -0
  288. package/frontend/dist/{ui → frontend/src/ui}/for_each.js +3 -3
  289. package/frontend/dist/{ui → frontend/src/ui}/form.d.ts +6 -2
  290. package/frontend/dist/{ui → frontend/src/ui}/form.js +10 -7
  291. package/frontend/dist/frontend/src/ui/frame_modes.d.ts +37 -0
  292. package/frontend/dist/{ui → frontend/src/ui}/frame_modes.js +16 -22
  293. package/frontend/dist/{ui → frontend/src/ui}/google_map.d.ts +4 -0
  294. package/frontend/dist/{ui → frontend/src/ui}/google_map.js +4 -4
  295. package/frontend/dist/{ui → frontend/src/ui}/gradient.d.ts +4 -0
  296. package/frontend/dist/{ui → frontend/src/ui}/gradient.js +3 -3
  297. package/frontend/dist/{ui → frontend/src/ui}/image.d.ts +4 -0
  298. package/frontend/dist/{ui → frontend/src/ui}/image.js +5 -5
  299. package/frontend/dist/frontend/src/ui/input.d.ts +392 -0
  300. package/frontend/dist/{ui → frontend/src/ui}/input.js +346 -360
  301. package/frontend/dist/{ui → frontend/src/ui}/link.d.ts +4 -0
  302. package/frontend/dist/{ui → frontend/src/ui}/link.js +3 -3
  303. package/frontend/dist/{ui → frontend/src/ui}/list.d.ts +4 -0
  304. package/frontend/dist/{ui → frontend/src/ui}/list.js +12 -6
  305. package/frontend/dist/frontend/src/ui/loader_button.d.ts +80 -0
  306. package/frontend/dist/{ui → frontend/src/ui}/loader_button.js +35 -47
  307. package/frontend/dist/frontend/src/ui/loaders.d.ts +57 -0
  308. package/frontend/dist/{ui → frontend/src/ui}/loaders.js +11 -11
  309. package/frontend/dist/{ui → frontend/src/ui}/popup.d.ts +11 -6
  310. package/frontend/dist/{ui → frontend/src/ui}/popup.js +32 -18
  311. package/frontend/dist/frontend/src/ui/pseudo.d.ts +44 -0
  312. package/frontend/dist/{ui → frontend/src/ui}/pseudo.js +84 -8
  313. package/frontend/dist/{ui → frontend/src/ui}/scroller.d.ts +14 -2
  314. package/frontend/dist/{ui → frontend/src/ui}/scroller.js +37 -43
  315. package/frontend/dist/{ui → frontend/src/ui}/slider.d.ts +5 -1
  316. package/frontend/dist/{ui → frontend/src/ui}/slider.js +4 -4
  317. package/frontend/dist/{ui → frontend/src/ui}/spacer.d.ts +4 -0
  318. package/frontend/dist/{ui → frontend/src/ui}/spacer.js +3 -3
  319. package/frontend/dist/{ui → frontend/src/ui}/span.d.ts +4 -0
  320. package/frontend/dist/{ui → frontend/src/ui}/span.js +3 -3
  321. package/frontend/dist/{ui → frontend/src/ui}/stack.d.ts +4 -0
  322. package/frontend/dist/{ui → frontend/src/ui}/stack.js +3 -9
  323. package/frontend/dist/frontend/src/ui/steps.d.ts +131 -0
  324. package/frontend/dist/{ui → frontend/src/ui}/steps.js +30 -45
  325. package/frontend/dist/{ui → frontend/src/ui}/style.d.ts +4 -0
  326. package/frontend/dist/{ui → frontend/src/ui}/style.js +3 -3
  327. package/frontend/dist/{ui → frontend/src/ui}/switch.d.ts +5 -1
  328. package/frontend/dist/{ui → frontend/src/ui}/switch.js +4 -4
  329. package/frontend/dist/{ui → frontend/src/ui}/table.d.ts +4 -0
  330. package/frontend/dist/{ui → frontend/src/ui}/table.js +6 -6
  331. package/frontend/dist/{ui → frontend/src/ui}/tabs.d.ts +45 -3
  332. package/frontend/dist/{ui → frontend/src/ui}/tabs.js +65 -40
  333. package/frontend/dist/{ui → frontend/src/ui}/text.d.ts +4 -0
  334. package/frontend/dist/{ui → frontend/src/ui}/text.js +3 -3
  335. package/frontend/dist/frontend/src/ui/title.d.ts +91 -0
  336. package/frontend/dist/frontend/src/ui/title.js +272 -0
  337. package/frontend/dist/{ui → frontend/src/ui}/view.d.ts +4 -0
  338. package/frontend/dist/{ui → frontend/src/ui}/view.js +3 -3
  339. package/frontend/dist/{volt.d.ts → frontend/src/volt.d.ts} +3 -0
  340. package/frontend/dist/{volt.js → frontend/src/volt.js} +4 -0
  341. package/frontend/tools/bundle_d_ts.js +71 -0
  342. package/frontend/tools/convert_to_jsdoc_input.txt +9452 -0
  343. package/frontend/tools/convert_to_jsdoc_output.txt +7626 -0
  344. package/frontend/tools/convert_to_jsdoc_tmp.js +345 -0
  345. package/package.json +11 -12
  346. package/backend/dist/cjs/database/collection.d.ts +0 -160
  347. package/backend/dist/cjs/database/collection.js +0 -842
  348. package/backend/dist/cjs/database/database.d.ts +0 -121
  349. package/backend/dist/cjs/database/document.d.ts +0 -131
  350. package/backend/dist/cjs/database/document.js +0 -224
  351. package/backend/dist/cjs/database.d.ts +0 -502
  352. package/backend/dist/cjs/database.js +0 -2248
  353. package/backend/dist/cjs/logger.d.ts +0 -3
  354. package/backend/dist/cjs/meta.d.ts +0 -50
  355. package/backend/dist/cjs/mutex.d.ts +0 -24
  356. package/backend/dist/cjs/payments/paddle.d.ts +0 -160
  357. package/backend/dist/cjs/plugins/browser.d.ts +0 -36
  358. package/backend/dist/cjs/plugins/browser.js +0 -198
  359. package/backend/dist/cjs/plugins/css.d.ts +0 -11
  360. package/backend/dist/cjs/plugins/css.js +0 -80
  361. package/backend/dist/cjs/plugins/mail.d.ts +0 -277
  362. package/backend/dist/cjs/plugins/mail.js +0 -1370
  363. package/backend/dist/cjs/plugins/ts/compiler.d.ts +0 -139
  364. package/backend/dist/cjs/plugins/ts/compiler.js +0 -750
  365. package/backend/dist/cjs/plugins/ts/preprocessing.d.ts +0 -14
  366. package/backend/dist/cjs/plugins/ts/preprocessing.js +0 -440
  367. package/backend/dist/cjs/rate_limit.d.ts +0 -63
  368. package/backend/dist/cjs/rate_limit.js +0 -348
  369. package/backend/dist/cjs/request.deprc.d.ts +0 -48
  370. package/backend/dist/cjs/request.deprc.js +0 -572
  371. package/backend/dist/cjs/response.deprc.d.ts +0 -55
  372. package/backend/dist/cjs/response.deprc.js +0 -275
  373. package/backend/dist/cjs/server.d.ts +0 -342
  374. package/backend/dist/cjs/splash_screen.d.ts +0 -35
  375. package/backend/dist/cjs/status.d.ts +0 -61
  376. package/backend/dist/cjs/stream.d.ts +0 -79
  377. package/backend/dist/cjs/users.d.ts +0 -111
  378. package/backend/dist/cjs/users.js +0 -1817
  379. package/backend/dist/cjs/view.js +0 -352
  380. package/backend/dist/cjs/vinc.dev.d.ts +0 -3
  381. package/backend/dist/cjs/vinc.dev.js +0 -7
  382. package/backend/dist/css/adyen.css +0 -92
  383. package/backend/dist/css/volt.css +0 -70
  384. package/backend/dist/esm/database/collection.d.ts +0 -160
  385. package/backend/dist/esm/database/collection.js +0 -1328
  386. package/backend/dist/esm/database/database.d.ts +0 -121
  387. package/backend/dist/esm/database/document.d.ts +0 -131
  388. package/backend/dist/esm/database/document.js +0 -247
  389. package/backend/dist/esm/database.d.ts +0 -502
  390. package/backend/dist/esm/database.js +0 -2423
  391. package/backend/dist/esm/file_watcher.js +0 -329
  392. package/backend/dist/esm/logger.d.ts +0 -3
  393. package/backend/dist/esm/logger.js +0 -11
  394. package/backend/dist/esm/meta.d.ts +0 -50
  395. package/backend/dist/esm/mutex.d.ts +0 -24
  396. package/backend/dist/esm/mutex.js +0 -48
  397. package/backend/dist/esm/payments/paddle.d.ts +0 -160
  398. package/backend/dist/esm/plugins/browser.d.ts +0 -36
  399. package/backend/dist/esm/plugins/browser.js +0 -176
  400. package/backend/dist/esm/plugins/css.d.ts +0 -11
  401. package/backend/dist/esm/plugins/css.js +0 -90
  402. package/backend/dist/esm/plugins/ts/compiler.d.ts +0 -139
  403. package/backend/dist/esm/plugins/ts/compiler.js +0 -1194
  404. package/backend/dist/esm/plugins/ts/preprocessing.d.ts +0 -14
  405. package/backend/dist/esm/plugins/ts/preprocessing.js +0 -726
  406. package/backend/dist/esm/rate_limit.d.ts +0 -63
  407. package/backend/dist/esm/rate_limit.js +0 -417
  408. package/backend/dist/esm/request.deprc.d.ts +0 -48
  409. package/backend/dist/esm/request.deprc.js +0 -572
  410. package/backend/dist/esm/response.deprc.d.ts +0 -55
  411. package/backend/dist/esm/response.deprc.js +0 -275
  412. package/backend/dist/esm/server.d.ts +0 -342
  413. package/backend/dist/esm/splash_screen.d.ts +0 -35
  414. package/backend/dist/esm/status.d.ts +0 -61
  415. package/backend/dist/esm/status.js +0 -197
  416. package/backend/dist/esm/stream.d.ts +0 -79
  417. package/backend/dist/esm/users.d.ts +0 -111
  418. package/backend/dist/esm/users.js +0 -1935
  419. package/backend/dist/esm/vinc.dev.d.ts +0 -3
  420. package/backend/dist/esm/vinc.dev.js +0 -7
  421. package/frontend/dist/elements/base.d.ts +0 -9889
  422. package/frontend/dist/elements/module.d.ts +0 -30
  423. package/frontend/dist/modules/array.d.ts +0 -94
  424. package/frontend/dist/modules/array.js +0 -634
  425. package/frontend/dist/modules/auth.d.ts +0 -46
  426. package/frontend/dist/modules/auth.js +0 -139
  427. package/frontend/dist/modules/colors.d.ts +0 -1
  428. package/frontend/dist/modules/colors.js +0 -417
  429. package/frontend/dist/modules/compression.d.ts +0 -6
  430. package/frontend/dist/modules/compression.js +0 -999
  431. package/frontend/dist/modules/cookies.d.ts +0 -18
  432. package/frontend/dist/modules/cookies.js +0 -167
  433. package/frontend/dist/modules/date.d.ts +0 -142
  434. package/frontend/dist/modules/date.js +0 -493
  435. package/frontend/dist/modules/events.d.ts +0 -8
  436. package/frontend/dist/modules/events.js +0 -91
  437. package/frontend/dist/modules/google.d.ts +0 -11
  438. package/frontend/dist/modules/google.js +0 -54
  439. package/frontend/dist/modules/meta.d.ts +0 -10
  440. package/frontend/dist/modules/mutex.d.ts +0 -7
  441. package/frontend/dist/modules/mutex.js +0 -51
  442. package/frontend/dist/modules/number.d.ts +0 -16
  443. package/frontend/dist/modules/number.js +0 -23
  444. package/frontend/dist/modules/object.d.ts +0 -52
  445. package/frontend/dist/modules/object.js +0 -383
  446. package/frontend/dist/modules/scheme.d.ts +0 -227
  447. package/frontend/dist/modules/scheme.js +0 -531
  448. package/frontend/dist/modules/settings.d.ts +0 -3
  449. package/frontend/dist/modules/settings.js +0 -4
  450. package/frontend/dist/modules/statics.d.ts +0 -5
  451. package/frontend/dist/modules/string.d.ts +0 -124
  452. package/frontend/dist/modules/string.js +0 -745
  453. package/frontend/dist/modules/support.d.ts +0 -19
  454. package/frontend/dist/modules/support.js +0 -103
  455. package/frontend/dist/modules/themes.d.ts +0 -8
  456. package/frontend/dist/modules/themes.js +0 -18
  457. package/frontend/dist/modules/user.d.ts +0 -59
  458. package/frontend/dist/modules/user.js +0 -280
  459. package/frontend/dist/modules/utils.d.ts +0 -87
  460. package/frontend/dist/modules/utils.js +0 -923
  461. package/frontend/dist/types/gradient.d.ts +0 -12
  462. package/frontend/dist/ui/border_button.d.ts +0 -152
  463. package/frontend/dist/ui/button.d.ts +0 -21
  464. package/frontend/dist/ui/canvas.d.ts +0 -56
  465. package/frontend/dist/ui/checkbox.d.ts +0 -52
  466. package/frontend/dist/ui/frame_modes.d.ts +0 -25
  467. package/frontend/dist/ui/input.d.ts +0 -241
  468. package/frontend/dist/ui/loader_button.d.ts +0 -93
  469. package/frontend/dist/ui/loaders.d.ts +0 -57
  470. package/frontend/dist/ui/pseudo.d.ts +0 -16
  471. package/frontend/dist/ui/steps.d.ts +0 -59
  472. package/frontend/dist/ui/title.d.ts +0 -21
  473. package/frontend/dist/ui/title.js +0 -121
  474. package/frontend/examples/dashboard/dashboard.ts +0 -776
  475. /package/backend/dist/cjs/{cli.d.ts → backend/src/cli.d.ts} +0 -0
  476. /package/backend/dist/cjs/{file_watcher.d.ts → backend/src/database/document.d.ts} +0 -0
  477. /package/backend/dist/cjs/{file_watcher.js → backend/src/database/document.js} +0 -0
  478. /package/backend/dist/cjs/{plugins/pdf.d.ts → backend/src/database/filters/strict_filter_test.d.ts} +0 -0
  479. /package/backend/dist/{esm/file_watcher.d.ts → cjs/backend/src/database/filters/strict_filter_test_v0.d.ts} +0 -0
  480. /package/backend/dist/{esm/plugins/pdf.d.ts → cjs/backend/src/database/flatten_test.d.ts} +0 -0
  481. /package/backend/dist/cjs/{frontend.d.ts → backend/src/frontend.d.ts} +0 -0
  482. /package/backend/dist/cjs/{plugins → backend/src/plugins}/communication.d.ts +0 -0
  483. /package/backend/dist/cjs/{plugins → backend/src/plugins}/communication.js +0 -0
  484. /package/backend/dist/cjs/{plugins → backend/src/plugins}/mail/ui.js +0 -0
  485. /package/backend/dist/cjs/{plugins → backend/src/plugins}/pdf.js +0 -0
  486. /package/backend/dist/cjs/{plugins → backend/src/plugins}/thread_monitor.d.ts +0 -0
  487. /package/backend/dist/cjs/{plugins → backend/src/plugins}/thread_monitor.js +0 -0
  488. /package/backend/dist/cjs/{vinc.d.ts → backend/src/vinc.d.ts} +0 -0
  489. /package/backend/dist/cjs/{vinc.js → backend/src/vinc.js} +0 -0
  490. /package/backend/dist/esm/{cli.d.ts → backend/src/cli.d.ts} +0 -0
  491. /package/backend/dist/esm/{frontend.d.ts → backend/src/frontend.d.ts} +0 -0
  492. /package/backend/dist/esm/{plugins → backend/src/plugins}/communication.d.ts +0 -0
  493. /package/backend/dist/esm/{plugins → backend/src/plugins}/communication.js +0 -0
  494. /package/backend/dist/esm/{plugins → backend/src/plugins}/thread_monitor.d.ts +0 -0
  495. /package/backend/dist/esm/{plugins → backend/src/plugins}/thread_monitor.js +0 -0
  496. /package/backend/dist/esm/{vinc.d.ts → backend/src/vinc.d.ts} +0 -0
  497. /package/backend/dist/esm/{vinc.js → backend/src/vinc.js} +0 -0
  498. /package/frontend/dist/{elements → frontend/src/elements}/register_element.d.ts +0 -0
  499. /package/frontend/dist/{elements → frontend/src/elements}/register_element.js +0 -0
  500. /package/frontend/dist/{modules → frontend/src/modules}/color.d.ts +0 -0
  501. /package/frontend/dist/{ui → frontend/src/ui}/ui.d.ts +0 -0
  502. /package/frontend/dist/{ui → frontend/src/ui}/ui.js +0 -0
@@ -0,0 +1,1007 @@
1
+ /**
2
+ * @author Daan van den Bergh
3
+ * @copyright © 2025 - 2025 Daan van den Bergh. All rights reserved.
4
+ */
5
+ // ---------------------------------------------------------
6
+ // Imports.
7
+ import zlib from 'zlib';
8
+ import * as vlib from "@vandenberghinc/vlib";
9
+ import RateLimits from './rate_limit.js';
10
+ const { debug } = vlib;
11
+ // ---------------------------------------------------------
12
+ // Request object.
13
+ /**
14
+ * The http2 stream wrapper object.
15
+ *
16
+ * @property headers The request headers.
17
+ * @docs
18
+ */
19
+ export class Stream {
20
+ s;
21
+ headers;
22
+ req;
23
+ res;
24
+ http2;
25
+ http1;
26
+ _ip;
27
+ _port;
28
+ _method;
29
+ _params;
30
+ _is_query_params;
31
+ _endpoint;
32
+ _query_string;
33
+ _cookies;
34
+ _uid;
35
+ status_code;
36
+ finished;
37
+ res_cookies;
38
+ res_headers;
39
+ body;
40
+ promise;
41
+ /** The cached value of {@link normalize_ip} */
42
+ _normalized_ip;
43
+ /**
44
+ * Create a new Stream wrapper for HTTP/1.1 or HTTP/2.
45
+ *
46
+ * @param stream The HTTP/2 stream (when using HTTP/2).
47
+ * @param headers The request headers.
48
+ * @param req The HTTP/1.1 request (when using HTTP/1.1).
49
+ * @param res The HTTP/1.1/HTTP/2 response object.
50
+ */
51
+ constructor(stream, headers, req, res) {
52
+ // Parameters.
53
+ this.s = stream;
54
+ this.headers = (headers ?? {});
55
+ this.req = req;
56
+ this.res = res;
57
+ this.http2 = req == null;
58
+ this.http1 = req != null;
59
+ // HTTP1.
60
+ if (this.http1) {
61
+ this.headers = this.req.headers;
62
+ }
63
+ // Request attributes.
64
+ this._ip = this.http2 ? this.s.session.socket.remoteAddress : this.req.socket.remoteAddress;
65
+ this._port = this.http2 ? this.s.session.socket.remotePort : this.req.socket.remotePort;
66
+ this._method = this.http2 ? this.headers[':method'] : this.req.method;
67
+ this._params = undefined;
68
+ this._is_query_params = false;
69
+ this._endpoint = undefined;
70
+ this._query_string = undefined;
71
+ this._cookies = undefined;
72
+ this._uid = undefined;
73
+ // Response attributes
74
+ this.status_code = undefined;
75
+ this.finished = false;
76
+ this.res_cookies = [];
77
+ this.res_headers = this.http1 ? [] : {};
78
+ // Read body.
79
+ this.body = "";
80
+ this.promise = undefined;
81
+ this._recv_body();
82
+ }
83
+ /**
84
+ * Receive and buffer the request body, handling optional gzip/deflate decompression.
85
+ * Sets {@link body} and resolves the internal promise used by {@link join}.
86
+ * @private
87
+ */
88
+ _recv_body() {
89
+ this.promise = new Promise((resolve, reject) => {
90
+ // Buffers.
91
+ const buffs = [];
92
+ // Get decompress stream.
93
+ let decompress_stream;
94
+ const content_encoding = this.headers['content-encoding'];
95
+ if (content_encoding === 'gzip') {
96
+ decompress_stream = zlib.createGunzip();
97
+ }
98
+ else if (content_encoding === 'deflate') {
99
+ decompress_stream = zlib.createInflate();
100
+ }
101
+ const cleanup = () => {
102
+ if (decompress_stream) {
103
+ decompress_stream.close();
104
+ }
105
+ };
106
+ // HTTP2.
107
+ if (this.http2) {
108
+ let stream = this.s;
109
+ // If decompression is needed, pipe the stream through the decompression stream
110
+ if (decompress_stream) {
111
+ stream = this.s.pipe(decompress_stream);
112
+ // decompress_stream.on('error', (e) => { cleanup(); reject(e); });
113
+ }
114
+ // On error.
115
+ stream.on('error', (e) => { cleanup(); reject(e); });
116
+ // Receive data.
117
+ stream.on('data', (chunk) => {
118
+ buffs.push(chunk);
119
+ });
120
+ stream.on('end', () => {
121
+ this.body = Buffer.concat(buffs).toString();
122
+ cleanup();
123
+ resolve();
124
+ });
125
+ }
126
+ // HTTP1.
127
+ else {
128
+ let stream = this.req;
129
+ // Decompress data.
130
+ if (decompress_stream) {
131
+ this.req.pipe(decompress_stream);
132
+ stream = decompress_stream;
133
+ }
134
+ // On error.
135
+ stream.on('error', (e) => { cleanup(); reject(e); });
136
+ // Receive data.
137
+ stream.on("data", (data) => {
138
+ buffs.push(data);
139
+ });
140
+ stream.on("end", () => {
141
+ this.body = Buffer.concat(buffs).toString();
142
+ cleanup();
143
+ resolve();
144
+ });
145
+ }
146
+ });
147
+ }
148
+ /**
149
+ * Parse and cache the request endpoint and query string.
150
+ * Populates {@link _endpoint} and {@link _query_string}.
151
+ * @private
152
+ */
153
+ _parse_endoint() {
154
+ if (this._endpoint !== undefined) {
155
+ return;
156
+ }
157
+ this._endpoint = this.http2 ? this.headers[":path"] : this.req.url;
158
+ let index;
159
+ if ((index = this._endpoint.indexOf("?")) !== -1) {
160
+ this._query_string = this._endpoint.substr(index + 1);
161
+ this._endpoint = this._endpoint.substr(0, index);
162
+ }
163
+ this._endpoint = this._endpoint.replace(/\/\//g, "/");
164
+ if (this._endpoint.length > 1 && this._endpoint.charAt(this._endpoint.length - 1) === "/") {
165
+ this._endpoint = this._endpoint.substr(0, this._endpoint.length - 1);
166
+ }
167
+ }
168
+ /**
169
+ * Parse and cache request parameters from the query string or JSON body.
170
+ * Returns the parsed params map.
171
+ */
172
+ _parse_params() {
173
+ // Parse query string.
174
+ this._parse_endoint();
175
+ // Already parsed.
176
+ if (this._params !== undefined) {
177
+ return;
178
+ }
179
+ // Initialize.
180
+ this._params = {};
181
+ // By query string.
182
+ if (this._query_string !== undefined) {
183
+ // As encoded json.
184
+ if (this._query_string.charAt(0) === "{") {
185
+ try {
186
+ this._params = JSON.parse(decodeURIComponent(this._query_string));
187
+ }
188
+ catch (err) {
189
+ throw Error(`Invalid json request query: ${err}.`);
190
+ }
191
+ }
192
+ // As query string.
193
+ else {
194
+ // Assign.
195
+ this._is_query_params = true;
196
+ // Variables.
197
+ let is_key = true, key = "", value = "";
198
+ const number_regex = /^-?\d+(\.\d+)?$/;
199
+ // Callback.
200
+ const add_value = () => {
201
+ let output_value;
202
+ switch (value) {
203
+ case "true":
204
+ case "True":
205
+ output_value = true;
206
+ break;
207
+ case "false":
208
+ case "False":
209
+ output_value = false;
210
+ break;
211
+ case "null":
212
+ case "None":
213
+ case "undefined":
214
+ output_value = null;
215
+ break;
216
+ default:
217
+ output_value = decodeURIComponent(value.replaceAll("+", " "));
218
+ if (number_regex.test(output_value)) {
219
+ if (output_value.indexOf(".") !== -1) {
220
+ output_value = parseFloat(output_value);
221
+ }
222
+ else {
223
+ output_value = parseInt(output_value);
224
+ }
225
+ }
226
+ break;
227
+ }
228
+ this._params[decodeURIComponent(key.replaceAll("+", " "))] = output_value;
229
+ key = "";
230
+ value = "";
231
+ is_key = true;
232
+ };
233
+ // Iterate
234
+ for (let i = 0; i < this._query_string.length; i++) {
235
+ const c = this._query_string.charAt(i);
236
+ if (is_key && c === "=") {
237
+ is_key = false;
238
+ continue;
239
+ }
240
+ else if (is_key === false && c === "&") {
241
+ add_value();
242
+ continue;
243
+ }
244
+ if (is_key) {
245
+ key += c;
246
+ }
247
+ else {
248
+ value += c;
249
+ }
250
+ }
251
+ if (key.length > 0) {
252
+ add_value();
253
+ }
254
+ }
255
+ }
256
+ // By body.
257
+ else if (this.body.trim().charAt(0) === "{") {
258
+ try {
259
+ this._params = JSON.parse(this.body);
260
+ }
261
+ catch (err) {
262
+ throw Error(`Invalid json request body: ${err}.`);
263
+ }
264
+ }
265
+ // Handler.
266
+ return this._params;
267
+ }
268
+ /**
269
+ * Parses & returns the cookies cookies,
270
+ * while assigning it to {@link _cookies}
271
+ *
272
+ * @warning On subsequent calls cookies will be parsed again.
273
+ */
274
+ _parse_cookies() {
275
+ // Reset cookies.
276
+ this._cookies = {};
277
+ // Vars.
278
+ const cookie_str = this.http2 ? this.headers["cookie"] : this.req.headers.cookie;
279
+ if (cookie_str == null) {
280
+ return this._cookies;
281
+ }
282
+ let key = "";
283
+ let value = "";
284
+ let cookie = {};
285
+ let cookie_length = 0;
286
+ let cookie_key = null;
287
+ let is_value = false;
288
+ let is_str = null;
289
+ // Append to cookie.
290
+ const append_to_cookie = () => {
291
+ if (key.length > 0) {
292
+ if (cookie_length === 0) {
293
+ cookie.value = value;
294
+ }
295
+ else {
296
+ cookie[key] = value;
297
+ }
298
+ ++cookie_length;
299
+ }
300
+ key = "";
301
+ value = "";
302
+ is_value = false;
303
+ is_str = null;
304
+ };
305
+ // Append cookie.
306
+ const append_cookie = () => {
307
+ if (cookie_key != null) {
308
+ this._cookies[cookie_key] = cookie;
309
+ cookie_key = null;
310
+ cookie = {};
311
+ cookie_length = 0;
312
+ }
313
+ };
314
+ // Iterate.
315
+ for (let x = 0; x < cookie_str.length; x++) {
316
+ const c = cookie_str.charAt(x);
317
+ // Add char to value.
318
+ if (is_value) {
319
+ // End of cookie string.
320
+ if (is_str === c) {
321
+ value = value.substr(1, value.length - 1);
322
+ append_to_cookie();
323
+ }
324
+ // Cookie seperator.
325
+ else if (is_str == null && c === " ") {
326
+ append_to_cookie();
327
+ }
328
+ // End of cookie.
329
+ else if (is_str == null && c === ";") {
330
+ append_to_cookie();
331
+ append_cookie();
332
+ }
333
+ // Append to value.
334
+ else {
335
+ value += c;
336
+ if (value.length === 1 && (c === "\"" || c === "'")) {
337
+ is_str = c;
338
+ }
339
+ }
340
+ }
341
+ // Skip whitespace in keys.
342
+ else if (c == " " || c == "\t") {
343
+ continue;
344
+ }
345
+ // End of cookie key.
346
+ else if (c == "=") {
347
+ if (cookie_key == null) {
348
+ cookie_key = key;
349
+ }
350
+ is_value = true;
351
+ }
352
+ // Add char to key.
353
+ else {
354
+ key += c;
355
+ }
356
+ }
357
+ append_to_cookie();
358
+ append_cookie();
359
+ return this._cookies;
360
+ }
361
+ // ---------------------------------------------------------
362
+ // Functions.
363
+ /**
364
+ * Wait until the request body is fully received.
365
+ * Resolves when the internal receive promise completes.
366
+ */
367
+ async join() {
368
+ await this.promise;
369
+ }
370
+ // Get the requests ip.
371
+ /**
372
+ * Get the request's ip.
373
+ *
374
+ * @example
375
+ * ```ts
376
+ * const ip = stream.ip;
377
+ * ```
378
+ * @docs
379
+ */
380
+ get ip() {
381
+ return this._ip;
382
+ }
383
+ /**
384
+ * Retrieve the normalized IP address, suitable for rate limiting and logging.
385
+ * @throws {Error} If the IP is invalid.
386
+ * @returns The normalized IP.
387
+ */
388
+ normalized_ip() {
389
+ if (this._normalized_ip != null) {
390
+ return this._normalized_ip;
391
+ }
392
+ return this._normalized_ip = RateLimits.normalize_ip(this._ip);
393
+ }
394
+ // Get the requests port.
395
+ /**
396
+ * Get the request's port.
397
+ *
398
+ * @example
399
+ * ```ts
400
+ * const port = stream.port;
401
+ * ```
402
+ * @docs
403
+ */
404
+ get port() {
405
+ return this._port;
406
+ }
407
+ // Get the method.
408
+ /**
409
+ * Get the request method.
410
+ *
411
+ * @example
412
+ * ```ts
413
+ * const method = stream.method;
414
+ * ```
415
+ * @docs
416
+ */
417
+ get method() {
418
+ return this._method;
419
+ }
420
+ // Get the endpoint.
421
+ /**
422
+ * Get the request's endpoint. This will not include the query string.
423
+ *
424
+ * @example
425
+ * ```ts
426
+ * const endpoint = stream.endpoint;
427
+ * ```
428
+ * @docs
429
+ */
430
+ get endpoint() {
431
+ if (this._endpoint !== undefined) {
432
+ return this._endpoint;
433
+ }
434
+ this._parse_endoint();
435
+ return this._endpoint;
436
+ }
437
+ // Get the params.
438
+ /**
439
+ * Get the request's query or body params.
440
+ *
441
+ * @example
442
+ * ```ts
443
+ * const params = stream.params;
444
+ * ```
445
+ * @docs
446
+ */
447
+ get params() {
448
+ if (this._params !== undefined) {
449
+ return this._params;
450
+ }
451
+ this._parse_params();
452
+ return this._params;
453
+ }
454
+ /** Add a param (used by the server backend for path parameters). */
455
+ add_param(name, value) {
456
+ if (!this._params) {
457
+ this._params = {};
458
+ }
459
+ this._params[name] = value;
460
+ }
461
+ // Get a param by name and optionally by type.
462
+ /**
463
+ * Get a single query or body parameter with an optional type cast.
464
+ *
465
+ * @warning Throws an error when the parameter does not exist or when the type is different from the specified type(s), unless parameter `def` is defined.
466
+ *
467
+ * @param name The name of the parameter.
468
+ * @param type The type cast of the parameters, valid types are `[null, "boolean", "number", "string", "array", "object"]`.
469
+ * @param def
470
+ * The default value to return when the parameter does not exist.
471
+ *
472
+ * If the parameter is not defined and `def` is `undefined` then this function will throw an error.
473
+ * When `def` is `undefined` errors will be thrown, when `def` is `null` and the parameter is undefined then `null` will be returned as the default value.
474
+ *
475
+ * Errors will always be thrown when the incorrect type has been sent by the user.
476
+ * @example
477
+ * ```ts
478
+ * const param = stream.param("myparameter", "number", 10);
479
+ * ```
480
+ * @docs
481
+ */
482
+ param(name, type = null, def = undefined) {
483
+ // Parse params.
484
+ this._parse_params();
485
+ // Get value.
486
+ let value = this._params[name];
487
+ // Check type.
488
+ if (type != null) {
489
+ // Vars.
490
+ let is_type_array = Array.isArray(type);
491
+ // Wrapper funcs.
492
+ const type_str = () => {
493
+ let str = "";
494
+ if (type != null) {
495
+ str += " type ";
496
+ if (is_type_array) {
497
+ let i = 0, one_but_last_i = type.length - 2;
498
+ type.forEach((item, i) => {
499
+ str += `"${item}"`;
500
+ if (i < one_but_last_i) {
501
+ str += ", ";
502
+ }
503
+ else if (i === one_but_last_i) {
504
+ str += " or ";
505
+ }
506
+ });
507
+ }
508
+ else {
509
+ str += `"${type}"`;
510
+ }
511
+ }
512
+ return str;
513
+ };
514
+ const type_eq_or_includes = (match) => {
515
+ if (is_type_array) {
516
+ return type.includes(match);
517
+ }
518
+ return match === type;
519
+ };
520
+ // Check undefined.
521
+ if (value == null || value === "") {
522
+ if (def !== undefined) {
523
+ return def;
524
+ }
525
+ throw Error(`Define parameter "${name}"${type_str()}.`);
526
+ }
527
+ // Cast the value to another type when a query string was used.
528
+ if (this._is_query_params && type_eq_or_includes("string") === false) {
529
+ if (is_type_array === false) {
530
+ type = [type];
531
+ }
532
+ const success = type.some((type) => {
533
+ // Convert to string.
534
+ if (type === "string") {
535
+ return true;
536
+ }
537
+ // Convert to null.
538
+ if (type === "null" && value === "null") {
539
+ value = null;
540
+ return true;
541
+ }
542
+ // Convert to boolean.
543
+ const is_boolean = type === "boolean";
544
+ if (is_boolean && value === "true") {
545
+ value = true;
546
+ return true;
547
+ }
548
+ if (is_boolean && value === "false") {
549
+ value = false;
550
+ return true;
551
+ }
552
+ // Convert to array.
553
+ if (type === "array") {
554
+ value = value.split(",");
555
+ return true;
556
+ }
557
+ // Convert to object.
558
+ if (type === "object") {
559
+ const split = value.split(",");
560
+ value = {};
561
+ split.forEach((item) => {
562
+ const pair = item.split(":");
563
+ value[pair[0]] = pair[1];
564
+ });
565
+ return true;
566
+ }
567
+ // Convert to numeric.
568
+ if (type === "number" && /^-?\d+(\.\d+)?$/.test(value)) {
569
+ value = parseFloat(value);
570
+ return true;
571
+ }
572
+ });
573
+ if (!success) {
574
+ throw Error(`Parameter "${name}" should be of${type_str()}.`);
575
+ }
576
+ }
577
+ // Check the type when no query params are defined since JSON.parse already parsed the types.
578
+ else if (!this._is_query_params) {
579
+ const value_type = typeof value;
580
+ if (!is_type_array) {
581
+ type = [type];
582
+ }
583
+ const success = type.some((type) => {
584
+ const l_is_array = type === "array";
585
+ const l_is_null = type === "null";
586
+ // Same type.
587
+ if (!l_is_array && !l_is_null && type === value_type) {
588
+ return true;
589
+ }
590
+ // Check to null.
591
+ if (l_is_null && value == null) {
592
+ return true;
593
+ }
594
+ // Convert to array.
595
+ if (l_is_array && Array.isArray(value)) {
596
+ return true;
597
+ }
598
+ });
599
+ if (!success) {
600
+ throw Error(`Parameter "${name}" should be of${type_str()}.`);
601
+ }
602
+ }
603
+ }
604
+ // Check undefined.
605
+ else if (value == null || value === "") {
606
+ if (def !== undefined) {
607
+ return def;
608
+ }
609
+ throw Error(`Define parameter "${name}".`);
610
+ }
611
+ // Return value.
612
+ return value;
613
+ }
614
+ // Get the request cookies.
615
+ /**
616
+ * Get the request's cookies
617
+ *
618
+ * @example
619
+ * ```ts
620
+ * const cookies = stream.cookies;
621
+ * ```
622
+ * @docs
623
+ */
624
+ get cookies() {
625
+ if (this._cookies != null)
626
+ return this._cookies;
627
+ return this._parse_cookies();
628
+ }
629
+ // DEPRECATED since its only available for http2.
630
+ // /**
631
+ // * Check if the stream is closed.
632
+ // *
633
+ // * @example
634
+ // * ```ts
635
+ // * const ip = stream.closed;
636
+ // * ```
637
+ // * @docs
638
+ // */
639
+ // get closed(): boolean {
640
+ // if (!this.http2) { throw new Error("This function is only supported for http2 streams."); }
641
+ // return this.s!.closed;
642
+ // }
643
+ // Check if the stream is destroyed
644
+ /**
645
+ * Check if the stream is destroyed.
646
+ *
647
+ * @example
648
+ * ```ts
649
+ * const ip = stream.destroyed;
650
+ * ```
651
+ * @docs
652
+ */
653
+ get destroyed() {
654
+ if (this.http2) {
655
+ return this.s.destroyed;
656
+ }
657
+ else {
658
+ return this.req.destroyed;
659
+ }
660
+ }
661
+ // ---------------------------------------------------------
662
+ // Functions.
663
+ // Get the authenticated uid.
664
+ /**
665
+ * Get the authenticated uid; `undefined` when the request was not authenticated.
666
+ *
667
+ * @example
668
+ * ```ts
669
+ * const uid = stream.uid;
670
+ * ```
671
+ * @docs
672
+ */
673
+ get uid() {
674
+ return this._uid;
675
+ }
676
+ set uid(value) {
677
+ this._uid = value;
678
+ }
679
+ // Send a response.
680
+ /**
681
+ * Send a response.
682
+ *
683
+ * @param options The response options.
684
+ * @param options.status The response status.
685
+ * @param options.headers The response headers.
686
+ * @param options.data The data of the response body to send.
687
+ * @param options.compress Whether the response should be gzip-compressed.
688
+ * @example
689
+ * ```ts
690
+ * stream.send({status: 200, data: "Hello World!"});
691
+ * ```
692
+ * @docs
693
+ */
694
+ send({ status = 200, headers = {}, data, compress = false, } = {}) {
695
+ // Assign sent status code.
696
+ this.status_code = status;
697
+ // The body to send as non `ResponseBody` type.
698
+ let body = data;
699
+ // Convert body primitivies to string.
700
+ if (typeof body === 'boolean' || typeof body === 'number') {
701
+ body = body.toString();
702
+ }
703
+ // HTTP2.
704
+ if (this.http2) {
705
+ const stream = this.s;
706
+ // Headers.
707
+ this.res_headers[":status"] = status;
708
+ this.set_headers(headers);
709
+ if (this.res_cookies.length > 0) {
710
+ this.res_headers["set-cookie"] = this.res_cookies;
711
+ }
712
+ if (compress && body) {
713
+ this.res_headers["Content-Encoding"] = "gzip";
714
+ this.res_headers["Vary"] = "Accept-Encoding";
715
+ }
716
+ // Is json.
717
+ if (body && typeof body === 'object' && Buffer.isBuffer(body) === false && (body instanceof Uint8Array) === false) {
718
+ this.res_headers["Content-Type"] = "application/json";
719
+ body = JSON.stringify(body);
720
+ }
721
+ // Compress.
722
+ if (body
723
+ && typeof body === "object"
724
+ && !(body instanceof Buffer)
725
+ && !(body instanceof Uint8Array)) {
726
+ // Convert to string.
727
+ body = JSON.stringify(body);
728
+ }
729
+ if (compress
730
+ && body) {
731
+ if (typeof body === 'string'
732
+ || Buffer.isBuffer(body)
733
+ || body instanceof Uint8Array) {
734
+ body = zlib.gzipSync(body, { level: zlib.constants.Z_BEST_COMPRESSION });
735
+ }
736
+ else {
737
+ body = zlib.gzipSync(JSON.stringify(body), { level: zlib.constants.Z_BEST_COMPRESSION });
738
+ }
739
+ }
740
+ // Respond.
741
+ stream.respond(this.res_headers);
742
+ // End.
743
+ debug(3, "Sending response: ", status, " - has body: ", !!body);
744
+ if (body) {
745
+ if (Buffer.isBuffer(body) || body instanceof Uint8Array) {
746
+ stream.end(body);
747
+ }
748
+ else {
749
+ stream.end(Buffer.from(body));
750
+ }
751
+ // stream.end(body); // do not use toString() here or it will cause issues with writing binary data.
752
+ }
753
+ else {
754
+ stream.end();
755
+ }
756
+ }
757
+ // HTTP1.
758
+ else {
759
+ const req = this.req;
760
+ const res = this.res;
761
+ // Set status code.
762
+ res.statusCode = status;
763
+ // Set headers.
764
+ for (let i = 0; i < this.res_headers.length; i++) {
765
+ res.setHeader(this.res_headers[i][0], this.res_headers[i][1]);
766
+ }
767
+ Object.keys(headers).forEach((key) => {
768
+ const v = headers[key];
769
+ if (v != null) {
770
+ if (typeof v === "boolean") {
771
+ res.setHeader(key, v.toString());
772
+ }
773
+ else {
774
+ res.setHeader(key, v);
775
+ }
776
+ }
777
+ });
778
+ // Set cookies.
779
+ if (this.cookies.length > 0) {
780
+ res.setHeader('Set-Cookie', this.res_cookies);
781
+ }
782
+ // Convert data.
783
+ if (body && typeof body === 'object' && Buffer.isBuffer(body) === false && (body instanceof Uint8Array) === false) {
784
+ res.setHeader("Content-Type", "application/json");
785
+ body = JSON.stringify(body);
786
+ }
787
+ // @todo compress.
788
+ if (compress && body) {
789
+ res.setHeader("Content-Encoding", "gzip");
790
+ res.setHeader("Vary", "Accept-Encoding");
791
+ body = zlib.gzipSync(body, { level: zlib.constants.Z_BEST_COMPRESSION });
792
+ }
793
+ // Set data.
794
+ if (body) {
795
+ res.end(body); // do not use toString() here or it will cause issues with writing binary data.
796
+ }
797
+ // End.
798
+ else {
799
+ res.end();
800
+ }
801
+ }
802
+ // Set as finished.
803
+ this.finished = true;
804
+ return this;
805
+ }
806
+ // Send a successs response.
807
+ /**
808
+ * Send a response
809
+ *
810
+ * @param options The response options.
811
+ * @param options.status The response status.
812
+ * @param options.headers The response headers.
813
+ * @param options.data The data of the response body to send.
814
+ * @param options.compress Whether the response should be gzip-compressed.
815
+ * @example
816
+ * ```ts
817
+ * stream.success({data: "Hello World!"});
818
+ * ```
819
+ * @docs
820
+ */
821
+ success({ status = 200, headers = {}, data, compress = false } = {}) {
822
+ debug(3, "Sending [success] response: ", status, " - body: ", data);
823
+ return this.send({ status, headers, data, compress });
824
+ }
825
+ // Send an error response.
826
+ /**
827
+ * Send an error response
828
+ *
829
+ * @param options The error response options.
830
+ * @param options.message The error message.
831
+ * @param options.type The error type.
832
+ * @param options.invalid_fields The invalid fields when validation fails.
833
+ * @param options.status The response status.
834
+ * @param options.headers The response headers.
835
+ * @param options.compress Whether the response should be gzip-compressed.
836
+ * @param options.data Optional data to include in the error response, nested in the JSON response under field `data`.
837
+ * @example
838
+ * ```ts
839
+ * stream.error({ message: "Some error occurred", status: 400 });
840
+ * ```
841
+ * @docs
842
+ */
843
+ error({ message, type = "APIError", invalid_fields = {}, status = 500, headers = {}, compress = false, data, }) {
844
+ debug(3, "Sending [error] response: ", status, " - message: ", message);
845
+ const api_error = {
846
+ error: {
847
+ type,
848
+ message,
849
+ status,
850
+ invalid_fields,
851
+ },
852
+ data,
853
+ };
854
+ return this.send({ status, headers, compress, data: api_error });
855
+ }
856
+ // Set headers.
857
+ /**
858
+ * Add a new header to the response data.
859
+ *
860
+ * @param name The header name.
861
+ * @param value The header value.
862
+ * @example
863
+ * ```ts
864
+ * stream.set_header("Connection", "close");
865
+ * ```
866
+ * @docs
867
+ */
868
+ set_header(name, value) {
869
+ if (this.http2) {
870
+ this.res_headers[name] = value;
871
+ }
872
+ else {
873
+ this.res_headers.append([name, value]);
874
+ }
875
+ return this;
876
+ }
877
+ // Set headers.
878
+ /**
879
+ * Add new headers to the response data.
880
+ *
881
+ * @param headers The new response headers.
882
+ * @example
883
+ * ```ts
884
+ * stream.set_headers({"Connection": "close"});
885
+ * ```
886
+ * @docs
887
+ */
888
+ set_headers(headers = {}) {
889
+ if (headers == null) {
890
+ return this;
891
+ }
892
+ if (this.http2) {
893
+ Object.keys(headers).forEach((key) => {
894
+ this.res_headers[key] = headers[key];
895
+ });
896
+ }
897
+ else {
898
+ Object.keys(headers).forEach((key) => {
899
+ this.res_headers.append([key, headers[key]]);
900
+ });
901
+ }
902
+ return this;
903
+ }
904
+ /**
905
+ * Get an added header.
906
+ *
907
+ * @param name The header name.
908
+ * @example
909
+ * ```ts
910
+ * stream.get_header("Connection");
911
+ * ```
912
+ * @docs
913
+ */
914
+ get_header(name) {
915
+ if (this.http2) {
916
+ return this.res_headers[name];
917
+ }
918
+ else {
919
+ return this.res_headers.find((header) => header[0] === name)?.[1];
920
+ }
921
+ }
922
+ /**
923
+ * Remove header names from the response data.
924
+ *
925
+ * @param names The header names to remove.
926
+ * @example
927
+ * ```ts
928
+ * stream.remove_header("Connection", "User-Agent");
929
+ * ```
930
+ * @docs
931
+ */
932
+ remove_header(...names) {
933
+ if (this.http1) {
934
+ const headers = [];
935
+ for (let i = 0; i < this.res_headers.length; i++) {
936
+ if (!names.includes(this.res_headers[i][0])) {
937
+ headers.push(this.res_headers[i]);
938
+ }
939
+ }
940
+ this.res_headers = headers;
941
+ }
942
+ else {
943
+ for (let i = 0; i < names.length; i++) {
944
+ delete this.res_headers[names[i]];
945
+ }
946
+ }
947
+ return this;
948
+ }
949
+ /**
950
+ * Alias of {@link remove_header}.
951
+ *
952
+ * @param names The header names to remove.
953
+ */
954
+ remove_headers(...names) {
955
+ return this.remove_header(...names);
956
+ }
957
+ // Set a cookie.
958
+ /**
959
+ * Set a cookie that will be sent with the response.
960
+ *
961
+ * @warning Will only be added to the response when the user uses `send()`, `success()` or `error()`.
962
+ * @param cookie The cookie string.
963
+ * @example
964
+ * ```ts
965
+ * stream.set_cookie("MyCookie=Hello World;");
966
+ * ```
967
+ * @docs
968
+ */
969
+ set_cookie(cookie) {
970
+ cookie = cookie.trim();
971
+ const name_end = cookie.indexOf("=");
972
+ if (name_end !== -1) {
973
+ const name = cookie.substr(0, name_end);
974
+ for (let i = 0; i < this.res_cookies.length; i++) {
975
+ if (this.res_cookies[i].startsWith(name)) {
976
+ this.res_cookies[i] = cookie;
977
+ return this;
978
+ }
979
+ }
980
+ }
981
+ this.res_cookies.push(cookie);
982
+ return this;
983
+ }
984
+ // Set cookies.
985
+ /**
986
+ * Set cookies that will be sent with the response.
987
+ *
988
+ * @warning Will only be added to the response when the user uses `send()`, `success()` or `error()`.
989
+ * @param cookies The cookie strings.
990
+ * @example
991
+ * ```ts
992
+ * stream.set_cookies("MyCookie1=Hello World;", "MyCookie2=Hello Universe;");
993
+ * ```
994
+ * @docs
995
+ */
996
+ set_cookies(...cookies) {
997
+ for (let i = 0; i < cookies.length; i++) {
998
+ this.set_cookie(cookies[i]);
999
+ }
1000
+ return this;
1001
+ }
1002
+ }
1003
+ ;
1004
+ ;
1005
+ // ---------------------------------------------------------
1006
+ // Exports.
1007
+ export default Stream;