acebase-server 1.8.0 → 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 +25 -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/routes/auth-change-password.yaml +74 -0
- package/src/routes/auth-delete.ts +47 -0
- package/src/routes/auth-delete.yaml +78 -0
- package/src/routes/auth-forgot-password.ts +73 -0
- package/src/routes/auth-forgot-password.yaml +50 -0
- package/src/routes/auth-reset-password.ts +93 -0
- package/src/routes/auth-reset-password.yaml +54 -0
- package/src/routes/auth-signin.ts +55 -0
- package/src/routes/auth-signin.yaml +130 -0
- package/src/routes/auth-signout.ts +61 -0
- package/src/routes/auth-signout.yaml +46 -0
- package/src/routes/auth-signup.ts +161 -0
- package/src/routes/auth-signup.yaml +136 -0
- package/src/routes/auth-state.ts +20 -0
- package/src/routes/auth-state.yaml +29 -0
- package/src/routes/auth-update.ts +147 -0
- package/src/routes/auth-update.yaml +152 -0
- package/src/routes/auth-verify-email.ts +67 -0
- package/src/routes/auth-verify-email.yaml +53 -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/routes/oauth2-init.yaml +63 -0
- package/src/routes/oauth2-refresh.ts +39 -0
- package/src/routes/oauth2-refresh.yaml +65 -0
- package/src/routes/oauth2-signin.ts +281 -0
- package/src/routes/oauth2-signin.yaml +66 -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 -3053
- package/src/index.d.ts +0 -212
- package/src/index.js +0 -2
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { RouteInitEnvironment, RouteRequest } from '../shared/env';
|
|
2
|
+
import { sendError, sendUnauthorizedError } from '../shared/error';
|
|
3
|
+
import { Response } from '../shared/http';
|
|
4
|
+
|
|
5
|
+
export type FullTextIndexOptions = {
|
|
6
|
+
type: 'fulltext';
|
|
7
|
+
config?: {
|
|
8
|
+
/** Callback function that transforms (and/or filters) words being indexed _and_ queried */
|
|
9
|
+
transform?: (locale: string, word: string) => string;
|
|
10
|
+
/** Also known as a stoplist. Array of words to automatically be ignored for indexing and querying. */
|
|
11
|
+
blacklist?: string[];
|
|
12
|
+
/** Words to be included if they did not match minLength and/or blacklist criteria */
|
|
13
|
+
whitelist?: string[];
|
|
14
|
+
/** Only use words with a minimum length */
|
|
15
|
+
minLength?: number;
|
|
16
|
+
/** Only use words with a maximum length */
|
|
17
|
+
maxLength?: number;
|
|
18
|
+
/** Specify a key in the data that contains the locale of the indexed texts. This allows multiple languages to be indexed using their own rules. */
|
|
19
|
+
localeKey?: string;
|
|
20
|
+
/** Boolean value that specifies whether a default stoplist for the used locale should be used to automatically blacklist words. Currently only available for locale "en", which contains very frequently used words like "a", "i", "me", "it", "the", "they", "them" etc. */
|
|
21
|
+
useStoplist?: boolean;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export type GeoIndexOptions = {
|
|
25
|
+
type: 'geo';
|
|
26
|
+
};
|
|
27
|
+
export type ArrayIndexOptions = {
|
|
28
|
+
type: 'array';
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type CreateIndexRequest = {
|
|
32
|
+
path: string;
|
|
33
|
+
key: string;
|
|
34
|
+
options?: {
|
|
35
|
+
type?: 'normal'|'array'|'fulltext'|'geo';
|
|
36
|
+
rebuild?: boolean;
|
|
37
|
+
textLocale?: string;
|
|
38
|
+
include?: string[];
|
|
39
|
+
config?: {}
|
|
40
|
+
} & ({} | FullTextIndexOptions | GeoIndexOptions | ArrayIndexOptions);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type RequestQuery = null;
|
|
44
|
+
export type RequestBody = CreateIndexRequest;
|
|
45
|
+
export type ResponseBody = { success: true } // 200
|
|
46
|
+
| { code: 'admin_only'; message: string } // 403
|
|
47
|
+
| { code: 'unexpected'; message: string }; // 500 (TODO check if 400 is also possible)
|
|
48
|
+
|
|
49
|
+
export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
|
|
50
|
+
|
|
51
|
+
export const addRoute = (env: RouteInitEnvironment) => {
|
|
52
|
+
|
|
53
|
+
const handleRequest = async (req: Request, res: Response) => {
|
|
54
|
+
if (!req.user || req.user.username !== 'admin') {
|
|
55
|
+
return sendUnauthorizedError(res, 'admin_only', 'only admin can perform index operations');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const data = req.body;
|
|
60
|
+
await env.db.indexes.create(data.path, data.key, data.options);
|
|
61
|
+
res.contentType('application/json').send({ success: true });
|
|
62
|
+
}
|
|
63
|
+
catch(err) {
|
|
64
|
+
env.debug.error(`failed to perform index action`, err);
|
|
65
|
+
sendError(res, err);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
env.app.post(`/index/${env.db.name}`, async (req: RouteRequest<any, ResponseBody, RequestBody & { action: 'create'} >, res) => {
|
|
70
|
+
// Legacy endpoint that was designed to handle multiple actions
|
|
71
|
+
// The only action ever implemented was 'create', so we'll handle that here
|
|
72
|
+
if (req.body?.action !== 'create') {
|
|
73
|
+
return sendError(res, { code: 'invalid_action', message: 'Invalid action' });
|
|
74
|
+
}
|
|
75
|
+
handleRequest(req, res);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
env.app.post(`/index/${env.db.name}/create`, async (req: Request, res) => {
|
|
79
|
+
// New dedicated create endpoint
|
|
80
|
+
handleRequest(req, res);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default addRoute;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/index/{dbname}/create:
|
|
2
|
+
post:
|
|
3
|
+
tags:
|
|
4
|
+
- data
|
|
5
|
+
- indexes
|
|
6
|
+
summary: Creates an index
|
|
7
|
+
description: Creates a new index in the database if it does not exist already. (admin only)
|
|
8
|
+
parameters:
|
|
9
|
+
- name: dbname
|
|
10
|
+
in: path
|
|
11
|
+
description: name of the database
|
|
12
|
+
required: true
|
|
13
|
+
schema:
|
|
14
|
+
type: string
|
|
15
|
+
example: mydb
|
|
16
|
+
requestBody:
|
|
17
|
+
description: request
|
|
18
|
+
content:
|
|
19
|
+
'application/json':
|
|
20
|
+
schema:
|
|
21
|
+
type: object
|
|
22
|
+
properties:
|
|
23
|
+
path:
|
|
24
|
+
type: string
|
|
25
|
+
description: path of the collection to index, can contain wildcards and variables such as * and $name
|
|
26
|
+
example: books
|
|
27
|
+
examples:
|
|
28
|
+
simple:
|
|
29
|
+
summary: Simple path
|
|
30
|
+
value: books
|
|
31
|
+
wildcard:
|
|
32
|
+
summary: path with a wildcard to index scattered data
|
|
33
|
+
value: users/*/reservations
|
|
34
|
+
variable:
|
|
35
|
+
summary: path with a variable (same as *) to index scattered data
|
|
36
|
+
value: hotels/$id/reviews
|
|
37
|
+
required: true
|
|
38
|
+
key:
|
|
39
|
+
type: string
|
|
40
|
+
description: key (property) to index for each item in the collection, can contain a nested target path
|
|
41
|
+
example: title
|
|
42
|
+
examples:
|
|
43
|
+
- title
|
|
44
|
+
- text
|
|
45
|
+
- content/title
|
|
46
|
+
- content/stats/size
|
|
47
|
+
required: true
|
|
48
|
+
options:
|
|
49
|
+
type: object
|
|
50
|
+
description: Additional options
|
|
51
|
+
properties:
|
|
52
|
+
'type':
|
|
53
|
+
type: string
|
|
54
|
+
enum:
|
|
55
|
+
- normal
|
|
56
|
+
- array
|
|
57
|
+
- fulltext
|
|
58
|
+
- geo
|
|
59
|
+
description: type of index to create
|
|
60
|
+
include:
|
|
61
|
+
type: array
|
|
62
|
+
items:
|
|
63
|
+
type: string
|
|
64
|
+
example:
|
|
65
|
+
- year
|
|
66
|
+
- rating
|
|
67
|
+
description: Additional keys to include in the index. Speeds up sorting on these columns when the index is used (and dramatically increases query speed when .take(n) is used in addition)
|
|
68
|
+
rebuild:
|
|
69
|
+
type: boolean
|
|
70
|
+
example: false
|
|
71
|
+
description: Whether to rebuild the index if it exists already
|
|
72
|
+
textLocale:
|
|
73
|
+
type: string
|
|
74
|
+
example: en-us
|
|
75
|
+
description: If the indexed values are strings, which default locale to use
|
|
76
|
+
config:
|
|
77
|
+
type: object
|
|
78
|
+
description: additional configuration for special indexes, see documentation
|
|
79
|
+
properties:
|
|
80
|
+
see_docs:
|
|
81
|
+
description: See documentation for config options. Note that you can't create fulltext indexes with custom callack functions through the API; those need to be created in your code at the server.
|
|
82
|
+
example: (See documentation for config options, many require server-side execution)
|
|
83
|
+
responses:
|
|
84
|
+
200:
|
|
85
|
+
description: returned when the index was created successfully
|
|
86
|
+
content:
|
|
87
|
+
'application/json':
|
|
88
|
+
schema:
|
|
89
|
+
type: object
|
|
90
|
+
properties:
|
|
91
|
+
success:
|
|
92
|
+
type: boolean
|
|
93
|
+
example: true
|
|
94
|
+
403:
|
|
95
|
+
description: Returns "403 Forbidden" if the signed in user is not admin
|
|
96
|
+
content:
|
|
97
|
+
'application/json':
|
|
98
|
+
schema:
|
|
99
|
+
$ref: '#/components/schemas/Error'
|
|
100
|
+
500:
|
|
101
|
+
description: An unexpected error occurred
|
|
102
|
+
content:
|
|
103
|
+
'application/json':
|
|
104
|
+
schema:
|
|
105
|
+
$ref: '#/components/schemas/UnexpectedError'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { RouteInitEnvironment, RouteRequest } from '../shared/env';
|
|
2
|
+
import { sendError, sendUnauthorizedError } from '../shared/error';
|
|
3
|
+
|
|
4
|
+
export type RequestQuery = null;
|
|
5
|
+
export type RequestBody = {
|
|
6
|
+
fileName: string;
|
|
7
|
+
};
|
|
8
|
+
export type ResponseBody = { success: true } // 200
|
|
9
|
+
| { code: 'admin_only'; message: string } // 403
|
|
10
|
+
| { code: 'unexpected'; message: string }; // 500 (TODO check if 400 is also possible)
|
|
11
|
+
|
|
12
|
+
export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
|
|
13
|
+
|
|
14
|
+
export const addRoute = (env: RouteInitEnvironment) => {
|
|
15
|
+
|
|
16
|
+
env.app.post(`/index/${env.db.name}/delete`, async (req: Request, res) => {
|
|
17
|
+
// Delete an index
|
|
18
|
+
if (!req.user || req.user.username !== 'admin') {
|
|
19
|
+
return sendUnauthorizedError(res, 'admin_only', 'only admin can perform index operations');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const data = req.body;
|
|
24
|
+
if (!data.fileName) {
|
|
25
|
+
throw new Error('fileName not given');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await env.db.indexes.delete(data.fileName); // Requires newer acebase & acebase-core packages
|
|
29
|
+
res.contentType('application/json').send({ success: true });
|
|
30
|
+
}
|
|
31
|
+
catch(err) {
|
|
32
|
+
env.debug.error(`failed to perform index action`, err);
|
|
33
|
+
sendError(res, err);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default addRoute;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/index/{dbname}/delete:
|
|
2
|
+
post:
|
|
3
|
+
tags:
|
|
4
|
+
- data
|
|
5
|
+
- indexes
|
|
6
|
+
summary: Removes an index
|
|
7
|
+
description: Removes an index from the database
|
|
8
|
+
parameters:
|
|
9
|
+
- name: dbname
|
|
10
|
+
in: path
|
|
11
|
+
description: name of the database
|
|
12
|
+
required: true
|
|
13
|
+
schema:
|
|
14
|
+
type: string
|
|
15
|
+
example: mydb
|
|
16
|
+
requestBody:
|
|
17
|
+
description: request
|
|
18
|
+
content:
|
|
19
|
+
'application/json':
|
|
20
|
+
schema:
|
|
21
|
+
type: object
|
|
22
|
+
properties:
|
|
23
|
+
fileName:
|
|
24
|
+
type: string
|
|
25
|
+
description: The name of the target index file to delete
|
|
26
|
+
required:
|
|
27
|
+
- action
|
|
28
|
+
- filePath
|
|
29
|
+
responses:
|
|
30
|
+
200:
|
|
31
|
+
description: Returned when the index is deleted successfully
|
|
32
|
+
content:
|
|
33
|
+
'application/json':
|
|
34
|
+
schema:
|
|
35
|
+
type: object
|
|
36
|
+
properties:
|
|
37
|
+
success:
|
|
38
|
+
type: boolean
|
|
39
|
+
example: true
|
|
40
|
+
403:
|
|
41
|
+
description: Returns "403 Forbidden" if the signed in user is not admin
|
|
42
|
+
content:
|
|
43
|
+
'application/json':
|
|
44
|
+
schema:
|
|
45
|
+
$ref: '#/components/schemas/Error'
|
|
46
|
+
500:
|
|
47
|
+
description: An unexpected error occurred
|
|
48
|
+
content:
|
|
49
|
+
'application/json':
|
|
50
|
+
schema:
|
|
51
|
+
$ref: '#/components/schemas/UnexpectedError'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RouteInitEnvironment, RouteRequest } from '../shared/env';
|
|
2
|
+
import { sendError, sendUnauthorizedError } from '../shared/error';
|
|
3
|
+
|
|
4
|
+
export interface PublicDataIndex {
|
|
5
|
+
path: string;
|
|
6
|
+
key: string;
|
|
7
|
+
caseSensitive: boolean;
|
|
8
|
+
textLocale: string;
|
|
9
|
+
includeKeys: string[];
|
|
10
|
+
indexMetadataKeys: string[];
|
|
11
|
+
type: "normal" | "array" | "fulltext" | "geo";
|
|
12
|
+
fileName: string;
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
export type RequestQuery = null;
|
|
16
|
+
export type RequestBody = null;
|
|
17
|
+
export type ResponseBody = PublicDataIndex[] | { code: string; message: string };
|
|
18
|
+
export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
|
|
19
|
+
|
|
20
|
+
export const addRoute = (env: RouteInitEnvironment) => {
|
|
21
|
+
|
|
22
|
+
env.app.get(`/index/${env.db.name}`, async (req: Request, res) => {
|
|
23
|
+
// Get all indexes
|
|
24
|
+
if (!req.user || req.user.username !== 'admin') {
|
|
25
|
+
return sendUnauthorizedError(res, 'admin_only', 'only admin can perform index operations');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const indexes = await env.db.indexes.get();
|
|
30
|
+
res.contentType('application/json').send(indexes.map(index => {
|
|
31
|
+
const { path, key, caseSensitive, textLocale, includeKeys, indexMetadataKeys, type, fileName, description } = index;
|
|
32
|
+
return { path, key, caseSensitive, textLocale, includeKeys, indexMetadataKeys, type, fileName, description };
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
sendError(res, err);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default addRoute;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/index/{dbname}:
|
|
2
|
+
get:
|
|
3
|
+
tags:
|
|
4
|
+
- data
|
|
5
|
+
- indexes
|
|
6
|
+
summary: Get indexes in the database
|
|
7
|
+
description: Gets a list of indexes created in the database (admin only)
|
|
8
|
+
parameters:
|
|
9
|
+
- name: dbname
|
|
10
|
+
in: path
|
|
11
|
+
description: name of the database
|
|
12
|
+
required: true
|
|
13
|
+
schema:
|
|
14
|
+
type: string
|
|
15
|
+
example: mydb
|
|
16
|
+
responses:
|
|
17
|
+
200:
|
|
18
|
+
description: Returns an array of indexes in the database
|
|
19
|
+
content:
|
|
20
|
+
'application/json':
|
|
21
|
+
schema:
|
|
22
|
+
type: array
|
|
23
|
+
items:
|
|
24
|
+
type: object
|
|
25
|
+
properties:
|
|
26
|
+
path:
|
|
27
|
+
type: string
|
|
28
|
+
description: path of the indexed collection
|
|
29
|
+
example: books
|
|
30
|
+
key:
|
|
31
|
+
type: string
|
|
32
|
+
description: key (property) of the indexed items in the collection
|
|
33
|
+
example: title
|
|
34
|
+
caseSensitive:
|
|
35
|
+
type: boolean
|
|
36
|
+
description: Whether the values are indexed with case sensitivity or not (applies to string values only)
|
|
37
|
+
example: false
|
|
38
|
+
textLocale:
|
|
39
|
+
type: string
|
|
40
|
+
description: Locale of the indexed string values
|
|
41
|
+
example: en-us
|
|
42
|
+
includeKeys:
|
|
43
|
+
type: array
|
|
44
|
+
description: keys (properties) whose values are included in the index
|
|
45
|
+
items:
|
|
46
|
+
type: string
|
|
47
|
+
example:
|
|
48
|
+
- rating
|
|
49
|
+
- year
|
|
50
|
+
indexMetadataKeys:
|
|
51
|
+
type: array
|
|
52
|
+
description: Any additional info that is being stored with the items. Eg for fulltext indexes, it contains the word count and location
|
|
53
|
+
items:
|
|
54
|
+
type: string
|
|
55
|
+
type:
|
|
56
|
+
type: string
|
|
57
|
+
description: Type of index
|
|
58
|
+
enum:
|
|
59
|
+
- normal
|
|
60
|
+
- array
|
|
61
|
+
- fulltext
|
|
62
|
+
- geo
|
|
63
|
+
fileName:
|
|
64
|
+
type: string
|
|
65
|
+
description: name of the index file on disk
|
|
66
|
+
description:
|
|
67
|
+
type: string
|
|
68
|
+
description: description of the index
|
|
69
|
+
403:
|
|
70
|
+
description: Returns a "403 Forbidden" if the signed in user is not admin
|
|
71
|
+
content:
|
|
72
|
+
'application/json':
|
|
73
|
+
schema:
|
|
74
|
+
$ref: '#/components/schemas/Error'
|
|
75
|
+
500:
|
|
76
|
+
description: An unexpected error occurred
|
|
77
|
+
content:
|
|
78
|
+
'application/json':
|
|
79
|
+
schema:
|
|
80
|
+
$ref: '#/components/schemas/UnexpectedError'
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Transport } from 'acebase-core';
|
|
2
|
+
import { RouteInitEnvironment, RouteRequest } from '../shared/env';
|
|
3
|
+
import { sendError, sendUnauthorizedError } from '../shared/error';
|
|
4
|
+
|
|
5
|
+
export type RequestQuery = null;
|
|
6
|
+
export type RequestBody = {
|
|
7
|
+
map: any;
|
|
8
|
+
val: {
|
|
9
|
+
query: {
|
|
10
|
+
/** result filters */
|
|
11
|
+
filters: Array<{ key: string, op: string, compare: any }>;
|
|
12
|
+
/** number of results to skip, useful for paging */
|
|
13
|
+
skip: number;
|
|
14
|
+
/** max number of results to return */
|
|
15
|
+
take: number;
|
|
16
|
+
/** sort order */
|
|
17
|
+
order: Array<{ key: string, ascending: boolean }>;
|
|
18
|
+
};
|
|
19
|
+
/** client's query id for realtime event notifications through the websocket */
|
|
20
|
+
query_id?: string;
|
|
21
|
+
/** client's socket id for realtime event notifications through websocket */
|
|
22
|
+
client_id?: string;
|
|
23
|
+
options: {
|
|
24
|
+
snapshots?: boolean;
|
|
25
|
+
monitor?: boolean|{ add: boolean; change: boolean; remove: boolean };
|
|
26
|
+
include?: string[];
|
|
27
|
+
exclude?: string[];
|
|
28
|
+
child_objects?: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export type ResponseBody = {
|
|
33
|
+
val: {
|
|
34
|
+
count: number;
|
|
35
|
+
list: any[]
|
|
36
|
+
},
|
|
37
|
+
map: any
|
|
38
|
+
};
|
|
39
|
+
export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
|
|
40
|
+
|
|
41
|
+
export const addRoute = (env: RouteInitEnvironment) => {
|
|
42
|
+
|
|
43
|
+
env.app.post(`/query/${env.db.name}/*`, async (req: Request, res) => {
|
|
44
|
+
// Execute query
|
|
45
|
+
const path = req.path.slice(env.db.name.length + 8);
|
|
46
|
+
const access = env.rules.userHasAccess(req.user, path, false);
|
|
47
|
+
if (!access.allow) {
|
|
48
|
+
return sendUnauthorizedError(res, access.code, access.message);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const data = Transport.deserialize(req.body);
|
|
52
|
+
if (typeof data !== 'object' || typeof data.query !== 'object' || typeof data.options !== 'object') {
|
|
53
|
+
return sendError(res, { code: 'invalid_request', message: 'Invalid query request' });
|
|
54
|
+
}
|
|
55
|
+
const query = data.query;
|
|
56
|
+
const options = data.options;
|
|
57
|
+
if (options.monitor === true) {
|
|
58
|
+
options.monitor = { add: true, change: true, remove: true };
|
|
59
|
+
}
|
|
60
|
+
if (typeof options.monitor === 'object' && (options.monitor.add || options.monitor.change || options.monitor.remove)) {
|
|
61
|
+
const queryId = data.query_id;
|
|
62
|
+
const clientId = data.client_id;
|
|
63
|
+
const client = env.clients.get(clientId);
|
|
64
|
+
client.realtimeQueries[queryId] = { path, query, options };
|
|
65
|
+
|
|
66
|
+
const sendEvent = event => {
|
|
67
|
+
const client = env.clients.get(clientId);
|
|
68
|
+
if (!client) { return false; } // Not connected, stop subscription
|
|
69
|
+
if (!env.rules.userHasAccess(client.user, event.path, false).allow) {
|
|
70
|
+
return false; // Access denied, stop subscription
|
|
71
|
+
}
|
|
72
|
+
event.query_id = queryId;
|
|
73
|
+
const data = Transport.serialize(event);
|
|
74
|
+
client.socket.emit('query-event', data);
|
|
75
|
+
}
|
|
76
|
+
options.eventHandler = sendEvent;
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const { results, context } = await env.db.api.query(path, query, options);
|
|
80
|
+
if (!env.config.transactions?.log) {
|
|
81
|
+
delete context.acebase_cursor;
|
|
82
|
+
}
|
|
83
|
+
const response = {
|
|
84
|
+
count: results.length,
|
|
85
|
+
list: results // []
|
|
86
|
+
};
|
|
87
|
+
res.setHeader('AceBase-Context', JSON.stringify(context));
|
|
88
|
+
res.send(Transport.serialize(response));
|
|
89
|
+
}
|
|
90
|
+
catch(err) {
|
|
91
|
+
sendError(res, { code: 'unknown', message: err.message });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default addRoute;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/query/{dbname}/{path}:
|
|
2
|
+
post:
|
|
3
|
+
tags:
|
|
4
|
+
- data
|
|
5
|
+
- query
|
|
6
|
+
summary: Query an object collection
|
|
7
|
+
description: Query an object collection in the database
|
|
8
|
+
parameters:
|
|
9
|
+
- name: dbname
|
|
10
|
+
in: path
|
|
11
|
+
description: name of the database
|
|
12
|
+
required: true
|
|
13
|
+
schema:
|
|
14
|
+
type: string
|
|
15
|
+
example: mydb
|
|
16
|
+
- name: path
|
|
17
|
+
in: path
|
|
18
|
+
description: database path
|
|
19
|
+
required: true
|
|
20
|
+
schema:
|
|
21
|
+
type: string
|
|
22
|
+
example: books
|
|
23
|
+
requestBody:
|
|
24
|
+
description: serialized query object
|
|
25
|
+
content:
|
|
26
|
+
'application/json':
|
|
27
|
+
schema:
|
|
28
|
+
type: object
|
|
29
|
+
properties:
|
|
30
|
+
map:
|
|
31
|
+
description: Data type mappings for the value in _val_. See the _SerializedValue_ schema for more info
|
|
32
|
+
oneOf:
|
|
33
|
+
- type: string
|
|
34
|
+
- type: object
|
|
35
|
+
example: {}
|
|
36
|
+
val:
|
|
37
|
+
description: Information about the query to execute
|
|
38
|
+
type: object
|
|
39
|
+
properties:
|
|
40
|
+
query:
|
|
41
|
+
type: object
|
|
42
|
+
properties:
|
|
43
|
+
filters:
|
|
44
|
+
type: array
|
|
45
|
+
items:
|
|
46
|
+
type: object
|
|
47
|
+
properties:
|
|
48
|
+
key:
|
|
49
|
+
type: string
|
|
50
|
+
example: title
|
|
51
|
+
description: Key to apply filter on
|
|
52
|
+
op:
|
|
53
|
+
type: string
|
|
54
|
+
description: Comparison operator to use, such as `==`, `>`, 'like' etc
|
|
55
|
+
example: like
|
|
56
|
+
compare:
|
|
57
|
+
example: AceBase*
|
|
58
|
+
description: Value to compare with
|
|
59
|
+
oneOf:
|
|
60
|
+
- type: string
|
|
61
|
+
- type: number
|
|
62
|
+
- type: boolean
|
|
63
|
+
skip:
|
|
64
|
+
type: integer
|
|
65
|
+
example: 0
|
|
66
|
+
description: Number of results to skip, useful for paging
|
|
67
|
+
take:
|
|
68
|
+
type: integer
|
|
69
|
+
example: 10
|
|
70
|
+
description: Max number of results to return
|
|
71
|
+
order:
|
|
72
|
+
type: array
|
|
73
|
+
items:
|
|
74
|
+
type: object
|
|
75
|
+
properties:
|
|
76
|
+
key:
|
|
77
|
+
type: string
|
|
78
|
+
description: Name of the key to sort the results on
|
|
79
|
+
example: rating
|
|
80
|
+
ascending:
|
|
81
|
+
type: boolean
|
|
82
|
+
description: Whether to sort the results in ascending or descending order
|
|
83
|
+
example: false
|
|
84
|
+
query_id:
|
|
85
|
+
type: string
|
|
86
|
+
description: (realtime queries only) client's query id for realtime event notifications through the websocket
|
|
87
|
+
example: l27nswgz000009l58bo7gqhf
|
|
88
|
+
client_id:
|
|
89
|
+
type: string
|
|
90
|
+
description: (realtime queries only) client's socket id for realtime event notifications through websocket
|
|
91
|
+
example: l27mjf9k000209mhafylc3eo
|
|
92
|
+
options:
|
|
93
|
+
type: object
|
|
94
|
+
properties:
|
|
95
|
+
snapshots:
|
|
96
|
+
type: boolean
|
|
97
|
+
description: Whether to return snapshots of the data, or references to the results only (default)
|
|
98
|
+
example: true
|
|
99
|
+
monitor:
|
|
100
|
+
description: (optional, realtime queries only) which realtime events to monitor
|
|
101
|
+
oneOf:
|
|
102
|
+
- type: boolean
|
|
103
|
+
description: Whether to monitor all or none of the realtime events (add, change, remove)
|
|
104
|
+
- type: object
|
|
105
|
+
description: Which realtime events to monitor
|
|
106
|
+
properties:
|
|
107
|
+
add:
|
|
108
|
+
type: boolean
|
|
109
|
+
description: Monitors results that are added after initial query execution
|
|
110
|
+
change:
|
|
111
|
+
type: boolean
|
|
112
|
+
description: Monitors results that are changed after initial query execution
|
|
113
|
+
remove:
|
|
114
|
+
type: boolean
|
|
115
|
+
description: Monitors results that are removed after initial query execution
|
|
116
|
+
example: false
|
|
117
|
+
include:
|
|
118
|
+
type: array
|
|
119
|
+
items:
|
|
120
|
+
type: string
|
|
121
|
+
description: (optional) keys to include in the results set
|
|
122
|
+
example:
|
|
123
|
+
- title
|
|
124
|
+
- author
|
|
125
|
+
- rating
|
|
126
|
+
- reviews/*/author
|
|
127
|
+
- reviews/*/text
|
|
128
|
+
exclude:
|
|
129
|
+
type: array
|
|
130
|
+
items:
|
|
131
|
+
type: string
|
|
132
|
+
description: (optional) keys to exclude from the results set
|
|
133
|
+
example: []
|
|
134
|
+
child_objects:
|
|
135
|
+
type: boolean
|
|
136
|
+
description: (optional) whether to load child object values
|
|
137
|
+
example: true
|
|
138
|
+
responses:
|
|
139
|
+
200:
|
|
140
|
+
description: Returns the serialized count and list of query results
|
|
141
|
+
content:
|
|
142
|
+
'application/json':
|
|
143
|
+
schema:
|
|
144
|
+
required:
|
|
145
|
+
- val
|
|
146
|
+
allOf:
|
|
147
|
+
- $ref: '#/components/schemas/SerializedValue'
|
|
148
|
+
example:
|
|
149
|
+
val: { count: 1, list: [{ path: 'books/l27oxggz000009ml9ri26y2d', val: { title: 'AceBase is cool', author: 'Database guru', rating: 5.0, reviews: { 'cl27ozp2g000009lbfopcbkd2': { author: 'DB admin', text: 'The title says it all!' } } }}] }
|
|
150
|
+
map: { 'stats/created': 'date', 'stats/modified': 'date' }
|
|
151
|
+
403:
|
|
152
|
+
description: Returns a "403 Forbidden" if the signed in user is not allowed to read from the target path
|
|
153
|
+
content:
|
|
154
|
+
'application/json':
|
|
155
|
+
schema:
|
|
156
|
+
$ref: '#/components/schemas/Error'
|
|
157
|
+
500:
|
|
158
|
+
description: An unexpected error occurred
|
|
159
|
+
content:
|
|
160
|
+
'application/json':
|
|
161
|
+
schema:
|
|
162
|
+
$ref: '#/components/schemas/UnexpectedError'
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|