@aurabase/aurabase-js 0.3.0 → 0.4.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/README.md +26 -795
- package/{packages/aurabase/dist/AuraClient-DAtDbfPB.d.ts → dist/AuraClient-BcFE8u1v.d.cts} +1 -1
- package/{packages/aurabase/dist/AuraClient-DAtDbfPB.d.cts → dist/AuraClient-BcFE8u1v.d.ts} +1 -1
- package/{packages/aurabase/dist → dist}/index.d.cts +1 -1
- package/{packages/aurabase/dist → dist}/index.d.ts +1 -1
- package/{packages/aurabase/dist → dist}/ssr.d.cts +1 -1
- package/{packages/aurabase/dist → dist}/ssr.d.ts +1 -1
- package/package.json +72 -82
- package/.changeset/config.json +0 -11
- package/CHANGELOG.md +0 -30
- package/packages/ai/LICENSE +0 -21
- package/packages/ai/README.md +0 -106
- package/packages/ai/dist/index.cjs +0 -229
- package/packages/ai/dist/index.d.cts +0 -139
- package/packages/ai/dist/index.d.ts +0 -139
- package/packages/ai/dist/index.js +0 -226
- package/packages/ai/node_modules/.bin/esbuild +0 -19
- package/packages/ai/node_modules/.bin/tsc +0 -22
- package/packages/ai/node_modules/.bin/tsserver +0 -22
- package/packages/ai/node_modules/.bin/tsup +0 -22
- package/packages/ai/node_modules/.bin/tsup-node +0 -22
- package/packages/ai/node_modules/.bin/vite +0 -22
- package/packages/ai/node_modules/.bin/vitest +0 -22
- package/packages/ai/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/ai/package.json +0 -61
- package/packages/ai/src/AiService.ts +0 -226
- package/packages/ai/src/index.ts +0 -18
- package/packages/ai/src/sse.ts +0 -141
- package/packages/ai/src/types.ts +0 -30
- package/packages/ai/tests/chat-stream.test.ts +0 -151
- package/packages/ai/tests/rag-namespaces.test.ts +0 -54
- package/packages/ai/tests/sse.test.ts +0 -69
- package/packages/ai/tsconfig.json +0 -5
- package/packages/ai/tsup.config.ts +0 -11
- package/packages/aurabase/LICENSE +0 -21
- package/packages/aurabase/README.md +0 -64
- package/packages/aurabase/node_modules/.bin/esbuild +0 -19
- package/packages/aurabase/node_modules/.bin/tsc +0 -22
- package/packages/aurabase/node_modules/.bin/tsserver +0 -22
- package/packages/aurabase/node_modules/.bin/tsup +0 -22
- package/packages/aurabase/node_modules/.bin/tsup-node +0 -22
- package/packages/aurabase/node_modules/.bin/vite +0 -22
- package/packages/aurabase/node_modules/.bin/vitest +0 -22
- package/packages/aurabase/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/aurabase/package.json +0 -80
- package/packages/aurabase/src/AuraClient.ts +0 -237
- package/packages/aurabase/src/index.ts +0 -152
- package/packages/aurabase/src/ssr.ts +0 -156
- package/packages/aurabase/tests/ai-streaming-rag-e2e.test.ts +0 -82
- package/packages/aurabase/tests/ai.test.ts +0 -111
- package/packages/aurabase/tests/auth-admin.test.ts +0 -515
- package/packages/aurabase/tests/auth-e2e.test.ts +0 -135
- package/packages/aurabase/tests/auth-hardening.test.ts +0 -206
- package/packages/aurabase/tests/auth.test.ts +0 -947
- package/packages/aurabase/tests/database.test.ts +0 -230
- package/packages/aurabase/tests/db-types-e2e.test.ts +0 -217
- package/packages/aurabase/tests/dispose.test.ts +0 -23
- package/packages/aurabase/tests/foreign-token.e2e.test.ts +0 -129
- package/packages/aurabase/tests/functions.test.ts +0 -107
- package/packages/aurabase/tests/integration.test.ts +0 -413
- package/packages/aurabase/tests/live-production-validation.js +0 -241
- package/packages/aurabase/tests/live-sdk-production-validation.js +0 -293
- package/packages/aurabase/tests/mocks.ts +0 -139
- package/packages/aurabase/tests/notifications.test.ts +0 -314
- package/packages/aurabase/tests/observability-backup.test.ts +0 -186
- package/packages/aurabase/tests/observability-hook.test.ts +0 -130
- package/packages/aurabase/tests/production-robustness.test.ts +0 -268
- package/packages/aurabase/tests/public-api-surface.test.ts +0 -53
- package/packages/aurabase/tests/query-builder.test.ts +0 -329
- package/packages/aurabase/tests/readme-smoke-e2e.test.ts +0 -231
- package/packages/aurabase/tests/realtime-filter-e2e.test.ts +0 -344
- package/packages/aurabase/tests/refresh-locks.test.ts +0 -210
- package/packages/aurabase/tests/retry-option.test.ts +0 -17
- package/packages/aurabase/tests/rpc-e2e.test.ts +0 -254
- package/packages/aurabase/tests/rs256-local-e2e.test.ts +0 -114
- package/packages/aurabase/tests/rt-alias-public-e2e.test.ts +0 -235
- package/packages/aurabase/tests/rt-http-broadcast-e2e.test.ts +0 -124
- package/packages/aurabase/tests/service-role-guard.test.ts +0 -99
- package/packages/aurabase/tests/ssr.test.ts +0 -91
- package/packages/aurabase/tests/storage-backend-e2e.test.ts +0 -481
- package/packages/aurabase/tests/storage-sdk-parity-e2e.test.ts +0 -104
- package/packages/aurabase/tests/storage-transform-e2e.test.ts +0 -684
- package/packages/aurabase/tests/storage.test.ts +0 -55
- package/packages/aurabase/tests/types/client-generic.test-d.ts +0 -79
- package/packages/aurabase/tests/types/docs-snippets.test-d.ts +0 -571
- package/packages/aurabase/tests/types/error-code.test-d.ts +0 -53
- package/packages/aurabase/tsconfig.json +0 -5
- package/packages/aurabase/tsconfig.test-d.json +0 -5
- package/packages/aurabase/tsup.config.ts +0 -11
- package/packages/aurabase/vitest.config.ts +0 -16
- package/packages/aurabase/vitest.e2e.config.ts +0 -9
- package/packages/auth/LICENSE +0 -21
- package/packages/auth/README.md +0 -215
- package/packages/auth/dist/index.cjs +0 -1175
- package/packages/auth/dist/index.d.cts +0 -397
- package/packages/auth/dist/index.d.ts +0 -397
- package/packages/auth/dist/index.js +0 -1170
- package/packages/auth/node_modules/.bin/esbuild +0 -19
- package/packages/auth/node_modules/.bin/tsc +0 -22
- package/packages/auth/node_modules/.bin/tsserver +0 -22
- package/packages/auth/node_modules/.bin/tsup +0 -22
- package/packages/auth/node_modules/.bin/tsup-node +0 -22
- package/packages/auth/node_modules/.bin/vite +0 -22
- package/packages/auth/node_modules/.bin/vitest +0 -22
- package/packages/auth/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/auth/package.json +0 -61
- package/packages/auth/src/AuthAdminService.ts +0 -149
- package/packages/auth/src/AuthService.ts +0 -1166
- package/packages/auth/src/SessionManager.ts +0 -92
- package/packages/auth/src/index.ts +0 -17
- package/packages/auth/src/jwks.ts +0 -337
- package/packages/auth/src/pkce.ts +0 -27
- package/packages/auth/src/types.ts +0 -89
- package/packages/auth/tests/auth-lifecycle.test.ts +0 -149
- package/packages/auth/tests/detect-session.test.ts +0 -361
- package/packages/auth/tests/getclaims.test.ts +0 -780
- package/packages/auth/tests/is-mfa-challenge.test.ts +0 -27
- package/packages/auth/tests/password-recovery.test.ts +0 -124
- package/packages/auth/tests/pkce.test.ts +0 -192
- package/packages/auth/tests/session-manager.test.ts +0 -103
- package/packages/auth/tests/set-session.test.ts +0 -139
- package/packages/auth/tests/verify-otp.test.ts +0 -153
- package/packages/auth/tsconfig.json +0 -5
- package/packages/auth/tsup.config.ts +0 -11
- package/packages/core/LICENSE +0 -21
- package/packages/core/README.md +0 -132
- package/packages/core/dist/index.cjs +0 -695
- package/packages/core/dist/index.d.cts +0 -1137
- package/packages/core/dist/index.d.ts +0 -1137
- package/packages/core/dist/index.js +0 -673
- package/packages/core/node_modules/.bin/esbuild +0 -22
- package/packages/core/node_modules/.bin/tsc +0 -22
- package/packages/core/node_modules/.bin/tsserver +0 -22
- package/packages/core/node_modules/.bin/tsup +0 -22
- package/packages/core/node_modules/.bin/tsup-node +0 -22
- package/packages/core/node_modules/.bin/vite +0 -22
- package/packages/core/node_modules/.bin/vitest +0 -22
- package/packages/core/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/core/package.json +0 -57
- package/packages/core/src/AuraError.ts +0 -89
- package/packages/core/src/BaseService.ts +0 -44
- package/packages/core/src/client.ts +0 -34
- package/packages/core/src/cookie-utils.ts +0 -42
- package/packages/core/src/fetch.ts +0 -435
- package/packages/core/src/index.ts +0 -22
- package/packages/core/src/retry.ts +0 -63
- package/packages/core/src/serialize.ts +0 -6
- package/packages/core/src/stores/BaseAuthStore.ts +0 -164
- package/packages/core/src/stores/LocalAuthStore.ts +0 -199
- package/packages/core/src/types.ts +0 -1042
- package/packages/core/tests/auth-store.test.ts +0 -300
- package/packages/core/tests/error-code.test.ts +0 -61
- package/packages/core/tests/error.test.ts +0 -24
- package/packages/core/tests/fetch.test.ts +0 -286
- package/packages/core/tests/mocks.ts +0 -139
- package/packages/core/tests/observability.test.ts +0 -86
- package/packages/core/tests/refresh-hardening.test.ts +0 -164
- package/packages/core/tests/refresh-observability.test.ts +0 -111
- package/packages/core/tests/retry.test.ts +0 -106
- package/packages/core/tests/serialize.test.ts +0 -12
- package/packages/core/tests/timeout.test.ts +0 -79
- package/packages/core/tsconfig.json +0 -5
- package/packages/core/tsup.config.ts +0 -11
- package/packages/db/LICENSE +0 -21
- package/packages/db/README.md +0 -152
- package/packages/db/VENDORED.md +0 -93
- package/packages/db/dist/index.cjs +0 -544
- package/packages/db/dist/index.d.cts +0 -1111
- package/packages/db/dist/index.d.ts +0 -1111
- package/packages/db/dist/index.js +0 -541
- package/packages/db/node_modules/.bin/esbuild +0 -19
- package/packages/db/node_modules/.bin/tsc +0 -22
- package/packages/db/node_modules/.bin/tsserver +0 -22
- package/packages/db/node_modules/.bin/tsup +0 -22
- package/packages/db/node_modules/.bin/tsup-node +0 -22
- package/packages/db/node_modules/.bin/vite +0 -22
- package/packages/db/node_modules/.bin/vitest +0 -22
- package/packages/db/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/db/package.json +0 -62
- package/packages/db/src/DatabaseService.ts +0 -170
- package/packages/db/src/QueryBuilder.ts +0 -830
- package/packages/db/src/index.ts +0 -2
- package/packages/db/src/pgrst-types/common/common.ts +0 -86
- package/packages/db/src/pgrst-types/common/rpc.ts +0 -151
- package/packages/db/src/pgrst-types/feature-flags.ts +0 -20
- package/packages/db/src/pgrst-types/types.ts +0 -134
- package/packages/db/src/select-query-parser/parser.ts +0 -479
- package/packages/db/src/select-query-parser/result.ts +0 -553
- package/packages/db/src/select-query-parser/types.ts +0 -132
- package/packages/db/src/select-query-parser/utils.ts +0 -707
- package/packages/db/tests/filters.test.ts +0 -81
- package/packages/db/tests/mutations-filtered.e2e.test.ts +0 -132
- package/packages/db/tests/mutations-filtered.test.ts +0 -188
- package/packages/db/tests/order.test.ts +0 -45
- package/packages/db/tests/rpc.test.ts +0 -41
- package/packages/db/tests/scale/build-large-schema.ts +0 -94
- package/packages/db/tests/scale/scale-compile.test.ts +0 -167
- package/packages/db/tests/schema.test.ts +0 -77
- package/packages/db/tests/single-accept.e2e.test.ts +0 -123
- package/packages/db/tests/single.test.ts +0 -211
- package/packages/db/tests/types/filters.test-d.ts +0 -52
- package/packages/db/tests/types/fixtures.ts +0 -40
- package/packages/db/tests/types/from-views.test-d.ts +0 -18
- package/packages/db/tests/types/mutations.test-d.ts +0 -23
- package/packages/db/tests/types/rpc.test-d.ts +0 -60
- package/packages/db/tests/types/schema-shape.test-d.ts +0 -8
- package/packages/db/tests/types/select-inference.test-d.ts +0 -38
- package/packages/db/tests/vendored/fixtures.ts +0 -83
- package/packages/db/tests/vendored/get-result.test-d.ts +0 -75
- package/packages/db/tsconfig.json +0 -5
- package/packages/db/tsconfig.test-d.json +0 -5
- package/packages/db/tsup.config.ts +0 -11
- package/packages/db/vitest.config.ts +0 -8
- package/packages/functions/LICENSE +0 -21
- package/packages/functions/README.md +0 -96
- package/packages/functions/dist/index.cjs +0 -173
- package/packages/functions/dist/index.d.cts +0 -81
- package/packages/functions/dist/index.d.ts +0 -81
- package/packages/functions/dist/index.js +0 -168
- package/packages/functions/node_modules/.bin/esbuild +0 -19
- package/packages/functions/node_modules/.bin/tsc +0 -22
- package/packages/functions/node_modules/.bin/tsserver +0 -22
- package/packages/functions/node_modules/.bin/tsup +0 -22
- package/packages/functions/node_modules/.bin/tsup-node +0 -22
- package/packages/functions/node_modules/.bin/vite +0 -22
- package/packages/functions/node_modules/.bin/vitest +0 -22
- package/packages/functions/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/functions/package.json +0 -60
- package/packages/functions/src/FunctionsService.ts +0 -188
- package/packages/functions/src/errors.ts +0 -70
- package/packages/functions/src/index.ts +0 -6
- package/packages/functions/tests/invoke.test.ts +0 -97
- package/packages/functions/tests/response-type-errors.test.ts +0 -135
- package/packages/functions/tsconfig.json +0 -5
- package/packages/functions/tsup.config.ts +0 -11
- package/packages/gen/LICENSE +0 -21
- package/packages/gen/README.md +0 -84
- package/packages/gen/dist/cli.cjs +0 -334
- package/packages/gen/dist/cli.d.cts +0 -1
- package/packages/gen/dist/cli.d.ts +0 -1
- package/packages/gen/dist/cli.js +0 -332
- package/packages/gen/dist/index.cjs +0 -257
- package/packages/gen/dist/index.d.cts +0 -12
- package/packages/gen/dist/index.d.ts +0 -12
- package/packages/gen/dist/index.js +0 -255
- package/packages/gen/node_modules/.bin/esbuild +0 -19
- package/packages/gen/node_modules/.bin/tsc +0 -22
- package/packages/gen/node_modules/.bin/tsserver +0 -22
- package/packages/gen/node_modules/.bin/tsup +0 -22
- package/packages/gen/node_modules/.bin/tsup-node +0 -22
- package/packages/gen/node_modules/.bin/vite +0 -22
- package/packages/gen/node_modules/.bin/vitest +0 -22
- package/packages/gen/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/gen/package.json +0 -66
- package/packages/gen/src/cli.ts +0 -67
- package/packages/gen/src/generate.ts +0 -0
- package/packages/gen/src/index.ts +0 -2
- package/packages/gen/tests/compile.test.ts +0 -213
- package/packages/gen/tests/e2e.test.ts +0 -130
- package/packages/gen/tests/generate.test.ts +0 -396
- package/packages/gen/tsconfig.json +0 -5
- package/packages/gen/tsup.config.ts +0 -11
- package/packages/notifications/LICENSE +0 -21
- package/packages/notifications/README.md +0 -134
- package/packages/notifications/dist/index.cjs +0 -128
- package/packages/notifications/dist/index.d.cts +0 -81
- package/packages/notifications/dist/index.d.ts +0 -81
- package/packages/notifications/dist/index.js +0 -125
- package/packages/notifications/node_modules/.bin/esbuild +0 -19
- package/packages/notifications/node_modules/.bin/tsc +0 -22
- package/packages/notifications/node_modules/.bin/tsserver +0 -22
- package/packages/notifications/node_modules/.bin/tsup +0 -22
- package/packages/notifications/node_modules/.bin/tsup-node +0 -22
- package/packages/notifications/node_modules/.bin/vite +0 -22
- package/packages/notifications/node_modules/.bin/vitest +0 -22
- package/packages/notifications/package.json +0 -60
- package/packages/notifications/src/NotificationsService.ts +0 -230
- package/packages/notifications/src/index.ts +0 -19
- package/packages/notifications/tsconfig.json +0 -5
- package/packages/notifications/tsup.config.ts +0 -11
- package/packages/realtime/LICENSE +0 -21
- package/packages/realtime/README.md +0 -183
- package/packages/realtime/dist/index.cjs +0 -977
- package/packages/realtime/dist/index.d.cts +0 -259
- package/packages/realtime/dist/index.d.ts +0 -259
- package/packages/realtime/dist/index.js +0 -973
- package/packages/realtime/node_modules/.bin/esbuild +0 -19
- package/packages/realtime/node_modules/.bin/tsc +0 -22
- package/packages/realtime/node_modules/.bin/tsserver +0 -22
- package/packages/realtime/node_modules/.bin/tsup +0 -22
- package/packages/realtime/node_modules/.bin/tsup-node +0 -22
- package/packages/realtime/node_modules/.bin/vite +0 -22
- package/packages/realtime/node_modules/.bin/vitest +0 -22
- package/packages/realtime/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/realtime/package.json +0 -60
- package/packages/realtime/src/AuraChannel.ts +0 -485
- package/packages/realtime/src/HeartbeatManager.ts +0 -73
- package/packages/realtime/src/RealtimeService.ts +0 -505
- package/packages/realtime/src/columnFilter.ts +0 -301
- package/packages/realtime/src/index.ts +0 -4
- package/packages/realtime/tests/ack-routing.test.ts +0 -81
- package/packages/realtime/tests/column-filter.test.ts +0 -144
- package/packages/realtime/tests/dispatch.test.ts +0 -191
- package/packages/realtime/tests/heartbeat.test.ts +0 -67
- package/packages/realtime/tests/http-broadcast.test.ts +0 -68
- package/packages/realtime/tests/realtime-token.test.ts +0 -43
- package/packages/realtime/tests/reconnect-race.test.ts +0 -149
- package/packages/realtime/tests/ref-id.test.ts +0 -34
- package/packages/realtime/tests/set-auth.test.ts +0 -70
- package/packages/realtime/tsconfig.json +0 -5
- package/packages/realtime/tsup.config.ts +0 -11
- package/packages/storage/LICENSE +0 -21
- package/packages/storage/README.md +0 -141
- package/packages/storage/dist/index.cjs +0 -333
- package/packages/storage/dist/index.d.cts +0 -185
- package/packages/storage/dist/index.d.ts +0 -185
- package/packages/storage/dist/index.js +0 -329
- package/packages/storage/node_modules/.bin/esbuild +0 -19
- package/packages/storage/node_modules/.bin/tsc +0 -22
- package/packages/storage/node_modules/.bin/tsserver +0 -22
- package/packages/storage/node_modules/.bin/tsup +0 -22
- package/packages/storage/node_modules/.bin/tsup-node +0 -22
- package/packages/storage/node_modules/.bin/vite +0 -22
- package/packages/storage/node_modules/.bin/vitest +0 -22
- package/packages/storage/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/storage/package.json +0 -60
- package/packages/storage/src/DownloadBuilder.ts +0 -60
- package/packages/storage/src/StorageService.ts +0 -323
- package/packages/storage/src/index.ts +0 -2
- package/packages/storage/src/path.ts +0 -35
- package/packages/storage/src/transform.ts +0 -15
- package/packages/storage/tests/download.test.ts +0 -64
- package/packages/storage/tests/parity.test.ts +0 -154
- package/packages/storage/tests/path.test.ts +0 -87
- package/packages/storage/tests/transform.test.ts +0 -79
- package/packages/storage/tsconfig.json +0 -5
- package/packages/storage/tsup.config.ts +0 -11
- package/pnpm-workspace.yaml +0 -24
- package/tsconfig.base.json +0 -15
- /package/{packages/aurabase/dist → dist}/index.cjs +0 -0
- /package/{packages/aurabase/dist → dist}/index.js +0 -0
- /package/{packages/aurabase/dist → dist}/ssr.cjs +0 -0
- /package/{packages/aurabase/dist → dist}/ssr.js +0 -0
package/README.md
CHANGED
|
@@ -1,69 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# aurabase
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Client JavaScript/TypeScript officiel d'Aurabase : point d'entrée principal du SDK, agrégeant les 8 packages de service (`@aurabase/*`) derrière `createClient`/`createAdminClient` et l'export `aurabase/ssr`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
 
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
The package name is `aurabase`. It targets Node.js 20+ and browser runtimes with `fetch`, and it exports both ESM and CommonJS builds from `dist/`.
|
|
10
|
-
|
|
11
|
-
## Structure (monorepo)
|
|
12
|
-
|
|
13
|
-
Le SDK est un monorepo pnpm. Le package `aurabase` agrège tous les sous-packages et reste le point d'entrée principal (surface publique inchangée).
|
|
14
|
-
|
|
15
|
-
| Package | Contenu |
|
|
16
|
-
|---|---|
|
|
17
|
-
| `aurabase` | `createClient`, `createAdminClient`, `AuraClient`, `./ssr` — point d'entrée principal |
|
|
18
|
-
| `@aurabase/core` | fetch, erreurs, types, stores, `BaseService`, interface `AuraClientLike` |
|
|
19
|
-
| `@aurabase/auth` | `AuthService`, `AuthAdminService` |
|
|
20
|
-
| `@aurabase/db` | `DatabaseService`, `QueryBuilder` |
|
|
21
|
-
| `@aurabase/storage` | `StorageService` |
|
|
22
|
-
| `@aurabase/realtime` | `RealtimeService`, `AuraChannel`, `HeartbeatManager` |
|
|
23
|
-
| `@aurabase/functions` | `FunctionsService` |
|
|
24
|
-
| `@aurabase/ai` | `AiService` |
|
|
25
|
-
| `@aurabase/notifications` | `NotificationsService`, `NotificationsAdminService` |
|
|
26
|
-
| `@aurabase/gen` | CLI `aurabase-gen` — générateur de types `Database` (dev-dependency, non inclus dans `aurabase`) |
|
|
27
|
-
|
|
28
|
-
Import principal (inchangé) :
|
|
29
|
-
|
|
30
|
-
```ts
|
|
31
|
-
import { createClient } from 'aurabase'
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Import ciblé (tree-shaking / usage avancé) :
|
|
35
|
-
|
|
36
|
-
```ts
|
|
37
|
-
import { AuthService } from '@aurabase/auth'
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Développement (workspace pnpm, à la racine `aurabase-js/`) :
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
pnpm install
|
|
44
|
-
pnpm -r build # build tous les packages (ordre topologique)
|
|
45
|
-
pnpm -r typecheck
|
|
46
|
-
pnpm -r test
|
|
47
|
-
```
|
|
7
|
+
> Pre-release — pas encore publié sur npm.
|
|
48
8
|
|
|
49
9
|
## Installation
|
|
50
10
|
|
|
51
11
|
```bash
|
|
52
|
-
npm
|
|
12
|
+
npm i @aurabase/aurabase-js
|
|
53
13
|
```
|
|
54
14
|
|
|
55
|
-
|
|
15
|
+
## Rôle
|
|
56
16
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
17
|
+
Ce package ne réimplémente aucune logique de service : il compose `AuthService`, `DatabaseService`, `StorageService`, `RealtimeService`, `FunctionsService`, `AiService` et `NotificationsService` (chacun dans son propre package `@aurabase/*`) derrière un seul client.
|
|
18
|
+
|
|
19
|
+
- `createClient(baseUrl, projectId, apiKey, options?)` — client applicatif standard.
|
|
20
|
+
- `createAdminClient(baseUrl, projectId, serviceRoleKey, options?)` — client serveur avec `authAdmin` (clé `service_role`, jamais côté navigateur).
|
|
21
|
+
- `aurabase/ssr` — `createServerClient`/`createBrowserClient` pour Next.js et frameworks SSR (cookies, session partagée serveur/navigateur).
|
|
62
22
|
|
|
63
23
|
## Quick Start
|
|
64
24
|
|
|
65
25
|
```ts
|
|
66
|
-
import { createClient } from 'aurabase'
|
|
26
|
+
import { createClient } from '@aurabase/aurabase-js'
|
|
67
27
|
|
|
68
28
|
const aura = createClient(
|
|
69
29
|
'http://localhost:8080',
|
|
@@ -83,751 +43,22 @@ if (error) {
|
|
|
83
43
|
}
|
|
84
44
|
```
|
|
85
45
|
|
|
86
|
-
##
|
|
87
|
-
|
|
88
|
-
```ts
|
|
89
|
-
import { createClient } from 'aurabase'
|
|
90
|
-
|
|
91
|
-
const aura = createClient(baseUrl, projectId, apiKey)
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Arguments:
|
|
95
|
-
|
|
96
|
-
- `baseUrl`: Aurabase gateway data-plane URL, for example `http://localhost:8080`.
|
|
97
|
-
- `projectId`: project UUID or project identifier used by backend routes.
|
|
98
|
-
- `apiKey`: project API key. Most data-plane operations require it.
|
|
99
|
-
|
|
100
|
-
You can also pass options:
|
|
101
|
-
|
|
102
|
-
```ts
|
|
103
|
-
const aura = createClient('http://localhost:8080', projectId, apiKey, {
|
|
104
|
-
auth: { persistSession: true },
|
|
105
|
-
fetch: customFetch,
|
|
106
|
-
})
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
Alternative form:
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
const aura = createClient('http://localhost:8080', projectId, {
|
|
113
|
-
apiKey,
|
|
114
|
-
auth: { persistSession: false },
|
|
115
|
-
})
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
If no API key is provided, the SDK logs a warning. Public auth routes can still work, but most operations require the `apikey` header.
|
|
119
|
-
|
|
120
|
-
## Response Shape
|
|
121
|
-
|
|
122
|
-
All service methods return an `AuraResponse<T>`:
|
|
123
|
-
|
|
124
|
-
```ts
|
|
125
|
-
type AuraResponse<T> = {
|
|
126
|
-
data: T | null
|
|
127
|
-
error: {
|
|
128
|
-
code: string
|
|
129
|
-
message: string
|
|
130
|
-
details?: unknown
|
|
131
|
-
} | null
|
|
132
|
-
meta?: {
|
|
133
|
-
total?: number
|
|
134
|
-
next_cursor?: string
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
Example:
|
|
140
|
-
|
|
141
|
-
```ts
|
|
142
|
-
const { data, error } = await aura.auth.getUser()
|
|
143
|
-
|
|
144
|
-
if (error) {
|
|
145
|
-
throw new Error(error.message)
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Query builder calls can opt into throwing:
|
|
150
|
-
|
|
151
|
-
```ts
|
|
152
|
-
const { data: post } = await aura.db
|
|
153
|
-
.from('posts')
|
|
154
|
-
.eq('id', postId)
|
|
155
|
-
.single()
|
|
156
|
-
.throwOnError()
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
## Auth
|
|
160
|
-
|
|
161
|
-
The auth service is available at `aura.auth`.
|
|
162
|
-
|
|
163
|
-
### Email And Password
|
|
164
|
-
|
|
165
|
-
```ts
|
|
166
|
-
const signup = await aura.auth.signUp({
|
|
167
|
-
email: 'user@example.com',
|
|
168
|
-
password: 'correct horse battery staple',
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
const login = await aura.auth.signInWithPassword({
|
|
172
|
-
email: 'user@example.com',
|
|
173
|
-
password: 'correct horse battery staple',
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
await aura.auth.signOut()
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
Successful sign-up/sign-in responses save the access token, refresh token and user in the configured auth store.
|
|
180
|
-
|
|
181
|
-
### Session
|
|
182
|
-
|
|
183
|
-
```ts
|
|
184
|
-
const session = await aura.auth.getSession()
|
|
185
|
-
const refreshed = await aura.auth.refreshSession()
|
|
186
|
-
|
|
187
|
-
const sessions = await aura.auth.listSessions()
|
|
188
|
-
await aura.auth.revokeSession('session-id')
|
|
189
|
-
await aura.auth.revokeAllSessions()
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
The SDK performs lazy token refresh before authenticated HTTP requests when the stored access token is near expiry and a refresh token exists.
|
|
193
|
-
|
|
194
|
-
### Auth State
|
|
195
|
-
|
|
196
|
-
```ts
|
|
197
|
-
const subscription = aura.auth.onAuthStateChange(({ event, user }) => {
|
|
198
|
-
console.log(event, user?.email)
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
subscription.unsubscribe()
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
Events currently emitted by the SDK (`AuthChangePayload.event`):
|
|
205
|
-
|
|
206
|
-
- `INITIAL_SESSION` (emitted once on subscribe, Supabase parity)
|
|
207
|
-
- `SIGNED_IN`
|
|
208
|
-
- `SIGNED_OUT`
|
|
209
|
-
- `TOKEN_REFRESHED`
|
|
210
|
-
- `USER_UPDATED`
|
|
211
|
-
- `MFA_CHALLENGE`
|
|
212
|
-
|
|
213
|
-
### User Profile
|
|
214
|
-
|
|
215
|
-
```ts
|
|
216
|
-
const user = await aura.auth.getUser()
|
|
217
|
-
|
|
218
|
-
await aura.auth.updateUser({
|
|
219
|
-
email: 'new@example.com',
|
|
220
|
-
data: { display_name: 'Ada' },
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
await aura.auth.updatePassword('new-password', 'current-password')
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### Magic Links, OTP And Anonymous Auth
|
|
227
|
-
|
|
228
|
-
```ts
|
|
229
|
-
await aura.auth.signInWithMagicLink({
|
|
230
|
-
email: 'user@example.com',
|
|
231
|
-
redirect_url: 'http://localhost:3000/auth/callback',
|
|
232
|
-
})
|
|
233
|
-
|
|
234
|
-
await aura.auth.signInWithEmailOtp('user@example.com')
|
|
235
|
-
await aura.auth.verifyEmailOtp('user@example.com', '123456')
|
|
236
|
-
|
|
237
|
-
await aura.auth.signInWithSmsOtp('+15551234567')
|
|
238
|
-
await aura.auth.verifySmsOtp('+15551234567', '123456')
|
|
239
|
-
|
|
240
|
-
await aura.auth.signInAnonymously()
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### OAuth
|
|
244
|
-
|
|
245
|
-
`signInWithOAuth` always returns `{ url }` in `data` (implicit flow by default), and additionally redirects the browser via `window.location.href` when a `window` is present.
|
|
246
|
-
|
|
247
|
-
```ts
|
|
248
|
-
const { data, error } = await aura.auth.signInWithOAuth('github', {
|
|
249
|
-
redirectTo: 'http://localhost:3000/auth/callback',
|
|
250
|
-
scopes: 'read:user user:email',
|
|
251
|
-
flowType: 'pkce', // opt-in; requires a persistent auth store (LocalAuthStore) in the browser
|
|
252
|
-
})
|
|
253
|
-
|
|
254
|
-
if (error) throw error
|
|
255
|
-
|
|
256
|
-
// Server-side / SSR: no automatic redirect, redirect manually using data!.url
|
|
257
|
-
console.log(data!.url)
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
Native/mobile ID token exchange:
|
|
261
|
-
|
|
262
|
-
```ts
|
|
263
|
-
await aura.auth.signInWithIdToken('google', idToken, accessToken)
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
### MFA
|
|
267
|
-
|
|
268
|
-
```ts
|
|
269
|
-
const enrollment = await aura.auth.mfaEnroll()
|
|
270
|
-
|
|
271
|
-
await aura.auth.mfaVerifySetup('123456')
|
|
272
|
-
|
|
273
|
-
await aura.auth.mfaVerify({
|
|
274
|
-
mfa_token: 'mfa-token-from-login-response',
|
|
275
|
-
code: '123456',
|
|
276
|
-
})
|
|
277
|
-
|
|
278
|
-
await aura.auth.regenerateRecoveryCodes('123456')
|
|
279
|
-
await aura.auth.mfaUnenroll('current-password')
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### Identity Linking
|
|
283
|
-
|
|
284
|
-
```ts
|
|
285
|
-
const identities = await aura.auth.listIdentities()
|
|
286
|
-
const link = await aura.auth.linkIdentity('github')
|
|
287
|
-
await aura.auth.unlinkIdentity('identity-id')
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
## Database
|
|
291
|
-
|
|
292
|
-
The database service is available at `aura.db`.
|
|
293
|
-
|
|
294
|
-
### Select
|
|
295
|
-
|
|
296
|
-
```ts
|
|
297
|
-
const posts = await aura.db
|
|
298
|
-
.from('posts')
|
|
299
|
-
.select('id,title,author_id')
|
|
300
|
-
.eq('published', true)
|
|
301
|
-
.order('created_at', 'desc')
|
|
302
|
-
.limit(20)
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
Supported filters:
|
|
306
|
-
|
|
307
|
-
- `eq(column, value)`
|
|
308
|
-
- `neq(column, value)`
|
|
309
|
-
- `gt(column, value)`
|
|
310
|
-
- `gte(column, value)`
|
|
311
|
-
- `lt(column, value)`
|
|
312
|
-
- `lte(column, value)`
|
|
313
|
-
- `like(column, pattern)`
|
|
314
|
-
- `ilike(column, pattern)`
|
|
315
|
-
- `is(column, 'null' | 'not_null')`
|
|
316
|
-
- `in(column, values)`
|
|
317
|
-
- `or([{ column, op, value }])`
|
|
318
|
-
|
|
319
|
-
Modifiers:
|
|
320
|
-
|
|
321
|
-
- `select(columns)`
|
|
322
|
-
- `order(column, 'asc' | 'desc')`
|
|
323
|
-
- `limit(n)`
|
|
324
|
-
- `offset(n)`
|
|
325
|
-
- `count('exact' | 'estimated')`
|
|
326
|
-
- `single()`
|
|
327
|
-
- `throwOnError()`
|
|
328
|
-
|
|
329
|
-
### Single Row
|
|
330
|
-
|
|
331
|
-
```ts
|
|
332
|
-
const post = await aura.db
|
|
333
|
-
.from('posts')
|
|
334
|
-
.eq('id', 'post-id')
|
|
335
|
-
.single()
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
### Insert, Update, Delete, Upsert
|
|
339
|
-
|
|
340
|
-
```ts
|
|
341
|
-
await aura.db.from('posts').insert({
|
|
342
|
-
title: 'Hello',
|
|
343
|
-
published: false,
|
|
344
|
-
})
|
|
345
|
-
|
|
346
|
-
await aura.db.from('posts').update('post-id', {
|
|
347
|
-
published: true,
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
await aura.db.from('posts').delete('post-id')
|
|
351
|
-
|
|
352
|
-
await aura.db.from('posts').upsert(
|
|
353
|
-
{ id: 'post-id', title: 'Updated' },
|
|
354
|
-
{ onConflict: 'id' },
|
|
355
|
-
)
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
### Raw SQL And Schema
|
|
359
|
-
|
|
360
|
-
```ts
|
|
361
|
-
const rows = await aura.db.sql('SELECT count(*) FROM posts')
|
|
362
|
-
const schema = await aura.db.schema() // { tables, functions }
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
Raw SQL is sent to `POST /v1/db/{project_id}/raw` and is subject to backend validation and rate limiting.
|
|
366
|
-
|
|
367
|
-
### RPC (Postgres Functions)
|
|
368
|
-
|
|
369
|
-
```ts
|
|
370
|
-
const { data: sum } = await aura.db.rpc('add', { a: 1, b: 2 })
|
|
371
|
-
const { data: thing } = await aura.db.rpc('list_things', {}).eq('id', 2).select('id,name').single()
|
|
372
|
-
const { data, meta } = await aura.db.rpc('list_things', {}, { count: 'exact' })
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
`options` accepts `{ count?: 'exact' | 'planned' | 'estimated'; head?: boolean; get?: boolean }`. Typed strictly when `Database['public']['Functions'][fn]` is known (see [Generated Database Types](#generated-database-types)); permissive otherwise. Postgres-only — see [`@aurabase/db` README](packages/db/README.md#fonctions-postgres-rpc) for the full reference.
|
|
376
|
-
|
|
377
|
-
## Storage
|
|
378
|
-
|
|
379
|
-
The storage service is available at `aura.storage`.
|
|
380
|
-
|
|
381
|
-
### Buckets
|
|
382
|
-
|
|
383
|
-
```ts
|
|
384
|
-
const buckets = await aura.storage.listBuckets()
|
|
385
|
-
|
|
386
|
-
await aura.storage.createBucket('avatars', {
|
|
387
|
-
public: true,
|
|
388
|
-
fileSizeLimit: 5 * 1024 * 1024,
|
|
389
|
-
allowedMimeTypes: ['image/png', 'image/jpeg'],
|
|
390
|
-
})
|
|
391
|
-
|
|
392
|
-
const bucket = await aura.storage.getBucket('avatars')
|
|
393
|
-
await aura.storage.deleteBucket('avatars')
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
### Objects
|
|
397
|
-
|
|
398
|
-
```ts
|
|
399
|
-
await aura.storage.upload('avatars', 'users/1.png', file, {
|
|
400
|
-
contentType: 'image/png',
|
|
401
|
-
upsert: true,
|
|
402
|
-
})
|
|
403
|
-
|
|
404
|
-
const files = await aura.storage.list('avatars', {
|
|
405
|
-
prefix: 'users/',
|
|
406
|
-
limit: 100,
|
|
407
|
-
})
|
|
408
|
-
|
|
409
|
-
const blob = await aura.storage.download('avatars', 'users/1.png')
|
|
410
|
-
|
|
411
|
-
await aura.storage.copy('avatars', 'users/1.png', 'archive/1.png')
|
|
412
|
-
await aura.storage.move('avatars', 'archive/1.png', 'users/1.png')
|
|
413
|
-
await aura.storage.remove('avatars', ['users/1.png'])
|
|
414
|
-
|
|
415
|
-
const metadata = await aura.storage.getMetadata('avatars', 'users/1.png')
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
### URLs
|
|
419
|
-
|
|
420
|
-
```ts
|
|
421
|
-
const signed = await aura.storage.createSignedUrl('avatars', 'users/1.png', 600)
|
|
422
|
-
const upload = await aura.storage.createSignedUploadUrl('avatars', 'users/1.png', 300)
|
|
423
|
-
|
|
424
|
-
const publicUrl = aura.storage.getPublicUrl('avatars', 'users/1.png')
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
### Transformations d'image
|
|
428
|
-
|
|
429
|
-
`getPublicUrl()`, `download()` et `createSignedUrl()` acceptent une option `{ transform: ImageTransform }` (`width`/`height`/`resize`/`quality`/`format`) pour un rendu à la volée côté backend (redimensionnement, recadrage, ré-encodage) :
|
|
430
|
-
|
|
431
|
-
```ts
|
|
432
|
-
const thumbnail = aura.storage.getPublicUrl('avatars', 'users/1.png', {
|
|
433
|
-
transform: { width: 200, resize: 'cover' },
|
|
434
|
-
})
|
|
435
|
-
```
|
|
436
|
-
|
|
437
|
-
Détails (flag projet, borne 2500px, `quality` JPEG uniquement, cache serveur des dérivés) : [README `@aurabase/storage`](packages/storage/README.md#transformations-dimage).
|
|
438
|
-
|
|
439
|
-
## Realtime
|
|
440
|
-
|
|
441
|
-
The realtime service is available at `aura.realtime`, and `aura.channel(name)` is a shortcut for `aura.realtime.channel(name)`.
|
|
442
|
-
|
|
443
|
-
```ts
|
|
444
|
-
const unsubscribe = aura.realtime.onStateChange((state) => {
|
|
445
|
-
console.log('realtime state:', state)
|
|
446
|
-
})
|
|
447
|
-
|
|
448
|
-
aura.realtime.connect()
|
|
449
|
-
```
|
|
450
|
-
|
|
451
|
-
Connection states:
|
|
452
|
-
|
|
453
|
-
- `disconnected`
|
|
454
|
-
- `connecting`
|
|
455
|
-
- `connected`
|
|
456
|
-
- `reconnecting`
|
|
457
|
-
|
|
458
|
-
An application-level heartbeat (`ping`) is sent every **25 seconds** via a dedicated Worker to avoid browser timer throttling in background tabs. Automatic reconnection uses exponential backoff with jitter.
|
|
459
|
-
|
|
460
|
-
### Postgres Changes
|
|
461
|
-
|
|
462
|
-
```ts
|
|
463
|
-
const channel = aura.channel('db:public.posts')
|
|
464
|
-
.on(
|
|
465
|
-
'postgres_changes',
|
|
466
|
-
{ event: 'INSERT', schema: 'public', table: 'posts' },
|
|
467
|
-
(payload) => {
|
|
468
|
-
console.log('insert:', payload)
|
|
469
|
-
},
|
|
470
|
-
)
|
|
471
|
-
.subscribe((status, error) => {
|
|
472
|
-
console.log(status, error)
|
|
473
|
-
})
|
|
474
|
-
|
|
475
|
-
aura.realtime.connect()
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
An optional `filter` field (PostgREST/Supabase syntax, `"column=operator.value"`) restricts events to rows matching the condition, e.g. `filter: 'room_id=eq.42'`. Supported operators: `eq, neq, lt, lte, gt, gte, in, like, ilike, is, match, imatch, isdistinct`, negation via `not.` (`status=not.eq.done`), and AND via commas (`room_id=eq.42,qty=gt.5`, commas inside `in.(...)` don't split conditions). Filtering is server-authoritative with a client-side fail-closed fallback; `DELETE` events are matched against the old row. Full reference: [`@aurabase/realtime` README](packages/realtime/README.md#filtres-de-colonne-postgres_changes).
|
|
479
|
-
|
|
480
|
-
### Broadcast
|
|
481
|
-
|
|
482
|
-
```ts
|
|
483
|
-
const channel = aura.realtime.channel('room-1', {
|
|
484
|
-
broadcast: { ack: true, self: true },
|
|
485
|
-
})
|
|
486
|
-
|
|
487
|
-
channel
|
|
488
|
-
.on('broadcast', { event: 'cursor-pos' }, (payload) => {
|
|
489
|
-
console.log(payload)
|
|
490
|
-
})
|
|
491
|
-
.subscribe()
|
|
492
|
-
|
|
493
|
-
aura.realtime.connect()
|
|
494
|
-
|
|
495
|
-
const status = await channel.send({
|
|
496
|
-
type: 'broadcast',
|
|
497
|
-
event: 'cursor-pos',
|
|
498
|
-
payload: { x: 100, y: 200 },
|
|
499
|
-
})
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
`send()` resolves to `ok`, `timeout` or `error`.
|
|
503
|
-
|
|
504
|
-
### Presence
|
|
505
|
-
|
|
506
|
-
```ts
|
|
507
|
-
const channel = aura.channel('room-1', {
|
|
508
|
-
config: { presence: { key: 'user-1' } },
|
|
509
|
-
})
|
|
510
|
-
|
|
511
|
-
channel
|
|
512
|
-
.on('presence', { event: 'sync' }, () => {
|
|
513
|
-
console.log(channel.presenceState())
|
|
514
|
-
})
|
|
515
|
-
.on('presence', { event: 'join' }, console.log)
|
|
516
|
-
.on('presence', { event: 'leave' }, console.log)
|
|
517
|
-
.subscribe()
|
|
518
|
-
|
|
519
|
-
aura.realtime.connect()
|
|
520
|
-
|
|
521
|
-
await channel.track({ online_at: new Date().toISOString() })
|
|
522
|
-
await channel.untrack()
|
|
523
|
-
```
|
|
524
|
-
|
|
525
|
-
### Cleanup
|
|
526
|
-
|
|
527
|
-
```ts
|
|
528
|
-
aura.realtime.removeChannel('room-1')
|
|
529
|
-
aura.realtime.removeAllChannels()
|
|
530
|
-
aura.realtime.disconnect()
|
|
531
|
-
unsubscribe()
|
|
532
|
-
```
|
|
533
|
-
|
|
534
|
-
## Functions
|
|
535
|
-
|
|
536
|
-
The functions service is available at `aura.functions`.
|
|
537
|
-
|
|
538
|
-
```ts
|
|
539
|
-
const result = await aura.functions.invoke('hello', {
|
|
540
|
-
method: 'POST',
|
|
541
|
-
path: '/welcome',
|
|
542
|
-
headers: { 'x-request-source': 'sdk' },
|
|
543
|
-
body: { name: 'Ada' },
|
|
544
|
-
})
|
|
545
|
-
```
|
|
546
|
-
|
|
547
|
-
Management helpers currently exposed by the SDK:
|
|
548
|
-
|
|
549
|
-
```ts
|
|
550
|
-
await aura.functions.list()
|
|
551
|
-
await aura.functions.get('hello')
|
|
552
|
-
|
|
553
|
-
await aura.functions.listJobs({ status: 'pending', limit: 10 })
|
|
554
|
-
await aura.functions.getJob('job-id')
|
|
555
|
-
|
|
556
|
-
await aura.functions.listCronJobs()
|
|
557
|
-
await aura.functions.createCronJob('nightly', '0 0 * * * *', 'hello', {
|
|
558
|
-
payload: { ok: true },
|
|
559
|
-
})
|
|
560
|
-
await aura.functions.deleteCronJob('nightly')
|
|
561
|
-
```
|
|
562
|
-
|
|
563
|
-
## AI
|
|
564
|
-
|
|
565
|
-
The AI service is available at `aura.ai`.
|
|
566
|
-
|
|
567
|
-
```ts
|
|
568
|
-
const chat = await aura.ai.chat([
|
|
569
|
-
{ role: 'system', content: 'Answer briefly.' },
|
|
570
|
-
{ role: 'user', content: 'What is Aurabase?' },
|
|
571
|
-
], {
|
|
572
|
-
temperature: 0.2,
|
|
573
|
-
})
|
|
574
|
-
```
|
|
575
|
-
|
|
576
|
-
Other methods:
|
|
577
|
-
|
|
578
|
-
```ts
|
|
579
|
-
await aura.ai.embed({
|
|
580
|
-
text: 'Aurabase is a BaaS platform.',
|
|
581
|
-
namespace: 'docs',
|
|
582
|
-
metadata: { source: 'readme' },
|
|
583
|
-
})
|
|
584
|
-
|
|
585
|
-
await aura.ai.semanticSearch('auth setup', 'docs', {
|
|
586
|
-
top_k: 5,
|
|
587
|
-
threshold: 0.7,
|
|
588
|
-
})
|
|
589
|
-
|
|
590
|
-
await aura.ai.ragIngest({
|
|
591
|
-
namespace: 'docs',
|
|
592
|
-
content: 'Aurabase uses a Rust gateway.',
|
|
593
|
-
})
|
|
594
|
-
|
|
595
|
-
await aura.ai.rag({
|
|
596
|
-
namespace: 'docs',
|
|
597
|
-
question: 'How does the gateway work?',
|
|
598
|
-
})
|
|
599
|
-
|
|
600
|
-
await aura.ai.nl2sql(
|
|
601
|
-
'How many users signed up today?',
|
|
602
|
-
'users(id uuid, created_at timestamptz)',
|
|
603
|
-
)
|
|
604
|
-
```
|
|
605
|
-
|
|
606
|
-
## Notifications
|
|
46
|
+
## Sous-packages
|
|
607
47
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
```ts
|
|
611
|
-
await aura.notifications.send(
|
|
612
|
-
'email',
|
|
613
|
-
'user@example.com',
|
|
614
|
-
'Welcome to Aurabase',
|
|
615
|
-
{
|
|
616
|
-
subject: 'Welcome',
|
|
617
|
-
variables: { name: 'Ada' },
|
|
618
|
-
},
|
|
619
|
-
)
|
|
620
|
-
|
|
621
|
-
await aura.notifications.list({ limit: 20 })
|
|
622
|
-
await aura.notifications.get('notification-id')
|
|
623
|
-
```
|
|
624
|
-
|
|
625
|
-
Templates:
|
|
626
|
-
|
|
627
|
-
```ts
|
|
628
|
-
await aura.notifications.listTemplates()
|
|
629
|
-
await aura.notifications.getTemplate('template-id')
|
|
630
|
-
|
|
631
|
-
await aura.notifications.createTemplate({
|
|
632
|
-
name: 'welcome',
|
|
633
|
-
channel: 'email',
|
|
634
|
-
subject: 'Welcome',
|
|
635
|
-
body: 'Hello {{ name }}',
|
|
636
|
-
variables: ['name'],
|
|
637
|
-
})
|
|
638
|
-
|
|
639
|
-
await aura.notifications.updateTemplate('template-id', {
|
|
640
|
-
subject: 'New subject',
|
|
641
|
-
})
|
|
642
|
-
|
|
643
|
-
await aura.notifications.deleteTemplate('template-id')
|
|
644
|
-
```
|
|
645
|
-
|
|
646
|
-
## SSR Helpers
|
|
647
|
-
|
|
648
|
-
Import SSR helpers from `aurabase/ssr`.
|
|
649
|
-
|
|
650
|
-
```ts
|
|
651
|
-
import { createServerClient } from 'aurabase/ssr'
|
|
652
|
-
|
|
653
|
-
const aura = createServerClient(baseUrl, projectId, {
|
|
654
|
-
apiKey,
|
|
655
|
-
cookies: {
|
|
656
|
-
getAll: () => request.cookies.getAll(),
|
|
657
|
-
setAll: (cookies) => {
|
|
658
|
-
for (const cookie of cookies) {
|
|
659
|
-
response.cookies.set(cookie.name, cookie.value, cookie.options)
|
|
660
|
-
}
|
|
661
|
-
},
|
|
662
|
-
},
|
|
663
|
-
})
|
|
664
|
-
```
|
|
665
|
-
|
|
666
|
-
Browser helper:
|
|
667
|
-
|
|
668
|
-
```ts
|
|
669
|
-
import { createBrowserClient } from 'aurabase/ssr'
|
|
670
|
-
|
|
671
|
-
const aura = createBrowserClient(baseUrl, projectId, apiKey)
|
|
672
|
-
```
|
|
673
|
-
|
|
674
|
-
Cookie utilities are also exported:
|
|
675
|
-
|
|
676
|
-
```ts
|
|
677
|
-
import { parseCookieHeader, serializeCookieHeader } from 'aurabase/ssr'
|
|
678
|
-
```
|
|
679
|
-
|
|
680
|
-
## Custom Auth Storage
|
|
681
|
-
|
|
682
|
-
By default:
|
|
683
|
-
|
|
684
|
-
- Browser runtime uses `LocalAuthStore` when `localStorage` exists.
|
|
685
|
-
- Node/runtime without `localStorage` uses `BaseAuthStore`.
|
|
686
|
-
- Passing `auth.persistSession: false` uses in-memory storage.
|
|
687
|
-
- Passing `auth.storage` uses your provided `BaseAuthStore` implementation.
|
|
688
|
-
|
|
689
|
-
```ts
|
|
690
|
-
import { BaseAuthStore, createClient } from 'aurabase'
|
|
691
|
-
|
|
692
|
-
const storage = new BaseAuthStore()
|
|
693
|
-
|
|
694
|
-
const aura = createClient(baseUrl, projectId, apiKey, {
|
|
695
|
-
auth: { storage },
|
|
696
|
-
})
|
|
697
|
-
```
|
|
698
|
-
|
|
699
|
-
## Advanced Admin Auth API
|
|
700
|
-
|
|
701
|
-
`AuthAdminService` is exported for advanced usage, but it is not exposed as an `aura.auth.admin` shortcut in the current client.
|
|
702
|
-
|
|
703
|
-
```ts
|
|
704
|
-
import { AuthAdminService, createClient } from 'aurabase'
|
|
705
|
-
|
|
706
|
-
const aura = createClient(baseUrl, projectId, apiKey)
|
|
707
|
-
const authAdmin = new AuthAdminService(aura)
|
|
708
|
-
|
|
709
|
-
await authAdmin.listUsers({ limit: 50 })
|
|
710
|
-
await authAdmin.getSettings()
|
|
711
|
-
```
|
|
712
|
-
|
|
713
|
-
Available admin helpers include user CRUD, ban/unban, magic link generation, audit log, auth settings and email templates.
|
|
714
|
-
|
|
715
|
-
## Headers And Authentication
|
|
716
|
-
|
|
717
|
-
HTTP requests made through service helpers automatically inject:
|
|
718
|
-
|
|
719
|
-
- `apikey: <apiKey>` when the client was created with an API key.
|
|
720
|
-
- `Authorization: Bearer <access_token>` when the auth store has an access token.
|
|
721
|
-
- `Content-Type: application/json` for JSON request bodies.
|
|
722
|
-
|
|
723
|
-
Realtime WebSocket connections send auth through query params because browsers do not support custom WebSocket headers:
|
|
724
|
-
|
|
725
|
-
- `?token=<access_token>`
|
|
726
|
-
- `?apikey=<apiKey>`
|
|
727
|
-
|
|
728
|
-
## Scripts
|
|
729
|
-
|
|
730
|
-
```bash
|
|
731
|
-
npm run build # build ESM/CJS/types with tsup
|
|
732
|
-
npm run typecheck # run TypeScript without emitting files
|
|
733
|
-
npm run test # run Vitest once
|
|
734
|
-
npm run test:watch # run Vitest in watch mode
|
|
735
|
-
```
|
|
736
|
-
|
|
737
|
-
## Exports
|
|
738
|
-
|
|
739
|
-
Root export:
|
|
740
|
-
|
|
741
|
-
```ts
|
|
742
|
-
import {
|
|
743
|
-
createClient,
|
|
744
|
-
AuraClient,
|
|
745
|
-
AuraError,
|
|
746
|
-
isAuraError,
|
|
747
|
-
BaseAuthStore,
|
|
748
|
-
LocalAuthStore,
|
|
749
|
-
QueryBuilder,
|
|
750
|
-
} from 'aurabase'
|
|
751
|
-
```
|
|
752
|
-
|
|
753
|
-
Service classes and public types are also exported from the root package.
|
|
754
|
-
|
|
755
|
-
SSR export:
|
|
756
|
-
|
|
757
|
-
```ts
|
|
758
|
-
import {
|
|
759
|
-
createServerClient,
|
|
760
|
-
createBrowserClient,
|
|
761
|
-
parseCookieHeader,
|
|
762
|
-
serializeCookieHeader,
|
|
763
|
-
} from 'aurabase/ssr'
|
|
764
|
-
```
|
|
765
|
-
|
|
766
|
-
## Generated Database Types
|
|
767
|
-
|
|
768
|
-
Database types are not hand-written: generate them from your project's live schema with the `@aurabase/gen` CLI, then pass them to `createClient<Database>` for typed `select()`/`insert()`/`update()`.
|
|
769
|
-
|
|
770
|
-
```bash
|
|
771
|
-
npm i -D @aurabase/gen
|
|
772
|
-
|
|
773
|
-
npx aurabase-gen \
|
|
774
|
-
--url http://localhost:8080 \
|
|
775
|
-
--project my-project \
|
|
776
|
-
--key aura_anon_xxx \
|
|
777
|
-
--out database.types.ts \
|
|
778
|
-
--schema public \
|
|
779
|
-
--type-name Database
|
|
780
|
-
```
|
|
781
|
-
|
|
782
|
-
```ts
|
|
783
|
-
import { createClient } from 'aurabase'
|
|
784
|
-
import type { Database } from './database.types' // generated by @aurabase/gen
|
|
785
|
-
|
|
786
|
-
const aura = createClient<Database>('http://localhost:8080', 'my-project', 'aura_anon_xxx')
|
|
787
|
-
|
|
788
|
-
// select()/insert()/update() are now inferred from the real columns of `posts`.
|
|
789
|
-
const { data } = await aura.db.from('posts').select('id,title').eq('id', 'post-id').single()
|
|
790
|
-
```
|
|
791
|
-
|
|
792
|
-
`Functions` is now generated from the project's Postgres functions (used by `db.rpc()` for strict `args` typing and scalar return typing). Generated `SetofOptions.to` is a placeholder that never matches a real table — `@aurabase/gen` doesn't resolve which table a `SETOF` return actually targets — so a SETOF function's `.select()` falls back to `Record<string, unknown>[]`. Strict column-level typing of a SETOF return requires a hand-written `Database` type with `SetofOptions.to` pointing at a real table. `Views`, `Enums` and `CompositeTypes` are still always generated empty (`Record<string, never>`) — only `Tables` and `Functions` are introspected today. Full CLI reference and limitations: [`@aurabase/gen` README](packages/gen/README.md).
|
|
793
|
-
|
|
794
|
-
## Current Limitations
|
|
795
|
-
|
|
796
|
-
- `rpc()` is Postgres-only — not available on projects using MongoDB as the database engine (`aura.db.schema()` returns `functions: []` there).
|
|
797
|
-
- No streaming responses (functions invocation and AI chat/RAG are request/response, not streamed).
|
|
798
|
-
- No client-side query transforms/composition helpers beyond the `QueryBuilder` filters/modifiers listed above (parité postgrest-js partielle : pas de `range()`, `csv()`, `geojson()`, `explain()`, `abortSignal()`, `returns()`).
|
|
799
|
-
- `AuthAdminService` is available via `client.authAdmin` (browser guard warns) or `createAdminClient()` (server-only, requires a `service_role` key).
|
|
800
|
-
- Realtime requires a runtime with `WebSocket`.
|
|
801
|
-
- File upload APIs require `FormData` and `Blob` support.
|
|
802
|
-
- API behavior depends on the running Aurabase backend and project permissions.
|
|
803
|
-
|
|
804
|
-
## Package Documentation
|
|
805
|
-
|
|
806
|
-
Each package below has its own README with detailed usage, limitations and links back here:
|
|
807
|
-
|
|
808
|
-
| Package | README |
|
|
48
|
+
| Package | Contenu |
|
|
809
49
|
|---|---|
|
|
810
|
-
|
|
|
811
|
-
| `@aurabase/
|
|
812
|
-
| `@aurabase/
|
|
813
|
-
| `@aurabase/
|
|
814
|
-
| `@aurabase/
|
|
815
|
-
| `@aurabase/
|
|
816
|
-
| `@aurabase/
|
|
817
|
-
| `@aurabase/
|
|
818
|
-
| `@aurabase/
|
|
819
|
-
| `@aurabase/gen` | [packages/gen/README.md](packages/gen/README.md) |
|
|
50
|
+
| [`@aurabase/core`](../core) | fetch, erreurs, types, stores, `BaseService`, interface `AuraClientLike` |
|
|
51
|
+
| [`@aurabase/auth`](../auth) | `AuthService`, `AuthAdminService` |
|
|
52
|
+
| [`@aurabase/db`](../db) | `DatabaseService`, `QueryBuilder` |
|
|
53
|
+
| [`@aurabase/storage`](../storage) | `StorageService` |
|
|
54
|
+
| [`@aurabase/realtime`](../realtime) | `RealtimeService`, `AuraChannel`, `HeartbeatManager` |
|
|
55
|
+
| [`@aurabase/functions`](../functions) | `FunctionsService` |
|
|
56
|
+
| [`@aurabase/ai`](../ai) | `AiService` |
|
|
57
|
+
| [`@aurabase/notifications`](../notifications) | `NotificationsService`, `NotificationsAdminService` |
|
|
58
|
+
| [`@aurabase/gen`](../gen) | générateur CLI de types `Database` (dev-dependency, non inclus dans `aurabase`) |
|
|
820
59
|
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
This monorepo uses [Changesets](https://github.com/changesets/changesets) to version and publish packages.
|
|
824
|
-
|
|
825
|
-
```bash
|
|
826
|
-
pnpm changeset # describe the change (bump type + summary) — run per PR/feature
|
|
827
|
-
pnpm changeset version # consume changesets, bump package.json versions, update changelogs
|
|
828
|
-
git add . && git commit -m "chore: version packages"
|
|
829
|
-
```
|
|
60
|
+
Tous ces packages (hors `@aurabase/gen`) sont des dépendances directes de `aurabase` : les installer séparément n'est utile que pour du tree-shaking ciblé ou pour composer votre propre client.
|
|
830
61
|
|
|
831
|
-
|
|
62
|
+
## Documentation
|
|
832
63
|
|
|
833
|
-
|
|
64
|
+
Cette page ne couvre que le rôle du package d'agrégation. Documentation de référence complète : voir le [README du dépôt](../../README.md).
|