@donotdev/functions 0.1.44 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/README.md +25 -14
  2. package/lib/chunks/chunk-3F4BWKQD.js +22 -0
  3. package/lib/chunks/chunk-3F4BWKQD.js.map +7 -0
  4. package/lib/chunks/chunk-5IPULSUX.js +22 -0
  5. package/lib/chunks/chunk-5IPULSUX.js.map +7 -0
  6. package/lib/chunks/chunk-6USHTJED.js +22 -0
  7. package/lib/chunks/chunk-6USHTJED.js.map +7 -0
  8. package/lib/chunks/chunk-AYY7UXNI.js +22 -0
  9. package/lib/chunks/chunk-AYY7UXNI.js.map +7 -0
  10. package/lib/chunks/chunk-CXBSROEW.js +23 -0
  11. package/lib/chunks/chunk-CXBSROEW.js.map +7 -0
  12. package/lib/chunks/chunk-GYTCWMXV.js +22 -0
  13. package/lib/chunks/chunk-GYTCWMXV.js.map +7 -0
  14. package/lib/chunks/chunk-HLNYUAZH.js +22 -0
  15. package/lib/chunks/chunk-HLNYUAZH.js.map +7 -0
  16. package/lib/chunks/chunk-LCDLG4VG.js +151 -0
  17. package/lib/chunks/chunk-LCDLG4VG.js.map +7 -0
  18. package/lib/chunks/chunk-MQANUSY3.js +22 -0
  19. package/lib/chunks/chunk-MQANUSY3.js.map +7 -0
  20. package/lib/chunks/chunk-OFQVO3FD.js +22 -0
  21. package/lib/chunks/chunk-OFQVO3FD.js.map +7 -0
  22. package/lib/chunks/chunk-PWAGW4R6.js +22 -0
  23. package/lib/chunks/chunk-PWAGW4R6.js.map +7 -0
  24. package/lib/chunks/chunk-US2VOP4S.js +22 -0
  25. package/lib/chunks/chunk-US2VOP4S.js.map +7 -0
  26. package/lib/chunks/chunk-YTKDNZNW.js +22 -0
  27. package/lib/chunks/chunk-YTKDNZNW.js.map +7 -0
  28. package/lib/chunks/monitoring-E7JBYBHQ.js +22 -0
  29. package/lib/chunks/monitoring-E7JBYBHQ.js.map +7 -0
  30. package/lib/chunks/rateLimiter-SQISLOP5.js +22 -0
  31. package/lib/chunks/rateLimiter-SQISLOP5.js.map +7 -0
  32. package/lib/chunks/server-IQ5JNJOM.js +22 -0
  33. package/lib/chunks/server-IQ5JNJOM.js.map +7 -0
  34. package/lib/firebase/auth/getCustomClaims.d.ts +1 -1
  35. package/lib/firebase/auth/getUserAuthStatus.d.ts +1 -1
  36. package/lib/firebase/auth/index.d.ts +0 -0
  37. package/lib/firebase/auth/removeCustomClaims.d.ts +1 -1
  38. package/lib/firebase/auth/setCustomClaims.d.ts +1 -1
  39. package/lib/firebase/baseFunction.d.ts +1 -1
  40. package/lib/firebase/billing/cancelSubscription.d.ts +0 -0
  41. package/lib/firebase/billing/changePlan.d.ts +0 -0
  42. package/lib/firebase/billing/createCheckoutSession.d.ts +2 -2
  43. package/lib/firebase/billing/createCustomerPortal.d.ts +1 -1
  44. package/lib/firebase/billing/healthCheck.d.ts +0 -0
  45. package/lib/firebase/billing/index.d.ts +2 -1
  46. package/lib/firebase/billing/refreshSubscriptionStatus.d.ts +0 -8
  47. package/lib/firebase/billing/webhookHandler.d.ts +17 -2
  48. package/lib/firebase/config/constants.d.ts +0 -0
  49. package/lib/firebase/config/index.d.ts +0 -0
  50. package/lib/firebase/config/secrets.d.ts +0 -0
  51. package/lib/firebase/crud/aggregate.d.ts +0 -9
  52. package/lib/firebase/crud/bulk.d.ts +2 -2
  53. package/lib/firebase/crud/create.d.ts +1 -1
  54. package/lib/firebase/crud/delete.d.ts +1 -1
  55. package/lib/firebase/crud/get.d.ts +1 -1
  56. package/lib/firebase/crud/index.d.ts +0 -0
  57. package/lib/firebase/crud/list.d.ts +1 -1
  58. package/lib/firebase/crud/update.d.ts +1 -9
  59. package/lib/firebase/helpers/githubAccessHelper.d.ts +0 -0
  60. package/lib/firebase/helpers/githubTeamAccessHelper.d.ts +0 -0
  61. package/lib/firebase/helpers/index.d.ts +0 -0
  62. package/lib/firebase/index.d.ts +0 -0
  63. package/lib/firebase/index.js +1 -5
  64. package/lib/firebase/index.js.map +4 -4
  65. package/lib/firebase/oauth/disconnect.d.ts +0 -0
  66. package/lib/firebase/oauth/exchangeToken.d.ts +0 -0
  67. package/lib/firebase/oauth/getConnections.d.ts +0 -0
  68. package/lib/firebase/oauth/githubAccess.d.ts +2 -2
  69. package/lib/firebase/oauth/index.d.ts +0 -0
  70. package/lib/firebase/oauth/refreshToken.d.ts +0 -0
  71. package/lib/firebase/registerCrudFunctions.d.ts +9 -1
  72. package/lib/firebase/scheduled/checkExpiredSubscriptions.d.ts +0 -0
  73. package/lib/firebase/scheduled/index.d.ts +0 -0
  74. package/lib/shared/ai/classifyAIError.d.ts +0 -0
  75. package/lib/shared/ai/costTracker.d.ts +0 -0
  76. package/lib/shared/ai/createAIRoute.d.ts +0 -0
  77. package/lib/shared/ai/index.d.ts +0 -0
  78. package/lib/shared/ai/resolveModelTier.d.ts +0 -0
  79. package/lib/shared/billing/apiVersion.d.ts +22 -0
  80. package/lib/shared/billing/checkoutPrice.d.ts +27 -0
  81. package/lib/shared/billing/checkoutValidation.d.ts +89 -0
  82. package/lib/shared/billing/createCheckout.d.ts +73 -24
  83. package/lib/shared/billing/firestoreIdempotency.d.ts +13 -0
  84. package/lib/shared/billing/helpers/index.d.ts +0 -1
  85. package/lib/shared/billing/helpers/subscriptionManagement.d.ts +4 -4
  86. package/lib/shared/billing/helpers/updateUserSubscription.d.ts +2 -29
  87. package/lib/shared/billing/idempotency.d.ts +21 -10
  88. package/lib/shared/billing/idempotencyContract.d.ts +121 -0
  89. package/lib/shared/billing/index.d.ts +2 -0
  90. package/lib/shared/billing/orderWebhook.d.ts +75 -0
  91. package/lib/shared/billing/stripeClient.d.ts +45 -0
  92. package/lib/shared/billing/supabaseIdempotency.d.ts +32 -0
  93. package/lib/shared/billing/tierWebhookEvents.d.ts +54 -0
  94. package/lib/shared/billing/webhookHandler.d.ts +29 -20
  95. package/lib/shared/email/createEmailRoute.d.ts +0 -0
  96. package/lib/shared/email/index.d.ts +0 -0
  97. package/lib/shared/email/provider.d.ts +0 -0
  98. package/lib/shared/email/resendProvider.d.ts +0 -0
  99. package/lib/shared/errorHandling.d.ts +0 -0
  100. package/lib/shared/firebase.d.ts +0 -0
  101. package/lib/shared/github.d.ts +0 -0
  102. package/lib/shared/index.d.ts +0 -0
  103. package/lib/shared/index.js +1 -6
  104. package/lib/shared/index.js.map +4 -4
  105. package/lib/shared/logger.d.ts +0 -0
  106. package/lib/shared/metadata.d.ts +0 -0
  107. package/lib/shared/oauth/exchangeToken.d.ts +0 -0
  108. package/lib/shared/oauth/grantAccess.d.ts +0 -0
  109. package/lib/shared/oauth/index.d.ts +0 -0
  110. package/lib/shared/schema.d.ts +0 -0
  111. package/lib/shared/utils/detectFirestore.d.ts +0 -0
  112. package/lib/shared/utils/external/date.d.ts +0 -0
  113. package/lib/shared/utils/external/index.d.ts +0 -0
  114. package/lib/shared/utils/external/references.d.ts +0 -0
  115. package/lib/shared/utils/external/subscription.d.ts +0 -0
  116. package/lib/shared/utils/firebaseHelpers.d.ts +0 -0
  117. package/lib/shared/utils/functionWrapper.d.ts +1 -1
  118. package/lib/shared/utils/index.d.ts +0 -0
  119. package/lib/shared/utils/internal/auth.d.ts +38 -1
  120. package/lib/shared/utils/internal/firebase.d.ts +0 -0
  121. package/lib/shared/utils/internal/idempotency.d.ts +0 -0
  122. package/lib/shared/utils/internal/index.d.ts +0 -0
  123. package/lib/shared/utils/internal/monitoring.d.ts +0 -0
  124. package/lib/shared/utils/internal/rateLimiter.d.ts +8 -0
  125. package/lib/shared/utils/internal/validation.d.ts +0 -8
  126. package/lib/shared/utils/schemaValidation.d.ts +1 -1
  127. package/lib/shared/utils/validation.d.ts +0 -0
  128. package/lib/shared/utils/vercelHelpers.d.ts +8 -0
  129. package/lib/shared/utils.d.ts +0 -56
  130. package/lib/shared/validation.d.ts +0 -0
  131. package/lib/supabase/ai/createAIFunction.d.ts +0 -0
  132. package/lib/supabase/auth/deleteAccount.d.ts +0 -0
  133. package/lib/supabase/auth/getCustomClaims.d.ts +0 -0
  134. package/lib/supabase/auth/getUserAuthStatus.d.ts +0 -0
  135. package/lib/supabase/auth/removeCustomClaims.d.ts +0 -0
  136. package/lib/supabase/auth/setCustomClaims.d.ts +0 -0
  137. package/lib/supabase/baseFunction.d.ts +1 -1
  138. package/lib/supabase/billing/cancelSubscription.d.ts +0 -0
  139. package/lib/supabase/billing/changePlan.d.ts +0 -0
  140. package/lib/supabase/billing/createCheckoutSession.d.ts +0 -0
  141. package/lib/supabase/billing/createCustomerPortal.d.ts +0 -0
  142. package/lib/supabase/billing/refreshSubscriptionStatus.d.ts +0 -0
  143. package/lib/supabase/billing/stripeWebhook.d.ts +34 -0
  144. package/lib/supabase/crud/aggregate.d.ts +0 -0
  145. package/lib/supabase/crud/bulk.d.ts +1 -1
  146. package/lib/supabase/crud/create.d.ts +0 -0
  147. package/lib/supabase/crud/delete.d.ts +0 -0
  148. package/lib/supabase/crud/entityStore.d.ts +71 -0
  149. package/lib/supabase/crud/get.d.ts +0 -0
  150. package/lib/supabase/crud/index.d.ts +2 -0
  151. package/lib/supabase/crud/list.d.ts +0 -8
  152. package/lib/supabase/crud/update.d.ts +0 -0
  153. package/lib/supabase/edgeFunction.d.ts +0 -0
  154. package/lib/supabase/email/createEmailFunction.d.ts +0 -0
  155. package/lib/supabase/helpers/authProvider.d.ts +5 -5
  156. package/lib/supabase/index.d.ts +11 -2
  157. package/lib/supabase/index.js +1 -3
  158. package/lib/supabase/index.js.map +4 -4
  159. package/lib/supabase/oauth/disconnect.d.ts +0 -0
  160. package/lib/supabase/oauth/exchangeToken.d.ts +0 -0
  161. package/lib/supabase/oauth/getConnections.d.ts +0 -0
  162. package/lib/supabase/oauth/index.d.ts +0 -0
  163. package/lib/supabase/oauth/refreshToken.d.ts +0 -0
  164. package/lib/supabase/registerCrudFunctions.d.ts +0 -0
  165. package/lib/supabase/utils/idempotency.d.ts +0 -0
  166. package/lib/supabase/utils/monitoring.d.ts +0 -0
  167. package/lib/supabase/utils/rateLimiter.d.ts +1 -1
  168. package/lib/vercel/api/ai/chat.d.ts +0 -9
  169. package/lib/vercel/api/ai/index.d.ts +0 -0
  170. package/lib/vercel/api/auth/get-custom-claims.d.ts +8 -0
  171. package/lib/vercel/api/auth/get-user-auth-status.d.ts +8 -0
  172. package/lib/vercel/api/auth/index.d.ts +0 -0
  173. package/lib/vercel/api/auth/remove-custom-claims.d.ts +8 -0
  174. package/lib/vercel/api/auth/set-custom-claims.d.ts +8 -0
  175. package/lib/vercel/api/billing/backend.d.ts +39 -0
  176. package/lib/vercel/api/billing/cancel.d.ts +8 -0
  177. package/lib/vercel/api/billing/change-plan.d.ts +9 -1
  178. package/lib/vercel/api/billing/create-checkout-session.d.ts +25 -6
  179. package/lib/vercel/api/billing/customer-portal.d.ts +8 -0
  180. package/lib/vercel/api/billing/index.d.ts +4 -2
  181. package/lib/vercel/api/billing/refresh-subscription-status.d.ts +19 -3
  182. package/lib/vercel/api/billing/webhook-handler.d.ts +25 -4
  183. package/lib/vercel/api/config/constants.d.ts +0 -0
  184. package/lib/vercel/api/config/firebase-admin.d.ts +8 -0
  185. package/lib/vercel/api/config/index.d.ts +0 -0
  186. package/lib/vercel/api/crud/bulk.d.ts +17 -0
  187. package/lib/vercel/api/crud/create.d.ts +8 -0
  188. package/lib/vercel/api/crud/delete.d.ts +8 -0
  189. package/lib/vercel/api/crud/get.d.ts +8 -0
  190. package/lib/vercel/api/crud/index.d.ts +0 -0
  191. package/lib/vercel/api/crud/list.d.ts +8 -0
  192. package/lib/vercel/api/crud/update.d.ts +8 -0
  193. package/lib/vercel/api/index.d.ts +0 -0
  194. package/lib/vercel/api/index.js +1 -3
  195. package/lib/vercel/api/index.js.map +4 -4
  196. package/lib/vercel/api/oauth/check-github-access.d.ts +8 -0
  197. package/lib/vercel/api/oauth/exchange-token.d.ts +8 -0
  198. package/lib/vercel/api/oauth/grant-github-access.d.ts +8 -0
  199. package/lib/vercel/api/oauth/index.d.ts +0 -0
  200. package/lib/vercel/api/oauth/revoke-github-access.d.ts +1 -1
  201. package/lib/vercel/api/utils/cors.d.ts +0 -0
  202. package/lib/vercel/baseFunction.d.ts +4 -1
  203. package/lib/vercel/supabaseAdmin.d.ts +22 -0
  204. package/package.json +25 -26
  205. package/src/firebase/auth/getCustomClaims.ts +4 -5
  206. package/src/firebase/auth/getUserAuthStatus.ts +4 -5
  207. package/src/firebase/auth/removeCustomClaims.ts +4 -5
  208. package/src/firebase/auth/setCustomClaims.ts +4 -5
  209. package/src/firebase/baseFunction.ts +4 -5
  210. package/src/firebase/billing/cancelSubscription.ts +2 -3
  211. package/src/firebase/billing/changePlan.ts +3 -8
  212. package/src/firebase/billing/createCheckoutSession.ts +31 -61
  213. package/src/firebase/billing/createCustomerPortal.ts +5 -6
  214. package/src/firebase/billing/healthCheck.ts +1 -1
  215. package/src/firebase/billing/index.ts +8 -1
  216. package/src/firebase/billing/refreshSubscriptionStatus.ts +3 -4
  217. package/src/firebase/billing/webhookHandler.ts +21 -5
  218. package/src/firebase/crud/__tests__/bulk.test.ts +11 -1
  219. package/src/firebase/crud/aggregate.ts +1 -2
  220. package/src/firebase/crud/bulk.ts +5 -6
  221. package/src/firebase/crud/create.ts +5 -6
  222. package/src/firebase/crud/delete.ts +4 -5
  223. package/src/firebase/crud/get.ts +4 -5
  224. package/src/firebase/crud/list.ts +4 -5
  225. package/src/firebase/crud/update.ts +5 -6
  226. package/src/firebase/oauth/githubAccess.ts +2 -3
  227. package/src/firebase/registerCrudFunctions.ts +2 -2
  228. package/src/shared/__tests__/auth.test.ts +0 -3
  229. package/src/shared/__tests__/bulkCore.test.ts +3 -2
  230. package/src/shared/__tests__/errorHandling.test.ts +2 -2
  231. package/src/shared/__tests__/idempotency.test.ts +282 -55
  232. package/src/shared/__tests__/internalValidation.test.ts +3 -42
  233. package/src/shared/__tests__/logger.test.ts +31 -0
  234. package/src/shared/__tests__/rateLimiter.test.ts +2 -8
  235. package/src/shared/__tests__/schemaValidation.test.ts +1 -1
  236. package/src/shared/__tests__/utils.test.ts +3 -2
  237. package/src/shared/__tests__/validation-env.test.ts +0 -0
  238. package/src/shared/ai/createAIRoute.ts +53 -30
  239. package/src/shared/billing/__tests__/checkoutValidation.test.ts +219 -0
  240. package/src/shared/billing/__tests__/createCheckout.compat.test.ts +349 -0
  241. package/src/shared/billing/__tests__/createCheckout.test.ts +454 -411
  242. package/src/shared/billing/__tests__/firestoreIdempotency.emulator.test.ts +92 -0
  243. package/src/shared/billing/__tests__/webhookCorrectness.test.ts +387 -0
  244. package/src/shared/billing/__tests__/webhookHandler.test.ts +370 -23
  245. package/src/shared/billing/apiVersion.ts +25 -0
  246. package/src/shared/billing/checkoutPrice.ts +125 -0
  247. package/src/shared/billing/checkoutValidation.ts +284 -0
  248. package/src/shared/billing/createCheckout.ts +332 -196
  249. package/src/shared/billing/firestoreIdempotency.ts +189 -0
  250. package/src/shared/billing/helpers/index.ts +0 -1
  251. package/src/shared/billing/helpers/subscriptionManagement.ts +8 -10
  252. package/src/shared/billing/helpers/updateUserSubscription.ts +3 -36
  253. package/src/shared/billing/idempotency.ts +104 -168
  254. package/src/shared/billing/idempotencyContract.ts +135 -0
  255. package/src/shared/billing/index.ts +2 -0
  256. package/src/shared/billing/orderWebhook.ts +269 -0
  257. package/src/shared/billing/stripeClient.ts +91 -0
  258. package/src/shared/billing/supabaseIdempotency.ts +228 -0
  259. package/src/shared/billing/tierWebhookEvents.ts +432 -0
  260. package/src/shared/billing/webhookHandler.ts +189 -386
  261. package/src/shared/logger.ts +4 -6
  262. package/src/shared/utils/external/subscription.ts +0 -0
  263. package/src/shared/utils/firebaseHelpers.ts +2 -3
  264. package/src/shared/utils/functionWrapper.ts +1 -2
  265. package/src/shared/utils/internal/auth.ts +55 -7
  266. package/src/shared/utils/internal/monitoring.ts +17 -9
  267. package/src/shared/utils/internal/rateLimiter.ts +14 -5
  268. package/src/shared/utils/internal/validation.ts +0 -18
  269. package/src/shared/utils/schemaValidation.ts +1 -2
  270. package/src/shared/utils/vercelHelpers.ts +3 -3
  271. package/src/shared/utils.ts +5 -99
  272. package/src/shared/validation.ts +1 -1
  273. package/src/supabase/__tests__/bulk.test.ts +3 -1
  274. package/src/supabase/__tests__/entityStore.test.ts +90 -0
  275. package/src/supabase/baseFunction.ts +1 -2
  276. package/src/supabase/billing/cancelSubscription.ts +1 -1
  277. package/src/supabase/billing/changePlan.ts +1 -1
  278. package/src/supabase/billing/createCheckoutSession.ts +11 -41
  279. package/src/supabase/billing/createCustomerPortal.ts +1 -1
  280. package/src/supabase/billing/refreshSubscriptionStatus.ts +2 -7
  281. package/src/supabase/billing/stripeWebhook.ts +79 -0
  282. package/src/supabase/crud/aggregate.ts +1 -1
  283. package/src/supabase/crud/bulk.ts +3 -7
  284. package/src/supabase/crud/create.ts +1 -1
  285. package/src/supabase/crud/entityStore.ts +240 -0
  286. package/src/supabase/crud/index.ts +8 -0
  287. package/src/supabase/crud/list.ts +2 -0
  288. package/src/supabase/crud/update.ts +1 -1
  289. package/src/supabase/helpers/authProvider.ts +6 -5
  290. package/src/supabase/index.ts +26 -0
  291. package/src/supabase/utils/rateLimiter.ts +2 -2
  292. package/src/vercel/__tests__/bulk.test.ts +24 -21
  293. package/src/vercel/__tests__/firebaseOptional.test.ts +64 -0
  294. package/src/vercel/api/ai/chat.ts +2 -1
  295. package/src/vercel/api/auth/get-custom-claims.ts +2 -3
  296. package/src/vercel/api/auth/get-user-auth-status.ts +2 -3
  297. package/src/vercel/api/auth/remove-custom-claims.ts +2 -3
  298. package/src/vercel/api/auth/set-custom-claims.ts +3 -3
  299. package/src/vercel/api/billing/backend.ts +72 -0
  300. package/src/vercel/api/billing/cancel.ts +2 -4
  301. package/src/vercel/api/billing/change-plan.ts +4 -5
  302. package/src/vercel/api/billing/create-checkout-session.ts +43 -73
  303. package/src/vercel/api/billing/customer-portal.ts +3 -5
  304. package/src/vercel/api/billing/index.ts +4 -2
  305. package/src/vercel/api/billing/refresh-subscription-status.ts +22 -7
  306. package/src/vercel/api/billing/webhook-handler.ts +32 -26
  307. package/src/vercel/api/config/firebase-admin.ts +2 -2
  308. package/src/vercel/api/crud/bulk.ts +6 -9
  309. package/src/vercel/api/crud/create.ts +6 -5
  310. package/src/vercel/api/crud/delete.ts +4 -3
  311. package/src/vercel/api/crud/get.ts +6 -5
  312. package/src/vercel/api/crud/list.ts +6 -5
  313. package/src/vercel/api/crud/update.ts +6 -5
  314. package/src/vercel/api/oauth/check-github-access.ts +5 -5
  315. package/src/vercel/api/oauth/exchange-token.ts +3 -3
  316. package/src/vercel/api/oauth/grant-github-access.ts +5 -5
  317. package/src/vercel/api/oauth/revoke-github-access.ts +3 -4
  318. package/src/vercel/baseFunction.ts +23 -8
  319. package/src/vercel/supabaseAdmin.ts +45 -0
  320. package/lib/shared/ai/createAIHandler.d.ts +0 -39
  321. package/lib/shared/ai/providers/anthropic.d.ts +0 -12
  322. package/lib/shared/ai/providers/google.d.ts +0 -10
  323. package/lib/shared/ai/providers/index.d.ts +0 -23
  324. package/lib/shared/ai/providers/openai.d.ts +0 -10
  325. package/lib/shared/ai/utils/parseSSE.d.ts +0 -22
@@ -4,30 +4,45 @@
4
4
  * @fileoverview Stripe webhook handler API
5
5
  * @description Vercel API route for handling Stripe webhook events
6
6
  *
7
- * @version 0.1.0
7
+ * @version 0.2.0
8
8
  * @since 0.0.1
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
 
12
- import { logger } from 'firebase-functions/v2';
12
+ import type { NextApiRequest, NextApiResponse } from 'next';
13
13
 
14
14
  import type { StripeBackConfig } from '@donotdev/core/server';
15
- import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
16
15
 
16
+ import { resolveBillingBackend } from './backend.js';
17
+ import type { VercelBillingOptions } from './backend.js';
17
18
  import { updateUserSubscription } from '../../../shared/billing/helpers/updateUserSubscription.js';
18
19
  import { processWebhook } from '../../../shared/billing/webhookHandler.js';
19
- import { stripe } from '../../../shared/utils.js';
20
-
21
- import type { NextApiRequest, NextApiResponse } from 'next';
20
+ import { logger } from '../../../shared/logger.js';
21
+ import { stripe } from '../../../shared/billing/stripeClient.js';
22
22
 
23
23
  /**
24
- * Create Vercel webhook handler from billing config
24
+ * Create Vercel webhook handler from billing config.
25
+ * Idempotency storage and user claims follow `options.backend`.
26
+ * Any failure answers non-2xx so Stripe retries the event.
25
27
  *
26
- * @version 0.1.0
28
+ * @example
29
+ * ```typescript
30
+ * // api/billing/stripe-webhook.ts
31
+ * import { createStripeWebhook } from '@donotdev/functions/vercel';
32
+ * import { billingConfig } from '../../config/billing';
33
+ *
34
+ * export const config = { api: { bodyParser: false } };
35
+ * export default createStripeWebhook(billingConfig, { backend: 'supabase' });
36
+ * ```
37
+ *
38
+ * @version 0.2.0
27
39
  * @since 0.0.1
28
40
  * @author AMBROISE PARK Consulting
29
41
  */
30
- export function createStripeWebhook(billingConfig: StripeBackConfig) {
42
+ export function createStripeWebhook(
43
+ billingConfig: StripeBackConfig,
44
+ options: VercelBillingOptions
45
+ ) {
31
46
  return async (req: NextApiRequest, res: NextApiResponse) => {
32
47
  if (req.method !== 'POST') {
33
48
  res.status(405).json({ error: 'Method not allowed' });
@@ -55,20 +70,9 @@ export function createStripeWebhook(billingConfig: StripeBackConfig) {
55
70
  // Get raw body
56
71
  const rawBody = await getRawBody(req);
57
72
 
58
- // C5: Build a proper authProvider so subscription webhook events can activate.
59
- // null was previously passed which caused processWebhook to throw on every
60
- // checkout.session.completed / invoice.payment_succeeded event.
61
- const authProvider = {
62
- async getUser(userId: string) {
63
- return getFirebaseAdminAuth().getUser(userId);
64
- },
65
- async setCustomUserClaims(
66
- userId: string,
67
- claims: Record<string, unknown>
68
- ) {
69
- await getFirebaseAdminAuth().setCustomUserClaims(userId, claims);
70
- },
71
- };
73
+ const { authProvider, idempotencyStore } = await resolveBillingBackend(
74
+ options.backend
75
+ );
72
76
 
73
77
  // Call shared algorithm
74
78
  await processWebhook(
@@ -78,13 +82,15 @@ export function createStripeWebhook(billingConfig: StripeBackConfig) {
78
82
  stripe,
79
83
  billingConfig,
80
84
  updateUserSubscription,
81
- authProvider
85
+ authProvider,
86
+ idempotencyStore
82
87
  );
83
88
 
84
89
  res.status(200).json({ received: true });
85
90
  } catch (error) {
86
- logger.error('Vercel webhook error', {
87
- error: error instanceof Error ? error.message : String(error),
91
+ logger.error('[Vercel Webhook] Error', {
92
+ error: error instanceof Error ? error : new Error(String(error)),
93
+ operation: 'webhook_processing',
88
94
  });
89
95
  res.status(400).json({
90
96
  error: 'Webhook processing failed',
@@ -9,8 +9,6 @@
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
 
12
- import { getFirebaseAdminApp } from '@donotdev/firebase/server';
13
-
14
12
  import type { App } from 'firebase-admin/app';
15
13
 
16
14
  /**
@@ -22,6 +20,7 @@ import type { App } from 'firebase-admin/app';
22
20
  * @author AMBROISE PARK Consulting
23
21
  */
24
22
  export async function initializeFirebaseAdmin(): Promise<App> {
23
+ const { getFirebaseAdminApp } = await import('@donotdev/firebase/server');
25
24
  return await getFirebaseAdminApp();
26
25
  }
27
26
 
@@ -34,5 +33,6 @@ export async function initializeFirebaseAdmin(): Promise<App> {
34
33
  * @author AMBROISE PARK Consulting
35
34
  */
36
35
  export async function getFirebaseAdmin(): Promise<App> {
36
+ const { getFirebaseAdminApp } = await import('@donotdev/firebase/server');
37
37
  return await getFirebaseAdminApp();
38
38
  }
@@ -18,6 +18,7 @@
18
18
  * @author AMBROISE PARK Consulting
19
19
  */
20
20
 
21
+ import type { NextApiRequest, NextApiResponse } from 'next';
21
22
  import * as v from 'valibot';
22
23
 
23
24
  import {
@@ -26,20 +27,14 @@ import {
26
27
  BulkRequestSchema,
27
28
  } from '@donotdev/core/server';
28
29
  import type { BulkRequest, BulkResponse } from '@donotdev/core/server';
29
- import { getFirebaseAdminFirestore } from '@donotdev/firebase/server';
30
30
 
31
+ import { executeBulk } from '../../../shared/crud/bulkCore.js';
31
32
  import { handleError } from '../../../shared/errorHandling.js';
32
- import {
33
- createMetadata,
34
- executeBulk,
35
- prepareForFirestore,
36
- updateMetadata,
37
- } from '../../../shared/index.js';
33
+ import { prepareForFirestore } from '../../../shared/firebase.js';
34
+ import { createMetadata, updateMetadata } from '../../../shared/metadata.js';
38
35
  import { verifyAuthToken } from '../../../shared/utils/internal/auth.js';
39
36
  import { validateCollectionName } from '../../../shared/utils.js';
40
37
 
41
- import type { NextApiRequest, NextApiResponse } from 'next';
42
-
43
38
  /**
44
39
  * Pass-through row schema — the bulk endpoint is URL-routed and does not
45
40
  * carry entity schemas on the wire, so per-row validation reduces to the
@@ -114,6 +109,8 @@ export default async function handler(
114
109
  }
115
110
  const ops: BulkRequest = parseResult.output;
116
111
 
112
+ const { getFirebaseAdminFirestore } =
113
+ await import('@donotdev/firebase/server');
117
114
  const response: BulkResponse = await executeBulk({
118
115
  collection: collection as string,
119
116
  ops,
@@ -9,23 +9,22 @@
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
 
12
+ import type { NextApiRequest, NextApiResponse } from 'next';
13
+
12
14
  import type { CreateEntityData } from '@donotdev/core/server';
13
- import { getFirebaseAdminFirestore } from '@donotdev/firebase/server';
14
15
 
15
16
  import { handleError } from '../../../shared/errorHandling.js';
16
17
  import {
17
18
  prepareForFirestore,
18
19
  transformFirestoreData,
19
- } from '../../../shared/index.js';
20
- import { createMetadata } from '../../../shared/index.js';
20
+ } from '../../../shared/firebase.js';
21
+ import { createMetadata } from '../../../shared/metadata.js';
21
22
  import { verifyAuthToken } from '../../../shared/utils/internal/auth.js';
22
23
  import {
23
24
  validateCollectionName,
24
25
  validateDocument,
25
26
  } from '../../../shared/utils.js';
26
27
 
27
- import type { NextApiRequest, NextApiResponse } from 'next';
28
-
29
28
  export default async function handler(
30
29
  req: NextApiRequest,
31
30
  res: NextApiResponse
@@ -68,6 +67,8 @@ export default async function handler(
68
67
  };
69
68
 
70
69
  // Save the document to Firestore
70
+ const { getFirebaseAdminFirestore } =
71
+ await import('@donotdev/firebase/server');
71
72
  const db = getFirebaseAdminFirestore();
72
73
  const docRef = await db
73
74
  .collection(schema.metadata.collection)
@@ -9,15 +9,14 @@
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
 
12
+ import type { NextApiRequest, NextApiResponse } from 'next';
13
+
12
14
  import type { GetEntityData } from '@donotdev/core/server';
13
- import { getFirebaseAdminFirestore } from '@donotdev/firebase/server';
14
15
 
15
16
  import { handleError } from '../../../shared/errorHandling.js';
16
17
  import { verifyAuthToken } from '../../../shared/utils/internal/auth.js';
17
18
  import { validateCollectionName } from '../../../shared/utils.js';
18
19
 
19
- import type { NextApiRequest, NextApiResponse } from 'next';
20
-
21
20
  export default async function handler(
22
21
  req: NextApiRequest,
23
22
  res: NextApiResponse
@@ -40,6 +39,8 @@ export default async function handler(
40
39
  validateCollectionName(schema.metadata.collection);
41
40
 
42
41
  // Check if document exists
42
+ const { getFirebaseAdminFirestore } =
43
+ await import('@donotdev/firebase/server');
43
44
  const db = getFirebaseAdminFirestore();
44
45
  const doc = await db.collection(schema.metadata.collection).doc(id).get();
45
46
 
@@ -9,18 +9,17 @@
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
 
12
+ import type { NextApiRequest, NextApiResponse } from 'next';
13
+
12
14
  import { HIDDEN_STATUSES } from '@donotdev/core/server';
13
15
  import type { GetEntityData } from '@donotdev/core/server';
14
- import { getFirebaseAdminFirestore } from '@donotdev/firebase/server';
15
16
 
16
17
  import { handleError } from '../../../shared/errorHandling.js';
17
- import { transformFirestoreData } from '../../../shared/index.js';
18
- import { filterVisibleFields } from '../../../shared/index.js';
18
+ import { transformFirestoreData } from '../../../shared/firebase.js';
19
+ import { filterVisibleFields } from '../../../shared/schema.js';
19
20
  import { verifyAuthToken } from '../../../shared/utils/internal/auth.js';
20
21
  import { validateCollectionName } from '../../../shared/utils.js';
21
22
 
22
- import type { NextApiRequest, NextApiResponse } from 'next';
23
-
24
23
  export default async function handler(
25
24
  req: NextApiRequest,
26
25
  res: NextApiResponse
@@ -48,6 +47,8 @@ export default async function handler(
48
47
  validateCollectionName(schema.metadata.collection);
49
48
 
50
49
  // Get the document from Firestore
50
+ const { getFirebaseAdminFirestore } =
51
+ await import('@donotdev/firebase/server');
51
52
  const db = getFirebaseAdminFirestore();
52
53
  const doc = await db
53
54
  .collection(schema.metadata.collection)
@@ -9,18 +9,17 @@
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
 
12
+ import type { NextApiRequest, NextApiResponse } from 'next';
13
+
12
14
  import { HIDDEN_STATUSES } from '@donotdev/core/server';
13
15
  import type { ListEntityData } from '@donotdev/core/server';
14
- import { getFirebaseAdminFirestore } from '@donotdev/firebase/server';
15
16
 
16
17
  import { handleError } from '../../../shared/errorHandling.js';
17
- import { transformFirestoreData } from '../../../shared/index.js';
18
- import { filterVisibleFields } from '../../../shared/index.js';
18
+ import { transformFirestoreData } from '../../../shared/firebase.js';
19
+ import { filterVisibleFields } from '../../../shared/schema.js';
19
20
  import { verifyAuthToken } from '../../../shared/utils/internal/auth.js';
20
21
  import { validateCollectionName } from '../../../shared/utils.js';
21
22
 
22
- import type { NextApiRequest, NextApiResponse } from 'next';
23
-
24
23
  export default async function handler(
25
24
  req: NextApiRequest,
26
25
  res: NextApiResponse
@@ -50,6 +49,8 @@ export default async function handler(
50
49
  validateCollectionName(schema.metadata.collection);
51
50
 
52
51
  // Get documents from Firestore
52
+ const { getFirebaseAdminFirestore } =
53
+ await import('@donotdev/firebase/server');
53
54
  const db = getFirebaseAdminFirestore();
54
55
  let query: FirebaseFirestore.Query<FirebaseFirestore.DocumentData> =
55
56
  db.collection(schema.metadata.collection);
@@ -9,24 +9,23 @@
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
 
12
+ import type { NextApiRequest, NextApiResponse } from 'next';
13
+
12
14
  import { DEFAULT_STATUS_VALUE } from '@donotdev/core/server';
13
15
  import type { UpdateEntityData } from '@donotdev/core/server';
14
- import { getFirebaseAdminFirestore } from '@donotdev/firebase/server';
15
16
 
16
17
  import { handleError } from '../../../shared/errorHandling.js';
17
18
  import {
18
19
  prepareForFirestore,
19
20
  transformFirestoreData,
20
- } from '../../../shared/index.js';
21
- import { updateMetadata } from '../../../shared/index.js';
21
+ } from '../../../shared/firebase.js';
22
+ import { updateMetadata } from '../../../shared/metadata.js';
22
23
  import { verifyAuthToken } from '../../../shared/utils/internal/auth.js';
23
24
  import {
24
25
  validateCollectionName,
25
26
  validateDocument,
26
27
  } from '../../../shared/utils.js';
27
28
 
28
- import type { NextApiRequest, NextApiResponse } from 'next';
29
-
30
29
  export default async function handler(
31
30
  req: NextApiRequest,
32
31
  res: NextApiResponse
@@ -48,6 +47,8 @@ export default async function handler(
48
47
  // W22: Validate collection name from client-supplied schema
49
48
  validateCollectionName(schema.metadata.collection);
50
49
 
50
+ const { getFirebaseAdminFirestore } =
51
+ await import('@donotdev/firebase/server');
51
52
  const db = getFirebaseAdminFirestore();
52
53
 
53
54
  // Get current document to merge with payload for status check
@@ -9,18 +9,17 @@
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
 
12
+ import type { NextApiRequest, NextApiResponse } from 'next';
13
+ import type * as v from 'valibot';
14
+
12
15
  import {
13
16
  checkGitHubAccessSchema,
14
17
  type CheckGitHubAccessRequest,
15
18
  } from '@donotdev/core/server';
16
- import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
17
19
 
18
- import { GitHubApiService } from '../../../shared/index.js';
20
+ import { GitHubApiService } from '../../../shared/github.js';
19
21
  import { createVercelBaseFunction } from '../../baseFunction.js';
20
22
 
21
- import type { NextApiRequest, NextApiResponse } from 'next';
22
- import type * as v from 'valibot';
23
-
24
23
  /**
25
24
  * Business logic for checking GitHub access
26
25
  * Base function handles: validation, auth, rate limiting, monitoring
@@ -63,6 +62,7 @@ async function checkGitHubAccessLogic(
63
62
  );
64
63
 
65
64
  // Also check custom claims for access record
65
+ const { getFirebaseAdminAuth } = await import('@donotdev/firebase/server');
66
66
  const user = await getFirebaseAdminAuth().getUser(userId);
67
67
  const customClaims = user.customClaims || {};
68
68
  const githubAccess =
@@ -9,6 +9,9 @@
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
 
12
+ import type { NextApiRequest, NextApiResponse } from 'next';
13
+ import type * as v from 'valibot';
14
+
12
15
  import {
13
16
  OAUTH_PARTNERS,
14
17
  exchangeTokenSchema,
@@ -22,9 +25,6 @@ import {
22
25
  } from '../../../shared/utils.js';
23
26
  import { createVercelBaseFunction } from '../../baseFunction.js';
24
27
 
25
- import type { NextApiRequest, NextApiResponse } from 'next';
26
- import type * as v from 'valibot';
27
-
28
28
  /** Validate Mastodon instance URL to prevent SSRF */
29
29
  function validateInstanceUrl(url: string): void {
30
30
  const parsed = new URL(url);
@@ -9,18 +9,17 @@
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
 
12
+ import type { NextApiRequest, NextApiResponse } from 'next';
13
+ import type * as v from 'valibot';
14
+
12
15
  import {
13
16
  grantGitHubAccessSchema,
14
17
  type GrantGitHubAccessRequest,
15
18
  } from '@donotdev/core/server';
16
- import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
17
19
 
18
- import { GitHubApiService } from '../../../shared/index.js';
20
+ import { GitHubApiService } from '../../../shared/github.js';
19
21
  import { createVercelBaseFunction } from '../../baseFunction.js';
20
22
 
21
- import type { NextApiRequest, NextApiResponse } from 'next';
22
- import type * as v from 'valibot';
23
-
24
23
  /**
25
24
  * Business logic for granting GitHub access
26
25
  * Base function handles: validation, auth, rate limiting, monitoring
@@ -70,6 +69,7 @@ async function grantGitHubAccessLogic(
70
69
 
71
70
  // Update user's custom claims if provided
72
71
  if (customClaims) {
72
+ const { getFirebaseAdminAuth } = await import('@donotdev/firebase/server');
73
73
  const user = await getFirebaseAdminAuth().getUser(userId);
74
74
  const updatedClaims = {
75
75
  ...user.customClaims,
@@ -9,20 +9,18 @@
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
 
12
+ import type { NextApiRequest, NextApiResponse } from 'next';
12
13
  import * as v from 'valibot';
13
14
 
14
15
  import {
15
16
  revokeGitHubAccessSchema,
16
17
  type RevokeGitHubAccessRequest,
17
18
  } from '@donotdev/core/server';
18
- import { getFirebaseAdminAuth } from '@donotdev/firebase/server';
19
19
 
20
20
  import { handleError } from '../../../shared/errorHandling.js';
21
- import { GitHubApiService } from '../../../shared/index.js';
21
+ import { GitHubApiService } from '../../../shared/github.js';
22
22
  import { verifyAuthToken } from '../../../shared/utils/internal/auth.js';
23
23
 
24
- import type { NextApiRequest, NextApiResponse } from 'next';
25
-
26
24
  export default async function handler(
27
25
  req: NextApiRequest,
28
26
  res: NextApiResponse,
@@ -86,6 +84,7 @@ export default async function handler(
86
84
  }
87
85
 
88
86
  // Remove from user's custom claims
87
+ const { getFirebaseAdminAuth } = await import('@donotdev/firebase/server');
89
88
  const user = await getFirebaseAdminAuth().getUser(userId);
90
89
  const customClaims = user.customClaims || {};
91
90
 
@@ -9,25 +9,32 @@
9
9
  * @author AMBROISE PARK Consulting
10
10
  */
11
11
 
12
+ import type { NextApiRequest, NextApiResponse } from 'next';
12
13
  import * as v from 'valibot';
13
14
 
14
15
  import type { SecurityContext } from '@donotdev/core';
15
16
 
17
+ import { getSupabaseAdmin } from './supabaseAdmin.js';
16
18
  import { handleError, DoNotDevError } from '../shared/errorHandling.js';
17
- import { verifyAuthToken } from '../shared/utils/internal/auth.js';
19
+ import {
20
+ parseAuthBackend,
21
+ verifyAuthToken,
22
+ } from '../shared/utils/internal/auth.js';
23
+ import type { AuthProvider } from '../shared/utils/internal/auth.js';
18
24
  import { recordPaymentMetrics } from '../shared/utils/internal/monitoring.js';
19
25
  import {
20
26
  checkRateLimitWithFirestore,
21
27
  DEFAULT_RATE_LIMITS,
22
28
  } from '../shared/utils/internal/rateLimiter.js';
23
-
24
- import type { AuthProvider } from '../shared/utils/internal/auth.js';
25
- import type { NextApiRequest, NextApiResponse } from 'next';
29
+ import { checkRateLimitWithPostgres } from '../supabase/utils/rateLimiter.js';
26
30
 
27
31
  /**
28
32
  * Base Vercel function that handles all common concerns
29
33
  * Users just provide their business logic
30
34
  *
35
+ * @throws DoNotDevError (`invalid-argument`) at construction when `provider` is
36
+ * neither `'firebase'` nor `'supabase'`
37
+ *
31
38
  * @version 0.1.0
32
39
  * @since 0.0.1
33
40
  * @author AMBROISE PARK Consulting
@@ -48,6 +55,9 @@ export function createVercelBaseFunction<TRequest, TResponse>(
48
55
  /** Auth provider for token verification. Auto-detects via provider registry if omitted. */
49
56
  provider?: AuthProvider
50
57
  ) {
58
+ // Fail at route construction: an unknown backend must never run as Firebase
59
+ if (provider !== undefined) parseAuthBackend(provider);
60
+
51
61
  return async (
52
62
  req: NextApiRequest,
53
63
  res: NextApiResponse
@@ -77,10 +87,15 @@ export function createVercelBaseFunction<TRequest, TResponse>(
77
87
  const rateLimitKey = `${operation}_${uid}`;
78
88
  const rateLimitConfig =
79
89
  (DEFAULT_RATE_LIMITS as any)[operation] || DEFAULT_RATE_LIMITS.api;
80
- const rateLimitResult = await checkRateLimitWithFirestore(
81
- rateLimitKey,
82
- rateLimitConfig
83
- );
90
+ // Rate-limit storage follows the auth backend (Postgres for Supabase)
91
+ const rateLimitResult =
92
+ provider === 'supabase'
93
+ ? await checkRateLimitWithPostgres(
94
+ await getSupabaseAdmin(),
95
+ rateLimitKey,
96
+ rateLimitConfig
97
+ )
98
+ : await checkRateLimitWithFirestore(rateLimitKey, rateLimitConfig);
84
99
 
85
100
  if (!rateLimitResult.allowed) {
86
101
  security?.audit({
@@ -0,0 +1,45 @@
1
+ // packages/functions/src/vercel/supabaseAdmin.ts
2
+
3
+ /**
4
+ * @fileoverview Supabase admin client for Vercel functions
5
+ * @description Lazily created service-role client for Vercel functions backed by
6
+ * Supabase. `@supabase/supabase-js` is imported on first use only, so
7
+ * Firebase-backed deployments never load it.
8
+ *
9
+ * @version 0.2.0
10
+ * @since 0.2.0
11
+ * @author AMBROISE PARK Consulting
12
+ */
13
+
14
+ import type { SupabaseClient } from '@supabase/supabase-js';
15
+
16
+ let cached: SupabaseClient | null = null;
17
+
18
+ /**
19
+ * Get the service-role Supabase client (`SUPABASE_URL` + `SUPABASE_SECRET_KEY`
20
+ * or the legacy `SUPABASE_SERVICE_ROLE_KEY`).
21
+ *
22
+ * @throws When the environment variables are missing
23
+ *
24
+ * @version 0.2.0
25
+ * @since 0.2.0
26
+ * @author AMBROISE PARK Consulting
27
+ */
28
+ export async function getSupabaseAdmin(): Promise<SupabaseClient> {
29
+ if (cached) return cached;
30
+
31
+ const supabaseUrl = process.env.SUPABASE_URL;
32
+ const secretKey =
33
+ process.env.SUPABASE_SECRET_KEY || process.env.SUPABASE_SERVICE_ROLE_KEY;
34
+ if (!supabaseUrl || !secretKey) {
35
+ throw new Error(
36
+ 'Missing SUPABASE_URL or SUPABASE_SECRET_KEY/SUPABASE_SERVICE_ROLE_KEY environment variables'
37
+ );
38
+ }
39
+
40
+ const { createClient } = await import('@supabase/supabase-js');
41
+ cached = createClient(supabaseUrl, secretKey, {
42
+ auth: { autoRefreshToken: false, persistSession: false },
43
+ });
44
+ return cached;
45
+ }
@@ -1,39 +0,0 @@
1
- /**
2
- * @fileoverview AI Handler Algorithm
3
- * @description Platform-agnostic handler for AI chat requests.
4
- * Validates, rate limits (Upstash), dispatches to provider adapter.
5
- *
6
- * @version 0.2.0
7
- * @since 0.1.0
8
- * @author AMBROISE PARK Consulting
9
- */
10
- import type {
11
- AIChatRequest,
12
- AIChatResponse,
13
- AIProviderAdapter,
14
- AIRateLimitConfig,
15
- } from '@donotdev/core/server';
16
- /**
17
- * Handle an AI chat request (non-streaming).
18
- * Returns the full response as JSON.
19
- */
20
- export declare function handleAIChatRequest(
21
- request: AIChatRequest,
22
- adapter: AIProviderAdapter,
23
- options: {
24
- userId: string;
25
- rateLimitConfig?: AIRateLimitConfig;
26
- }
27
- ): Promise<AIChatResponse>;
28
- /**
29
- * Handle an AI chat request (streaming).
30
- * Returns an SSE Response for direct use in edge functions.
31
- */
32
- export declare function handleAIStreamRequest(
33
- request: AIChatRequest,
34
- adapter: AIProviderAdapter,
35
- options: {
36
- userId: string;
37
- rateLimitConfig?: AIRateLimitConfig;
38
- }
39
- ): Response;
@@ -1,12 +0,0 @@
1
- /**
2
- * @fileoverview Anthropic (Claude) Provider Adapter
3
- * @description fetch-based, no SDK. Normalizes to framework types.
4
- *
5
- * @version 0.1.0
6
- * @since 0.1.0
7
- * @author AMBROISE PARK Consulting
8
- */
9
- import type { AIProviderAdapter } from '@donotdev/core/server';
10
- export declare function createAnthropicAdapter(
11
- apiKey: string
12
- ): AIProviderAdapter;
@@ -1,10 +0,0 @@
1
- /**
2
- * @fileoverview Google (Gemini) Provider Adapter
3
- * @description fetch-based, no SDK. Normalizes to framework types.
4
- *
5
- * @version 0.1.0
6
- * @since 0.1.0
7
- * @author AMBROISE PARK Consulting
8
- */
9
- import type { AIProviderAdapter } from '@donotdev/core/server';
10
- export declare function createGoogleAdapter(apiKey: string): AIProviderAdapter;
@@ -1,23 +0,0 @@
1
- /**
2
- * @fileoverview AI Provider Factory
3
- * @description Creates the right adapter based on provider name.
4
- *
5
- * @version 0.1.0
6
- * @since 0.1.0
7
- * @author AMBROISE PARK Consulting
8
- */
9
- import type { AIProvider, AIProviderAdapter } from '@donotdev/core/server';
10
- /**
11
- * Get the provider adapter for the given provider name.
12
- *
13
- * @param provider - The AI provider ('anthropic', 'openai', 'google')
14
- * @param apiKey - The API key for the provider
15
- * @returns The provider adapter
16
- */
17
- export declare function getProviderAdapter(
18
- provider: AIProvider,
19
- apiKey: string
20
- ): AIProviderAdapter;
21
- export { createAnthropicAdapter } from './anthropic.js';
22
- export { createOpenAIAdapter } from './openai.js';
23
- export { createGoogleAdapter } from './google.js';
@@ -1,10 +0,0 @@
1
- /**
2
- * @fileoverview OpenAI (GPT) Provider Adapter
3
- * @description fetch-based, no SDK. Normalizes to framework types.
4
- *
5
- * @version 0.1.0
6
- * @since 0.1.0
7
- * @author AMBROISE PARK Consulting
8
- */
9
- import type { AIProviderAdapter } from '@donotdev/core/server';
10
- export declare function createOpenAIAdapter(apiKey: string): AIProviderAdapter;