acebase-server 1.10.1 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/.vscode/launch.json +24 -0
  2. package/dist/cjs/index.d.ts +1 -0
  3. package/dist/cjs/index.js +16 -0
  4. package/dist/cjs/logger.js +74 -0
  5. package/dist/cjs/middleware/admin-only.js +29 -0
  6. package/dist/cjs/middleware/user.js +4 -4
  7. package/dist/cjs/oauth-providers/dropbox.js +3 -2
  8. package/dist/cjs/oauth-providers/facebook.js +3 -2
  9. package/dist/cjs/oauth-providers/google.js +3 -2
  10. package/dist/cjs/oauth-providers/instagram.js +3 -2
  11. package/dist/cjs/oauth-providers/oauth-provider.js +23 -0
  12. package/dist/cjs/oauth-providers/spotify.js +3 -2
  13. package/dist/cjs/routes/auth-change-password.js +7 -4
  14. package/dist/cjs/routes/auth-delete.js +9 -7
  15. package/dist/cjs/routes/auth-forgot-password.js +9 -6
  16. package/dist/cjs/routes/auth-reset-password.js +5 -3
  17. package/dist/cjs/routes/auth-signout.js +6 -4
  18. package/dist/cjs/routes/auth-signup.js +17 -15
  19. package/dist/cjs/routes/auth-update.js +9 -6
  20. package/dist/cjs/routes/auth-verify-email.js +6 -3
  21. package/dist/cjs/routes/data-index-create.js +3 -5
  22. package/dist/cjs/routes/data-index-delete.js +2 -4
  23. package/dist/cjs/routes/data-index-list.js +2 -4
  24. package/dist/cjs/routes/data-reflect.js +2 -4
  25. package/dist/cjs/routes/data-schema-get.js +2 -4
  26. package/dist/cjs/routes/data-schema-set.js +2 -4
  27. package/dist/cjs/routes/data-schema-test.js +2 -4
  28. package/dist/cjs/routes/data-schemas-list.js +2 -4
  29. package/dist/cjs/routes/data-set.js +11 -7
  30. package/dist/cjs/routes/data-transaction.js +30 -10
  31. package/dist/cjs/routes/data-update.js +11 -6
  32. package/dist/cjs/routes/meta-logs.js +50 -0
  33. package/dist/cjs/routes/meta.js +3 -0
  34. package/dist/cjs/routes/oauth2-signin.js +15 -11
  35. package/dist/cjs/rules.js +5 -5
  36. package/dist/cjs/server.js +6 -4
  37. package/dist/cjs/settings/index.js +6 -7
  38. package/dist/cjs/shared/rootpath.js +2 -0
  39. package/dist/cjs/shared/signin.js +8 -3
  40. package/dist/cjs/start.js +3 -0
  41. package/dist/cjs/websocket/index.js +43 -24
  42. package/dist/cjs/websocket/socket.io.js +8 -11
  43. package/dist/esm/index.d.ts +1 -0
  44. package/dist/esm/index.js +2 -0
  45. package/dist/esm/logger.js +52 -0
  46. package/dist/esm/middleware/admin-only.js +25 -0
  47. package/dist/esm/middleware/user.js +4 -4
  48. package/dist/esm/oauth-providers/dropbox.js +3 -2
  49. package/dist/esm/oauth-providers/facebook.js +3 -2
  50. package/dist/esm/oauth-providers/google.js +3 -2
  51. package/dist/esm/oauth-providers/instagram.js +3 -2
  52. package/dist/esm/oauth-providers/oauth-provider.js +21 -1
  53. package/dist/esm/oauth-providers/spotify.js +3 -2
  54. package/dist/esm/routes/auth-change-password.js +6 -3
  55. package/dist/esm/routes/auth-delete.js +7 -5
  56. package/dist/esm/routes/auth-forgot-password.js +8 -6
  57. package/dist/esm/routes/auth-reset-password.js +4 -2
  58. package/dist/esm/routes/auth-signout.js +4 -2
  59. package/dist/esm/routes/auth-signup.js +12 -10
  60. package/dist/esm/routes/auth-update.js +8 -6
  61. package/dist/esm/routes/auth-verify-email.js +6 -2
  62. package/dist/esm/routes/data-index-create.js +4 -6
  63. package/dist/esm/routes/data-index-delete.js +3 -5
  64. package/dist/esm/routes/data-index-list.js +3 -5
  65. package/dist/esm/routes/data-reflect.js +1 -4
  66. package/dist/esm/routes/data-schema-get.js +3 -5
  67. package/dist/esm/routes/data-schema-set.js +3 -5
  68. package/dist/esm/routes/data-schema-test.js +3 -5
  69. package/dist/esm/routes/data-schemas-list.js +3 -5
  70. package/dist/esm/routes/data-set.js +9 -5
  71. package/dist/esm/routes/data-transaction.js +28 -8
  72. package/dist/esm/routes/data-update.js +9 -4
  73. package/dist/esm/routes/meta-logs.js +36 -0
  74. package/dist/esm/routes/meta.js +3 -0
  75. package/dist/esm/routes/oauth2-signin.js +14 -10
  76. package/dist/esm/rules.js +5 -5
  77. package/dist/esm/server.js +6 -4
  78. package/dist/esm/settings/index.js +5 -6
  79. package/dist/esm/shared/rootpath.js +2 -0
  80. package/dist/esm/shared/signin.js +7 -3
  81. package/dist/esm/start.js +3 -0
  82. package/dist/esm/websocket/index.js +38 -23
  83. package/dist/esm/websocket/socket.io.js +9 -11
  84. package/dist/types/index.d.ts +2 -0
  85. package/dist/types/logger.d.ts +35 -0
  86. package/dist/types/middleware/admin-only.d.ts +19 -0
  87. package/dist/types/oauth-providers/dropbox.d.ts +3 -14
  88. package/dist/types/oauth-providers/facebook.d.ts +3 -7
  89. package/dist/types/oauth-providers/google.d.ts +3 -7
  90. package/dist/types/oauth-providers/index.d.ts +2 -10
  91. package/dist/types/oauth-providers/instagram.d.ts +3 -7
  92. package/dist/types/oauth-providers/oauth-provider.d.ts +25 -21
  93. package/dist/types/oauth-providers/spotify.d.ts +3 -7
  94. package/dist/types/routes/data-query.d.ts +1 -1
  95. package/dist/types/routes/meta-logs.d.ts +20 -0
  96. package/dist/types/rules.d.ts +4 -4
  97. package/dist/types/server.d.ts +9 -7
  98. package/dist/types/settings/email.d.ts +1 -1
  99. package/dist/types/settings/index.d.ts +5 -6
  100. package/dist/types/shared/clients.d.ts +3 -1
  101. package/dist/types/shared/env.d.ts +6 -4
  102. package/dist/types/shared/http.d.ts +2 -0
  103. package/dist/types/shared/signin.d.ts +1 -1
  104. package/dist/types/websocket/index.d.ts +4 -0
  105. package/dist/types/websocket/manager.d.ts +1 -1
  106. package/package.json +8 -8
  107. package/webmanager/acebase-client-browser.min.js +16 -0
  108. package/webmanager/index.html +2 -2
  109. package/webmanager/index.js +3 -6
  110. package/create-package-files +0 -12
  111. package/dist/cjs/auth.js.map +0 -1
  112. package/dist/cjs/cluster.js.map +0 -1
  113. package/dist/cjs/index.js.map +0 -1
  114. package/dist/cjs/middleware/404.js.map +0 -1
  115. package/dist/cjs/middleware/cache.js.map +0 -1
  116. package/dist/cjs/middleware/connection.js.map +0 -1
  117. package/dist/cjs/middleware/context.js.map +0 -1
  118. package/dist/cjs/middleware/cors.js.map +0 -1
  119. package/dist/cjs/middleware/swagger.js.map +0 -1
  120. package/dist/cjs/middleware/user.js.map +0 -1
  121. package/dist/cjs/oauth-providers/dropbox.js.map +0 -1
  122. package/dist/cjs/oauth-providers/facebook.js.map +0 -1
  123. package/dist/cjs/oauth-providers/google.js.map +0 -1
  124. package/dist/cjs/oauth-providers/index.js.map +0 -1
  125. package/dist/cjs/oauth-providers/instagram.js.map +0 -1
  126. package/dist/cjs/oauth-providers/oauth-provider.js.map +0 -1
  127. package/dist/cjs/oauth-providers/spotify.js.map +0 -1
  128. package/dist/cjs/routes/auth-change-password.js.map +0 -1
  129. package/dist/cjs/routes/auth-delete.js.map +0 -1
  130. package/dist/cjs/routes/auth-forgot-password.js.map +0 -1
  131. package/dist/cjs/routes/auth-reset-password.js.map +0 -1
  132. package/dist/cjs/routes/auth-signin.js.map +0 -1
  133. package/dist/cjs/routes/auth-signout.js.map +0 -1
  134. package/dist/cjs/routes/auth-signup.js.map +0 -1
  135. package/dist/cjs/routes/auth-state.js.map +0 -1
  136. package/dist/cjs/routes/auth-update.js.map +0 -1
  137. package/dist/cjs/routes/auth-verify-email.js.map +0 -1
  138. package/dist/cjs/routes/auth.js.map +0 -1
  139. package/dist/cjs/routes/data-exists.js.map +0 -1
  140. package/dist/cjs/routes/data-export.js.map +0 -1
  141. package/dist/cjs/routes/data-get.js.map +0 -1
  142. package/dist/cjs/routes/data-import.js.map +0 -1
  143. package/dist/cjs/routes/data-index-create.js.map +0 -1
  144. package/dist/cjs/routes/data-index-delete.js.map +0 -1
  145. package/dist/cjs/routes/data-index-list.js.map +0 -1
  146. package/dist/cjs/routes/data-query.js.map +0 -1
  147. package/dist/cjs/routes/data-reflect.js.map +0 -1
  148. package/dist/cjs/routes/data-schema-get.js.map +0 -1
  149. package/dist/cjs/routes/data-schema-set.js.map +0 -1
  150. package/dist/cjs/routes/data-schema-test.js.map +0 -1
  151. package/dist/cjs/routes/data-schemas-list.js.map +0 -1
  152. package/dist/cjs/routes/data-set.js.map +0 -1
  153. package/dist/cjs/routes/data-sync-changes.js.map +0 -1
  154. package/dist/cjs/routes/data-sync-mutations.js.map +0 -1
  155. package/dist/cjs/routes/data-transaction.js.map +0 -1
  156. package/dist/cjs/routes/data-update.js.map +0 -1
  157. package/dist/cjs/routes/data.js.map +0 -1
  158. package/dist/cjs/routes/docs.js.map +0 -1
  159. package/dist/cjs/routes/meta-info.js.map +0 -1
  160. package/dist/cjs/routes/meta-ping.js.map +0 -1
  161. package/dist/cjs/routes/meta-stats.js.map +0 -1
  162. package/dist/cjs/routes/meta.js.map +0 -1
  163. package/dist/cjs/routes/oauth2-init.js.map +0 -1
  164. package/dist/cjs/routes/oauth2-refresh.js.map +0 -1
  165. package/dist/cjs/routes/oauth2-signin.js.map +0 -1
  166. package/dist/cjs/routes/webmanager.js.map +0 -1
  167. package/dist/cjs/rules.js.map +0 -1
  168. package/dist/cjs/schema/user.js.map +0 -1
  169. package/dist/cjs/server.js.map +0 -1
  170. package/dist/cjs/settings/email.js.map +0 -1
  171. package/dist/cjs/settings/index.js.map +0 -1
  172. package/dist/cjs/shared/clients.js.map +0 -1
  173. package/dist/cjs/shared/email.js.map +0 -1
  174. package/dist/cjs/shared/env.js.map +0 -1
  175. package/dist/cjs/shared/error.js.map +0 -1
  176. package/dist/cjs/shared/http.js.map +0 -1
  177. package/dist/cjs/shared/password.js.map +0 -1
  178. package/dist/cjs/shared/rootpath.js.map +0 -1
  179. package/dist/cjs/shared/signin.js.map +0 -1
  180. package/dist/cjs/shared/simple-fetch.js.map +0 -1
  181. package/dist/cjs/shared/tokens.js.map +0 -1
  182. package/dist/cjs/shared/validate.js.map +0 -1
  183. package/dist/cjs/start.js.map +0 -1
  184. package/dist/cjs/test.js.map +0 -1
  185. package/dist/cjs/websocket/index.js.map +0 -1
  186. package/dist/cjs/websocket/manager.js.map +0 -1
  187. package/dist/cjs/websocket/socket.io.js.map +0 -1
  188. package/dist/esm/auth.js.map +0 -1
  189. package/dist/esm/cluster.js.map +0 -1
  190. package/dist/esm/index.js.map +0 -1
  191. package/dist/esm/middleware/404.js.map +0 -1
  192. package/dist/esm/middleware/cache.js.map +0 -1
  193. package/dist/esm/middleware/connection.js.map +0 -1
  194. package/dist/esm/middleware/context.js.map +0 -1
  195. package/dist/esm/middleware/cors.js.map +0 -1
  196. package/dist/esm/middleware/swagger.js.map +0 -1
  197. package/dist/esm/middleware/user.js.map +0 -1
  198. package/dist/esm/oauth-providers/dropbox.js.map +0 -1
  199. package/dist/esm/oauth-providers/facebook.js.map +0 -1
  200. package/dist/esm/oauth-providers/google.js.map +0 -1
  201. package/dist/esm/oauth-providers/index.js.map +0 -1
  202. package/dist/esm/oauth-providers/instagram.js.map +0 -1
  203. package/dist/esm/oauth-providers/oauth-provider.js.map +0 -1
  204. package/dist/esm/oauth-providers/spotify.js.map +0 -1
  205. package/dist/esm/routes/auth-change-password.js.map +0 -1
  206. package/dist/esm/routes/auth-delete.js.map +0 -1
  207. package/dist/esm/routes/auth-forgot-password.js.map +0 -1
  208. package/dist/esm/routes/auth-reset-password.js.map +0 -1
  209. package/dist/esm/routes/auth-signin.js.map +0 -1
  210. package/dist/esm/routes/auth-signout.js.map +0 -1
  211. package/dist/esm/routes/auth-signup.js.map +0 -1
  212. package/dist/esm/routes/auth-state.js.map +0 -1
  213. package/dist/esm/routes/auth-update.js.map +0 -1
  214. package/dist/esm/routes/auth-verify-email.js.map +0 -1
  215. package/dist/esm/routes/auth.js.map +0 -1
  216. package/dist/esm/routes/data-exists.js.map +0 -1
  217. package/dist/esm/routes/data-export.js.map +0 -1
  218. package/dist/esm/routes/data-get.js.map +0 -1
  219. package/dist/esm/routes/data-import.js.map +0 -1
  220. package/dist/esm/routes/data-index-create.js.map +0 -1
  221. package/dist/esm/routes/data-index-delete.js.map +0 -1
  222. package/dist/esm/routes/data-index-list.js.map +0 -1
  223. package/dist/esm/routes/data-query.js.map +0 -1
  224. package/dist/esm/routes/data-reflect.js.map +0 -1
  225. package/dist/esm/routes/data-schema-get.js.map +0 -1
  226. package/dist/esm/routes/data-schema-set.js.map +0 -1
  227. package/dist/esm/routes/data-schema-test.js.map +0 -1
  228. package/dist/esm/routes/data-schemas-list.js.map +0 -1
  229. package/dist/esm/routes/data-set.js.map +0 -1
  230. package/dist/esm/routes/data-sync-changes.js.map +0 -1
  231. package/dist/esm/routes/data-sync-mutations.js.map +0 -1
  232. package/dist/esm/routes/data-transaction.js.map +0 -1
  233. package/dist/esm/routes/data-update.js.map +0 -1
  234. package/dist/esm/routes/data.js.map +0 -1
  235. package/dist/esm/routes/docs.js.map +0 -1
  236. package/dist/esm/routes/meta-info.js.map +0 -1
  237. package/dist/esm/routes/meta-ping.js.map +0 -1
  238. package/dist/esm/routes/meta-stats.js.map +0 -1
  239. package/dist/esm/routes/meta.js.map +0 -1
  240. package/dist/esm/routes/oauth2-init.js.map +0 -1
  241. package/dist/esm/routes/oauth2-refresh.js.map +0 -1
  242. package/dist/esm/routes/oauth2-signin.js.map +0 -1
  243. package/dist/esm/routes/webmanager.js.map +0 -1
  244. package/dist/esm/rules.js.map +0 -1
  245. package/dist/esm/schema/user.js.map +0 -1
  246. package/dist/esm/server.js.map +0 -1
  247. package/dist/esm/settings/email.js.map +0 -1
  248. package/dist/esm/settings/index.js.map +0 -1
  249. package/dist/esm/shared/clients.js.map +0 -1
  250. package/dist/esm/shared/email.js.map +0 -1
  251. package/dist/esm/shared/env.js.map +0 -1
  252. package/dist/esm/shared/error.js.map +0 -1
  253. package/dist/esm/shared/http.js.map +0 -1
  254. package/dist/esm/shared/password.js.map +0 -1
  255. package/dist/esm/shared/rootpath.js.map +0 -1
  256. package/dist/esm/shared/signin.js.map +0 -1
  257. package/dist/esm/shared/simple-fetch.js.map +0 -1
  258. package/dist/esm/shared/tokens.js.map +0 -1
  259. package/dist/esm/shared/validate.js.map +0 -1
  260. package/dist/esm/start.js.map +0 -1
  261. package/dist/esm/test.js.map +0 -1
  262. package/dist/esm/websocket/index.js.map +0 -1
  263. package/dist/esm/websocket/manager.js.map +0 -1
  264. package/dist/esm/websocket/socket.io.js.map +0 -1
  265. package/src/auth.ts +0 -87
  266. package/src/cluster.ts +0 -62
  267. package/src/index.ts +0 -2
  268. package/src/middleware/404.ts +0 -13
  269. package/src/middleware/cache.ts +0 -15
  270. package/src/middleware/connection.ts +0 -48
  271. package/src/middleware/context.ts +0 -23
  272. package/src/middleware/cors.ts +0 -49
  273. package/src/middleware/swagger.ts +0 -19
  274. package/src/middleware/user.ts +0 -51
  275. package/src/oauth-providers/dropbox.ts +0 -143
  276. package/src/oauth-providers/facebook.ts +0 -102
  277. package/src/oauth-providers/google.ts +0 -146
  278. package/src/oauth-providers/index.ts +0 -20
  279. package/src/oauth-providers/instagram.ts +0 -97
  280. package/src/oauth-providers/oauth-provider.ts +0 -55
  281. package/src/oauth-providers/spotify.ts +0 -126
  282. package/src/routes/auth-change-password.ts +0 -89
  283. package/src/routes/auth-change-password.yaml +0 -74
  284. package/src/routes/auth-delete.ts +0 -47
  285. package/src/routes/auth-delete.yaml +0 -78
  286. package/src/routes/auth-forgot-password.ts +0 -73
  287. package/src/routes/auth-forgot-password.yaml +0 -50
  288. package/src/routes/auth-reset-password.ts +0 -93
  289. package/src/routes/auth-reset-password.yaml +0 -54
  290. package/src/routes/auth-signin.ts +0 -55
  291. package/src/routes/auth-signin.yaml +0 -130
  292. package/src/routes/auth-signout.ts +0 -61
  293. package/src/routes/auth-signout.yaml +0 -46
  294. package/src/routes/auth-signup.ts +0 -161
  295. package/src/routes/auth-signup.yaml +0 -136
  296. package/src/routes/auth-state.ts +0 -20
  297. package/src/routes/auth-state.yaml +0 -29
  298. package/src/routes/auth-update.ts +0 -147
  299. package/src/routes/auth-update.yaml +0 -152
  300. package/src/routes/auth-verify-email.ts +0 -67
  301. package/src/routes/auth-verify-email.yaml +0 -53
  302. package/src/routes/auth.ts +0 -67
  303. package/src/routes/data-exists.ts +0 -31
  304. package/src/routes/data-exists.yaml +0 -44
  305. package/src/routes/data-export.ts +0 -51
  306. package/src/routes/data-export.yaml +0 -64
  307. package/src/routes/data-get.ts +0 -68
  308. package/src/routes/data-get.yaml +0 -54
  309. package/src/routes/data-import.ts +0 -56
  310. package/src/routes/data-import.yaml +0 -75
  311. package/src/routes/data-index-create.ts +0 -85
  312. package/src/routes/data-index-create.yaml +0 -105
  313. package/src/routes/data-index-delete.ts +0 -39
  314. package/src/routes/data-index-delete.yaml +0 -51
  315. package/src/routes/data-index-list.ts +0 -42
  316. package/src/routes/data-index-list.yaml +0 -80
  317. package/src/routes/data-query.ts +0 -97
  318. package/src/routes/data-query.yaml +0 -166
  319. package/src/routes/data-reflect.ts +0 -94
  320. package/src/routes/data-reflect.yaml +0 -124
  321. package/src/routes/data-schema-get.ts +0 -38
  322. package/src/routes/data-schema-get.yaml +0 -53
  323. package/src/routes/data-schema-set.ts +0 -38
  324. package/src/routes/data-schema-set.yaml +0 -60
  325. package/src/routes/data-schema-test.ts +0 -53
  326. package/src/routes/data-schema-test.yaml +0 -66
  327. package/src/routes/data-schemas-list.ts +0 -33
  328. package/src/routes/data-schemas-list.yaml +0 -41
  329. package/src/routes/data-set.ts +0 -76
  330. package/src/routes/data-set.yaml +0 -71
  331. package/src/routes/data-sync-changes.ts +0 -78
  332. package/src/routes/data-sync-changes.yaml +0 -67
  333. package/src/routes/data-sync-mutations.ts +0 -78
  334. package/src/routes/data-sync-mutations.yaml +0 -67
  335. package/src/routes/data-transaction-finish.yaml +0 -76
  336. package/src/routes/data-transaction-start.yaml +0 -58
  337. package/src/routes/data-transaction.ts +0 -144
  338. package/src/routes/data-update.ts +0 -77
  339. package/src/routes/data-update.yaml +0 -71
  340. package/src/routes/data.ts +0 -79
  341. package/src/routes/docs.ts +0 -249
  342. package/src/routes/meta-info.ts +0 -80
  343. package/src/routes/meta-info.yaml +0 -41
  344. package/src/routes/meta-ping.ts +0 -15
  345. package/src/routes/meta-ping.yaml +0 -23
  346. package/src/routes/meta-stats.ts +0 -31
  347. package/src/routes/meta-stats.yaml +0 -41
  348. package/src/routes/meta.ts +0 -18
  349. package/src/routes/oauth2-init.ts +0 -44
  350. package/src/routes/oauth2-init.yaml +0 -63
  351. package/src/routes/oauth2-refresh.ts +0 -39
  352. package/src/routes/oauth2-refresh.yaml +0 -65
  353. package/src/routes/oauth2-signin.ts +0 -281
  354. package/src/routes/oauth2-signin.yaml +0 -66
  355. package/src/routes/webmanager.ts +0 -29
  356. package/src/rules.ts +0 -196
  357. package/src/schema/user.ts +0 -99
  358. package/src/server.ts +0 -416
  359. package/src/settings/email.ts +0 -18
  360. package/src/settings/index.ts +0 -240
  361. package/src/shared/clients.ts +0 -31
  362. package/src/shared/email.ts +0 -33
  363. package/src/shared/env.ts +0 -38
  364. package/src/shared/error.ts +0 -37
  365. package/src/shared/http.ts +0 -24
  366. package/src/shared/password.ts +0 -41
  367. package/src/shared/rootpath.ts +0 -15
  368. package/src/shared/signin.ts +0 -143
  369. package/src/shared/simple-fetch.ts +0 -65
  370. package/src/shared/tokens.ts +0 -77
  371. package/src/shared/validate.ts +0 -53
  372. package/src/start.ts +0 -45
  373. package/src/test.ts +0 -10
  374. package/src/websocket/index.ts +0 -320
  375. package/src/websocket/manager.ts +0 -46
  376. package/src/websocket/socket.io.ts +0 -91
  377. package/tsconfig-cjs.json +0 -10
  378. package/tsconfig.json +0 -21
@@ -1,64 +0,0 @@
1
- /export/{dbname}/{path}:
2
- get:
3
- tags:
4
- - data
5
- summary: Export (stream) the value of a path
6
- description: Exports the value of a path in the database by streaming its content in a serialized format
7
- parameters:
8
- - name: dbname
9
- in: path
10
- description: name of the database
11
- required: true
12
- schema:
13
- type: string
14
- example: mydb
15
- - name: path
16
- in: path
17
- description: database path
18
- required: true
19
- schema:
20
- type: string
21
- example: collection
22
- - name: format
23
- in: query
24
- description: desired output format. Only `json` is currently supported
25
- schema:
26
- type: string
27
- enum:
28
- - json
29
- example: json
30
- - name: type_safe
31
- in: query
32
- description: Whether to add type information for data that has no native JSON representation (such as dates, binary data etc)
33
- schema:
34
- type: string
35
- enum:
36
- - 0
37
- - 1
38
- example: 1
39
- responses:
40
- 200:
41
- description: Streams the data of requested path in the requested format. In the browser, this will trigger a file download.
42
- headers:
43
- 'Content-Disposition':
44
- description: Tells the browser to download the data as a file
45
- schema:
46
- type: string
47
- example: attachment; filename=[target_key].json
48
- content:
49
- 'text/plain':
50
- schema:
51
- type: object
52
- example: {"l27mgh8r000009mhh84jdp9c":{"name":"My todo list","stats":{"size":216,"created":{".type":"date",".val":"2022-04-07T15:11:42.000Z"},"modified":{".type":"date",".val":"2022-03-08T12:24:05.000Z"}}},"l27mhwz2000109mh11yi7rbo":{"name":"Another child"},"l27mjf9k000209mhafylc3eo":{"name":"And another.."}}
53
- 403:
54
- description: Returns a "403 Forbidden" if the signed in user is not allowed to read from the target path
55
- content:
56
- 'application/json':
57
- schema:
58
- $ref: '#/components/schemas/Error'
59
- 500:
60
- description: An unexpected error occurred
61
- content:
62
- 'application/json':
63
- schema:
64
- $ref: '#/components/schemas/UnexpectedError'
@@ -1,68 +0,0 @@
1
- import { Transport } from 'acebase-core';
2
- import { SerializedValue } from 'acebase-core/types/transport';
3
- import { RouteInitEnvironment, RouteRequest } from '../shared/env';
4
- import { sendUnauthorizedError } from '../shared/error';
5
-
6
- export type RequestQuery = { include?: string; exclude?: string; child_objects?: boolean };
7
- export type RequestBody = null;
8
- export type ResponseBody = SerializedValue & { exists: boolean };
9
- export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
10
-
11
- export const addRoute = (env: RouteInitEnvironment) => {
12
-
13
- env.app.get(`/data/${env.db.name}/*`, async (req: Request, res) => {
14
- // Request data
15
- const path = req.path.slice(env.db.name.length + 7);
16
- const access = env.rules.userHasAccess(req.user, path, false);
17
- if (!access.allow) {
18
- return sendUnauthorizedError(res, access.code, access.message);
19
- }
20
-
21
- const options: { include?: string[]; exclude?: string[]; child_objects?: boolean } = {};
22
- if (req.query.include) {
23
- options.include = req.query.include.split(',');
24
- }
25
- if (req.query.exclude) {
26
- options.exclude = req.query.exclude.split(',');
27
- }
28
- if (typeof req.query.child_objects === 'boolean') {
29
- options.child_objects = req.query.child_objects;
30
- }
31
-
32
- if (path === '') {
33
- // If user has access to the root of database (NOT recommended for others than admin...)
34
- // Do not return private server data. If the admin user wants access, they should use
35
- // direct requests on those paths (GET /data/dbname/__auth__), or use reflection
36
-
37
- if (options.include) {
38
- // Remove all includes for private paths
39
- options.include = options.include.filter(path => !path.startsWith('__'));
40
- }
41
- // Add private paths to exclude
42
- options.exclude = [...options.exclude || [], '__auth__', '__log__'];
43
- }
44
-
45
- try {
46
- // const snap = await db.ref(path).get(options);
47
- // const value = snap.val(), context = snap.context();
48
- const { value, context } = await env.db.api.get(path, options);
49
- if (!env.config.transactions?.log) {
50
- delete context.acebase_cursor;
51
- }
52
- const serialized = Transport.serialize(value);
53
-
54
- res.setHeader('AceBase-Context', JSON.stringify(context));
55
- res.send({
56
- exists: value !== null,
57
- val: serialized.val,
58
- map: serialized.map
59
- });
60
- }
61
- catch (err) {
62
- res.status(500).send(err);
63
- }
64
- });
65
-
66
- };
67
-
68
- export default addRoute;
@@ -1,54 +0,0 @@
1
- /data/{dbname}/{path}:
2
- get:
3
- tags:
4
- - data
5
- summary: Get the value of a path
6
- description: Gets the stored value of a path in the database
7
- parameters:
8
- - name: dbname
9
- in: path
10
- description: name of the database
11
- required: true
12
- schema:
13
- type: string
14
- example: mydb
15
- - name: path
16
- in: path
17
- description: database path
18
- required: true
19
- schema:
20
- type: string
21
- example: collection/child/property
22
- responses:
23
- 200:
24
- description: Returns the serialized value of the target path, and whether it exists in the database
25
- content:
26
- 'application/json':
27
- schema:
28
- required:
29
- - val
30
- - exists
31
- allOf:
32
- - type: object
33
- properties:
34
- exists:
35
- type: boolean
36
- description: indicates if the path exists (when `false`, `val` property will be `null`)
37
- example: true
38
- - $ref: '#/components/schemas/SerializedValue'
39
- example:
40
- exists: true
41
- val: { name: 'My todo list', stats: { size: 216, created: '2022-04-07T15:11:42Z', modified: '2022-03-08T12:24:05Z' } }
42
- map: { 'stats/created': 'date', 'stats/modified': 'date' }
43
- 403:
44
- description: Returns a "403 Forbidden" if the signed in user is not allowed to read from the target path
45
- content:
46
- 'application/json':
47
- schema:
48
- $ref: '#/components/schemas/Error'
49
- 500:
50
- description: An unexpected error occurred
51
- content:
52
- 'application/json':
53
- schema:
54
- $ref: '#/components/schemas/UnexpectedError'
@@ -1,56 +0,0 @@
1
- import { RouteInitEnvironment, RouteRequest } from '../shared/env';
2
- import { sendUnauthorizedError } from '../shared/error';
3
-
4
- export type RequestQuery = {
5
- format?: 'json';
6
- suppress_events?: '0'|'1'
7
- };
8
- export type RequestBody = null;
9
- export type ResponseBody = { success: boolean; reason?: string };
10
- export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
11
-
12
- export const addRoute = (env: RouteInitEnvironment) => {
13
-
14
- env.app.post(`/import/${env.db.name}/*`, async (req: Request, res) => {
15
- // Import API
16
- const path = req.path.slice(env.db.name.length + 9);
17
- const access = env.rules.userHasAccess(req.user, path, false);
18
- if (!access.allow) {
19
- return sendUnauthorizedError(res, access.code, access.message);
20
- }
21
- const format = req.query.format || 'json';
22
- const suppress_events = req.query.suppress_events === '1';
23
-
24
- req.pause(); // Switch to non-flowing mode so we can use .read() upon request
25
- let eof = false;
26
- req.once('end', () => { eof = true; });
27
- const read = async (length: number) => {
28
- let chunk = req.read();
29
- if (chunk === null && !eof) {
30
- await new Promise(resolve => req.once('readable', resolve));
31
- chunk = req.read();
32
- }
33
- // env.debug.verbose(`Received chunk: `, chunk);
34
- return chunk;
35
- };
36
-
37
- const ref = env.db.ref(path);
38
- try {
39
- await ref.import(read, { format, suppress_events });
40
- res.send({ success: true });
41
- }
42
- catch (err) {
43
- env.debug.error(`Error importing data for path "/${path}": `, err);
44
- if (!res.headersSent) {
45
- res.statusCode = 500;
46
- res.send({ success: false, reason: err.message });
47
- }
48
- }
49
- finally {
50
- res.end();
51
- }
52
- });
53
-
54
- };
55
-
56
- export default addRoute;
@@ -1,75 +0,0 @@
1
- /import/{dbname}/{path}:
2
- post:
3
- tags:
4
- - data
5
- summary: Import (stream) a new value for a path
6
- description: Imports (streams) the sent data for a path into the database (beta functionality, currently not very fast)
7
- parameters:
8
- - name: dbname
9
- in: path
10
- description: name of the database
11
- required: true
12
- schema:
13
- type: string
14
- example: mydb
15
- - name: path
16
- in: path
17
- description: database path
18
- required: true
19
- schema:
20
- type: string
21
- example: collection
22
- - name: format
23
- in: query
24
- description: used data format. Only `json` is currently supported
25
- schema:
26
- type: string
27
- enum:
28
- - json
29
- example: json
30
- - name: suppress_events
31
- in: query
32
- description: Whether to suppress firing data change events during the import
33
- schema:
34
- type: string
35
- enum:
36
- - 0
37
- - 1
38
- example: 0
39
- requestBody:
40
- description: value to store in the database, can use typesafe values as exported by the _export_ endpoint
41
- content:
42
- 'text/plain':
43
- schema:
44
- type: object
45
- example: {"l27mgh8r000009mhh84jdp9c":{"name":"My todo list","stats":{"size":216,"created":{".type":"date",".val":"2022-04-07T15:11:42.000Z"},"modified":{".type":"date",".val":"2022-03-08T12:24:05.000Z"}}},"l27mhwz2000109mh11yi7rbo":{"name":"Another child"},"l27mjf9k000209mhafylc3eo":{"name":"And another.."}}
46
- responses:
47
- 200:
48
- description: Returns "200 OK" when the database operation succeeded
49
- content:
50
- 'application/json':
51
- schema:
52
- type: object
53
- properties:
54
- success:
55
- type: boolean
56
- example: true
57
- 403:
58
- description: Returns "403 Forbidden" if the signed in user is not allowed to write to the target path
59
- content:
60
- 'application/json':
61
- schema:
62
- $ref: '#/components/schemas/Error'
63
- 500:
64
- description: An error occurred
65
- content:
66
- 'application/json':
67
- schema:
68
- type: object
69
- properties:
70
- success:
71
- type: boolean
72
- example: false
73
- reason:
74
- type: string
75
- example: Something went wrong
@@ -1,85 +0,0 @@
1
- import { RouteInitEnvironment, RouteRequest } from '../shared/env';
2
- import { sendError, sendUnauthorizedError } from '../shared/error';
3
- import { Response } from '../shared/http';
4
-
5
- export type FullTextIndexOptions = {
6
- type: 'fulltext';
7
- config?: {
8
- /** Callback function that transforms (and/or filters) words being indexed _and_ queried */
9
- transform?: (locale: string, word: string) => string;
10
- /** Also known as a stoplist. Array of words to automatically be ignored for indexing and querying. */
11
- blacklist?: string[];
12
- /** Words to be included if they did not match minLength and/or blacklist criteria */
13
- whitelist?: string[];
14
- /** Only use words with a minimum length */
15
- minLength?: number;
16
- /** Only use words with a maximum length */
17
- maxLength?: number;
18
- /** Specify a key in the data that contains the locale of the indexed texts. This allows multiple languages to be indexed using their own rules. */
19
- localeKey?: string;
20
- /** Boolean value that specifies whether a default stoplist for the used locale should be used to automatically blacklist words. Currently only available for locale "en", which contains very frequently used words like "a", "i", "me", "it", "the", "they", "them" etc. */
21
- useStoplist?: boolean;
22
- }
23
- };
24
- export type GeoIndexOptions = {
25
- type: 'geo';
26
- };
27
- export type ArrayIndexOptions = {
28
- type: 'array';
29
- };
30
-
31
- export type CreateIndexRequest = {
32
- path: string;
33
- key: string;
34
- options?: {
35
- type?: 'normal'|'array'|'fulltext'|'geo';
36
- rebuild?: boolean;
37
- textLocale?: string;
38
- include?: string[];
39
- config?: {}
40
- } & ({} | FullTextIndexOptions | GeoIndexOptions | ArrayIndexOptions);
41
- };
42
-
43
- export type RequestQuery = null;
44
- export type RequestBody = CreateIndexRequest;
45
- export type ResponseBody = { success: true } // 200
46
- | { code: 'admin_only'; message: string } // 403
47
- | { code: 'unexpected'; message: string }; // 500 (TODO check if 400 is also possible)
48
-
49
- export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
50
-
51
- export const addRoute = (env: RouteInitEnvironment) => {
52
-
53
- const handleRequest = async (req: Request, res: Response) => {
54
- if (!req.user || req.user.username !== 'admin') {
55
- return sendUnauthorizedError(res, 'admin_only', 'only admin can perform index operations');
56
- }
57
-
58
- try {
59
- const data = req.body;
60
- await env.db.indexes.create(data.path, data.key, data.options);
61
- res.contentType('application/json').send({ success: true });
62
- }
63
- catch(err) {
64
- env.debug.error(`failed to perform index action`, err);
65
- sendError(res, err);
66
- }
67
- };
68
-
69
- env.app.post(`/index/${env.db.name}`, async (req: RouteRequest<any, ResponseBody, RequestBody & { action: 'create'} >, res) => {
70
- // Legacy endpoint that was designed to handle multiple actions
71
- // The only action ever implemented was 'create', so we'll handle that here
72
- if (req.body?.action !== 'create') {
73
- return sendError(res, { code: 'invalid_action', message: 'Invalid action' });
74
- }
75
- handleRequest(req, res);
76
- });
77
-
78
- env.app.post(`/index/${env.db.name}/create`, async (req: Request, res) => {
79
- // New dedicated create endpoint
80
- handleRequest(req, res);
81
- });
82
-
83
- };
84
-
85
- export default addRoute;
@@ -1,105 +0,0 @@
1
- /index/{dbname}/create:
2
- post:
3
- tags:
4
- - data
5
- - indexes
6
- summary: Creates an index
7
- description: Creates a new index in the database if it does not exist already. (admin only)
8
- parameters:
9
- - name: dbname
10
- in: path
11
- description: name of the database
12
- required: true
13
- schema:
14
- type: string
15
- example: mydb
16
- requestBody:
17
- description: request
18
- content:
19
- 'application/json':
20
- schema:
21
- type: object
22
- properties:
23
- path:
24
- type: string
25
- description: path of the collection to index, can contain wildcards and variables such as * and $name
26
- example: books
27
- examples:
28
- simple:
29
- summary: Simple path
30
- value: books
31
- wildcard:
32
- summary: path with a wildcard to index scattered data
33
- value: users/*/reservations
34
- variable:
35
- summary: path with a variable (same as *) to index scattered data
36
- value: hotels/$id/reviews
37
- required: true
38
- key:
39
- type: string
40
- description: key (property) to index for each item in the collection, can contain a nested target path
41
- example: title
42
- examples:
43
- - title
44
- - text
45
- - content/title
46
- - content/stats/size
47
- required: true
48
- options:
49
- type: object
50
- description: Additional options
51
- properties:
52
- 'type':
53
- type: string
54
- enum:
55
- - normal
56
- - array
57
- - fulltext
58
- - geo
59
- description: type of index to create
60
- include:
61
- type: array
62
- items:
63
- type: string
64
- example:
65
- - year
66
- - rating
67
- description: Additional keys to include in the index. Speeds up sorting on these columns when the index is used (and dramatically increases query speed when .take(n) is used in addition)
68
- rebuild:
69
- type: boolean
70
- example: false
71
- description: Whether to rebuild the index if it exists already
72
- textLocale:
73
- type: string
74
- example: en-us
75
- description: If the indexed values are strings, which default locale to use
76
- config:
77
- type: object
78
- description: additional configuration for special indexes, see documentation
79
- properties:
80
- see_docs:
81
- description: See documentation for config options. Note that you can't create fulltext indexes with custom callack functions through the API; those need to be created in your code at the server.
82
- example: (See documentation for config options, many require server-side execution)
83
- responses:
84
- 200:
85
- description: returned when the index was created successfully
86
- content:
87
- 'application/json':
88
- schema:
89
- type: object
90
- properties:
91
- success:
92
- type: boolean
93
- example: true
94
- 403:
95
- description: Returns "403 Forbidden" if the signed in user is not admin
96
- content:
97
- 'application/json':
98
- schema:
99
- $ref: '#/components/schemas/Error'
100
- 500:
101
- description: An unexpected error occurred
102
- content:
103
- 'application/json':
104
- schema:
105
- $ref: '#/components/schemas/UnexpectedError'
@@ -1,39 +0,0 @@
1
- import { RouteInitEnvironment, RouteRequest } from '../shared/env';
2
- import { sendError, sendUnauthorizedError } from '../shared/error';
3
-
4
- export type RequestQuery = null;
5
- export type RequestBody = {
6
- fileName: string;
7
- };
8
- export type ResponseBody = { success: true } // 200
9
- | { code: 'admin_only'; message: string } // 403
10
- | { code: 'unexpected'; message: string }; // 500 (TODO check if 400 is also possible)
11
-
12
- export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
13
-
14
- export const addRoute = (env: RouteInitEnvironment) => {
15
-
16
- env.app.post(`/index/${env.db.name}/delete`, async (req: Request, res) => {
17
- // Delete an index
18
- if (!req.user || req.user.username !== 'admin') {
19
- return sendUnauthorizedError(res, 'admin_only', 'only admin can perform index operations');
20
- }
21
-
22
- try {
23
- const data = req.body;
24
- if (!data.fileName) {
25
- throw new Error('fileName not given');
26
- }
27
-
28
- await env.db.indexes.delete(data.fileName); // Requires newer acebase & acebase-core packages
29
- res.contentType('application/json').send({ success: true });
30
- }
31
- catch(err) {
32
- env.debug.error(`failed to perform index action`, err);
33
- sendError(res, err);
34
- }
35
- });
36
-
37
- };
38
-
39
- export default addRoute;
@@ -1,51 +0,0 @@
1
- /index/{dbname}/delete:
2
- post:
3
- tags:
4
- - data
5
- - indexes
6
- summary: Removes an index
7
- description: Removes an index from the database
8
- parameters:
9
- - name: dbname
10
- in: path
11
- description: name of the database
12
- required: true
13
- schema:
14
- type: string
15
- example: mydb
16
- requestBody:
17
- description: request
18
- content:
19
- 'application/json':
20
- schema:
21
- type: object
22
- properties:
23
- fileName:
24
- type: string
25
- description: The name of the target index file to delete
26
- required:
27
- - action
28
- - filePath
29
- responses:
30
- 200:
31
- description: Returned when the index is deleted successfully
32
- content:
33
- 'application/json':
34
- schema:
35
- type: object
36
- properties:
37
- success:
38
- type: boolean
39
- example: true
40
- 403:
41
- description: Returns "403 Forbidden" if the signed in user is not admin
42
- content:
43
- 'application/json':
44
- schema:
45
- $ref: '#/components/schemas/Error'
46
- 500:
47
- description: An unexpected error occurred
48
- content:
49
- 'application/json':
50
- schema:
51
- $ref: '#/components/schemas/UnexpectedError'
@@ -1,42 +0,0 @@
1
- import { RouteInitEnvironment, RouteRequest } from '../shared/env';
2
- import { sendError, sendUnauthorizedError } from '../shared/error';
3
-
4
- export interface PublicDataIndex {
5
- path: string;
6
- key: string;
7
- caseSensitive: boolean;
8
- textLocale: string;
9
- includeKeys: string[];
10
- indexMetadataKeys: string[];
11
- type: "normal" | "array" | "fulltext" | "geo";
12
- fileName: string;
13
- description: string;
14
- };
15
- export type RequestQuery = null;
16
- export type RequestBody = null;
17
- export type ResponseBody = PublicDataIndex[] | { code: string; message: string };
18
- export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
19
-
20
- export const addRoute = (env: RouteInitEnvironment) => {
21
-
22
- env.app.get(`/index/${env.db.name}`, async (req: Request, res) => {
23
- // Get all indexes
24
- if (!req.user || req.user.username !== 'admin') {
25
- return sendUnauthorizedError(res, 'admin_only', 'only admin can perform index operations');
26
- }
27
-
28
- try {
29
- const indexes = await env.db.indexes.get();
30
- res.contentType('application/json').send(indexes.map(index => {
31
- const { path, key, caseSensitive, textLocale, includeKeys, indexMetadataKeys, type, fileName, description } = index;
32
- return { path, key, caseSensitive, textLocale, includeKeys, indexMetadataKeys, type, fileName, description };
33
- }));
34
- }
35
- catch (err) {
36
- sendError(res, err);
37
- }
38
- });
39
-
40
- };
41
-
42
- export default addRoute;