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,60 +0,0 @@
1
- /schema/{dbname}:
2
- post:
3
- tags:
4
- - data
5
- - schemas
6
- summary: Add a schema definition
7
- description: Adds a schema definition to the specified path. This schema will be enabled while the server runs, and cleared upon restart. If you need the schema to be persisted, add it to your server's rules.json file
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: details about the data and schema to test
18
- content:
19
- 'application/json':
20
- schema:
21
- type: object
22
- properties:
23
- action:
24
- type: string
25
- description: The desired operation `'set'` (optional, deprecated since v1.10.0)
26
- example: set
27
- path:
28
- type: string
29
- description: database path to the given value
30
- example: collection/item
31
- schema:
32
- type: string
33
- description: When given, tests this schema definition against the passed value instead of ones defined in the database
34
- example: "{ name: string, stats?: { size: number, created: Date, modified: Date, deleted?: Date } }"
35
- required:
36
- - path
37
- - schema
38
- responses:
39
- 200:
40
- description: Returns "200 OK" if the schema was added successfully
41
- content:
42
- 'application/json':
43
- schema:
44
- type: object
45
- properties:
46
- success:
47
- type: boolean
48
- example: true
49
- 403:
50
- description: Returns a "403 Forbidden" if the signed in user is not admin
51
- content:
52
- 'application/json':
53
- schema:
54
- $ref: '#/components/schemas/Error'
55
- 500:
56
- description: An error occurred
57
- content:
58
- 'application/json':
59
- schema:
60
- $ref: '#/components/schemas/UnexpectedError'
@@ -1,53 +0,0 @@
1
- import { ISchemaCheckResult, SchemaDefinition, Transport } from 'acebase-core';
2
- import type { IAceBaseSchemaInfo } from 'acebase-core/src/api';
3
- import type { SerializedValue } from 'acebase-core/types/transport';
4
- import { RouteInitEnvironment, RouteRequest } from '../shared/env';
5
- import { sendError, sendUnauthorizedError } from '../shared/error';
6
-
7
- export type RequestQuery = null;
8
- export type RequestBody = {
9
- value: SerializedValue;
10
- partial: boolean;
11
- path?: string;
12
- schema?: IAceBaseSchemaInfo
13
- };
14
- export type ResponseBody = ISchemaCheckResult // 200
15
- | { code: 'admin_only'; message: string } // 403
16
- | { code: 'unexpected'; message: string }; // 500
17
-
18
- export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
19
-
20
- export const addRoute = (env: RouteInitEnvironment) => {
21
-
22
- env.app.post(`/schema/${env.db.name}/test`, async (req: Request, res) => {
23
- // tests a schema
24
- if (!req.user || req.user.username !== 'admin') {
25
- return sendUnauthorizedError(res, 'admin_only', 'only admin can perform schema operations');
26
- }
27
-
28
- try {
29
- const data = req.body;
30
- if (typeof data.value?.val === 'undefined' || !['string','object','undefined'].includes(typeof data.value?.map)) {
31
- return sendError(res, { code: 'invalid_serialized_value', message: 'The sent value is not properly serialized' });
32
- }
33
- const value = Transport.deserialize(data.value);
34
- const { path, schema, partial } = data;
35
- let result: ISchemaCheckResult;
36
- if (schema) {
37
- const definition = new SchemaDefinition(schema);
38
- result = definition.check(path, value, partial);
39
- }
40
- else {
41
- result = await env.db.schema.check(path, schema, partial);
42
- }
43
-
44
- res.contentType('application/json').send(result);
45
- }
46
- catch(err) {
47
- sendError(res, err);
48
- }
49
- });
50
-
51
- };
52
-
53
- export default addRoute;
@@ -1,66 +0,0 @@
1
- /schema/{dbname}/test:
2
- post:
3
- tags:
4
- - data
5
- - schemas
6
- summary: Test a data schema
7
- description: Tests an existing data schema in the database, or a given custom schema.
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: details about the data and schema to test
18
- content:
19
- 'application/json':
20
- schema:
21
- type: object
22
- properties:
23
- path:
24
- type: string
25
- description: database path to the given value
26
- example: collection/item
27
- value:
28
- $ref: '#/components/schemas/SerializedValue'
29
- partial:
30
- type: boolean
31
- description: Whether to only test passed data (`update` db operation), or to validate the value against the entire schema (`set` db operation). Update operations allow required children in the schema not to be present in the passed value.
32
- example: false
33
- schema:
34
- type: string
35
- description: When given, tests this schema definition against the passed value instead of ones defined in the database
36
- example: "{ name: string, stats?: { size: number, created: Date, modified: Date, deleted?: Date } }"
37
- required:
38
- - path
39
- - value
40
- - partial
41
- responses:
42
- 200:
43
- description: Returns an object that indicates whether the value successfully validated against schema
44
- content:
45
- 'application/json':
46
- schema:
47
- type: object
48
- properties:
49
- ok:
50
- type: boolean
51
- example: false
52
- reason:
53
- type: string
54
- example: path "books/book1/title" must be typeof string
55
- 403:
56
- description: Returns a "403 Forbidden" if the signed in user is not admin
57
- content:
58
- 'application/json':
59
- schema:
60
- $ref: '#/components/schemas/Error'
61
- 500:
62
- description: An unexpected error occurred
63
- content:
64
- 'application/json':
65
- schema:
66
- $ref: '#/components/schemas/UnexpectedError'
@@ -1,33 +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 = null;
6
- export type ResponseBody =
7
- { path: string; schema: string; text: string }[] // 200
8
-
9
- export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
10
-
11
- export const addRoute = (env: RouteInitEnvironment) => {
12
-
13
- env.app.get(`/schema/${env.db.name}`, async (req: Request, res) => {
14
- // Get all defined schemas
15
- if (!req.user || req.user.username !== 'admin') {
16
- return sendUnauthorizedError(res, 'admin_only', 'only admin can perform schema operations');
17
- }
18
- try {
19
- const schemas = await env.db.schema.all();
20
- res.contentType('application/json').send(schemas.map(schema => ({
21
- path: schema.path,
22
- schema: typeof schema.schema === 'string' ? schema.schema : schema.text,
23
- text: schema.text
24
- })));
25
- }
26
- catch(err) {
27
- sendError(res, err);
28
- }
29
- });
30
-
31
- };
32
-
33
- export default addRoute;
@@ -1,41 +0,0 @@
1
- /schema/{dbname}:
2
- get:
3
- tags:
4
- - data
5
- - schemas
6
- summary: Gets all defined schema definitions
7
- description: Gets a list of all defined schema definitions
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
- responses:
17
- 200:
18
- description: Returns all defined schemas in the database
19
- content:
20
- 'application/json':
21
- schema:
22
- type: array
23
- items:
24
- type: object
25
- description: Object containing the string representation of the schema
26
- example:
27
- - path: collection/child
28
- schema: "{ name: string, stats?: { size: number, created: Date, modified: Date, deleted?: Date } }"
29
- text: "{ name: string, stats?: { size: number, created: Date, modified: Date, deleted?: Date } }"
30
- 403:
31
- description: Returns a "403 Forbidden" if the signed in user is not admin
32
- content:
33
- 'application/json':
34
- schema:
35
- $ref: '#/components/schemas/Error'
36
- 500:
37
- description: An unexpected error occurred
38
- content:
39
- 'application/json':
40
- schema:
41
- $ref: '#/components/schemas/UnexpectedError'
@@ -1,76 +0,0 @@
1
- import { SchemaValidationError } from 'acebase';
2
- import { Transport } from 'acebase-core';
3
- import { SerializedValue } from 'acebase-core/types/transport';
4
- import { RuleValidationFailCode } from '../rules';
5
- import { RouteInitEnvironment, RouteRequest } from '../shared/env';
6
- import { sendBadRequestError, sendError, sendUnauthorizedError } from '../shared/error';
7
-
8
- export class SetDataError extends Error {
9
- constructor(public code: 'invalid_serialized_value', message: string) {
10
- super(message);
11
- }
12
- }
13
- export type RequestQuery = null;
14
- export type RequestBody = SerializedValue; // { val: any; map?: string|Record<string, 'date'|'binary'|'reference'|'regexp'|'array'> };
15
- export type ResponseBody = { success: true } // 200
16
- | { code: 'invalid_serialized_value', message: string } // 400
17
- | { code: RuleValidationFailCode, message: string } // 403
18
- | { code: 'schema_validation_failed', message: string } // 422
19
- | { code: string, message: string } // 500
20
-
21
- export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
22
-
23
- export const addRoute = (env: RouteInitEnvironment) => {
24
-
25
- env.app.put(`/data/${env.db.name}/*`, async (req: Request, res) => {
26
- // Set data
27
- const path = req.path.slice(env.db.name.length + 7);
28
- const access = env.rules.userHasAccess(req.user, path, true);
29
- if (!access.allow) {
30
- return sendUnauthorizedError(res, access.code, access.message);
31
- }
32
-
33
- try {
34
- const data = req.body;
35
- if (typeof data?.val === 'undefined' || !['string','object','undefined'].includes(typeof data?.map)) {
36
- throw new SetDataError('invalid_serialized_value', 'The sent value is not properly serialized');
37
- }
38
- const val = Transport.deserialize(data);
39
-
40
- if (path === '' && req.user?.uid !== 'admin' && val !== null && typeof val === 'object') {
41
- // Non-admin user: remove any private properties from the update object
42
- Object.keys(val).filter(key => key.startsWith('__')).forEach(key => delete val[key]);
43
- }
44
-
45
- // Schema validation moved to storage, no need to check here but an early check won't do no harm!
46
- const validation = await env.db.schema.check(path, val, false);
47
- if (!validation.ok) {
48
- throw new SchemaValidationError(validation.reason);
49
- }
50
-
51
- await env.db.ref(path)
52
- .context(req.context)
53
- .set(val);
54
-
55
- res.send({ success: true });
56
- }
57
- catch(err) {
58
- if (err instanceof SchemaValidationError) {
59
- env.logRef?.push({ action: 'set_data', success: false, code: 'schema_validation_failed', path, error: err.reason, ip: req.ip, uid: req.user?.uid ?? null });
60
- res.status(422).send({ code: 'schema_validation_failed', message: err.message });
61
- }
62
- else if (err instanceof SetDataError) {
63
- env.logRef?.push({ action: 'set_data', success: false, code: err.code, path, ip: req.ip, uid: req.user?.uid ?? null });
64
- sendBadRequestError(res, err);
65
- }
66
- else {
67
- env.debug.error(`failed to set "${path}":`, err);
68
- env.logRef?.push({ action: 'set_data', success: false, code: 'unknown_error', path, error: err.message, ip: req.ip, uid: req.user?.uid ?? null });
69
- sendError(res, err);
70
- }
71
- };
72
- });
73
-
74
- };
75
-
76
- export default addRoute;
@@ -1,71 +0,0 @@
1
- /data/{dbname}/{path}:
2
- put:
3
- tags:
4
- - data
5
- summary: Sets the value of a path
6
- description: Sets the stored value of a path in the database, overwriting existing data and its children
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
- - name: AceBase-Context
23
- in: header
24
- description: Contextual info about the database operation (must be valid JSON). This info is included in event notifications sent to clients watching data at this or child paths
25
- schema:
26
- type: string
27
- example: {}
28
- requestBody:
29
- description: serialized value to store in the database
30
- content:
31
- 'application/json':
32
- schema:
33
- $ref: '#/components/schemas/SerializedValue'
34
- responses:
35
- 200:
36
- description: Returns "200 OK" when the database operation succeeded
37
- content:
38
- 'application/json':
39
- schema:
40
- type: object
41
- properties:
42
- success:
43
- type: boolean
44
- example: true
45
- 400:
46
- description: Returns "400 Bad Request" if the sent value is incorrect
47
- content:
48
- 'application/json':
49
- schema:
50
- $ref: '#/components/schemas/Error'
51
- example:
52
- code: invalid_serialized_value
53
- message: The sent value is not properly serialized
54
- 403:
55
- description: Returns "403 Forbidden" if the signed in user is not allowed to write to the target path
56
- content:
57
- 'application/json':
58
- schema:
59
- $ref: '#/components/schemas/Error'
60
- 422:
61
- description: Returns "422 Unprocessable Entity" if schema validation for the sent value failed.
62
- content:
63
- 'application/json':
64
- schema:
65
- $ref: '#/components/schemas/SchemaValidationError'
66
- 500:
67
- description: An unexpected error occurred
68
- content:
69
- 'application/json':
70
- schema:
71
- $ref: '#/components/schemas/UnexpectedError'
@@ -1,78 +0,0 @@
1
- import { ValueChange } from 'acebase-core/src/api';
2
- import { PathInfo, Transport } from 'acebase-core';
3
- import { RouteInitEnvironment, RouteRequest } from '../shared/env';
4
- import { sendBadRequestError, sendError, sendUnauthorizedError } from '../shared/error';
5
-
6
- export type RequestQuery = {
7
- path?: string;
8
- for?: Array<{ path: string, events: string[] }>;
9
- cursor?: string;
10
- timestamp?: string;
11
- };
12
- export type RequestBody = null;
13
- export type ResponseBody = ValueChange[] // 200
14
- | { code: 'no_transaction_logging', message: string } // 400
15
- | { code: 'invalid_request', message: string } // 400
16
- | { code: 'not_authorized', message: string } // 403
17
- | { code: 'unexpected', message: string }; // 500
18
-
19
- export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
20
-
21
- export const addRoute = (env: RouteInitEnvironment) => {
22
-
23
- env.app.get(`/sync/changes/${env.db.name}`, async (req: Request, res) => {
24
- // Gets effective changes for specific path(s) and event combinations since given cursor
25
- if (!env.config.transactions?.log) {
26
- return sendBadRequestError(res, { code: 'no_transaction_logging', message: 'Transaction logging not enabled' });
27
- }
28
- try {
29
- const data = req.query;
30
- let targets = typeof data.path === 'string'
31
- ? [{ path: data.path, events: ['value'] }]
32
- : typeof data.for === 'string'
33
- ? JSON.parse(data.for)
34
- : null;
35
- if (targets === null) {
36
- return sendBadRequestError(res, { code: 'invalid_request', message: 'Invalid changes request' });
37
- }
38
- if (targets.length === 0) {
39
- targets.push({ path: '', events: ['value'] });
40
- }
41
- // Filter out any requested paths user does not have access to.
42
- targets = targets.filter(target => {
43
- let path = target.path;
44
- if (target.events.every(event => /^(?:notify_)?child_/.test(event))) { //if (!target.events.some(event => ['value','notify_value','mutations','mutated'].includes(event))) {
45
- // Only child_ events, check if they have access to children instead
46
- path = PathInfo.get(path).childPath('*');
47
- }
48
- return env.rules.userHasAccess(req.user, path, false).allow;
49
- });
50
- if (targets.length === 0) {
51
- return sendUnauthorizedError(res, 'not_authorized', 'User is not authorized to access this data');
52
- }
53
-
54
- const { cursor } = data;
55
- let timestamp: number;
56
- if (typeof data.timestamp !== 'undefined') {
57
- timestamp = parseInt(data.timestamp);
58
- if (isNaN(timestamp)) {
59
- return sendBadRequestError(res, { code: 'wrong_timestamp', message: 'Timestamp is not a number' });
60
- }
61
- }
62
- const result = await env.db.api.getChanges({ for: targets, cursor, timestamp });
63
-
64
- res.setHeader('AceBase-Context', JSON.stringify({ acebase_cursor: result.new_cursor }));
65
- res.contentType('application/json');
66
-
67
- const serialized = Transport.serialize2(result.changes);
68
- res.send(serialized);
69
- }
70
- catch(err) {
71
- sendError(res, err);
72
- }
73
- });
74
-
75
-
76
- };
77
-
78
- export default addRoute;
@@ -1,67 +0,0 @@
1
- /sync/changes/{dbname}:
2
- get:
3
- tags:
4
- - data
5
- summary: Gets effective changes since cursor
6
- description: Gets effective changes for specific path(s) and event combinations since given cursor. Use either the _path_ or _for_ parameter. If both are given, only _path_ is used.
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: query
17
- description: "single database path to get all changes for (equivalent to _for_ `[{ path, events: ['value'] }]`)"
18
- schema:
19
- type: string
20
- example: collection
21
- - name: for
22
- in: query
23
- description: JSON array of path / events combinations
24
- schema:
25
- type: string
26
- example: "[{ path: 'collection', events: ['child_changed'] }]"
27
- - name: cursor
28
- in: query
29
- description: previously acquired cursor to use
30
- schema:
31
- type: string
32
- example: l2a37q55000008ll8dyngkny
33
- - name: timestamp
34
- in: query
35
- description: instead of a cursor, you can also use a timestamp (ms since 1970/01/01)
36
- schema:
37
- type: integer
38
- example: ""
39
- responses:
40
- 200:
41
- description: Returns an array of all effective changes to the requested selection
42
- content:
43
- 'application/json':
44
- schema:
45
- type: object
46
- example: []
47
- 400:
48
- description: Returns "400 Bad Request" if transaction logging is not enabled in the server settings (code `no_transaction_logging`) or if no targets were specified in your query (no _path_ or _for_ parameters given, code `invalid_request`)
49
- content:
50
- 'application/json':
51
- schema:
52
- $ref: '#/components/schemas/Error'
53
- example:
54
- code: no_transaction_logging
55
- message: Transaction logging not enabled
56
- 403:
57
- description: Returns a "403 Forbidden" if the signed in user is not allowed to read from any of the targeted paths
58
- content:
59
- 'application/json':
60
- schema:
61
- $ref: '#/components/schemas/Error'
62
- 500:
63
- description: An unexpected error occurred
64
- content:
65
- 'application/json':
66
- schema:
67
- $ref: '#/components/schemas/UnexpectedError'
@@ -1,78 +0,0 @@
1
- import { PathInfo, Transport } from 'acebase-core';
2
- import { ValueMutation } from 'acebase-core/src/api';
3
- import { RouteInitEnvironment, RouteRequest } from '../shared/env';
4
- import { sendBadRequestError, sendError, sendUnauthorizedError } from '../shared/error';
5
-
6
- export type RequestQuery = {
7
- path?: string;
8
- for?: Array<{ path: string, events: string[] }>;
9
- cursor?: string;
10
- timestamp?: string;
11
- };
12
- export type RequestBody = null;
13
- export type ResponseBody = ValueMutation[] // 200
14
- | { code: 'no_transaction_logging', message: string } // 400
15
- | { code: 'invalid_request', message: string } // 400
16
- | { code: 'not_authorized', message: string } // 403
17
- | { code: 'unexpected', message: string }; // 500
18
-
19
- export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
20
-
21
- export const addRoute = (env: RouteInitEnvironment) => {
22
-
23
- env.app.get(`/sync/mutations/${env.db.name}`, async (req: Request, res) => {
24
- // Gets mutations for specific path(s) and event combinations since given cursor
25
- if (!env.config.transactions?.log) {
26
- return sendBadRequestError(res, { code: 'no_transaction_logging', message: 'Transaction logging not enabled' });
27
- }
28
- try {
29
- const data = req.query;
30
- let targets = typeof data.path === 'string'
31
- ? [{ path: data.path, events: ['value'] }]
32
- : typeof data.for === 'string'
33
- ? JSON.parse(data.for)
34
- : null;
35
- if (targets === null) {
36
- return sendBadRequestError(res, { code: 'invalid_request', message: 'Invalid mutations request' });
37
- }
38
- if (targets.length === 0) {
39
- targets.push({ path: '', events: ['value'] });
40
- }
41
- // Filter out any requested paths user does not have access to.
42
- targets = targets.filter(target => {
43
- let path = target.path;
44
- if (target.events.every(event => /^(?:notify_)?child_/.test(event))) { //if (!target.events.some(event => ['value','notify_value','mutations','mutated'].includes(event))) {
45
- // Only child_ events, check if they have access to children instead
46
- path = PathInfo.get(path).childPath('*');
47
- }
48
- return env.rules.userHasAccess(req.user, path, false).allow;
49
- });
50
- if (targets.length === 0) {
51
- return sendUnauthorizedError(res, 'not_authorized', 'User is not authorized to access this data');
52
- }
53
-
54
- const { cursor } = data;
55
- let timestamp: number;
56
- if (typeof data.timestamp !== 'undefined') {
57
- timestamp = parseInt(data.timestamp);
58
- if (isNaN(timestamp)) {
59
- return sendBadRequestError(res, { code: 'wrong_timestamp', message: 'Timestamp is not a number' });
60
- }
61
- }
62
- const result = await env.db.api.getMutations({ for: targets, cursor, timestamp });
63
-
64
- res.setHeader('AceBase-Context', JSON.stringify({ acebase_cursor: result.new_cursor }));
65
- res.contentType('application/json');
66
-
67
- const serialized = Transport.serialize2(result.mutations);
68
- res.send(serialized);
69
- }
70
- catch(err) {
71
- sendError(res, err);
72
- }
73
- });
74
-
75
-
76
- };
77
-
78
- export default addRoute;