@aurabase/aurabase-js 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +26 -795
  2. package/{packages/aurabase/dist/AuraClient-DAtDbfPB.d.ts → dist/AuraClient-BcFE8u1v.d.cts} +1 -1
  3. package/{packages/aurabase/dist/AuraClient-DAtDbfPB.d.cts → dist/AuraClient-BcFE8u1v.d.ts} +1 -1
  4. package/{packages/aurabase/dist → dist}/index.d.cts +1 -1
  5. package/{packages/aurabase/dist → dist}/index.d.ts +1 -1
  6. package/{packages/aurabase/dist → dist}/ssr.d.cts +1 -1
  7. package/{packages/aurabase/dist → dist}/ssr.d.ts +1 -1
  8. package/package.json +74 -82
  9. package/.changeset/config.json +0 -11
  10. package/CHANGELOG.md +0 -30
  11. package/packages/ai/LICENSE +0 -21
  12. package/packages/ai/README.md +0 -106
  13. package/packages/ai/dist/index.cjs +0 -229
  14. package/packages/ai/dist/index.d.cts +0 -139
  15. package/packages/ai/dist/index.d.ts +0 -139
  16. package/packages/ai/dist/index.js +0 -226
  17. package/packages/ai/package.json +0 -61
  18. package/packages/aurabase/LICENSE +0 -21
  19. package/packages/aurabase/README.md +0 -64
  20. package/packages/aurabase/package.json +0 -80
  21. package/packages/aurabase/vitest.e2e.config.ts +0 -9
  22. package/packages/auth/LICENSE +0 -21
  23. package/packages/auth/README.md +0 -215
  24. package/packages/auth/dist/index.cjs +0 -1175
  25. package/packages/auth/dist/index.d.cts +0 -397
  26. package/packages/auth/dist/index.d.ts +0 -397
  27. package/packages/auth/dist/index.js +0 -1170
  28. package/packages/auth/package.json +0 -61
  29. package/packages/core/LICENSE +0 -21
  30. package/packages/core/README.md +0 -132
  31. package/packages/core/dist/index.cjs +0 -695
  32. package/packages/core/dist/index.d.cts +0 -1137
  33. package/packages/core/dist/index.d.ts +0 -1137
  34. package/packages/core/dist/index.js +0 -673
  35. package/packages/core/package.json +0 -57
  36. package/packages/db/LICENSE +0 -21
  37. package/packages/db/README.md +0 -152
  38. package/packages/db/VENDORED.md +0 -93
  39. package/packages/db/dist/index.cjs +0 -544
  40. package/packages/db/dist/index.d.cts +0 -1111
  41. package/packages/db/dist/index.d.ts +0 -1111
  42. package/packages/db/dist/index.js +0 -541
  43. package/packages/db/package.json +0 -62
  44. package/packages/functions/LICENSE +0 -21
  45. package/packages/functions/README.md +0 -96
  46. package/packages/functions/dist/index.cjs +0 -173
  47. package/packages/functions/dist/index.d.cts +0 -81
  48. package/packages/functions/dist/index.d.ts +0 -81
  49. package/packages/functions/dist/index.js +0 -168
  50. package/packages/functions/package.json +0 -60
  51. package/packages/gen/LICENSE +0 -21
  52. package/packages/gen/README.md +0 -84
  53. package/packages/gen/dist/cli.cjs +0 -334
  54. package/packages/gen/dist/cli.d.cts +0 -1
  55. package/packages/gen/dist/cli.d.ts +0 -1
  56. package/packages/gen/dist/cli.js +0 -332
  57. package/packages/gen/dist/index.cjs +0 -257
  58. package/packages/gen/dist/index.d.cts +0 -12
  59. package/packages/gen/dist/index.d.ts +0 -12
  60. package/packages/gen/dist/index.js +0 -255
  61. package/packages/gen/package.json +0 -66
  62. package/packages/notifications/LICENSE +0 -21
  63. package/packages/notifications/README.md +0 -134
  64. package/packages/notifications/dist/index.cjs +0 -128
  65. package/packages/notifications/dist/index.d.cts +0 -81
  66. package/packages/notifications/dist/index.d.ts +0 -81
  67. package/packages/notifications/dist/index.js +0 -125
  68. package/packages/notifications/package.json +0 -60
  69. package/packages/realtime/LICENSE +0 -21
  70. package/packages/realtime/README.md +0 -183
  71. package/packages/realtime/dist/index.cjs +0 -977
  72. package/packages/realtime/dist/index.d.cts +0 -259
  73. package/packages/realtime/dist/index.d.ts +0 -259
  74. package/packages/realtime/dist/index.js +0 -973
  75. package/packages/realtime/package.json +0 -60
  76. package/packages/storage/LICENSE +0 -21
  77. package/packages/storage/README.md +0 -141
  78. package/packages/storage/dist/index.cjs +0 -333
  79. package/packages/storage/dist/index.d.cts +0 -185
  80. package/packages/storage/dist/index.d.ts +0 -185
  81. package/packages/storage/dist/index.js +0 -329
  82. package/packages/storage/package.json +0 -60
  83. /package/{packages/aurabase/dist → dist}/index.cjs +0 -0
  84. /package/{packages/aurabase/dist → dist}/index.js +0 -0
  85. /package/{packages/aurabase/dist → dist}/ssr.cjs +0 -0
  86. /package/{packages/aurabase/dist → dist}/ssr.js +0 -0
package/README.md CHANGED
@@ -1,69 +1,29 @@
1
- # Aurabase JavaScript SDK
1
+ # aurabase
2
2
 
3
- ![npm](https://img.shields.io/npm/v/aurabase) ![license](https://img.shields.io/badge/license-MIT-blue) ![node](https://img.shields.io/badge/node-%3E%3D20-brightgreen) ![TypeScript](https://img.shields.io/badge/TypeScript-5-blue)
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
- > **Pre-release — not yet published to npm.** Version numbers and badges above reflect the workspace version; there is no published `aurabase` package yet.
5
+ ![npm](https://img.shields.io/npm/v/aurabase) ![license](https://img.shields.io/badge/license-MIT-blue)
6
6
 
7
- Official JavaScript/TypeScript client for Aurabase.
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 install aurabase
12
+ npm i @aurabase/aurabase-js
53
13
  ```
54
14
 
55
- For local development inside this repository:
15
+ ## Rôle
56
16
 
57
- ```bash
58
- cd aurabase-js
59
- npm install
60
- npm run build
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
- ## Client Creation
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
- The notifications service is available at `aura.notifications`.
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
- | `aurabase` (meta) | [packages/aurabase/README.md](packages/aurabase/README.md) |
811
- | `@aurabase/core` | [packages/core/README.md](packages/core/README.md) |
812
- | `@aurabase/auth` | [packages/auth/README.md](packages/auth/README.md) |
813
- | `@aurabase/db` | [packages/db/README.md](packages/db/README.md) |
814
- | `@aurabase/storage` | [packages/storage/README.md](packages/storage/README.md) |
815
- | `@aurabase/realtime` | [packages/realtime/README.md](packages/realtime/README.md) |
816
- | `@aurabase/functions` | [packages/functions/README.md](packages/functions/README.md) |
817
- | `@aurabase/ai` | [packages/ai/README.md](packages/ai/README.md) |
818
- | `@aurabase/notifications` | [packages/notifications/README.md](packages/notifications/README.md) |
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
- ## Releases & Versioning
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
- Release history: [CHANGELOG.md](./CHANGELOG.md).
62
+ ## Documentation
832
63
 
833
- Note: `.changeset/config.json` currently has `"access": "restricted"` — switch it to `"public"` before the first npm publish (all `@aurabase/*` packages and `aurabase` are meant to be public, scoped packages).
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).