@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,18 +0,0 @@
1
- import { expectTypeOf } from 'vitest'
2
- import { DatabaseService } from '../../src/DatabaseService'
3
- import type { Database } from './fixtures'
4
-
5
- declare const db: DatabaseService<Database>
6
-
7
- // COMPL LOT 4 : `from()` accepte les Views (générées par LOT C), pas seulement les
8
- // Tables. La vue `active_users` est non updatable → uniquement queryable en lecture.
9
-
10
- test('from(view).select(col) compile et infère le Row de la vue', async () => {
11
- const { data } = await db.from('active_users').select('email')
12
- expectTypeOf(data).toEqualTypeOf<{ email: string }[] | null>()
13
- })
14
-
15
- test('from(view).select(*) → Row complète de la vue', async () => {
16
- const { data } = await db.from('active_users').select('*')
17
- expectTypeOf(data).toEqualTypeOf<{ id: string; email: string }[] | null>()
18
- })
@@ -1,23 +0,0 @@
1
- import { DatabaseService } from '../../src/DatabaseService'
2
- import type { Database } from './fixtures'
3
-
4
- declare const db: DatabaseService<Database>
5
-
6
- test('insert exige les champs requis', () => {
7
- db.from('posts').insert({ author_id: 'u', title: 't' }) // OK (id optionnel)
8
- // @ts-expect-error title requis manquant
9
- db.from('posts').insert({ author_id: 'u' })
10
- })
11
-
12
- test('update accepte un body partiel typé', () => {
13
- db.from('posts').update('id1', { title: 'new' }) // OK
14
- // @ts-expect-error colonne inconnue
15
- db.from('posts').update('id1', { nope: 1 })
16
- })
17
-
18
- test('upsert typé sur Insert (array ou objet)', () => {
19
- db.from('posts').upsert({ author_id: 'u', title: 't' }) // OK
20
- db.from('posts').upsert([{ author_id: 'u', title: 't' }]) // OK
21
- // @ts-expect-error title requis manquant
22
- db.from('posts').upsert({ author_id: 'u' })
23
- })
@@ -1,60 +0,0 @@
1
- import { expectTypeOf } from 'vitest'
2
- import { DatabaseService } from '../../src/DatabaseService'
3
-
4
- // Fixture Database locale avec une fonction scalaire et une fonction SETOF liée
5
- // à une table (parité avec la sortie attendue de `@aurabase/gen` Phase B).
6
- type DB = {
7
- public: {
8
- Tables: {
9
- things: {
10
- Row: { id: number; name: string }
11
- Insert: { id?: number; name: string }
12
- Update: { id?: number; name?: string }
13
- Relationships: []
14
- }
15
- }
16
- Views: Record<string, never>
17
- Functions: {
18
- add: { Args: { a: number; b: number }; Returns: number }
19
- list_things: {
20
- Args: Record<string, never>
21
- Returns: { id: number; name: string }[]
22
- SetofOptions: { isSetofReturn: true; isOneToOne: false; to: 'things'; from: '*' }
23
- }
24
- }
25
- Enums: Record<string, never>
26
- CompositeTypes: Record<string, never>
27
- }
28
- }
29
-
30
- declare const db: DatabaseService<DB>
31
- // Fallback permissif : Database = any (comportement historique conservé).
32
- declare const untyped: DatabaseService
33
-
34
- test('rpc fort : args typés sur Schema["Functions"]', () => {
35
- db.rpc('add', { a: 1, b: 2 }) // OK
36
- // @ts-expect-error mauvais type d'arg (a doit être number)
37
- db.rpc('add', { a: 'x', b: 2 })
38
- })
39
-
40
- test('rpc SETOF : select post-rpc typé sur la table liée (SetofOptions.to)', async () => {
41
- const { data } = await db.rpc('list_things', {}).select('id,name').single()
42
- expectTypeOf(data).toMatchTypeOf<{ id: number; name: string } | null>()
43
- })
44
-
45
- // Verrouille le fix #1 (double-emballage) : `Fn['Result']` est DÉJÀ la charge
46
- // utile complète (scalaire pour une fonction scalaire, tableau pour un SETOF)
47
- // — le 5e générique du builder ne doit PAS ajouter un `[]` par-dessus.
48
- test('rpc fort : retour scalaire (Result), pas de sur-emballage en tableau', async () => {
49
- const { data } = await db.rpc('add', { a: 1, b: 2 })
50
- expectTypeOf(data).toEqualTypeOf<number | null>()
51
- })
52
-
53
- test('rpc SETOF sans .select() : Result est déjà un tableau (pas `[][]`)', async () => {
54
- const { data } = await db.rpc('list_things', {})
55
- expectTypeOf(data).toEqualTypeOf<{ id: number; name: string }[] | null>()
56
- })
57
-
58
- test('rpc fallback permissif (Database = any)', () => {
59
- untyped.rpc('whatever', { anything: true }) // OK, pas d'erreur de compilation
60
- })
@@ -1,8 +0,0 @@
1
- import { expectTypeOf } from 'vitest'
2
- import type { GenericSchema } from '../../src/pgrst-types/common/common'
3
- import type { Database } from './fixtures'
4
-
5
- // Un Database à la forme générée par @aurabase/gen (Phase 1) doit satisfaire GenericSchema.
6
- test('le Database généré satisfait GenericSchema', () => {
7
- expectTypeOf<Database['public']>().toMatchTypeOf<GenericSchema>()
8
- })
@@ -1,38 +0,0 @@
1
- import { expectTypeOf } from 'vitest'
2
- import { DatabaseService } from '../../src/DatabaseService'
3
- import type { Database } from './fixtures'
4
-
5
- declare const db: DatabaseService<Database>
6
-
7
- test('select colonnes → type restreint', async () => {
8
- const { data } = await db.from('users').select('id, email')
9
- expectTypeOf(data).toEqualTypeOf<{ id: string; email: string }[] | null>()
10
- })
11
-
12
- test('select embed many-to-one → objet imbriqué', async () => {
13
- // Contrat postgrest-js : la FK `posts.author_id` étant NOT NULL dans la Row,
14
- // l'embed many-to-one est non nullable (deviendrait `| null` si author_id: string | null).
15
- const { data } = await db.from('posts').select('title, author:users(email)')
16
- expectTypeOf(data).toEqualTypeOf<{ title: string; author: { email: string } }[] | null>()
17
- })
18
-
19
- test('single() → objet | null', async () => {
20
- const { data } = await db.from('users').select('id').single()
21
- expectTypeOf(data).toEqualTypeOf<{ id: string } | null>()
22
- })
23
-
24
- test('maybeSingle() → objet | null', async () => {
25
- const { data } = await db.from('users').select('email').maybeSingle()
26
- expectTypeOf(data).toEqualTypeOf<{ email: string } | null>()
27
- })
28
-
29
- test('select * → Row complète', async () => {
30
- const { data } = await db.from('users').select('*')
31
- expectTypeOf(data).toEqualTypeOf<{ id: string; email: string; bio: string | null }[] | null>()
32
- })
33
-
34
- test("client non typé (Database = any) → data permissif, pas d'erreur de compilation", async () => {
35
- const untyped = db as unknown as DatabaseService
36
- const { data } = await untyped.from('whatever').select('a, b')
37
- expectTypeOf(data).not.toBeNever()
38
- })
@@ -1,83 +0,0 @@
1
- // LOT 6 (I7 — vendoré sans tests type-level) : fixture dédiée aux tests de
2
- // régression sur le code vendoré (`select-query-parser/*`, `pgrst-types/*`).
3
- // Volontairement distincte de `tests/types/fixtures.ts` (utilisé par les tests
4
- // de `DatabaseService`/`QueryBuilder`) : celle-ci couvre en plus le cas
5
- // one-to-many (tableau) et un embed imbriqué sur 2 niveaux, nécessaires pour
6
- // tester `GetResult` directement (voir `get-result.test-d.ts`).
7
- export interface Database {
8
- public: {
9
- Tables: {
10
- users: {
11
- Row: { id: string; email: string }
12
- Insert: { id?: string; email: string }
13
- Update: { id?: string; email?: string }
14
- Relationships: []
15
- }
16
- // many-to-one NOT NULL : posts.author_id -> users.id
17
- posts: {
18
- Row: { id: string; author_id: string; title: string }
19
- Insert: { id?: string; author_id: string; title: string }
20
- Update: { id?: string; author_id?: string; title?: string }
21
- Relationships: [
22
- {
23
- foreignKeyName: 'posts_author_id_fkey'
24
- columns: ['author_id']
25
- isOneToOne: false
26
- referencedRelation: 'users'
27
- referencedColumns: ['id']
28
- },
29
- ]
30
- }
31
- // many-to-one NULLABLE : reviews.reviewer_id -> users.id (nullable)
32
- reviews: {
33
- Row: { id: string; reviewer_id: string | null; comment: string }
34
- Insert: { id?: string; reviewer_id?: string | null; comment: string }
35
- Update: { id?: string; reviewer_id?: string | null; comment?: string }
36
- Relationships: [
37
- {
38
- foreignKeyName: 'reviews_reviewer_id_fkey'
39
- columns: ['reviewer_id']
40
- isOneToOne: false
41
- referencedRelation: 'users'
42
- referencedColumns: ['id']
43
- },
44
- ]
45
- }
46
- // one-to-many (côté "many") : comments.post_id -> posts.id NOT NULL.
47
- // Embedder `comments` DEPUIS `posts` donne un tableau (voir get-result.test-d.ts).
48
- comments: {
49
- Row: { id: string; post_id: string; body: string }
50
- Insert: { id?: string; post_id: string; body: string }
51
- Update: { id?: string; post_id?: string; body?: string }
52
- Relationships: [
53
- {
54
- foreignKeyName: 'comments_post_id_fkey'
55
- columns: ['post_id']
56
- isOneToOne: false
57
- referencedRelation: 'posts'
58
- referencedColumns: ['id']
59
- },
60
- ]
61
- }
62
- // 2e niveau d'imbrication pour l'embed profond : replies.comment_id -> comments.id.
63
- replies: {
64
- Row: { id: string; comment_id: string; text: string }
65
- Insert: { id?: string; comment_id: string; text: string }
66
- Update: { id?: string; comment_id?: string; text?: string }
67
- Relationships: [
68
- {
69
- foreignKeyName: 'replies_comment_id_fkey'
70
- columns: ['comment_id']
71
- isOneToOne: false
72
- referencedRelation: 'comments'
73
- referencedColumns: ['id']
74
- },
75
- ]
76
- }
77
- }
78
- Views: Record<string, never>
79
- Functions: Record<string, never>
80
- Enums: Record<string, never>
81
- CompositeTypes: Record<string, never>
82
- }
83
- }
@@ -1,75 +0,0 @@
1
- // LOT 6 (I7 — vendoré sans tests type-level) : régression de forme sur le
2
- // résolveur vendoré (`GetResult`, `select-query-parser/*`), testé ICI
3
- // directement (pas via `DatabaseService`/`QueryBuilder`) pour détecter une
4
- // régression de comportement dès le prochain resync (voir VENDORED.md),
5
- // indépendamment de l'évolution du reste du query builder.
6
- //
7
- // Couvre les trois formes d'embed dont la nullabilité/l'arité diffère :
8
- // - many-to-one NOT NULL → objet non-null
9
- // - many-to-one NULLABLE → objet | null
10
- // - one-to-many → tableau
11
- // … plus l'aliasing (colonne scalaire + clé d'embed) et un embed imbriqué sur
12
- // 2 niveaux (tableau de tableaux correctement typé).
13
- import { expectTypeOf } from 'vitest'
14
- import type { GetResult } from '../../src/select-query-parser/result'
15
- import type { Database } from './fixtures'
16
-
17
- type Public = Database['public']
18
- // Même pin que `AuraClientOptionsT` (src/QueryBuilder.ts) — voir VENDORED.md
19
- // « PostgrestVersion figé à '12' ».
20
- type ClientOpts = { PostgrestVersion: '12' }
21
-
22
- type PostsRow = Public['Tables']['posts']['Row']
23
- type PostsRel = Public['Tables']['posts']['Relationships']
24
- type ReviewsRow = Public['Tables']['reviews']['Row']
25
- type ReviewsRel = Public['Tables']['reviews']['Relationships']
26
-
27
- test('embed many-to-one NOT NULL (posts.author_id -> users, NOT NULL) → objet non-null, clé aliasée', () => {
28
- type Result = GetResult<Public, PostsRow, 'posts', PostsRel, '*, author:users(email)', ClientOpts>
29
- expectTypeOf<Result>().toEqualTypeOf<{
30
- id: string
31
- author_id: string
32
- title: string
33
- author: { email: string }
34
- }>()
35
- })
36
-
37
- test('embed many-to-one NULLABLE (reviews.reviewer_id -> users, nullable) → objet | null', () => {
38
- type Result = GetResult<Public, ReviewsRow, 'reviews', ReviewsRel, '*, reviewer:users(email)', ClientOpts>
39
- expectTypeOf<Result>().toEqualTypeOf<{
40
- id: string
41
- reviewer_id: string | null
42
- comment: string
43
- reviewer: { email: string } | null
44
- }>()
45
- })
46
-
47
- test('embed one-to-many (posts -> comments, comments.post_id -> posts) → tableau', () => {
48
- type Result = GetResult<Public, PostsRow, 'posts', PostsRel, '*, comments(*)', ClientOpts>
49
- expectTypeOf<Result>().toEqualTypeOf<{
50
- id: string
51
- author_id: string
52
- title: string
53
- comments: { id: string; post_id: string; body: string }[]
54
- }>()
55
- })
56
-
57
- test('alias sur colonne scalaire', () => {
58
- type Result = GetResult<Public, PostsRow, 'posts', PostsRel, 'renamedTitle:title', ClientOpts>
59
- expectTypeOf<Result>().toEqualTypeOf<{ renamedTitle: string }>()
60
- })
61
-
62
- test('embed imbriqué 2 niveaux (posts -> comments -> replies) → forme correcte (tableau de tableaux)', () => {
63
- type Result = GetResult<Public, PostsRow, 'posts', PostsRel, '*, comments(*, replies(*))', ClientOpts>
64
- expectTypeOf<Result>().toEqualTypeOf<{
65
- id: string
66
- author_id: string
67
- title: string
68
- comments: {
69
- id: string
70
- post_id: string
71
- body: string
72
- replies: { id: string; comment_id: string; text: string }[]
73
- }[]
74
- }>()
75
- })
@@ -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'],
5
- format: ['cjs', 'esm'],
6
- dts: true,
7
- splitting: false,
8
- clean: true,
9
- treeshake: true,
10
- minify: false,
11
- })
@@ -1,8 +0,0 @@
1
- import { defineConfig } from 'vitest/config'
2
-
3
- export default defineConfig({
4
- test: {
5
- typecheck: { enabled: true, include: ['tests/**/*.test-d.ts'] },
6
- include: ['tests/**/*.test.ts'],
7
- },
8
- })
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Aurabase
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,96 +0,0 @@
1
- # @aurabase/functions
2
-
3
- Service d'invocation d'edge functions du SDK Aurabase : appel de fonctions avec enveloppe routée (méthode/chemin/headers), jobs asynchrones et cron.
4
-
5
- ![npm](https://img.shields.io/npm/v/@aurabase/functions) ![license](https://img.shields.io/badge/license-MIT-blue)
6
-
7
- > Pre-release — pas encore publié sur npm.
8
-
9
- Fait partie du SDK **[aurabase](../aurabase)**. Installé automatiquement avec `aurabase` ; ce package est publié séparément pour un usage ciblé / tree-shaking.
10
-
11
- ## Installation
12
-
13
- ```bash
14
- npm i @aurabase/functions
15
- ```
16
-
17
- > Ce package dépend de `@aurabase/core` (`workspace:*` en interne, résolu en semver côté npm). Si vous utilisez déjà le package `aurabase`, `@aurabase/functions` est déjà inclus — cette installation ciblée n'est utile que pour composer votre propre client ou limiter la taille du bundle.
18
-
19
- ## Usage
20
-
21
- Dans l'usage courant, `FunctionsService` n'est jamais instancié directement : il est exposé par le client principal sous `aura.functions`.
22
-
23
- ```ts
24
- import { createClient } from 'aurabase'
25
-
26
- const aura = createClient('http://localhost:8080', 'my-project', 'aura_anon_xxx')
27
- ```
28
-
29
- ### Invocation
30
-
31
- `invoke<T>()` enveloppe la requête (`{ method, path, headers, body }`) et dé-wrap la réponse JSON du backend — tout est bufferisé, pas de streaming (voir Limitations).
32
-
33
- ```ts
34
- const { data, error } = await aura.functions.invoke<{ ok: boolean }>('hello-world', {
35
- body: { name: 'Ada' },
36
- })
37
-
38
- if (error) throw error
39
- console.log(data!.ok)
40
- ```
41
-
42
- Options complètes : `method`, `path` (sous-route à l'intérieur de la fonction), `headers` (transmis à la fonction elle-même, pas des headers de transport), `signal`, `timeout`.
43
-
44
- ```ts
45
- const controller = new AbortController()
46
-
47
- const { error } = await aura.functions.invoke('slow-job', {
48
- method: 'POST',
49
- path: '/process',
50
- headers: { 'x-request-source': 'studio' },
51
- timeout: 5000, // ms — annule automatiquement au-delà
52
- signal: controller.signal, // ou : annulation manuelle via controller.abort()
53
- })
54
-
55
- // Une annulation (timeout ou signal) remonte toujours en AuraError code 'timeout'.
56
- if (error?.code === 'timeout') {
57
- console.warn('invocation annulée ou trop lente')
58
- }
59
- ```
60
-
61
- ### Fonctions (métadonnées)
62
-
63
- ```ts
64
- const { data: fns } = await aura.functions.list()
65
- const { data: fn } = await aura.functions.get(fns![0]!.id)
66
- ```
67
-
68
- ### Jobs asynchrones (extra vs `@supabase/functions-js`)
69
-
70
- ```ts
71
- const { data: jobs } = await aura.functions.listJobs({ status: 'pending', limit: 20 })
72
- const { data: job } = await aura.functions.getJob(jobs![0]!.id)
73
- ```
74
-
75
- ### Cron (extra vs `@supabase/functions-js`)
76
-
77
- ```ts
78
- await aura.functions.createCronJob('nightly-cleanup', '0 3 * * *', 'cleanup-fn', {
79
- payload: { dryRun: false },
80
- })
81
-
82
- const { data: crons } = await aura.functions.listCronJobs()
83
- await aura.functions.deleteCronJob('nightly-cleanup')
84
- ```
85
-
86
- ## Limitations
87
-
88
- - Pas de streaming de réponse : `invoke()` bufferise toujours l'intégralité du corps JSON avant de résoudre (pas de lecture incrémentale, pas de réponse SSE/chunked exploitable).
89
- - Pas de `responseType` (`json`/`text`/`blob`) : la réponse est toujours parsée comme JSON puis dé-wrappée (`{data}` → contenu).
90
- - Pas de sélection de région d'exécution.
91
- - `headers` est transmis tel quel à la fonction invoquée — ce ne sont pas des headers de transport HTTP (pas de contrôle sur ceux injectés par le pipeline : `apikey`, `Authorization`, `Content-Type`).
92
- - Pas de `getCronJob()` ni `updateCronJob()` : seuls `listCronJobs`, `createCronJob` et `deleteCronJob` sont exposés.
93
-
94
- ## Documentation
95
-
96
- Référence complète du SDK (tous les services, types partagés, SSR) : [README racine](../../README.md).
@@ -1,173 +0,0 @@
1
- 'use strict';
2
-
3
- var core = require('@aurabase/core');
4
-
5
- // src/FunctionsService.ts
6
- var RELAY_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
7
- function isRelayStatus(status) {
8
- return status === 0 || RELAY_STATUSES.has(status);
9
- }
10
- var FunctionsHttpError = class _FunctionsHttpError extends core.AuraError {
11
- context;
12
- constructor(status, body, context) {
13
- super(status, body);
14
- this.name = "FunctionsHttpError";
15
- this.context = context;
16
- Object.setPrototypeOf(this, _FunctionsHttpError.prototype);
17
- }
18
- };
19
- var FunctionsRelayError = class _FunctionsRelayError extends core.AuraError {
20
- context;
21
- constructor(status, body, context) {
22
- super(status, body);
23
- this.name = "FunctionsRelayError";
24
- this.context = context;
25
- Object.setPrototypeOf(this, _FunctionsRelayError.prototype);
26
- }
27
- };
28
- function toFunctionsError(err, context) {
29
- const body = err.details != null ? err.details : { error: { code: err.code, message: err.message } };
30
- return isRelayStatus(err.status) ? new FunctionsRelayError(err.status, body, err.details) : new FunctionsHttpError(err.status, body, err.details);
31
- }
32
-
33
- // src/FunctionsService.ts
34
- var FunctionsService = class extends core.BaseService {
35
- constructor(client) {
36
- super(client);
37
- }
38
- get prefix() {
39
- return `/v1/functions/${this.client.projectId}`;
40
- }
41
- // -- Function invocation ----------------------------------------------------
42
- /**
43
- * Invoque une edge function.
44
- *
45
- * `responseType` (parité `@supabase/functions-js`, défaut `'json'`) :
46
- * - `'json'` : chemin PIPELINE inchangé (refresh proactif centralisé, injection
47
- * apikey/Authorization, dé-wrapping `{data,meta}`, retryConfig). Non-régression.
48
- * - `'text' | 'blob' | 'arrayBuffer'` : chemin TRANSPORT BRUT `client.fetchFn`
49
- * (patron `StorageService`, SANS toucher `core/fetch.ts`) — refresh proactif
50
- * manuel, pose de `Authorization`/`apikey`, puis `res.text()/blob()/arrayBuffer()`
51
- * sans dé-wrapping (le corps HTTP est renvoyé tel quel).
52
- *
53
- * Erreurs typées (parité) : une réponse HTTP non-2xx → `FunctionsHttpError`, une
54
- * panne de relais/infra (réseau, 502/503/504) → `FunctionsRelayError` ; les deux
55
- * sous-classent `AuraError` (rétrocompat `isAuraError`/champ `error`). `timeout`/
56
- * `signal` continuent de produire le code `timeout`.
57
- */
58
- async invoke(slug, options) {
59
- const controller = new AbortController();
60
- let timeoutId;
61
- const userSignal = options?.signal;
62
- const onAbort = () => controller.abort();
63
- if (options?.timeout) timeoutId = setTimeout(() => controller.abort(), options.timeout);
64
- if (userSignal) {
65
- if (userSignal.aborted) controller.abort();
66
- else userSignal.addEventListener("abort", onAbort, { once: true });
67
- }
68
- const cleanup = () => {
69
- if (timeoutId) clearTimeout(timeoutId);
70
- if (userSignal) userSignal.removeEventListener("abort", onAbort);
71
- };
72
- const envelope = { method: options?.method, path: options?.path, headers: options?.headers, body: options?.body };
73
- const responseType = options?.responseType ?? "json";
74
- const timeoutError = () => ({
75
- data: null,
76
- error: new core.AuraError(0, {
77
- error: { code: "timeout", message: "Function invocation aborted or timed out" }
78
- })
79
- });
80
- try {
81
- if (responseType === "json") {
82
- const res2 = await this.request("POST", `${this.prefix}/${slug}/invoke`, envelope, {
83
- signal: controller.signal
84
- });
85
- if (res2.error && controller.signal.aborted) return timeoutError();
86
- if (res2.error) return { data: null, error: toFunctionsError(res2.error) };
87
- return res2;
88
- }
89
- const client = this.client;
90
- const store = client.authStore;
91
- if (store.token && store.refreshToken && core.isTokenExpired(store.token, 30)) {
92
- await core.refreshOnce(client);
93
- }
94
- const headers = {
95
- "Content-Type": "application/json",
96
- // Négocie le mode passthrough côté backend : réponse HTTP BRUTE (statut réel de la
97
- // fonction + content-type réel + corps brut) au lieu de l'enveloppe `{data,meta}`.
98
- // Indispensable pour que `res.text()/blob()/arrayBuffer()` reçoive le corps de la
99
- // fonction (et non l'enveloppe JSON) et que `res.status` porte le statut fonction.
100
- "X-Aurabase-Invoke-Mode": "raw"
101
- };
102
- if (store.token) headers["Authorization"] = `Bearer ${store.token}`;
103
- if (client.apiKey) headers["apikey"] = client.apiKey;
104
- const res = await client.fetchFn(this.url(`${this.prefix}/${slug}/invoke`), {
105
- method: "POST",
106
- headers,
107
- body: JSON.stringify(envelope),
108
- signal: controller.signal
109
- });
110
- if (!res.ok) {
111
- let parsed = null;
112
- try {
113
- parsed = await res.json();
114
- } catch {
115
- }
116
- return { data: null, error: toFunctionsError(new core.AuraError(res.status, parsed)) };
117
- }
118
- let data;
119
- if (responseType === "text") data = await res.text();
120
- else if (responseType === "blob") data = await res.blob();
121
- else data = await res.arrayBuffer();
122
- return { data, error: null };
123
- } catch (err) {
124
- if (controller.signal.aborted || core.isAbortError(err)) return timeoutError();
125
- return {
126
- data: null,
127
- error: new FunctionsRelayError(0, {
128
- error: { code: "network_error", message: err instanceof Error ? err.message : "Function relay error" }
129
- })
130
- };
131
- } finally {
132
- cleanup();
133
- }
134
- }
135
- // -- Function CRUD ----------------------------------------------------------
136
- async list() {
137
- return this.request("GET", `${this.prefix}`);
138
- }
139
- async get(id) {
140
- return this.request("GET", `${this.prefix}/${id}`);
141
- }
142
- // -- Jobs -------------------------------------------------------------------
143
- async listJobs(options) {
144
- const params = new URLSearchParams();
145
- if (options?.status) params.set("status", options.status);
146
- if (options?.limit !== void 0) params.set("limit", String(options.limit));
147
- const qs = params.toString() ? `?${params.toString()}` : "";
148
- return this.request("GET", `${this.prefix}/jobs${qs}`);
149
- }
150
- async getJob(jobId) {
151
- return this.request("GET", `${this.prefix}/jobs/${jobId}`);
152
- }
153
- // -- Cron -------------------------------------------------------------------
154
- async listCronJobs() {
155
- return this.request("GET", `${this.prefix}/cron`);
156
- }
157
- async createCronJob(name, schedule, functionName, options) {
158
- return this.request("POST", `${this.prefix}/cron`, {
159
- name,
160
- schedule,
161
- function_name: functionName,
162
- payload: options?.payload
163
- });
164
- }
165
- async deleteCronJob(name) {
166
- return this.request("DELETE", `${this.prefix}/cron/${name}`);
167
- }
168
- };
169
-
170
- exports.FunctionsHttpError = FunctionsHttpError;
171
- exports.FunctionsRelayError = FunctionsRelayError;
172
- exports.FunctionsService = FunctionsService;
173
- exports.isRelayStatus = isRelayStatus;