@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.
Files changed (343) 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 +72 -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/node_modules/.bin/esbuild +0 -19
  18. package/packages/ai/node_modules/.bin/tsc +0 -22
  19. package/packages/ai/node_modules/.bin/tsserver +0 -22
  20. package/packages/ai/node_modules/.bin/tsup +0 -22
  21. package/packages/ai/node_modules/.bin/tsup-node +0 -22
  22. package/packages/ai/node_modules/.bin/vite +0 -22
  23. package/packages/ai/node_modules/.bin/vitest +0 -22
  24. package/packages/ai/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  25. package/packages/ai/package.json +0 -61
  26. package/packages/ai/src/AiService.ts +0 -226
  27. package/packages/ai/src/index.ts +0 -18
  28. package/packages/ai/src/sse.ts +0 -141
  29. package/packages/ai/src/types.ts +0 -30
  30. package/packages/ai/tests/chat-stream.test.ts +0 -151
  31. package/packages/ai/tests/rag-namespaces.test.ts +0 -54
  32. package/packages/ai/tests/sse.test.ts +0 -69
  33. package/packages/ai/tsconfig.json +0 -5
  34. package/packages/ai/tsup.config.ts +0 -11
  35. package/packages/aurabase/LICENSE +0 -21
  36. package/packages/aurabase/README.md +0 -64
  37. package/packages/aurabase/node_modules/.bin/esbuild +0 -19
  38. package/packages/aurabase/node_modules/.bin/tsc +0 -22
  39. package/packages/aurabase/node_modules/.bin/tsserver +0 -22
  40. package/packages/aurabase/node_modules/.bin/tsup +0 -22
  41. package/packages/aurabase/node_modules/.bin/tsup-node +0 -22
  42. package/packages/aurabase/node_modules/.bin/vite +0 -22
  43. package/packages/aurabase/node_modules/.bin/vitest +0 -22
  44. package/packages/aurabase/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  45. package/packages/aurabase/package.json +0 -80
  46. package/packages/aurabase/src/AuraClient.ts +0 -237
  47. package/packages/aurabase/src/index.ts +0 -152
  48. package/packages/aurabase/src/ssr.ts +0 -156
  49. package/packages/aurabase/tests/ai-streaming-rag-e2e.test.ts +0 -82
  50. package/packages/aurabase/tests/ai.test.ts +0 -111
  51. package/packages/aurabase/tests/auth-admin.test.ts +0 -515
  52. package/packages/aurabase/tests/auth-e2e.test.ts +0 -135
  53. package/packages/aurabase/tests/auth-hardening.test.ts +0 -206
  54. package/packages/aurabase/tests/auth.test.ts +0 -947
  55. package/packages/aurabase/tests/database.test.ts +0 -230
  56. package/packages/aurabase/tests/db-types-e2e.test.ts +0 -217
  57. package/packages/aurabase/tests/dispose.test.ts +0 -23
  58. package/packages/aurabase/tests/foreign-token.e2e.test.ts +0 -129
  59. package/packages/aurabase/tests/functions.test.ts +0 -107
  60. package/packages/aurabase/tests/integration.test.ts +0 -413
  61. package/packages/aurabase/tests/live-production-validation.js +0 -241
  62. package/packages/aurabase/tests/live-sdk-production-validation.js +0 -293
  63. package/packages/aurabase/tests/mocks.ts +0 -139
  64. package/packages/aurabase/tests/notifications.test.ts +0 -314
  65. package/packages/aurabase/tests/observability-backup.test.ts +0 -186
  66. package/packages/aurabase/tests/observability-hook.test.ts +0 -130
  67. package/packages/aurabase/tests/production-robustness.test.ts +0 -268
  68. package/packages/aurabase/tests/public-api-surface.test.ts +0 -53
  69. package/packages/aurabase/tests/query-builder.test.ts +0 -329
  70. package/packages/aurabase/tests/readme-smoke-e2e.test.ts +0 -231
  71. package/packages/aurabase/tests/realtime-filter-e2e.test.ts +0 -344
  72. package/packages/aurabase/tests/refresh-locks.test.ts +0 -210
  73. package/packages/aurabase/tests/retry-option.test.ts +0 -17
  74. package/packages/aurabase/tests/rpc-e2e.test.ts +0 -254
  75. package/packages/aurabase/tests/rs256-local-e2e.test.ts +0 -114
  76. package/packages/aurabase/tests/rt-alias-public-e2e.test.ts +0 -235
  77. package/packages/aurabase/tests/rt-http-broadcast-e2e.test.ts +0 -124
  78. package/packages/aurabase/tests/service-role-guard.test.ts +0 -99
  79. package/packages/aurabase/tests/ssr.test.ts +0 -91
  80. package/packages/aurabase/tests/storage-backend-e2e.test.ts +0 -481
  81. package/packages/aurabase/tests/storage-sdk-parity-e2e.test.ts +0 -104
  82. package/packages/aurabase/tests/storage-transform-e2e.test.ts +0 -684
  83. package/packages/aurabase/tests/storage.test.ts +0 -55
  84. package/packages/aurabase/tests/types/client-generic.test-d.ts +0 -79
  85. package/packages/aurabase/tests/types/docs-snippets.test-d.ts +0 -571
  86. package/packages/aurabase/tests/types/error-code.test-d.ts +0 -53
  87. package/packages/aurabase/tsconfig.json +0 -5
  88. package/packages/aurabase/tsconfig.test-d.json +0 -5
  89. package/packages/aurabase/tsup.config.ts +0 -11
  90. package/packages/aurabase/vitest.config.ts +0 -16
  91. package/packages/aurabase/vitest.e2e.config.ts +0 -9
  92. package/packages/auth/LICENSE +0 -21
  93. package/packages/auth/README.md +0 -215
  94. package/packages/auth/dist/index.cjs +0 -1175
  95. package/packages/auth/dist/index.d.cts +0 -397
  96. package/packages/auth/dist/index.d.ts +0 -397
  97. package/packages/auth/dist/index.js +0 -1170
  98. package/packages/auth/node_modules/.bin/esbuild +0 -19
  99. package/packages/auth/node_modules/.bin/tsc +0 -22
  100. package/packages/auth/node_modules/.bin/tsserver +0 -22
  101. package/packages/auth/node_modules/.bin/tsup +0 -22
  102. package/packages/auth/node_modules/.bin/tsup-node +0 -22
  103. package/packages/auth/node_modules/.bin/vite +0 -22
  104. package/packages/auth/node_modules/.bin/vitest +0 -22
  105. package/packages/auth/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  106. package/packages/auth/package.json +0 -61
  107. package/packages/auth/src/AuthAdminService.ts +0 -149
  108. package/packages/auth/src/AuthService.ts +0 -1166
  109. package/packages/auth/src/SessionManager.ts +0 -92
  110. package/packages/auth/src/index.ts +0 -17
  111. package/packages/auth/src/jwks.ts +0 -337
  112. package/packages/auth/src/pkce.ts +0 -27
  113. package/packages/auth/src/types.ts +0 -89
  114. package/packages/auth/tests/auth-lifecycle.test.ts +0 -149
  115. package/packages/auth/tests/detect-session.test.ts +0 -361
  116. package/packages/auth/tests/getclaims.test.ts +0 -780
  117. package/packages/auth/tests/is-mfa-challenge.test.ts +0 -27
  118. package/packages/auth/tests/password-recovery.test.ts +0 -124
  119. package/packages/auth/tests/pkce.test.ts +0 -192
  120. package/packages/auth/tests/session-manager.test.ts +0 -103
  121. package/packages/auth/tests/set-session.test.ts +0 -139
  122. package/packages/auth/tests/verify-otp.test.ts +0 -153
  123. package/packages/auth/tsconfig.json +0 -5
  124. package/packages/auth/tsup.config.ts +0 -11
  125. package/packages/core/LICENSE +0 -21
  126. package/packages/core/README.md +0 -132
  127. package/packages/core/dist/index.cjs +0 -695
  128. package/packages/core/dist/index.d.cts +0 -1137
  129. package/packages/core/dist/index.d.ts +0 -1137
  130. package/packages/core/dist/index.js +0 -673
  131. package/packages/core/node_modules/.bin/esbuild +0 -22
  132. package/packages/core/node_modules/.bin/tsc +0 -22
  133. package/packages/core/node_modules/.bin/tsserver +0 -22
  134. package/packages/core/node_modules/.bin/tsup +0 -22
  135. package/packages/core/node_modules/.bin/tsup-node +0 -22
  136. package/packages/core/node_modules/.bin/vite +0 -22
  137. package/packages/core/node_modules/.bin/vitest +0 -22
  138. package/packages/core/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  139. package/packages/core/package.json +0 -57
  140. package/packages/core/src/AuraError.ts +0 -89
  141. package/packages/core/src/BaseService.ts +0 -44
  142. package/packages/core/src/client.ts +0 -34
  143. package/packages/core/src/cookie-utils.ts +0 -42
  144. package/packages/core/src/fetch.ts +0 -435
  145. package/packages/core/src/index.ts +0 -22
  146. package/packages/core/src/retry.ts +0 -63
  147. package/packages/core/src/serialize.ts +0 -6
  148. package/packages/core/src/stores/BaseAuthStore.ts +0 -164
  149. package/packages/core/src/stores/LocalAuthStore.ts +0 -199
  150. package/packages/core/src/types.ts +0 -1042
  151. package/packages/core/tests/auth-store.test.ts +0 -300
  152. package/packages/core/tests/error-code.test.ts +0 -61
  153. package/packages/core/tests/error.test.ts +0 -24
  154. package/packages/core/tests/fetch.test.ts +0 -286
  155. package/packages/core/tests/mocks.ts +0 -139
  156. package/packages/core/tests/observability.test.ts +0 -86
  157. package/packages/core/tests/refresh-hardening.test.ts +0 -164
  158. package/packages/core/tests/refresh-observability.test.ts +0 -111
  159. package/packages/core/tests/retry.test.ts +0 -106
  160. package/packages/core/tests/serialize.test.ts +0 -12
  161. package/packages/core/tests/timeout.test.ts +0 -79
  162. package/packages/core/tsconfig.json +0 -5
  163. package/packages/core/tsup.config.ts +0 -11
  164. package/packages/db/LICENSE +0 -21
  165. package/packages/db/README.md +0 -152
  166. package/packages/db/VENDORED.md +0 -93
  167. package/packages/db/dist/index.cjs +0 -544
  168. package/packages/db/dist/index.d.cts +0 -1111
  169. package/packages/db/dist/index.d.ts +0 -1111
  170. package/packages/db/dist/index.js +0 -541
  171. package/packages/db/node_modules/.bin/esbuild +0 -19
  172. package/packages/db/node_modules/.bin/tsc +0 -22
  173. package/packages/db/node_modules/.bin/tsserver +0 -22
  174. package/packages/db/node_modules/.bin/tsup +0 -22
  175. package/packages/db/node_modules/.bin/tsup-node +0 -22
  176. package/packages/db/node_modules/.bin/vite +0 -22
  177. package/packages/db/node_modules/.bin/vitest +0 -22
  178. package/packages/db/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  179. package/packages/db/package.json +0 -62
  180. package/packages/db/src/DatabaseService.ts +0 -170
  181. package/packages/db/src/QueryBuilder.ts +0 -830
  182. package/packages/db/src/index.ts +0 -2
  183. package/packages/db/src/pgrst-types/common/common.ts +0 -86
  184. package/packages/db/src/pgrst-types/common/rpc.ts +0 -151
  185. package/packages/db/src/pgrst-types/feature-flags.ts +0 -20
  186. package/packages/db/src/pgrst-types/types.ts +0 -134
  187. package/packages/db/src/select-query-parser/parser.ts +0 -479
  188. package/packages/db/src/select-query-parser/result.ts +0 -553
  189. package/packages/db/src/select-query-parser/types.ts +0 -132
  190. package/packages/db/src/select-query-parser/utils.ts +0 -707
  191. package/packages/db/tests/filters.test.ts +0 -81
  192. package/packages/db/tests/mutations-filtered.e2e.test.ts +0 -132
  193. package/packages/db/tests/mutations-filtered.test.ts +0 -188
  194. package/packages/db/tests/order.test.ts +0 -45
  195. package/packages/db/tests/rpc.test.ts +0 -41
  196. package/packages/db/tests/scale/build-large-schema.ts +0 -94
  197. package/packages/db/tests/scale/scale-compile.test.ts +0 -167
  198. package/packages/db/tests/schema.test.ts +0 -77
  199. package/packages/db/tests/single-accept.e2e.test.ts +0 -123
  200. package/packages/db/tests/single.test.ts +0 -211
  201. package/packages/db/tests/types/filters.test-d.ts +0 -52
  202. package/packages/db/tests/types/fixtures.ts +0 -40
  203. package/packages/db/tests/types/from-views.test-d.ts +0 -18
  204. package/packages/db/tests/types/mutations.test-d.ts +0 -23
  205. package/packages/db/tests/types/rpc.test-d.ts +0 -60
  206. package/packages/db/tests/types/schema-shape.test-d.ts +0 -8
  207. package/packages/db/tests/types/select-inference.test-d.ts +0 -38
  208. package/packages/db/tests/vendored/fixtures.ts +0 -83
  209. package/packages/db/tests/vendored/get-result.test-d.ts +0 -75
  210. package/packages/db/tsconfig.json +0 -5
  211. package/packages/db/tsconfig.test-d.json +0 -5
  212. package/packages/db/tsup.config.ts +0 -11
  213. package/packages/db/vitest.config.ts +0 -8
  214. package/packages/functions/LICENSE +0 -21
  215. package/packages/functions/README.md +0 -96
  216. package/packages/functions/dist/index.cjs +0 -173
  217. package/packages/functions/dist/index.d.cts +0 -81
  218. package/packages/functions/dist/index.d.ts +0 -81
  219. package/packages/functions/dist/index.js +0 -168
  220. package/packages/functions/node_modules/.bin/esbuild +0 -19
  221. package/packages/functions/node_modules/.bin/tsc +0 -22
  222. package/packages/functions/node_modules/.bin/tsserver +0 -22
  223. package/packages/functions/node_modules/.bin/tsup +0 -22
  224. package/packages/functions/node_modules/.bin/tsup-node +0 -22
  225. package/packages/functions/node_modules/.bin/vite +0 -22
  226. package/packages/functions/node_modules/.bin/vitest +0 -22
  227. package/packages/functions/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  228. package/packages/functions/package.json +0 -60
  229. package/packages/functions/src/FunctionsService.ts +0 -188
  230. package/packages/functions/src/errors.ts +0 -70
  231. package/packages/functions/src/index.ts +0 -6
  232. package/packages/functions/tests/invoke.test.ts +0 -97
  233. package/packages/functions/tests/response-type-errors.test.ts +0 -135
  234. package/packages/functions/tsconfig.json +0 -5
  235. package/packages/functions/tsup.config.ts +0 -11
  236. package/packages/gen/LICENSE +0 -21
  237. package/packages/gen/README.md +0 -84
  238. package/packages/gen/dist/cli.cjs +0 -334
  239. package/packages/gen/dist/cli.d.cts +0 -1
  240. package/packages/gen/dist/cli.d.ts +0 -1
  241. package/packages/gen/dist/cli.js +0 -332
  242. package/packages/gen/dist/index.cjs +0 -257
  243. package/packages/gen/dist/index.d.cts +0 -12
  244. package/packages/gen/dist/index.d.ts +0 -12
  245. package/packages/gen/dist/index.js +0 -255
  246. package/packages/gen/node_modules/.bin/esbuild +0 -19
  247. package/packages/gen/node_modules/.bin/tsc +0 -22
  248. package/packages/gen/node_modules/.bin/tsserver +0 -22
  249. package/packages/gen/node_modules/.bin/tsup +0 -22
  250. package/packages/gen/node_modules/.bin/tsup-node +0 -22
  251. package/packages/gen/node_modules/.bin/vite +0 -22
  252. package/packages/gen/node_modules/.bin/vitest +0 -22
  253. package/packages/gen/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  254. package/packages/gen/package.json +0 -66
  255. package/packages/gen/src/cli.ts +0 -67
  256. package/packages/gen/src/generate.ts +0 -0
  257. package/packages/gen/src/index.ts +0 -2
  258. package/packages/gen/tests/compile.test.ts +0 -213
  259. package/packages/gen/tests/e2e.test.ts +0 -130
  260. package/packages/gen/tests/generate.test.ts +0 -396
  261. package/packages/gen/tsconfig.json +0 -5
  262. package/packages/gen/tsup.config.ts +0 -11
  263. package/packages/notifications/LICENSE +0 -21
  264. package/packages/notifications/README.md +0 -134
  265. package/packages/notifications/dist/index.cjs +0 -128
  266. package/packages/notifications/dist/index.d.cts +0 -81
  267. package/packages/notifications/dist/index.d.ts +0 -81
  268. package/packages/notifications/dist/index.js +0 -125
  269. package/packages/notifications/node_modules/.bin/esbuild +0 -19
  270. package/packages/notifications/node_modules/.bin/tsc +0 -22
  271. package/packages/notifications/node_modules/.bin/tsserver +0 -22
  272. package/packages/notifications/node_modules/.bin/tsup +0 -22
  273. package/packages/notifications/node_modules/.bin/tsup-node +0 -22
  274. package/packages/notifications/node_modules/.bin/vite +0 -22
  275. package/packages/notifications/node_modules/.bin/vitest +0 -22
  276. package/packages/notifications/package.json +0 -60
  277. package/packages/notifications/src/NotificationsService.ts +0 -230
  278. package/packages/notifications/src/index.ts +0 -19
  279. package/packages/notifications/tsconfig.json +0 -5
  280. package/packages/notifications/tsup.config.ts +0 -11
  281. package/packages/realtime/LICENSE +0 -21
  282. package/packages/realtime/README.md +0 -183
  283. package/packages/realtime/dist/index.cjs +0 -977
  284. package/packages/realtime/dist/index.d.cts +0 -259
  285. package/packages/realtime/dist/index.d.ts +0 -259
  286. package/packages/realtime/dist/index.js +0 -973
  287. package/packages/realtime/node_modules/.bin/esbuild +0 -19
  288. package/packages/realtime/node_modules/.bin/tsc +0 -22
  289. package/packages/realtime/node_modules/.bin/tsserver +0 -22
  290. package/packages/realtime/node_modules/.bin/tsup +0 -22
  291. package/packages/realtime/node_modules/.bin/tsup-node +0 -22
  292. package/packages/realtime/node_modules/.bin/vite +0 -22
  293. package/packages/realtime/node_modules/.bin/vitest +0 -22
  294. package/packages/realtime/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  295. package/packages/realtime/package.json +0 -60
  296. package/packages/realtime/src/AuraChannel.ts +0 -485
  297. package/packages/realtime/src/HeartbeatManager.ts +0 -73
  298. package/packages/realtime/src/RealtimeService.ts +0 -505
  299. package/packages/realtime/src/columnFilter.ts +0 -301
  300. package/packages/realtime/src/index.ts +0 -4
  301. package/packages/realtime/tests/ack-routing.test.ts +0 -81
  302. package/packages/realtime/tests/column-filter.test.ts +0 -144
  303. package/packages/realtime/tests/dispatch.test.ts +0 -191
  304. package/packages/realtime/tests/heartbeat.test.ts +0 -67
  305. package/packages/realtime/tests/http-broadcast.test.ts +0 -68
  306. package/packages/realtime/tests/realtime-token.test.ts +0 -43
  307. package/packages/realtime/tests/reconnect-race.test.ts +0 -149
  308. package/packages/realtime/tests/ref-id.test.ts +0 -34
  309. package/packages/realtime/tests/set-auth.test.ts +0 -70
  310. package/packages/realtime/tsconfig.json +0 -5
  311. package/packages/realtime/tsup.config.ts +0 -11
  312. package/packages/storage/LICENSE +0 -21
  313. package/packages/storage/README.md +0 -141
  314. package/packages/storage/dist/index.cjs +0 -333
  315. package/packages/storage/dist/index.d.cts +0 -185
  316. package/packages/storage/dist/index.d.ts +0 -185
  317. package/packages/storage/dist/index.js +0 -329
  318. package/packages/storage/node_modules/.bin/esbuild +0 -19
  319. package/packages/storage/node_modules/.bin/tsc +0 -22
  320. package/packages/storage/node_modules/.bin/tsserver +0 -22
  321. package/packages/storage/node_modules/.bin/tsup +0 -22
  322. package/packages/storage/node_modules/.bin/tsup-node +0 -22
  323. package/packages/storage/node_modules/.bin/vite +0 -22
  324. package/packages/storage/node_modules/.bin/vitest +0 -22
  325. package/packages/storage/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  326. package/packages/storage/package.json +0 -60
  327. package/packages/storage/src/DownloadBuilder.ts +0 -60
  328. package/packages/storage/src/StorageService.ts +0 -323
  329. package/packages/storage/src/index.ts +0 -2
  330. package/packages/storage/src/path.ts +0 -35
  331. package/packages/storage/src/transform.ts +0 -15
  332. package/packages/storage/tests/download.test.ts +0 -64
  333. package/packages/storage/tests/parity.test.ts +0 -154
  334. package/packages/storage/tests/path.test.ts +0 -87
  335. package/packages/storage/tests/transform.test.ts +0 -79
  336. package/packages/storage/tsconfig.json +0 -5
  337. package/packages/storage/tsup.config.ts +0 -11
  338. package/pnpm-workspace.yaml +0 -24
  339. package/tsconfig.base.json +0 -15
  340. /package/{packages/aurabase/dist → dist}/index.cjs +0 -0
  341. /package/{packages/aurabase/dist → dist}/index.js +0 -0
  342. /package/{packages/aurabase/dist → dist}/ssr.cjs +0 -0
  343. /package/{packages/aurabase/dist → dist}/ssr.js +0 -0
@@ -1,1137 +0,0 @@
1
- /**
2
- * Codes d'erreur produits par le SDK (LOT 3, finding I4 : taxonomie ad hoc non
3
- * typée). Union fermée de tous les codes émis SDK-side (`grep new AuraError` sur
4
- * `packages/*\/src`) + les codes backend usuels rencontrés (`PGRST116`), plus
5
- * `(string & {})` pour rester ouvert à tout code backend arbitraire (`error.error.code`)
6
- * sans perdre l'autocomplétion sur les codes connus (pattern "LiteralUnion").
7
- *
8
- * Provenance des codes SDK-side :
9
- * - fetch.ts (core) : no_session, network_error, invalid_response, refresh_discarded, timeout
10
- * - AuthService.ts : no_session, pkce_generation_failed, no_code_verifier, missing_email,
11
- * unverifiable_token, invalid_issuer, invalid_audience
12
- * - jwks.ts : jwks_fetch_failed, no_matching_key, signature_invalid, token_expired,
13
- * token_not_yet_valid, invalid_jwt, unsupported_alg
14
- * - storage/path.ts : invalid_path
15
- * - db/QueryBuilder.ts: PGRST116 (parité PostgREST : `.single()` sur 0/plusieurs lignes)
16
- */
17
- type AuraErrorCode = 'no_session' | 'timeout' | 'network_error' | 'invalid_response' | 'refresh_discarded' | 'unverifiable_token' | 'no_code_verifier' | 'pkce_generation_failed' | 'missing_email' | 'jwks_fetch_failed' | 'signature_invalid' | 'token_expired' | 'token_not_yet_valid' | 'invalid_jwt' | 'unsupported_alg' | 'no_matching_key' | 'invalid_issuer' | 'invalid_audience' | 'invalid_path' | 'PGRST116' | (string & {});
18
- /**
19
- * Structured error thrown/returned by the Aurabase SDK.
20
- * Mirrors the backend's `AuraError` JSON shape.
21
- */
22
- declare class AuraError extends Error {
23
- readonly status: number;
24
- readonly code: AuraErrorCode;
25
- readonly details: unknown;
26
- /** Marqueur runtime pour `isAuraError` (détection cross-realm/cross-bundle). */
27
- protected readonly __isAuraError = true;
28
- constructor(status: number, body?: {
29
- error?: {
30
- code?: string;
31
- message?: string;
32
- };
33
- message?: string;
34
- } | null);
35
- get isNotFound(): boolean;
36
- get isUnauthorized(): boolean;
37
- get isForbidden(): boolean;
38
- get isRateLimited(): boolean;
39
- }
40
- declare function isAuraError(error: unknown): error is AuraError;
41
-
42
- interface Meta {
43
- total?: number;
44
- next_cursor?: string;
45
- }
46
- interface AuraResponse<T> {
47
- data: T | null;
48
- error: AuraError | null;
49
- meta?: Meta;
50
- }
51
- interface User {
52
- id: string;
53
- email: string | null;
54
- phone?: string | null;
55
- role: string;
56
- email_verified: boolean;
57
- is_banned: boolean;
58
- is_anonymous: boolean;
59
- mfa_enabled: boolean;
60
- avatar_url?: string | null;
61
- name?: string | null;
62
- user_metadata: Record<string, unknown>;
63
- app_metadata: Record<string, unknown>;
64
- created_at: string;
65
- last_sign_in_at?: string | null;
66
- }
67
- interface TokenPair {
68
- access_token: string;
69
- refresh_token: string;
70
- token_type: string;
71
- expires_in: number;
72
- user: User;
73
- provider_token?: string | null;
74
- provider_refresh_token?: string | null;
75
- }
76
- interface MfaChallenge {
77
- mfa_required: true;
78
- mfa_token: string;
79
- mfa_setup_required?: boolean;
80
- }
81
- type LoginResponse = TokenPair | MfaChallenge;
82
- type AuthEvent = 'INITIAL_SESSION' | 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED' | 'MFA_CHALLENGE' | 'PASSWORD_RECOVERY';
83
- /**
84
- * Payload émis par `onAuthStateChange`. NOTE (LOT 3, 3.4) : `mfaToken`/`mfaSetupRequired`
85
- * ne sont présents QUE lorsque `event === 'MFA_CHALLENGE'` (posés par `AuthService`
86
- * uniquement sur cet événement — voir `_emitEvent` dans `AuthService.ts`) ; sur tout
87
- * autre `event`, ces deux champs sont `undefined`. Le type reste une interface plate
88
- * (pas une union discriminée) pour ne pas casser les consommateurs existants qui
89
- * déstructurent `{event, user, accessToken}` sans varier selon `event` — mais un
90
- * consommateur qui lit `mfaToken` DOIT d'abord vérifier `event === 'MFA_CHALLENGE'`.
91
- */
92
- interface AuthChangePayload {
93
- event: AuthEvent;
94
- user: User | null;
95
- accessToken: string | null;
96
- /** Présent uniquement si `event === 'MFA_CHALLENGE'`. */
97
- mfaToken?: string;
98
- /** Présent uniquement si `event === 'MFA_CHALLENGE'`. */
99
- mfaSetupRequired?: boolean;
100
- /**
101
- * Token de récupération opaque à passer à `resetPassword(token, newPassword)`.
102
- * Présent uniquement si `event === 'PASSWORD_RECOVERY'` (extrait du lien email
103
- * `?token=…&type=recovery` par `detectSessionInUrl`). `undefined` sur tout autre
104
- * événement.
105
- */
106
- recoveryToken?: string;
107
- }
108
- interface SignUpRequest {
109
- email: string;
110
- password: string;
111
- captcha_token?: string;
112
- }
113
- interface SignInRequest {
114
- email: string;
115
- password: string;
116
- captcha_token?: string;
117
- }
118
- interface MagicLinkRequest {
119
- email: string;
120
- create_user?: boolean;
121
- captcha_token?: string;
122
- redirect_url?: string;
123
- }
124
- interface OAuthSignInOptions {
125
- redirectTo?: string;
126
- scopes?: string;
127
- queryParams?: Record<string, string>;
128
- /**
129
- * Active le flux PKCE (génère + stocke un `code_verifier`, envoie
130
- * `code_challenge`/`code_challenge_method=S256` au provider). Opt-in :
131
- * absent ou `'implicit'` conserve le comportement existant (aucun
132
- * paramètre PKCE) pour ne pas casser silencieusement les consommateurs
133
- * actuels du flux implicite.
134
- */
135
- flowType?: 'pkce' | 'implicit';
136
- }
137
- interface PasswordResetRequest {
138
- email: string;
139
- }
140
- interface UpdateUserRequest {
141
- email?: string;
142
- phone?: string;
143
- password?: string;
144
- current_password?: string;
145
- data?: Record<string, unknown>;
146
- }
147
- interface MfaEnrollResponse {
148
- otpauth_url: string;
149
- secret: string;
150
- }
151
- interface MfaVerifyRequest {
152
- mfa_token: string;
153
- code: string;
154
- }
155
- interface SessionInfo {
156
- id: string;
157
- device_info?: string | null;
158
- ip_address?: string | null;
159
- created_at: string;
160
- expires_at: string;
161
- last_used_at: string;
162
- is_current: boolean;
163
- }
164
- type FilterOp = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'not_in' | 'like' | 'ilike' | 'is_null' | 'is_not_null' | 'between';
165
- interface QueryFilter {
166
- column: string;
167
- op: string;
168
- value: unknown;
169
- }
170
- type CountMode = 'exact' | 'estimated';
171
- interface QueryOptions {
172
- select?: string[];
173
- filters?: QueryFilter[];
174
- sort_by?: string;
175
- sort_order?: 'asc' | 'desc';
176
- limit?: number;
177
- offset?: number;
178
- count?: CountMode;
179
- }
180
- interface SchemaColumn {
181
- name: string;
182
- col_type: string;
183
- nullable: boolean;
184
- unique: boolean;
185
- default_val?: string | null;
186
- references?: {
187
- table: string;
188
- column: string;
189
- constraint_name?: string | null;
190
- } | null;
191
- }
192
- interface SchemaIndex {
193
- name: string;
194
- columns: string[];
195
- unique: boolean;
196
- }
197
- interface SchemaTable {
198
- name: string;
199
- columns: SchemaColumn[];
200
- primary_key?: string;
201
- indexes: SchemaIndex[];
202
- rls_enabled: boolean;
203
- realtime_enabled: boolean;
204
- }
205
- interface SchemaFunctionArg {
206
- name: string;
207
- data_type: string;
208
- mode: string;
209
- }
210
- interface SchemaFunction {
211
- name: string;
212
- args: SchemaFunctionArg[];
213
- returns: string;
214
- is_set_returning: boolean;
215
- }
216
- /**
217
- * Type enum Postgres (`pg_type.typtype='e'`) exposé par `GET /schema` (LOT B).
218
- * `values` est ordonné (`enumsortorder`). Le générateur SDK (`@aurabase/gen`)
219
- * en dérive une union de littéraux `Database['public']['Enums'][name]`.
220
- */
221
- interface SchemaEnum {
222
- name: string;
223
- values: string[];
224
- }
225
- /**
226
- * Options de transformation d'image (vocabulaire façon Supabase) appliquées
227
- * côté rendu backend (`GET /v1/storage/{pid}/{bucket}/{key}?width=&height=&
228
- * fit=&format=&quality=`). Voir `renderTransformParams` (`@aurabase/storage`)
229
- * pour le mapping vers les query params du backend.
230
- */
231
- interface ImageTransform {
232
- width?: number;
233
- height?: number;
234
- resize?: 'cover' | 'contain' | 'fill';
235
- quality?: number;
236
- format?: 'origin' | 'jpeg' | 'png' | 'webp' | 'gif';
237
- }
238
- interface StorageBucket {
239
- id: string;
240
- name: string;
241
- public: boolean;
242
- file_size_limit?: number | null;
243
- allowed_mime_types?: string[] | null;
244
- created_at: string;
245
- updated_at: string;
246
- }
247
- interface UploadResult {
248
- /** Clé unique de l'objet (`<uuid>.<ext>`) relative au bucket. */
249
- key: string;
250
- url: string;
251
- size: number;
252
- mime_type: string;
253
- }
254
- interface FileEntry {
255
- name: string;
256
- id?: string;
257
- bucket_id: string;
258
- size: number;
259
- mime_type: string;
260
- created_at: string;
261
- updated_at: string;
262
- metadata?: Record<string, unknown>;
263
- }
264
- /** Métadonnées d'un objet storage — forme réelle retournée par getMetadata() */
265
- interface ObjectMeta {
266
- key: string;
267
- bucket: string;
268
- size: number;
269
- content_type: string;
270
- etag?: string | null;
271
- last_modified?: string | null;
272
- metadata: Record<string, string>;
273
- }
274
- /** Événement serveur brut reçu via WebSocket (union discriminée par type) */
275
- type ServerMessage = ServerSubscribedMsg | ServerEventMsg | ServerPongMsg | ServerErrorMsg | ServerTokenRefreshedMsg | ServerPresenceStateMsg | BroadcastAckMessage;
276
- interface ServerSubscribedMsg {
277
- type: 'subscribed';
278
- channel: string;
279
- subscription_id?: string;
280
- history: RealtimeEvent[];
281
- ref_id?: string;
282
- }
283
- interface ServerEventMsg {
284
- type: 'event';
285
- id: string;
286
- event: 'insert' | 'update' | 'delete' | 'broadcast' | 'presence' | 'system';
287
- topic: string;
288
- payload: Record<string, unknown>;
289
- timestamp: string;
290
- allowed_sub_ids?: string[];
291
- }
292
- interface ServerPongMsg {
293
- type: 'pong';
294
- }
295
- interface ServerErrorMsg {
296
- type: 'error';
297
- message: string;
298
- }
299
- interface ServerTokenRefreshedMsg {
300
- type: 'token_refreshed';
301
- }
302
- interface ServerPresenceStateMsg {
303
- type: 'presence_state';
304
- channel: string;
305
- presences: PresenceInfo[];
306
- }
307
- /** Événement realtime (CDC, broadcast, presence) */
308
- interface RealtimeEvent<T = Record<string, unknown>> {
309
- id: string;
310
- event: 'insert' | 'update' | 'delete' | 'broadcast' | 'presence' | 'system';
311
- topic: string;
312
- payload: T;
313
- timestamp: string;
314
- /** IDs des subscriptions autorisées par RLS. Absent = pas de filtre. */
315
- allowed_sub_ids?: string[];
316
- /** Ref ID corrélé à la requête client (si fourni) */
317
- ref_id?: string;
318
- }
319
- /** Accusé de réception d'un broadcast (envoyé si config.broadcast.ack = true) */
320
- interface BroadcastAckMessage {
321
- type: 'broadcast_ack';
322
- message_id: string;
323
- ref_id?: string;
324
- }
325
- /** Payload CDC (postgres_changes) avec old_record et type d'operation */
326
- interface CdcPayload {
327
- schema: string;
328
- table: string;
329
- type: 'INSERT' | 'UPDATE' | 'DELETE';
330
- record: Record<string, unknown>;
331
- old_record: Record<string, unknown> | null;
332
- _truncated?: boolean;
333
- }
334
- /** Status de subscription */
335
- type RealtimeSubscribeStatus = 'SUBSCRIBED' | 'CLOSED' | 'CHANNEL_ERROR' | 'TIMED_OUT';
336
- /** Callback de subscription */
337
- type SubscribeCallback = (status: RealtimeSubscribeStatus, err?: Error) => void;
338
- /** Types d'écoute supportés (pattern Supabase) */
339
- type RealtimeListenType = 'postgres_changes' | 'broadcast' | 'presence';
340
- /** Config pour postgres_changes */
341
- interface PostgresChangesFilter {
342
- event: 'INSERT' | 'UPDATE' | 'DELETE' | '*';
343
- schema?: string;
344
- table?: string;
345
- /**
346
- * Filtre sur colonne, syntaxe PostgREST/Supabase : `"column=operator.value"`.
347
- *
348
- * **Opérateurs supportés** : `eq, neq, lt, lte, gt, gte, in, like, ilike, is,
349
- * match, imatch, isdistinct`.
350
- *
351
- * - `eq`/`neq` : égalité/inégalité (comparaison textuelle).
352
- * - `lt`/`lte`/`gt`/`gte` : comparaison numérique (échoue — pas de match — si
353
- * la valeur n'est pas numérique).
354
- * - `in` : appartenance à une liste, `"status=in.(active,pending)"`.
355
- * - `like`/`ilike` : motif SQL (`%` = sous-chaîne, `_` = 1 caractère), `ilike`
356
- * insensible à la casse. Ex: `"name=like.jo%"`.
357
- * - `is` : `"col=is.null"` / `"col=is.true"` / `"col=is.false"` — compare la
358
- * valeur JSON réelle, pas sa représentation texte.
359
- * - `match`/`imatch` : expression régulière (`imatch` insensible à la casse).
360
- * - `isdistinct` : distinct au sens SQL — `NULL` est distinct de toute valeur
361
- * non-NULL.
362
- *
363
- * **Négation** : préfixer l'opérateur par `not.`, ex: `"status=not.eq.done"`.
364
- *
365
- * **AND** : plusieurs conditions séparées par des virgules, ex:
366
- * `"room_id=eq.42,qty=gt.5"` (toutes doivent matcher). Les virgules internes
367
- * d'un `in.(a,b,c)` ne séparent PAS les conditions.
368
- *
369
- * **Où c'est évalué** : le serveur `aura-realtime` filtre ces conditions de
370
- * façon **autoritaire** avant l'envoi au client — un `filter` invalide y est
371
- * fail-closed (l'event est exclu, jamais laissé passer par défaut). Le SDK
372
- * réévalue ensuite la même syntaxe côté client comme second rideau
373
- * (defense-in-depth) : il ne peut que sur-filtrer, jamais faire fuiter un
374
- * event que le serveur aurait dû exclure.
375
- *
376
- * **DELETE** : le prédicat est évalué sur l'**ancienne ligne** (`old_record`),
377
- * puisque le `record` d'un DELETE est vide côté CDC. Si votre table utilise
378
- * `REPLICA IDENTITY DEFAULT`, `old_record` ne contient que la clé primaire —
379
- * un filtre sur une autre colonne exclura systématiquement les DELETE, **sauf
380
- * `is.null`/`isdistinct`** qui traitent une colonne absente comme `NULL` et
381
- * peuvent donc matcher même sans cette colonne dans `old_record`.
382
- */
383
- filter?: string;
384
- }
385
- /** Config pour broadcast */
386
- interface BroadcastFilter {
387
- event: string;
388
- }
389
- /** Config pour presence */
390
- interface PresenceFilter {
391
- event: 'sync' | 'join' | 'leave';
392
- }
393
- /** Options de channel — compatible Supabase */
394
- interface ChannelConfig {
395
- private?: boolean;
396
- /** Configuration broadcast pour ce channel */
397
- broadcast?: {
398
- /** Si true, le serveur ACK chaque send() (résout la Promise) */
399
- ack?: boolean;
400
- /** Si true, le client reçoit ses propres broadcasts (self-echo) */
401
- self?: boolean;
402
- };
403
- /** Configuration présence */
404
- config?: {
405
- presence?: {
406
- /** Clé de présence — permet de regrouper plusieurs onglets/devices du même user */
407
- key?: string;
408
- };
409
- };
410
- }
411
- /** Payload d'un broadcast à envoyer */
412
- interface BroadcastPayload {
413
- type: 'broadcast';
414
- event: string;
415
- payload: Record<string, unknown>;
416
- /** Ref ID pour la corrélation request/response (optionnel) */
417
- ref_id?: string;
418
- }
419
- /** Presence state (map de key → presences) */
420
- type PresenceState = Record<string, PresenceInfo[]>;
421
- interface PresenceInfo {
422
- client_id: string;
423
- user_id?: string | null;
424
- metadata: Record<string, unknown>;
425
- joined_at: string;
426
- last_seen: string;
427
- }
428
- interface ChatMessage {
429
- role: 'system' | 'user' | 'assistant';
430
- content: string;
431
- }
432
- interface ChatResponse {
433
- model: string;
434
- content: string;
435
- input_tokens?: number;
436
- output_tokens?: number;
437
- }
438
- interface EmbedRequest {
439
- text: string;
440
- namespace: string;
441
- metadata?: Record<string, unknown>;
442
- }
443
- interface EmbedResponse {
444
- id: string;
445
- dimensions: number;
446
- }
447
- interface RagRequest {
448
- question: string;
449
- namespace: string;
450
- history?: ChatMessage[];
451
- system?: string;
452
- }
453
- interface RagResponse {
454
- answer: string;
455
- sources: Array<{
456
- id: string;
457
- content: string;
458
- metadata: Record<string, unknown>;
459
- similarity: number;
460
- }>;
461
- model: string;
462
- tokens?: number;
463
- }
464
- interface RagIngestRequest {
465
- namespace: string;
466
- content: string;
467
- metadata?: Record<string, unknown>;
468
- }
469
- interface RagIngestResponse {
470
- id: string;
471
- chunks: number;
472
- }
473
- interface SemanticSearchResult {
474
- id: string;
475
- content: string;
476
- metadata: Record<string, unknown>;
477
- similarity: number;
478
- }
479
- interface FunctionDef {
480
- id: string;
481
- project_id: string;
482
- name: string;
483
- runtime: string;
484
- code: string;
485
- code_hash: string;
486
- env_vars: Record<string, unknown>;
487
- is_active: boolean;
488
- created_at: string;
489
- updated_at: string;
490
- }
491
- interface Job {
492
- id: string;
493
- project_id: string;
494
- function_name: string;
495
- status: 'pending' | 'running' | 'completed' | 'failed' | 'dead';
496
- payload: unknown;
497
- attempts: number;
498
- max_attempts: number;
499
- error?: string | null;
500
- scheduled_at: string;
501
- started_at?: string | null;
502
- created_at: string;
503
- completed_at?: string | null;
504
- }
505
- interface CronJob {
506
- id: string;
507
- project_id: string;
508
- name: string;
509
- schedule: string;
510
- function_name: string;
511
- payload: unknown;
512
- is_active: boolean;
513
- last_run?: string | null;
514
- next_run?: string | null;
515
- created_at: string;
516
- }
517
- interface Notification {
518
- id: string;
519
- project_id?: string;
520
- channel: 'email' | 'sms' | 'push' | 'webhook';
521
- recipient: string;
522
- subject?: string | null;
523
- body: string;
524
- status: 'queued' | 'processing' | 'sent' | 'failed' | 'delivered' | 'expired' | 'dead_lettered';
525
- error?: string | null;
526
- metadata?: Record<string, unknown>;
527
- attempt_count?: number;
528
- last_attempt_at?: string | null;
529
- next_attempt_at?: string | null;
530
- locked_until?: string | null;
531
- lock_owner?: string | null;
532
- provider_message_id?: string | null;
533
- delivered_at?: string | null;
534
- expires_at?: string | null;
535
- idempotency_key?: string | null;
536
- payload_hash?: string | null;
537
- last_error?: string | null;
538
- last_error_code?: string | null;
539
- last_provider_response?: string | null;
540
- processing_started_at?: string | null;
541
- completed_at?: string | null;
542
- updated_at?: string;
543
- sent_at?: string | null;
544
- created_at: string;
545
- }
546
- interface SendNotificationRequest {
547
- channel: 'email' | 'sms' | 'push' | 'webhook';
548
- recipient: string;
549
- body?: string;
550
- subject?: string;
551
- template_id?: string;
552
- variables?: Record<string, unknown>;
553
- metadata?: Record<string, unknown>;
554
- idempotency_key?: string;
555
- }
556
- interface BatchSendItemResult {
557
- index: number;
558
- status: 'queued' | 'error';
559
- notification?: Notification | null;
560
- error?: string | null;
561
- }
562
- interface BatchSendResponse {
563
- items: BatchSendItemResult[];
564
- }
565
- interface NotificationTemplate {
566
- id: string;
567
- name: string;
568
- channel: 'email' | 'sms' | 'push' | 'webhook';
569
- subject?: string | null;
570
- body: string;
571
- variables?: string[];
572
- created_at: string;
573
- updated_at: string;
574
- }
575
- interface NotificationTemplatePreview {
576
- subject?: string | null;
577
- body: string;
578
- }
579
- interface NotificationAttempt {
580
- id: string;
581
- notification_id: string;
582
- project_id: string;
583
- channel: 'email' | 'sms' | 'push' | 'webhook';
584
- provider: string;
585
- attempt_number: number;
586
- status: 'processing' | 'sent' | 'failed' | 'retry_scheduled' | 'dead_lettered';
587
- started_at: string;
588
- completed_at?: string | null;
589
- duration_ms?: number | null;
590
- error_code?: string | null;
591
- error_message?: string | null;
592
- provider_response?: string | null;
593
- created_at: string;
594
- }
595
- interface NotificationDeadLetter {
596
- id: string;
597
- notification_id: string;
598
- project_id: string;
599
- channel: 'email' | 'sms' | 'push' | 'webhook';
600
- recipient: string;
601
- subject?: string | null;
602
- body: string;
603
- metadata?: Record<string, unknown>;
604
- payload_hash?: string | null;
605
- idempotency_key?: string | null;
606
- attempt_count: number;
607
- last_error: string;
608
- last_error_code: string;
609
- last_provider_response?: string | null;
610
- failed_at: string;
611
- created_at: string;
612
- }
613
- interface NotificationEvent {
614
- id: string;
615
- project_id: string;
616
- subject: string;
617
- event_type: string;
618
- status: 'received' | 'matched' | 'ignored' | 'failed' | 'enqueued';
619
- rule_id?: string | null;
620
- notification_id?: string | null;
621
- error?: string | null;
622
- metadata?: Record<string, unknown>;
623
- created_at: string;
624
- }
625
- interface NotificationProviderLog {
626
- timestamp: string;
627
- notification_id: string;
628
- channel: 'email' | 'sms' | 'push' | 'webhook';
629
- provider: string;
630
- status: string;
631
- duration_ms?: number | null;
632
- error_code?: string | null;
633
- error_message?: string | null;
634
- provider_response?: string | null;
635
- provider_message_id?: string | null;
636
- }
637
- interface NotificationQueueStats {
638
- queued_count: number;
639
- processing_count: number;
640
- retry_scheduled_count: number;
641
- expired_processing_count: number;
642
- next_retry_at_min?: string | null;
643
- }
644
- interface NotificationChannelStats {
645
- channel: 'email' | 'sms' | 'push' | 'webhook';
646
- total: number;
647
- sent: number;
648
- delivered: number;
649
- failed: number;
650
- dead_lettered: number;
651
- queued: number;
652
- processing: number;
653
- success_rate: number;
654
- failure_rate: number;
655
- }
656
- interface NotificationStats {
657
- window: string;
658
- channel?: 'email' | 'sms' | 'push' | 'webhook' | null;
659
- total: number;
660
- sent: number;
661
- delivered: number;
662
- failed: number;
663
- dead_lettered: number;
664
- queued: number;
665
- processing: number;
666
- success_rate: number;
667
- failure_rate: number;
668
- by_status: Array<{
669
- status: string;
670
- count: number;
671
- }>;
672
- by_channel: NotificationChannelStats[];
673
- timeline: Array<{
674
- bucket: string;
675
- total: number;
676
- sent: number;
677
- delivered: number;
678
- failed: number;
679
- dead_lettered: number;
680
- }>;
681
- }
682
- interface NotificationSettings {
683
- project_id: string;
684
- smtp?: Record<string, unknown>;
685
- twilio?: Record<string, unknown>;
686
- fcm?: Record<string, unknown>;
687
- apns?: Record<string, unknown>;
688
- webhook?: Record<string, unknown>;
689
- quotas?: Record<string, unknown>;
690
- updated_at?: string | null;
691
- }
692
- interface NotificationRule {
693
- id: string;
694
- project_id: string;
695
- name: string;
696
- trigger_type: string;
697
- condition: Record<string, unknown>;
698
- template_id?: string | null;
699
- channel: 'email' | 'sms' | 'push' | 'webhook';
700
- recipient_expr: string;
701
- enabled: boolean;
702
- delay_seconds: number;
703
- fire_count: number;
704
- last_fired_at?: string | null;
705
- created_at: string;
706
- updated_at: string;
707
- }
708
- /**
709
- * Événement d'observabilité interne du SDK. Émis best-effort via le hook `onEvent`
710
- * (option client) et/ou `console.debug` (option `debug: true`) — voir `emitAuraEvent`.
711
- * Les erreurs sont massivement avalées ailleurs dans le SDK (`catch {}` JWKS/storage/
712
- * cookie/subscribers) : ce hook rend visibles les retries, timeouts, refresh
713
- * silencieux et échecs JWKS/storage sans changer le contrat `AuraResponse`.
714
- */
715
- type AuraObservabilityEvent = {
716
- kind: 'retry';
717
- attempt: number;
718
- status?: number;
719
- url: string;
720
- } | {
721
- kind: 'timeout';
722
- url: string;
723
- } | {
724
- kind: 'refresh-success';
725
- } | {
726
- kind: 'refresh-discarded';
727
- reason: string;
728
- } | {
729
- kind: 'jwks-fetch-failed';
730
- baseUrl: string;
731
- } | {
732
- kind: 'storage-blocked';
733
- op: string;
734
- };
735
- declare function emitAuraEvent(onEvent: ((event: AuraObservabilityEvent) => void) | undefined, debug: boolean | undefined, event: AuraObservabilityEvent): void;
736
- interface AuraClientOptions {
737
- auth?: {
738
- persistSession?: boolean;
739
- storage?: BaseAuthStore;
740
- /** Refresh proactif en arrière-plan + synchro multi-onglets (défaut true). */
741
- autoRefresh?: boolean;
742
- /**
743
- * Détecte et consomme automatiquement une session présente dans l'URL au boot
744
- * du client (callback OAuth) : fragment `#access_token=…` (flux implicit) ou
745
- * query `?code=…` (flux PKCE), puis nettoie l'URL via `history.replaceState`.
746
- * Défaut : `true` en navigateur, no-op hors navigateur (SSR/Node).
747
- */
748
- detectSessionInUrl?: boolean;
749
- };
750
- apiKey?: string;
751
- fetch?: typeof globalThis.fetch;
752
- /**
753
- * SEC-F5 : si une clé `service_role` (`aura_sk_…`) est fournie en contexte NAVIGATEUR
754
- * (thread principal ou Web Worker navigateur), `true` (DÉFAUT) fait ÉCHOUER la
755
- * construction du client (`throw`) — cette clé à privilèges élevés (BYPASSRLS)
756
- * fuiterait dans le bundle JS = compromission totale du projet. `false` rétrograde
757
- * en simple `console.warn` (échappatoire explicite, à n'utiliser qu'en connaissance
758
- * de cause). Sans effet côté serveur (où service_role est légitime).
759
- */
760
- refuseServiceRoleInBrowser?: boolean;
761
- /** Retry transitoire des GET/HEAD (activé par défaut). `false` désactive. */
762
- retry?: boolean | {
763
- enabled?: boolean;
764
- maxRetries?: number;
765
- };
766
- /**
767
- * Timeout par défaut (ms) des requêtes JSON sans `signal` fourni (borne un serveur
768
- * qui « hang »). N'affecte ni les uploads FormData ni les appels gérant leur propre
769
- * annulation (invoke, download). `0` désactive. Défaut : 30 000 ms.
770
- */
771
- requestTimeoutMs?: number;
772
- /**
773
- * Hook d'observabilité (LOT 3, finding I8) : reçoit chaque `AuraObservabilityEvent`
774
- * (retry transitoire, timeout, refresh de session réussi/écarté, échec fetch JWKS,
775
- * storage bloqué). Best-effort — le SDK l'appelle dans un try/catch, ce hook ne
776
- * peut jamais faire échouer une requête. `undefined` par défaut (aucune émission).
777
- */
778
- onEvent?: (event: AuraObservabilityEvent) => void;
779
- /**
780
- * Si `true`, chaque `AuraObservabilityEvent` est aussi journalisé via
781
- * `console.debug('[aurabase]', event)`, en plus (ou à la place) du hook `onEvent`.
782
- * Défaut `false`.
783
- */
784
- debug?: boolean;
785
- }
786
- interface IdentityInfo {
787
- id: string;
788
- provider: string;
789
- provider_id: string;
790
- identity_data: Record<string, unknown>;
791
- auto_linked: boolean;
792
- created_at: string;
793
- }
794
- interface AdminUser extends User {
795
- }
796
- interface AuditLogEntry {
797
- id: string;
798
- user_id?: string | null;
799
- action: string;
800
- ip_address?: string | null;
801
- user_agent?: string | null;
802
- created_at: string;
803
- }
804
- interface UserStats {
805
- total: number;
806
- verified: number;
807
- banned: number;
808
- mfa_enabled: number;
809
- new_7d: number;
810
- }
811
- /**
812
- * Sessions vues depuis l'admin (endpoint `admin/sessions`) : contient `user_id`
813
- * (toutes sessions, tous utilisateurs) mais pas `is_current` (contrairement à
814
- * `SessionInfo`, qui décrit les sessions de l'utilisateur courant).
815
- */
816
- interface AdminSessionInfo {
817
- id: string;
818
- user_id: string;
819
- device_info?: string | null;
820
- ip_address?: string | null;
821
- created_at: string;
822
- expires_at: string;
823
- last_used_at: string;
824
- }
825
- interface AuthSettings {
826
- allow_signup: boolean;
827
- email_confirmation_required: boolean;
828
- password_min_length: number;
829
- mfa_enabled: boolean;
830
- allow_anonymous_users: boolean;
831
- jwt_expiry_seconds: number;
832
- refresh_token_expiry_days: number;
833
- site_url?: string | null;
834
- oauth_providers: Record<string, {
835
- enabled?: boolean;
836
- client_id?: string;
837
- client_secret?: string;
838
- }>;
839
- new_device_alerts_enabled: boolean;
840
- webhook_url?: string | null;
841
- smtp_host?: string | null;
842
- smtp_port?: number | null;
843
- smtp_username?: string | null;
844
- smtp_password_set?: boolean;
845
- smtp_from_email?: string | null;
846
- smtp_from_name?: string | null;
847
- oauth_credentials: Record<string, Record<string, string>>;
848
- captcha_enabled: boolean;
849
- captcha_provider?: string | null;
850
- captcha_site_key?: string | null;
851
- captcha_secret_key_set?: boolean;
852
- password_check_hibp: boolean;
853
- sms_provider?: string | null;
854
- sms_api_key_set?: boolean;
855
- sms_from_number?: string | null;
856
- redirect_urls: string[];
857
- session_inactivity_timeout_seconds: number;
858
- hook_send_sms_url?: string | null;
859
- hook_send_email_url?: string | null;
860
- hook_mfa_verification_url?: string | null;
861
- hook_password_verification_url?: string | null;
862
- auto_link_by_email: boolean;
863
- revoke_on_new_device: boolean;
864
- enforce_ip_binding: boolean;
865
- allowed_email_domains: string[];
866
- blocked_email_domains: string[];
867
- updated_at: string;
868
- }
869
- interface EmailTemplateUpdate {
870
- subject: string;
871
- html_body: string;
872
- }
873
- interface AdminCreateUserRequest {
874
- email: string;
875
- password?: string;
876
- role?: string;
877
- email_verified?: boolean;
878
- user_metadata?: Record<string, unknown>;
879
- }
880
- interface AdminUpdateUserRequest {
881
- password?: string;
882
- role?: string;
883
- is_active?: boolean;
884
- is_banned?: boolean;
885
- email_verified?: boolean;
886
- user_metadata?: Record<string, unknown>;
887
- app_metadata?: Record<string, unknown>;
888
- mfa_enabled?: boolean;
889
- revoke_sessions?: boolean;
890
- }
891
- type GenerateLinkType = 'magic' | 'recovery' | 'invite';
892
- interface GenerateLinkResult {
893
- link: string;
894
- token: string;
895
- }
896
- interface JwtClaims {
897
- sub: string;
898
- exp?: number;
899
- iat?: number;
900
- nbf?: number;
901
- iss?: string;
902
- aud?: string | string[];
903
- role?: string;
904
- [key: string]: unknown;
905
- }
906
- interface GetClaimsResult {
907
- claims: JwtClaims;
908
- header: {
909
- alg: string;
910
- kid?: string;
911
- typ?: string;
912
- };
913
- }
914
-
915
- type AuthChangeCallback = (token: string | null, user: User | null) => void;
916
- /**
917
- * Check whether a JWT has expired (or will expire within `marginSec` seconds).
918
- */
919
- declare function isTokenExpired(token: string, marginSec?: number): boolean;
920
- /**
921
- * In-memory auth store with an event-emitter pattern.
922
- * Can be extended (see LocalAuthStore) for persistence.
923
- */
924
- declare class BaseAuthStore {
925
- /**
926
- * True si le store survit à un redirect pleine page (persistance disque, ex.
927
- * localStorage). Le store de base est en mémoire → non persistant. Exploité par
928
- * le flux PKCE : le `code_verifier` doit survivre au redirect OAuth.
929
- */
930
- readonly persistent: boolean;
931
- private _token;
932
- private _refreshToken;
933
- private _user;
934
- private _listeners;
935
- private _removalEpoch;
936
- /** Stockage générique clé/valeur (ex: PKCE `code_verifier`). En mémoire par défaut. */
937
- private _kv;
938
- /** Hook d'observabilité (LOT 3) — câblé par `AuraClient` via `setObservabilityHook`. */
939
- private _onEvent?;
940
- private _debug;
941
- /** Compteur incrémenté à chaque `clear()` — sert au commit-guard anti-race du refresh. */
942
- get removalEpoch(): number;
943
- get token(): string | null;
944
- get refreshToken(): string | null;
945
- get user(): User | null;
946
- /** True if a non-expired access token is present. */
947
- get isValid(): boolean;
948
- save(token: string, refreshToken: string, user: User): void;
949
- clear(): void;
950
- setItem(key: string, value: string): void;
951
- getItem(key: string): string | null;
952
- removeItem(key: string): void;
953
- /**
954
- * Câble le hook d'observabilité (appelé par `AuraClient` à la construction).
955
- * Permet à `LocalAuthStore` d'émettre `storage-blocked` quand `localStorage` est
956
- * indisponible (navigation privée Safari, quota dépassé, storage désactivé…).
957
- * Sans effet sur `BaseAuthStore` elle-même (en mémoire, jamais "bloquée").
958
- */
959
- setObservabilityHook(onEvent: ((event: AuraObservabilityEvent) => void) | undefined, debug: boolean | undefined): void;
960
- /** Émet `{kind:'storage-blocked', op}` — ne throw jamais (voir `emitAuraEvent`). */
961
- protected _emitStorageBlocked(op: string): void;
962
- /**
963
- * Register a callback that fires whenever the auth state changes.
964
- * Returns an unsubscribe function.
965
- */
966
- onChange(callback: AuthChangeCallback): () => void;
967
- protected _triggerChange(): void;
968
- }
969
-
970
- /**
971
- * Forme minimale du client consommée par `fetchWithAuth`, `BaseService`,
972
- * le `QueryBuilder` et les services. Le `AuraClient` concret (meta-package)
973
- * satisfait cette interface structurellement — ce qui casse le cycle de
974
- * dépendance core → meta (les services n'importent plus la classe concrète).
975
- */
976
- interface AuraClientLike {
977
- readonly baseUrl: string;
978
- readonly projectId: string;
979
- readonly apiKey: string | null;
980
- readonly fetchFn: typeof globalThis.fetch;
981
- readonly authStore: BaseAuthStore;
982
- /** Consommé uniquement par le service realtime (refresh proactif du token). */
983
- readonly auth: {
984
- refreshSession(): Promise<AuraResponse<TokenPair>>;
985
- };
986
- /** Config du retry transitoire. Défauts appliqués si absent : enabled=true, maxRetries=3. */
987
- readonly retryConfig?: {
988
- enabled: boolean;
989
- maxRetries: number;
990
- };
991
- /**
992
- * Timeout par défaut (ms) des requêtes HTTP. Appliqué UNIQUEMENT aux requêtes
993
- * JSON sans `signal` fourni (donc pas aux uploads FormData ni aux appels qui
994
- * gèrent déjà leur propre annulation). `0` désactive. Défaut : 30 000 ms.
995
- */
996
- readonly requestTimeoutMs?: number;
997
- /**
998
- * Hook d'observabilité (LOT 3, finding I8), optionnel — n'importe quelle implémentation
999
- * structurelle de `AuraClientLike` reste compatible sans le fournir (pas de breaking
1000
- * change). Consommé par `fetchWithAuth`/`refreshOnce` pour émettre retry/timeout/refresh.
1001
- */
1002
- readonly onEvent?: (event: AuraObservabilityEvent) => void;
1003
- /** Si `true`, chaque `AuraObservabilityEvent` est aussi journalisé via `console.debug`. */
1004
- readonly debug?: boolean;
1005
- }
1006
-
1007
- /** Point d'entrée unique du refresh, dédupliqué par client (single-flight). */
1008
- declare function refreshOnce(client: AuraClientLike): Promise<AuraResponse<TokenPair>>;
1009
- interface FetchInit {
1010
- method?: string;
1011
- headers?: Record<string, string>;
1012
- body?: unknown;
1013
- signal?: AbortSignal;
1014
- skipAuthRefresh?: boolean;
1015
- /**
1016
- * Override explicite du `Authorization: Bearer` (LOT D). S'il est fourni, il
1017
- * GAGNE sur `store.token` — permet de valider un token ARBITRAIRE (foreign)
1018
- * plutôt que celui de la session courante (ex. `getUser(jwt)`). Sans lui, le
1019
- * comportement historique s'applique (`Authorization = Bearer store.token`).
1020
- */
1021
- authToken?: string;
1022
- /** Désactive le retry transitoire pour cette requête (override). */
1023
- skipRetry?: boolean;
1024
- /** Interne (E19) : marque une requête déjà rejouée après refresh pour borner la récursion. */
1025
- _retried?: boolean;
1026
- }
1027
- /**
1028
- * Core fetch wrapper that handles:
1029
- * - Lazy token refresh before expiry
1030
- * - Authorization / API key injection
1031
- * - Content-Type defaulting
1032
- * - Structured AuraResponse parsing
1033
- */
1034
- declare function fetchWithAuth<T>(url: string, init: FetchInit, client: AuraClientLike): Promise<AuraResponse<T>>;
1035
-
1036
- /**
1037
- * Abstract base class for all service modules.
1038
- * Provides the shared HTTP helper and URL builder.
1039
- */
1040
- declare abstract class BaseService {
1041
- protected readonly client: AuraClientLike;
1042
- constructor(client: AuraClientLike);
1043
- /** Build a full URL for the given path. */
1044
- protected url(path: string): string;
1045
- /** Convenience HTTP helper that delegates to fetchWithAuth. */
1046
- protected request<T>(method: string, path: string, body?: unknown, options?: {
1047
- headers?: Record<string, string>;
1048
- signal?: AbortSignal;
1049
- skipAuthRefresh?: boolean;
1050
- /** Override explicite du Bearer (LOT D) — valide un token arbitraire. */
1051
- authToken?: string;
1052
- }): Promise<AuraResponse<T>>;
1053
- }
1054
-
1055
- interface CookieOptions {
1056
- path?: string;
1057
- domain?: string;
1058
- maxAge?: number;
1059
- secure?: boolean;
1060
- sameSite?: 'Strict' | 'Lax' | 'None';
1061
- httpOnly?: boolean;
1062
- }
1063
- /**
1064
- * Auth store backed by `localStorage` (browser) with cookie helpers for SSR.
1065
- */
1066
- declare class LocalAuthStore extends BaseAuthStore {
1067
- /** Persiste en localStorage → survit au redirect pleine page (cf. PKCE). */
1068
- readonly persistent = true;
1069
- private readonly key;
1070
- constructor(key?: string);
1071
- save(token: string, refreshToken: string, user: User): void;
1072
- clear(): void;
1073
- /**
1074
- * Supprime de localStorage tous les artefacts d'auth éphémères sur disque :
1075
- * - `code_verifier` PKCE (`aura-<projectId>-pkce-code-verifier`),
1076
- * - marqueur d'initiation OAuth implicit (`aura-<projectId>-oauth-implicit-initiated`,
1077
- * SEC-F3). Un `signOut`/`clear()` ne doit laisser aucun résidu réutilisable (parité
1078
- * `@supabase/ssr` : ces artefacts sont éphémères). On itère les clés préfixées pour
1079
- * couvrir un store partagé entre plusieurs projets, sans dépendre du `projectId` courant.
1080
- */
1081
- private _removePkceVerifiers;
1082
- setItem(key: string, value: string): void;
1083
- getItem(key: string): string | null;
1084
- removeItem(key: string): void;
1085
- /**
1086
- * Populate the store from a raw `Cookie` header string (server-side).
1087
- * Looks for the key matching `this.key`.
1088
- */
1089
- loadFromCookie(cookieString: string): void;
1090
- /**
1091
- * Serialize current auth state into a `Set-Cookie` value.
1092
- */
1093
- exportToCookie(options?: CookieOptions): string;
1094
- private _loadFromStorage;
1095
- private _persist;
1096
- private _removeStorage;
1097
- }
1098
-
1099
- /** JSON.stringify avec support des bigint (sérialisés en string). */
1100
- declare function serializeBody(body: unknown): string;
1101
-
1102
- /**
1103
- * Parse a raw Cookie header string into key-value pairs.
1104
- */
1105
- declare function parseCookieHeader(header: string): Record<string, string>;
1106
- interface SerializeCookieOptions {
1107
- path?: string;
1108
- domain?: string;
1109
- maxAge?: number;
1110
- secure?: boolean;
1111
- sameSite?: 'Strict' | 'Lax' | 'None';
1112
- httpOnly?: boolean;
1113
- }
1114
- /**
1115
- * Serialize a cookie name + value + options into a Set-Cookie header value.
1116
- */
1117
- declare function serializeCookieHeader(name: string, value: string, options?: SerializeCookieOptions): string;
1118
-
1119
- /**
1120
- * Primitives de résilience réseau (module pur, sans I/O).
1121
- * `Math.random`/`Date.now` sont injectables pour des tests déterministes.
1122
- */
1123
- declare const RETRYABLE_STATUS: Set<number>;
1124
- declare const RETRYABLE_METHODS: Set<string>;
1125
- declare const DEFAULT_MAX_RETRIES = 3;
1126
- declare function isRetryableStatus(status: number): boolean;
1127
- declare function isRetryableMethod(method: string): boolean;
1128
- /** Full jitter : random(0, min(BASE·2^attempt, CAP)). `attempt` commence à 0. */
1129
- declare function computeBackoff(attempt: number, rand?: () => number): number;
1130
- /** Parse un header `Retry-After` (secondes OU HTTP-date) → délai en ms, ou null. */
1131
- declare function parseRetryAfter(header: string | null, now?: number): number | null;
1132
- /** `sleep(ms)` qui résout tôt (sans rejeter) si `signal` s'annule. */
1133
- declare function abortableSleep(ms: number, signal?: AbortSignal): Promise<void>;
1134
- /** True si l'erreur `fetch` est une annulation utilisateur (jamais rejouée). */
1135
- declare function isAbortError(err: unknown): boolean;
1136
-
1137
- export { type AdminCreateUserRequest, type AdminSessionInfo, type AdminUpdateUserRequest, type AdminUser, type AuditLogEntry, type AuraClientLike, type AuraClientOptions, AuraError, type AuraErrorCode, type AuraObservabilityEvent, type AuraResponse, type AuthChangePayload, type AuthEvent, type AuthSettings, BaseAuthStore, BaseService, type BatchSendItemResult, type BatchSendResponse, type BroadcastAckMessage, type BroadcastFilter, type BroadcastPayload, type CdcPayload, type ChannelConfig, type ChatMessage, type ChatResponse, type CountMode, type CronJob, DEFAULT_MAX_RETRIES, type EmailTemplateUpdate, type EmbedRequest, type EmbedResponse, type FetchInit, type FileEntry, type FilterOp, type FunctionDef, type GenerateLinkResult, type GenerateLinkType, type GetClaimsResult, type IdentityInfo, type ImageTransform, type Job, type JwtClaims, LocalAuthStore, type LoginResponse, type MagicLinkRequest, type Meta, type MfaChallenge, type MfaEnrollResponse, type MfaVerifyRequest, type Notification, type NotificationAttempt, type NotificationChannelStats, type NotificationDeadLetter, type NotificationEvent, type NotificationProviderLog, type NotificationQueueStats, type NotificationRule, type NotificationSettings, type NotificationStats, type NotificationTemplate, type NotificationTemplatePreview, type OAuthSignInOptions, type ObjectMeta, type PasswordResetRequest, type PostgresChangesFilter, type PresenceFilter, type PresenceInfo, type PresenceState, type QueryFilter, type QueryOptions, RETRYABLE_METHODS, RETRYABLE_STATUS, type RagIngestRequest, type RagIngestResponse, type RagRequest, type RagResponse, type RealtimeEvent, type RealtimeListenType, type RealtimeSubscribeStatus, type SchemaColumn, type SchemaEnum, type SchemaFunction, type SchemaFunctionArg, type SchemaIndex, type SchemaTable, type SemanticSearchResult, type SendNotificationRequest, type SerializeCookieOptions, type ServerErrorMsg, type ServerEventMsg, type ServerMessage, type ServerPongMsg, type ServerPresenceStateMsg, type ServerSubscribedMsg, type ServerTokenRefreshedMsg, type SessionInfo, type SignInRequest, type SignUpRequest, type StorageBucket, type SubscribeCallback, type TokenPair, type UpdateUserRequest, type UploadResult, type User, type UserStats, abortableSleep, computeBackoff, emitAuraEvent, fetchWithAuth, isAbortError, isAuraError, isRetryableMethod, isRetryableStatus, isTokenExpired, parseCookieHeader, parseRetryAfter, refreshOnce, serializeBody, serializeCookieHeader };