acebase-server 1.9.1 → 1.10.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.
- package/.vscode/launch.json +24 -0
- package/create-package-files +12 -0
- package/dist/cjs/auth.js +89 -0
- package/dist/cjs/auth.js.map +1 -0
- package/dist/cjs/cluster.js +57 -0
- package/dist/cjs/cluster.js.map +1 -0
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/middleware/404.js +15 -0
- package/dist/cjs/middleware/404.js.map +1 -0
- package/dist/cjs/middleware/cache.js +15 -0
- package/dist/cjs/middleware/cache.js.map +1 -0
- package/dist/cjs/middleware/connection.js +50 -0
- package/dist/cjs/middleware/connection.js.map +1 -0
- package/dist/cjs/middleware/context.js +21 -0
- package/dist/cjs/middleware/context.js.map +1 -0
- package/dist/cjs/middleware/cors.js +51 -0
- package/dist/cjs/middleware/cors.js.map +1 -0
- package/dist/cjs/middleware/swagger.js +18 -0
- package/dist/cjs/middleware/swagger.js.map +1 -0
- package/dist/cjs/middleware/user.js +58 -0
- package/dist/cjs/middleware/user.js.map +1 -0
- package/dist/cjs/oauth-providers/dropbox.js +109 -0
- package/dist/cjs/oauth-providers/dropbox.js.map +1 -0
- package/dist/cjs/oauth-providers/facebook.js +85 -0
- package/dist/cjs/oauth-providers/facebook.js.map +1 -0
- package/dist/cjs/oauth-providers/google.js +125 -0
- package/dist/cjs/oauth-providers/google.js.map +1 -0
- package/dist/cjs/oauth-providers/index.js +27 -0
- package/dist/cjs/oauth-providers/index.js.map +1 -0
- package/dist/cjs/oauth-providers/instagram.js +80 -0
- package/dist/cjs/oauth-providers/instagram.js.map +1 -0
- package/dist/cjs/oauth-providers/oauth-provider.js +3 -0
- package/dist/cjs/oauth-providers/oauth-provider.js.map +1 -0
- package/dist/cjs/oauth-providers/spotify.js +113 -0
- package/dist/cjs/oauth-providers/spotify.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/routes/auth-change-password.js +85 -0
- package/dist/cjs/routes/auth-change-password.js.map +1 -0
- package/dist/cjs/routes/auth-delete.js +51 -0
- package/dist/cjs/routes/auth-delete.js.map +1 -0
- package/dist/cjs/routes/auth-forgot-password.js +75 -0
- package/dist/cjs/routes/auth-forgot-password.js.map +1 -0
- package/dist/cjs/routes/auth-reset-password.js +94 -0
- package/dist/cjs/routes/auth-reset-password.js.map +1 -0
- package/dist/cjs/routes/auth-signin.js +47 -0
- package/dist/cjs/routes/auth-signin.js.map +1 -0
- package/dist/cjs/routes/auth-signout.js +60 -0
- package/dist/cjs/routes/auth-signout.js.map +1 -0
- package/dist/cjs/routes/auth-signup.js +141 -0
- package/dist/cjs/routes/auth-signup.js.map +1 -0
- package/dist/cjs/routes/auth-state.js +26 -0
- package/dist/cjs/routes/auth-state.js.map +1 -0
- package/dist/cjs/routes/auth-update.js +129 -0
- package/dist/cjs/routes/auth-update.js.map +1 -0
- package/dist/cjs/routes/auth-verify-email.js +67 -0
- package/dist/cjs/routes/auth-verify-email.js.map +1 -0
- package/dist/cjs/routes/auth.js +55 -0
- package/dist/cjs/routes/auth.js.map +1 -0
- package/dist/cjs/routes/data-exists.js +34 -0
- package/dist/cjs/routes/data-exists.js.map +1 -0
- package/dist/cjs/routes/data-export.js +49 -0
- package/dist/cjs/routes/data-export.js.map +1 -0
- package/dist/cjs/routes/data-get.js +67 -0
- package/dist/cjs/routes/data-get.js.map +1 -0
- package/dist/cjs/routes/data-import.js +55 -0
- package/dist/cjs/routes/data-import.js.map +1 -0
- package/dist/cjs/routes/data-index-create.js +45 -0
- package/dist/cjs/routes/data-index-create.js.map +1 -0
- package/dist/cjs/routes/data-index-delete.js +36 -0
- package/dist/cjs/routes/data-index-delete.js.map +1 -0
- package/dist/cjs/routes/data-index-list.js +35 -0
- package/dist/cjs/routes/data-index-list.js.map +1 -0
- package/dist/cjs/routes/data-query.js +71 -0
- package/dist/cjs/routes/data-query.js.map +1 -0
- package/dist/cjs/routes/data-reflect.js +89 -0
- package/dist/cjs/routes/data-reflect.js.map +1 -0
- package/dist/cjs/routes/data-schema-get.js +39 -0
- package/dist/cjs/routes/data-schema-get.js.map +1 -0
- package/dist/cjs/routes/data-schema-set.js +33 -0
- package/dist/cjs/routes/data-schema-set.js.map +1 -0
- package/dist/cjs/routes/data-schema-test.js +46 -0
- package/dist/cjs/routes/data-schema-test.js.map +1 -0
- package/dist/cjs/routes/data-schemas-list.js +35 -0
- package/dist/cjs/routes/data-schemas-list.js.map +1 -0
- package/dist/cjs/routes/data-set.js +72 -0
- package/dist/cjs/routes/data-set.js.map +1 -0
- package/dist/cjs/routes/data-sync-changes.js +68 -0
- package/dist/cjs/routes/data-sync-changes.js.map +1 -0
- package/dist/cjs/routes/data-sync-mutations.js +68 -0
- package/dist/cjs/routes/data-sync-mutations.js.map +1 -0
- package/dist/cjs/routes/data-transaction.js +120 -0
- package/dist/cjs/routes/data-transaction.js.map +1 -0
- package/dist/cjs/routes/data-update.js +71 -0
- package/dist/cjs/routes/data-update.js.map +1 -0
- package/dist/cjs/routes/data.js +63 -0
- package/dist/cjs/routes/data.js.map +1 -0
- package/dist/cjs/routes/docs.js +249 -0
- package/dist/cjs/routes/docs.js.map +1 -0
- package/dist/cjs/routes/meta-info.js +70 -0
- package/dist/cjs/routes/meta-info.js.map +1 -0
- package/dist/cjs/routes/meta-ping.js +12 -0
- package/dist/cjs/routes/meta-ping.js.map +1 -0
- package/dist/cjs/routes/meta-stats.js +28 -0
- package/dist/cjs/routes/meta-stats.js.map +1 -0
- package/dist/cjs/routes/meta.js +17 -0
- package/dist/cjs/routes/meta.js.map +1 -0
- package/dist/cjs/routes/oauth2-init.js +52 -0
- package/dist/cjs/routes/oauth2-init.js.map +1 -0
- package/dist/cjs/routes/oauth2-refresh.js +43 -0
- package/dist/cjs/routes/oauth2-refresh.js.map +1 -0
- package/dist/cjs/routes/oauth2-signin.js +262 -0
- package/dist/cjs/routes/oauth2-signin.js.map +1 -0
- package/dist/cjs/routes/webmanager.js +27 -0
- package/dist/cjs/routes/webmanager.js.map +1 -0
- package/dist/cjs/rules.js +175 -0
- package/dist/cjs/rules.js.map +1 -0
- package/dist/cjs/schema/user.js +26 -0
- package/dist/cjs/schema/user.js.map +1 -0
- package/dist/cjs/server.js +363 -0
- package/dist/cjs/server.js.map +1 -0
- package/dist/cjs/settings/email.js +5 -0
- package/dist/cjs/settings/email.js.map +1 -0
- package/dist/cjs/settings/index.js +159 -0
- package/dist/cjs/settings/index.js.map +1 -0
- package/dist/cjs/shared/clients.js +27 -0
- package/dist/cjs/shared/clients.js.map +1 -0
- package/dist/cjs/shared/email.js +7 -0
- package/dist/cjs/shared/email.js.map +1 -0
- package/{src/oauth-providers/oauth-provider.js → dist/cjs/shared/env.js} +3 -0
- package/dist/cjs/shared/env.js.map +1 -0
- package/dist/cjs/shared/error.js +35 -0
- package/dist/cjs/shared/error.js.map +1 -0
- package/dist/cjs/shared/http.js +21 -0
- package/dist/cjs/shared/http.js.map +1 -0
- package/dist/cjs/shared/password.js +46 -0
- package/dist/cjs/shared/password.js.map +1 -0
- package/dist/cjs/shared/rootpath.js +15 -0
- package/dist/cjs/shared/rootpath.js.map +1 -0
- package/dist/cjs/shared/signin.js +139 -0
- package/dist/cjs/shared/signin.js.map +1 -0
- package/dist/cjs/shared/simple-fetch.js +77 -0
- package/dist/cjs/shared/simple-fetch.js.map +1 -0
- package/dist/cjs/shared/tokens.js +79 -0
- package/dist/cjs/shared/tokens.js.map +1 -0
- package/dist/cjs/shared/validate.js +62 -0
- package/dist/cjs/shared/validate.js.map +1 -0
- package/dist/cjs/start.js +51 -0
- package/dist/cjs/start.js.map +1 -0
- package/dist/cjs/test.js +11 -0
- package/dist/cjs/test.js.map +1 -0
- package/dist/cjs/websocket/index.js +301 -0
- package/dist/cjs/websocket/index.js.map +1 -0
- package/dist/cjs/websocket/manager.js +16 -0
- package/dist/cjs/websocket/manager.js.map +1 -0
- package/dist/cjs/websocket/socket.io.js +79 -0
- package/dist/cjs/websocket/socket.io.js.map +1 -0
- package/dist/esm/auth.js +76 -0
- package/dist/esm/auth.js.map +1 -0
- package/{src → dist/esm}/cluster.js +9 -14
- package/dist/esm/cluster.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/middleware/404.js +11 -0
- package/dist/esm/middleware/404.js.map +1 -0
- package/dist/esm/middleware/cache.js +11 -0
- package/dist/esm/middleware/cache.js.map +1 -0
- package/dist/esm/middleware/connection.js +46 -0
- package/dist/esm/middleware/connection.js.map +1 -0
- package/dist/esm/middleware/context.js +17 -0
- package/dist/esm/middleware/context.js.map +1 -0
- package/dist/esm/middleware/cors.js +45 -0
- package/dist/esm/middleware/cors.js.map +1 -0
- package/dist/esm/middleware/swagger.js +14 -0
- package/dist/esm/middleware/swagger.js.map +1 -0
- package/dist/esm/middleware/user.js +45 -0
- package/dist/esm/middleware/user.js.map +1 -0
- package/{src → dist/esm}/oauth-providers/dropbox.js +11 -9
- package/dist/esm/oauth-providers/dropbox.js.map +1 -0
- package/{src → dist/esm}/oauth-providers/facebook.js +6 -9
- package/dist/esm/oauth-providers/facebook.js.map +1 -0
- package/{src → dist/esm}/oauth-providers/google.js +8 -11
- package/dist/esm/oauth-providers/google.js.map +1 -0
- package/dist/esm/oauth-providers/index.js +19 -0
- package/dist/esm/oauth-providers/index.js.map +1 -0
- package/{src → dist/esm}/oauth-providers/instagram.js +6 -9
- package/dist/esm/oauth-providers/instagram.js.map +1 -0
- package/dist/esm/oauth-providers/oauth-provider.js +2 -0
- package/dist/esm/oauth-providers/oauth-provider.js.map +1 -0
- package/{src → dist/esm}/oauth-providers/spotify.js +7 -10
- package/dist/esm/oauth-providers/spotify.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/routes/auth-change-password.js +70 -0
- package/dist/esm/routes/auth-change-password.js.map +1 -0
- package/dist/esm/routes/auth-delete.js +36 -0
- package/dist/esm/routes/auth-delete.js.map +1 -0
- package/dist/esm/routes/auth-forgot-password.js +61 -0
- package/dist/esm/routes/auth-forgot-password.js.map +1 -0
- package/dist/esm/routes/auth-reset-password.js +78 -0
- package/dist/esm/routes/auth-reset-password.js.map +1 -0
- package/dist/esm/routes/auth-signin.js +34 -0
- package/dist/esm/routes/auth-signin.js.map +1 -0
- package/dist/esm/routes/auth-signout.js +46 -0
- package/dist/esm/routes/auth-signout.js.map +1 -0
- package/dist/esm/routes/auth-signup.js +126 -0
- package/dist/esm/routes/auth-signup.js.map +1 -0
- package/dist/esm/routes/auth-state.js +13 -0
- package/dist/esm/routes/auth-state.js.map +1 -0
- package/dist/esm/routes/auth-update.js +115 -0
- package/dist/esm/routes/auth-update.js.map +1 -0
- package/dist/esm/routes/auth-verify-email.js +52 -0
- package/dist/esm/routes/auth-verify-email.js.map +1 -0
- package/dist/esm/routes/auth.js +51 -0
- package/dist/esm/routes/auth.js.map +1 -0
- package/dist/esm/routes/data-exists.js +21 -0
- package/dist/esm/routes/data-exists.js.map +1 -0
- package/dist/esm/routes/data-export.js +36 -0
- package/dist/esm/routes/data-export.js.map +1 -0
- package/dist/esm/routes/data-get.js +53 -0
- package/dist/esm/routes/data-get.js.map +1 -0
- package/dist/esm/routes/data-import.js +42 -0
- package/dist/esm/routes/data-import.js.map +1 -0
- package/dist/esm/routes/data-index-create.js +31 -0
- package/dist/esm/routes/data-index-create.js.map +1 -0
- package/dist/esm/routes/data-index-delete.js +23 -0
- package/dist/esm/routes/data-index-delete.js.map +1 -0
- package/dist/esm/routes/data-index-list.js +22 -0
- package/dist/esm/routes/data-index-list.js.map +1 -0
- package/dist/esm/routes/data-query.js +57 -0
- package/dist/esm/routes/data-query.js.map +1 -0
- package/dist/esm/routes/data-reflect.js +76 -0
- package/dist/esm/routes/data-reflect.js.map +1 -0
- package/dist/esm/routes/data-schema-get.js +26 -0
- package/dist/esm/routes/data-schema-get.js.map +1 -0
- package/dist/esm/routes/data-schema-set.js +20 -0
- package/dist/esm/routes/data-schema-set.js.map +1 -0
- package/dist/esm/routes/data-schema-test.js +32 -0
- package/dist/esm/routes/data-schema-test.js.map +1 -0
- package/dist/esm/routes/data-schemas-list.js +22 -0
- package/dist/esm/routes/data-schemas-list.js.map +1 -0
- package/dist/esm/routes/data-set.js +57 -0
- package/dist/esm/routes/data-set.js.map +1 -0
- package/dist/esm/routes/data-sync-changes.js +54 -0
- package/dist/esm/routes/data-sync-changes.js.map +1 -0
- package/dist/esm/routes/data-sync-mutations.js +54 -0
- package/dist/esm/routes/data-sync-mutations.js.map +1 -0
- package/dist/esm/routes/data-transaction.js +104 -0
- package/dist/esm/routes/data-transaction.js.map +1 -0
- package/dist/esm/routes/data-update.js +56 -0
- package/dist/esm/routes/data-update.js.map +1 -0
- package/dist/esm/routes/data.js +59 -0
- package/dist/esm/routes/data.js.map +1 -0
- package/dist/esm/routes/docs.js +244 -0
- package/dist/esm/routes/docs.js.map +1 -0
- package/dist/esm/routes/meta-info.js +66 -0
- package/dist/esm/routes/meta-info.js.map +1 -0
- package/dist/esm/routes/meta-ping.js +8 -0
- package/dist/esm/routes/meta-ping.js.map +1 -0
- package/dist/esm/routes/meta-stats.js +15 -0
- package/dist/esm/routes/meta-stats.js.map +1 -0
- package/dist/esm/routes/meta.js +13 -0
- package/dist/esm/routes/meta.js.map +1 -0
- package/dist/esm/routes/oauth2-init.js +39 -0
- package/dist/esm/routes/oauth2-init.js.map +1 -0
- package/dist/esm/routes/oauth2-refresh.js +30 -0
- package/dist/esm/routes/oauth2-refresh.js.map +1 -0
- package/dist/esm/routes/oauth2-signin.js +248 -0
- package/dist/esm/routes/oauth2-signin.js.map +1 -0
- package/dist/esm/routes/webmanager.js +23 -0
- package/dist/esm/routes/webmanager.js.map +1 -0
- package/dist/esm/rules.js +171 -0
- package/dist/esm/rules.js.map +1 -0
- package/dist/esm/schema/user.js +21 -0
- package/dist/esm/schema/user.js.map +1 -0
- package/dist/esm/server.js +344 -0
- package/dist/esm/server.js.map +1 -0
- package/dist/esm/settings/email.js +4 -0
- package/dist/esm/settings/email.js.map +1 -0
- package/dist/esm/settings/index.js +152 -0
- package/dist/esm/settings/index.js.map +1 -0
- package/dist/esm/shared/clients.js +23 -0
- package/dist/esm/shared/clients.js.map +1 -0
- package/dist/esm/shared/email.js +6 -0
- package/dist/esm/shared/email.js.map +1 -0
- package/dist/esm/shared/env.js +4 -0
- package/dist/esm/shared/env.js.map +1 -0
- package/dist/esm/shared/error.js +27 -0
- package/dist/esm/shared/error.js.map +1 -0
- package/dist/esm/shared/http.js +16 -0
- package/dist/esm/shared/http.js.map +1 -0
- package/dist/esm/shared/password.js +39 -0
- package/dist/esm/shared/password.js.map +1 -0
- package/dist/esm/shared/rootpath.js +12 -0
- package/dist/esm/shared/rootpath.js.map +1 -0
- package/dist/esm/shared/signin.js +125 -0
- package/dist/esm/shared/signin.js.map +1 -0
- package/{src/oauth-providers → dist/esm/shared}/simple-fetch.js +7 -10
- package/dist/esm/shared/simple-fetch.js.map +1 -0
- package/dist/esm/shared/tokens.js +72 -0
- package/dist/esm/shared/tokens.js.map +1 -0
- package/dist/esm/shared/validate.js +42 -0
- package/dist/esm/shared/validate.js.map +1 -0
- package/dist/esm/start.js +48 -0
- package/dist/esm/start.js.map +1 -0
- package/dist/esm/test.js +9 -0
- package/dist/esm/test.js.map +1 -0
- package/dist/esm/websocket/index.js +288 -0
- package/dist/esm/websocket/index.js.map +1 -0
- package/dist/esm/websocket/manager.js +12 -0
- package/dist/esm/websocket/manager.js.map +1 -0
- package/dist/esm/websocket/socket.io.js +73 -0
- package/dist/esm/websocket/socket.io.js.map +1 -0
- package/dist/types/auth.d.ts +3 -0
- package/dist/types/cluster.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/middleware/404.d.ts +7 -0
- package/dist/types/middleware/cache.d.ts +3 -0
- package/dist/types/middleware/connection.d.ts +7 -0
- package/dist/types/middleware/context.d.ts +3 -0
- package/dist/types/middleware/cors.d.ts +25 -0
- package/dist/types/middleware/swagger.d.ts +3 -0
- package/dist/types/middleware/user.d.ts +2 -0
- package/dist/types/oauth-providers/dropbox.d.ts +63 -0
- package/dist/types/oauth-providers/facebook.d.ts +45 -0
- package/dist/types/oauth-providers/google.d.ts +47 -0
- package/dist/types/oauth-providers/index.d.ts +18 -0
- package/dist/types/oauth-providers/instagram.d.ts +54 -0
- package/dist/types/oauth-providers/oauth-provider.d.ts +70 -0
- package/dist/types/oauth-providers/spotify.d.ts +57 -0
- package/dist/types/routes/auth-change-password.d.ts +20 -0
- package/dist/types/routes/auth-delete.d.ts +16 -0
- package/dist/types/routes/auth-forgot-password.d.ts +16 -0
- package/dist/types/routes/auth-reset-password.d.ts +23 -0
- package/dist/types/routes/auth-signin.d.ts +24 -0
- package/dist/types/routes/auth-signout.d.ts +14 -0
- package/dist/types/routes/auth-signup.d.ts +32 -0
- package/dist/types/routes/auth-state.d.ts +13 -0
- package/dist/types/routes/auth-update.d.ts +33 -0
- package/dist/types/routes/auth-verify-email.d.ts +21 -0
- package/dist/types/routes/auth.d.ts +6 -0
- package/dist/types/routes/data-exists.d.ts +9 -0
- package/dist/types/routes/data-export.d.ts +10 -0
- package/dist/types/routes/data-get.d.ts +14 -0
- package/dist/types/routes/data-import.d.ts +13 -0
- package/dist/types/routes/data-index-create.d.ts +51 -0
- package/dist/types/routes/data-index-delete.d.ts +17 -0
- package/dist/types/routes/data-index-list.d.ts +21 -0
- package/dist/types/routes/data-query.d.ts +49 -0
- package/dist/types/routes/data-reflect.d.ts +29 -0
- package/dist/types/routes/data-schema-get.d.ts +11 -0
- package/dist/types/routes/data-schema-set.d.ts +19 -0
- package/dist/types/routes/data-schema-test.d.ts +21 -0
- package/dist/types/routes/data-schemas-list.d.ts +11 -0
- package/dist/types/routes/data-set.d.ts +27 -0
- package/dist/types/routes/data-sync-changes.d.ts +28 -0
- package/dist/types/routes/data-sync-mutations.d.ts +28 -0
- package/dist/types/routes/data-transaction.d.ts +34 -0
- package/dist/types/routes/data-update.d.ts +27 -0
- package/dist/types/routes/data.d.ts +3 -0
- package/dist/types/routes/docs.d.ts +3 -0
- package/dist/types/routes/meta-info.d.ts +11 -0
- package/dist/types/routes/meta-ping.d.ts +7 -0
- package/dist/types/routes/meta-stats.d.ts +13 -0
- package/dist/types/routes/meta.d.ts +3 -0
- package/dist/types/routes/oauth2-init.d.ts +13 -0
- package/dist/types/routes/oauth2-refresh.d.ts +17 -0
- package/dist/types/routes/oauth2-signin.d.ts +15 -0
- package/dist/types/routes/webmanager.d.ts +3 -0
- package/dist/types/rules.d.ts +41 -0
- package/dist/types/schema/user.d.ts +85 -0
- package/dist/types/server.d.ts +106 -0
- package/dist/types/settings/email.d.ts +14 -0
- package/dist/types/settings/index.d.ts +165 -0
- package/dist/types/shared/clients.d.ts +44 -0
- package/dist/types/shared/email.d.ts +34 -0
- package/dist/types/shared/env.d.ts +42 -0
- package/dist/types/shared/error.d.ts +15 -0
- package/dist/types/shared/http.d.ts +14 -0
- package/dist/types/shared/password.d.ts +19 -0
- package/dist/types/shared/rootpath.d.ts +2 -0
- package/dist/types/shared/signin.d.ts +31 -0
- package/dist/types/shared/simple-fetch.d.ts +21 -0
- package/dist/types/shared/tokens.d.ts +23 -0
- package/dist/types/shared/validate.d.ts +22 -0
- package/dist/types/start.d.ts +1 -0
- package/dist/types/test.d.ts +1 -0
- package/dist/types/websocket/index.d.ts +2 -0
- package/dist/types/websocket/manager.d.ts +99 -0
- package/dist/types/websocket/socket.io.d.ts +10 -0
- package/package.json +23 -8
- package/src/auth.ts +87 -0
- package/src/cluster.ts +62 -0
- package/src/index.ts +2 -0
- package/src/middleware/404.ts +13 -0
- package/src/middleware/cache.ts +15 -0
- package/src/middleware/connection.ts +48 -0
- package/src/middleware/context.ts +23 -0
- package/src/middleware/cors.ts +49 -0
- package/src/middleware/swagger.ts +19 -0
- package/src/middleware/user.ts +51 -0
- package/src/{ts/oauth-providers → oauth-providers}/dropbox.ts +1 -1
- package/src/{ts/oauth-providers → oauth-providers}/facebook.ts +1 -1
- package/src/{ts/oauth-providers → oauth-providers}/google.ts +1 -1
- package/src/oauth-providers/index.ts +20 -0
- package/src/{ts/oauth-providers → oauth-providers}/instagram.ts +1 -1
- package/src/{ts/oauth-providers → oauth-providers}/oauth-provider.ts +0 -0
- package/src/{ts/oauth-providers → oauth-providers}/spotify.ts +1 -1
- package/src/routes/auth-change-password.ts +89 -0
- package/src/{ts/routes → routes}/auth-change-password.yaml +0 -2
- package/src/routes/auth-delete.ts +47 -0
- package/src/{ts/routes → routes}/auth-delete.yaml +0 -0
- package/src/routes/auth-forgot-password.ts +73 -0
- package/src/{ts/routes → routes}/auth-forgot-password.yaml +0 -0
- package/src/routes/auth-reset-password.ts +93 -0
- package/src/{ts/routes → routes}/auth-reset-password.yaml +0 -0
- package/src/routes/auth-signin.ts +55 -0
- package/src/{ts/routes → routes}/auth-signin.yaml +5 -5
- package/src/routes/auth-signout.ts +61 -0
- package/src/{ts/routes → routes}/auth-signout.yaml +0 -0
- package/src/routes/auth-signup.ts +161 -0
- package/src/{ts/routes → routes}/auth-signup.yaml +15 -0
- package/src/routes/auth-state.ts +20 -0
- package/src/{ts/routes → routes}/auth-state.yaml +0 -0
- package/src/routes/auth-update.ts +147 -0
- package/src/{ts/routes → routes}/auth-update.yaml +22 -2
- package/src/routes/auth-verify-email.ts +67 -0
- package/src/{ts/routes → routes}/auth-verify-email.yaml +0 -0
- package/src/routes/auth.ts +67 -0
- package/src/routes/data-exists.ts +31 -0
- package/src/routes/data-exists.yaml +44 -0
- package/src/routes/data-export.ts +51 -0
- package/src/routes/data-export.yaml +64 -0
- package/src/routes/data-get.ts +68 -0
- package/src/routes/data-get.yaml +54 -0
- package/src/routes/data-import.ts +56 -0
- package/src/routes/data-import.yaml +75 -0
- package/src/routes/data-index-create.ts +85 -0
- package/src/routes/data-index-create.yaml +105 -0
- package/src/routes/data-index-delete.ts +39 -0
- package/src/routes/data-index-delete.yaml +51 -0
- package/src/routes/data-index-list.ts +42 -0
- package/src/routes/data-index-list.yaml +80 -0
- package/src/routes/data-query.ts +97 -0
- package/src/routes/data-query.yaml +166 -0
- package/src/routes/data-reflect.ts +94 -0
- package/src/routes/data-reflect.yaml +124 -0
- package/src/routes/data-schema-get.ts +38 -0
- package/src/routes/data-schema-get.yaml +53 -0
- package/src/routes/data-schema-set.ts +38 -0
- package/src/routes/data-schema-set.yaml +60 -0
- package/src/routes/data-schema-test.ts +53 -0
- package/src/routes/data-schema-test.yaml +66 -0
- package/src/routes/data-schemas-list.ts +33 -0
- package/src/routes/data-schemas-list.yaml +41 -0
- package/src/routes/data-set.ts +76 -0
- package/src/routes/data-set.yaml +71 -0
- package/src/routes/data-sync-changes.ts +78 -0
- package/src/routes/data-sync-changes.yaml +67 -0
- package/src/routes/data-sync-mutations.ts +78 -0
- package/src/routes/data-sync-mutations.yaml +67 -0
- package/src/routes/data-transaction-finish.yaml +76 -0
- package/src/routes/data-transaction-start.yaml +58 -0
- package/src/routes/data-transaction.ts +144 -0
- package/src/routes/data-update.ts +77 -0
- package/src/routes/data-update.yaml +71 -0
- package/src/routes/data.ts +79 -0
- package/src/routes/docs.ts +249 -0
- package/src/routes/meta-info.ts +80 -0
- package/src/routes/meta-info.yaml +41 -0
- package/src/routes/meta-ping.ts +15 -0
- package/src/routes/meta-ping.yaml +23 -0
- package/src/routes/meta-stats.ts +31 -0
- package/src/routes/meta-stats.yaml +41 -0
- package/src/routes/meta.ts +18 -0
- package/src/routes/oauth2-init.ts +44 -0
- package/src/{ts/routes → routes}/oauth2-init.yaml +0 -0
- package/src/routes/oauth2-refresh.ts +39 -0
- package/src/{ts/routes → routes}/oauth2-refresh.yaml +0 -0
- package/src/routes/oauth2-signin.ts +281 -0
- package/src/{ts/routes → routes}/oauth2-signin.yaml +0 -0
- package/src/routes/webmanager.ts +29 -0
- package/src/rules.ts +196 -0
- package/src/schema/user.ts +99 -0
- package/src/server.ts +416 -0
- package/src/settings/email.ts +18 -0
- package/src/settings/index.ts +241 -0
- package/src/shared/clients.ts +31 -0
- package/src/shared/email.ts +33 -0
- package/src/shared/env.ts +38 -0
- package/src/shared/error.ts +37 -0
- package/src/shared/http.ts +24 -0
- package/src/shared/password.ts +41 -0
- package/src/shared/rootpath.ts +15 -0
- package/src/shared/signin.ts +143 -0
- package/src/{ts/oauth-providers → shared}/simple-fetch.ts +2 -2
- package/src/shared/tokens.ts +77 -0
- package/src/shared/validate.ts +53 -0
- package/src/{start.js → start.ts} +7 -5
- package/src/test.ts +10 -0
- package/src/websocket/index.ts +320 -0
- package/src/websocket/manager.ts +46 -0
- package/src/websocket/socket.io.ts +91 -0
- package/tsconfig-cjs.json +10 -0
- package/tsconfig.json +13 -5
- package/{src/webmanager → webmanager}/index.html +0 -0
- package/{src/webmanager → webmanager}/index.js +0 -0
- package/src/acebase-server.js +0 -3060
- package/src/index.d.ts +0 -212
- package/src/index.js +0 -2
- package/src/routes/docs.js +0 -97
- package/src/ts/routes/docs.ts +0 -100
|
@@ -0,0 +1,66 @@
|
|
|
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'
|
|
@@ -0,0 +1,33 @@
|
|
|
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;
|
|
@@ -0,0 +1,41 @@
|
|
|
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'
|
|
@@ -0,0 +1,76 @@
|
|
|
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;
|
|
@@ -0,0 +1,71 @@
|
|
|
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'
|
|
@@ -0,0 +1,78 @@
|
|
|
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;
|
|
@@ -0,0 +1,67 @@
|
|
|
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'
|
|
@@ -0,0 +1,78 @@
|
|
|
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;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/sync/mutations/{dbname}:
|
|
2
|
+
get:
|
|
3
|
+
tags:
|
|
4
|
+
- data
|
|
5
|
+
summary: Gets mutations since cursor
|
|
6
|
+
description: Gets all mutations 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 mutations 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'
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/transaction/{dbname}/finish:
|
|
2
|
+
post:
|
|
3
|
+
tags:
|
|
4
|
+
- data
|
|
5
|
+
summary: Finishes a transaction on a path
|
|
6
|
+
description: Finishes a transaction on a path in the database by overwriting it with a new value. NOTE this API endpoint is also available through the websocket connection, which is the preferred method. This API endpoint is provided for clients not supporting websockets, and those that don't have a websocket connection by choice or because of network limitations.
|
|
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
|
+
requestBody:
|
|
16
|
+
description: transaction details and the new value to store
|
|
17
|
+
content:
|
|
18
|
+
'application/json':
|
|
19
|
+
schema:
|
|
20
|
+
type: object
|
|
21
|
+
properties:
|
|
22
|
+
id:
|
|
23
|
+
type: string
|
|
24
|
+
description: transaction id returned by the _start_ endpoint
|
|
25
|
+
example: jld2cjxh0000qzrmn831i7rn
|
|
26
|
+
path:
|
|
27
|
+
type: string
|
|
28
|
+
description: the same path used in the _start_ endpoint call
|
|
29
|
+
example: collection/child/property
|
|
30
|
+
value:
|
|
31
|
+
$ref: '#/components/schemas/SerializedValue'
|
|
32
|
+
responses:
|
|
33
|
+
200:
|
|
34
|
+
description: If successful returns the string `"done"`
|
|
35
|
+
content:
|
|
36
|
+
'text/plain':
|
|
37
|
+
schema:
|
|
38
|
+
type: string
|
|
39
|
+
value: done
|
|
40
|
+
example: done
|
|
41
|
+
description: the string `"done"`
|
|
42
|
+
400:
|
|
43
|
+
description: Returns "400 Bad Request" if the sent value is incorrect
|
|
44
|
+
content:
|
|
45
|
+
'application/json':
|
|
46
|
+
schema:
|
|
47
|
+
$ref: '#/components/schemas/Error'
|
|
48
|
+
example:
|
|
49
|
+
code: invalid_serialized_value
|
|
50
|
+
message: The sent value is not properly serialized
|
|
51
|
+
403:
|
|
52
|
+
description: Returns "403 Forbidden" if the signed in user is not allowed to write to the target path
|
|
53
|
+
content:
|
|
54
|
+
'application/json':
|
|
55
|
+
schema:
|
|
56
|
+
$ref: '#/components/schemas/Error'
|
|
57
|
+
410:
|
|
58
|
+
description: Returns "410 Gone" if the specified transaction was not found, timed out, or the path does not match with the one provided in the _start_ endpoint.
|
|
59
|
+
content:
|
|
60
|
+
'text/plain':
|
|
61
|
+
schema:
|
|
62
|
+
type: string
|
|
63
|
+
value: transaction not found
|
|
64
|
+
example: transaction not found
|
|
65
|
+
422:
|
|
66
|
+
description: Returns "422 Unprocessable Entity" if schema validation for the sent value failed.
|
|
67
|
+
content:
|
|
68
|
+
'application/json':
|
|
69
|
+
schema:
|
|
70
|
+
$ref: '#/components/schemas/SchemaValidationError'
|
|
71
|
+
500:
|
|
72
|
+
description: An unexpected error occurred
|
|
73
|
+
content:
|
|
74
|
+
'application/json':
|
|
75
|
+
schema:
|
|
76
|
+
$ref: '#/components/schemas/UnexpectedError'
|