@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
@@ -1,1328 +0,0 @@
1
- /**
2
- * @author Daan van den Bergh
3
- * @copyright © 2022 - 2025 Daan van den Bergh.
4
- */
5
- // External imports.
6
- import { deserialize, serialize } from "bson";
7
- // Imports.
8
- import { logger } from "../logger.js";
9
- import { Document } from "./document.js";
10
- /** Debug */
11
- const { log } = logger;
12
- // ---------------------------------------------------------
13
- /**
14
- * A wrapper class for the MongoDB collection.
15
- *
16
- * @note Any document type is suported, including primitives, arrays and objects.
17
- *
18
- * @example
19
- * const col1 = server.db.collection("col1");
20
- * const col2 = server.db.collection({
21
- * name: "col2",
22
- * indexes: ["uid", "name"],
23
- * ttl: 1000 * 60 * 60 * 24, // 1 day
24
- * });
25
- */
26
- export class Collection {
27
- // Static attributes.
28
- static chunk_size = 1024 * 1024 * 4; // 4MB chunks, lower is better for frequent updates.
29
- static constructor_scheme = {
30
- name: "string",
31
- ttl: { type: "number", default: null }, // ttl in msec
32
- indexes: {
33
- type: "array",
34
- default: [],
35
- value_scheme: {
36
- type: ["string", "object"],
37
- scheme: {
38
- key: { type: "string", required: (data) => data.key == null && data.keys == null },
39
- keys: {
40
- type: ["array"],
41
- required: (data) => data.key == null && data.keys == null, value_scheme: "string",
42
- postprocess: (keys) => typeof keys === "string" ? [keys] : keys,
43
- },
44
- options: { type: "object", required: false },
45
- forced: { type: "boolean", default: false },
46
- },
47
- postprocess: (info) => {
48
- if (typeof info === "string")
49
- return { keys: [info] };
50
- return info;
51
- },
52
- },
53
- },
54
- };
55
- /** Collection name */
56
- name;
57
- /** Time to live in msec for all documents. */
58
- ttl;
59
- ttl_enabled;
60
- /** The column. */
61
- _col;
62
- /**
63
- * The Database parent class, used to initialize the column on demand.
64
- * So the user can define collections at root level before the database is initialized. */
65
- db;
66
- /** Is initialized. */
67
- initialized = false;
68
- /** The temporary indexes passed to the constructor for the init method. */
69
- _init_indexes;
70
- /** Constructor. */
71
- constructor(opts) {
72
- // Attributes.
73
- this.name = opts.name;
74
- this._col = opts.col;
75
- this.ttl = opts.ttl;
76
- this.ttl_enabled = typeof opts.ttl === "number";
77
- this.db = opts.db;
78
- this._init_indexes = opts.indexes;
79
- }
80
- /** Initialize. */
81
- async init() {
82
- if (this.initialized === false) {
83
- // Create column.
84
- if (this._col == null) {
85
- // Start connection in dev mode.
86
- if (!this.db.server.production) {
87
- await this.db.ensure_connection();
88
- }
89
- // Not connected.
90
- if (!this.db.connected || !this.db._db) {
91
- throw new Error(`Database is not connected.`);
92
- }
93
- // Check if t
94
- // he collection exists
95
- if (this.db._listed_cols == null) {
96
- this.db._listed_cols = await this.db._db.listCollections().toArray();
97
- }
98
- if (!this.db._listed_cols.find(x => x.name === this.name)) {
99
- log(0, `Creating collection "${this.name}".`);
100
- await this.db._db.createCollection(this.name);
101
- }
102
- // Create collection.
103
- this._col = this.db._db.collection(this.name);
104
- }
105
- // Assign as initialized when the column is created.
106
- // Also since next used methods are checking for this attribute.
107
- this.initialized = true;
108
- // Create ttl index.
109
- if (this.ttl_enabled) {
110
- await this._setup_ttl();
111
- }
112
- // Create indexes.
113
- if (this._init_indexes?.length) {
114
- for (const item of this._init_indexes) {
115
- await this.create_index(item);
116
- }
117
- }
118
- else {
119
- await this.create_index({ key: "_path", options: { unique: false } });
120
- }
121
- }
122
- return this;
123
- }
124
- assert_init() {
125
- if (this._col == null) {
126
- throw new Error(`Collection "${this.name}" is not initialized.`);
127
- }
128
- }
129
- /** Setup the ttl configuration. */
130
- async _setup_ttl() {
131
- if (!this.initialized) {
132
- await this.init();
133
- }
134
- this.assert_init();
135
- if (this.ttl == null) {
136
- return;
137
- }
138
- const desired_seconds = Math.floor(this.ttl / 1000);
139
- // 1) Get all indexes
140
- const indexes = await this._col.indexes(); // [{ key: { _ttl_timestamp: 1 }, expireAfterSeconds: 3600 }, …]
141
- // 2) Find the TTL index
142
- const ttl_index = indexes.find(ix => ix.key._ttl_timestamp === 1 ||
143
- (ix.key instanceof Array && ix.key[0] === '_ttl_timestamp'));
144
- // 3a) Doesn’t exist → create it
145
- if (!ttl_index) {
146
- await this._col.createIndex({ _ttl_timestamp: 1 }, { expireAfterSeconds: desired_seconds });
147
- return;
148
- }
149
- // 3b) Exists but wrong TTL → drop & recreate
150
- if (ttl_index.expireAfterSeconds !== desired_seconds) {
151
- if (!ttl_index.name) {
152
- // nothing to drop
153
- return;
154
- }
155
- await this._col.dropIndex(ttl_index.name);
156
- await this._col.createIndex({ _ttl_timestamp: 1 }, { expireAfterSeconds: desired_seconds });
157
- }
158
- // 3c) Exists and correct → nothing to do
159
- }
160
- _process_doc(doc) {
161
- if (doc == null) {
162
- return;
163
- }
164
- else if (doc._content != null) {
165
- return doc._content;
166
- }
167
- return doc;
168
- }
169
- // Chunked methods.
170
- async _load_chunked(path, find_opts) {
171
- if (!this.initialized) {
172
- await this.init();
173
- }
174
- this.assert_init();
175
- let query = typeof path === "string" ?
176
- { _path: path, chunk: { $gte: 0 } } :
177
- { ...path, chunk: { $gte: 0 } };
178
- const chunks_cursor = this._col.find(query, find_opts).sort({ chunk: 1 });
179
- const chunks = await chunks_cursor.toArray();
180
- if (chunks.length === 0) {
181
- return null;
182
- }
183
- const buffer = Buffer.concat(chunks.map(chunk => chunk.data.buffer));
184
- return deserialize(buffer);
185
- }
186
- async _save_chunked(path, content) {
187
- if (!this.initialized) {
188
- await this.init();
189
- }
190
- this.assert_init();
191
- // Serialize.
192
- const buffer = serialize(content);
193
- const new_chunk_count = Math.ceil(buffer.length / Collection.chunk_size);
194
- // Retrieve the old chunk count
195
- const ref_query = typeof path === "string" ?
196
- { _path: path, chunk: -1 } :
197
- { ...path, chunk: -1 };
198
- const object_ref = await this._col.findOne(ref_query);
199
- const old_chunk_count = object_ref ? object_ref.chunks : 0;
200
- // Update chunks.
201
- const bulk_ops = [];
202
- for (let i = 0; i < buffer.length; i += Collection.chunk_size) {
203
- let query, update;
204
- if (typeof path === "string") {
205
- query = {
206
- _path: path,
207
- chunk: i / Collection.chunk_size,
208
- };
209
- update = {
210
- chunk: i / Collection.chunk_size,
211
- data: buffer.slice(i, i + Collection.chunk_size)
212
- };
213
- }
214
- else {
215
- query = {
216
- ...path,
217
- chunk: i / Collection.chunk_size,
218
- };
219
- update = {
220
- chunk: i / Collection.chunk_size,
221
- data: buffer.slice(i, i + Collection.chunk_size)
222
- };
223
- }
224
- const full_update = {
225
- $set: update,
226
- };
227
- if (this.ttl_enabled) {
228
- full_update["$setOnInsert"] = { _ttl_timestamp: new Date() };
229
- }
230
- bulk_ops.push({
231
- updateOne: {
232
- filter: query,
233
- update: full_update,
234
- upsert: true
235
- }
236
- });
237
- }
238
- // Update reference.
239
- const full_update = {
240
- $set: {
241
- chunk: -1,
242
- chunks: new_chunk_count,
243
- },
244
- };
245
- if (this.ttl_enabled) {
246
- full_update["$setOnInsert"] = { _ttl_timestamp: new Date() };
247
- }
248
- bulk_ops.push({
249
- updateOne: {
250
- filter: ref_query,
251
- update: full_update,
252
- upsert: true
253
- }
254
- });
255
- // Write.
256
- await this._col.bulkWrite(bulk_ops, { ordered: true });
257
- // Delete any excess chunks if the new chunk count is less than the old chunk count
258
- if (new_chunk_count < old_chunk_count) {
259
- ref_query.chunk = { $gte: new_chunk_count };
260
- await this._col.deleteMany(ref_query);
261
- }
262
- }
263
- // Get the raw and initialized mongo collection.
264
- async col() {
265
- await this.init();
266
- return this._col;
267
- }
268
- /** Create a reference. */
269
- ref(query, opts) {
270
- return new Document.Ref(query, opts ? { ...opts, col: this } : { col: this });
271
- }
272
- reference(query, opts) {
273
- return new Document.Ref(query, opts ? { ...opts, col: this } : { col: this });
274
- }
275
- /** Has index. */
276
- async has_index(index) {
277
- if (!this.initialized) {
278
- await this.init();
279
- }
280
- this.assert_init();
281
- return (await this._col.listIndexes().toArray()).some(x => x.name === index);
282
- }
283
- /* @docs:
284
- @title: Create index
285
- @description: Creates indexes on collections.
286
- @return:
287
- Returns the document that was found or `null` when no document is found.
288
- @parameter:
289
- @name: keys
290
- @desc: The `keys` argument for the orignal mongodb `createIndex()` function.
291
- @parameter:
292
- @name: options
293
- @desc: The `options` argument for the orignal mongodb `createIndex()` function.
294
- @parameter:
295
- @name: commitQuorum
296
- @desc: The `commitQuorum` argument for the orignal mongodb `createIndex()` function.
297
- */
298
- async create_index(opts) {
299
- if (!this.initialized) {
300
- await this.init();
301
- }
302
- this.assert_init();
303
- let key, keys;
304
- let options;
305
- let forced = false;
306
- if (typeof opts === "string") {
307
- key = opts;
308
- }
309
- else {
310
- ({
311
- key,
312
- keys,
313
- options,
314
- forced = false
315
- } = opts);
316
- }
317
- // Create keys objs per input type.
318
- let keys_obj = {};
319
- if (key) {
320
- keys_obj = {};
321
- keys_obj[key] = 1;
322
- }
323
- else if (Array.isArray(keys) && keys.length > 0) {
324
- keys_obj = {};
325
- for (const key of keys) {
326
- keys_obj[key] = 1;
327
- }
328
- }
329
- else {
330
- throw new Error("Define one of the following parameters: [key, keys].");
331
- }
332
- // Drop index.
333
- if (forced) {
334
- try {
335
- await this._col.dropIndex(options?.name ??
336
- Object.entries(keys_obj)
337
- .map(([key, value]) => `${key}_${value}`)
338
- .join('_'));
339
- }
340
- catch (err) {
341
- if (err.codeName !== 'IndexNotFound') {
342
- throw err;
343
- }
344
- }
345
- }
346
- // Create index.
347
- // @ts-ignore
348
- return await this._col.createIndex(keys_obj, options || {});
349
- }
350
- /* @docs:
351
- * @title: Find
352
- * @description: Find a document by a query.
353
- * @return:
354
- * Returns the document that was found or `null` when no document is found.
355
- * @parameter:
356
- * @name: query
357
- * @desc: The query options.
358
- * @type: object
359
- */
360
- async find(query) {
361
- if (!this.initialized) {
362
- await this.init();
363
- }
364
- this.assert_init();
365
- try {
366
- return this._process_doc(await this._col.findOne(query));
367
- }
368
- catch (error) {
369
- console.error(error);
370
- throw new Error('Encountered an error while finding the document.');
371
- }
372
- }
373
- async find_many(query) {
374
- if (!this.initialized) {
375
- await this.init();
376
- }
377
- this.assert_init();
378
- try {
379
- const list = await this._col.find(query).toArray();
380
- return list.map(i => this._process_doc(i));
381
- }
382
- catch (error) {
383
- console.error(error);
384
- throw new Error('Encountered an error while finding the document.');
385
- }
386
- }
387
- /* @docs:
388
- * @title: Exists
389
- * @description: Check if a document exists.
390
- * @parameter:
391
- * @name: path
392
- * @description: The database path to the document.
393
- * @type: string
394
- */
395
- async exists(path) {
396
- if (!this.initialized) {
397
- await this.init();
398
- }
399
- this.assert_init();
400
- if (typeof path !== "string" && (typeof path !== "object" || path == null)) {
401
- throw Error(`Parameter "path" has an invalid type "${typeof path}", the valid type is "string".`);
402
- }
403
- try {
404
- const doc = await this._col.findOne(typeof path === "object" ? path : { _path: path }, { projection: { _id: 1 } });
405
- return doc != null;
406
- }
407
- catch (error) {
408
- console.error(error);
409
- throw new Error('Encountered an error while checking if the document exists.');
410
- }
411
- }
412
- /* @docs:
413
- * @title: Load
414
- * @description: Load data by path.
415
- * @return:
416
- * Returns the loaded document.
417
- *
418
- * Returns the `def` parameter when the data does not exist, keep in mind that when parameter `def` is an object it could be a reference to a defined variable.
419
- * @parameter:
420
- * @name: path
421
- * @description: The database path to the document.
422
- * @type: string
423
- * @parameter:
424
- * @name: opts
425
- * @desc: Additional options.
426
- * @type: null, object
427
- * @attribute:
428
- * @name: default
429
- * @description:
430
- * The default data to be returned when the data does not exist.
431
- *
432
- * When the type of attribute `default` is `object` then the keys that do not exist in the loaded object, but do exist in the default object will be inserted into the loaded object.
433
- * @type: null, object
434
- * @attribute:
435
- * @name: chunked
436
- * @description: Load a chunked document.
437
- * @type: null, object
438
- * @attribute:
439
- * @name: attributes
440
- * @description: The attributes to load.
441
- * @type: null, string[]
442
- */
443
- async load(path, opts = null) {
444
- if (!this.initialized) {
445
- await this.init();
446
- }
447
- this.assert_init();
448
- if (typeof path !== "string" && (typeof path !== "object" || path == null)) {
449
- throw Error(`Parameter "path" has an invalid type "${typeof path}", the valid type is "string".`);
450
- }
451
- if (opts && opts.projection && opts.chunked) {
452
- throw new Error("The `projection` and `chunked` options cannot be used together.");
453
- }
454
- try {
455
- // Get attributes.
456
- let find_opts;
457
- if (opts) {
458
- if (opts.projection) {
459
- find_opts = { projection: opts.projection };
460
- }
461
- else if (opts.attributes) {
462
- find_opts = { projection: {
463
- _id: 1,
464
- _path: 1,
465
- _uid: 1,
466
- } };
467
- opts.attributes.forEach((i) => {
468
- if (find_opts?.projection) {
469
- find_opts.projection[i] = 1;
470
- }
471
- });
472
- }
473
- }
474
- // Load doc.
475
- let doc;
476
- if (opts != null && opts.chunked === true) {
477
- doc = await this._load_chunked(path, find_opts);
478
- }
479
- else {
480
- // Load.
481
- doc = await this._col.findOne(typeof path === "object" ? path : { _path: path }, find_opts);
482
- }
483
- // Process doc.
484
- doc = this._process_doc(doc);
485
- // Handle default.
486
- if (doc == null) {
487
- if (opts != null && opts.default !== undefined) {
488
- return opts.default;
489
- }
490
- return;
491
- }
492
- // Insert default keys.
493
- else if (opts != null && typeof opts.default === "object" && opts.default != null && Array.isArray(opts.default) === false) {
494
- const set_defaults = (obj, defaults) => {
495
- Object.keys(defaults).forEach((key) => {
496
- if (obj[key] === undefined) {
497
- obj[key] = defaults[key];
498
- }
499
- else if (typeof obj[key] === "object" && !Array.isArray(obj[key]) && obj[key] != null &&
500
- typeof defaults[key] === "object" && !Array.isArray(defaults[key]) && defaults[key] != null) {
501
- set_defaults(obj[key], defaults[key]);
502
- }
503
- });
504
- };
505
- set_defaults(doc, opts.default);
506
- }
507
- // Response.
508
- return doc;
509
- }
510
- catch (error) {
511
- console.error(error);
512
- throw new Error('Encountered an error while loading the document.');
513
- }
514
- }
515
- /* @docs:
516
- * @title: Save
517
- * @description: Save data by path. When the document already exists this function only updates the specified content attributes.
518
- * @return:
519
- * Returns the updated document.
520
- * @parameter:
521
- * @name: path
522
- * @description: The database path to the document.
523
- * @type: string
524
- * @parameter:
525
- * @name: data
526
- * @description: The data to save.
527
- * @type: null, boolean, number, string, array, object
528
- * @parameter:
529
- * @name: opts
530
- * @desc: Additional options.
531
- * @type: null, object
532
- * @attribute:
533
- * @name: chunked
534
- * @description: Chunk the document into multiple documents, therefore documents larger than 16MB are supported.
535
- * @warning: Currently this option is only supported for types `object` and `array`.
536
- * @default: false
537
- * @type: boolean
538
- * @attribute:
539
- * @name: bulk
540
- * @description: Get a bulk operation object, so several operations can be executed in bulk.
541
- * @default: false
542
- * @type: boolean
543
- * @attribute:
544
- * @name: set
545
- * @description: By default the $set attribute is used for the content, with `opts.set` disabled you can create your own instructions. The `content` attribute must reflect this.
546
- * @warning: This does not work in combination with `opts.chunked`.
547
- * @default: true
548
- * @type: boolean
549
- */
550
- async save(path, content, opts = null) {
551
- if (!this.initialized) {
552
- await this.init();
553
- }
554
- this.assert_init();
555
- if (typeof path !== "string" && (typeof path !== "object" || path == null)) {
556
- throw Error(`Parameter "path" has an invalid type "${typeof path}", the valid type is "string".`);
557
- }
558
- try {
559
- // Vars.
560
- let doc, set;
561
- // Create set.
562
- if (typeof content === "object" && Array.isArray(content) == false && content != null) {
563
- delete content._id;
564
- delete content._path;
565
- delete content._uid;
566
- delete content._ttl_timestamp;
567
- set = content;
568
- }
569
- else {
570
- set = { _content: content };
571
- }
572
- // Save chunked.
573
- if (opts != null && opts.chunked === true) {
574
- await this._save_chunked(path, set);
575
- }
576
- // Save as single doc.
577
- else {
578
- // Apply $set rules.
579
- if (opts == null || (opts.set !== false)) {
580
- set = { $set: set };
581
- }
582
- // Apply TTL.
583
- if (this.ttl_enabled) {
584
- if (set["$setOnInsert"] === undefined) {
585
- set["$setOnInsert"] = {};
586
- set["$setOnInsert"]._ttl_timestamp = new Date();
587
- }
588
- else if (set["$setOnInsert"] != null && typeof set["$setOnInsert"] === "object") {
589
- set["$setOnInsert"]._ttl_timestamp = new Date();
590
- }
591
- else {
592
- throw new Error(`Undefined behaviour: Unable to assign the $setOnInsert data for ttl control.`);
593
- }
594
- }
595
- // Bulk operation.
596
- if (opts != null && opts.bulk) {
597
- return {
598
- updateOne: {
599
- filter: typeof path === "object" ? path : { _path: path },
600
- update: set,
601
- upsert: true,
602
- }
603
- };
604
- }
605
- // Normal operation.
606
- else {
607
- await this._col.updateOne(typeof path === "object" ? path : { _path: path }, set, { upsert: true });
608
- }
609
- }
610
- // Response.
611
- return content;
612
- }
613
- catch (error) {
614
- console.error(error);
615
- throw new Error('Encountered an error while updating the document.');
616
- }
617
- }
618
- /** Update many. */
619
- async update_many(...args) {
620
- if (!this.initialized) {
621
- await this.init();
622
- }
623
- this.assert_init();
624
- return this._col.updateMany(...args);
625
- }
626
- // List.
627
- /* @docs:
628
- * @title: List
629
- * @description: List all child documents of directory path.
630
- * @parameter:
631
- * @name: path
632
- * @description: The database directory path.
633
- * @type: string
634
- * @parameter:
635
- * @name: options
636
- * @description: List options.
637
- * @type: object
638
- * @attribute:
639
- * @name: process
640
- * @description: Process the document. By default saved non object data will be stored under `_content`. Processing checks this attribute and uses that content instead when it is detected.
641
- * @type: boolean
642
- * @default: true
643
- * @attribute:
644
- * @name: projection
645
- * @description: The data attributes to retrieve, when left undefined all attributes are retrieved.
646
- * @type: object
647
- * @default: undefined
648
- */
649
- async list(path, options = {}) {
650
- if (!this.initialized) {
651
- await this.init();
652
- }
653
- this.assert_init();
654
- if (typeof path !== "string" && (typeof path !== "object" || path == null)) {
655
- throw Error(`Parameter "path" has an invalid type "${typeof path}", the valid type is "string".`);
656
- }
657
- if (typeof path === "string") {
658
- while (path.length > 0 && path.charAt(path.length - 1) === "/") {
659
- path = path.substr(0, path.length - 1);
660
- }
661
- if (path.length == 0) {
662
- throw Error("Invalid path.");
663
- }
664
- path = { _path: { $regex: `^${path}/` } };
665
- }
666
- else if (path._path) {
667
- let _path = path._path;
668
- while (_path.length > 0 && _path.charAt(_path.length - 1) === "/") {
669
- _path = _path.substr(0, _path.length - 1);
670
- }
671
- if (_path.length == 0) {
672
- throw Error("Invalid path.");
673
- }
674
- path._path = { $regex: `^${_path}/` };
675
- }
676
- try {
677
- const docs = await this._col.find(path, { projection: options.projection }).toArray();
678
- if (options.process === false) {
679
- return docs;
680
- }
681
- return docs.map((doc) => this._process_doc(doc));
682
- }
683
- catch (error) {
684
- console.error(error);
685
- throw new Error('Encountered an error while listing all documents.');
686
- }
687
- }
688
- /* @docs:
689
- * @title: List Query
690
- * @description: List all documents of the collection based on a query.
691
- * @parameter:
692
- * @name: query
693
- * @desc: The query options.
694
- * @type: object
695
- * @parameter:
696
- * @name: options
697
- * @description: List options.
698
- * @type: object
699
- * @attribute:
700
- * @name: process
701
- * @description: Process the document. By default saved non object data will be stored under `_content`. Processing checks this attribute and uses that content instead when it is detected.
702
- * @type: boolean
703
- * @default: true
704
- * @attribute:
705
- * @name: projection
706
- * @description: The data attributes to retrieve, when left undefined all attributes are retrieved.
707
- * @type: object
708
- * @default: undefined
709
- */
710
- async list_query(query = {}, options = {}) {
711
- if (!this.initialized) {
712
- await this.init();
713
- }
714
- this.assert_init();
715
- try {
716
- const docs = await this._col.find(query, { projection: options.projection }).toArray();
717
- if (options.process === false) {
718
- return docs;
719
- }
720
- return docs.map((doc) => this._process_doc(doc)); // list as array since the user might have used a path object width different attributes so dict is not reliable.
721
- }
722
- catch (error) {
723
- console.error(error);
724
- throw new Error('Encountered an error while listing all documents.');
725
- }
726
- }
727
- /* @docs:
728
- * @title: List All
729
- * @description: List all documents of the collection, optionally per uid.
730
- * @parameter:
731
- * @name: query
732
- * @ignore: true
733
- * @parameter:
734
- * @name: options
735
- * @description: List options.
736
- * @type: object
737
- * @attribute:
738
- * @name: process
739
- * @description: Process the document. By default saved non object data will be stored under `_content`. Processing checks this attribute and uses that content instead when it is detected.
740
- * @type: boolean
741
- * @default: true
742
- * @attribute:
743
- * @name: projection
744
- * @description: The data attributes to retrieve, when left undefined all attributes are retrieved.
745
- * @type: object
746
- * @default: undefined
747
- */
748
- async list_all(query = {}, options = {}) {
749
- if (!this.initialized) {
750
- await this.init();
751
- }
752
- this.assert_init();
753
- let docs;
754
- docs = await this._col.find(query, { projection: options.projection }).toArray();
755
- if (options.process === false) {
756
- return docs;
757
- }
758
- return docs.map((doc) => this._process_doc(doc)); // list as array since the user might have used a path object width different attributes so dict is not reliable.
759
- }
760
- /* @docs:
761
- * @title: Delete
762
- * @description: Delete a document of the collection by path.
763
- * @parameter:
764
- * @name: path
765
- * @description: The database path to the document.
766
- * @type: string
767
- * @parameter:
768
- * @name: opts
769
- * @desc: Additional options.
770
- * @type: null, object
771
- * @attribute:
772
- * @name: chunked
773
- * @description: Delete a chunked document.
774
- * @default: false
775
- * @type: boolean
776
- * @attribute:
777
- * @name: bulk
778
- * @description: Get a bulk operation object, so several operations can be executed in bulk.
779
- * @default: false
780
- * @type: boolean
781
- */
782
- async delete(path, opts) {
783
- if (!this.initialized) {
784
- await this.init();
785
- }
786
- this.assert_init();
787
- if (typeof path !== "string" && (typeof path !== "object" || path == null)) {
788
- throw Error(`Parameter "path" has an invalid type "${typeof path}", the valid type is "string".`);
789
- }
790
- try {
791
- if (opts != null && opts.chunked === true) {
792
- if (opts.bulk) {
793
- return { deleteMany: { filter: typeof path === "object" ? path : { _path: path } } };
794
- }
795
- else {
796
- await this._col.deleteMany(typeof path === "object" ? path : { _path: path });
797
- }
798
- }
799
- else {
800
- if (opts != null && opts.bulk) {
801
- return { deleteOne: { filter: typeof path === "object" ? path : { _path: path } } };
802
- }
803
- else {
804
- await this._col.deleteOne(typeof path === "object" ? path : { _path: path });
805
- }
806
- }
807
- }
808
- catch (error) {
809
- console.error(error);
810
- throw new Error('Encountered an error while deleting.');
811
- }
812
- }
813
- /* @docs:
814
- * @title: Delete Query
815
- * @description: Delete a document of the collection by query.
816
- * @parameter:
817
- * @name: query
818
- * @description: The query object.
819
- * @type: object
820
- */
821
- async delete_query(query = {}) {
822
- if (!this.initialized) {
823
- await this.init();
824
- }
825
- this.assert_init();
826
- if (typeof query !== "object" || query == null || Object.keys(query).length === 0) {
827
- throw Error(`Parameter "query" has an invalid type "${typeof query}", the valid type is "object".`);
828
- }
829
- if (Object.keys(query).length === 0) {
830
- throw Error(`Parameter "query" is an empty object.`);
831
- }
832
- await this._col.deleteMany(query);
833
- }
834
- // Delete all.
835
- async delete_all(path) {
836
- if (!this.initialized) {
837
- await this.init();
838
- }
839
- this.assert_init();
840
- if (typeof path !== "string" && (typeof path !== "object" || path == null)) {
841
- throw Error(`Parameter "path" has an invalid type "${typeof path}", the valid type is "string".`);
842
- }
843
- try {
844
- await this._col.deleteMany(typeof path === "object" ? path : { _path: path });
845
- }
846
- catch (error) {
847
- console.error(error);
848
- throw new Error('Encountered an error while deleting.');
849
- }
850
- }
851
- async delete_many(query) {
852
- if (!this.initialized) {
853
- await this.init();
854
- }
855
- this.assert_init();
856
- try {
857
- await this._col.deleteMany(query);
858
- }
859
- catch (error) {
860
- console.error(error);
861
- throw new Error('Encountered an error while deleting.');
862
- }
863
- }
864
- /* @docs:
865
- * @title: Delete Collection
866
- * @description: Delete all documents of from the collection.
867
- */
868
- async delete_collection() {
869
- if (!this.initialized) {
870
- await this.init();
871
- }
872
- this.assert_init();
873
- await this._col.deleteMany();
874
- await this._col.drop();
875
- }
876
- /* @docs:
877
- // * @title: Clean document
878
- // * @description: Clean a document from all default system attributes.
879
- // */
880
- clean(doc) {
881
- if (doc == null) {
882
- return doc;
883
- }
884
- if (typeof doc === "object") {
885
- delete doc._id;
886
- delete doc._path;
887
- if (this.ttl_enabled) {
888
- delete doc._ttl_timestamp;
889
- }
890
- }
891
- return doc;
892
- }
893
- /** Write bulk operations. */
894
- async bulk_operations(operations = []) {
895
- if (!this.initialized) {
896
- await this.init();
897
- }
898
- this.assert_init();
899
- return await this._col.bulkWrite(operations, { ordered: true });
900
- }
901
- async aggregate(pipeline, opts) {
902
- if (!this.initialized) {
903
- await this.init();
904
- }
905
- this.assert_init();
906
- const out = this._col.aggregate(pipeline);
907
- if (opts?.cursor) {
908
- return out;
909
- }
910
- const arr = await out.toArray();
911
- if (opts?.clean === true) {
912
- return arr.map((doc) => this.clean(doc)).filter((x) => x != null);
913
- }
914
- return arr;
915
- }
916
- }
917
- // ---------------------------------------------------------
918
- // UID based collection.
919
- // @warning: The "path" param must always be allowed to be an object or string, also for the UIDCollection class.
920
- // @warning: THE DATABASE COLLECTION SHOULD ALSO ACCEPT OBJECTS FOR PATHS.
921
- /* @docs:
922
- @nav: Backend
923
- @chapter: Database
924
- @title: UID Collection
925
- @desc: The UID based database collection class.
926
- @note: The document attribute `_uid` is a reserved index attribute for the user id of the document.
927
- @note: The document attribute `_path` is a reserved index attribute for the path of the document.
928
- @attribute:
929
- @name: col
930
- @desc: The native mongodb collection.
931
- */
932
- // export class UIDCollection {
933
- // private _col: Collection;
934
- // col: MongoCollection;
935
- // constructor(
936
- // name: string,
937
- // collection: MongoCollection,
938
- // indexes: IndexOptions[] = [],
939
- // ttl: number | null = null,
940
- // ) {
941
- // this._col = new Collection(name, collection, ttl, indexes, true);
942
- // this.col = this._col.col;
943
- // }
944
- // /* @docs:
945
- // @title: Create index
946
- // @description: Creates indexes on collections.
947
- // @return:
948
- // Returns the document that was found or `null` when no document is found.
949
- // @parameter:
950
- // @name: keys
951
- // @desc: The `keys` argument for the orignal mongodb `createIndex()` function.
952
- // @parameter:
953
- // @name: options
954
- // @desc: The `options` argument for the orignal mongodb `createIndex()` function.
955
- // @parameter:
956
- // @name: commitQuorum
957
- // @desc: The `commitQuorum` argument for the orignal mongodb `createIndex()` function.
958
- // */
959
- // async create_index(args: IndexOptions): Promise<string> {
960
- // return this._col.create_index(args);
961
- // }
962
- // /* @docs:
963
- // * @title: Find
964
- // * @description: Find a document by a query.
965
- // * @return:
966
- // * Returns the document that was found or `null` when no document is found.
967
- // * @parameter:
968
- // * @name: uid
969
- // * @cached: Users:uid:param
970
- // * @required: false
971
- // * @parameter:
972
- // * @name: query
973
- // * @desc: The query options.
974
- // * @type: object
975
- // */
976
- // async find(uid: string | null = null, query: Record<string, any> = {}): Promise<any> {
977
- // if (uid != null) {
978
- // query._uid = uid;
979
- // }
980
- // return await this._col.find(query);
981
- // }
982
- // /* @docs:
983
- // * @title: Exists
984
- // * @description: Check if a document exists.
985
- // * @parameter:
986
- // * @name: uid
987
- // * @cached: Users:uid:param
988
- // * @parameter:
989
- // * @name: path
990
- // * @description: The database path to the document.
991
- // * @type: string, object
992
- // */
993
- // async exists(uid: string, path: Query): Promise<boolean> {
994
- // if (typeof path !== "string" && (typeof path !== "object" || path == null)) {
995
- // throw Error(`Parameter "path" has an invalid type "${typeof path}", the valid type is "string".`);
996
- // }
997
- // if (typeof uid !== "string") {
998
- // throw Error(`Parameter "uid" has an invalid type "${typeof uid}", the valid type is "string".`);
999
- // }
1000
- // if (typeof path === "object") {
1001
- // return await this._col.exists({...path, _uid: uid});
1002
- // } else {
1003
- // return await this._col.exists({_path: path, _uid: uid});
1004
- // }
1005
- // }
1006
- // /* @docs:
1007
- // * @title: Load
1008
- // * @description: Load data by user id and path.
1009
- // * @return:
1010
- // * Returns the loaded document.
1011
- // *
1012
- // * Returns the `def` parameter when the data does not exist, keep in mind that when parameter `def` is an object it could be a reference to a defined variable.
1013
- // * @parameter:
1014
- // * @name: uid
1015
- // * @cached: Users:uid:param
1016
- // * @parameter:
1017
- // * @name: path
1018
- // * @description: The database path to the document.
1019
- // * @type: string, object
1020
- // * @parameter:
1021
- // * @name: opts
1022
- // * @desc: Additional options.
1023
- // * @type: null, object
1024
- // * @attribute:
1025
- // * @name: default
1026
- // * @description:
1027
- // * The default data to be returned when the data does not exist.
1028
- // *
1029
- // * When the type of attribute `default` is `object` then the keys that do not exist in the loaded object, but do exist in the default object will be inserted into the loaded object.
1030
- // * @type: null, object
1031
- // */
1032
- // async load(
1033
- // uid: string,
1034
- // path: Query,
1035
- // opts: {
1036
- // default?: any,
1037
- // chunked?: boolean,
1038
- // attributes?: string[],
1039
- // projection?: Record<string, any>
1040
- // } | null = null
1041
- // ): Promise<any> {
1042
- // if (typeof path !== "string" && (typeof path !== "object" || path == null)) {
1043
- // throw Error(`Parameter "path" has an invalid type "${typeof path}", the valid type is "string".`);
1044
- // }
1045
- // if (typeof uid !== "string") {
1046
- // throw Error(`Parameter "uid" has an invalid type "${typeof uid}", the valid type is "string".`);
1047
- // }
1048
- // if (typeof path === "object") {
1049
- // return await this._col.load({...path, _uid: uid}, opts);
1050
- // } else {
1051
- // return await this._col.load({_path: path, _uid: uid}, opts);
1052
- // }
1053
- // }
1054
- // /* @docs:
1055
- // * @title: Save
1056
- // * @description: Save data by user id and path. When the document already exists this function only updates the specified content attributes.
1057
- // * @return:
1058
- // * Returns the updated document.
1059
- // * @parameter:
1060
- // * @name: uid
1061
- // * @cached: Users:uid:param
1062
- // * @parameter:
1063
- // * @name: path
1064
- // * @description: The database path to the document.
1065
- // * @type: string, object
1066
- // * @parameter:
1067
- // * @name: data
1068
- // * @description: The data to save.
1069
- // * @type: null, boolean, number, string, array, object
1070
- // * @parameter:
1071
- // * @name: opts
1072
- // * @desc: Additional options.
1073
- // * @type: null, object
1074
- // * @attribute:
1075
- // * @name: chunked
1076
- // * @description: Chunk the document into multiple documents, therefore documents larger than 16MB are supported.
1077
- // * @warning: Currently this option is only supported for types `object` and `array`.
1078
- // * @default: false
1079
- // * @type: boolean
1080
- // * @attribute:
1081
- // * @name: bulk
1082
- // * @description: Get a bulk operation object, so several operations can be executed in bulk.
1083
- // * @default: false
1084
- // * @type: boolean
1085
- // * @attribute:
1086
- // * @name: set
1087
- // * @description: By default the $set attribute is used for the content, with `opts.set` disabled you can create your own instructions. The `content` attribute must reflect this.
1088
- // * @warning: This does not work in combination with `opts.chunked`.
1089
- // * @default: true
1090
- // * @type: boolean
1091
- // */
1092
- // async save(
1093
- // uid: string,
1094
- // path: Query,
1095
- // content: any,
1096
- // opts: {
1097
- // chunked?: boolean,
1098
- // bulk?: boolean,
1099
- // set?: boolean
1100
- // } | null = null
1101
- // ): Promise<any> {
1102
- // if (typeof path !== "string" && (typeof path !== "object" || path == null)) {
1103
- // throw Error(`Parameter "path" has an invalid type "${typeof path}", the valid type is "string".`);
1104
- // }
1105
- // if (typeof uid !== "string") {
1106
- // throw Error(`Parameter "uid" has an invalid type "${typeof uid}", the valid type is "string".`);
1107
- // }
1108
- // if (typeof path === "object") {
1109
- // return await this._col.save({...path, _uid: uid}, content, opts);
1110
- // } else {
1111
- // return await this._col.save({_path: path, _uid: uid}, content, opts);
1112
- // }
1113
- // }
1114
- // /** Update many. */
1115
- // async update_many(...args: Parameters<typeof this.col.updateMany>): Promise<any> {
1116
- // return this.col.updateMany(...args);
1117
- // }
1118
- // /* @docs:
1119
- // * @title: List
1120
- // * @description: List all child documents of directory path.
1121
- // * @parameter:
1122
- // * @name: uid
1123
- // * @cached: Users:uid:param
1124
- // * @parameter:
1125
- // * @name: path
1126
- // * @description: The database directory path.
1127
- // * @type: string, object
1128
- // * @parameter:
1129
- // * @name: options
1130
- // * @description: List options.
1131
- // * @type: object
1132
- // * @attribute:
1133
- // * @name: process
1134
- // * @description: Process the document. By default saved non object data will be stored under `_content`. Processing checks this attribute and uses that content instead when it is detected.
1135
- // * @type: boolean
1136
- // * @default: true
1137
- // * @attribute:
1138
- // * @name: projection
1139
- // * @description: The data attributes to retrieve, when left undefined all attributes are retrieved.
1140
- // * @type: object
1141
- // * @default: undefined
1142
- // */
1143
- // async list(
1144
- // uid: string,
1145
- // path: Query,
1146
- // options: {
1147
- // process?: boolean,
1148
- // projection?: Record<string, any>
1149
- // } = {}
1150
- // ): Promise<any[]> {
1151
- // if (typeof path !== "string" && (typeof path !== "object" || path == null)) {
1152
- // throw Error(`Parameter "path" has an invalid type "${typeof path}", the valid type is "string".`);
1153
- // }
1154
- // if (typeof uid !== "string") {
1155
- // throw Error(`Parameter "uid" has an invalid type "${typeof uid}", the valid type is "string".`);
1156
- // }
1157
- // if (typeof path === "object") {
1158
- // return await this._col.list({...path, _uid: uid}, options)
1159
- // } else {
1160
- // return await this._col.list({_path: path, _uid: uid}, options)
1161
- // }
1162
- // }
1163
- // /* @docs:
1164
- // * @title: List Query
1165
- // * @description: List all documents of the collection based on a query.
1166
- // * @parameter:
1167
- // * @name: query
1168
- // * @desc: The query options.
1169
- // * @type: object
1170
- // * @parameter:
1171
- // * @name: options
1172
- // * @description: List options.
1173
- // * @type: object
1174
- // * @attribute:
1175
- // * @name: process
1176
- // * @description: Process the document. By default saved non object data will be stored under `_content`. Processing checks this attribute and uses that content instead when it is detected.
1177
- // * @type: boolean
1178
- // * @default: true
1179
- // * @attribute:
1180
- // * @name: projection
1181
- // * @description: The data attributes to retrieve, when left undefined all attributes are retrieved.
1182
- // * @type: object
1183
- // * @default: undefined
1184
- // */
1185
- // async list_query(
1186
- // query: Record<string, any> = {},
1187
- // options: {
1188
- // process?: boolean,
1189
- // projection?: Record<string, any>
1190
- // } = {}
1191
- // ): Promise<any[]> {
1192
- // return await this._col.list_query(query, options);
1193
- // }
1194
- // /* @docs:
1195
- // * @title: List All
1196
- // * @description: List all documents of the collection, optionally per uid.
1197
- // * @parameter:
1198
- // * @name: uid
1199
- // * @cached: Users:uid:param
1200
- // * @parameter:
1201
- // * @name: options
1202
- // * @description: List options.
1203
- // * @type: object
1204
- // * @attribute:
1205
- // * @name: process
1206
- // * @description: Process the document. By default saved non object data will be stored under `_content`. Processing checks this attribute and uses that content instead when it is detected.
1207
- // * @type: boolean
1208
- // * @default: true
1209
- // * @attribute:
1210
- // * @name: projection
1211
- // * @description: The data attributes to retrieve, when left undefined all attributes are retrieved.
1212
- // * @type: object
1213
- // * @default: undefined
1214
- // */
1215
- // async list_all(
1216
- // uid: string | null = null,
1217
- // options: {
1218
- // process?: boolean,
1219
- // projection?: Record<string, any>
1220
- // } = {}
1221
- // ): Promise<any[]> {
1222
- // if (uid == null) {
1223
- // return await this._col.list_all({}, options)
1224
- // } else {
1225
- // return await this._col.list_all({_uid: uid}, options);
1226
- // }
1227
- // }
1228
- // /* @docs:
1229
- // * @title: Delete
1230
- // * @description: Delete a document of the collection by uid and path.
1231
- // * @parameter:
1232
- // * @name: uid
1233
- // * @cached: Users:uid:param
1234
- // * @parameter:
1235
- // * @name: path
1236
- // * @description: The database path to the document.
1237
- // * @type: string, object
1238
- // * @parameter:
1239
- // * @name: opts
1240
- // * @desc: Additional options.
1241
- // * @type: null, object
1242
- // * @attribute:
1243
- // * @name: chunked
1244
- // * @description: Delete a chunked document.
1245
- // * @default: false
1246
- // * @type: boolean
1247
- // * @attribute:
1248
- // * @name: bulk
1249
- // * @description: Get a bulk operation object, so several operations can be executed in bulk.
1250
- // * @default: false
1251
- // * @type: boolean
1252
- // */
1253
- // async delete(
1254
- // uid: string,
1255
- // path: Query,
1256
- // opts?: {
1257
- // chunked?: boolean,
1258
- // bulk?: boolean
1259
- // }
1260
- // ): Promise<any> {
1261
- // if (typeof path !== "string" && (typeof path !== "object" || path == null)) {
1262
- // throw Error(`Parameter "path" has an invalid type "${typeof path}", the valid type is "string".`);
1263
- // }
1264
- // if (typeof uid !== "string") {
1265
- // throw Error(`Parameter "uid" has an invalid type "${typeof uid}", the valid type is "string".`);
1266
- // }
1267
- // if (typeof path === "object") {
1268
- // return await this._col.delete({...path, _uid: uid}, opts)
1269
- // } else {
1270
- // return await this._col.delete({_path: path, _uid: uid}, opts)
1271
- // }
1272
- // }
1273
- // /* @docs:
1274
- // * @title: Delete Query
1275
- // * @description: Delete a document of the collection by query.
1276
- // * @parameter:
1277
- // * @name: query
1278
- // * @description: The query object.
1279
- // * @type: object
1280
- // */
1281
- // async delete_query(query: Record<string, any>): Promise<any> {
1282
- // if (typeof query !== "object" || query == null || Object.keys(query).length === 0) {
1283
- // throw Error(`Parameter "query" has an invalid type "${typeof query}", the valid type is "object".`);
1284
- // }
1285
- // if (Object.keys(query).length === 0) {
1286
- // throw Error(`Parameter "query" is an empty object.`);
1287
- // }
1288
- // return await this._col.delete_query(query)
1289
- // }
1290
- // // Delete all.
1291
- // async delete_all(
1292
- // uid: string,
1293
- // path: Query | null = null
1294
- // ): Promise<void> {
1295
- // if (typeof uid !== "string") {
1296
- // throw Error(`Parameter "uid" has an invalid type "${typeof uid}", the valid type is "string".`);
1297
- // }
1298
- // if (path == null) {
1299
- // return await this._col.delete_all({_uid: uid})
1300
- // }
1301
- // else if (typeof path === "object") {
1302
- // return await this._col.delete_all({...path, _uid: uid})
1303
- // } else {
1304
- // return await this._col.delete_all({_path: path, _uid: uid})
1305
- // }
1306
- // }
1307
- // async delete_many(query: Record<string, any>): Promise<void> {
1308
- // return await this._col.delete_many(query)
1309
- // }
1310
- // /* @docs:
1311
- // * @title: Delete Collection
1312
- // * @description: Delete all documents of from the collection.
1313
- // */
1314
- // async delete_collection(): Promise<void> {
1315
- // await this._col.delete_collection()
1316
- // }
1317
- // /* @docs:
1318
- // * @title: Clean document
1319
- // * @description: Clean a document from all default system attributes.
1320
- // */
1321
- // clean<T>(doc: T): T | null {
1322
- // return this._col.clean(doc);
1323
- // }
1324
- // /** Write bulk operations. */
1325
- // async bulk_operations(operations: any[] = []): Promise<any> {
1326
- // return await this.col.bulkWrite(operations, {ordered: true});
1327
- // }
1328
- // }