@aurabase/aurabase-js 0.3.0 → 0.3.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 (258) hide show
  1. package/package.json +4 -4
  2. package/packages/ai/node_modules/.bin/esbuild +0 -19
  3. package/packages/ai/node_modules/.bin/tsc +0 -22
  4. package/packages/ai/node_modules/.bin/tsserver +0 -22
  5. package/packages/ai/node_modules/.bin/tsup +0 -22
  6. package/packages/ai/node_modules/.bin/tsup-node +0 -22
  7. package/packages/ai/node_modules/.bin/vite +0 -22
  8. package/packages/ai/node_modules/.bin/vitest +0 -22
  9. package/packages/ai/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  10. package/packages/ai/src/AiService.ts +0 -226
  11. package/packages/ai/src/index.ts +0 -18
  12. package/packages/ai/src/sse.ts +0 -141
  13. package/packages/ai/src/types.ts +0 -30
  14. package/packages/ai/tests/chat-stream.test.ts +0 -151
  15. package/packages/ai/tests/rag-namespaces.test.ts +0 -54
  16. package/packages/ai/tests/sse.test.ts +0 -69
  17. package/packages/ai/tsconfig.json +0 -5
  18. package/packages/ai/tsup.config.ts +0 -11
  19. package/packages/aurabase/node_modules/.bin/esbuild +0 -19
  20. package/packages/aurabase/node_modules/.bin/tsc +0 -22
  21. package/packages/aurabase/node_modules/.bin/tsserver +0 -22
  22. package/packages/aurabase/node_modules/.bin/tsup +0 -22
  23. package/packages/aurabase/node_modules/.bin/tsup-node +0 -22
  24. package/packages/aurabase/node_modules/.bin/vite +0 -22
  25. package/packages/aurabase/node_modules/.bin/vitest +0 -22
  26. package/packages/aurabase/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  27. package/packages/aurabase/src/AuraClient.ts +0 -237
  28. package/packages/aurabase/src/index.ts +0 -152
  29. package/packages/aurabase/src/ssr.ts +0 -156
  30. package/packages/aurabase/tests/ai-streaming-rag-e2e.test.ts +0 -82
  31. package/packages/aurabase/tests/ai.test.ts +0 -111
  32. package/packages/aurabase/tests/auth-admin.test.ts +0 -515
  33. package/packages/aurabase/tests/auth-e2e.test.ts +0 -135
  34. package/packages/aurabase/tests/auth-hardening.test.ts +0 -206
  35. package/packages/aurabase/tests/auth.test.ts +0 -947
  36. package/packages/aurabase/tests/database.test.ts +0 -230
  37. package/packages/aurabase/tests/db-types-e2e.test.ts +0 -217
  38. package/packages/aurabase/tests/dispose.test.ts +0 -23
  39. package/packages/aurabase/tests/foreign-token.e2e.test.ts +0 -129
  40. package/packages/aurabase/tests/functions.test.ts +0 -107
  41. package/packages/aurabase/tests/integration.test.ts +0 -413
  42. package/packages/aurabase/tests/live-production-validation.js +0 -241
  43. package/packages/aurabase/tests/live-sdk-production-validation.js +0 -293
  44. package/packages/aurabase/tests/mocks.ts +0 -139
  45. package/packages/aurabase/tests/notifications.test.ts +0 -314
  46. package/packages/aurabase/tests/observability-backup.test.ts +0 -186
  47. package/packages/aurabase/tests/observability-hook.test.ts +0 -130
  48. package/packages/aurabase/tests/production-robustness.test.ts +0 -268
  49. package/packages/aurabase/tests/public-api-surface.test.ts +0 -53
  50. package/packages/aurabase/tests/query-builder.test.ts +0 -329
  51. package/packages/aurabase/tests/readme-smoke-e2e.test.ts +0 -231
  52. package/packages/aurabase/tests/realtime-filter-e2e.test.ts +0 -344
  53. package/packages/aurabase/tests/refresh-locks.test.ts +0 -210
  54. package/packages/aurabase/tests/retry-option.test.ts +0 -17
  55. package/packages/aurabase/tests/rpc-e2e.test.ts +0 -254
  56. package/packages/aurabase/tests/rs256-local-e2e.test.ts +0 -114
  57. package/packages/aurabase/tests/rt-alias-public-e2e.test.ts +0 -235
  58. package/packages/aurabase/tests/rt-http-broadcast-e2e.test.ts +0 -124
  59. package/packages/aurabase/tests/service-role-guard.test.ts +0 -99
  60. package/packages/aurabase/tests/ssr.test.ts +0 -91
  61. package/packages/aurabase/tests/storage-backend-e2e.test.ts +0 -481
  62. package/packages/aurabase/tests/storage-sdk-parity-e2e.test.ts +0 -104
  63. package/packages/aurabase/tests/storage-transform-e2e.test.ts +0 -684
  64. package/packages/aurabase/tests/storage.test.ts +0 -55
  65. package/packages/aurabase/tests/types/client-generic.test-d.ts +0 -79
  66. package/packages/aurabase/tests/types/docs-snippets.test-d.ts +0 -571
  67. package/packages/aurabase/tests/types/error-code.test-d.ts +0 -53
  68. package/packages/aurabase/tsconfig.json +0 -5
  69. package/packages/aurabase/tsconfig.test-d.json +0 -5
  70. package/packages/aurabase/tsup.config.ts +0 -11
  71. package/packages/aurabase/vitest.config.ts +0 -16
  72. package/packages/auth/node_modules/.bin/esbuild +0 -19
  73. package/packages/auth/node_modules/.bin/tsc +0 -22
  74. package/packages/auth/node_modules/.bin/tsserver +0 -22
  75. package/packages/auth/node_modules/.bin/tsup +0 -22
  76. package/packages/auth/node_modules/.bin/tsup-node +0 -22
  77. package/packages/auth/node_modules/.bin/vite +0 -22
  78. package/packages/auth/node_modules/.bin/vitest +0 -22
  79. package/packages/auth/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  80. package/packages/auth/src/AuthAdminService.ts +0 -149
  81. package/packages/auth/src/AuthService.ts +0 -1166
  82. package/packages/auth/src/SessionManager.ts +0 -92
  83. package/packages/auth/src/index.ts +0 -17
  84. package/packages/auth/src/jwks.ts +0 -337
  85. package/packages/auth/src/pkce.ts +0 -27
  86. package/packages/auth/src/types.ts +0 -89
  87. package/packages/auth/tests/auth-lifecycle.test.ts +0 -149
  88. package/packages/auth/tests/detect-session.test.ts +0 -361
  89. package/packages/auth/tests/getclaims.test.ts +0 -780
  90. package/packages/auth/tests/is-mfa-challenge.test.ts +0 -27
  91. package/packages/auth/tests/password-recovery.test.ts +0 -124
  92. package/packages/auth/tests/pkce.test.ts +0 -192
  93. package/packages/auth/tests/session-manager.test.ts +0 -103
  94. package/packages/auth/tests/set-session.test.ts +0 -139
  95. package/packages/auth/tests/verify-otp.test.ts +0 -153
  96. package/packages/auth/tsconfig.json +0 -5
  97. package/packages/auth/tsup.config.ts +0 -11
  98. package/packages/core/node_modules/.bin/esbuild +0 -22
  99. package/packages/core/node_modules/.bin/tsc +0 -22
  100. package/packages/core/node_modules/.bin/tsserver +0 -22
  101. package/packages/core/node_modules/.bin/tsup +0 -22
  102. package/packages/core/node_modules/.bin/tsup-node +0 -22
  103. package/packages/core/node_modules/.bin/vite +0 -22
  104. package/packages/core/node_modules/.bin/vitest +0 -22
  105. package/packages/core/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  106. package/packages/core/src/AuraError.ts +0 -89
  107. package/packages/core/src/BaseService.ts +0 -44
  108. package/packages/core/src/client.ts +0 -34
  109. package/packages/core/src/cookie-utils.ts +0 -42
  110. package/packages/core/src/fetch.ts +0 -435
  111. package/packages/core/src/index.ts +0 -22
  112. package/packages/core/src/retry.ts +0 -63
  113. package/packages/core/src/serialize.ts +0 -6
  114. package/packages/core/src/stores/BaseAuthStore.ts +0 -164
  115. package/packages/core/src/stores/LocalAuthStore.ts +0 -199
  116. package/packages/core/src/types.ts +0 -1042
  117. package/packages/core/tests/auth-store.test.ts +0 -300
  118. package/packages/core/tests/error-code.test.ts +0 -61
  119. package/packages/core/tests/error.test.ts +0 -24
  120. package/packages/core/tests/fetch.test.ts +0 -286
  121. package/packages/core/tests/mocks.ts +0 -139
  122. package/packages/core/tests/observability.test.ts +0 -86
  123. package/packages/core/tests/refresh-hardening.test.ts +0 -164
  124. package/packages/core/tests/refresh-observability.test.ts +0 -111
  125. package/packages/core/tests/retry.test.ts +0 -106
  126. package/packages/core/tests/serialize.test.ts +0 -12
  127. package/packages/core/tests/timeout.test.ts +0 -79
  128. package/packages/core/tsconfig.json +0 -5
  129. package/packages/core/tsup.config.ts +0 -11
  130. package/packages/db/node_modules/.bin/esbuild +0 -19
  131. package/packages/db/node_modules/.bin/tsc +0 -22
  132. package/packages/db/node_modules/.bin/tsserver +0 -22
  133. package/packages/db/node_modules/.bin/tsup +0 -22
  134. package/packages/db/node_modules/.bin/tsup-node +0 -22
  135. package/packages/db/node_modules/.bin/vite +0 -22
  136. package/packages/db/node_modules/.bin/vitest +0 -22
  137. package/packages/db/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  138. package/packages/db/src/DatabaseService.ts +0 -170
  139. package/packages/db/src/QueryBuilder.ts +0 -830
  140. package/packages/db/src/index.ts +0 -2
  141. package/packages/db/src/pgrst-types/common/common.ts +0 -86
  142. package/packages/db/src/pgrst-types/common/rpc.ts +0 -151
  143. package/packages/db/src/pgrst-types/feature-flags.ts +0 -20
  144. package/packages/db/src/pgrst-types/types.ts +0 -134
  145. package/packages/db/src/select-query-parser/parser.ts +0 -479
  146. package/packages/db/src/select-query-parser/result.ts +0 -553
  147. package/packages/db/src/select-query-parser/types.ts +0 -132
  148. package/packages/db/src/select-query-parser/utils.ts +0 -707
  149. package/packages/db/tests/filters.test.ts +0 -81
  150. package/packages/db/tests/mutations-filtered.e2e.test.ts +0 -132
  151. package/packages/db/tests/mutations-filtered.test.ts +0 -188
  152. package/packages/db/tests/order.test.ts +0 -45
  153. package/packages/db/tests/rpc.test.ts +0 -41
  154. package/packages/db/tests/scale/build-large-schema.ts +0 -94
  155. package/packages/db/tests/scale/scale-compile.test.ts +0 -167
  156. package/packages/db/tests/schema.test.ts +0 -77
  157. package/packages/db/tests/single-accept.e2e.test.ts +0 -123
  158. package/packages/db/tests/single.test.ts +0 -211
  159. package/packages/db/tests/types/filters.test-d.ts +0 -52
  160. package/packages/db/tests/types/fixtures.ts +0 -40
  161. package/packages/db/tests/types/from-views.test-d.ts +0 -18
  162. package/packages/db/tests/types/mutations.test-d.ts +0 -23
  163. package/packages/db/tests/types/rpc.test-d.ts +0 -60
  164. package/packages/db/tests/types/schema-shape.test-d.ts +0 -8
  165. package/packages/db/tests/types/select-inference.test-d.ts +0 -38
  166. package/packages/db/tests/vendored/fixtures.ts +0 -83
  167. package/packages/db/tests/vendored/get-result.test-d.ts +0 -75
  168. package/packages/db/tsconfig.json +0 -5
  169. package/packages/db/tsconfig.test-d.json +0 -5
  170. package/packages/db/tsup.config.ts +0 -11
  171. package/packages/db/vitest.config.ts +0 -8
  172. package/packages/functions/node_modules/.bin/esbuild +0 -19
  173. package/packages/functions/node_modules/.bin/tsc +0 -22
  174. package/packages/functions/node_modules/.bin/tsserver +0 -22
  175. package/packages/functions/node_modules/.bin/tsup +0 -22
  176. package/packages/functions/node_modules/.bin/tsup-node +0 -22
  177. package/packages/functions/node_modules/.bin/vite +0 -22
  178. package/packages/functions/node_modules/.bin/vitest +0 -22
  179. package/packages/functions/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  180. package/packages/functions/src/FunctionsService.ts +0 -188
  181. package/packages/functions/src/errors.ts +0 -70
  182. package/packages/functions/src/index.ts +0 -6
  183. package/packages/functions/tests/invoke.test.ts +0 -97
  184. package/packages/functions/tests/response-type-errors.test.ts +0 -135
  185. package/packages/functions/tsconfig.json +0 -5
  186. package/packages/functions/tsup.config.ts +0 -11
  187. package/packages/gen/node_modules/.bin/esbuild +0 -19
  188. package/packages/gen/node_modules/.bin/tsc +0 -22
  189. package/packages/gen/node_modules/.bin/tsserver +0 -22
  190. package/packages/gen/node_modules/.bin/tsup +0 -22
  191. package/packages/gen/node_modules/.bin/tsup-node +0 -22
  192. package/packages/gen/node_modules/.bin/vite +0 -22
  193. package/packages/gen/node_modules/.bin/vitest +0 -22
  194. package/packages/gen/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  195. package/packages/gen/src/cli.ts +0 -67
  196. package/packages/gen/src/generate.ts +0 -0
  197. package/packages/gen/src/index.ts +0 -2
  198. package/packages/gen/tests/compile.test.ts +0 -213
  199. package/packages/gen/tests/e2e.test.ts +0 -130
  200. package/packages/gen/tests/generate.test.ts +0 -396
  201. package/packages/gen/tsconfig.json +0 -5
  202. package/packages/gen/tsup.config.ts +0 -11
  203. package/packages/notifications/node_modules/.bin/esbuild +0 -19
  204. package/packages/notifications/node_modules/.bin/tsc +0 -22
  205. package/packages/notifications/node_modules/.bin/tsserver +0 -22
  206. package/packages/notifications/node_modules/.bin/tsup +0 -22
  207. package/packages/notifications/node_modules/.bin/tsup-node +0 -22
  208. package/packages/notifications/node_modules/.bin/vite +0 -22
  209. package/packages/notifications/node_modules/.bin/vitest +0 -22
  210. package/packages/notifications/src/NotificationsService.ts +0 -230
  211. package/packages/notifications/src/index.ts +0 -19
  212. package/packages/notifications/tsconfig.json +0 -5
  213. package/packages/notifications/tsup.config.ts +0 -11
  214. package/packages/realtime/node_modules/.bin/esbuild +0 -19
  215. package/packages/realtime/node_modules/.bin/tsc +0 -22
  216. package/packages/realtime/node_modules/.bin/tsserver +0 -22
  217. package/packages/realtime/node_modules/.bin/tsup +0 -22
  218. package/packages/realtime/node_modules/.bin/tsup-node +0 -22
  219. package/packages/realtime/node_modules/.bin/vite +0 -22
  220. package/packages/realtime/node_modules/.bin/vitest +0 -22
  221. package/packages/realtime/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  222. package/packages/realtime/src/AuraChannel.ts +0 -485
  223. package/packages/realtime/src/HeartbeatManager.ts +0 -73
  224. package/packages/realtime/src/RealtimeService.ts +0 -505
  225. package/packages/realtime/src/columnFilter.ts +0 -301
  226. package/packages/realtime/src/index.ts +0 -4
  227. package/packages/realtime/tests/ack-routing.test.ts +0 -81
  228. package/packages/realtime/tests/column-filter.test.ts +0 -144
  229. package/packages/realtime/tests/dispatch.test.ts +0 -191
  230. package/packages/realtime/tests/heartbeat.test.ts +0 -67
  231. package/packages/realtime/tests/http-broadcast.test.ts +0 -68
  232. package/packages/realtime/tests/realtime-token.test.ts +0 -43
  233. package/packages/realtime/tests/reconnect-race.test.ts +0 -149
  234. package/packages/realtime/tests/ref-id.test.ts +0 -34
  235. package/packages/realtime/tests/set-auth.test.ts +0 -70
  236. package/packages/realtime/tsconfig.json +0 -5
  237. package/packages/realtime/tsup.config.ts +0 -11
  238. package/packages/storage/node_modules/.bin/esbuild +0 -19
  239. package/packages/storage/node_modules/.bin/tsc +0 -22
  240. package/packages/storage/node_modules/.bin/tsserver +0 -22
  241. package/packages/storage/node_modules/.bin/tsup +0 -22
  242. package/packages/storage/node_modules/.bin/tsup-node +0 -22
  243. package/packages/storage/node_modules/.bin/vite +0 -22
  244. package/packages/storage/node_modules/.bin/vitest +0 -22
  245. package/packages/storage/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  246. package/packages/storage/src/DownloadBuilder.ts +0 -60
  247. package/packages/storage/src/StorageService.ts +0 -323
  248. package/packages/storage/src/index.ts +0 -2
  249. package/packages/storage/src/path.ts +0 -35
  250. package/packages/storage/src/transform.ts +0 -15
  251. package/packages/storage/tests/download.test.ts +0 -64
  252. package/packages/storage/tests/parity.test.ts +0 -154
  253. package/packages/storage/tests/path.test.ts +0 -87
  254. package/packages/storage/tests/transform.test.ts +0 -79
  255. package/packages/storage/tsconfig.json +0 -5
  256. package/packages/storage/tsup.config.ts +0 -11
  257. package/pnpm-workspace.yaml +0 -24
  258. package/tsconfig.base.json +0 -15
@@ -1,571 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Compile-check des snippets README — Task 6 (chantier H, DX).
3
- //
4
- // Ce fichier ne s'EXÉCUTE jamais (aucun test vitest ici, uniquement des
5
- // fonctions `async function _x() {}` jamais appelées) : il est ramassé par
6
- // `tsconfig.test-d.json` (include: `tests/**/*.test-d.ts`) et compilé par
7
- // `pnpm test:types` (`tsc --noEmit`). Le but est de reproduire fidèlement les
8
- // PRINCIPAUX snippets documentés dans les README des 7 packages de service
9
- // (auth, db, storage, realtime, functions, ai, notifications) pour qu'une
10
- // dérive doc ↔ code réel (renommage de méthode, signature changée, type de
11
- // retour modifié) casse la compilation ici plutôt que d'atteindre un
12
- // utilisateur qui copie-colle la doc. `@aurabase/core` et `@aurabase/gen`
13
- // (infrastructure / outil CLI, pas des services `aura.*`) sont hors périmètre
14
- // de ce fichier — leurs snippets ne s'expriment pas via `aura.<service>.*`.
15
- //
16
- // Règle (cf. brief Task 6) : un snippet qui ne compile pas est un bug de
17
- // README à corriger dans le README source — ne JAMAIS assouplir le snippet
18
- // ici pour le faire passer artificiellement.
19
- // ---------------------------------------------------------------------------
20
-
21
- import { createClient, createAdminClient } from '../../src/index'
22
- import type { AuthChangePayload } from '../../src/index'
23
- // `ImageTransform` n'est pas ré-exporté par le package `aurabase` (surface publique
24
- // actuelle) — importé directement depuis `@aurabase/core` (dépendance directe du
25
- // package `aurabase`) uniquement pour typer ce snippet de compile-check, cf. README
26
- // storage § "Transformations d'image".
27
- import type { ImageTransform } from '@aurabase/core'
28
-
29
- // Fixture `Database` minimale, cohérente avec la sortie de `@aurabase/gen`
30
- // (Row/Insert/Update/Relationships + Views/Functions/Enums/CompositeTypes
31
- // vides) — cf. packages/db/tests/types/fixtures.ts et
32
- // packages/aurabase/tests/types/client-generic.test-d.ts.
33
- //
34
- // `posts` porte une vraie FK vers `authors` (Relationships non vide, même
35
- // forme que packages/db/tests/types/fixtures.ts : foreignKeyName / columns /
36
- // isOneToOne / referencedRelation / referencedColumns) pour que le parser
37
- // vendoré (packages/db/src/select-query-parser) puisse réellement résoudre
38
- // l'embed many-to-one `author:authors(*)` prouvé dans `_dbSnippets` ci-dessous
39
- // — cf. select-inference.test-d.ts (`author:users(email)`) pour la forme
40
- // exacte d'un embed aliasé qui compile.
41
- type Database = {
42
- public: {
43
- Tables: {
44
- posts: {
45
- Row: {
46
- id: string
47
- title: string
48
- published: boolean
49
- author_id: string
50
- created_at: string
51
- }
52
- Insert: {
53
- id?: string
54
- title: string
55
- published?: boolean
56
- author_id: string
57
- created_at?: string
58
- }
59
- Update: {
60
- id?: string
61
- title?: string
62
- published?: boolean
63
- author_id?: string
64
- created_at?: string
65
- }
66
- Relationships: [
67
- {
68
- foreignKeyName: 'posts_author_id_fkey'
69
- columns: ['author_id']
70
- isOneToOne: false
71
- referencedRelation: 'authors'
72
- referencedColumns: ['id']
73
- },
74
- ]
75
- }
76
- authors: {
77
- Row: { id: string; name: string }
78
- Insert: { id?: string; name: string }
79
- Update: { id?: string; name?: string }
80
- Relationships: []
81
- }
82
- }
83
- Views: Record<string, never>
84
- // `add` (scalaire) et `list_things` (SETOF lié à `authors` via SetofOptions.to)
85
- // — parité avec la sortie réelle de `@aurabase/gen` (Task B5) et avec
86
- // packages/db/tests/types/rpc.test-d.ts (même fixture Functions).
87
- Functions: {
88
- add: { Args: { a: number; b: number }; Returns: number }
89
- list_things: {
90
- Args: Record<string, never>
91
- Returns: { id: string; name: string }[]
92
- SetofOptions: { isSetofReturn: true; isOneToOne: false; to: 'authors'; from: '*' }
93
- }
94
- }
95
- Enums: Record<string, never>
96
- CompositeTypes: Record<string, never>
97
- }
98
- }
99
-
100
- // -- auth (packages/auth/README.md) ------------------------------------------
101
-
102
- async function _authSnippets() {
103
- const aura = createClient<Database>('http://localhost:8080', 'my-project', 'aura_anon_xxx')
104
-
105
- // Mot de passe (§ "Mot de passe")
106
- await aura.auth.signUp({ email: 'user@example.com', password: 'correct horse battery staple' })
107
- await aura.auth.signInWithPassword({ email: 'user@example.com', password: 'correct horse battery staple' })
108
- await aura.auth.signOut()
109
-
110
- // Session (§ "Session")
111
- const { accessToken, user } = await aura.auth.getSession()
112
- void accessToken
113
- void user
114
- await aura.auth.refreshSession()
115
- await aura.auth.setSession('stored-access-token', 'stored-refresh-token')
116
- const sessions = await aura.auth.listSessions()
117
- await aura.auth.revokeSession(sessions.data![0]!.id)
118
- await aura.auth.revokeAllSessions()
119
-
120
- // OAuth PKCE (§ "OAuth (implicite ou PKCE)") — renvoie toujours { url }.
121
- const { data, error } = await aura.auth.signInWithOAuth('github', {
122
- redirectTo: 'http://localhost:3000/auth/callback',
123
- scopes: 'read:user user:email',
124
- flowType: 'pkce',
125
- })
126
- if (error) throw error
127
- const url: string = data!.url
128
- void url
129
-
130
- await aura.auth.exchangeCodeForSession('auth-code-from-callback')
131
- await aura.auth.signInWithIdToken('google', 'id-token-from-provider')
132
-
133
- // Magic link / OTP
134
- await aura.auth.signInWithMagicLink({ email: 'user@example.com', redirect_url: 'http://localhost:3000/auth/callback' })
135
- await aura.auth.verifyMagicLink('token-from-link')
136
- await aura.auth.signInWithEmailOtp('user@example.com')
137
- await aura.auth.verifyEmailOtp('user@example.com', '123456')
138
- await aura.auth.signInWithSmsOtp('+15551234567')
139
- await aura.auth.verifySmsOtp('+15551234567', '123456')
140
-
141
- // Anonyme
142
- await aura.auth.signInAnonymously()
143
- await aura.auth.promoteAnonymous({ email: 'user@example.com', password: 'correct horse battery staple' })
144
-
145
- // Utilisateur, claims, mot de passe
146
- await aura.auth.getUser()
147
- await aura.auth.getClaims()
148
- await aura.auth.updateUser({ data: { display_name: 'Ada' } })
149
- await aura.auth.updatePassword('new-password', 'current-password')
150
- await aura.auth.deleteUser('current-password')
151
-
152
- // Réinitialisation / vérification email
153
- await aura.auth.resetPasswordForEmail({ email: 'user@example.com' })
154
- await aura.auth.resetPassword('token-from-email', 'new-password')
155
- await aura.auth.verifyEmail('token-from-email')
156
- await aura.auth.resendVerificationEmail()
157
- await aura.auth.confirmEmailChange('token-from-email')
158
-
159
- // MFA (TOTP)
160
- await aura.auth.mfaEnroll()
161
- await aura.auth.mfaVerifySetup('123456')
162
- await aura.auth.mfaVerify({ mfa_token: 'mfa-token-from-login-response', code: '123456' })
163
- await aura.auth.regenerateRecoveryCodes('123456')
164
- await aura.auth.mfaUnenroll('current-password')
165
-
166
- // Configuration publique
167
- await aura.auth.getSettings()
168
- await aura.auth.getAnonKey()
169
-
170
- // État d'authentification — événements documentés (AuthEvent réel).
171
- const subscription = aura.auth.onAuthStateChange(
172
- ({ event, user, accessToken }: AuthChangePayload) => {
173
- const e: 'INITIAL_SESSION' | 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED' | 'MFA_CHALLENGE' | 'PASSWORD_RECOVERY' = event
174
- void e
175
- void user
176
- void accessToken
177
- },
178
- )
179
- subscription.unsubscribe()
180
- aura.dispose()
181
-
182
- // Administration (AuthAdminService) — via createAdminClient.
183
- const admin = createAdminClient<Database>('http://localhost:8080', 'my-project', 'aura_service_role_xxx')
184
- await admin.authAdmin.listUsers({ limit: 50 })
185
- }
186
-
187
- // -- db typé (packages/db/README.md) -----------------------------------------
188
-
189
- async function _dbSnippets() {
190
- const aura = createClient<Database>('http://localhost:8080', 'my-project', 'aura_anon_xxx')
191
-
192
- // Select, filtres, embeds, order/limit.
193
- await aura.db
194
- .from('posts')
195
- .select('id,title,author_id')
196
- .eq('published', true)
197
- .order('id', 'desc')
198
- .limit(10)
199
-
200
- // Embed relationnel (§ "Select, filtres, embeds") — `posts.author_id` est
201
- // NOT NULL dans la Row, donc l'embed many-to-one `author` est un objet non
202
- // nullable (pas `| null`) : preuve que le README db (`author:authors(*)`)
203
- // compile réellement contre le parser vendoré, pas seulement contre une
204
- // fixture sans relation.
205
- const { data: withAuthor } = await aura.db
206
- .from('posts')
207
- .select('id,title,author:authors(*)')
208
- .eq('published', true)
209
- .order('created_at', 'desc')
210
- .limit(10)
211
- const firstPostAuthorName: string | undefined = withAuthor?.[0]?.author.name
212
- void firstPostAuthorName
213
-
214
- await aura.db
215
- .from('posts')
216
- .or([
217
- { column: 'published', op: 'eq', value: true },
218
- { column: 'author_id', op: 'eq', value: 'user-id' },
219
- ])
220
- .textSearch('title', 'aurabase', { type: 'websearch' })
221
-
222
- // single()/maybeSingle()/cursor().
223
- const postId = 'post-id'
224
- await aura.db.from('posts').eq('id', postId).single()
225
- await aura.db.from('posts').eq('id', postId).maybeSingle()
226
- const firstPage = await aura.db.from('posts').order('id').limit(20)
227
- await aura.db.from('posts').order('id').cursor(firstPage.meta?.next_cursor ?? '')
228
-
229
- // Mutations — update()/delete() ciblent par id (pas de .eq()).
230
- await aura.db.from('posts').insert({ title: 'Hello', published: false, author_id: 'a' })
231
- await aura.db.from('posts').insert([
232
- { title: 'A', author_id: 'a' },
233
- { title: 'B', author_id: 'a' },
234
- ])
235
- await aura.db.from('posts').update(postId, { published: true })
236
- await aura.db.from('posts').delete(postId)
237
- await aura.db.from('posts').upsert({ id: postId, title: 'Updated', author_id: 'a' }, { onConflict: 'id' })
238
-
239
- // SQL brut et schéma.
240
- await aura.db.sql('SELECT count(*) FROM posts WHERE published = $1', [true])
241
- await aura.db.schema()
242
-
243
- // rpc() — § "Fonctions Postgres (rpc)" (packages/db/README.md).
244
- // Appel scalaire (POST par défaut, args typés strictement sur Functions.add).
245
- const { data: sum } = await aura.db.rpc('add', { a: 1, b: 2 })
246
- void sum
247
-
248
- // Fonction SETOF filtrée (Row inféré de SetofOptions.to = 'authors').
249
- const { data: thing } = await aura.db.rpc('list_things', {}).eq('id', 'author-1').select('id,name').single()
250
- void thing
251
-
252
- // Options : count → meta.total ; get/head → verbe HTTP sans body.
253
- const rpcCount = await aura.db.rpc('list_things', {}, { count: 'exact' })
254
- void rpcCount.meta?.total
255
- await aura.db.rpc('list_things', {}, { get: true })
256
- await aura.db.rpc('list_things', {}, { head: true, count: 'exact' })
257
- }
258
-
259
- // -- rpc : fallback permissif (Database = any, pas de bloc Functions) --------
260
-
261
- async function _dbRpcUntypedSnippet() {
262
- const aura = createClient('http://localhost:8080', 'my-project', 'aura_anon_xxx')
263
-
264
- // Aucun Database générique fourni : args permissifs, résultat non typé.
265
- await aura.db.rpc('whatever_fn', { anything: true })
266
- }
267
-
268
- // -- storage (packages/storage/README.md) ------------------------------------
269
-
270
- // `declare const` doit être au niveau module (interdit dans un corps de
271
- // fonction, cf. TS1184) : le README l'illustre au même niveau.
272
- declare const file: File
273
-
274
- async function _storageSnippets() {
275
- const aura = createClient('http://localhost:8080', 'my-project', 'aura_anon_xxx')
276
-
277
- await aura.storage.listBuckets()
278
- await aura.storage.createBucket('avatars', {
279
- public: true,
280
- fileSizeLimit: 5 * 1024 * 1024,
281
- allowedMimeTypes: ['image/png', 'image/jpeg'],
282
- })
283
- await aura.storage.getBucket('avatars')
284
- await aura.storage.deleteBucket('avatars')
285
-
286
- const { data } = await aura.storage.upload('avatars', 'photo.png', file, {
287
- contentType: 'image/png',
288
- upsert: true,
289
- })
290
- await aura.storage.list('avatars', { prefix: 'users/', limit: 100 })
291
- await aura.storage.getMetadata('avatars', data!.key)
292
-
293
- // Download — builder paresseux : n'exécute la requête qu'une fois `await`é.
294
- const { data: blob } = await aura.storage.download('avatars', 'photo.png')
295
- void blob
296
- const { data: stream } = await aura.storage.download('avatars', 'photo.png').asStream()
297
- void stream
298
-
299
- await aura.storage.copy('avatars', 'photo.png', 'archive/photo.png')
300
- await aura.storage.move('avatars', 'archive/photo.png', 'photo.png')
301
- await aura.storage.remove('avatars', ['photo.png'])
302
-
303
- await aura.storage.createSignedUrl('avatars', 'photo.png', 600)
304
- await aura.storage.createSignedUploadUrl('avatars', 'photo.png', 300)
305
- const publicUrl: string = aura.storage.getPublicUrl('avatars', 'photo.png')
306
- void publicUrl
307
- }
308
-
309
- // -- storage : transformations d'image (packages/storage/README.md § "Transformations
310
- // d'image") — les 3 méthodes acceptant `{ transform: ImageTransform }`.
311
-
312
- async function _storageTransformSnippets() {
313
- const aura = createClient('http://localhost:8080', 'my-project', 'aura_anon_xxx')
314
-
315
- const cover: ImageTransform = { width: 200, resize: 'cover' }
316
- const thumbnail: string = aura.storage.getPublicUrl('avatars', 'photo.png', { transform: cover })
317
- void thumbnail
318
-
319
- const { data: resized } = await aura.storage.download('avatars', 'photo.png', {
320
- transform: { width: 800, height: 300, quality: 75 },
321
- })
322
- void resized
323
-
324
- const webpSigned = await aura.storage.createSignedUrl('avatars', 'photo.png', 600, {
325
- transform: { width: 200, format: 'webp' },
326
- })
327
- void webpSigned.data?.url
328
- }
329
-
330
- // -- realtime (packages/realtime/README.md) -----------------------------------
331
-
332
- async function _realtimeSnippets() {
333
- const aura = createClient('http://localhost:8080', 'my-project', 'aura_anon_xxx')
334
-
335
- const unsubscribe = aura.realtime.onStateChange((state) => {
336
- const s: 'disconnected' | 'connecting' | 'connected' | 'reconnecting' = state
337
- void s
338
- })
339
- aura.realtime.connect()
340
- const cs: 'disconnected' | 'connecting' | 'connected' | 'reconnecting' = aura.realtime.connectionState
341
- void cs
342
- aura.realtime.setAutoReconnect(true, 5)
343
- aura.realtime.refreshToken('new-access-token')
344
-
345
- // postgres_changes via le raccourci aura.channel(name).
346
- aura.channel('db:public.posts')
347
- .on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'posts' }, (payload) => {
348
- void payload
349
- })
350
- .subscribe((status, err) => {
351
- const s: 'SUBSCRIBED' | 'CLOSED' | 'CHANNEL_ERROR' | 'TIMED_OUT' = status
352
- void s
353
- void err
354
- })
355
-
356
- // postgres_changes avec filtre de colonne (§ "Filtres de colonne (postgres_changes)",
357
- // packages/realtime/README.md) — le champ `filter` doit typer/compiler.
358
- aura.channel('room')
359
- .on('postgres_changes', { event: '*', schema: 'public', table: 'x', filter: 'id=eq.1' }, (payload) => {
360
- void payload
361
- })
362
- .subscribe()
363
-
364
- // Broadcast.
365
- const room = aura.realtime.channel('room-1', { broadcast: { ack: true, self: true } })
366
- room
367
- .on('broadcast', { event: 'cursor-pos' }, (payload) => {
368
- void payload
369
- })
370
- .subscribe()
371
- const sendStatus: 'ok' | 'timeout' | 'error' = await room.send({
372
- type: 'broadcast',
373
- event: 'cursor-pos',
374
- payload: { x: 100, y: 200 },
375
- })
376
- void sendStatus
377
-
378
- // Presence.
379
- const lobby = aura.channel('room-1', { config: { presence: { key: 'user-1' } } })
380
- lobby
381
- .on('presence', { event: 'sync' }, () => {
382
- lobby.presenceState()
383
- })
384
- .on('presence', { event: 'join' }, () => {})
385
- .on('presence', { event: 'leave' }, () => {})
386
- .subscribe()
387
- await lobby.track({ online_at: new Date().toISOString() })
388
- await lobby.untrack()
389
-
390
- // Nettoyage.
391
- aura.realtime.getChannels()
392
- aura.realtime.removeChannel('room-1')
393
- aura.realtime.removeAllChannels()
394
- aura.realtime.disconnect()
395
- unsubscribe()
396
- }
397
-
398
- // -- functions (packages/functions/README.md) ---------------------------------
399
-
400
- async function _functionsSnippets() {
401
- const aura = createClient('http://localhost:8080', 'my-project', 'aura_anon_xxx')
402
-
403
- const { data, error } = await aura.functions.invoke<{ ok: boolean }>('hello-world', {
404
- body: { name: 'Ada' },
405
- })
406
- if (error) throw error
407
- const ok: boolean = data!.ok
408
- void ok
409
-
410
- const controller = new AbortController()
411
- const invokeRes = await aura.functions.invoke('slow-job', {
412
- method: 'POST',
413
- path: '/process',
414
- headers: { 'x-request-source': 'studio' },
415
- timeout: 5000,
416
- signal: controller.signal,
417
- })
418
- if (invokeRes.error?.code === 'timeout') {
419
- // annulation timeout ou signal
420
- }
421
-
422
- const { data: fns } = await aura.functions.list()
423
- await aura.functions.get(fns![0]!.id)
424
-
425
- const { data: jobs } = await aura.functions.listJobs({ status: 'pending', limit: 20 })
426
- await aura.functions.getJob(jobs![0]!.id)
427
-
428
- await aura.functions.createCronJob('nightly-cleanup', '0 3 * * *', 'cleanup-fn', {
429
- payload: { dryRun: false },
430
- })
431
- await aura.functions.listCronJobs()
432
- await aura.functions.deleteCronJob('nightly-cleanup')
433
- }
434
-
435
- // -- ai (packages/ai/README.md) ------------------------------------------------
436
-
437
- async function _aiSnippets() {
438
- const aura = createClient('http://localhost:8080', 'my-project', 'aura_anon_xxx')
439
-
440
- const { data, error } = await aura.ai.chat(
441
- [{ role: 'user', content: 'Résume ce texte en une phrase.' }],
442
- { model: 'gpt-4o-mini', temperature: 0.2, max_tokens: 200 },
443
- )
444
- if (error) throw error
445
- const content: string = data!.content
446
- void content
447
-
448
- const { data: embedding } = await aura.ai.embed({
449
- text: 'Aurabase est une plateforme Backend-as-a-Service.',
450
- namespace: 'docs',
451
- })
452
- void embedding!.dimensions
453
-
454
- await aura.ai.ragIngest({
455
- namespace: 'docs',
456
- content: 'Aurabase expose un service de fonctions edge invocables via aura.functions.invoke().',
457
- })
458
- const { data: answer } = await aura.ai.rag({
459
- question: 'Comment invoquer une edge function ?',
460
- namespace: 'docs',
461
- })
462
- void answer!.answer
463
- void answer!.sources
464
-
465
- const { data: results } = await aura.ai.semanticSearch('invocation de fonction', 'docs', {
466
- top_k: 5,
467
- threshold: 0.75,
468
- })
469
- for (const r of results ?? []) {
470
- void r.similarity
471
- void r.content
472
- }
473
-
474
- const schema = 'CREATE TABLE posts (id uuid, title text, published boolean);'
475
- const { data: query } = await aura.ai.nl2sql('Combien de posts sont publiés ?', schema, {
476
- dialect: 'postgres',
477
- })
478
- void query!.sql
479
- void query!.explanation
480
- }
481
-
482
- // -- notifications (packages/notifications/README.md) -------------------------
483
-
484
- async function _notificationsSnippets() {
485
- const aura = createClient('http://localhost:8080', 'my-project', 'aura_anon_xxx')
486
-
487
- const { data, error } = await aura.notifications.send(
488
- 'email',
489
- 'user@example.com',
490
- 'Votre commande a été expédiée.',
491
- { subject: 'Expédition', variables: { order_id: '1234' }, idempotencyKey: 'order-1234-shipped' },
492
- )
493
- if (error) throw error
494
- void data!.status
495
-
496
- const { data: batch } = await aura.notifications.sendBatch([
497
- { channel: 'email', recipient: 'a@example.com', body: 'Bonjour A' },
498
- { channel: 'sms', recipient: '+15551234567', body: 'Bonjour B' },
499
- ])
500
- for (const item of batch!.items) {
501
- void item.status
502
- void item.notification?.id
503
- }
504
-
505
- const { data: sent } = await aura.notifications.list({
506
- channel: 'email',
507
- status: 'delivered',
508
- sort: 'created_at',
509
- order: 'desc',
510
- limit: 20,
511
- })
512
- const notificationId = sent![0]!.id
513
- await aura.notifications.get(notificationId)
514
-
515
- const { data: template } = await aura.notifications.createTemplate({
516
- name: 'order-shipped',
517
- channel: 'email',
518
- subject: 'Expédition {{order_id}}',
519
- body: 'Votre commande {{order_id}} est en route.',
520
- variables: ['order_id'],
521
- })
522
- await aura.notifications.updateTemplate(template!.id, { body: 'Mise à jour : {{order_id}} expédiée.' })
523
-
524
- // Administration (aura.notifications.admin).
525
- const { data: settings } = await aura.notifications.admin.getSettings()
526
- void settings
527
- await aura.notifications.admin.updateSettings({ quotas: { daily_email: 10000 } })
528
-
529
- await aura.notifications.admin.getStats({ window: '24h', channel: 'email' })
530
- await aura.notifications.admin.getQueue()
531
-
532
- const failedId = 'notification-id'
533
- await aura.notifications.admin.listAttempts(failedId)
534
-
535
- const { data: deadLetters } = await aura.notifications.admin.listDeadLetters({ channel: 'email', limit: 50 })
536
- await aura.notifications.admin.retryDeadLetter(deadLetters![0]!.id)
537
-
538
- await aura.notifications.admin.listEvents({ status: 'failed' })
539
- await aura.notifications.admin.listProviderLogs({ channel: 'sms' })
540
-
541
- const templateId = 'template-id'
542
- const { data: preview } = await aura.notifications.admin.previewTemplate(templateId, { order_id: '1234' })
543
- void preview!.subject
544
- void preview!.body
545
-
546
- // Règles déclenchées par événement.
547
- const { data: rule } = await aura.notifications.admin.createRule({
548
- name: 'welcome-email',
549
- trigger_type: 'user.created',
550
- channel: 'email',
551
- recipient_expr: 'user.email',
552
- template_id: 'welcome-template-id',
553
- delay_seconds: 0,
554
- })
555
- await aura.notifications.admin.listRules()
556
- await aura.notifications.admin.updateRule(rule!.id, { enabled: false })
557
- await aura.notifications.admin.deleteRule(rule!.id)
558
- }
559
-
560
- // Empêche "declared but never read" sur les fonctions non exécutées : chaque
561
- // snippet doit être référencé pour que `tsc --noEmit` le compile réellement
562
- // (un import/déclaration inutilisé n'est PAS une erreur `noUnusedLocals` tant
563
- // que la fonction elle-même est référencée quelque part).
564
- void _authSnippets
565
- void _dbSnippets
566
- void _dbRpcUntypedSnippet
567
- void _storageSnippets
568
- void _realtimeSnippets
569
- void _functionsSnippets
570
- void _aiSnippets
571
- void _notificationsSnippets
@@ -1,53 +0,0 @@
1
- // Test type-level (LOT 3, finding I4 + I8) :
2
- // - `AuraErrorCode` exporté depuis le meta-package, `AuraError.code` typé dessus,
3
- // union ouverte aux codes backend arbitraires (pattern LiteralUnion).
4
- // - `AuraObservabilityEvent` (union discriminée par `kind`) + `AuraClientOptions.
5
- // onEvent`/`debug` acceptés par `createClient`.
6
- import { expectTypeOf } from 'vitest'
7
- import { AuraError, createClient } from '../../src/index'
8
- import type { AuraErrorCode, AuraObservabilityEvent } from '../../src/index'
9
-
10
- test('AuraError.code est typé AuraErrorCode', () => {
11
- const e = new AuraError(0, { error: { code: 'no_session', message: 'x' } })
12
- expectTypeOf(e.code).toEqualTypeOf<AuraErrorCode>()
13
- })
14
-
15
- test('AuraErrorCode accepte un code connu ET un code backend arbitraire (LiteralUnion)', () => {
16
- // La simple compilation de ces affectations EST le test : si `AuraErrorCode`
17
- // n'acceptait pas un littéral connu OU un code backend arbitraire, `tsc` échouerait
18
- // ici. (`toEqualTypeOf` générique se prête mal à `(string & {})` — cf. doc
19
- // expect-type sur les intersections — `toMatchTypeOf` reste pertinent en subtype.)
20
- const known: AuraErrorCode = 'timeout'
21
- const arbitrary: AuraErrorCode = 'some_backend_code_not_in_the_union'
22
- expectTypeOf(known).toMatchTypeOf<AuraErrorCode>()
23
- expectTypeOf(arbitrary).toMatchTypeOf<AuraErrorCode>()
24
- })
25
-
26
- test('AuraObservabilityEvent est une union discriminée par kind', () => {
27
- const retry: AuraObservabilityEvent = { kind: 'retry', attempt: 1, url: 'http://x' }
28
- const retryWithStatus: AuraObservabilityEvent = { kind: 'retry', attempt: 1, status: 503, url: 'http://x' }
29
- const timeout: AuraObservabilityEvent = { kind: 'timeout', url: 'http://x' }
30
- const refreshSuccess: AuraObservabilityEvent = { kind: 'refresh-success' }
31
- const refreshDiscarded: AuraObservabilityEvent = { kind: 'refresh-discarded', reason: 'x' }
32
- const jwksFailed: AuraObservabilityEvent = { kind: 'jwks-fetch-failed', baseUrl: 'http://x' }
33
- const storageBlocked: AuraObservabilityEvent = { kind: 'storage-blocked', op: 'setItem' }
34
- expectTypeOf(retry).toMatchTypeOf<AuraObservabilityEvent>()
35
- expectTypeOf(retryWithStatus).toMatchTypeOf<AuraObservabilityEvent>()
36
- expectTypeOf(timeout).toMatchTypeOf<AuraObservabilityEvent>()
37
- expectTypeOf(refreshSuccess).toMatchTypeOf<AuraObservabilityEvent>()
38
- expectTypeOf(refreshDiscarded).toMatchTypeOf<AuraObservabilityEvent>()
39
- expectTypeOf(jwksFailed).toMatchTypeOf<AuraObservabilityEvent>()
40
- expectTypeOf(storageBlocked).toMatchTypeOf<AuraObservabilityEvent>()
41
- })
42
-
43
- test('createClient accepte onEvent/debug (optionnels — pas de breaking change)', () => {
44
- // Compile sans onEvent/debug (rétro-compat) :
45
- createClient('http://x', 'p', 'k')
46
- // Compile avec onEvent/debug :
47
- createClient('http://x', 'p', 'k', {
48
- onEvent: (e) => {
49
- expectTypeOf(e).toEqualTypeOf<AuraObservabilityEvent>()
50
- },
51
- debug: true,
52
- })
53
- })
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": { "outDir": "dist", "rootDir": "src" },
4
- "include": ["src"]
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": { "noEmit": true, "rootDir": "." },
4
- "include": ["src", "tests/**/*.test-d.ts"]
5
- }
@@ -1,11 +0,0 @@
1
- import { defineConfig } from 'tsup'
2
-
3
- export default defineConfig({
4
- entry: ['src/index.ts', 'src/ssr.ts'],
5
- format: ['cjs', 'esm'],
6
- dts: true,
7
- splitting: false,
8
- clean: true,
9
- treeshake: true,
10
- minify: false,
11
- })
@@ -1,16 +0,0 @@
1
- import { defineConfig, configDefaults } from 'vitest/config'
2
-
3
- export default defineConfig({
4
- test: {
5
- globals: true,
6
- environment: 'node',
7
- exclude: process.env.RUN_E2E
8
- ? configDefaults.exclude
9
- : [
10
- ...configDefaults.exclude,
11
- 'tests/integration.test.ts',
12
- 'tests/observability-backup.test.ts',
13
- 'tests/production-robustness.test.ts',
14
- ],
15
- },
16
- })